index.b7bcfd90.js 636 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. var ll=Object.defineProperty,hl=Object.defineProperties;var fl=Object.getOwnPropertyDescriptors;var gr=Object.getOwnPropertySymbols;var Ea=Object.prototype.hasOwnProperty,Ra=Object.prototype.propertyIsEnumerable;var Ca=(t,e,n)=>e in t?ll(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,rt=(t,e)=>{for(var n in e||(e={}))Ea.call(e,n)&&Ca(t,n,e[n]);if(gr)for(var n of gr(e))Ra.call(e,n)&&Ca(t,n,e[n]);return t},In=(t,e)=>hl(t,fl(e));var Ta=(t,e)=>{var n={};for(var r in t)Ea.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&gr)for(var r of gr(t))e.indexOf(r)<0&&Ra.call(t,r)&&(n[r]=t[r]);return n};import{s as ge,r as Dt,a as pl}from"./index.4d543e6e.js";import{j as nu,n as as,d as Fe,i as Ur,f as S,l as Z,p as Dr,t as yo,u as Co,v as Ia,x as lt,y as ru,z as Eo,A as iu,B as gl,C as ml,D as ou,F as Fi,r as Pe,G as _l,H as vl,I as $r,J as yl,K as Cl,L as Hi,M as ji,N as $i}from"./vendor.3d4ad280.js";const El="_liveHeader_8nata_1",Rl="_liveLogo_8nata_12",Tl="_liveHeaderLeft_8nata_17",Sl="_liveHeaderLeftIcon_8nata_23",Il="_liveHeaderLeftText_8nata_27",bl="_avatarWrapper_8nata_30",Nl="_userAvatar_8nata_37";var Vt={liveHeader:El,liveLogo:Rl,liveHeaderLeft:Tl,liveHeaderLeftIcon:Sl,liveHeaderLeftText:Il,avatarWrapper:bl,userAvatar:Nl},Ro;(function(t){t[t.READ=1]="READ",t[t.LISTENED=2]="LISTENED",t[t.DOWNLOADED=4]="DOWNLOADED",t[t.RETRIEVED=8]="RETRIEVED",t[t.UNREAD=0]="UNREAD"})(Ro||(Ro={}));var Nt,Ki,Gn=Ro,wl=["https://nav.cn.ronghub.com","https://nav2-cn.ronghub.com"],Ol=["wsproxy.cn.ronghub.com","wsap-cn.ronghub.com"],Al=["cometproxy-cn.ronghub.com","mini-cn.ronghub.com"],ba={"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}},Ml=["RC:TypSts","RC:InterceptMsg"];(function(t){t.WEBSOCKET="websocket",t.COMET="comet"})(Nt||(Nt={}));var vi=function(t){return Ki||(Ki={set:function(e,n){t.localStorage.setItem(e,JSON.stringify(n))},get:function(e){var n;try{n=JSON.parse(t.localStorage.getItem(e))}catch{n=null}return n},remove:function(e){return t.localStorage.removeItem(e)},getKeys:function(){var e=[];for(var n in t.localStorage)e.push(n);return e}}),Ki},Pl=function(){function t(e){this._caches={},e&&(this._caches=e)}return t.prototype.set=function(e,n){this._caches[e]=n},t.prototype.remove=function(e){var n=this.get(e);return delete this._caches[e],n},t.prototype.get=function(e){return this._caches[e]},t.prototype.getKeys=function(){var e=[];for(var n in this._caches)e.push(n);return e},t}(),Na=function(){function t(e,n){var r,i=n?"RCV4-"+n:"RCV4-";this._rootStorage=vi(e);var o=this._rootStorage.get(i)||{};this._cache=new Pl(((r={})[i]=o,r)),this._storageKey=i}return t.prototype._get=function(){var e=this._storageKey;return this._cache.get(e)||{}},t.prototype._set=function(e){var n=this._storageKey;e=e||{},this._cache.set(n,e),this._rootStorage.set(n,e)},t.prototype.set=function(e,n){var r=this._get();r[e]=n,this._set(r)},t.prototype.remove=function(e){var n=this._get();delete n[e],this._set(n)},t.prototype.clear=function(){var e=this._storageKey;this._rootStorage.remove(e),this._cache.remove(e)},t.prototype.get=function(e){return this._get()[e]},t.prototype.getKeys=function(){var e=this._get(),n=[];for(var r in e)n.push(r);return n},t.prototype.getValues=function(){return this._get()||{}},t}(),su=function(t,e){return(su=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])})(t,e)};function Ne(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}su(t,e),t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Ce=function(){return(Ce=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function x(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}function B(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(d){return function(l){return function(h){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=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 s.label++,{value:h[1],done:!1};case 5:s.label++,r=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){s.label=h[1];break}if(h[0]===6&&s.label<i[1]){s.label=i[1],i=h;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(h);break}i[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(a){h=[6,a],r=0}finally{n=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}function Kt(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}var Me,Kr;(function(t){function e(n){return t.call(this,"TODO => "+n)||this}return Ne(e,t),e})(Error);var wa=function(t,e,n){if(e===void 0||n===void 0)return t.toUpperCase();var r=t.slice(e,n);return t=t.replace(r,function(i){return i.toUpperCase()})},au=function(t,e){e===void 0&&(e="utf-8");var n,r=0;if(e==="utf-16")for(var i=0,o=t.length;i<o;i++)r+=(n=t.charCodeAt(i))<=65535?2:4;else for(i=0,o=t.length;i<o;i++)r+=(n=t.charCodeAt(i))<127?1:n<=2047?2:n<=65535?3:4;return r},yi=function(t,e){if(t=t.replace(/\?$/,""),!e)return t;var n=Object.keys(e).map(function(r){return r+"="+e[r]}).filter(function(r){return!!r});return n.length?[t,n.join("&")].join("?"):t},cs=function(t){return t.match(/\d+(\.\d+){2}/)[0]};(function(t){t[t.LOG=0]="LOG",t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.FATAL=4]="FATAL",t[t.NONE=1e3]="NONE"})(Me||(Me={})),function(t){t.IM="IM",t.RTC="RTC"}(Kr||(Kr={}));var nn="RC_Logs";function Ll(t){var e=t.target.result;t.oldVersion===1&&e.deleteObjectStore(nn),function(n,r,i){var o;if(!n.objectStoreNames.contains(r)){var s=Ce({},i.objectStoreParams);o=n.createObjectStore(r,s),i.indexs&&i.indexs.length>0&&i.indexs.forEach(function(c){o.createIndex(c.indexName,c.key,{unique:c.unique})})}}(e,nn,{indexs:[{indexName:"time",key:"time",unique:!1}],objectStoreParams:{autoIncrement:!0}})}var To,us=function(){function t(){}return t.init=function(){if(typeof window!="undefined"&&window&&window.indexedDB){var e=window.indexedDB.open("RC_ENGINE_DB",2);e.onerror=function(n){console.warn("open indexDB request failed "+n.target.error)},e.onsuccess=function(n){t._db=n.target.result,t._db&&(t._db.onclose=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has unexpectedly closed.",r),t._db=null,t._instance=null},t._db.onerror=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening error.",r),t._db=null,t._instance=null},t._db.onabort=function(r){var i;console.warn("The database "+((i=t._db)===null||i===void 0?void 0:i.name)+" has opening aborted.",r),t._db=null,t._instance=null}),t._instance=new t},e.onupgradeneeded=function(n){t._db=n.target.result,Ll(n)}}else console.debug("IndexDB is not currently supported in the environment!")},t.getInstance=function(){return t._instance},t.prototype.addList=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readwrite"),o=i.objectStore(e);n.forEach(function(s){o==null||o.add(s)}),i.oncomplete=function(s){r(!0)},i.onerror=function(s){r(!1)}}else r(!1)})},t.prototype.getRangeData=function(e,n,r,i){return new Promise(function(o){if(t._db){var s=t._db.transaction([e],"readwrite").objectStore(e),c=IDBKeyRange.bound(r,i),d=s.index(n),l=[],h=d.openCursor(c);h.onsuccess=function(a){var u=a.target.result;u?(l.push(u.value),u.continue()):o(l)},h.onerror=function(a){console.error(a),o([])}}else o([])})},t.prototype.getCount=function(e,n){return new Promise(function(r){if(t._db){var i=t._db.transaction([e],"readonly").objectStore(e).count();i.onsuccess=function(){r(i.result)},i.onerror=function(o){console.error(o),r(0)}}else r(0)})},t.prototype.removeFirstData=function(e,n,r){return new Promise(function(i){if(t._db){var o=t._db.transaction([e],"readwrite").objectStore(e),s=o.getAllKeys(IDBKeyRange.lowerBound(0),r);s.onsuccess=function(){var c=s.result;c.length>0&&(o.delete(IDBKeyRange.bound(c[0],c[c.length-1])).onsuccess=function(){i(!0)})}}else i(!1)})},t._db=null,t}(),cu=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)})},uu=function(){var t=cu();if(t=t.replace(/-/g,"")+"a",(t=function(r){var i="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZa0".split(""),o=i.length+1,s=+r,c=[];do{var d=s%o;s=(s-d)/o,c.unshift(i[d])}while(s);return c.join("")}(t=parseInt(t,16))).length>22&&(t=t.slice(0,22)),t.length<22)for(var e=22-t.length,n=0;n<e;n++)t+="0";return t};(function(t){t[t.NONE=0]="NONE",t[t.PRIVATE=1]="PRIVATE",t[t.DISCUSSION=2]="DISCUSSION",t[t.GROUP=3]="GROUP",t[t.CHATROOM=4]="CHATROOM",t[t.CUSTOMER_SERVICE=5]="CUSTOMER_SERVICE",t[t.SYSTEM=6]="SYSTEM",t[t.APP_PUBLIC_SERVICE=7]="APP_PUBLIC_SERVICE",t[t.PUBLIC_SERVICE=8]="PUBLIC_SERVICE",t[t.RTC_ROOM=12]="RTC_ROOM"})(To||(To={}));var So,z=To;(function(t){t[t.IMAGE=1]="IMAGE",t[t.AUDIO=2]="AUDIO",t[t.VIDEO=3]="VIDEO",t[t.FILE=4]="FILE",t[t.SIGHT=5]="SIGHT",t[t.COMBINE_HTML=6]="COMBINE_HTML"})(So||(So={}));var Wt,Io,Le=So,Ze=function(t){return typeof t=="string"},qr=function(t){return typeof t=="boolean"},Ie=function(t){return typeof t=="number"&&!isNaN(t)},We=function(t){return Object.prototype.toString.call(t).indexOf("Array")!==-1},du=function(t){return Object.prototype.toString.call(t)==="[object ArrayBuffer]"},Xe=function(t){return Ze(t)&&t.length>0},Ve=function(t){return Object.prototype.toString.call(t)==="[object Object]"},Gr=function(t){return Object.prototype.toString.call(t)==="[object Function]"},me=function(t){return t===void 0||Object.prototype.toString.call(t)==="[object Undefined]"},Oa=function(t){return Object.prototype.toString.call(t)==="[object Null]"},Yn=function(t){return Ze(t)&&/https?:\/\//.test(t)},Vn=function(t){for(var e in t)return!0;return!1},kl=function(t){return Ie(t)&&Object.prototype.hasOwnProperty.call(Le,t)},Aa=((Wt={})[Me.DEBUG]=console.debug.bind(console),Wt[Me.INFO]=console.info.bind(console),Wt[Me.WARN]=console.warn.bind(console),Wt[Me.ERROR]=console.error.bind(console),Wt[Me.FATAL]=console.log.bind(console),Wt),Ma=function(t){return Ze(t)||Ie(t)||me(t)||qr(t)?t:t instanceof Error?JSON.stringify({name:t.name,message:t.message,stack:t.stack}):JSON.stringify(t)},Ut=function(){function t(e,n,r){this.tag=e,this.type=n,this.initiator=r,this._outLevel=Me.WARN,this.debug=this.log.bind(this,Me.DEBUG),this.info=this.log.bind(this,Me.INFO),this.warn=this.log.bind(this,Me.WARN),this.error=this.log.bind(this,Me.ERROR),this.fatal=this.log.bind(this,Me.FATAL)}return t.init=function(e){t.userId=e},t.reset=function(){t.userId=""},t.prototype._defaultStdout=function(e,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];Aa[e].apply(Aa,Kt([n+":"],r))},t.prototype.__pushLocalLog=function(e,n,r){var i;i=this.type?this.type:["RCRTCLog","RCCall","RCRTC","RTC-A"].includes(this.tag)?Kr.RTC:Kr.IM;var o=Date.now();au(n)>=1e3&&(n=function(l,h,a){if(a===void 0&&(a="utf-8"),!l||!h)return"";var u=a==="utf-8"?3:2,f=0,p=0,m="";for(p=0;p<l.length;p++){if(l.charCodeAt(p)>255?f+=u:f++,f>h)return m;m+=l.charAt(p)}return l}(n,1e3));var s=JSON.stringify({message:n,userId:t.userId}).replace(/"/g,'""'),c=/^[\w]+-[\w]+-[\w]+?/.test(r)?r:(this.initiator||"L")+"-"+r+"-O",d={sessionId:t.sessionId,time:o,level:4-e,content:t.sessionId+","+Date.now()+","+i+","+(4-e)+","+c+',"'+s+`"
  2. `,userId:t.userId};t.databaseLogList.push(d),(t.databaseLogList.length>=100||e===Me.FATAL)&&this.__insertLogIntoDatabase()},t.prototype.__insertLogIntoDatabase=function(){return x(this,void 0,void 0,function(){var e,n,r;return B(this,function(i){switch(i.label){case 0:return e=Kt([],t.databaseLogList),t.databaseLogList=[],(n=us.getInstance())?[4,n.addList(nn,e)]:[3,3];case 1:return r=i.sent(),[4,n.getCount(nn,"time")];case 2:return i.sent()>1e5&&n.removeFirstData(nn,"time",2e3),[2,r];case 3:return[2,!1]}})})},t.prototype.setLogLevel=function(e){this._outLevel=typeof e!="number"?Me.WARN:e},t.prototype.setLogStdout=function(e){this._logStdout=e},t.prototype.log=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(e>Me.DEBUG&&this.__pushLocalLog(e,n.map(Ma).join(" "),this.tag),!(e<this._outLevel)){var i=new Date().toISOString()+"["+this.tag+"]["+Me[e]+"]",o=i+" - "+n.map(Ma).join(" ");this._logStdout?this._logStdout(e,o):this._stdout?this._stdout(e,o):this._defaultStdout.apply(this,Kt([e,i],n))}},t.prototype.reportLog=function(e,n,r){this.__pushLocalLog(4-e,r,n);var i=JSON.stringify({message:r}).replace(/"/g,'""');i='"'+i+'"';var o={level:e,content:[t.sessionId,Date.now(),this.type,e,n,i].join()+`
  3. `};t.realTimeLogList.push(o),t.realTimeLogList.length>=600&&(t.realTimeLogList=t.realTimeLogList.slice(-500))},t.prototype.set=function(e,n){this.warn("logger.set has being deprecated!")},t.prototype.setStdout=function(e){this._stdout=e},t.prototype.__clearRealTimeLog=function(){t.realTimeLogList=[]},t.databaseLogList=[],t.realTimeLogList=[],t.sessionId=uu(),t.userId="",t}(),$=new Ut("RCLog"),ir=function(){function t(){this._map={}}return t.prototype.on=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r})},t.prototype.once=function(e,n,r){var i=this._map[e]||(this._map[e]=[]);i.some(function(o){return o.listener===n&&o.target===r})||i.push({listener:n,target:r,once:!0})},t.prototype.off=function(e,n,r){var i=this._map[e];i&&((i=i.filter(function(o){return o.listener!==n||o.target!==r})).length?this._map[e]=i:delete this._map[e])},t.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._map[e];if(i)for(var o=i.length-1;o>=0;o-=1){var s=i[o],c=s.target,d=s.once,l=s.listener;d&&i.splice(o,1);try{l.call.apply(l,Kt([c],n))}catch(h){$.error(h)}}},t.prototype.removeAll=function(e){delete this._map[e]},t.prototype.clear=function(){Object.keys(this._map).forEach(this.removeAll,this)},t}();(function(t){t[t.SEND=1]="SEND",t[t.RECEIVE=2]="RECEIVE"})(Io||(Io={}));var bo,st=Io;(function(t){t[t.TIMEOUT=-1]="TIMEOUT",t[t.UNKNOWN=-2]="UNKNOWN",t[t.PARAMETER_ERROR=-3]="PARAMETER_ERROR",t[t.EXTRA_METHOD_UNDEFINED=-4]="EXTRA_METHOD_UNDEFINED",t[t.MAIN_PROCESS_ERROR=-5]="MAIN_PROCESS_ERROR",t[t.PARAMETER_CHANGED=-6]="PARAMETER_CHANGED",t[t.SUCCESS=0]="SUCCESS",t[t.RC_MSG_UNAUTHORIZED=20406]="RC_MSG_UNAUTHORIZED",t[t.RC_DISCUSSION_GROUP_ID_INVALID=20407]="RC_DISCUSSION_GROUP_ID_INVALID",t[t.SEND_FREQUENCY_TOO_FAST=20604]="SEND_FREQUENCY_TOO_FAST",t[t.NOT_IN_DISCUSSION=21406]="NOT_IN_DISCUSSION",t[t.FORBIDDEN_IN_GROUP=22408]="FORBIDDEN_IN_GROUP",t[t.RECALL_MESSAGE=25101]="RECALL_MESSAGE",t[t.NOT_IN_GROUP=22406]="NOT_IN_GROUP",t[t.NOT_IN_CHATROOM=23406]="NOT_IN_CHATROOM",t[t.FORBIDDEN_IN_CHATROOM=23408]="FORBIDDEN_IN_CHATROOM",t[t.RC_CHATROOM_USER_KICKED=23409]="RC_CHATROOM_USER_KICKED",t[t.RC_CHATROOM_NOT_EXIST=23410]="RC_CHATROOM_NOT_EXIST",t[t.RC_CHATROOM_IS_FULL=23411]="RC_CHATROOM_IS_FULL",t[t.RC_CHATROOM_PATAMETER_INVALID=23412]="RC_CHATROOM_PATAMETER_INVALID",t[t.CHATROOM_GET_HISTORYMSG_ERROR=23413]="CHATROOM_GET_HISTORYMSG_ERROR",t[t.CHATROOM_NOT_OPEN_HISTORYMSG_STORE=23414]="CHATROOM_NOT_OPEN_HISTORYMSG_STORE",t[t.CHATROOM_KV_EXCEED=23423]="CHATROOM_KV_EXCEED",t[t.CHATROOM_KV_OVERWRITE_INVALID=23424]="CHATROOM_KV_OVERWRITE_INVALID",t[t.CHATROOM_KV_STORE_NOT_OPEN=23426]="CHATROOM_KV_STORE_NOT_OPEN",t[t.CHATROOM_KEY_NOT_EXIST=23427]="CHATROOM_KEY_NOT_EXIST",t[t.SENSITIVE_SHIELD=21501]="SENSITIVE_SHIELD",t[t.SENSITIVE_REPLACE=21502]="SENSITIVE_REPLACE",t[t.JOIN_IN_DISCUSSION=21407]="JOIN_IN_DISCUSSION",t[t.CREATE_DISCUSSION=21408]="CREATE_DISCUSSION",t[t.INVITE_DICUSSION=21409]="INVITE_DICUSSION",t[t.GET_USERINFO_ERROR=23407]="GET_USERINFO_ERROR",t[t.REJECTED_BY_BLACKLIST=405]="REJECTED_BY_BLACKLIST",t[t.RC_NET_CHANNEL_INVALID=30001]="RC_NET_CHANNEL_INVALID",t[t.RC_NET_UNAVAILABLE=30002]="RC_NET_UNAVAILABLE",t[t.RC_MSG_RESP_TIMEOUT=30003]="RC_MSG_RESP_TIMEOUT",t[t.RC_HTTP_SEND_FAIL=30004]="RC_HTTP_SEND_FAIL",t[t.RC_HTTP_REQ_TIMEOUT=30005]="RC_HTTP_REQ_TIMEOUT",t[t.RC_HTTP_RECV_FAIL=30006]="RC_HTTP_RECV_FAIL",t[t.RC_NAVI_RESOURCE_ERROR=30007]="RC_NAVI_RESOURCE_ERROR",t[t.RC_NODE_NOT_FOUND=30008]="RC_NODE_NOT_FOUND",t[t.RC_DOMAIN_NOT_RESOLVE=30009]="RC_DOMAIN_NOT_RESOLVE",t[t.RC_SOCKET_NOT_CREATED=30010]="RC_SOCKET_NOT_CREATED",t[t.RC_SOCKET_DISCONNECTED=30011]="RC_SOCKET_DISCONNECTED",t[t.RC_PING_SEND_FAIL=30012]="RC_PING_SEND_FAIL",t[t.RC_PONG_RECV_FAIL=30013]="RC_PONG_RECV_FAIL",t[t.RC_MSG_SEND_FAIL=30014]="RC_MSG_SEND_FAIL",t[t.RC_MSG_CONTENT_EXCEED_LIMIT=30016]="RC_MSG_CONTENT_EXCEED_LIMIT",t[t.RC_CONN_ACK_TIMEOUT=31e3]="RC_CONN_ACK_TIMEOUT",t[t.RC_CONN_PROTO_VERSION_ERROR=31001]="RC_CONN_PROTO_VERSION_ERROR",t[t.RC_CONN_ID_REJECT=31002]="RC_CONN_ID_REJECT",t[t.RC_CONN_SERVER_UNAVAILABLE=31003]="RC_CONN_SERVER_UNAVAILABLE",t[t.RC_CONN_USER_OR_PASSWD_ERROR=31004]="RC_CONN_USER_OR_PASSWD_ERROR",t[t.RC_CONN_NOT_AUTHRORIZED=31005]="RC_CONN_NOT_AUTHRORIZED",t[t.RC_CONN_REDIRECTED=31006]="RC_CONN_REDIRECTED",t[t.RC_CONN_PACKAGE_NAME_INVALID=31007]="RC_CONN_PACKAGE_NAME_INVALID",t[t.RC_CONN_APP_BLOCKED_OR_DELETED=31008]="RC_CONN_APP_BLOCKED_OR_DELETED",t[t.RC_CONN_USER_BLOCKED=31009]="RC_CONN_USER_BLOCKED",t[t.RC_DISCONN_KICK=31010]="RC_DISCONN_KICK",t[t.RC_DISCONN_EXCEPTION=31011]="RC_DISCONN_EXCEPTION",t[t.RC_APP_AUTH_NOT_PASS=31026]="RC_APP_AUTH_NOT_PASS",t[t.RC_OTP_USED=31027]="RC_OTP_USED",t[t.RC_PLATFORM_ERROR=31028]="RC_PLATFORM_ERROR",t[t.RC_QUERY_ACK_NO_DATA=32001]="RC_QUERY_ACK_NO_DATA",t[t.RC_MSG_DATA_INCOMPLETE=32002]="RC_MSG_DATA_INCOMPLETE",t[t.BIZ_ERROR_CLIENT_NOT_INIT=33001]="BIZ_ERROR_CLIENT_NOT_INIT",t[t.BIZ_ERROR_DATABASE_ERROR=33002]="BIZ_ERROR_DATABASE_ERROR",t[t.BIZ_ERROR_INVALID_PARAMETER=33003]="BIZ_ERROR_INVALID_PARAMETER",t[t.BIZ_ERROR_NO_CHANNEL=33004]="BIZ_ERROR_NO_CHANNEL",t[t.BIZ_ERROR_RECONNECT_SUCCESS=33005]="BIZ_ERROR_RECONNECT_SUCCESS",t[t.BIZ_ERROR_CONNECTING=33006]="BIZ_ERROR_CONNECTING",t[t.MSG_ROAMING_SERVICE_UNAVAILABLE=33007]="MSG_ROAMING_SERVICE_UNAVAILABLE",t[t.MSG_INSERT_ERROR=33008]="MSG_INSERT_ERROR",t[t.MSG_DEL_ERROR=33009]="MSG_DEL_ERROR",t[t.TAG_EXISTS=33101]="TAG_EXISTS",t[t.TAG_NOT_EXIST=33100]="TAG_NOT_EXIST",t[t.NO_TAG_IN_CONVER=33102]="NO_TAG_IN_CONVER",t[t.CONVER_REMOVE_ERROR=34001]="CONVER_REMOVE_ERROR",t[t.CONVER_GETLIST_ERROR=34002]="CONVER_GETLIST_ERROR",t[t.CONVER_SETOP_ERROR=34003]="CONVER_SETOP_ERROR",t[t.CONVER_TOTAL_UNREAD_ERROR=34004]="CONVER_TOTAL_UNREAD_ERROR",t[t.CONVER_TYPE_UNREAD_ERROR=34005]="CONVER_TYPE_UNREAD_ERROR",t[t.CONVER_ID_TYPE_UNREAD_ERROR=34006]="CONVER_ID_TYPE_UNREAD_ERROR",t[t.CONVER_CLEAR_ERROR=34007]="CONVER_CLEAR_ERROR",t[t.EXPANSION_LIMIT_EXCEET=34010]="EXPANSION_LIMIT_EXCEET",t[t.MESSAGE_KV_NOT_SUPPORT=34008]="MESSAGE_KV_NOT_SUPPORT",t[t.CLEAR_HIS_TIME_ERROR=34011]="CLEAR_HIS_TIME_ERROR",t[t.CONVER_OUT_LIMIT_ERROR=34013]="CONVER_OUT_LIMIT_ERROR",t[t.CONVER_GET_ERROR=35021]="CONVER_GET_ERROR",t[t.GROUP_SYNC_ERROR=35001]="GROUP_SYNC_ERROR",t[t.GROUP_MATCH_ERROR=35002]="GROUP_MATCH_ERROR",t[t.READ_RECEIPT_ERROR=35003]="READ_RECEIPT_ERROR",t[t.PACKAGE_ENVIRONMENT_ERROR=35006]="PACKAGE_ENVIRONMENT_ERROR",t[t.CAN_NOT_RECONNECT=35007]="CAN_NOT_RECONNECT",t[t.SERVER_UNAVAILABLE=35008]="SERVER_UNAVAILABLE",t[t.HOSTNAME_ERROR=35009]="HOSTNAME_ERROR",t[t.HAS_OHTER_SAME_CLIENT_ON_LINE=35010]="HAS_OHTER_SAME_CLIENT_ON_LINE",t[t.UPLOAD_FILE_FAILED=35020]="UPLOAD_FILE_FAILED",t[t.CHATROOM_ID_ISNULL=36001]="CHATROOM_ID_ISNULL",t[t.CHARTOOM_JOIN_ERROR=36002]="CHARTOOM_JOIN_ERROR",t[t.CHATROOM_HISMESSAGE_ERROR=36003]="CHATROOM_HISMESSAGE_ERROR",t[t.CHATROOM_KV_NOT_FOUND=36004]="CHATROOM_KV_NOT_FOUND",t[t.BLACK_ADD_ERROR=37001]="BLACK_ADD_ERROR",t[t.BLACK_GETSTATUS_ERROR=37002]="BLACK_GETSTATUS_ERROR",t[t.BLACK_REMOVE_ERROR=37003]="BLACK_REMOVE_ERROR",t[t.DRAF_GET_ERROR=38001]="DRAF_GET_ERROR",t[t.DRAF_SAVE_ERROR=38002]="DRAF_SAVE_ERROR",t[t.DRAF_REMOVE_ERROR=38003]="DRAF_REMOVE_ERROR",t[t.SUBSCRIBE_ERROR=39001]="SUBSCRIBE_ERROR",t[t.NOT_SUPPORT=39002]="NOT_SUPPORT",t[t.QNTKN_FILETYPE_ERROR=41001]="QNTKN_FILETYPE_ERROR",t[t.QNTKN_GET_ERROR=41002]="QNTKN_GET_ERROR",t[t.COOKIE_ENABLE=51001]="COOKIE_ENABLE",t[t.GET_MESSAGE_BY_ID_ERROR=61001]="GET_MESSAGE_BY_ID_ERROR",t[t.HAVNODEVICEID=24001]="HAVNODEVICEID",t[t.DEVICEIDISHAVE=24002]="DEVICEIDISHAVE",t[t.FEILD=24009]="FEILD",t[t.VOIPISNULL=24013]="VOIPISNULL",t[t.NOENGINETYPE=24010]="NOENGINETYPE",t[t.NULLCHANNELNAME=24011]="NULLCHANNELNAME",t[t.VOIPDYANMICERROR=24012]="VOIPDYANMICERROR",t[t.NOVOIP=24014]="NOVOIP",t[t.INTERNALERRROR=24015]="INTERNALERRROR",t[t.VOIPCLOSE=24016]="VOIPCLOSE",t[t.CLOSE_BEFORE_OPEN=51001]="CLOSE_BEFORE_OPEN",t[t.ALREADY_IN_USE=51002]="ALREADY_IN_USE",t[t.INVALID_CHANNEL_NAME=51003]="INVALID_CHANNEL_NAME",t[t.VIDEO_CONTAINER_IS_NULL=51004]="VIDEO_CONTAINER_IS_NULL",t[t.DELETE_MESSAGE_ID_IS_NULL=61001]="DELETE_MESSAGE_ID_IS_NULL",t[t.CANCEL=1]="CANCEL",t[t.REJECT=2]="REJECT",t[t.HANGUP=3]="HANGUP",t[t.BUSYLINE=4]="BUSYLINE",t[t.NO_RESPONSE=5]="NO_RESPONSE",t[t.ENGINE_UN_SUPPORTED=6]="ENGINE_UN_SUPPORTED",t[t.NETWORK_ERROR=7]="NETWORK_ERROR",t[t.REMOTE_CANCEL=11]="REMOTE_CANCEL",t[t.REMOTE_REJECT=12]="REMOTE_REJECT",t[t.REMOTE_HANGUP=13]="REMOTE_HANGUP",t[t.REMOTE_BUSYLINE=14]="REMOTE_BUSYLINE",t[t.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",t[t.REMOTE_ENGINE_UN_SUPPORTED=16]="REMOTE_ENGINE_UN_SUPPORTED",t[t.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",t[t.VOIP_NOT_AVALIABLE=18]="VOIP_NOT_AVALIABLE",t[t.CHATROOM_KV_STORE_NOT_ALL_SUCCESS=23428]="CHATROOM_KV_STORE_NOT_ALL_SUCCESS",t[t.CHATROOM_KV_STORE_OUT_LIMIT=23429]="CHATROOM_KV_STORE_OUT_LIMIT"})(bo||(bo={}));var No,N=bo;(function(t){t[t.CONNECTED=0]="CONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.DISCONNECTED=2]="DISCONNECTED",t[t.NETWORK_UNAVAILABLE=3]="NETWORK_UNAVAILABLE",t[t.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",t[t.KICKED_OFFLINE_BY_OTHER_CLIENT=6]="KICKED_OFFLINE_BY_OTHER_CLIENT",t[t.WEBSOCKET_UNAVAILABLE=7]="WEBSOCKET_UNAVAILABLE",t[t.WEBSOCKET_ERROR=8]="WEBSOCKET_ERROR",t[t.BLOCKED=9]="BLOCKED",t[t.DOMAIN_INCORRECT=12]="DOMAIN_INCORRECT",t[t.DISCONNECT_BY_SERVER=13]="DISCONNECT_BY_SERVER",t[t.REDIRECT=14]="REDIRECT",t[t.APPKEY_IS_FAKE=20]="APPKEY_IS_FAKE",t[t.ULTRALIMIT=1101]="ULTRALIMIT",t[t.REQUEST_NAVI=201]="REQUEST_NAVI",t[t.RESPONSE_NAVI=202]="RESPONSE_NAVI",t[t.RESPONSE_NAVI_ERROR=203]="RESPONSE_NAVI_ERROR",t[t.RESPONSE_NAVI_TIMEOUT=204]="RESPONSE_NAVI_TIMEOUT"})(No||(No={}));var wo,ne=No,He={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(t){t.TextMessage="RC:TxtMsg",t.VOICE="RC:VcMsg",t.HQ_VOICE="RC:HQVCMsg",t.IMAGE="RC:ImgMsg",t.GIF="RC:GIFMsg",t.RICH_CONTENT="RC:ImgTextMsg",t.LOCATION="RC:LBSMsg",t.FILE="RC:FileMsg",t.SIGHT="RC:SightMsg",t.COMBINE="RC:CombineMsg",t.CHRM_KV_NOTIFY="RC:chrmKVNotiMsg",t.LOG_COMMAND="RC:LogCmdMsg",t.EXPANSION_NOTIFY="RC:MsgExMsg",t.REFERENCE="RC:ReferenceMsg",t.RECALL="RC:RcCmd",t.READ_RECEIPT="RC:ReadNtf",t.READ_RECEIPT_REQUEST="RC:RRReqMsg",t.READ_RECEIPT_RESPONSE="RC:RRRspMsg",t.SYNC_READ_STATUS="RC:SRSMsg",t.GROUP_READ_RECEIPT_REQUEST="RC:RRMsg",t.CHATROOM_JOIN="RC:ChrmJoinNtf",t.CHATROOM_LEFT="RC:ChrmQuitNtf",t.CHATROOM_MERGE_CHANGE="RC:ChrmMemChange",t.TYPING_STATUS="RC:TypSts",t.INTERCEPT="RC:InterceptMsg"})(wo||(wo={}));var Oo,$e=wo;(function(t){t[t.OPEN=1]="OPEN",t[t.CLOSE=2]="CLOSE"})(Oo||(Oo={}));var Ao,Zt=Oo;(function(t){t[t.ALL=1]="ALL",t[t.SINGAL=2]="SINGAL"})(Ao||(Ao={}));var Mo,ds=Ao;(function(t){t[t.QINIU=1]="QINIU",t[t.ALI=2]="ALI",t[t.AWS=3]="AWS",t[t.STC=4]="STC"})(Mo||(Mo={}));var Po,Je=Mo;(function(t){t[t.UPDATE=1]="UPDATE",t[t.DELETE=2]="DELETE"})(Po||(Po={}));var Lo,Qe=Po;(function(t){t[t.QUIT=0]="QUIT",t[t.JOIN=1]="JOIN"})(Lo||(Lo={}));var Pa,La=Lo;(function(t){/*!
  4. 全局敏感词:命中了融云内置的全局敏感词
  5. */t[t.GLOBAL=1]="GLOBAL",t[t.CUSTOM=2]="CUSTOM",t[t.THIRD_PARTY=3]="THIRD_PARTY"})(Pa||(Pa={}));var qe,ka,Ua;(function(t){t[t.RTC=0]="RTC",t[t.LIVE=2]="LIVE"})(qe||(qe={})),function(t){t[t.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",t[t.AUDIO=1]="AUDIO"}(ka||(ka={})),function(t){t[t.ANCHOR=1]="ANCHOR",t[t.AUDIENCE=2]="AUDIENCE"}(Ua||(Ua={}));var yt,Yr,ko,Ul={"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(t){t[t.ROOM=1]="ROOM",t[t.PERSON=2]="PERSON"})(yt||(yt={})),function(t){t[t.AnchorToViewer=1]="AnchorToViewer",t[t.ViewerToAnchor=2]="ViewerToAnchor"}(Yr||(Yr={})),function(t){t[t.KICK=0]="KICK",t[t.REFUSE=1]="REFUSE",t[t.COEXIST=2]="COEXIST"}(ko||(ko={}));var mt,Ae,qi={engine:"5.1.1"},qt=function(){function t(){}return t.add=function(e,n){qi[e]=n},t.validEngine=function(e){var n=e.match(/\d+\.\d+\.\d+/);if(!n)return $.warn("The validation engine version '"+e+"' is invalid!"),!1;var r=n[0].split(".").map(function(i){return i.padStart(3,"0")}).join("");return qi.engine.match(/\d+\.\d+\.\d+/)[0].split(".").map(function(i){return i.padStart(3,"0")}).join("")>=r},t.getInfo=function(){return qi},t}();(function(t){t[t.STRING=0]="STRING",t[t.ONLY_STRING=1]="ONLY_STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.OBJECT=4]="OBJECT",t[t.ARRAY=5]="ARRAY",t[t.CALLBACK=6]="CALLBACK",t[t.CHANNEL_ID=7]="CHANNEL_ID"})(Ae||(Ae={}));var Tt,je,et,Gt,jt,Dl=((mt={})[Ae.STRING]=Xe,mt[Ae.ONLY_STRING]=Ze,mt[Ae.NUMBER]=Ie,mt[Ae.BOOLEAN]=function(t){return typeof t=="boolean"},mt[Ae.OBJECT]=Ve,mt[Ae.ARRAY]=We,mt[Ae.CALLBACK]=function(t){var e=!0;return Ve(t)||(e=!1),(t=t||{}).onSuccess&&!Gr(t.onSuccess)&&(e=!1),t.onError&&!Gr(t.onError)&&(e=!1),e},mt[Ae.CHANNEL_ID]=function(t){var e=!1;return Ze(t)&&!/_/g.test(t)&&t.length<=20&&(e=!0),e},mt),xl=function(t){function e(n){var r=t.call(this,n)||this;return r.name="RCAssertError",r}return Ne(e,t),e}(Error),De=function(t,e,n,r){if(r===void 0&&(r=!1),!Ee(t,e,n,r))throw new xl("'"+t+"' is invalid: "+JSON.stringify(e))},Ee=function(t,e,n,r){r===void 0&&(r=!1),n=Dl[n]||n;var i=r&&!n(e)||!r&&!(me(e)||e===null||n(e));return i&&$.error("'"+t+"' is invalid: "+JSON.stringify(e)),!i},it=function(t){if(!Ve(t)||t.low===void 0||t.high===void 0)return t;var e=t.low;return e<0&&(e+=4294967296),e=e.toString(16),parseInt(t.high.toString(16)+"00000000".replace(new RegExp("0{"+e.length+"}$"),e),16)},Bl=function(t,e){var n=Math.floor(1e3*Math.random()%1e4),r=cu(),i=function(d){d=d||"-";var l=new Date;return""+l.getFullYear()+d+(l.getMonth()+1)+d+l.getDate()}(),o=new Date().getTime(),s="";if(e){var c=e.split(".");s="."+c[c.length-1]}return t+"__RC-"+i+"_"+n+"_"+o+r+s},Vl=function(t,e){t===void 0&&(t={}),e===void 0&&(e={});var n=t.threadId,r=t.apnsCollapseId,i=t.category,o=t.richMediaUri,s=e.channelIdMi,c=e.channelIdHW,d=e.channelIdOPPO,l=e.typeVivo,h=e.googleConfig,a={};a["thread-id"]=n||"",a["apns-collapse-id"]=r||"",a.category=i||"",a.richMediaUri=o||"";var u={};u.collapse_key=h==null?void 0:h.collapseKey,u.imageUrl=h==null?void 0:h.imageUrl;var f=h==null?void 0:h.priority;f&&!["high","normal"].includes(f)&&(f="normal"),u.priority=f;var p=[{HW:{channelId:c||""}},{MI:{channelId:s||""}},{OPPO:{channelId:d||""}},{VIVO:{classification:l||""}},{APNS:a},{FCM:u}];return JSON.stringify(p)},Da=function(t,e){var n={},r={notificationId:e||""};if(!t)return{iOSConfig:n,androidConfig:r};try{var i=JSON.parse(t);i==null||i.forEach(function(o){var s,c,d,l,h=Object.keys(o);if(h.length!==0){var a=h[0];switch(a){case"HW":return void(r.channelIdHW=(s=o[a])===null||s===void 0?void 0:s.channelId);case"MI":return void(r.channelIdMi=(c=o[a])===null||c===void 0?void 0:c.channelId);case"OPPO":return void(r.channelIdOPPO=(d=o[a])===null||d===void 0?void 0:d.channelId);case"VIVO":return void(r.typeVivo=(l=o[a])===null||l===void 0?void 0:l.classification);case"APNS":return n.threadId=o[a]["thread-id"],n.apnsCollapseId=o[a]["apns-collapse-id"],n.category=o[a].category,void(n.richMediaUri=o[a].richMediaUri);case"FCM":r.googleConfig={collapseKey:o[a].collapse_key||"",imageUrl:o[a].imageUrl||"",priority:o[a].priority||""}}}})}catch{$.error("Wrong format for pushConfigs field! content: "+t)}return{iOSConfig:n,androidConfig:r}},zt=function(t){var e=/^[A-Za-z0-9_=+-]+$/.test(t),n=t.length;return e&&n<=128&&n>=1},Gi=function(t){var e=t.length;return e<=4096&&e>=1},Oe=function(t,e,n){e=e||function(){};var r=(n=n||{}).isReverse;Ve(t)&&function(){for(var i in t)e(t[i],i,t)}(),(We(t)||Ze(t))&&function(){if(r)for(var i=t.length-1;i>=0;i--)e(t[i],i);else for(var o=0,s=t.length;o<s;o++)e(t[o],o)}()},mr=function(t,e){return Oe(t,function(n,r){t[r]=e(n,r)}),t},Fl=function(t,e){if(t.indexOf)return t.indexOf(e);var n=-1;return Oe(t,function(r,i){e===r&&(n=i)}),n},Hl=function(t,e){var n=[];return Oe(t,function(r){n.push(r)}),Fl(n,e)!==-1},xr=function(t){return JSON.parse(JSON.stringify(t))},xa=function(){return typeof RCCppEngine!="undefined"},jl=function(t){if(t.tag!=="browser")return{type:t.tag,version:"UnKonw"};var e,n,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 o in i)if(i.hasOwnProperty(o)){var s=r.match(i[o]);if(s){n=o,e=s[1]||s[2];break}}return{type:n||"UnKonw",version:e||"UnKonw"}},lu=function(t){switch(t){case He.SERVER_UNAVAILABLE:return N.SERVER_UNAVAILABLE;case He.TOKEN_INCORRECT:return N.RC_CONN_USER_OR_PASSWD_ERROR;case He.REDIRECT:return N.RC_CONN_REDIRECTED;case He.APP_BLOCK_OR_DELETE:return N.RC_CONN_APP_BLOCKED_OR_DELETED;case He.BLOCK:return N.RC_CONN_USER_BLOCKED;case He.TOKEN_EXPIRE:return N.RC_CONN_USER_OR_PASSWD_ERROR;case He.HOSTNAME_ERROR:return N.HOSTNAME_ERROR;case He.HASOHTERSAMECLIENTONLINE:return N.HAS_OHTER_SAME_CLIENT_ON_LINE;case He.APP_AUTH_NOT_PASS:return N.RC_APP_AUTH_NOT_PASS;case He.OTP_USED:return N.RC_OTP_USED;case He.PLATFORM_ERROR:return N.RC_PLATFORM_ERROR;default:return N.RC_NET_UNAVAILABLE}},Ba=function(t){var e={},n=JSON.parse(t);return Oe(n,function(r,i){e[i]=r.v}),e},en={_delayTime:0,setTime:function(t){var e=new Date().getTime();en._delayTime=e-t},getTime:function(){var t=en._delayTime;return new Date().getTime()-t}},Va=function(t,e){var n=0;return t.isAutoDelete&&(n|=1),t.isOverwrite&&(n|=2),e===2&&(n|=4),n};(function(t){t[t.AT_MOST_ONCE=0]="AT_MOST_ONCE",t[t.AT_LEAST_ONCE=1]="AT_LEAST_ONCE",t[t.EXACTLY_ONCE=2]="EXACTLY_ONCE",t[t.DEFAULT=3]="DEFAULT"})(Tt||(Tt={})),function(t){t[t.SYMMETRIC=0]="SYMMETRIC",t[t.CONNECT=1]="CONNECT",t[t.CONN_ACK=2]="CONN_ACK",t[t.PUBLISH=3]="PUBLISH",t[t.PUB_ACK=4]="PUB_ACK",t[t.QUERY=5]="QUERY",t[t.QUERY_ACK=6]="QUERY_ACK",t[t.QUERY_CONFIRM=7]="QUERY_CONFIRM",t[t.SUBSCRIBE=8]="SUBSCRIBE",t[t.SUB_ACK=9]="SUB_ACK",t[t.UNSUBSCRIBE=10]="UNSUBSCRIBE",t[t.UNSUB_ACK=11]="UNSUB_ACK",t[t.PING_REQ=12]="PING_REQ",t[t.PING_RESP=13]="PING_RESP",t[t.DISCONNECT=14]="DISCONNECT",t[t.RESERVER2=15]="RESERVER2"}(je||(je={})),function(t){t.CONN_ACK="ConnAckMessage",t.DISCONNECT="DisconnectMessage",t.PING_REQ="PingReqMessage",t.PING_RESP="PingRespMessage",t.PUBLISH="PublishMessage",t.PUB_ACK="PubAckMessage",t.QUERY="QueryMessage",t.QUERY_CON="QueryConMessage",t.QUERY_ACK="QueryAckMessage"}(et||(et={})),function(t){t.PUB="pub",t.QUERY="qry"}(Gt||(Gt={})),function(t){t[t.V4=4]="V4",t[t.V3=3]="V3"}(jt||(jt={}));var K,ls=function(){function t(e,n,r,i){n===void 0&&(n=!1),r===void 0&&(r=Tt.AT_LEAST_ONCE),i===void 0&&(i=!1),this._retain=!1,this.qos=Tt.AT_LEAST_ONCE,this._dup=!1,this.syncMsg=!1;var o=e>0;e&&o&&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=n,this.qos=r,this._dup=i)}return t.prototype.encode=function(){var e=this.type<<4;return e|=this._retain?1:0,e|=this.qos<<1,e|=this._dup?8:0},t}(),or=function(){function t(){}return t.writeUTF=function(e,n){var r=[],i=0;if(Ze(e))for(var o=0,s=e.length;o<s;o++){var c=e.charCodeAt(o);c>=0&&c<=127?(i+=1,r.push(c)):c>=128&&c<=2047?(i+=2,r.push(192|31&c>>6),r.push(128|63&c)):c>=2048&&c<=65535&&(i+=3,r.push(224|15&c>>12),r.push(128|63&c>>6),r.push(128|63&c))}for(o=0,s=r.length;o<s;o++)r[o]>255&&(r[o]&=255);return n?r:i<=255?[0,i].concat(r):[i>>8,255&i].concat(r)},t.readUTF=function(e){for(var n,r,i=[],o=-1,s=e,c="";++o<s.length;){var d=Number(s[o]);if(d===(127&d)||((240&d)==240?d=(d=(d=(d^=240)<<6|128^s[++o])<<6|128^s[++o])<<6|128^s[++o]:(224&d)==224?d=(d=(d^=224)<<6|128^s[++o])<<6|128^s[++o]:(192&d)==192&&(d=(d^=192)<<6|128^s[++o])),!isFinite(d)||d<0||d>1114111||Math.floor(d)!==d)throw RangeError("Invalid code point: "+d);d<=65535?i.push(d):(n=(d-=65536)>>10|55296,r=d%1024|56320,i.push(n,r)),(o+1===s.length||i.length>16384)&&(c+=String.fromCharCode.apply(null,i),i.length=0)}return c},t}(),$l=function(){function t(e){this._position=0,this._poolLen=0,this._pool=e,this._poolLen=e.length}return t.prototype.check=function(){return this._position>=this._pool.length},t.prototype.read2Byte=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<2;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readInt=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<4;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i.toString()}return parseInt(n,16)},t.prototype.readLong=function(){var e=this;if(e.check())return-1;for(var n="",r=0;r<8;r++){var i=e._pool[e._position++].toString(16);i.length===1&&(i="0"+i),n+=i}return parseInt(n,16)},t.prototype.readByte=function(){if(this.check())return-1;var e=this._pool[this._position++];return e>255&&(e&=255),e},t.prototype.readUTF=function(){if(this.check())return"";var e=this.readByte()<<8|this.readByte(),n=this._pool.subarray(this._position,this._position+=e);return or.readUTF(n)},t.prototype.readAll=function(){return this._pool.subarray(this._position,this._poolLen)},t}(),Kl=function(){function t(){this._pool=[],this._position=0,this._writen=0}return t.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},t.prototype.writeArr=function(e){return this._pool=this._pool.concat(e),e},t.prototype.writeUTF=function(e){var n=or.writeUTF(e);this._pool=this._pool.concat(n),this._writen+=n.length},t.prototype.getBytesArray=function(){return this._pool},t}(),Jn="UpStreamMessage",hs="PushExtra",Ci="DownStreamMessage",Wn="DownStreamMessages",fs="SessionsAttQryInput",hu="SessionsAttOutput",ps="SyncRequestMsg",gs="ChrmPullMsg",Jr="NotifyMsg",ms="HistoryMsgInput",zn="HistoryMsgOuput",Wr="RelationQryInput",Qn="RelationsOutput",_s="DeleteSessionsInput",vs="SessionInfo",fu="DeleteSessionsOutput",ys="RelationsInput",Cs="DeleteMsgInput",Es="CleanHisMsgInput",Rs="SessionMsgReadInput",Ts="ChrmInput",Ss="ChrmOutput",Is="QueryChatRoomInfoInput",Ei="QueryChatRoomInfoOutput",zr="RtcInput",$t="RtcUserListOutput",bs="SetUserStatusInput",Ns="RtcSetDataInput",Qr="RtcUserSetDataInput",Xr="RtcDataInput",ws="RtcSetOutDataInput",Os="MCFollowInput",Ri="RtcTokenOutput",Ti="RtcQryOutput",As="RtcQryUserOutDataInput",pu="RtcUserOutDataOutput",Ms="RtcQueryListInput",gu="RtcRoomInfoOutput",ot="RtcValueInfo",Ps="RtcKeyDeleteInput",Ls="GetQNupTokenInput",ks="GetQNupTokenOutput",Us="GetQNdownloadUrlInput",Ds="GetDownloadUrlInput",xs="GetQNdownloadUrlOutput",Bs="GetDownloadUrlOutput",Vs="SetChrmKV",Fs="SetChrmKVS",mu="DeleteChrmKVS",rn="ChrmKVOutput",Hs="ChrmKVSOutput",_u="ChrmKVSOutputEntity",js="QueryChrmKV",vu="SetUserSettingInput",on="SetUserSettingOutput",$s="PullUserSettingInput",Si="PullUserSettingOutput",Ii="UserSettingNotification",Ks="SessionReq",bi="SessionStates",Zr="SessionState",ei="SessionStateItem",ti="SessionStateModifyReq",qs="SessionStateModifyResp",ni="GrpReadReceiptMsg",yu="GrpReadReceiptQryReq",Ni="GrpReadReceiptQryResp",Cu="GrpMsgReadUser",Gs="SessionTagAddInput",Fn="SessionTagItem",Ys="SessionTagDelInput",Js="SessionDisTagReq",Ws="ReportSDKInput",Eu="ReportSDKOutput",zs="RtcNotifyMsg",Qs="RtcPullKV",wi="RtcKVOutput",Xs="RtcQueryUserJoinedInput",Oi="RtcQueryUserJoinedOutput",Ru="RtcViewerJoinedOutput",Zs="RtcInviteInput",ea="RtcCancelInviteInput",ta="RtcInviteAnswerInput",na="RtcEndInviteInput",Tu=((K={})[Jn]=["sessionId","classname","content","pushText","userId","configFlag","appData","extraContent","pushExt","busChannel"],K[Wn]=["list","syncTime","finished"],K[Ci]=["fromUserId","type","groupId","classname","content","dataTime","status","msgId","extraContent","pushContent","configFlag","pushExt","busChannel"],K[hs]=["title","templateIdNoUse","pushId","pushConfigs","templateId"],K[fs]=["nothing"],K[hu]=["inboxTime","sendboxTime","totalUnreadCount"],K[ps]=["syncTime","ispolling","isweb","isPullSend","isKeeping","sendBoxSyncTime"],K[gs]=["syncTime","count"],K[Jr]=["type","time","chrmId"],K[ms]=["targetId","time","count","order","busChannel"],K[zn]=["list","syncTime","hasMsg"],K[Wr]=["type","count","startTime","order"],K[Qn]=["info"],K[_s]=["sessions"],K[vs]=["type","channelId","busChannel"],K[fu]=["nothing"],K[ys]=["type","msg","count","busChannel","startTime","endTime"],K[Cs]=["type","conversationId","msgs","busChannel"],K[Es]=["targetId","dataTime","conversationType","busChannel"],K[Rs]=["type","msgTime","channelId"],K[Ts]=["nothing"],K[Ss]=["nothing","sessionId","joinTime"],K[Is]=["count","order"],K[Ei]=["userTotalNums","userInfos"],K[Ls]=["type","key","httpMethod","queryString"],K[Us]=["type","key","fileName"],K[Ds]=["type","key","fileName"],K[ks]=["deadline","token","bosToken","bosDate","path","osskeyId","ossPolicy","ossSign","ossBucketName"],K[xs]=["downloadUrl"],K[Bs]=["downloadUrl"],K[Vs]=["entry","bNotify","notification","type"],K[Fs]=["entry","bNotify","notification","type"],K[mu]=["entry","bNotify","notification","type"],K[rn]=["entries","bFullUpdate","syncTime"],K[Hs]=["timestamp","errorKeys"],K[_u]=["key","errorCode"],K[js]=["timestamp"],K[vu]=["version","value"],K[on]=["version","reserve"],K[$s]=["version","reserve"],K[Si]=["items","version"],K.UserSettingItem=["targetId","type","key","value","version","status","tags"],K[Ks]=["time"],K[bi]=["version","state"],K[Zr]=["type","channelId","time","stateItem","busChannel"],K[ei]=["sessionStateType","value","tags"],K[ti]=["version","state"],K[qs]=["version"],K[ni]=["msgId","busChannel"],K[yu]=["msgId","busChannel"],K[Ni]=["totalMemberNum","list"],K[Cu]=["readTime","userId"],K[Gs]=["version","tags"],K[Fn]=["tagId","name","createdTime","isTop"],K[Ys]=["version","tags"],K[Js]=["tagId"],K[Ii]=["version","reserve"],K[Ws]=["sdkInfo"],K[Eu]=["nothing"],K[zr]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType"],K[$t]=["users","token","sessionId","roomInfo"],K[bs]=["status"],K[Ns]=["interior","target","key","value","objectName","content"],K[Qr]=["valueInfo","objectName","content"],K[Xr]=["interior","target","key","objectName","content"],K[ws]=["target","valueInfo","objectName","content"],K[Os]=["state"],K[Ri]=["rtcToken"],K[Ti]=["outInfo"],K[As]=["userId"],K[pu]=["user"],K[Ms]=["order"],K[gu]=["roomId","roomData","userCount","list"],K[ot]=["key","value"],K[Ps]=["key"],K[zs]=["type","time","roomId"],K[Qs]=["timestamp","roomId"],K[wi]=["entries","bFullUpdate","syncTime"],K[Xs]=["userId"],K[Oi]=["info"],K[Zs]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],K[ea]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],K[ta]=["inviteUserID","answerCode","inviteRoomId","inviteSessionId","content","key","value"],K[na]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],K),Xn={},ql=function(t){var e=Tu[t];Xn[t]=function(){for(var n={},r={getArrayData:function(){return n}},i=function(s){var c=e[s],d="set"+wa(c,0,1);r[d]=function(l){n[c]=l}},o=0;o<e.length;o++)i(o);return r},Xn[t].decode=function(n){var r={};Ze(n)&&(n=JSON.parse(n));var i=function(s){var c="get"+wa(s,0,1);r[s]=n[s],r[c]=function(){return n[s]}};for(var o in n)i(o);return r}};for(var Gl in Tu)ql(Gl);Xn.getModule=function(t){return Xn[t]()};var Yl=`
  6. package Modules;
  7. message probuf {
  8. message `+bs+`
  9. {
  10. optional int32 status=1;
  11. }
  12. message SetUserStatusOutput
  13. {
  14. optional int32 nothing=1;
  15. }
  16. message GetUserStatusInput
  17. {
  18. optional int32 nothing=1;
  19. }
  20. message GetUserStatusOutput
  21. {
  22. optional string status=1;
  23. optional string subUserId=2;
  24. }
  25. message SubUserStatusInput
  26. {
  27. repeated string userid =1;
  28. }
  29. message SubUserStatusOutput
  30. {
  31. optional int32 nothing=1;
  32. }
  33. message VoipDynamicInput
  34. {
  35. required int32 engineType = 1;
  36. required string channelName = 2;
  37. optional string channelExtra = 3;
  38. }
  39. message VoipDynamicOutput
  40. {
  41. required string dynamicKey=1;
  42. }
  43. message `+Jr+` {
  44. required int32 type = 1;
  45. optional int64 time = 2;
  46. optional string chrmId=3;
  47. }
  48. message `+ps+` {
  49. required int64 syncTime = 1;
  50. required bool ispolling = 2;
  51. optional bool isweb=3;
  52. optional bool isPullSend=4;
  53. optional bool isKeeping=5;
  54. optional int64 sendBoxSyncTime=6;
  55. }
  56. message `+Jn+` {
  57. required int32 sessionId = 1;
  58. required string classname = 2;
  59. required bytes content = 3;
  60. optional string pushText = 4;
  61. optional string appData = 5;
  62. repeated string userId = 6;
  63. optional int64 delMsgTime = 7;
  64. optional string delMsgId = 8;
  65. optional int32 configFlag = 9;
  66. optional int64 clientUniqueId = 10;
  67. optional string extraContent = 11;
  68. optional PushExtra pushExt = 12;
  69. optional string busChannel = 13; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  70. }
  71. message `+hs+` {
  72. optional string title = 1;
  73. optional int32 templateIdNoUse= 2;
  74. optional string pushId = 3;
  75. optional string pushConfigs = 4;
  76. optional string templateId = 5;
  77. }
  78. message `+Wn+` {
  79. repeated DownStreamMessage list = 1;
  80. required int64 syncTime = 2;
  81. optional bool finished = 3;
  82. }
  83. message `+Ci+` {
  84. required string fromUserId = 1;
  85. required ChannelType type = 2;
  86. optional string groupId = 3;
  87. required string classname = 4;
  88. required bytes content = 5;
  89. required int64 dataTime = 6;
  90. required int64 status = 7;
  91. optional int64 extra = 8;
  92. optional string msgId = 9;
  93. optional int32 direction = 10;
  94. optional int32 plantform =11;
  95. optional int32 isRemoved = 12;
  96. optional string source = 13;
  97. optional int64 clientUniqueId = 14;
  98. optional string extraContent = 15;
  99. optional string pushContent = 16;
  100. optional int32 configFlag = 17;
  101. optional PushExtra pushExt = 18;
  102. optional string busChannel = 19; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  103. }
  104. enum ChannelType {
  105. PERSON = 1;
  106. PERSONS = 2;
  107. GROUP = 3;
  108. TEMPGROUP = 4;
  109. CUSTOMERSERVICE = 5;
  110. NOTIFY = 6;
  111. MC=7;
  112. MP=8;
  113. }
  114. message CreateDiscussionInput {
  115. optional string name = 1;
  116. }
  117. message CreateDiscussionOutput {
  118. required string id = 1;
  119. }
  120. message ChannelInvitationInput {
  121. repeated string users = 1;
  122. }
  123. message LeaveChannelInput {
  124. required int32 nothing = 1;
  125. }
  126. message ChannelEvictionInput {
  127. required string user = 1;
  128. }
  129. message RenameChannelInput {
  130. required string name = 1;
  131. }
  132. message ChannelInfoInput {
  133. required int32 nothing = 1;
  134. }
  135. message ChannelInfoOutput {
  136. required ChannelType type = 1;
  137. required string channelId = 2;
  138. required string channelName = 3;
  139. required string adminUserId = 4;
  140. repeated string firstTenUserIds = 5;
  141. required int32 openStatus = 6;
  142. }
  143. message ChannelInfosInput {
  144. required int32 page = 1;
  145. optional int32 number = 2;
  146. }
  147. message ChannelInfosOutput {
  148. repeated ChannelInfoOutput channels = 1;
  149. required int32 total = 2;
  150. }
  151. message MemberInfo {
  152. required string userId = 1;
  153. required string userName = 2;
  154. required string userPortrait = 3;
  155. required string extension = 4;
  156. }
  157. message GroupMembersInput {
  158. required int32 page = 1;
  159. optional int32 number = 2;
  160. }
  161. message GroupMembersOutput {
  162. repeated MemberInfo members = 1;
  163. required int32 total = 2;
  164. }
  165. message GetUserInfoInput {
  166. required int32 nothing = 1;
  167. }
  168. message GetUserInfoOutput {
  169. required string userId = 1;
  170. required string userName = 2;
  171. required string userPortrait = 3;
  172. }
  173. message GetSessionIdInput {
  174. required int32 nothing = 1;
  175. }
  176. message GetSessionIdOutput {
  177. required int32 sessionId = 1;
  178. }
  179. enum FileType {
  180. image = `+Le.IMAGE+`;
  181. audio = `+Le.AUDIO+`;
  182. video = `+Le.VIDEO+`;
  183. file = `+Le.FILE+`;
  184. }
  185. message `+Ls+` {
  186. required FileType type = 1;
  187. optional string key = 2;
  188. optional string httpMethod = 3;
  189. optional string queryString = 4;
  190. }
  191. message `+Us+` {
  192. required FileType type = 1;
  193. required string key = 2;
  194. optional string fileName = 3;
  195. }
  196. message `+Ds+` {
  197. required FileType type = 1;
  198. required string key = 2;
  199. optional string fileName = 3;
  200. }
  201. message `+ks+` {
  202. required int64 deadline = 1;
  203. required string token = 2;
  204. optional string bosToken = 3;
  205. optional string bosDate = 4;
  206. optional string path = 5;
  207. optional string osskeyId = 6;
  208. optional string ossPolicy = 7;
  209. optional string ossSign = 8;
  210. optional string ossBucketName = 9;
  211. optional string s3Credential = 10;
  212. optional string s3Algorithm = 11;
  213. optional string s3Date = 12;
  214. optional string s3Policy = 13;
  215. optional string s3Signature = 14;
  216. optional string s3BucketName = 15;
  217. optional string stcAuthorization = 16;
  218. optional string stcContentSha256 = 17;
  219. optional string stcDate = 18;
  220. optional string stcBucketName = 19;
  221. }
  222. message `+xs+` {
  223. required string downloadUrl = 1;
  224. }
  225. message `+Bs+` {
  226. required string downloadUrl = 1;
  227. }
  228. message Add2BlackListInput {
  229. required string userId = 1;
  230. }
  231. message RemoveFromBlackListInput {
  232. required string userId = 1;
  233. }
  234. message QueryBlackListInput {
  235. required int32 nothing = 1;
  236. }
  237. message QueryBlackListOutput {
  238. repeated string userIds = 1;
  239. }
  240. message BlackListStatusInput {
  241. required string userId = 1;
  242. }
  243. message BlockPushInput {
  244. required string blockeeId = 1;
  245. }
  246. message ModifyPermissionInput {
  247. required int32 openStatus = 1;
  248. }
  249. message GroupInput {
  250. repeated GroupInfo groupInfo = 1;
  251. }
  252. message GroupOutput {
  253. required int32 nothing = 1;
  254. }
  255. message GroupInfo {
  256. required string id = 1;
  257. required string name = 2;
  258. }
  259. message GroupHashInput {
  260. required string userId = 1;
  261. required string groupHashCode = 2;
  262. }
  263. message GroupHashOutput {
  264. required GroupHashType result = 1;
  265. }
  266. enum GroupHashType {
  267. group_success = 0x00;
  268. group_failure = 0x01;
  269. }
  270. message `+Ts+` {
  271. required int32 nothing = 1;
  272. }
  273. message `+Ss+` {
  274. required int32 nothing = 1;
  275. optional string sessionId = 2;
  276. optional int64 joinTime = 3;
  277. }
  278. message `+gs+` {
  279. required int64 syncTime = 1;
  280. required int32 count = 2;
  281. }
  282. message ChrmPullMsgNew
  283. {
  284. required int32 count = 1;
  285. required int64 syncTime = 2;
  286. optional string chrmId=3;
  287. }
  288. message `+Wr+`
  289. {
  290. optional ChannelType type = 1;
  291. optional int32 count = 2;
  292. optional int64 startTime = 3;
  293. optional int32 order = 4;
  294. }
  295. message `+ys+`
  296. {
  297. required ChannelType type = 1;
  298. optional DownStreamMessage msg =2;
  299. optional int32 count = 3;
  300. optional string busChannel = 4;
  301. optional int64 startTime = 5;
  302. optional int64 endTime = 6;
  303. }
  304. message `+Qn+`
  305. {
  306. repeated RelationInfo info = 1;
  307. }
  308. message RelationInfo
  309. {
  310. required ChannelType type = 1;
  311. required string userId = 2;
  312. optional DownStreamMessage msg =3;
  313. optional int64 readMsgTime= 4;
  314. optional int64 unreadCount= 5;
  315. optional string busChannel = 6;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  316. }
  317. message RelationInfoReadTime
  318. {
  319. required ChannelType type = 1;
  320. required int64 readMsgTime= 2;
  321. required string targetId = 3;
  322. }
  323. message `+Es+`
  324. {
  325. required string targetId = 1;
  326. required int64 dataTime = 2;
  327. optional int32 conversationType= 3;
  328. optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  329. }
  330. message HistoryMessageInput
  331. {
  332. required string targetId = 1;
  333. required int64 dataTime =2;
  334. required int32 size = 3;
  335. }
  336. message HistoryMessagesOuput
  337. {
  338. repeated DownStreamMessage list = 1;
  339. required int64 syncTime = 2;
  340. required int32 hasMsg = 3;
  341. }
  342. message `+Is+`
  343. {
  344. required int32 count= 1;
  345. optional int32 order= 2;
  346. }
  347. message `+Ei+`
  348. {
  349. optional int32 userTotalNums = 1;
  350. repeated ChrmMember userInfos = 2;
  351. }
  352. message ChrmMember
  353. {
  354. required int64 time = 1;
  355. required string id = 2;
  356. }
  357. message MPFollowInput
  358. {
  359. required string id = 1;
  360. }
  361. message MPFollowOutput
  362. {
  363. required int32 nothing = 1;
  364. optional MpInfo info =2;
  365. }
  366. message `+Os+`
  367. {
  368. required string state = 1;
  369. }
  370. message MCFollowOutput
  371. {
  372. required int32 nothing = 1;
  373. optional MpInfo info =2;
  374. }
  375. message MpInfo
  376. {
  377. required string mpid=1;
  378. required string name = 2;
  379. required string type = 3;
  380. required int64 time=4;
  381. optional string portraitUrl=5;
  382. optional string extra =6;
  383. }
  384. message SearchMpInput
  385. {
  386. required int32 type=1;
  387. required string id=2;
  388. }
  389. message SearchMpOutput
  390. {
  391. required int32 nothing=1;
  392. repeated MpInfo info = 2;
  393. }
  394. message PullMpInput
  395. {
  396. required int64 time=1;
  397. required string mpid=2;
  398. }
  399. message PullMpOutput
  400. {
  401. required int32 status=1;
  402. repeated MpInfo info = 2;
  403. }
  404. message `+ms+`
  405. {
  406. optional string targetId = 1;
  407. optional int64 time = 2;
  408. optional int32 count = 3;
  409. optional int32 order = 4;
  410. optional string busChannel = 5; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  411. }
  412. message `+zn+`
  413. {
  414. repeated DownStreamMessage list=1;
  415. required int64 syncTime=2;
  416. required int32 hasMsg=3;
  417. }
  418. message `+Ms+`{
  419. optional int32 order=1;
  420. }
  421. message `+Ps+`{
  422. repeated string key=1;
  423. }
  424. message `+ot+`{
  425. required string key=1;
  426. required string value=2;
  427. }
  428. message RtcUserInfo{
  429. required string userId=1;
  430. repeated `+ot+` userData=2; //\u7528\u6237\u8D44\u6E90\u4FE1\u606F
  431. }
  432. message `+$t+`{
  433. repeated RtcUserInfo users=1;
  434. optional string token=2;
  435. optional string sessionId=3;
  436. repeated RtcValueInfo roomInfo = 4; //\u623F\u95F4key value
  437. repeated RtcKVEntity entries = 5;//\u76F4\u64ADKV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
  438. optional int64 syncTime = 6;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
  439. optional int32 offlineKickTime = 7;//server\u8D85\u65F6\u8E22\u4EBA\u65F6\u95F4\uFF0C\u9ED8\u8BA460s
  440. }
  441. message RtcRoomInfoOutput{
  442. optional string roomId = 1;
  443. repeated `+ot+` roomData = 2;
  444. optional int32 userCount = 3;
  445. repeated RtcUserInfo list=4;
  446. }
  447. message `+zr+`{
  448. required int32 roomType=1;
  449. optional int32 broadcastType=2;
  450. optional RtcValueInfo extraInnerData = 3;
  451. optional bool needSysChatroom = 4; //\u662F\u5426\u9700\u8981\u540C\u6B65\u804A\u5929\u5BA4
  452. optional IdentityChangeType identityChangeType = 5; //\u8EAB\u4EFD\u53D8\u66F4\u7C7B\u578B
  453. optional JoinType joinType = 6; // \u52A0\u5165\u623F\u95F4\u7C7B\u578B
  454. }
  455. enum JoinType {
  456. KICK = 0; //\u8E22\u524D\u4E00\u4E2A\u8BBE\u5907
  457. REFUSE = 1; //\u5F53\u524D\u52A0\u5165\u62D2\u7EDD
  458. COEXIST = 2; //\u4E24\u4E2A\u8BBE\u5907\u5171\u5B58
  459. }
  460. message RtcQryInput{
  461. required bool isInterior=1;
  462. required targetType target=2;
  463. repeated string key=3;
  464. }
  465. message `+Ti+`{
  466. repeated `+ot+` outInfo=1;
  467. }
  468. message RtcDelDataInput{
  469. repeated string key=1;
  470. required bool isInterior=2;
  471. required targetType target=3;
  472. }
  473. message `+Xr+`{
  474. required bool interior=1;
  475. required targetType target=2;
  476. repeated string key=3;
  477. optional string objectName=4;
  478. optional string content=5;
  479. }
  480. message `+Ns+`{
  481. required bool interior=1;
  482. required targetType target=2;
  483. required string key=3;
  484. required string value=4;
  485. optional string objectName=5;
  486. optional string content=6;
  487. }
  488. message `+Qr+` {
  489. repeated `+ot+` valueInfo = 1;
  490. required string objectName = 2;
  491. repeated `+ot+` content = 3;
  492. }
  493. message RtcOutput
  494. {
  495. optional int32 nothing=1;
  496. }
  497. message `+Ri+`{
  498. required string rtcToken=1;
  499. }
  500. enum targetType {
  501. ROOM =1 ;
  502. PERSON = 2;
  503. }
  504. message `+ws+`{
  505. required targetType target=1;
  506. repeated `+ot+` valueInfo=2;
  507. optional string objectName=3;
  508. optional string content=4;
  509. }
  510. message `+As+`{
  511. repeated string userId = 1;
  512. }
  513. message `+pu+`{
  514. repeated RtcUserInfo user = 1;
  515. }
  516. message `+fs+`{
  517. required int32 nothing = 1;
  518. }
  519. message `+hu+`{
  520. required int64 inboxTime = 1;
  521. required int64 sendboxTime = 2;
  522. required int64 totalUnreadCount = 3;
  523. }
  524. message `+Rs+`
  525. {
  526. required ChannelType type = 1;
  527. required int64 msgTime = 2;
  528. required string channelId = 3;
  529. }
  530. message SessionMsgReadOutput
  531. {
  532. optional int32 nothing=1;
  533. }
  534. message `+_s+`
  535. {
  536. repeated SessionInfo sessions = 1;
  537. }
  538. message `+vs+`
  539. {
  540. required ChannelType type = 1;
  541. required string channelId = 2;
  542. optional string busChannel = 3;//\u6240\u5C5E\u4F1A\u8BDD\u4E1A\u52A1\u6807\u8BC6
  543. }
  544. message `+fu+`
  545. {
  546. optional int32 nothing=1;
  547. }
  548. message `+Cs+`
  549. {
  550. optional ChannelType type = 1;
  551. optional string conversationId = 2;
  552. repeated DeleteMsg msgs = 3;
  553. optional string busChannel = 4; //\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6\uFF0C\u9650\u523620\u5B57\u7B26\u4EE5\u5185
  554. }
  555. message DeleteMsg
  556. {
  557. optional string msgId = 1;
  558. optional int64 msgDataTime = 2;
  559. optional int32 direct = 3;
  560. }
  561. message ChrmKVEntity {
  562. required string key = 1;
  563. required string value = 2;
  564. optional int32 status = 3;
  565. optional int64 timestamp = 4;
  566. optional string uid = 5;
  567. }
  568. message `+Vs+` {
  569. required ChrmKVEntity entry = 1;
  570. optional bool bNotify = 2;
  571. optional UpStreamMessage notification = 3;
  572. optional ChannelType type = 4;
  573. }
  574. message `+Fs+` {
  575. repeated ChrmKVEntity entry = 1;
  576. optional bool bNotify = 2;
  577. optional UpStreamMessage notification = 3;
  578. optional ChannelType type = 4;
  579. }
  580. message `+mu+` {
  581. repeated ChrmKVEntity entry = 1;
  582. optional bool bNotify = 2;
  583. optional UpStreamMessage notification = 3;
  584. optional ChannelType type = 4;
  585. }
  586. message `+rn+` {
  587. repeated ChrmKVEntity entries = 1;
  588. optional bool bFullUpdate = 2;
  589. optional int64 syncTime = 3;
  590. }
  591. message `+Hs+` {
  592. repeated ChrmKVSOutputEntity errorKeys = 1;
  593. }
  594. message `+_u+`
  595. {
  596. optional string key = 1;
  597. optional int32 errorCode = 2;
  598. }
  599. message `+js+` {
  600. required int64 timestamp = 1;
  601. }
  602. message `+vu+` {
  603. required int64 version=1;
  604. required string value=2;
  605. }
  606. message `+on+` {
  607. required int64 version=1;
  608. required bool reserve=2;
  609. }
  610. message `+$s+` {
  611. required int64 version=1;
  612. optional bool reserve=2;
  613. }
  614. message `+Si+` {
  615. repeated UserSettingItem items = 1;
  616. required int64 version=2;
  617. }
  618. message UserSettingItem {
  619. required string targetId= 1;
  620. required ChannelType type = 2;
  621. required string key = 4;
  622. required bytes value = 5;
  623. required int64 version=6;
  624. required int32 status=7;
  625. repeated SessionTagItem tags= 8;
  626. }
  627. message `+Ks+` {
  628. required int64 time = 1;
  629. }
  630. message `+bi+` {
  631. required int64 version=1;
  632. repeated SessionState state= 2;
  633. }
  634. message `+Zr+` {
  635. required ChannelType type = 1;
  636. required string channelId = 2;
  637. optional int64 time = 3;
  638. repeated SessionStateItem stateItem = 4;
  639. optional string busChannel = 5;//\u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  640. }
  641. message `+ei+` {
  642. required SessionStateType sessionStateType = 1;
  643. required string value = 2;
  644. repeated SessionTagItem tags = 3;
  645. }
  646. enum SessionStateType {
  647. IsSilent = 1;
  648. IsTop = 2;
  649. Tags = 3;
  650. }
  651. message `+ti+` {
  652. required int64 version=1;
  653. repeated SessionState state= 2;
  654. }
  655. message `+qs+` {
  656. required int64 version=1;
  657. }
  658. message `+ni+` {
  659. repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
  660. optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  661. }
  662. message `+yu+` {
  663. repeated string msgId=1; //\u5DF2\u8BFB\u6D88\u606FID
  664. optional string channelId = 2; // \u8BE5\u6D88\u606F\u6240\u5C5E\u4F1A\u8BDD\u7684\u4E1A\u52A1\u6807\u8BC6
  665. }
  666. message `+Ni+` {
  667. required int32 totalMemberNum = 1;//\u7FA4\u5185\u603B\u4EBA\u6570
  668. repeated GrpMsgReadUser list = 2;//\u5DF2\u8BFB\u7528\u6237\u5217\u8868\uFF08list\u590D\u7C7B\u578B\uFF09
  669. }
  670. message `+Cu+` {
  671. required int64 readTime = 1;//\u5DF2\u8BFB\u65F6\u95F4
  672. required string userId = 2;//\u5DF2\u8BFB\u7528\u6237id
  673. }
  674. message `+Gs+` {
  675. required int64 version=1;
  676. repeated SessionTagItem tags=2;
  677. }
  678. message `+Fn+` {
  679. required string tagId=1;
  680. optional string name=2;
  681. optional int64 createdTime=3;
  682. optional bool isTop=4;
  683. }
  684. message `+Ys+` {
  685. required int64 version=1;
  686. repeated SessionTagItem tags=2;
  687. }
  688. message `+Js+` {
  689. repeated string tagId=1;
  690. }
  691. message `+Ii+` {
  692. required int64 version=1;
  693. required bool reserve=2;
  694. }
  695. message `+Ws+` {
  696. required string sdkInfo=1; // \u7528\u6237\u96C6\u6210\u7684 sdk \u4FE1\u606F,json \u683C\u5F0F {"web-rtc": "4.0.3.7"}
  697. }
  698. message `+Eu+`
  699. {
  700. optional int32 nothing=1; //\u5360\u4F4D
  701. }
  702. message `+zs+`
  703. {
  704. required int32 type= 1; //(\u901A\u77E5\u7C7B\u578B 1:rtc\u623F\u95F4\u72B6\u6001KV\u53D8\u66F4\u901A\u77E5)
  705. optional int64 time= 2; //\u6D88\u606F\u4EA7\u751F\u65F6\u95F4
  706. optional string roomId=3; //\u4E3B\u64AD\u623F\u95F4id
  707. }
  708. message `+Qs+`
  709. {
  710. required int64 timestamp = 1;
  711. required string roomId = 2;
  712. }
  713. message `+wi+`
  714. {
  715. repeated RtcKVEntity entries = 1;
  716. optional bool bFullUpdate = 2;
  717. optional int64 syncTime = 3;
  718. }
  719. message RtcKVEntity
  720. {
  721. required string key = 1;
  722. required string value = 2;
  723. optional int32 status = 3;
  724. optional int64 timestamp = 4;
  725. optional string uid = 5;
  726. }
  727. enum IdentityChangeType
  728. {
  729. AnchorToViewer = 1; //1\u4E3A\u4E3B\u64AD\u53D8\u89C2\u4F17
  730. ViewerToAnchor = 2; //2\u4E3A\u89C2\u4F17\u53D8\u4E3B\u64AD
  731. }
  732. message `+Xs+`
  733. {
  734. required string userId = 1;
  735. }
  736. message `+Oi+`
  737. {
  738. repeated RtcJoinedInfo info = 1;
  739. }
  740. message RtcJoinedInfo
  741. {
  742. required string deviceId = 1; //\u8BBE\u5907ID
  743. required string roomId = 2; //\u52A0\u5165\u7684\u623F\u95F4ID
  744. optional int64 joinTime = 3; //\u52A0\u5165\u7684\u65F6\u95F4
  745. }
  746. message `+Ru+`
  747. {
  748. required string rtcToken=1;
  749. repeated RtcKVEntity entries = 2;//KV\u5C5E\u6027\u5BF9\u8C61\u96C6\u5408
  750. optional int64 syncTime = 3;//\u6240\u6709\u5C5E\u6027\u7684\u6700\u5927\u65F6\u95F4\u6233\uFF08\u4E0B\u6B21\u62C9\u53D6KV\u65F6\u7528\uFF09\u3002
  751. }
  752. message `+Zs+`
  753. {
  754. required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
  755. optional int32 timeoutTime=2; //\u9080\u8BF7\u8D85\u65F6\u65F6\u95F4(\u79D2),\u9ED8\u8BA4\u4E09\u5341\u79D2
  756. required string invitedRoomId=3; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
  757. 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
  758. required string inviteSessionId= 5; //\u5BA2\u6237\u7AEF\u4FDD\u8BC1\u552F\u4E00\u6027(\u5EFA\u8BAEroomid_userid_\u65F6\u95F4\u6233_\u968F\u673A\u6570)
  759. }
  760. message `+ea+`
  761. {
  762. required string invitedUserId=1; //\u88AB\u9080\u8BF7\u7684\u4EBA\u7684uid
  763. required string invitedRoomId=2; //\u88AB\u9080\u8BF7\u7684\u623F\u95F4
  764. 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
  765. required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId,\u5BA2\u6237\u7AEF\u53D1\u8D77\u9080\u8BF7\u65F6\u4EA7\u751F
  766. }
  767. message `+ta+`
  768. {
  769. required string inviteUserId=1; //\u9080\u8BF7\u7684\u4EBA\u7684uid
  770. required int32 answerCode=2; //\u662F\u5426\u63A5\u53D7\u8FDE\u9EA6\u9080\u8BF7.0\u4E3A\u62D2\u7EDD,1\u4E3A\u63A5\u53D7
  771. required string inviteRoomId=3; //\u9080\u8BF7\u7684\u623F\u95F4
  772. required string inviteSessionId=4; //\u9080\u8BF7\u7684sessionId
  773. required string content=5; //\u9700\u8981\u8F6C\u53D1\u7684content
  774. 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
  775. 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
  776. }
  777. message `+na+`
  778. {
  779. required string inviteRoomId=1; //\u9080\u8BF7\u7684\u623F\u95F4
  780. required string inviteSessionId=2; //\u9080\u8BF7\u7684sessionId
  781. required string inviteContent=3; //\u7ED3\u675F\u8FDE\u9EA6\u7684\u4FE1\u606F(\u9700\u8981\u900F\u4F20\u7ED9\u623F\u95F4\u5185\u5176\u4ED6\u4EBA)
  782. repeated string inviteRoomKeys=4; //\u9700\u8981\u5220\u9664\u8FDE\u9EA6\u7684\u4FE1\u606F\u7684key
  783. }
  784. }
  785. `,Fa,Ha,bn,Qt,Nn,Uo=(Fa=Yl,function(t,e){var n,r,i={};return i.ByteBuffer=t,i.c=t,n=t,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 o={};return o.IS_NODE=!(typeof process!="object"||process+""!="[object process]"||process.browser),o.XHR=function(){var s,c=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],d=null;for(s=0;s<c.length;s++){try{d=c[s]()}catch{continue}break}if(!d)throw Error("XMLHttpRequest is not supported");return d},o.fetch=function(s,c){if(c&&typeof c!="function"&&(c=null),o.IS_NODE)if(c)g.readFile(s,function(l,h){c(l?null:""+h)});else try{return g.readFileSync(s)}catch{return null}else{var d=o.XHR();if(d.open("GET",s,!!c),d.setRequestHeader("Accept","text/plain"),typeof d.overrideMimeType=="function"&&d.overrideMimeType("text/plain"),!c)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"?c(d.responseText):c(null))},d.readyState==4)return;d.send(null)}},o.toCamelCase=function(s){return s.replace(/_([a-zA-Z])/g,function(c,d){return d.toUpperCase()})},o}(),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(o,s){function c(m,_){var v=-1,y=1;if(m.charAt(0)=="-"&&(y=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))v=parseInt(m);else if(s.NUMBER_HEX.test(m))v=parseInt(m.substring(2),16);else{if(!s.NUMBER_OCT.test(m))throw Error("illegal id value: "+(y<0?"-":"")+m);v=parseInt(m.substring(1),8)}if(v=0|y*v,!_&&v<0)throw Error("illegal id value: "+(y<0?"-":"")+m);return v}function d(m){var _=1;if(m.charAt(0)=="-"&&(_=-1,m=m.substring(1)),s.NUMBER_DEC.test(m))return _*parseInt(m,10);if(s.NUMBER_HEX.test(m))return _*parseInt(m.substring(2),16);if(s.NUMBER_OCT.test(m))return _*parseInt(m.substring(1),8);if(m==="inf")return 1/0*_;if(m==="nan")return NaN;if(s.NUMBER_FLT.test(m))return _*parseFloat(m);throw Error("illegal number value: "+(_<0?"-":"")+m)}function l(m,_,v){m[_]===void 0?m[_]=v:(Array.isArray(m[_])||(m[_]=[m[_]]),m[_].push(v))}var h,a,u={},f=function(m){this.source=m+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},p=f.prototype;return p._readString=function(){var m,_=this._stringOpen==='"'?s.STRING_DQ:s.STRING_SQ;if(_.lastIndex=this.index-1,!(m=_.exec(this.source)))throw Error("unterminated string");return this.index=_.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,m[1]},p.next=function(){var m,_,v,y,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;s.WHITESPACE.test(v=this.source.charAt(this.index));)if(v===`
  786. `&&++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)!==`
  787. `;)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===`
  788. `&&++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(y=this.index,s.DELIM.lastIndex=0,!s.DELIM.test(this.source.charAt(y++)))for(;y<this.source.length&&!s.DELIM.test(this.source.charAt(y));)++y;return((C=this.source.substring(this.index,this.index=y))==='"'||C==="'")&&(this._stringOpen=C),C},p.peek=function(){if(this.stack.length===0){var m=this.next();if(m===null)return null;this.stack.push(m)}return this.stack[0]},p.skip=function(m){var _=this.next();if(_!==m)throw Error("illegal '"+_+"', '"+m+"' expected")},p.omit=function(m){return this.peek()===m&&(this.next(),!0)},p.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"},u.Tokenizer=f,(a=(h=function(m){this.tn=new f(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(),!s.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(y){throw y.message="Parse error at line "+this.tn.line+": "+y.message,y}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(),s.NUMBER.test(_))return d(_);if(s.BOOL.test(_))return _.toLowerCase()==="true";if(m&&s.TYPEREF.test(_))return _;throw Error("illegal value: "+_)},a._parseOption=function(m,_){var v,y=this.tn.next(),C=!1;if(y==="("&&(C=!0,y=this.tn.next()),!s.TYPEREF.test(y))throw Error("illegal option name: "+y);v=y,C&&(this.tn.skip(")"),v="("+v+")",y=this.tn.peek(),s.FQTYPEREF.test(y)&&(v+=y,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(!s.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(!s.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,y="rpc",C=this.tn.next();if(!s.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()),!s.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[y]===void 0&&(m[y]={}),m[y][_]=v},a._parseMessage=function(m,_){var v=!!_,y=this.tn.next(),C={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!s.NAME.test(y))throw Error("illegal "+(v?"group":"message")+" name: "+y);for(C.name=y,v&&(this.tn.skip("="),_.id=c(this.tn.next()),C.isGroup=!0),(y=this.tn.peek())==="["&&_&&this._parseFieldOptions(_),this.tn.skip("{");(y=this.tn.next())!=="}";)if(s.RULE.test(y))this._parseMessageField(C,y);else if(y==="oneof")this._parseMessageOneOf(C);else if(y==="enum")this._parseEnum(C);else if(y==="message")this._parseMessage(C);else if(y==="option")this._parseOption(C);else if(y==="service")this._parseService(C);else if(y==="extensions")C.extensions=this._parseExtensionRanges();else if(y==="reserved")this._parseIgnored();else if(y==="extend")this._parseExtend(C);else{if(!s.TYPEREF.test(y))throw Error("illegal message token: "+y);if(!this.proto3)throw Error("illegal field rule: "+y);this._parseMessageField(C,"optional",y)}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 y,C,I;if(!s.RULE.test(_))throw Error("illegal message field rule: "+_);if(y={rule:_,type:"",name:"",options:{},id:0},_==="map"){if(v)throw Error("illegal type: "+v);if(this.tn.skip("<"),C=this.tn.next(),!s.TYPE.test(C)&&!s.TYPEREF.test(C))throw Error("illegal message field type: "+C);if(y.keytype=C,this.tn.skip(","),C=this.tn.next(),!s.TYPE.test(C)&&!s.TYPEREF.test(C))throw Error("illegal message field: "+C);if(y.type=C,this.tn.skip(">"),C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}else if((v=v!==void 0?v:this.tn.next())==="group"){if(I=this._parseMessage(m,y),!/^[A-Z]/.test(I.name))throw Error("illegal group name: "+I.name);y.type=I.name,y.name=I.name.toLowerCase(),this.tn.omit(";")}else{if(!s.TYPE.test(v)&&!s.TYPEREF.test(v))throw Error("illegal message field type: "+v);if(y.type=v,C=this.tn.next(),!s.NAME.test(C))throw Error("illegal message field name: "+C);y.name=C,this.tn.skip("="),y.id=c(this.tn.next()),(C=this.tn.peek())==="["&&this._parseFieldOptions(y),this.tn.skip(";")}return m.fields.push(y),y},a._parseMessageOneOf=function(m){var _,v,y,C=this.tn.next();if(!s.NAME.test(C))throw Error("illegal oneof name: "+C);for(v=C,y=[],this.tn.skip("{");(C=this.tn.next())!=="}";)(_=this._parseMessageField(m,"optional",C)).oneof=v,y.push(_.id);this.tn.omit(";"),m.oneofs[v]=y},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:{}},y=this.tn.next();if(!s.NAME.test(y))throw Error("illegal name: "+y);for(v.name=y,this.tn.skip("{");(y=this.tn.next())!=="}";)if(y==="option")this._parseOption(v);else{if(!s.NAME.test(y))throw Error("illegal name: "+y);this.tn.skip("="),_={name:y,id:c(this.tn.next(),!0)},(y=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,y=[];do{for(_=[];;){switch(m=this.tn.next()){case"min":v=o.ID_MIN;break;case"max":v=o.ID_MAX;break;default:v=d(m)}if(_.push(v),_.length===2)break;if(this.tn.peek()!=="to"){_.push(v);break}this.tn.next()}y.push(_)}while(this.tn.omit(","));return this.tn.skip(";"),y},a._parseExtend=function(m){var _,v=this.tn.next();if(!s.TYPEREF.test(v))throw Error("illegal extend reference: "+v);for(_={ref:v,fields:[]},this.tn.skip("{");(v=this.tn.next())!=="}";)if(s.RULE.test(v))this._parseMessageField(_,v);else{if(!s.TYPEREF.test(v))throw Error("illegal extend token: "+v);if(!this.proto3)throw Error("illegal field rule: "+v);this._parseMessageField(_,"optional",v)}return this.tn.omit(";"),m.messages.push(_),_},a.toString=function(){return"Parser at line "+this.tn.line},u.Parser=h,u}(i,i.Lang),i.Reflect=function(o){function s(E,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 o.Long(E.low,E.high,T===void 0?E.unsigned:T);if(typeof E=="string")return o.Long.fromString(E,T||!1,10);if(typeof E=="number")return o.Long.fromNumber(E,T||!1);throw Error("not convertible to Long")}function c(E,T){var A=T.readVarint32(),L=7&A,k=A>>>3;switch(L){case o.WIRE_TYPES.VARINT:do A=T.readUint8();while((128&A)==128);break;case o.WIRE_TYPES.BITS64:T.offset+=8;break;case o.WIRE_TYPES.LDELIM:A=T.readVarint32(),T.offset+=A;break;case o.WIRE_TYPES.STARTGROUP:c(k,T);break;case o.WIRE_TYPES.ENDGROUP:if(k===E)return!1;throw Error("Illegal GROUPEND after unknown group: "+k+" ("+E+" expected)");case o.WIRE_TYPES.BITS32:T.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+E+": "+L)}return!0}var d,l,h,a,u,f,p,m,_,v,y,C,I,P,b,R,M={},F=function(E,T,A){this.builder=E,this.parent=T,this.name=A,this.className},q=F.prototype;return q.fqn=function(){for(var E=this.name,T=this;(T=T.parent)!=null;)E=T.name+"."+E;return E},q.toString=function(E){return(E?this.className+" ":"")+this.fqn()},q.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},M.T=F,(l=(d=function(E,T,A,L,k){F.call(this,E,T,A),this.className="Namespace",this.children=[],this.options=L||{},this.syntax=k||"proto2"}).prototype=Object.create(F.prototype)).getChildren=function(E){var T,A,L;if((E=E||null)==null)return this.children.slice();for(T=[],A=0,L=this.children.length;L>A;++A)this.children[A]instanceof E&&T.push(this.children[A]);return T},l.addChild=function(E){var T;if(T=this.getChild(E.name))if(T instanceof u.Field&&T.name!==T.originalName&&this.getChild(T.originalName)===null)T.name=T.originalName;else{if(!(E instanceof u.Field&&E.name!==E.originalName&&this.getChild(E.originalName)===null))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+E.name);E.name=E.originalName}this.children.push(E)},l.getChild=function(E){var T,A,L=typeof E=="number"?"id":"name";for(T=0,A=this.children.length;A>T;++T)if(this.children[T][L]===E)return this.children[T];return null},l.resolve=function(E,T){var A,L=typeof E=="string"?E.split("."):E,k=this,V=0;if(L[V]===""){for(;k.parent!==null;)k=k.parent;V++}do{do{if(!(k instanceof M.Namespace)){k=null;break}if(!((A=k.getChild(L[V]))&&A instanceof M.T&&(!T||A instanceof M.Namespace))){k=null;break}k=A,V++}while(V<L.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,A,L=[],k=E;do L.unshift(k.name),k=k.parent;while(k!==null);for(T=1;T<=L.length;T++)if(A=L.slice(L.length-T),E===this.resolve(A,E instanceof M.Namespace))return A.join(".");return E.fqn()},l.build=function(){var E,T,A,L={},k=this.children;for(T=0,A=k.length;A>T;++T)(E=k[T])instanceof d&&(L[E.name]=E.build());return Object.defineProperty&&Object.defineProperty(L,"$options",{value:this.buildOpt()}),L},l.buildOpt=function(){var E,T,A,L,k={},V=Object.keys(this.options);for(E=0,T=V.length;T>E;++E)A=V[E],L=this.options[V[E]],k[A]=L;return k},l.getOption=function(E){return E===void 0?this.options:this.options[E]!==void 0?this.options[E]:null},M.Namespace=d,a=(h=function(E,T,A,L){if(this.type=E,this.resolvedType=T,this.isMapKey=A,this.syntax=L,A&&o.MAP_KEY_TYPES.indexOf(E)<0)throw Error("Invalid map key type: "+E.name)}).prototype,h.defaultFieldValue=function(E){if(typeof E=="string"&&(E=o.TYPES[E]),E.defaultValue===void 0)throw Error("default value for type "+E.name+" is not supported");return E==o.TYPES.bytes?new n(0):E.defaultValue},a.verifyValue=function(E){var T,A,L,k=function(V,j){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+V+" ("+j+")")}.bind(this);switch(this.type){case o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E>4294967295?0|E:E;case o.TYPES.uint32:case o.TYPES.fixed32:return(typeof E!="number"||E==E&&E%1!=0)&&k(typeof E,"not an integer"),E<0?E>>>0:E;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:if(o.Long)try{return s(E,!1)}catch(V){k(typeof E,V.message)}else k(typeof E,"requires Long.js");case o.TYPES.uint64:case o.TYPES.fixed64:if(o.Long)try{return s(E,!0)}catch(V){k(typeof E,V.message)}else k(typeof E,"requires Long.js");case o.TYPES.bool:return typeof E!="boolean"&&k(typeof E,"not a boolean"),E;case o.TYPES.float:case o.TYPES.double:return typeof E!="number"&&k(typeof E,"not a number"),E;case o.TYPES.string:return typeof E=="string"||E&&E instanceof String||k(typeof E,"not a string"),""+E;case o.TYPES.bytes:return t.isByteBuffer(E)?E:t.wrap(E);case o.TYPES.enum:for(T=this.resolvedType.getChildren(o.Reflect.Enum.Value),L=0;L<T.length;L++)if(T[L].name==E||T[L].id==E)return T[L].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 o.TYPES.group:case o.TYPES.message:if(E&&typeof E=="object"||k(typeof E,"object expected"),E instanceof this.resolvedType.clazz)return E;if(E instanceof o.Builder.Message){for(L in A={},E)E.hasOwnProperty(L)&&(A[L]=E[L]);E=A}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 A;switch(this.type){case o.TYPES.int32:return T<0?n.calculateVarint64(T):n.calculateVarint32(T);case o.TYPES.uint32:return n.calculateVarint32(T);case o.TYPES.sint32:return n.calculateVarint32(n.zigZagEncode32(T));case o.TYPES.fixed32:case o.TYPES.sfixed32:case o.TYPES.float:return 4;case o.TYPES.int64:case o.TYPES.uint64:return n.calculateVarint64(T);case o.TYPES.sint64:return n.calculateVarint64(n.zigZagEncode64(T));case o.TYPES.fixed64:case o.TYPES.sfixed64:return 8;case o.TYPES.bool:return 1;case o.TYPES.enum:return n.calculateVarint32(T);case o.TYPES.double:return 8;case o.TYPES.string:return A=n.calculateUTF8Bytes(T),n.calculateVarint32(A)+A;case o.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");return n.calculateVarint32(T.remaining())+T.remaining();case o.TYPES.message:return A=this.resolvedType.calculate(T),n.calculateVarint32(A)+A;case o.TYPES.group:return(A=this.resolvedType.calculate(T))+n.calculateVarint32(E<<3|o.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")},a.encodeValue=function(E,T,A){var L,k;if(T===null)return A;switch(this.type){case o.TYPES.int32:T<0?A.writeVarint64(T):A.writeVarint32(T);break;case o.TYPES.uint32:A.writeVarint32(T);break;case o.TYPES.sint32:A.writeVarint32ZigZag(T);break;case o.TYPES.fixed32:A.writeUint32(T);break;case o.TYPES.sfixed32:A.writeInt32(T);break;case o.TYPES.int64:case o.TYPES.uint64:A.writeVarint64(T);break;case o.TYPES.sint64:A.writeVarint64ZigZag(T);break;case o.TYPES.fixed64:A.writeUint64(T);break;case o.TYPES.sfixed64:A.writeInt64(T);break;case o.TYPES.bool:typeof T=="string"?A.writeVarint32(T.toLowerCase()==="false"?0:!!T):A.writeVarint32(T?1:0);break;case o.TYPES.enum:A.writeVarint32(T);break;case o.TYPES.float:A.writeFloat32(T);break;case o.TYPES.double:A.writeFloat64(T);break;case o.TYPES.string:A.writeVString(T);break;case o.TYPES.bytes:if(T.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+T.remaining()+" bytes remaining");L=T.offset,A.writeVarint32(T.remaining()),A.append(T),T.offset=L;break;case o.TYPES.message:k=new n().LE(),this.resolvedType.encode(T,k),A.writeVarint32(k.offset),A.append(k.flip());break;case o.TYPES.group:this.resolvedType.encode(T,A),A.writeVarint32(E<<3|o.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+T+" (unknown type)")}return A},a.decode=function(E,T,A){if(T!=this.type.wireType)throw Error("Unexpected wire type for element");var L,k;switch(this.type){case o.TYPES.int32:return 0|E.readVarint32();case o.TYPES.uint32:return E.readVarint32()>>>0;case o.TYPES.sint32:return 0|E.readVarint32ZigZag();case o.TYPES.fixed32:return E.readUint32()>>>0;case o.TYPES.sfixed32:return 0|E.readInt32();case o.TYPES.int64:return E.readVarint64();case o.TYPES.uint64:return E.readVarint64().toUnsigned();case o.TYPES.sint64:return E.readVarint64ZigZag();case o.TYPES.fixed64:return E.readUint64();case o.TYPES.sfixed64:return E.readInt64();case o.TYPES.bool:return!!E.readVarint32();case o.TYPES.enum:return E.readVarint32();case o.TYPES.float:return E.readFloat();case o.TYPES.double:return E.readDouble();case o.TYPES.string:return E.readVString();case o.TYPES.bytes:if(k=E.readVarint32(),E.remaining()<k)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+k+" required but got only "+E.remaining());return(L=E.clone()).limit=L.offset+k,E.offset+=k,L;case o.TYPES.message:return k=E.readVarint32(),this.resolvedType.decode(E,k);case o.TYPES.group:return this.resolvedType.decode(E,-1,A)}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 o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:case o.TYPES.uint32:case o.TYPES.fixed32:return this.verifyValue(parseInt(E));case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:case o.TYPES.uint64:case o.TYPES.fixed64:return this.verifyValue(E);case o.TYPES.bool:return E==="true";case o.TYPES.string:return this.verifyValue(E);case o.TYPES.bytes:return n.fromBinary(E)}},a.valueToString=function(E){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===o.TYPES.bytes?E.toString("binary"):E.toString()},M.Element=h,(f=(u=function(E,T,A,L,k,V){d.call(this,E,T,A,L,V),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,A,L,k;if(this.clazz&&!E)return this.clazz;for(T=function(V,j){function G(U,Y,ee,re){var ue,ye,pr,Sn,Bi,Vi,Jt;if(U===null||typeof U!="object")return re&&re instanceof V.Reflect.Enum&&(ue=V.Reflect.Enum.getName(re.object,U))!==null?ue:U;if(n.isByteBuffer(U))return Y?U.toBase64():U.toBuffer();if(V.Long.isLong(U))return ee?U.toString():V.Long.fromValue(U);if(Array.isArray(U))return ye=[],U.forEach(function(ul,dl){ye[dl]=G(ul,Y,ee,re)}),ye;if(ye={},U instanceof V.Map){for(Sn=(pr=U.entries()).next();!Sn.done;Sn=pr.next())ye[U.keyElem.valueToString(Sn.value[0])]=G(Sn.value[1],Y,ee,U.valueElem.resolvedType);return ye}for(Jt in Bi=U.$type,Vi=void 0,U)U.hasOwnProperty(Jt)&&(ye[Jt]=Bi&&(Vi=Bi.getChild(Jt))?G(U[Jt],Y,ee,Vi.resolvedType):G(U[Jt],Y,ee));return ye}var J,oe,he=j.getChildren(V.Reflect.Message.Field),de=j.getChildren(V.Reflect.Message.OneOf),ae=function(U){var Y,ee,re,ue;for(V.Builder.Message.call(this),Y=0,ee=de.length;ee>Y;++Y)this[de[Y].name]=null;for(Y=0,ee=he.length;ee>Y;++Y)this[(re=he[Y]).name]=re.repeated?[]:re.map?new V.Map(re):null,!re.required&&j.syntax!=="proto3"||re.defaultValue===null||(this[re.name]=re.defaultValue);if(arguments.length>0)if(arguments.length!==1||U===null||typeof U!="object"||!(typeof U.encode!="function"||U instanceof ae)||Array.isArray(U)||U instanceof V.Map||n.isByteBuffer(U)||U instanceof ArrayBuffer||V.Long&&U instanceof V.Long)for(Y=0,ee=arguments.length;ee>Y;++Y)(ue=arguments[Y])!==void 0&&this.$set(he[Y].name,ue);else this.$set(U)},te=ae.prototype=Object.create(V.Builder.Message.prototype);for(te.add=function(U,Y,ee){var re=j._fieldsByName[U];if(!ee){if(!re)throw Error(this+"#"+U+" is undefined");if(!(re instanceof V.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+re.toString(!0));if(!re.repeated)throw Error(this+"#"+U+" is not a repeated field");Y=re.verifyValue(Y,!0)}return this[U]===null&&(this[U]=[]),this[U].push(Y),this},te.$add=te.add,te.set=function(U,Y,ee){var re,ue,ye;if(U&&typeof U=="object"){for(re in ee=Y,U)U.hasOwnProperty(re)&&(Y=U[re])!==void 0&&this.$set(re,Y,ee);return this}if(ue=j._fieldsByName[U],ee)this[U]=Y;else{if(!ue)throw Error(this+"#"+U+" is not a field: undefined");if(!(ue instanceof V.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ue.toString(!0));this[ue.name]=Y=ue.verifyValue(Y)}return ue&&ue.oneof&&(ye=this[ue.oneof.name],Y!==null?(ye!==null&&ye!==ue.name&&(this[ye]=null),this[ue.oneof.name]=ue.name):ye===U&&(this[ue.oneof.name]=null)),this},te.$set=te.set,te.get=function(U,Y){if(Y)return this[U];var ee=j._fieldsByName[U];if(!(ee&&ee instanceof V.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: undefined");if(!(ee instanceof V.Reflect.Message.Field))throw Error(this+"#"+U+" is not a field: "+ee.toString(!0));return this[ee.name]},te.$get=te.get,J=0;J<he.length;J++)(oe=he[J])instanceof V.Reflect.Message.ExtensionField||j.builder.options.populateAccessors&&function(U){var Y,ee,re,ue=U.originalName.replace(/(_[a-zA-Z])/g,function(ye){return ye.toUpperCase().replace("_","")});ue=ue.substring(0,1).toUpperCase()+ue.substring(1),Y=U.originalName.replace(/([A-Z])/g,function(ye){return"_"+ye}),ee=function(ye,pr){return this[U.name]=pr?ye:U.verifyValue(ye),this},re=function(){return this[U.name]},j.getChild("set"+ue)===null&&(te["set"+ue]=ee),j.getChild("set_"+Y)===null&&(te["set_"+Y]=ee),j.getChild("get"+ue)===null&&(te["get"+ue]=re),j.getChild("get_"+Y)===null&&(te["get_"+Y]=re)}(oe);return te.encode=function(U,Y){var ee,re;typeof U=="boolean"&&(Y=U,U=void 0),ee=!1,U||(U=new t,ee=!0),re=U.littleEndian;try{return j.encode(this,U.LE(),Y),(ee?U.flip():U).LE(re)}catch(ue){throw U.LE(re),ue}},ae.encode=function(U,Y,ee){return new ae(U).encode(Y,ee)},te.calculate=function(){return j.calculate(this)},te.encodeDelimited=function(U){var Y,ee=!1;return U||(U=new n,ee=!0),Y=new n().LE(),j.encode(this,Y).flip(),U.writeVarint32(Y.remaining()),U.append(Y),ee?U.flip():U},te.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toArrayBuffer()),U}},te.toArrayBuffer=te.encodeAB,te.encodeNB=function(){try{return this.encode().toBuffer()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBuffer()),U}},te.toBuffer=te.encodeNB,te.encode64=function(){try{return this.encode().toBase64()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toBase64()),U}},te.toBase64=te.encode64,te.encodeHex=function(){try{return this.encode().toHex()}catch(U){throw U.encoded&&(U.encoded=U.encoded.toHex()),U}},te.toHex=te.encodeHex,te.toRaw=function(U,Y){return G(this,!!U,!!Y,this.$type)},te.encodeJSON=function(){return JSON.stringify(G(this,!0,!0,this.$type))},ae.decode=function(U,Y){var ee,re;typeof U=="string"&&(U=n.wrap(U,Y||"base64")),ee=(U=n.isByteBuffer(U)?U:n.wrap(U)).littleEndian;try{return re=j.decode(U.LE()),U.LE(ee),re}catch(ue){throw U.LE(ee),ue}},ae.decodeDelimited=function(U,Y){var ee,re,ue;if(typeof U=="string"&&(U=n.wrap(U,Y||"base64")),(U=n.isByteBuffer(U)?U:n.wrap(U)).remaining()<1)return null;if(ee=U.offset,re=U.readVarint32(),U.remaining()<re)return U.offset=ee,null;try{return ue=j.decode(U.slice(U.offset,U.offset+re).LE()),U.offset+=re,ue}catch(ye){throw U.offset+=re,ye}},ae.decode64=function(U){return ae.decode(U,"base64")},ae.decodeHex=function(U){return ae.decode(U,"hex")},ae.decodeJSON=function(U){return new ae(JSON.parse(U))},te.toString=function(){return j.toString()},Object.defineProperty&&(Object.defineProperty(ae,"$options",{value:j.buildOpt()}),Object.defineProperty(te,"$options",{value:ae.$options}),Object.defineProperty(ae,"$type",{value:j}),Object.defineProperty(te,"$type",{value:j})),ae}(o,this),this._fields=[],this._fieldsById={},this._fieldsByName={},L=0,k=this.children.length;k>L;L++)if((A=this.children[L])instanceof y||A instanceof u||A instanceof P){if(T.hasOwnProperty(A.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+A.toString(!0)+" cannot override static property '"+A.name+"'");T[A.name]=A.build()}else if(A instanceof u.Field)A.build(),this._fields.push(A),this._fieldsById[A.id]=A,this._fieldsByName[A.name]=A;else if(!(A instanceof u.OneOf||A instanceof I))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[L].toString(!0));return this.clazz=T},f.encode=function(E,T,A){var L,k,V,j,G,J=null;for(V=0,j=this._fields.length;j>V;++V)k=E[(L=this._fields[V]).name],L.required&&k===null?J===null&&(J=L):L.encode(A?k:L.verifyValue(k),T,E);if(J!==null)throw(G=Error("Missing at least one required field for "+this.toString(!0)+": "+J)).encoded=T,G;return T},f.calculate=function(E){for(var T,A,L=0,k=0,V=this._fields.length;V>k;++k){if(A=E[(T=this._fields[k]).name],T.required&&A===null)throw Error("Missing at least one required field for "+this.toString(!0)+": "+T);L+=T.calculate(A,E)}return L},f.decode=function(E,T,A){var L,k,V,j,G,J,oe,he,de,ae,te,U;for(T=typeof T=="number"?T:-1,G=E.offset,J=new this.clazz;E.offset<G+T||T===-1&&E.remaining()>0;){if(V=(L=E.readVarint32())>>>3,(k=7&L)===o.WIRE_TYPES.ENDGROUP){if(V!==A)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+V+" ("+(A?A+" expected":"not a group")+")");break}if(j=this._fieldsById[V])j.repeated&&!j.options.packed?J[j.name].push(j.decode(k,E)):j.map?(he=j.decode(k,E),J[j.name].set(he[0],he[1])):(J[j.name]=j.decode(k,E),j.oneof&&((de=J[j.oneof.name])!==null&&de!==j.name&&(J[de]=null),J[j.oneof.name]=j.name));else switch(k){case o.WIRE_TYPES.VARINT:E.readVarint32();break;case o.WIRE_TYPES.BITS32:E.offset+=4;break;case o.WIRE_TYPES.BITS64:E.offset+=8;break;case o.WIRE_TYPES.LDELIM:oe=E.readVarint32(),E.offset+=oe;break;case o.WIRE_TYPES.STARTGROUP:for(;c(V,E););break;default:throw Error("Illegal wire type for unknown field "+V+" in "+this.toString(!0)+"#decode: "+k)}}for(ae=0,te=this._fields.length;te>ae;++ae)if(J[(j=this._fields[ae]).name]===null)if(this.syntax==="proto3")J[j.name]=j.defaultValue;else{if(j.required)throw(U=Error("Missing at least one required field for "+this.toString(!0)+": "+j.name)).decoded=J,U;o.populateDefaults&&j.defaultValue!==null&&(J[j.name]=j.defaultValue)}return J},M.Message=u,(m=(p=function(E,T,A,L,k,V,j,G,J,oe){F.call(this,E,T,V),this.className="Message.Field",this.required=A==="required",this.repeated=A==="repeated",this.map=A==="map",this.keyType=L||null,this.type=k,this.resolvedType=null,this.id=j,this.options=G||{},this.defaultValue=null,this.oneof=J||null,this.syntax=oe||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof u.ExtensionField||(this.name=o.Util.toCamelCase(this.name))}).prototype=Object.create(F.prototype)).build=function(){this.element=new h(this.type,this.resolvedType,!1,this.syntax),this.map&&(this.keyElement=new h(this.keyType,void 0,!0,this.syntax)),this.syntax!=="proto3"||this.repeated||this.map?this.options.default!==void 0&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=h.defaultFieldValue(this.type)},m.verifyValue=function(E,T){var A,L,k;if(T=T||!1,A=function(V,j){throw Error("Illegal value for "+this.toString(!0)+" of type "+this.type.name+": "+V+" ("+j+")")}.bind(this),E===null)return this.required&&A(typeof E,"required"),this.syntax==="proto3"&&this.type!==o.TYPES.message&&A(typeof E,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!T){for(Array.isArray(E)||(E=[E]),k=[],L=0;L<E.length;L++)k.push(this.element.verifyValue(E[L]));return k}return this.map&&!T?E instanceof o.Map?E:(E instanceof Object||A(typeof E,"expected ProtoBuf.Map or raw object for map field"),new o.Map(this,E)):(!this.repeated&&Array.isArray(E)&&A(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 o.TYPES.int32:case o.TYPES.sint32:case o.TYPES.sfixed32:case o.TYPES.uint32:case o.TYPES.fixed32:return E!==0;case o.TYPES.int64:case o.TYPES.sint64:case o.TYPES.sfixed64:case o.TYPES.uint64:case o.TYPES.fixed64:return E.low!==0||E.high!==0;case o.TYPES.bool:return E;case o.TYPES.float:case o.TYPES.double:return E!==0;case o.TYPES.string:return E.length>0;case o.TYPES.bytes:return E.remaining()>0;case o.TYPES.enum:return E!==0;case o.TYPES.message:return E!==null;default:return!0}},m.encode=function(E,T,A){var L,k,V,j,G;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&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(T.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),T.ensureCapacity(T.offset+=1),k=T.offset,L=0;L<E.length;L++)this.element.encodeValue(this.id,E[L],T);V=T.offset-k,(j=n.calculateVarint32(V))>1&&(G=T.slice(k,T.offset),k+=j-1,T.offset=k,T.append(G)),T.writeVarint32(V,k-j)}else for(L=0;L<E.length;L++)T.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,E[L],T);else this.map?E.forEach(function(J,oe){var he=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,oe)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,J);T.writeVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),T.writeVarint32(he),T.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,oe,T),T.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,J,T)},this):this.hasWirePresence(E,A)&&(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 A,L,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;A=0;try{if(this.repeated)if(this.options.packed&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(A+=n.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),k=0,L=0;L<E.length;L++)k+=this.element.calculateLength(this.id,E[L]);A+=n.calculateVarint32(k),A+=k}else for(L=0;L<E.length;L++)A+=n.calculateVarint32(this.id<<3|this.type.wireType),A+=this.element.calculateLength(this.id,E[L]);else this.map?E.forEach(function(V,j){var G=n.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,j)+n.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,V);A+=n.calculateVarint32(this.id<<3|o.WIRE_TYPES.LDELIM),A+=n.calculateVarint32(G),A+=G},this):this.hasWirePresence(E,T)&&(A+=n.calculateVarint32(this.id<<3|this.type.wireType),A+=this.element.calculateLength(this.id,E))}catch(V){throw Error("Illegal value for "+this.toString(!0)+": "+E+" ("+V+")")}return A},m.decode=function(E,T,A){var L,k,V,j,G,J,oe;if(!(!this.map&&E==this.type.wireType||!A&&this.repeated&&this.options.packed&&E==o.WIRE_TYPES.LDELIM||this.map&&E==o.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+E+" ("+this.type.wireType+" expected)");if(E==o.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&o.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!A){for(k=T.readVarint32(),k=T.offset+k,V=[];T.offset<k;)V.push(this.decode(this.type.wireType,T,!0));return V}if(this.map){if(j=h.defaultFieldValue(this.keyType),L=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((G=T.clone()).limit=G.offset+k,T.offset+=k;G.remaining()>0;)if(E=7&(J=G.readVarint32()),(oe=J>>>3)==1)j=this.keyElement.decode(G,E,oe);else{if(oe!==2)throw Error("Unexpected tag in map field key/value submessage");L=this.element.decode(G,E,oe)}return[j,L]}return this.element.decode(T,E,this.id)},M.Message.Field=p,(_=function(E,T,A,L,k,V,j){p.call(this,E,T,A,null,L,k,V,j),this.extension}).prototype=Object.create(p.prototype),M.Message.ExtensionField=_,v=function(E,T,A){F.call(this,E,T,A),this.fields=[]},M.Message.OneOf=v,(y=function(E,T,A,L,k){d.call(this,E,T,A,L,k),this.className="Enum",this.object=null}).getName=function(E,T){var A,L,k=Object.keys(E);for(L=0;L<k.length;++L)if(E[A=k[L]]===T)return A;return null},(y.prototype=Object.create(d.prototype)).build=function(E){var T,A,L,k;if(this.object&&!E)return this.object;for(T=new o.Builder.Enum,L=0,k=(A=this.getChildren(y.Value)).length;k>L;++L)T[A[L].name]=A[L].id;return Object.defineProperty&&Object.defineProperty(T,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=T},M.Enum=y,(C=function(E,T,A,L){F.call(this,E,T,A),this.className="Enum.Value",this.id=L}).prototype=Object.create(F.prototype),M.Enum.Value=C,(I=function(E,T,A,L){F.call(this,E,T,A),this.field=L}).prototype=Object.create(F.prototype),M.Extension=I,((P=function(E,T,A,L){d.call(this,E,T,A,L),this.className="Service",this.clazz=null}).prototype=Object.create(d.prototype)).build=function(E){return this.clazz&&!E?this.clazz:this.clazz=function(T,A){var L,k=function(G){T.Builder.Service.call(this),this.rpcImpl=G||function(J,oe,he){setTimeout(he.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},V=k.prototype=Object.create(T.Builder.Service.prototype),j=A.getChildren(T.Reflect.Service.RPCMethod);for(L=0;L<j.length;L++)(function(G){V[G.name]=function(J,oe){try{try{J=G.resolvedRequestType.clazz.decode(n.wrap(J))}catch(he){if(!(he instanceof TypeError))throw he}if(J===null||typeof J!="object")throw Error("Illegal arguments");J instanceof G.resolvedRequestType.clazz||(J=new G.resolvedRequestType.clazz(J)),this.rpcImpl(G.fqn(),J,function(he,de){if(!he){try{de=G.resolvedResponseType.clazz.decode(de)}catch{}return de&&de instanceof G.resolvedResponseType.clazz?void oe(null,de):void oe(Error("Illegal response type received in service method "+A.name+"#"+G.name))}oe(he)})}catch(he){setTimeout(oe.bind(this,he),0)}},k[G.name]=function(J,oe,he){new k(J)[G.name](oe,he)},Object.defineProperty&&(Object.defineProperty(k[G.name],"$options",{value:G.buildOpt()}),Object.defineProperty(V[G.name],"$options",{value:k[G.name].$options}))})(j[L]);return Object.defineProperty&&(Object.defineProperty(k,"$options",{value:A.buildOpt()}),Object.defineProperty(V,"$options",{value:k.$options}),Object.defineProperty(k,"$type",{value:A}),Object.defineProperty(V,"$type",{value:A})),k}(o,this)},M.Service=P,((b=function(E,T,A,L){F.call(this,E,T,A),this.className="Service.Method",this.options=L||{}}).prototype=Object.create(F.prototype)).buildOpt=l.buildOpt,M.Service.Method=b,(R=function(E,T,A,L,k,V,j,G){b.call(this,E,T,A,G),this.className="Service.RPCMethod",this.requestName=L,this.responseName=k,this.requestStream=V,this.responseStream=j,this.resolvedRequestType=null,this.resolvedResponseType=null}).prototype=Object.create(b.prototype),M.Service.RPCMethod=R,M}(i),i.Builder=function(o,s,c){function d(a){a.messages&&a.messages.forEach(function(u){u.syntax=a.syntax,d(u)}),a.enums&&a.enums.forEach(function(u){u.syntax=a.syntax})}var l=function(a){this.ns=new c.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"||!s.TYPEREF.test(a))throw Error("illegal namespace: "+a);return a.split(".").forEach(function(u){var f=this.ptr.getChild(u);f===null&&this.ptr.addChild(f=new c.Namespace(this,this.ptr,u)),this.ptr=f},this),this},h.create=function(a){var u,f,p,m,_;if(!a)return this;if(Array.isArray(a)){if(a.length===0)return this;a=a.slice()}else a=[a];for(u=[a];u.length>0;){if(a=u.pop(),!Array.isArray(a))throw Error("not a valid namespace: "+JSON.stringify(a));for(;a.length>0;){if(f=a.shift(),l.isMessage(f)){if(p=new c.Message(this,this.ptr,f.name,f.options,f.isGroup,f.syntax),m={},f.oneofs&&Object.keys(f.oneofs).forEach(function(v){p.addChild(m[v]=new c.Message.OneOf(this,p,v))},this),f.fields&&f.fields.forEach(function(v){if(p.getChild(0|v.id)!==null)throw Error("duplicate or invalid field id in "+p.name+": "+v.id);if(v.options&&typeof v.options!="object")throw Error("illegal field options in "+p.name+"#"+v.name);var y=null;if(typeof v.oneof=="string"&&!(y=m[v.oneof]))throw Error("illegal oneof in "+p.name+"#"+v.name+": "+v.oneof);v=new c.Message.Field(this,p,v.rule,v.keytype,v.type,v.name,v.id,v.options,y,f.syntax),y&&y.fields.push(v),p.addChild(v)},this),_=[],f.enums&&f.enums.forEach(function(v){_.push(v)}),f.messages&&f.messages.forEach(function(v){_.push(v)}),f.services&&f.services.forEach(function(v){_.push(v)}),f.extensions&&(p.extensions=typeof f.extensions[0]=="number"?[f.extensions]:f.extensions),this.ptr.addChild(p),_.length>0){u.push(a),a=_,_=null,this.ptr=p,p=null;continue}_=null}else if(l.isEnum(f))p=new c.Enum(this,this.ptr,f.name,f.options,f.syntax),f.values.forEach(function(v){p.addChild(new c.Enum.Value(this,p,v.name,v.id))},this),this.ptr.addChild(p);else if(l.isService(f))p=new c.Service(this,this.ptr,f.name,f.options),Object.keys(f.rpc).forEach(function(v){var y=f.rpc[v];p.addChild(new c.Service.RPCMethod(this,p,v,y.request,y.response,!!y.request_stream,!!y.response_stream,y.options))},this),this.ptr.addChild(p);else{if(!l.isExtend(f))throw Error("not a valid definition: "+JSON.stringify(f));if(p=this.ptr.resolve(f.ref,!0))f.fields.forEach(function(v){var y,C,I,P;if(p.getChild(0|v.id)!==null)throw Error("duplicate extended field id in "+p.name+": "+v.id);if(p.extensions&&(y=!1,p.extensions.forEach(function(b){v.id>=b[0]&&v.id<=b[1]&&(y=!0)}),!y))throw Error("illegal extended field id in "+p.name+": "+v.id+" (not within valid ranges)");C=v.name,this.options.convertFieldsToCamelCase&&(C=o.Util.toCamelCase(C)),I=new c.Message.ExtensionField(this,p,v.rule,v.type,this.ptr.fqn()+"."+C,v.id,v.options),P=new c.Extension(this,this.ptr,v.name,I),I.extension=P,this.ptr.addChild(P),p.addChild(I)},this);else if(!/\.?google\.protobuf\./.test(f.ref))throw Error("extended message "+f.ref+" is not defined")}f=null,p=null}a=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},h.import=function(a,u){var f,p,m,_,v,y,C,I,P="/";if(typeof u=="string"){if(o.Util.IS_NODE,this.files[u]===!0)return this.reset();this.files[u]=!0}else if(typeof u=="object"){if(f=u.root,o.Util.IS_NODE,(f.indexOf("\\")>=0||u.file.indexOf("\\")>=0)&&(P="\\"),p=f+P+u.file,this.files[p]===!0)return this.reset();this.files[p]=!0}if(a.imports&&a.imports.length>0){for(_=!1,typeof u=="object"?(this.importRoot=u.root,_=!0,m=this.importRoot,u=u.file,(m.indexOf("\\")>=0||u.indexOf("\\")>=0)&&(P="\\")):typeof u=="string"?this.importRoot?m=this.importRoot:u.indexOf("/")>=0?(m=u.replace(/\/[^\/]*$/,""))===""&&(m="/"):u.indexOf("\\")>=0?(m=u.replace(/\\[^\\]*$/,""),P="\\"):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((y=a.imports[v])==="google/protobuf/descriptor.proto"||(y=m+P+y,this.files[y]===!0))continue;if(/\.proto$/i.test(y)&&!o.DotProto&&(y=y.replace(/\.proto$/,".json")),(C=o.Util.fetch(y))===null)throw Error("failed to import '"+y+"' in '"+u+"': file not found");/\.json$/i.test(y)?this.import(JSON.parse(C+""),y):this.import(o.DotProto.Parser.parse(C),y)}else u?/\.(\w+)$/.test(u)?this.import(a.imports[v],u.replace(/^(.+)\.(\w+)$/,function(b,R,M){return R+"_import"+v+"."+M})):this.import(a.imports[v],u+"_import"+v):this.import(a.imports[v]);_&&(this.importRoot=null)}return a.package&&this.define(a.package),a.syntax&&d(a),I=this.ptr,a.options&&Object.keys(a.options).forEach(function(b){I.options[b]=a.options[b]}),a.messages&&(this.create(a.messages),this.ptr=I),a.enums&&(this.create(a.enums),this.ptr=I),a.services&&(this.create(a.services),this.ptr=I),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 c.Namespace)this.ptr.children.forEach(function(u){this.ptr=u,this.resolveAll()},this);else if(this.ptr instanceof c.Message.Field){if(s.TYPE.test(this.ptr.type))this.ptr.type=o.TYPES[this.ptr.type];else{if(!s.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(a=(this.ptr instanceof c.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 c.Enum){if(this.ptr.type=o.TYPES.enum,this.ptr.syntax==="proto3"&&a.syntax!=="proto3")throw Error("proto3 message cannot reference proto2 enum")}else{if(!(a instanceof c.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=a.isGroup?o.TYPES.group:o.TYPES.message}}if(this.ptr.map){if(!s.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=o.TYPES[this.ptr.keyType]}}else if(this.ptr instanceof o.Reflect.Service.Method){if(!(this.ptr instanceof o.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 o.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 o.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=a}else if(!(this.ptr instanceof o.Reflect.Message.OneOf||this.ptr instanceof o.Reflect.Extension||this.ptr instanceof o.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},h.build=function(a){var u,f,p;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(u=typeof a=="string"?a.split("."):a,f=this.result,p=0;p<u.length;p++){if(!f[u[p]]){f=null;break}f=f[u[p]]}return f},h.lookup=function(a,u){return a?this.ns.resolve(a,u):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(o,s){function c(h){var a=0;return{next:function(){return a<h.length?{done:!1,value:h[a++]}:{done:!0}}}}var d=function(h,a){var u,f,p,m;if(!h.map)throw Error("field is not a map");if(this.field=h,this.keyElem=new s.Element(h.keyType,null,!0,h.syntax),this.valueElem=new s.Element(h.type,h.resolvedType,!1,h.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),a)for(u=Object.keys(a),f=0;f<u.length;f++)p=this.keyElem.valueFromString(u[f]),m=this.valueElem.verifyValue(a[u[f]]),this.map[this.keyElem.valueToString(p)]={key:p,value:m}},l=d.prototype;return l.clear=function(){this.map={}},l.delete=function(h){var a=this.keyElem.valueToString(this.keyElem.verifyValue(h)),u=a in this.map;return delete this.map[a],u},l.entries=function(){var h,a,u=[],f=Object.keys(this.map);for(a=0;a<f.length;a++)u.push([(h=this.map[f[a]]).key,h.value]);return c(u)},l.keys=function(){var h,a=[],u=Object.keys(this.map);for(h=0;h<u.length;h++)a.push(this.map[u[h]].key);return c(a)},l.values=function(){var h,a=[],u=Object.keys(this.map);for(h=0;h<u.length;h++)a.push(this.map[u[h]].value);return c(a)},l.forEach=function(h,a){var u,f,p=Object.keys(this.map);for(f=0;f<p.length;f++)h.call(a,(u=this.map[p[f]]).value,u.key,this)},l.set=function(h,a){var u=this.keyElem.verifyValue(h),f=this.valueElem.verifyValue(a);return this.map[this.keyElem.valueToString(u)]={key:u,value:f},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(o,s,c){return(typeof s=="string"||s&&typeof s.file=="string"&&typeof s.root=="string")&&(c=s,s=void 0),i.loadJson(i.DotProto.Parser.parse(o),s,c)},i.protoFromString=i.loadProto,i.loadProtoFile=function(o,s,c){if(s&&typeof s=="object"?(c=s,s=null):s&&typeof s=="function"||(s=null),s)return i.Util.fetch(typeof o=="string"?o:o.root+"/"+o.file,function(l){if(l!==null)try{s(null,i.loadProto(l,c,o))}catch(h){s(h)}else s(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof o=="object"?o.root+"/"+o.file:o);return d===null?null:i.loadProto(d,c,o)},i.protoFromFile=i.loadProtoFile,i.newBuilder=function(o){return(o=o||{}).convertFieldsToCamelCase===void 0&&(o.convertFieldsToCamelCase=i.convertFieldsToCamelCase),o.populateAccessors===void 0&&(o.populateAccessors=i.populateAccessors),new i.Builder(o)},i.loadJson=function(o,s,c){return(typeof s=="string"||s&&typeof s.file=="string"&&typeof s.root=="string")&&(c=s,s=null),s&&typeof s=="object"||(s=i.newBuilder()),typeof o=="string"&&(o=JSON.parse(o)),s.import(o,c),s.resolveAll(),s},i.loadJsonFile=function(o,s,c){if(s&&typeof s=="object"?(c=s,s=null):s&&typeof s=="function"||(s=null),s)return i.Util.fetch(typeof o=="string"?o:o.root+"/"+o.file,function(l){if(l!==null)try{s(null,i.loadJson(JSON.parse(l),c,o))}catch(h){s(h)}else s(Error("Failed to fetch file"))});var d=i.Util.fetch(typeof o=="object"?o.root+"/"+o.file:o);return d===null?null:i.loadJson(JSON.parse(d),c,o)},r=Fa,i.loadProto(r,void 0,"").build("Modules").probuf}(function(t){function e(a){var u=0;return function(){return u<a.length?a.charCodeAt(u++):null}}function n(){var a=[],u=[];return function(){return arguments.length===0?u.join("")+c.apply(String,a):(a.length+arguments.length>1024&&(u.push(c.apply(String,a)),a.length=0),void Array.prototype.push.apply(a,arguments))}}function r(a,u,f,p,m){var _,v,y=8*m-p-1,C=(1<<y)-1,I=C>>1,P=-7,b=f?m-1:0,R=f?-1:1,M=a[u+b];for(b+=R,_=M&(1<<-P)-1,M>>=-P,P+=y;P>0;_=256*_+a[u+b],b+=R,P-=8);for(v=_&(1<<-P)-1,_>>=-P,P+=p;P>0;v=256*v+a[u+b],b+=R,P-=8);if(_===0)_=1-I;else{if(_===C)return v?NaN:1/0*(M?-1:1);v+=Math.pow(2,p),_-=I}return(M?-1:1)*v*Math.pow(2,_-p)}function i(a,u,f,p,m,_){var v,y,C,I=8*_-m-1,P=(1<<I)-1,b=P>>1,R=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=p?0:_-1,F=p?1:-1,q=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||1/0===u?(y=isNaN(u)?1:0,v=P):(v=Math.floor(Math.log(u)/Math.LN2),u*(C=Math.pow(2,-v))<1&&(v--,C*=2),(u+=v+b>=1?R/C:R*Math.pow(2,1-b))*C>=2&&(v++,C/=2),v+b>=P?(y=0,v=P):v+b>=1?(y=(u*C-1)*Math.pow(2,m),v+=b):(y=u*Math.pow(2,b-1)*Math.pow(2,m),v=0));m>=8;a[f+M]=255&y,M+=F,y/=256,m-=8);for(v=v<<m|y,I+=m;I>0;a[f+M]=255&v,M+=F,v/=256,I-=8);a[f+M-F]|=128*q}var o,s,c,d,l,h=function(a,u,f){if(a===void 0&&(a=h.DEFAULT_CAPACITY),u===void 0&&(u=h.DEFAULT_ENDIAN),f===void 0&&(f=h.DEFAULT_NOASSERT),!f){if((a|=0)<0)throw RangeError("Illegal capacity");u=!!u,f=!!f}this.buffer=a===0?s:new ArrayBuffer(a),this.view=a===0?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=a,this.littleEndian=u,this.noAssert=f};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=t||null,(o=h.prototype).__isByteBuffer__,Object.defineProperty(o,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1}),s=new ArrayBuffer(0),c=String.fromCharCode,h.accessor=function(){return Uint8Array},h.allocate=function(a,u,f){return new h(a,u,f)},h.concat=function(a,u,f,p){var m,_,v,y,C,I;for((typeof u=="boolean"||typeof u!="string")&&(p=f,f=u,u=void 0),m=0,v=0,y=a.length;y>v;++v)h.isByteBuffer(a[v])||(a[v]=h.wrap(a[v],u)),(_=a[v].limit-a[v].offset)>0&&(m+=_);if(m===0)return new h(0,f,p);for(I=new h(m,f,p),v=0;y>v;)(_=(C=a[v++]).limit-C.offset)<=0||(I.view.set(C.view.subarray(C.offset,C.limit),I.offset),I.offset+=_);return I.limit=I.offset,I.offset=0,I},h.isByteBuffer=function(a){return(a&&a.__isByteBuffer__)===!0},h.type=function(){return ArrayBuffer},h.wrap=function(a,u,f,p){var m,_;if(typeof u!="string"&&(p=f,f=u,u=void 0),typeof a=="string")switch(u===void 0&&(u="utf8"),u){case"base64":return h.fromBase64(a,f);case"hex":return h.fromHex(a,f);case"binary":return h.fromBinary(a,f);case"utf8":return h.fromUTF8(a,f);case"debug":return h.fromDebug(a,f);default:throw Error("Unsupported encoding: "+u)}if(a===null||typeof a!="object")throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return(m=o.clone.call(a)).markedOffset=-1,m;if(a instanceof Uint8Array)m=new h(0,f,p),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,f,p),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,f,p)).limit=a.length,_=0;_<a.length;++_)m.view[_]=a[_]}return m},o.writeBitSet=function(a,u){var f,p,m,_,v,y,C=u===void 0;if(C&&(u=this.offset),!this.noAssert){if(!(a instanceof Array))throw TypeError("Illegal BitSet: Not an array");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for(p=u,_=(m=a.length)>>3,v=0,u+=this.writeVarint32(m,u);_--;)f=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(f,u++);if(m>v){for(y=0,f=0;m>v;)f|=(1&!!a[v++])<<y++;this.writeByte(f,u++)}return C?(this.offset=u,this):u-p},o.readBitSet=function(a){var u,f,p,m,_,v,y,C=a===void 0;for(C&&(a=this.offset),m=(p=(f=this.readVarint32(a)).value)>>3,_=0,v=[],a+=f.length;m--;)u=this.readByte(a++),v[_++]=!!(1&u),v[_++]=!!(2&u),v[_++]=!!(4&u),v[_++]=!!(8&u),v[_++]=!!(16&u),v[_++]=!!(32&u),v[_++]=!!(64&u),v[_++]=!!(128&u);if(p>_)for(y=0,u=this.readByte(a++);p>_;)v[_++]=!!(1&u>>y++);return C&&(this.offset=a),v},o.readBytes=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+"+a+") <= "+this.buffer.byteLength)}return f=this.slice(u,u+a),p&&(this.offset+=a),f},o.writeBytes=o.append,o.writeInt8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeByte=o.writeInt8,o.readInt8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return(128&(u=this.view[a]))==128&&(u=-(255-u+1)),f&&(this.offset+=1),u},o.readByte=o.readInt8,o.writeUint8=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=1)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=1,this.view[u]=a,p&&(this.offset+=1),this},o.writeUInt8=o.writeUint8,o.readUint8=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=this.view[a],f&&(this.offset+=1),u},o.readUInt8=o.readUint8,o.writeInt16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeShort=o.writeInt16,o.readInt16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),(32768&u)==32768&&(u=-(65535-u+1)),f&&(this.offset+=2),u},o.readShort=o.readInt16,o.writeUint16=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=2)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=2,this.littleEndian?(this.view[u+1]=(65280&a)>>>8,this.view[u]=255&a):(this.view[u]=(65280&a)>>>8,this.view[u+1]=255&a),p&&(this.offset+=2),this},o.writeUInt16=o.writeUint16,o.readUint16=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a],u|=this.view[a+1]<<8):(u=this.view[a]<<8,u|=this.view[a+1]),f&&(this.offset+=2),u},o.readUInt16=o.readUint16,o.writeInt32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeInt=o.writeInt32,o.readInt32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),u|=0,f&&(this.offset+=4),u},o.readInt=o.readInt32,o.writeUint32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,this.littleEndian?(this.view[u+3]=255&a>>>24,this.view[u+2]=255&a>>>16,this.view[u+1]=255&a>>>8,this.view[u]=255&a):(this.view[u]=255&a>>>24,this.view[u+1]=255&a>>>16,this.view[u+2]=255&a>>>8,this.view[u+3]=255&a),p&&(this.offset+=4),this},o.writeUInt32=o.writeUint32,o.readUint32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0):(u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),f&&(this.offset+=4),u},o.readUInt32=o.readUint32,t&&(o.writeInt64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeLong=o.writeInt64,o.readInt64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!1),m&&(this.offset+=8),p},o.readLong=o.readInt64,o.writeUint64=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a)),(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,p=a.low,m=a.high,this.littleEndian?(this.view[u+3]=255&p>>>24,this.view[u+2]=255&p>>>16,this.view[u+1]=255&p>>>8,this.view[u]=255&p,u+=4,this.view[u+3]=255&m>>>24,this.view[u+2]=255&m>>>16,this.view[u+1]=255&m>>>8,this.view[u]=255&m):(this.view[u]=255&m>>>24,this.view[u+1]=255&m>>>16,this.view[u+2]=255&m>>>8,this.view[u+3]=255&m,u+=4,this.view[u]=255&p>>>24,this.view[u+1]=255&p>>>16,this.view[u+2]=255&p>>>8,this.view[u+3]=255&p),_&&(this.offset+=8),this},o.writeUInt64=o.writeUint64,o.readUint64=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=0,f=0,this.littleEndian?(u=this.view[a+2]<<16,u|=this.view[a+1]<<8,u|=this.view[a],u+=this.view[a+3]<<24>>>0,a+=4,f=this.view[a+2]<<16,f|=this.view[a+1]<<8,f|=this.view[a],f+=this.view[a+3]<<24>>>0):(f=this.view[a+1]<<16,f|=this.view[a+2]<<8,f|=this.view[a+3],f+=this.view[a]<<24>>>0,a+=4,u=this.view[a+1]<<16,u|=this.view[a+2]<<8,u|=this.view[a+3],u+=this.view[a]<<24>>>0),p=new t(u,f,!0),m&&(this.offset+=8),p},o.readUInt64=o.readUint64),o.writeFloat32=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=4)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=4,i(this.view,a,u,this.littleEndian,23,4),p&&(this.offset+=4),this},o.writeFloat=o.writeFloat32,o.readFloat32=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,23,4),f&&(this.offset+=4),u},o.readFloat=o.readFloat32,o.writeFloat64=function(a,u){var f,p=u===void 0;if(p&&(u=this.offset),!this.noAssert){if(typeof a!="number")throw TypeError("Illegal value: "+a+" (not a number)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return(u+=8)>(f=this.buffer.byteLength)&&this.resize((f*=2)>u?f:u),u-=8,i(this.view,a,u,this.littleEndian,52,8),p&&(this.offset+=8),this},o.writeDouble=o.writeFloat64,o.readFloat64=function(a){var u,f=a===void 0;if(f&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength)}return u=r(this.view,a,this.littleEndian,52,8),f&&(this.offset+=8),u},o.readDouble=o.readFloat64,h.MAX_VARINT32_BYTES=5,h.calculateVarint32=function(a){return(a>>>=0)<128?1:a<16384?2:1<<21>a?3:1<<28>a?4:5},h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0},h.zigZagDecode32=function(a){return 0|a>>>1^-(1&a)},o.writeVarint32=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}for((u+=p=h.calculateVarint32(a))>(m=this.buffer.byteLength)&&this.resize((m*=2)>u?m:u),u-=p,a>>>=0;a>=128;)f=128|127&a,this.view[u++]=f,a>>>=7;return this.view[u++]=a,_?(this.offset=u,this):p},o.writeVarint32ZigZag=function(a,u){return this.writeVarint32(h.zigZagEncode32(a),u)},o.readVarint32=function(a){var u,f,p,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)}f=0,p=0;do{if(!this.noAssert&&a>this.limit)throw(m=Error("Truncated")).truncated=!0,m;u=this.view[a++],f<5&&(p|=(127&u)<<7*f),++f}while((128&u)!=0);return p|=0,_?(this.offset=a,p):{value:p,length:f}},o.readVarint32ZigZag=function(a){var u=this.readVarint32(a);return typeof u=="object"?u.value=h.zigZagDecode32(u.value):u=h.zigZagDecode32(u),u},t&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){typeof a=="number"?a=t.fromNumber(a):typeof a=="string"&&(a=t.fromString(a));var u=a.toInt()>>>0,f=a.shiftRightUnsigned(28).toInt()>>>0,p=a.shiftRightUnsigned(56).toInt()>>>0;return p==0?f==0?u<16384?u<128?1:2:1<<21>u?3:4:f<16384?f<128?5:6:1<<21>f?7:8:p<128?9:10},h.zigZagEncode64=function(a){return typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.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=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),a.shiftRightUnsigned(1).xor(a.and(t.ONE).toSigned().negate()).toSigned()},o.writeVarint64=function(a,u){var f,p,m,_,v,y=u===void 0;if(y&&(u=this.offset),!this.noAssert){if(typeof a=="number")a=t.fromNumber(a);else if(typeof a=="string")a=t.fromString(a);else if(!(a&&a instanceof t))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}switch(typeof a=="number"?a=t.fromNumber(a,!1):typeof a=="string"?a=t.fromString(a,!1):a.unsigned!==!1&&(a=a.toSigned()),f=h.calculateVarint64(a),p=a.toInt()>>>0,m=a.shiftRightUnsigned(28).toInt()>>>0,_=a.shiftRightUnsigned(56).toInt()>>>0,(u+=f)>(v=this.buffer.byteLength)&&this.resize((v*=2)>u?v:u),u-=f,f){case 10:this.view[u+9]=1&_>>>7;case 9:this.view[u+8]=f!==9?128|_:127&_;case 8:this.view[u+7]=f!==8?128|m>>>21:127&m>>>21;case 7:this.view[u+6]=f!==7?128|m>>>14:127&m>>>14;case 6:this.view[u+5]=f!==6?128|m>>>7:127&m>>>7;case 5:this.view[u+4]=f!==5?128|m:127&m;case 4:this.view[u+3]=f!==4?128|p>>>21:127&p>>>21;case 3:this.view[u+2]=f!==3?128|p>>>14:127&p>>>14;case 2:this.view[u+1]=f!==2?128|p>>>7:127&p>>>7;case 1:this.view[u]=f!==1?128|p:127&p}return y?(this.offset+=f,this):f},o.writeVarint64ZigZag=function(a,u){return this.writeVarint64(h.zigZagEncode64(a),u)},o.readVarint64=function(a){var u,f,p,m,_,v,y=a===void 0;if(y&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}if(u=a,f=0,p=0,m=0,_=0,f=127&(_=this.view[a++]),128&_&&(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)&&(p=127&(_=this.view[a++]),(128&_||this.noAssert&&_===void 0)&&(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)&&(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=t.fromBits(f|p<<28,p>>>4|m<<24,!1),y?(this.offset=a,v):{value:v,length:a-u}},o.readVarint64ZigZag=function(a){var u=this.readVarint64(a);return u&&u.value instanceof t?u.value=h.zigZagDecode64(u.value):u=h.zigZagDecode64(u),u}),o.writeCString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),p=a.length,!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");for(f=0;p>f;++f)if(a.charCodeAt(f)===0)throw RangeError("Illegal str: Contains NULL-characters");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=l.calculateUTF16asUTF8(e(a))[1],u+=p+1,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=p+1,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),this.view[u++]=0,_?(this.offset=u,this):p},o.readCString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,p=-1,l.decodeUTF8toUTF16(function(){if(p===0)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return(p=this.view[a++])===0?null:p}.bind(this),f=n(),!0),m?(this.offset=a,f()):{string:f(),length:a-u}},o.writeIString=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(p=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],u+=4+f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=4+f,this.littleEndian?(this.view[u+3]=255&f>>>24,this.view[u+2]=255&f>>>16,this.view[u+1]=255&f>>>8,this.view[u]=255&f):(this.view[u]=255&f>>>24,this.view[u+1]=255&f>>>16,this.view[u+2]=255&f>>>8,this.view[u+3]=255&f),u+=4,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),u!==p+4+f)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+4+f));return _?(this.offset=u,this):u-p},o.readIString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength)}return u=a,f=this.readUint32(a),p=this.readUTF8String(f,h.METRICS_BYTES,a+=4),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},h.METRICS_CHARS="c",h.METRICS_BYTES="b",o.writeUTF8String=function(a,u){var f,p,m,_=u===void 0;if(_&&(u=this.offset),!this.noAssert){if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}return p=u,f=l.calculateUTF16asUTF8(e(a))[1],u+=f,m=this.buffer.byteLength,u>m&&this.resize((m*=2)>u?m:u),u-=f,l.encodeUTF16toUTF8(e(a),function(v){this.view[u++]=v}.bind(this)),_?(this.offset=u,this):u-p},o.writeString=o.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,o.readUTF8String=function(a,u,f){var p,m,_,v,y;if(typeof u=="number"&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),u===void 0&&(u=h.METRICS_CHARS),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");if(a|=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}if(_=0,v=f,u===h.METRICS_CHARS){if(m=n(),l.decodeUTF8(function(){return a>_&&f<this.limit?this.view[f++]:null}.bind(this),function(C){++_,l.UTF8toUTF16(C,m)}),_!==a)throw RangeError("Illegal range: Truncated data, "+_+" == "+a);return p?(this.offset=f,m()):{string:m(),length:f-v}}if(u===h.METRICS_BYTES){if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+"+a+") <= "+this.buffer.byteLength)}if(y=f+a,l.decodeUTF8toUTF16(function(){return y>f?this.view[f++]:null}.bind(this),m=n(),this.noAssert),f!==y)throw RangeError("Illegal range: Truncated data, "+f+" == "+y);return p?(this.offset=f,m()):{string:m(),length:f-v}}throw TypeError("Unsupported metrics: "+u)},o.readString=o.readUTF8String,o.writeVString=function(a,u){var f,p,m,_,v=u===void 0;if(v&&(u=this.offset),!this.noAssert){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(typeof u!="number"||u%1!=0)throw TypeError("Illegal offset: "+u+" (not an integer)");if((u>>>=0)<0||u+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+u+" (+0) <= "+this.buffer.byteLength)}if(m=u,f=l.calculateUTF16asUTF8(e(a),this.noAssert)[1],p=h.calculateVarint32(f),u+=p+f,_=this.buffer.byteLength,u>_&&this.resize((_*=2)>u?_:u),u-=p+f,u+=this.writeVarint32(f,u),l.encodeUTF16toUTF8(e(a),function(y){this.view[u++]=y}.bind(this)),u!==m+f+p)throw RangeError("Illegal range: Truncated data, "+u+" == "+(u+f+p));return v?(this.offset=u,this):u-m},o.readVString=function(a){var u,f,p,m=a===void 0;if(m&&(a=this.offset),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength)}return u=a,f=this.readVarint32(a),p=this.readUTF8String(f.value,h.METRICS_BYTES,a+=f.length),a+=p.length,m?(this.offset=a,p.string):{string:p.string,length:a-u}},o.append=function(a,u,f){var p,m,_;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((f+=m)>(_=this.buffer.byteLength)&&this.resize((_*=2)>f?_:f),f-=m,this.view.set(a.view.subarray(a.offset,a.limit),f),a.offset+=m,p&&(this.offset+=m)),this},o.appendTo=function(a,u){return a.append(this,u),this},o.assert=function(a){return this.noAssert=!a,this},o.capacity=function(){return this.buffer.byteLength},o.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},o.clone=function(a){var u=new h(0,this.littleEndian,this.noAssert);return a?(u.buffer=new ArrayBuffer(this.buffer.byteLength),u.view=new Uint8Array(u.buffer)):(u.buffer=this.buffer,u.view=this.view),u.offset=this.offset,u.markedOffset=this.markedOffset,u.limit=this.limit,u},o.compact=function(a,u){var f,p,m;if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===0&&u===this.buffer.byteLength?this:(f=u-a)==0?(this.buffer=s,this.view=null,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=0,this):(p=new ArrayBuffer(f),(m=new Uint8Array(p)).set(this.view.subarray(a,u)),this.buffer=p,this.view=m,this.markedOffset>=0&&(this.markedOffset-=a),this.offset=0,this.limit=f,this)},o.copy=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}if(a===u)return new h(0,this.littleEndian,this.noAssert);var f=u-a,p=new h(f,this.littleEndian,this.noAssert);return p.offset=0,p.limit=f,p.markedOffset>=0&&(p.markedOffset-=a),this.copyTo(p,0,a,u),p},o.copyTo=function(a,u,f,p){var m,_,v;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");if(u=(_=u===void 0)?a.offset:0|u,f=(m=f===void 0)?this.offset:0|f,p=p===void 0?this.limit:0|p,u<0||u>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+u+" <= "+a.buffer.byteLength);if(f<0||p>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+f+" <= "+this.buffer.byteLength);return(v=p-f)==0?a:(a.ensureCapacity(u+v),a.view.set(this.view.subarray(f,p),u),m&&(this.offset+=v),_&&(a.offset+=v),this)},o.ensureCapacity=function(a){var u=this.buffer.byteLength;return a>u?this.resize((u*=2)>a?u:a):this},o.fill=function(a,u,f){var p=u===void 0;if(p&&(u=this.offset),typeof a=="string"&&a.length>0&&(a=a.charCodeAt(0)),u===void 0&&(u=this.offset),f===void 0&&(f=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal value: "+a+" (not an integer)");if(a|=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal begin: Not an integer");if(u>>>=0,typeof f!="number"||f%1!=0)throw TypeError("Illegal end: Not an integer");if(f>>>=0,u<0||u>f||f>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+u+" <= "+f+" <= "+this.buffer.byteLength)}if(u>=f)return this;for(;f>u;)this.view[u++]=a;return p&&(this.offset=u),this},o.flip=function(){return this.limit=this.offset,this.offset=0,this},o.mark=function(a){if(a=a===void 0?this.offset:a,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal offset: "+a+" (not an integer)");if((a>>>=0)<0||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=a,this},o.order=function(a){if(!this.noAssert&&typeof a!="boolean")throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!a,this},o.LE=function(a){return this.littleEndian=a===void 0||!!a,this},o.BE=function(a){return this.littleEndian=a!==void 0&&!a,this},o.prepend=function(a,u,f){var p,m,_,v,y;if((typeof u=="number"||typeof u!="string")&&(f=u,u=void 0),(p=f===void 0)&&(f=this.offset),!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: "+f+" (not an integer)");if((f>>>=0)<0||f+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+f+" (+0) <= "+this.buffer.byteLength)}return a instanceof h||(a=h.wrap(a,u)),(m=a.limit-a.offset)<=0||((_=m-f)>0?(v=new ArrayBuffer(this.buffer.byteLength+_),(y=new Uint8Array(v)).set(this.view.subarray(f,this.buffer.byteLength),m),this.buffer=v,this.view=y,this.offset+=_,this.markedOffset>=0&&(this.markedOffset+=_),this.limit+=_,f+=_):new Uint8Array(this.buffer),this.view.set(a.view.subarray(a.offset,a.limit),f-m),a.offset=a.limit,p&&(this.offset-=m)),this},o.prependTo=function(a,u){return a.prepend(this,u),this},o.printDebug=function(a){typeof a!="function"&&(a=console.log.bind(console)),a(this.toString()+`
  789. -------------------------------------------------------------------
  790. `+this.toDebug(!0))},o.remaining=function(){return this.limit-this.offset},o.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},o.resize=function(a){var u,f;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&&(u=new ArrayBuffer(a),(f=new Uint8Array(u)).set(this.view),this.buffer=u,this.view=f),this},o.reverse=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}return a===u||Array.prototype.reverse.call(this.view.subarray(a,u)),this},o.skip=function(a){if(!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var u=this.offset+a;if(!this.noAssert&&(u<0||u>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);return this.offset=u,this},o.slice=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f=this.clone();return f.offset=a,f.limit=u,f},o.toBuffer=function(a){var u,f=this.offset,p=this.limit;if(!this.noAssert){if(typeof f!="number"||f%1!=0)throw TypeError("Illegal offset: Not an integer");if(f>>>=0,typeof p!="number"||p%1!=0)throw TypeError("Illegal limit: Not an integer");if(p>>>=0,f<0||f>p||p>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+f+" <= "+p+" <= "+this.buffer.byteLength)}return a||f!==0||p!==this.buffer.byteLength?f===p?s:(u=new ArrayBuffer(p-f),new Uint8Array(u).set(new Uint8Array(this.buffer).subarray(f,p),0),u):this.buffer},o.toArrayBuffer=o.toBuffer,o.toString=function(a,u,f){if(a===void 0)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch(typeof a=="number"&&(f=u=a="utf8"),a){case"utf8":return this.toUTF8(u,f);case"base64":return this.toBase64(u,f);case"hex":return this.toHex(u,f);case"binary":return this.toBinary(u,f);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a)}},d=function(){var a,u,f={},p=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],m=[];for(a=0,u=p.length;u>a;++a)m[p[a]]=a;return f.encode=function(_,v){for(var y,C;(y=_())!==null;)v(p[63&y>>2]),C=(3&y)<<4,(y=_())!==null?(v(p[63&((C|=15&y>>4)|15&y>>4)]),C=(15&y)<<2,(y=_())!==null?(v(p[63&(C|3&y>>6)]),v(p[63&y])):(v(p[63&C]),v(61))):(v(p[63&C]),v(61),v(61))},f.decode=function(_,v){function y(b){throw Error("Illegal character code: "+b)}for(var C,I,P;(C=_())!==null;)if((I=m[C])===void 0&&y(C),(C=_())!==null&&((P=m[C])===void 0&&y(C),v(I<<2>>>0|(48&P)>>4),(C=_())!==null)){if((I=m[C])===void 0){if(C===61)break;y(C)}if(v((15&P)<<4>>>0|(60&I)>>2),(C=_())!==null){if((P=m[C])===void 0){if(C===61)break;y(C)}v((3&I)<<6>>>0|P)}}},f.test=function(_){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(_)},f}(),o.toBase64=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity||a>u)throw RangeError("begin, end");var f;return d.encode(function(){return u>a?this.view[a++]:null}.bind(this),f=n()),f()},h.fromBase64=function(a,u){if(typeof a!="string")throw TypeError("str");var f=new h(a.length/4*3,u),p=0;return d.decode(e(a),function(m){f.view[p++]=m}),f.limit=p,f},h.btoa=function(a){return h.fromBinary(a).toBase64()},h.atob=function(a){return h.fromBase64(a).toBinary()},o.toBinary=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),u|=0,(a|=0)<0||u>this.capacity()||a>u)throw RangeError("begin, end");if(a===u)return"";for(var f=[],p=[];u>a;)f.push(this.view[a++]),f.length>=1024&&(p.push(String.fromCharCode.apply(String,f)),f=[]);return p.join("")+String.fromCharCode.apply(String,f)},h.fromBinary=function(a,u){if(typeof a!="string")throw TypeError("str");for(var f,p=0,m=a.length,_=new h(m,u);m>p;){if((f=a.charCodeAt(p))>255)throw RangeError("illegal char code: "+f);_.view[p++]=f}return _.limit=m,_},o.toDebug=function(a){for(var u,f=-1,p=this.buffer.byteLength,m="",_="",v="";p>f;){if(f!==-1&&(m+=(u=this.view[f])<16?"0"+u.toString(16).toUpperCase():u.toString(16).toUpperCase(),a&&(_+=u>32&&u<127?String.fromCharCode(u):".")),++f,a&&f>0&&f%16==0&&f!==p){for(;m.length<51;)m+=" ";v+=m+_+`
  791. `,m=_=""}m+=f===this.offset&&f===this.limit?f===this.markedOffset?"!":"|":f===this.offset?f===this.markedOffset?"[":"<":f===this.limit?f===this.markedOffset?"]":">":f===this.markedOffset?"'":a||f!==0&&f!==p?" ":""}if(a&&m!==" "){for(;m.length<51;)m+=" ";v+=m+_+`
  792. `}return a?v:m},h.fromDebug=function(a,u,f){for(var p,m,_=a.length,v=new h(0|(_+1)/3,u,f),y=0,C=0,I=!1,P=!1,b=!1,R=!1,M=!1;_>y;){switch(p=a.charAt(y++)){case"!":if(!f){if(P||b||R){M=!0;break}P=b=R=!0}v.offset=v.markedOffset=v.limit=C,I=!1;break;case"|":if(!f){if(P||R){M=!0;break}P=R=!0}v.offset=v.limit=C,I=!1;break;case"[":if(!f){if(P||b){M=!0;break}P=b=!0}v.offset=v.markedOffset=C,I=!1;break;case"<":if(!f){if(P){M=!0;break}P=!0}v.offset=C,I=!1;break;case"]":if(!f){if(R||b){M=!0;break}R=b=!0}v.limit=v.markedOffset=C,I=!1;break;case">":if(!f){if(R){M=!0;break}R=!0}v.limit=C,I=!1;break;case"'":if(!f){if(b){M=!0;break}b=!0}v.markedOffset=C,I=!1;break;case" ":I=!1;break;default:if(!f&&I){M=!0;break}if(m=parseInt(p+a.charAt(y++),16),!f&&(isNaN(m)||m<0||m>255))throw TypeError("Illegal str: Not a debug encoded string");v.view[C++]=m,I=!0}if(M)throw TypeError("Illegal str: Invalid symbol at "+y)}if(!f){if(!P||!R)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},o.toHex=function(a,u){if(a=a===void 0?this.offset:a,u=u===void 0?this.limit:u,!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}for(var f,p=new Array(u-a);u>a;)(f=this.view[a++])<16?p.push("0",f.toString(16)):p.push(f.toString(16));return p.join("")},h.fromHex=function(a,u,f){var p,m,_,v,y;if(!f){if(typeof a!="string")throw TypeError("Illegal str: Not a string");if(a.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(m=a.length,_=new h(0|m/2,u),v=0,y=0;m>v;v+=2){if(p=parseInt(a.substring(v,v+2),16),!f&&(!isFinite(p)||p<0||p>255))throw TypeError("Illegal str: Contains non-hex characters");_.view[y++]=p}return _.limit=y,_},l=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<128?f(127&p):p<2048?(f(192|31&p>>6),f(128|63&p)):p<65536?(f(224|15&p>>12),f(128|63&p>>6),f(128|63&p)):(f(240|7&p>>18),f(128|63&p>>12),f(128|63&p>>6),f(128|63&p)),p=null},decodeUTF8:function(u,f){for(var p,m,_,v,y=function(C){C=C.slice(0,C.indexOf(null));var I=Error(C.toString());throw I.name="TruncatedError",I.bytes=C,I};(p=u())!==null;)if((128&p)==0)f(p);else if((224&p)==192)(m=u())===null&&y([p,m]),f((31&p)<<6|63&m);else if((240&p)==224)((m=u())===null||(_=u())===null)&&y([p,m,_]),f((15&p)<<12|(63&m)<<6|63&_);else{if((248&p)!=240)throw RangeError("Illegal starting byte: "+p);((m=u())===null||(_=u())===null||(v=u())===null)&&y([p,m,_,v]),f((7&p)<<18|(63&m)<<12|(63&_)<<6|63&v)}},UTF16toUTF8:function(u,f){for(var p,m=null;(p=m!==null?m:u())!==null;)p>=55296&&p<=57343&&(m=u())!==null&&m>=56320&&m<=57343?(f(1024*(p-55296)+m-56320+65536),m=null):f(p);m!==null&&f(m)},UTF8toUTF16:function(u,f){var p=null;for(typeof u=="number"&&(p=u,u=function(){return null});p!==null||(p=u())!==null;)p<=65535?f(p):(f(55296+((p-=65536)>>10)),f(p%1024+56320)),p=null},encodeUTF16toUTF8:function(u,f){a.UTF16toUTF8(u,function(p){a.encodeUTF8(p,f)})},decodeUTF8toUTF16:function(u,f){a.decodeUTF8(u,function(p){a.UTF8toUTF16(p,f)})},calculateCodePoint:function(u){return u<128?1:u<2048?2:u<65536?3:4},calculateUTF8:function(u){for(var f,p=0;(f=u())!==null;)p+=f<128?1:f<2048?2:f<65536?3:4;return p},calculateUTF16asUTF8:function(u){var f=0,p=0;return a.UTF16toUTF8(u,function(m){++f,p+=m<128?1:m<2048?2:m<65536?3:4}),[f,p]}};return a}(),o.toUTF8=function(a,u){if(a===void 0&&(a=this.offset),u===void 0&&(u=this.limit),!this.noAssert){if(typeof a!="number"||a%1!=0)throw TypeError("Illegal begin: Not an integer");if(a>>>=0,typeof u!="number"||u%1!=0)throw TypeError("Illegal end: Not an integer");if(u>>>=0,a<0||a>u||u>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+u+" <= "+this.buffer.byteLength)}var f;try{l.decodeUTF8toUTF16(function(){return u>a?this.view[a++]:null}.bind(this),f=n())}catch{if(a!==u)throw RangeError("Illegal range: Truncated data, "+a+" != "+u)}return f()},h.fromUTF8=function(a,u,f){if(!f&&typeof a!="string")throw TypeError("Illegal str: Not a string");var p=new h(l.calculateUTF16asUTF8(e(a),!0)[1],u,f),m=0;return l.encodeUTF16toUTF8(e(a),function(_){p.view[m++]=_}),p.limit=m,p},h}(Ha=function(){function t(R,M,F){this.low=0|R,this.high=0|M,this.unsigned=!!F}function e(R){return(R&&R.__isLong__)===!0}function n(R,M){var F,q,E;return M?(E=(R>>>=0)>=0&&R<256)&&(q=d[R])?q:(F=i(R,(0|R)<0?-1:0,!0),E&&(d[R]=F),F):(E=(R|=0)>=-128&&R<128)&&(q=c[R])?q:(F=i(R,R<0?-1:0,!1),E&&(c[R]=F),F)}function r(R,M){if(isNaN(R)||!isFinite(R))return M?m:p;if(M){if(R<0)return m;if(R>=a)return I}else{if(-u>=R)return P;if(R+1>=u)return C}return R<0?r(-R,M).neg():i(0|R%h,0|R/h,M)}function i(R,M,F){return new t(R,M,F)}function o(R,M,F){var q,E,T,A,L,k,V;if(R.length===0)throw Error("empty string");if(R==="NaN"||R==="Infinity"||R==="+Infinity"||R==="-Infinity")return p;if(typeof M=="number"?(F=M,M=!1):M=!!M,(F=F||10)<2||F>36)throw RangeError("radix");if((q=R.indexOf("-"))>0)throw Error("interior hyphen");if(q===0)return o(R.substring(1),M,F).neg();for(E=r(l(F,8)),T=p,A=0;A<R.length;A+=8)L=Math.min(8,R.length-A),k=parseInt(R.substring(A,A+L),F),L<8?(V=r(l(F,L)),T=T.mul(V).add(r(k))):T=(T=T.mul(E)).add(r(k));return T.unsigned=M,T}function s(R){return R instanceof t?R:typeof R=="number"?r(R):typeof R=="string"?o(R):i(R.low,R.high,R.unsigned)}var c,d,l,h,a,u,f,p,m,_,v,y,C,I,P,b;return t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),t.isLong=e,c={},d={},t.fromInt=n,t.fromNumber=r,t.fromBits=i,l=Math.pow,t.fromString=o,t.fromValue=s,u=(a=(h=4294967296)*h)/2,f=n(16777216),p=n(0),t.ZERO=p,m=n(0,!0),t.UZERO=m,_=n(1),t.ONE=_,v=n(1,!0),t.UONE=v,y=n(-1),t.NEG_ONE=y,C=i(-1,2147483647,!1),t.MAX_VALUE=C,I=i(-1,-1,!0),t.MAX_UNSIGNED_VALUE=I,P=i(0,-2147483648,!1),t.MIN_VALUE=P,(b=t.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},b.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},b.toString=function(R){var M,F,q,E,T,A,L,k;if((R=R||10)<2||R>36)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())return this.eq(P)?(M=r(R),q=(F=this.div(M)).mul(M).sub(this),F.toString(R)+q.toInt().toString(R)):"-"+this.neg().toString(R);for(E=r(l(R,6),this.unsigned),T=this,A="";;){if(L=T.div(E),k=(T.sub(L.mul(E)).toInt()>>>0).toString(R),(T=L).isZero())return k+A;for(;k.length<6;)k="0"+k;A=""+k+A}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){var R,M;if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(R=this.high!=0?this.high:this.low,M=31;M>0&&(R&1<<M)==0;M--);return this.high!=0?M+33:M+1},b.isZero=function(){return this.high===0&&this.low===0},b.isNegative=function(){return!this.unsigned&&this.high<0},b.isPositive=function(){return this.unsigned||this.high>=0},b.isOdd=function(){return(1&this.low)==1},b.isEven=function(){return(1&this.low)==0},b.equals=function(R){return e(R)||(R=s(R)),(this.unsigned===R.unsigned||this.high>>>31!=1||R.high>>>31!=1)&&this.high===R.high&&this.low===R.low},b.eq=b.equals,b.notEquals=function(R){return!this.eq(R)},b.neq=b.notEquals,b.lessThan=function(R){return this.comp(R)<0},b.lt=b.lessThan,b.lessThanOrEqual=function(R){return this.comp(R)<=0},b.lte=b.lessThanOrEqual,b.greaterThan=function(R){return this.comp(R)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(R){return this.comp(R)>=0},b.gte=b.greaterThanOrEqual,b.compare=function(R){if(e(R)||(R=s(R)),this.eq(R))return 0;var M=this.isNegative(),F=R.isNegative();return M&&!F?-1:!M&&F?1:this.unsigned?R.high>>>0>this.high>>>0||R.high===this.high&&R.low>>>0>this.low>>>0?-1:1:this.sub(R).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(_)},b.neg=b.negate,b.add=function(R){var M,F,q,E,T,A,L,k,V,j,G;return e(R)||(R=s(R)),M=this.high>>>16,F=65535&this.high,q=this.low>>>16,E=65535&this.low,T=R.high>>>16,A=65535&R.high,L=R.low>>>16,k=0,V=0,j=0,G=0,j+=(G+=E+(65535&R.low))>>>16,V+=(j+=q+L)>>>16,k+=(V+=F+A)>>>16,k+=M+T,i((j&=65535)<<16|(G&=65535),(k&=65535)<<16|(V&=65535),this.unsigned)},b.subtract=function(R){return e(R)||(R=s(R)),this.add(R.neg())},b.sub=b.subtract,b.multiply=function(R){var M,F,q,E,T,A,L,k,V,j,G,J;return this.isZero()?p:(e(R)||(R=s(R)),R.isZero()?p:this.eq(P)?R.isOdd()?P:p:R.eq(P)?this.isOdd()?P:p:this.isNegative()?R.isNegative()?this.neg().mul(R.neg()):this.neg().mul(R).neg():R.isNegative()?this.mul(R.neg()).neg():this.lt(f)&&R.lt(f)?r(this.toNumber()*R.toNumber(),this.unsigned):(M=this.high>>>16,F=65535&this.high,q=this.low>>>16,E=65535&this.low,T=R.high>>>16,A=65535&R.high,L=R.low>>>16,V=0,j=0,G=0,J=0,G+=(J+=E*(k=65535&R.low))>>>16,j+=(G+=q*k)>>>16,G&=65535,j+=(G+=E*L)>>>16,V+=(j+=F*k)>>>16,j&=65535,V+=(j+=q*L)>>>16,j&=65535,V+=(j+=E*A)>>>16,V+=M*k+F*L+q*A+E*T,i((G&=65535)<<16|(J&=65535),(V&=65535)<<16|(j&=65535),this.unsigned)))},b.mul=b.multiply,b.divide=function(R){var M,F,q,E,T,A,L;if(e(R)||(R=s(R)),R.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;if(this.unsigned){if(R.unsigned||(R=R.toUnsigned()),R.gt(this))return m;if(R.gt(this.shru(1)))return v;q=m}else{if(this.eq(P))return R.eq(_)||R.eq(y)?P:R.eq(P)?_:(M=this.shr(1).div(R).shl(1)).eq(p)?R.isNegative()?_:y:(F=this.sub(R.mul(M)),q=M.add(F.div(R)));if(R.eq(P))return this.unsigned?m:p;if(this.isNegative())return R.isNegative()?this.neg().div(R.neg()):this.neg().div(R).neg();if(R.isNegative())return this.div(R.neg()).neg();q=p}for(F=this;F.gte(R);){for(M=Math.max(1,Math.floor(F.toNumber()/R.toNumber())),T=(E=Math.ceil(Math.log(M)/Math.LN2))<=48?1:l(2,E-48),L=(A=r(M)).mul(R);L.isNegative()||L.gt(F);)L=(A=r(M-=T,this.unsigned)).mul(R);A.isZero()&&(A=_),q=q.add(A),F=F.sub(L)}return q},b.div=b.divide,b.modulo=function(R){return e(R)||(R=s(R)),this.sub(this.div(R).mul(R))},b.mod=b.modulo,b.not=function(){return i(~this.low,~this.high,this.unsigned)},b.and=function(R){return e(R)||(R=s(R)),i(this.low&R.low,this.high&R.high,this.unsigned)},b.or=function(R){return e(R)||(R=s(R)),i(this.low|R.low,this.high|R.high,this.unsigned)},b.xor=function(R){return e(R)||(R=s(R)),i(this.low^R.low,this.high^R.high,this.unsigned)},b.shiftLeft=function(R){return e(R)&&(R=R.toInt()),(R&=63)==0?this:R<32?i(this.low<<R,this.high<<R|this.low>>>32-R,this.unsigned):i(0,this.low<<R-32,this.unsigned)},b.shl=b.shiftLeft,b.shiftRight=function(R){return e(R)&&(R=R.toInt()),(R&=63)==0?this:R<32?i(this.low>>>R|this.high<<32-R,this.high>>R,this.unsigned):i(this.high>>R-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(R){var M;return e(R)&&(R=R.toInt()),(R&=63)==0?this:(M=this.high,R<32?i(this.low>>>R|M<<32-R,M>>>R,this.unsigned):i(R===32?M:M>>>R-32,0,this.unsigned))},b.shru=b.shiftRightUnsigned,b.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},b.toBytes=function(R){return R?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var R=this.high,M=this.low;return[255&M,255&M>>>8,255&M>>>16,255&M>>>24,255&R,255&R>>>8,255&R>>>16,255&R>>>24]},b.toBytesBE=function(){var R=this.high,M=this.low;return[255&R>>>24,255&R>>>16,255&R>>>8,255&R,255&M>>>24,255&M>>>16,255&M>>>8,255&M]},t}()),Ha));Uo.getModule=function(t){var e=new Uo[t];return e.getArrayData=function(){var n=e.toArrayBuffer();return n=du(n)?[].slice.call(new Int8Array(n)):n},e};var Do,Jl="pgMsgP",Wl="chatMsg",zl="pcMsgP",Ql={PRIVATE:"ppMsgS",GROUP:"pgMsgS",CHATROOM:"chatMsgS"},Xl="delMsg",Zl="joinChrm",eh="joinChrmR",th="exitChrm",nh="setKV",rh="delKV",ih="setKVS",oh="delKVS",ja="qryRelationR",sh="delRelation",ah="setSeAtt",_r={PRIVATE:"cleanPMsg",GROUP:"cleanGMsg",CUSTOMER_SERVICE:"cleanCMsg",SYSTEM:"cleanSMsg"},Su="qryPMsg",ch="qryGMsg",Iu="qryCHMsg",uh="qryCMsg",dh="qrySMsg",lh=((bn={}).ppMsgP=z.PRIVATE,bn[Jl]=z.GROUP,bn[Wl]=z.CHATROOM,bn[zl]=z.CUSTOMER_SERVICE,bn),hh=((Qt={})[z.PRIVATE]=Su,Qt[z.GROUP]=ch,Qt[z.CHATROOM]=Iu,Qt[z.CUSTOMER_SERVICE]=uh,Qt[z.SYSTEM]=dh,Qt),fh=((Nn={})[z.PRIVATE]=_r.PRIVATE,Nn[z.GROUP]=_r.GROUP,Nn[z.CUSTOMER_SERVICE]=_r.CUSTOMER_SERVICE,Nn[z.SYSTEM]=_r.SYSTEM,Nn),Yi="1",ph="0",$a=1,Ka=2,qa=3,gh=function(){function t(e){this._codec=e==="websocket"?Uo:Xn,this._connectType=e}return t.prototype.decodeByPBName=function(e,n,r){var i,o=this,s=e,c=((i={})[Wn]=o._formatSyncMessages,i[Ci]=o._formatReceivedMessage,i[Jn]=o._formatSentMessage,i[zn]=o._formatHistoryMessages,i[Qn]=o._formatConversationList,i[Ei]=o._formatChatRoomInfos,i[$t]=o._formatRTCUserList,i[Ti]=o._formatRTCData,i[rn]=o._formatChatRoomKVList,i[Si]=o._formatUserSetting,i[bi]=o._formatConversationStatus,i[Ni]=o._formatGrpReadReceiptQryResp,i[on]=o._formatSetUserSettingOutput,i[Ii]=o._formatUserSettingNotification,i[wi]=o._formatRTCRoomKVList,i[Ri]=o._formatRTCAuidenceJoinRoomData,i[Oi]=o._formatRTCJoinedUserInfo,i)[n];try{s=e.length>0&&o._codec[n].decode(e),Ve(s)&&(s=function(d){for(var l in d)Ve(d[l])&&(d[l]=it(d[l]));return d}(s)),Gr(c)&&(s=c.call(this,s,r))}catch(d){$.error(`PB parse error
  793. `,d,e,n)}return s},t.prototype._readBytes=function(e){var n=e.offset,r=e.buffer,i=e.limit;if(n)try{var o=du(r)?new Uint8Array(r):r;return or.readUTF(o.subarray(n,i))}catch(s){$.info(`readBytes error
  794. `,s)}return e},t.prototype._formatBytes=function(e){var n=this._readBytes(e);try{n=JSON.parse(n)}catch(r){$.info(`formatBytes error
  795. `,r)}return n||e},t.prototype._formatSyncMessages=function(e,n){n=n||{};var r=this,i=e.list,o=e.syncTime,s=e.finished;return(me(s)||s===null)&&(e.finished=!0),e.syncTime=it(o),e.list=mr(i,function(c){return r._formatReceivedMessage(c,n)}),e},t.prototype._formatReceivedMessage=function(e,n){var r=(n=n||{}).currentUserId,i=n.connectedTime,o=e.content,s=e.fromUserId,c=e.type,d=e.groupId,l=e.status,h=e.dataTime,a=e.classname,u=e.msgId,f=e.extraContent,p=e.pushContent,m=e.pushExt,_=e.configFlag,v=(e.direction||st.RECEIVE)===st.SEND,y=function(ae){var te=Gn.READ;return{isPersited:!!(16&ae),isCounted:!!(32&ae),isMentioned:!!(64&ae),disableNotification:!!(512&ae),receivedStatus:te=2&ae?Gn.RETRIEVED:te,canIncludeExpansion:!!(1024&ae)}}(l),C=y.isPersited,I=y.isCounted,P=y.isMentioned,b=y.disableNotification,R=y.receivedStatus,M=y.canIncludeExpansion,F=[z.GROUP,z.CHATROOM,z.RTC_ROOM].indexOf(c)>-1?d:s,q=v?r:s,E=it(h),T=E<i,A=c===z.CHATROOM,L=this._formatBytes(o),k={};if(m&&(k=Da(m.pushConfigs,m.pushId)),L.user){var V=L.user,j=V.portrait,G=V.portraitUri,J=j||G;J&&(L.user.portrait=L.user.portraitUri=J)}var oe,he=Ce(Ce({},k),{pushTitle:m==null?void 0:m.title,pushContent:p,pushData:p,disablePushTitle:!!_&&Boolean(4&_),forceShowDetailContent:!!_&&Boolean(8&_),templateId:m==null?void 0:m.templateId}),de=v?st.SEND:st.RECEIVE;return A&&s===r&&(de=st.SEND),f&&(oe={},oe=Ba(f)),{conversationType:c,targetId:F,senderUserId:q,messageType:a,messageUId:u,isPersited:C,isCounted:I,isMentioned:P,sentTime:E,isOffLineMessage:T,messageDirection:de,receivedTime:en.getTime(),disableNotification:b,receivedStatus:R,canIncludeExpansion:M,content:L,expansion:oe,configFlag:_,pushConfig:he,channelId:e.busChannel||""}},t.prototype._formatSentMessage=function(e,n){var r,i=e.content,o=e.classname,s=e.sessionId,c=e.msgId,d=e.extraContent,l=e.pushExt,h=e.pushContent,a=e.configFlag,u=n.signal,f=n.currentUserId,p=u.date,m=u.topic,_=u.targetId,v=function(T){return{isPersited:!!(1&T),isCounted:!!(2&T),disableNotification:!!(32&T),canIncludeExpansion:!!(64&T)}}(s),y=v.isPersited,C=v.isCounted,I=v.disableNotification,P=v.canIncludeExpansion,b=lh[m]||z.PRIVATE,R=Hl(Ql,m),M=this._formatBytes(i),F=_;o===$e.RECALL&&(b=M.conversationType||b,F=M.targetId||_),d&&(r={},r=Ba(d));var q={};l&&(q=Da(l.pushConfigs,l.pushId));var E=Ce(Ce({},q),{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:b,targetId:F,messageType:o,messageUId:c,isPersited:y,isCounted:C,isStatusMessage:R,senderUserId:f,content:this._formatBytes(i),sentTime:1e3*p,receivedTime:en.getTime(),messageDirection:st.SEND,isOffLineMessage:!1,disableNotification:I,canIncludeExpansion:P,expansion:r,pushConfig:E,channelId:e.busChannel||""}},t.prototype._formatHistoryMessages=function(e,n){var r=this,i=n.conversation||{},o=e.list,s=e.hasMsg,c=i.targetId,d=it(e.syncTime),l=[];return Oe(o,function(h){var a=r._formatReceivedMessage(h,n);a.targetId=c,l.push(a)},{isReverse:!0}),{syncTime:d,list:l,hasMore:!!s}},t.prototype._formatConversationList=function(e,n){var r=this,i=e.info,o=n.afterDecode||function(){};return(i=mr(i,function(s){var c=s.msg,d=s.userId,l=s.type,h=s.unreadCount,a=s.busChannel,u=null;c&&((u=r._formatReceivedMessage(c,n)).targetId=d);var f={targetId:d,conversationType:l,unreadMessageCount:h,latestMessage:u,channelId:a||""};return o(f)||f}))||[]},t.prototype._formatSetUserSettingOutput=function(e){return e},t.prototype._formatChatRoomInfos=function(e){var n=e.userTotalNums,r=e.userInfos;return{userCount:n,userInfos:mr(r,function(i){var o=i.id,s=i.time;return{id:o,time:it(s)}})}},t.prototype._formatChatRoomKVList=function(e){var n=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:n=mr(n=n||[],function(o){var s=o.key,c=o.value,d=o.status,l=o.timestamp,h=o.uid,a=function(u){return{isAutoDelete:!!(1&u),isOverwrite:!!(2&u),type:4&u?Qe.DELETE:Qe.UPDATE}}(d);return{key:s,value:c,isAutoDelete:a.isAutoDelete,isOverwrite:a.isOverwrite,type:a.type,userId:h,timestamp:it(l)}}),isFullUpdate:r,syncTime:i}},t.prototype._formatUserSetting=function(e){var n=this,r=e.items,i=e.version,o={};return Oe(r||[],function(s){var c=s.key,d=s.version,l=s.value;s.version=it(d),s.value=n._readBytes(l),c==="Tag"&&s.tags.forEach(function(h){h.createdTime=it(h.createdTime),h.tagName=h.name}),o[c]=s}),{settings:o,version:i}},t.prototype._formatConversationStatus=function(e){var n=e.state,r=[];return Oe(n,function(i){var o=i.type,s=i.channelId,c=i.time,d=i.stateItem,l=i.busChannel,h=Zt.CLOSE,a=!1,u=[];Oe(d,function(f){var p=f.sessionStateType,m=f.value,_=f.tags;switch(p){case $a:h=m===Yi?Zt.OPEN:Zt.CLOSE;break;case Ka:a=m===Yi;break;case qa:u=_}}),r.push({conversationType:o,type:o,targetId:s,notificationStatus:h,isTop:a,updatedTime:it(c),tags:u,channelId:l||""})}),r},t.prototype._formatRTCUserList=function(e){var n=e.users,r=e.token,i=e.sessionId,o=e.roomInfo,s=e.entries,c={};return Oe(n,function(d){var l=d.userId,h=d.userData,a={};Oe(h,function(u){var f=u.key,p=u.value;a[f]=p}),c[l]=a}),{users:c,token:r,sessionId:i,roomInfo:o,kvEntries:s}},t.prototype._formatRTCData=function(e){var n=e.outInfo,r={};return Oe(n,function(i){r[i.key]=i.value}),r},t.prototype._formatRTCRoomInfo=function(e){var n=e.roomId,r=e.userCount,i=e.roomData,o={id:n,total:r};return Oe(i,function(s){o[s.key]=s.value}),o},t.prototype._formatGrpReadReceiptQryResp=function(e){var n=e.totalMemberNum,r=e.list;return r.forEach(function(i){i.readTime=it(i.readTime)}),{totalMemberCount:n,list:r}},t.prototype._formatUserSettingNotification=function(e){return e},t.prototype._formatRTCRoomKVList=function(e){var n=e.entries,r=e.bFullUpdate,i=e.syncTime;return{kvEntries:n=(n=n||[]).map(function(o){var s=o.timestamp;return Object.assign(o,{timestamp:it(s)})}),isFullUpdate:r,syncTime:i}},t.prototype._formatRTCAuidenceJoinRoomData=function(e){return e},t.prototype._formatRTCJoinedUserInfo=function(e){return(e.info||[]).map(function(n){return{deviceId:n.deviceId,roomId:n.roomId,joinTime:it(n.joinTime)}})},t.prototype.encodeServerConfParams=function(){var e=this._codec.getModule(fs);return e.setNothing(1),e.getArrayData()},t.prototype._getUpMsgModule=function(e,n){var r,i,o,s=this._connectType==="comet",c=(e.conversationType,n.messageType),d=n.isMentioned,l=n.mentionedType,h=n.mentionedUserIdList,a=n.content,u=n.pushContent,f=n.pushData,p=n.directionalUserIdList,m=n.isFilerWhiteBlacklist,_=n.isVoipPush,v=n.canIncludeExpansion,y=n.expansion,C=n.pushConfig,I=n.channelId;z.GROUP;var P=this._codec.getModule(Jn),b=function(de){var ae=de.isStatusMessage,te=de.isPersited,U=de.isCounted;ae&&(te=U=!1);var Y=0;return te&&(Y|=1),U&&(Y|=2),de.isMentioned&&(Y|=4),de.disableNotification&&(Y|=32),de.canIncludeExpansion&&(Y|=64),Y}(n),R=C||{},M=R.pushTitle,F=R.pushContent,q=R.pushData,E=R.iOSConfig,T=R.androidConfig,A=R.templateId,L=R.disablePushTitle,k=R.forceShowDetailContent,V=0;P.setSessionId(b),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||ds.ALL,mentionedContent:((o=a.mentionedInfo)===null||o===void 0?void 0:o.mentionedContent)||""});var j=F||u||"",G=q||f||"";if(j&&P.setPushText(j),G&&P.setAppData(G),p&&P.setUserId(p),V|=_?1:0,V|=m?2:0,V|=L?4:0,V|=k?8:0,P.setConfigFlag(V),P.setClassname(c),a.user&&a.user.portraitUri&&(a.user.portrait=a.user.portraitUri),P.setContent(JSON.stringify(a)),v&&y){var J={};Oe(y,function(de,ae){J[ae]={v:de}}),P.setExtraContent(JSON.stringify(J))}if(C){var oe=this._codec.getModule(hs);if(M&&oe.setTitle(M),E&&T){var he=Vl(E,T);oe.setPushConfigs(he)}(T==null?void 0:T.notificationId)&&oe.setPushId(T==null?void 0:T.notificationId),oe.setTemplateId(A||""),P.setPushExt(s?oe.getArrayData():oe)}return me(I)||P.setBusChannel(I),P},t.prototype.encodeUpMsg=function(e,n){return this._getUpMsgModule(e,n).getArrayData()},t.prototype.encodeSyncMsg=function(e){var n=e.sendboxTime,r=e.inboxTime,i=this._codec.getModule(ps);return i.setIspolling(!1),i.setIsPullSend(!0),i.setSendBoxSyncTime(n),i.setSyncTime(r),i.getArrayData()},t.prototype.encodeChrmSyncMsg=function(e,n){e=e||0,n=n||0;var r=this._codec.getModule(gs);return r.setCount(n),r.setSyncTime(e),r.getArrayData()},t.prototype.encodeGetHistoryMsg=function(e,n){var r=n.count,i=n.order,o=n.timestamp,s=n.channelId,c=this._codec.getModule(ms);return c.setTargetId(e),c.setTime(o),c.setCount(r),c.setOrder(i),c.setBusChannel(s||""),c.getArrayData()},t.prototype.encodeGetConversationList=function(e){var n=(e=e||{}).count,r=e.startTime,i=this._codec.getModule(Wr);return i.setType(1),i.setCount(n),i.setStartTime(r),i.getArrayData()},t.prototype.encodeOldConversationList=function(e){var n=(e=e||{}).count,r=e.type,i=e.startTime,o=e.order;n=n||0,i=i||0,o=o||0;var s=this._codec.getModule(Wr);return s.setType(r),s.setCount(n),s.setStartTime(i),s.setOrder(o),s.getArrayData()},t.prototype.encodeRemoveOldConversationList=function(e){var n=(e=e||{}).conversationType,r=e.channelId,i=this._codec.getModule(ys);return i.setType(n),i.setBusChannel(r),i.getArrayData()},t.prototype.encodeRemoveConversationList=function(e){var n=this,r=this._codec.getModule(_s),i=[];return Oe(e,function(o){var s=o.conversationType,c=o.targetId,d=n._codec.getModule(vs);d.setType(s),d.setChannelId(c),i.push(d)}),r.setSessions(i),r.getArrayData()},t.prototype.encodeDeleteMessages=function(e,n,r,i){var o=this._codec.getModule(Cs),s=[];return Oe(r,function(c){s.push({msgId:c.messageUId,msgDataTime:c.sentTime,direct:c.messageDirection})}),o.setType(e),o.setConversationId(n),o.setMsgs(s),o.setBusChannel(i),o.getArrayData()},t.prototype.encodeClearMessages=function(e,n,r){var i=this._codec.getModule(Es);return n=n||new Date().getTime(),i.setDataTime(n),i.setTargetId(e),i.setBusChannel(r),i.getArrayData()},t.prototype.encodeClearUnreadCount=function(e,n){var r=e.conversationType,i=e.targetId,o=n.timestamp,s=this._codec.getModule(Rs);return o=o||+new Date,s.setType(r),s.setChannelId(i),s.setMsgTime(o),s.getArrayData()},t.prototype.encodeJoinOrQuitChatRoom=function(){var e=this._codec.getModule(Ts);return e.setNothing(1),e.getArrayData()},t.prototype.encodeGetChatRoomInfo=function(e,n){var r=this._codec.getModule(Is);return r.setCount(e),r.setOrder(n),r.getArrayData()},t.prototype.encodeGetFileToken=function(e,n,r,i){var o=this._codec.getModule(Ls);return o.setType(e),o.setKey(n),o.setHttpMethod(r),o.setQueryString(i),o.getArrayData()},t.prototype.encodeGetFileUrl=function(e,n,r,i){var o=this._codec.getModule(e);return o.setType(n),o.setKey(r),i&&o.setFileName(i),o.getArrayData()},t.prototype.encodeModifyChatRoomKV=function(e,n,r){var i=this._connectType==="comet",o=this._codec.getModule(Vs),s=n.key,c=n.value,d=n.notificationExtra,l=n.isSendNotification,h=n.type||Qe.UPDATE,a=Va(n,h),u={key:s,value:c||"",uid:r};if(me(a)||(u.status=a),o.setEntry(u),l){var f={conversationType:z.CHATROOM,targetId:e},p={key:s,value:c,extra:d,type:h},m=this._getUpMsgModule(f,{messageType:$e.CHRM_KV_NOTIFY,content:p,isPersited:!1,isCounted:!1});i?o.setNotification(m.getArrayData()):o.setNotification(m),o.setBNotify(!0),o.setType(z.CHATROOM)}return o.getArrayData()},t.prototype.encodeModifyChatRoomKVS=function(e,n,r){this._connectType;var i=this._codec.getModule(Fs),o=n.entries,s=n.type||Qe.UPDATE,c=Va(n,s),d=[];return o.forEach(function(l){var h={key:l.key,value:l.value||"",uid:r};me(c)||(h.status=c),d.push(h)}),i.setEntry(d),i.getArrayData()},t.prototype.encodePullChatRoomKV=function(e){var n=this._codec.getModule(js);return n.setTimestamp(e),n.getArrayData()},t.prototype.encodePullUserSetting=function(e){var n=this._codec.getModule($s);return n.setVersion(e),n.getArrayData()},t.prototype.encodeGetConversationStatus=function(e){var n=this._codec.getModule(Ks);return n.setTime(e),n.getArrayData()},t.prototype.encodeSetConversationStatus=function(e){var n=this,r=this._connectType==="comet",i=this._codec.getModule(ti),o=en.getTime(),s=[];return Oe(e,function(c){var d=n._codec.getModule(Zr),l=c.conversationType,h=c.targetId,a=c.notificationStatus,u=c.isTop,f=c.channelId,p=[];d.setType(l),d.setChannelId(h),d.setTime(o),d.setBusChannel(f);var m=a===Zt.OPEN,_={};me(a)||(_[$a]=m),me(u)||(_[Ka]=u),Oe(_,function(y,C){if(!me(y)){var I=n._codec.getModule(ei);y=y?Yi:ph,I.setSessionStateType(Number(C)),I.setValue(y);var P=r?I.getArrayData():I;p.push(P)}}),d.setStateItem(p);var v=r?d.getArrayData():d;s.push(v)}),i.setVersion(o),i.setState(s),i.getArrayData()},t.prototype.encodeReadReceipt=function(e,n){var r=this._codec.getModule(ni);return r.setMsgId(e),n&&r.setChannelId(n),r.getArrayData()},t.prototype.encodeCreateTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(Gs),s=[];return e.forEach(function(c){var d=r._codec.getModule(Fn);d.setTagId(c.tagId),d.setName(c.tagName),s.push(i?d.getArrayData():d)}),o.setTags(s),o.setVersion(n),o.getArrayData()},t.prototype.encodeMessageReader=function(e,n){var r=this._codec.getModule(ni);return r.setMsgId(e),n&&r.setChannelId(n),r.getArrayData()},t.prototype.encodeRemoveTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(Ys),s=[];return e.forEach(function(c){var d=r._codec.getModule(Fn);d.setTagId(c),s.push(i?d.getArrayData():d)}),o.setTags(s),o.setVersion(n),o.getArrayData()},t.prototype.encodeDisConversationTag=function(e){var n=this._codec.getModule(Js);return n.setTagId(e),n.getArrayData()},t.prototype.encodeUpdateConversationTag=function(e,n){var r=this,i=this._connectType==="comet",o=this._codec.getModule(ti),s=[];return n.forEach(function(c){var d=r._codec.getModule(Zr),l=r._codec.getModule(ei),h=[];e.forEach(function(a){var u=r._codec.getModule(Fn);u.setTagId(a.tagId),me(a.isTop)||u.setIsTop(a.isTop),h.push(i?u.getArrayData():u)}),l.setSessionStateType(qa),l.setValue(JSON.stringify(h)),l.setTags(h),d.setType(c.conversationType),d.setChannelId(c.targetId),d.setTime(Date.now()),d.setStateItem([i?l.getArrayData():l]),s.push(i?d.getArrayData():d)}),o.setState(s),o.setVersion(en.getTime()),o.getArrayData()},t.prototype.encodeReportSDKInfo=function(e){var n=this._codec.getModule(Ws);return n.setSdkInfo(e),n.getArrayData()},t.prototype.encodeJoinRTCRoom=function(e,n,r){var i=this._codec.getModule(zr);return e=e||0,i.setRoomType(e),me(n)||i.setBroadcastType(n),me(r)||i.setJoinType(r),i.getArrayData()},t.prototype.encodeQuitRTCRoom=function(){return this._codec.getModule(bs).getArrayData()},t.prototype.encodeSetRTCData=function(e,n,r,i,o){var s=this._codec.getModule(Ns);if(s.setInterior(r),s.setTarget(i),s.setKey(e),s.setValue(n),o){o.name&&s.setObjectName(o.name);var c=o.content;c&&(Ve(c)&&(c=JSON.stringify(c)),s.setContent(c))}return s.getArrayData()},t.prototype.encodeUserSetRTCData=function(e,n,r,i){var o=this,s=this._connectType==="comet",c=this._codec.getModule(Qr);c.setObjectName(r);var d=this._codec.getModule(ot);d.setKey(e.name),d.setValue(e.content),s?c.setContent([d.getArrayData()]):c.setContent(d);var l=[];return["uris","mcu_uris"].forEach(function(h){var a=o._codec.getModule(ot);a.setKey(h);var u=h==="uris"?n:i;a.setValue(u),s?l.push(a.getArrayData()):l.push(a)}),c.setValueInfo(l),c.getArrayData()},t.prototype.encodeUserSetRTCCDNUris=function(e,n){this._connectType;var r=this._codec.getModule(Qr);r.setObjectName(e);var i=this._codec.getModule(ot);return i.setKey("cdn_uris"),i.setValue(n),r.setValueInfo(i),r.getArrayData()},t.prototype.encodeGetRTCData=function(e,n,r){var i=this._codec.getModule(Xr);return i.setInterior(n),i.setTarget(r),i.setKey(e),i.getArrayData()},t.prototype.encodeRemoveRTCData=function(e,n,r,i){var o=this._codec.getModule(Xr);o.setInterior(n),o.setTarget(r),o.setKey(e);var s=(i=i||{}).name,c=i.content;return!me(s)&&o.setObjectName(s),me(c)||(Ve(c)&&(c=JSON.stringify(c)),o.setContent(c)),o.getArrayData()},t.prototype.encodeSetRTCOutData=function(e,n,r){var i=this._codec.getModule(ws);i.setTarget(n),We(e)||(e=[e]),Oe(e,function(c,d){c.key=c.key?c.key.toString():c.key,c.value=c.value?c.value.toString():c.value,e[d]=c}),i.setValueInfo(e);var o=(r=r||{}).name,s=r.content;return!me(o)&&i.setObjectName(o),me(s)||(Ve(s)&&(s=JSON.stringify(s)),i.setContent(s)),i.getArrayData()},t.prototype.ecnodeGetRTCOutData=function(e){var n=this._codec.getModule(As);return n.setUserId(e),n.getArrayData()},t.prototype.encodeSetRTCState=function(e){var n=this._codec.getModule(Os);return n.setState(e),n.getArrayData()},t.prototype.encodeGetRTCRoomInfo=function(){var e=this._codec.getModule(Ms);return e.setOrder(2),e.getArrayData()},t.prototype.encodeSetRTCUserInfo=function(e,n){var r=this._codec.getModule(ot);return r.setKey(e),r.setValue(n),r.getArrayData()},t.prototype.encodeRemoveRTCUserInfo=function(e){var n=this._codec.getModule(Ps);return n.setKey(e),n.getArrayData()},t.prototype.encodeIdentityChangeInfo=function(e,n,r){r===void 0&&(r=!1);var i=this._codec.getModule(zr);return i.setRoomType(qe.LIVE),n&&i.setBroadcastType(n),i.setIdentityChangeType(e),i.setNeedSysChatroom(r),i.getArrayData()},t.prototype.encodePullRTCRoomKV=function(e,n){var r=this._codec.getModule(Qs);return r.setTimestamp(n),r.setRoomId(e),r.getArrayData()},t.prototype.encodeQueryUserJoinedInfo=function(e){var n=this._codec.getModule(Xs);return n.setUserId(e),n.getArrayData()},t.prototype.encodeRequestRoomPK=function(e){var n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,o=e.inviteTimeout,s=e.inviteInfo,c=this._codec.getModule(Zs);return c.setInvitedRoomId(n),c.setInvitedUserId(r),c.setInviteSessionId(i),c.setTimeoutTime(o),c.setInviteInfo(s),c.getArrayData()},t.prototype.encodeCancelRoomPK=function(e){var n=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,o=e.inviteInfo,s=this._codec.getModule(ea);return s.setInvitedRoomId(n),s.setInvitedUserId(r),s.setInviteSessionId(i),s.setInviteInfo(o),s.getArrayData()},t.prototype.encodeResponseRoomPK=function(e){var n=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,o=e.content,s=e.key,c=e.value,d=e.agree?1:0,l=this._codec.getModule(ta);return l.setInviteUserId(n),l.setInviteRoomId(r),l.setInviteSessionId(i),l.setContent(o),l.setKey(s),l.setValue(c),l.setAnswerCode(d),l.getArrayData()},t.prototype.encodeEndRoomPK=function(e){var n=e.endRoomId,r=e.sessionId,i=e.content,o=e.keys,s=this._codec.getModule(na);return s.setInviteRoomId(n),s.setInviteSessionId(r),s.setInviteContent(i),s.setInviteRoomKeys(o),s.getArrayData()},t}(),bu=function(t,e){this._watcher=e,this.codec=new gh(t)},Nu=function(t,e){return t&&e?e+"_"+t:t||Date.now()},sr=function(){function t(e){this.header=e,this._name=null,this.lengthSize=0,this.messageId=0,this.timestamp=0,this.syncMsg=!1,this.identifier=""}return t.prototype.getIdentifier=function(){var e=this.messageId,n=this.identifier;return Nu(e,n)},t.prototype.read=function(e,n,r){this.readMessage(e,n,r)},t.prototype.readMessage=function(e,n,r){return{stream:e,length:n}},t}(),wu=function(){function t(e){this.lengthSize=0,this.messageId=0,this.topic="",this.targetId="",this.identifier="",this._header=new ls(e,!1,Tt.AT_MOST_ONCE,!1)}return t.prototype.getIdentifier=function(){var e=this.messageId,n=this.identifier;return Nu(e,n)},t.prototype.write=function(e){var n=this.getHeaderFlag();e.write(n),this.writeMessage(e)},t.prototype.setHeaderQos=function(e){this._header.qos=e},t.prototype.getHeaderFlag=function(){return this._header.encode()},t.prototype.getLengthSize=function(){return this.lengthSize},t.prototype.getBufferData=function(){var e=new Kl;this.write(e);var n=e.getBytesArray();return new Int8Array(n)},t.prototype.getCometData=function(){var e=this.data||{};return JSON.stringify(e)},t}(),Ou=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=et.CONN_ACK,n.status=null,n.userId=null,n.timestamp=0,n}return Ne(e,t),e.prototype.readMessage=function(n,r,i){if(n.readByte(),this.status=+n.readByte(),r<=e.MESSAGE_LENGTH)return{stream:n,length:r};if(i===jt.V4){var o=n.readByte();1&o&&(this.userId=n.readUTF()),2&o&&n.readUTF(),4&o&&(this.timestamp=n.readLong()),8&o&&(this.messageId=n.read2Byte())}else{this.userId=n.readUTF();var s=n.readUTF();$.debug("server sessionId -> "+s),this.timestamp=n.readLong()}return{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(sr),ra=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=et.DISCONNECT,n.status=0,n}return Ne(e,t),e.prototype.readMessage=function(n,r){return n.readByte(),this.status=+n.readByte(),{stream:n,length:r}},e.MESSAGE_LENGTH=2,e}(sr),mh=function(t){function e(){var n=t.call(this,je.PING_REQ)||this;return n._name=et.PING_REQ,n}return Ne(e,t),e.prototype.writeMessage=function(n){},e}(wu),Au=function(t){function e(n){var r=t.call(this,n)||this;return r._name=et.PING_RESP,r}return Ne(e,t),e}(sr),ia=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Ne(e,t),e.prototype.readMessage=function(n,r){var i=256*n.readByte()+n.readByte();return this.messageId=parseInt(i.toString(),10),{stream:n,length:r}},e}(sr),Ai=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.messageId=0,n}return Ne(e,t),e.prototype.writeMessage=function(n){var r=this.messageId,i=255&r,o=(65280&r)>>8;n.write(o),n.write(i)},e}(wu),Zn=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=et.PUBLISH,n.topic="",n.targetId="",n.syncMsg=!1,n.identifier=Gt.PUB,n}return Ne(e,t),e.prototype.readMessage=function(n,r){return this.date=n.readInt(),this.topic=n.readUTF(),this.targetId=n.readUTF(),t.prototype.readMessage.call(this,n,r),this.data=n.readAll(),{stream:n,length:r}},e}(ia),wn=function(t){function e(n,r,i){var o=t.call(this,je.PUBLISH)||this;return o._name=et.PUBLISH,o.syncMsg=!1,o.identifier=Gt.PUB,o.topic=n,o.data=Ze(r)?or.writeUTF(r):r,o.targetId=i,o}return Ne(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Ai),xo=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=et.PUB_ACK,n.status=0,n.date=0,n.millisecond=0,n.messageUId="",n.timestamp=0,n.identifier=Gt.PUB,n.topic="",n.targetId="",n}return Ne(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.millisecond=256*n.readByte()+n.readByte(),this.timestamp=1e3*this.date+this.millisecond,this.messageUId=n.readUTF(),{stream:n,length:r}},e}(ia),Mu=function(t){function e(n){var r=t.call(this,je.PUB_ACK)||this;return r._name=et.PUB_ACK,r.status=0,r.date=0,r.millisecond=0,r.messageUId="",r.timestamp=0,r.messageId=n,r}return Ne(e,t),e.prototype.writeMessage=function(n){t.prototype.writeMessage.call(this,n)},e}(Ai),Q=function(t){function e(n,r,i){var o=t.call(this,je.QUERY)||this;return o.name=et.QUERY,o.identifier=Gt.QUERY,o.topic=n,o.data=Ze(r)?or.writeUTF(r):r,o.targetId=i,o}return Ne(e,t),e.prototype.writeMessage=function(n){n.writeUTF(this.topic),n.writeUTF(this.targetId),t.prototype.writeMessage.call(this,n),n.write(this.data)},e}(Ai),Pu=function(t){function e(n){var r=t.call(this,je.QUERY_CONFIRM)||this;return r._name=et.QUERY_CON,r.messageId=n,r}return Ne(e,t),e}(Ai),Hn=function(t){function e(){var n=t!==null&&t.apply(this,arguments)||this;return n._name=et.QUERY_ACK,n.status=0,n.identifier=Gt.QUERY,n.topic="",n.targetId="",n}return Ne(e,t),e.prototype.readMessage=function(n,r){return t.prototype.readMessage.call(this,n,r),this.date=n.readInt(),this.status=256*n.readByte()+n.readByte(),this.data=n.readAll(),{stream:n,length:r}},e}(ia),Lu=function(t){var e,n=t.type;switch(n){case je.CONN_ACK:e=new Ou(t);break;case je.PUBLISH:(e=new Zn(t)).syncMsg=t.syncMsg;break;case je.PUB_ACK:e=new xo(t);break;case je.QUERY_ACK:e=new Hn(t);break;case je.SUB_ACK:case je.UNSUB_ACK:case je.PING_RESP:e=new Au(t);break;case je.DISCONNECT:e=new ra(t);break;default:e=new sr(t),$.error("No support for deserializing "+n+" messages")}return e};(function(t){t[t.ppMsgP=1]="ppMsgP",t[t.ppMsgN=2]="ppMsgN",t[t.ppMsgS=3]="ppMsgS",t[t.pgMsgP=4]="pgMsgP",t[t.chatMsg=5]="chatMsg",t[t.pcMsgP=6]="pcMsgP",t[t.qryPMsg=7]="qryPMsg",t[t.qryGMsg=8]="qryGMsg",t[t.qryCHMsg=9]="qryCHMsg",t[t.qryCMsg=10]="qryCMsg",t[t.qrySMsg=11]="qrySMsg",t[t.recallMsg=12]="recallMsg",t[t.prMsgS=13]="prMsgS",t[t.rrMsg=14]="rrMsg",t[t.rrList=15]="rrList",t[t.s_ntf=16]="s_ntf",t[t.s_msg=17]="s_msg",t[t.s_stat=18]="s_stat",t[t.s_cmd=19]="s_cmd",t[t.s_us=20]="s_us",t[t.pullUS=21]="pullUS",t[t.pgMsgS=22]="pgMsgS",t[t.chatMsgS=23]="chatMsgS",t[t.qrySessionsAtt=24]="qrySessionsAtt",t[t.pullMsg=25]="pullMsg",t[t.qrySessions=26]="qrySessions",t[t.delSessions=27]="delSessions",t[t.delMsg=28]="delMsg",t[t.updRRTime=29]="updRRTime",t[t.chrmPull=30]="chrmPull",t[t.joinChrm=31]="joinChrm",t[t.joinChrmR=32]="joinChrmR",t[t.exitChrm=33]="exitChrm",t[t.queryChrmI=34]="queryChrmI",t[t.setKV=35]="setKV",t[t.delKV=36]="delKV",t[t.pullKV=37]="pullKV",t[t.qryRelation=38]="qryRelation",t[t.delRelation=39]="delRelation",t[t.pullSeAtts=40]="pullSeAtts",t[t.setSeAtt=41]="setSeAtt",t[t.qnTkn=42]="qnTkn",t[t.qnUrl=43]="qnUrl",t[t.aliUrl=44]="aliUrl",t[t.s3Url=45]="s3Url",t[t.stcUrl=46]="stcUrl",t[t.cleanPMsg=47]="cleanPMsg",t[t.cleanGMsg=48]="cleanGMsg",t[t.cleanCMsg=49]="cleanCMsg",t[t.cleanSMsg=50]="cleanSMsg",t[t.rtcRJoin_data=51]="rtcRJoin_data",t[t.rtcRExit=52]="rtcRExit",t[t.rtcPing=53]="rtcPing",t[t.rtcSetData=54]="rtcSetData",t[t.rtc_ntf=55]="rtc_ntf",t[t.viewerJoinR=56]="viewerJoinR",t[t.viewerExitR=57]="viewerExitR",t[t.rtcPullKv=58]="rtcPullKv",t[t.rtcIdentityChange=59]="rtcIdentityChange",t[t.userSetData=60]="userSetData",t[t.rtcQryData=61]="rtcQryData",t[t.rtcDelData=62]="rtcDelData",t[t.rtcSetOutData=63]="rtcSetOutData",t[t.rtcQryUserOutData=64]="rtcQryUserOutData",t[t.rtcToken=65]="rtcToken",t[t.rtcUserState=66]="rtcUserState",t[t.rtcRInfo=67]="rtcRInfo",t[t.rtcUData=68]="rtcUData",t[t.rtcUPut=69]="rtcUPut",t[t.rtcUDel=70]="rtcUDel",t[t.rtcUList=71]="rtcUList",t[t.rtcQueryJoined=72]="rtcQueryJoined",t[t.addSeTag=73]="addSeTag",t[t.delSeTag=74]="delSeTag",t[t.addTag=75]="addTag",t[t.delTag=76]="delTag",t[t.disTag=77]="disTag",t[t.reportsdk=78]="reportsdk",t[t.rtcInvite=79]="rtcInvite",t[t.rtcCancelInvite=80]="rtcCancelInvite",t[t.rtcInviteAnswer=81]="rtcInviteAnswer",t[t.rtcEndInvite=82]="rtcEndInvite"})(Do||(Do={}));var ht,D=Do,ku=function(t,e,n,r){return x(void 0,void 0,void 0,function(){var i;return B(this,function(o){return i=0,t.forEach(function(s){return x(void 0,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return c=e+"://"+s+"/ping?r="+(a=9999,(h=1e3)+Math.floor(Math.random()*(a-h))),$.debug("start ping",c),[4,n.httpReq({url:c,timeout:5e3})];case 1:return d=l.sent(),$.debug("end ping",i,c,d.status),i++,r({finished:i===t.length,code:d.status,host:s}),[2]}var h,a})})}),[2]})})},Uu=function(t,e,n,r,i,o,s,c){return t+"://"+e+"/websocket?appId="+n+"&token="+encodeURIComponent(r)+"&sdkVer="+o+"&pid="+s+"&apiVer="+(i.isFromUniapp?"uniapp":"normal")+(i.connectPlatform?"&platform="+i.connectPlatform:"")+(c?"&protocolVer="+c:"")},Du=function(t){return[D.ppMsgS,D.pgMsgS,D.chatMsgS].map(function(e){return D[e]}).indexOf(t)>=0};(function(t){t[t.REDIRECT=0]="REDIRECT",t[t.OTHER_DEVICE_LOGIN=1]="OTHER_DEVICE_LOGIN",t[t.BLOCK=2]="BLOCK",t[t.REMOTE_CLOSE=3]="REMOTE_CLOSE",t[t.LOGOUT=4]="LOGOUT",t[t.BLOCK_NEW=5]="BLOCK_NEW",t[t.REDIRECT_NEW=6]="REDIRECT_NEW"})(ht||(ht={}));var pt,Ga=function(t,e){$.info("websocket send -> messageId: "+t.messageId);var n=t.getBufferData();e.send(n.buffer)},vn=function(t){function e(n,r){var i=t.call(this,"websocket",r)||this;return i._runtime=n,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 Ne(e,t),e.prototype.connect=function(n,r,i,o,s,c){return x(this,void 0,void 0,function(){var d=this;return B(this,function(l){return[2,new Promise(function(h){var a=[],u=0,f=!1,p=!1,m=function(){return x(d,void 0,void 0,function(){var _;return B(this,function(v){switch(v.label){case 0:return a.length===0||f?[2]:(f=!0,[4,this._connect(n,r,a.shift(),o,s,c)]);case 1:if((_=v.sent())===N.SUCCESS)this._checkAlive(),h(_);else if(_===He.REDIRECT)h(_);else{if(p&&a.length===0)return h(lu(_)),[2];f=!1,m()}return[2]}})})};s=cs(s),d._watcher.status(ne.CONNECTING),ku(i,o,d._runtime,function(_){var v=_.code,y=_.finished,C=_.host;p=y,v===200&&(a.push(C),u++,m()),y&&u===0&&($.error("No valid websocket server hosts!"),h(N.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s,c){return x(this,void 0,void 0,function(){var d,l,h,a,u,f=this;return B(this,function(p){switch(p.label){case 0:return d=o.replace("http","ws"),l=Uu(d,i,n,r,this._runtime,s,"",c),$.debug("conenct start -> "+l),this.sendConnectTime=Date.now(),h=this._runtime.createWebSocket(l),a=function(m){f._timer&&(clearTimeout(f._timer),f._timer=null),f._socket===h&&(f._socket=null,f._watcher.status(m))},[4,new Promise(function(m){h.onMessage(function(_){if(Object.prototype.toString.call(_)==="[object ArrayBuffer]"){var v=function(C,I){var P=new Uint8Array(C),b=new $l(P),R=b.readByte(),M=new ls(R),F=Lu(M);return F.read(b,P.length-1,I),F}(_,c);if(v instanceof Au&&f._pingResolve)return f._pingResolve(N.SUCCESS),void(f._pingResolve=void 0);if(v instanceof Ou)return $.debug("recv connect ack -> "+v.status),v.status!==He.ACCEPTED?($.warn("connect failed: "+v.status),void m(v.status)):($.info("connect success -> "+l),f.connectedTime=v.timestamp,f.userId=v.userId||"",f._idCount=v.messageId,void m(N.SUCCESS));if(v instanceof ra){var y=v.status;switch($.warn("recv disconnect signal -> status: "+y),y){case ht.BLOCK:f._watcher.status(ne.BLOCKED);break;case ht.OTHER_DEVICE_LOGIN:f._watcher.status(ne.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case ht.REDIRECT_NEW:case ht.REDIRECT:f._watcher.status(ne.REDIRECT);break;default:f._watcher.status(ne.DISCONNECT_BY_SERVER)}}else f._onReceiveSignal(v)}else $.error("Socket received invalid data:",_)}),h.onClose(function(_,v){for(var y in $.warn("websocket closed! code:",_,"reason:",v),a(ne.CONNECTION_CLOSED),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(N.RC_NET_CHANNEL_INVALID)}m(_)}),h.onError(function(_){var v;for(var y in $.error("websocket error!",(v=_)===null||v===void 0?void 0:v.stack),a(ne.WEBSOCKET_ERROR),f._messageIds){var C=f._messageIds[y];delete f._messageIds[y],C(N.RC_NET_CHANNEL_INVALID)}m(N.NETWORK_ERROR)}),h.onOpen(function(){return $.debug("websocket open =>",l)}),setTimeout(function(){m(N.TIMEOUT)},5e3)})];case 1:return(u=p.sent())===N.SUCCESS?this._socket=h:($.warn("connect result -> code: "+u+", url: "+l),h.close()),[2,u]}})})},e.prototype._checkAlive=function(){var n;return x(this,void 0,void 0,function(){var r,i=this;return B(this,function(o){switch(o.label){case 0:return this._socket?($.debug("send ping ->"),this.sendOnly(new mh),[4,new Promise(function(s){i._pingResolve=s,i._timer&&clearTimeout(i._timer),i._timer=setTimeout(function(){i._pingResolve=void 0,s(N.TIMEOUT)},15e3)})]):[2];case 1:return(r=o.sent())!==N.SUCCESS?(this._failedCount+=1,$.warn("ping failed count: "+this._failedCount+", code: "+r),this._failedCount>=this.ALLOW_FAILED_TIMES?(this._failedCount=0,$.warn("ping timeout, close current websocket to reconnect!"),(n=this._socket)===null||n===void 0||n.close(),this._watcher.status(ne.NETWORK_UNAVAILABLE)):this._checkAlive(),[2]):($.debug("recv pong <-"),this._failedCount=0,setTimeout(function(){return i._checkAlive()},15e3),[2])}})})},e.prototype._onReceiveSignal=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return r=n.messageId,n.header&&n.header.qos!==Tt.AT_MOST_ONCE&&(n instanceof Zn&&!n.syncMsg&&($.debug("send pubAck -> "+r),this.sendOnly(new Mu(r))),n instanceof Hn&&($.debug("send queryCon -> "+r),this.sendOnly(new Pu(r)))),r>0&&(n instanceof xo||n instanceof Hn)&&($.debug("recv ack -> messageId: "+r),(i=this._messageIds[r])&&(i(n),delete this._messageIds[r]),(o=this._syncMessageIds[r])&&(delete this._syncMessageIds[r],o(n))),n instanceof Zn?(s=n.syncMsg,(c=n.topic)===D[D.userSetData]?[2]:!s||Du(c)?(this._watcher.signal(n),[2]):[4,new Promise(function(a){l._syncMessageIds[r]=a})]):[3,2];case 1:d=h.sent(),delete this._syncMessageIds[r],this._watcher.signal(n,d),h.label=2;case 2:return[2]}})})},e.prototype.sendOnly=function(n){this._socket&&Ga(n,this._socket)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),x(this,void 0,void 0,function(){var s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return this._socket?(s=this._generateMessageId(),n.messageId=s,Ga(n,this._socket),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){l._messageIds[s]&&delete l._messageIds[s],a()},o)})]):[3,2];case 1:return(c=h.sent())?c instanceof Hn||c instanceof xo?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?($.warn("send failed -> message: "+s+", respPBName: "+r+", status: "+c.status),[2,{code:c.status,data:r&&c.data?d:null}]):[2,{code:N.SUCCESS,data:d}]):[2,{code:c}]:($.warn("send timeout -> message: "+s+", respPBName: "+r+", timeout: "+o),[2,{code:N.TIMEOUT}]);case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.close=function(){this._socket&&(this._socket.close(),this._socket=null,this._watcher.status(ne.DISCONNECTED))},e}(bu);(function(t){t.GET="GET",t.POST="POST"})(pt||(pt={}));var yn=function(t){function e(n,r){var i=t.call(this,"comet",r)||this;return i._runtime=n,i._messageIds={},i._syncMessageIds={},i._idCount=0,i._generateMessageId=function(){return++i._idCount},i._pid=encodeURIComponent(new Date().getTime()+Math.random()+""),i}return Ne(e,t),e.prototype.handleCometRes=function(n){var r=this;if(n.status!==200&&n.status!==202)return!1;var i=Ze(n.data)?JSON.parse(n.data):n.data;return i?!We(i)||(Oe(i,function(o){return x(r,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p,m,_,v=this;return B(this,function(y){switch(y.label){case 0:if((s=o.sessionid)&&(this._sessionid=s),c=function(C){var I=C.headerCode,P=new ls(I),b=Lu(P);for(var R in C)b[R]=C[R];return b}(o),d=c.messageId,l=c._header,h=c.status,c.identifier,a=l&&l.qos!==Tt.AT_MOST_ONCE,d&&c.getIdentifier&&((u=this._messageIds[d])&&u(c),this._syncMessageIds[d]&&this._syncMessageIds[d](c)),a&&(c instanceof Zn&&!c.syncMsg&&(f=new Mu(d),this.sendOnly(f)),c instanceof Hn&&(f=new Pu(d),this.sendOnly(f))),c instanceof ra){switch(h){case ht.OTHER_DEVICE_LOGIN:this._watcher.status(ne.KICKED_OFFLINE_BY_OTHER_CLIENT);break;case ht.BLOCK:this._watcher.status(ne.BLOCKED);break;case ht.REDIRECT_NEW:case ht.REDIRECT:this._watcher.status(ne.REDIRECT);break;default:this._watcher.status(ne.DISCONNECT_BY_SERVER)}return[2]}return c instanceof Zn?(p=c.syncMsg,m=c.topic,!p||Du(m)?(this._watcher.signal(c),[2,!1]):[4,new Promise(function(C){v._syncMessageIds[d]=C})]):[3,2];case 1:_=y.sent(),delete this._syncMessageIds[d],this._watcher.signal(c,_),y.label=2;case 2:return[2]}})})}),!0):($.error("received data is not a validJson",i),!1)},e.prototype._startPullSignal=function(n){return x(this,void 0,void 0,function(){var r,i,o,s;return B(this,function(c){switch(c.label){case 0:return r=new Date().getTime(),i=n+"://"+this._domain+"/pullmsg.js?sessionid="+this._sessionid+"&timestrap="+r+"&pid="+this._pid,[4,this._runtime.httpReq({url:i,body:{pid:this._pid},timeout:45e3})];case 1:return o=c.sent(),s=this.handleCometRes(o),this._isDisconnected||(s?this._startPullSignal(n):(this._isDisconnected=!0,this._watcher.status(ne.NETWORK_UNAVAILABLE))),[2]}})})},e.prototype.connect=function(n,r,i,o,s,c){return x(this,void 0,void 0,function(){var d,l,h,a,u=this;return B(this,function(f){return s=cs(s),this._protocol=o,this._isDisconnected=!1,this._watcher.status(ne.CONNECTING),d=[],l=0,h=!1,a=!1,[2,new Promise(function(p){var m=function(){return x(u,void 0,void 0,function(){var _;return B(this,function(v){switch(v.label){case 0:return d.length===0||h?[2]:(h=!0,[4,this._connect(n,r,d.shift(),o,s)]);case 1:if((_=v.sent())===N.SUCCESS)this._startPullSignal(o),p(_);else if(_===He.REDIRECT)p(_);else{if(a&&d.length===0)return p(lu(_)),[2];h=!1,m()}return[2]}})})};u._watcher.status(ne.CONNECTING),ku(i,o,u._runtime,function(_){var v=_.code,y=_.finished,C=_.host;a=y,v===200&&(d.push(C),l++,m()),y&&l===0&&($.error("No valid websocket server hosts!"),p(N.RC_SOCKET_NOT_CREATED))})})]})})},e.prototype._connect=function(n,r,i,o,s){return x(this,void 0,void 0,function(){var c,d,l,h;return B(this,function(a){switch(a.label){case 0:return c=function(u){return u.status!==200&&u.status!==202?($.error("handle comet res -> res: "+JSON.stringify(u||{})),!1):!!u.data&&(function(f){if(Ve(f))return!0;var p=!1;try{var m=JSON.parse(f);p=JSON.stringify(m)===f}catch{p=!1}return p}(u.data)?Ve(u.data)?u.data:JSON.parse(u.data):($.error("received data is not a validJson",u.data),!1))},d=Uu(o,i,n,r,this._runtime,s,this._pid),this.sendConnectTime=Date.now(),$.debug("conenct start -> "+d),[4,this._runtime.httpReq({url:d,body:{pid:this._pid},timeout:5e3})];case 1:return l=a.sent(),h=c(l),this._domain=i,h&&h.status===0?(this._sessionid=h.sessionid,this.userId=h.userId,this.connectedTime=h.timestamp):$.warn("connect result -> code: "+(h==null?void 0:h.status)+", url: "+d),[2,h==null?void 0:h.status]}})})},e.prototype.sendCometData=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._domain,s=i._sessionid,c=i._pid,d=n.messageId,l=n.topic,h=n.targetId,n.identifier,a=n.getHeaderFlag(),u=l?this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&topic="+l+"&targetid="+h+"&pid="+c:this._protocol+"://"+o+"/websocket?messageid="+d+"&header="+a+"&sessionid="+s+"&pid="+c,[4,this._runtime.httpReq({url:u,method:pt.POST,body:n.getCometData()})];case 1:return f=p.sent(),this.handleCometRes(f),[2]}})})},e.prototype.sendOnly=function(n){this.sendCometData(n)},e.prototype.send=function(n,r,i,o){return o===void 0&&(o=3e4),x(this,void 0,void 0,function(){var s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return s=this._generateMessageId(),n.messageId=s,this.sendCometData(n),[4,new Promise(function(a){l._messageIds[s]=a,setTimeout(function(){delete l._messageIds[s],a()},o)})];case 1:return(c=h.sent())?(d=r&&c.data?this.codec.decodeByPBName(c.data,r,i):c,c.status!==0?[2,{code:c.status,data:r&&c.data?d:null}]:[2,{code:N.SUCCESS,data:d}]):[2,{code:N.TIMEOUT}]}})})},e.prototype.close=function(){this._isDisconnected=!0,this._watcher.status(ne.DISCONNECTED)},e}(bu),_h=function(t,e,n){this.runtime=t,this._watcher=e,this._options=n,this.currentUserId="",this._appkey=this._options.appkey,this._apiVer=this._options.apiVersion,this.navi=this._createNavi()},Ji=function(t){return["navi",t].join("_")},vh=function(){function t(e,n){this._runtime=e,this._options=n,this._naviInfo=null,this._appkey=this._options.appkey,this._apiVersion=cs(this._options.apiVersion)}return t.prototype.getInfo=function(e,n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return r&&this._clear(e),(o=function(d,l,h){var a,u,f=Ji(d);try{var p=h.getItem(f);u=p?JSON.parse(p):[]}catch{u=[]}var m=Date.now();return u.length>0&&(u=u.filter(function(_){return m-_.timestamp<72e5})),u.length===0?h.removeItem(f):h.setItem(f,JSON.stringify(u)),((a=u.find(function(_){return _.token===l}))===null||a===void 0?void 0:a.naviInfo)||null}(this._appkey,e,this._runtime.localStorage))?(this._naviInfo=o,[2,o]):(s=this._options.navigators.slice(),n.length&&n.forEach(function(d){s.indexOf(d)<0&&s.unshift(d)}),[4,this._reqNavi(s,this._appkey,e,i)]);case 1:return(o=c.sent())?(this._naviInfo=o,this.setNaviInfo2Cache(e,o),[2,o]):[2,o]}})})},t.prototype.setNaviInfo2Cache=function(e,n){this._naviInfo=n,function(r,i,o,s){var c,d=Ji(r);try{var l=s.getItem(d);c=l?JSON.parse(l):[]}catch{c=[]}var h=Date.now();c.length>0&&(c=c.filter(function(a){return h-a.timestamp<72e5&&i!==a.token})),c.push({timestamp:h,naviInfo:o,token:i}),s.setItem(d,JSON.stringify(c))}(this._appkey,e,n,this._runtime.localStorage)},t.prototype.getInfoFromCache=function(e){return this._naviInfo},t.prototype._clear=function(e){(function(n,r,i){var o,s=Ji(n);try{var c=i.getItem(s);o=c?JSON.parse(c):[]}catch{o=[]}var d=Date.now();o.length>0&&(o=o.filter(function(l){return d-l.timestamp<72e5&&r!==l.token})),o.length===0?i.removeItem(s):i.setItem(s,JSON.stringify(o))})(this._appkey,e,this._runtime.localStorage)},t}(),vr=function(t,e,n){return[t,e,n].join("_")},yh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._users={}}return t.prototype._getMemData=function(e){return this._users[e]||(this._users[e]={inboxTime:0,outboxTime:0})},t.prototype.setInboxTime=function(e,n){var r=this._getMemData(n);if(!(r.inboxTime>e)){r.inboxTime=e;var i=vr("inbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getInboxTime=function(e){var n=this._getMemData(e);if(n.inboxTime===0){var r=vr("inbox",this._appkey,e);n.inboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.inboxTime},t.prototype.setOutboxTime=function(e,n){var r=this._getMemData(n);if(!(r.outboxTime>=e)){r.outboxTime=e;var i=vr("outbox",this._appkey,n);this._runtime.localStorage.setItem(i,e.toString())}},t.prototype.getOutboxTime=function(e){var n=this._getMemData(e);if(n.outboxTime===0){var r=vr("outbox",this._appkey,e);n.outboxTime=parseInt(this._runtime.localStorage.getItem(r))||0}return n.outboxTime},t}(),Wi={_caches:{},set:function(t,e){this._caches[t]=e},get:function(t){return this._caches[t]||0},clear:function(t){this._caches[t]=0}},Ch=function(){function t(e,n){this._kvCaches={},this._chatroomId=e,this._currentUserId=n}return t.prototype._add=function(e){var n=e.key;e.isDeleted=!1,this._kvCaches[n]=e},t.prototype._remove=function(e){var n=e.key,r=this._kvCaches[n];r&&(r.isDeleted=!0,this._kvCaches[n]=r)},t.prototype._setEntry=function(e,n){var r=e.key,i=e.type,o=e.isOverwrite,s=e.userId,c=this._getSetUserId(r),d=i===Qe.DELETE,l=c===s,h=!this._isExisted(r),a=d?this._remove:this._add;(n||o||l||h)&&a.call(this,e)},t.prototype.getValue=function(e){var n=this._kvCaches[e]||{};return n.isDeleted?null:n.value},t.prototype.getAllValue=function(){var e={};for(var n in this._kvCaches)this._kvCaches[n].isDeleted||(e[n]=this._kvCaches[n].value);return e},t.prototype._getSetUserId=function(e){return(this._kvCaches[e]||{}).userId},t.prototype._isExisted=function(e){var n=this._kvCaches[e]||{},r=n.value,i=n.isDeleted;return r&&!i},t.prototype.setEntries=function(e){var n=this,r=e.kvEntries,i=e.isFullUpdate;r=r||[],(i=i||!1)&&this.clear(),r.forEach(function(o){n._setEntry(o,i)}),$.debug("end setEntries")},t.prototype.clear=function(){this._kvCaches={}},t}(),Eh=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._storeCaches={},this._engine=e}return t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],n=e.chrmId,r=e.timestamp,(i=Wi.get(n))>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullChatroomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,this._isPulling=!1,s===N.SUCCESS?(Wi.set(n,c.syncTime||0),this._startPull()):this._startPull(),[2]}})})},t.prototype.reset=function(e){Wi.clear(e);var n=this._storeCaches[e];n&&n.clear()},t.prototype.pullEntry=function(e,n){this._pullQueue.push({chrmId:e,timestamp:n}),this._startPull()},t.prototype.setLocal=function(e,n,r){var i=this._storeCaches[e];Vn(i)||(i=new Ch(e,r)),i.setEntries(n),this._storeCaches[e]=i},t.prototype.getValue=function(e,n){var r=this._storeCaches[e];return r?r.getValue(n):null},t.prototype.getAll=function(e){var n=this._storeCaches[e],r={};return n&&(r=n.getAllValue()),r},t}(),Rh=function(){function t(e,n,r,i){this._runtime=e,this._appkey=n,this._userId=r,this._canJoinMulipleChrm=i,this._sessionKey="",this._joinedChrmsInfo={},this._sessionKey="sync-chrm-"+this._appkey+"-"+this._userId}return t.prototype.set=function(e,n){n===void 0&&(n=10),!this._canJoinMulipleChrm&&(this._joinedChrmsInfo={}),this._joinedChrmsInfo[e]=n,this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo))},t.prototype.get=function(){var e,n;try{n=this._runtime.sessionStorage.getItem(this._sessionKey),e=JSON.parse(n||"{}")}catch{$.error("parse rejoined chrm infos error -> "+n),e={}}return e},t.prototype.remove=function(e){delete this._joinedChrmsInfo[e],Vn(this._joinedChrmsInfo)?this._runtime.sessionStorage.setItem(this._sessionKey,JSON.stringify(this._joinedChrmsInfo)):this.clear()},t.prototype.clear=function(){this._joinedChrmsInfo={},this._runtime.sessionStorage.removeItem(this._sessionKey)},t}(),zi="converStatusChanged",Th=function(){function t(e,n,r){this._eventEmitter=new ir,this._pullQueue=[],this._isPulling=!1,this._storage=vi(e.runtime),this._appkey=n,this._currentUserId=r,this._engine=e,this._storagePullTimeKey="con-s-"+n+"-"+r}return t.prototype._set=function(e){var n=this;if(!me(e)&&Array.isArray(e)){var r=this._storage.get(this._storagePullTimeKey)||0,i=e.length;e.forEach(function(o,s){var c=o.updatedTime||0;r=c>r?c:r,o.conversationType=o.type,n._eventEmitter.emit(zi,{statusItem:o,isLastPull:s===i-1})}),this._storage.set(this._storagePullTimeKey,r)}},t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i;return B(this,function(o){switch(o.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 n=o.sent(),r=n.code,i=n.data,r===N.SUCCESS?(this._isPulling=!1,this._set(i),this._startPull()):this._startPull(),[2]}})})},t.prototype.pull=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.watch=function(e){this._eventEmitter.on(zi,function(n){e(n)})},t.prototype.unwatch=function(){this._eventEmitter.off(zi,function(e){})},t}(),Ht={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}},Br={};for(var Ya in Ht){var Sh=Ht[Ya].keyName;Br[Sh]=Ya}var On,Ih=function(){function t(e,n,r){this._appkey=n,this._currentUserId=r;var i="con-"+n+"-"+r;this.storage=new Na(e,i),this._localStore=new Na(e,"CONVER-"+n+"-"+r)}return t.prototype._getStoreKey=function(e,n,r){return r+"_"+e+"_"+n},t.prototype._getConOptionByKey=function(e){var n=(e=e||"").split("_");if(n.length>=2){var r=n.shift(),i=n.shift(),o=n.join("_");return{conversationType:Number(i),targetId:o,channelId:r}}return{conversationType:z.PRIVATE,targetId:"",channelId:""}},t.prototype.updateMentionedData=function(e){var n=this,r=e.conversationType,i=e.targetId,o=e.messageType,s=e.isMentioned,c=e.content,d=e.senderUserId,l=e.channelId,h=this._getStoreKey(r,i,l),a=this._localStore.get(h)||{},u=Br.mentionedInfo,f=Br.hasMentioned,p=a[u]||{},m=p.userIdList||[],_=c.mentionedInfo;if(_){if(s&&r===z.GROUP&&((_.userIdList||[]).forEach(function(y){y===n._currentUserId&&m.indexOf(d)<0&&m.push(d)}),_.type===ds.ALL&&m.indexOf(d)<0&&m.push(d)),o===$e.RECALL&&r===z.GROUP){var v=m.indexOf(d);v>=0&&m.splice(v,1)}_={userIdList:m,type:(_==null?void 0:_.type)||p.type},m.length!==0?(a[u]=_,a[f]=!0):(delete a[u],delete a[f]),Vn(a)?this._localStore.set(h,a):this._localStore.remove(h)}},t.prototype.set=function(e,n,r,i){var o=this._getStoreKey(e,n,i),s=this._localStore.get(o)||{};for(var c in r){var d=Br[c],l=r[c];if(!me(d)&&!me(l)&&c!=="hasMentioned"&&c!=="MentionedInfo"){if(l===Ht[d].defaultVal||c==="tags"&&!Vn(l))delete s[d];else if(c==="tags"){var h=l;for(var a in h)h[a].isTop||delete h[a].isTop;s[d]=l}else s[d]=l;s.c||(delete s.t,delete s.hm,delete s.m,delete s.mc)}}Vn(s)?this._localStore.set(o,s):this._localStore.remove(o)},t.prototype.get=function(e,n,r){r===void 0&&(r="");var i=this._getStoreKey(e,n,r),o=this._localStore.get(i)||{},s={};for(var c in Ht){var d=Ht[c],l=d.keyName,h=d.defaultVal;s[l]=o[c]||xr(h)}return s},t.prototype.getValue=function(e){var n=this._localStore.getValues()||{},r=[];for(var i in n){var o=this._getConOptionByKey(i),s={conversationType:o.conversationType,targetId:o.targetId,channelId:o.channelId},c=n[i];for(var d in c){var l=Ht[d],h=l.keyName,a=l.defaultVal;s[h]=c[d]||xr(a)}s=e?e(s):s,r.push(s)}return r},t.prototype.getValueForTag=function(){var e=this._localStore.getValues()||{},n={};for(var r in e){var i=this._getConOptionByKey(r),o=i.conversationType,s=i.targetId,c={},d=e[r];for(var l in d){var h=Ht[l],a=h.keyName,u=h.defaultVal;c[a]=d[l]||xr(u)}for(var f in c.tags){me(n[f])&&(n[f]=[]);var p=Object.assign({},c,{conversationType:o,targetId:s});delete p.tags,n[f].push(p)}}return n},t.prototype.adaptOldStore=function(){try{var e=this.storage.getValues();if(Object.keys(e).length===0)return;for(var n in e){var r="_"+n;this._localStore.set(r,e[n])}}catch(i){$.error("adaptOldStore error: "+i.message)}},t}(),bh=[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE,z.APP_PUBLIC_SERVICE],Ja="conversationChanged",Wa="conTagStatusChanged",Nh=function(){function t(e,n,r,i,o){var s=this;this._updatedConversations={},this._conTagStatusChanged=!1,this._eventEmitter=new ir,this._draftMap={},this._appkey=n,this._loginUserId=r,this._store=new Ih(e.runtime,n,r),this._statusManager=new Th(e,n,r),this._statusManager.watch(function(c){var d=c.statusItem,l=c.isLastPull;s.addStatus(d,l)}),this._eventEmitter.on(Ja,function(c){i(c)}),this._eventEmitter.on(Wa,function(){o()})}return t.prototype._calcUnreadCount=function(e,n){var r=e.content,i=e.messageType,o=e.sentTime,s=e.isCounted,c=e.messageDirection,d=e.senderUserId,l=c===st.SEND&&d===this._loginUserId,h=i===$e.RECALL,a=Ve(r),u=!1,f={},p=n.lastUnreadTime||0,m=n.unreadMessageCount||0;return p>o||l?{hasChanged:u,localConversation:n,updateItems:f}:(s&&(n.unreadMessageCount=m+1,n.lastUnreadTime=o,u=!0),h&&a&&p>=r.sentTime&&m&&(n.unreadMessageCount=m-1,u=!0),u&&(f.unreadMessageCount={val:n.unreadMessageCount,time:o}),{hasChanged:u,localConversation:n,updateItems:f})},t.prototype._calcMentionedInfo=function(e,n){var r=e.content,i=(e.messageDirection,e.isMentioned),o=e.sentTime;st.SEND;var s=Ve(r),c=!1,d={};return i&&s&&r.mentionedInfo&&(n.hasMentioned=!0,c=!0,d.hasMentioned={val:!0,time:o},d.mentionedInfo={val:r.mentionedInfo,time:o}),{hasChanged:c,localConversation:n,updateItems:d}},t.prototype._calcMentionedCount=function(e,n){var r=e.content,i=e.messageDirection,o=!1;if(e.isMentioned&&i===st.RECEIVE&&(r==null?void 0:r.mentionedInfo)){var s=r.mentionedInfo,c=s.type,d=s.userIdList;if(c===ds.ALL||(d||[]).includes(this._loginUserId)){o=!0;var l=n.unreadMentionedCount||0;n.unreadMentionedCount=l+1}}return{hasChanged:o,localConversation:n}},t.prototype._setUpdatedConversation=function(e){if(Ve(e)){var n=e.conversationType,r=e.targetId,i=e.channelId,o=n+"_"+r,s=this._store.get(n,r,i)||{};this._updatedConversations[o]=Object.assign(s,e)}},t.prototype._setConTagStatusChanged=function(e,n,r,i){var o=(this._store.get(e,n,i)||{}).tags||{};if(Object.keys(o).length===Object.keys(r).length){for(var s in o)if(!r[s]||o[s].isTop!==r[s].isTop)return void(this._conTagStatusChanged=!0)}else this._conTagStatusChanged=!0},t.prototype.addStatus=function(e,n){var r=e.conversationType,i=e.targetId,o=e.updatedTime,s=e.notificationStatus,c=e.isTop,d=e.tags,l=e.channelId,h={},a={};me(s)||(a.notificationStatus={time:o,val:s}),me(c)||(a.isTop={time:o,val:c}),me(d)||(a.tags={time:o,val:d},d==null||d.forEach(function(u){h[u.tagId]={isTop:u.isTop}})),this._setConTagStatusChanged(r,i,h,l),this._store.set(r,i,{notificationStatus:s,isTop:c,tags:h},l),this._setUpdatedConversation({conversationType:r,targetId:i,updatedItems:a,channelId:l}),n&&this._notifyConversationChanged()},t.prototype._notifyConversationChanged=function(){var e=[];for(var n in this._updatedConversations)e.push(this._updatedConversations[n]);e.length!==0&&(this._eventEmitter.emit(Ja,e),this._updatedConversations={},this._conTagStatusChanged&&(this._eventEmitter.emit(Wa),this._conTagStatusChanged=!1))},t.prototype.setConversationCacheByMessage=function(e,n){var r=this,i=e.conversationType,o=e.isPersited,s=e.targetId,c=e.channelId;if(bh.indexOf(i)>=0){var d=!1,l=this._store.get(i,s,c),h={};if([this._calcUnreadCount,this._calcMentionedInfo,this._calcMentionedCount].forEach(function(f){var p=f.call(r,e,l),m=p.hasChanged,_=p.localConversation,v=p.updateItems;d=d||m,h=Ce(Ce({},h),v),l=xr(_)}),d&&this._store.set(i,s,l,c),this._store.updateMentionedData(e),o){var a=this._store.get(i,s,c);a.updatedItems=Ce({latestMessage:{time:e.sentTime,val:e}},h),a.latestMessage=e;var u=Object.assign(a,{conversationType:i,targetId:s,channelId:c});this._setUpdatedConversation(u)}(d||o)&&this._notifyConversationChanged()}},t.prototype.get=function(e,n,r){return r===void 0&&(r=""),this._store.get(e,n,r)},t.prototype.getAllUnreadCount=function(e,n,r){var i=this._store.getValue(),o=0;return i.forEach(function(s){var c=s.unreadMessageCount,d=s.notificationStatus,l=s.conversationType;c=c||0,(r||d!==1)&&(n.length>0?n.includes(Number(l))&&(o+=Number(c)):o+=Number(c))}),o},t.prototype.getUnreadCountByTag=function(e,n){var r=this._store.getValueForTag()[e]||[],i=0;return r.forEach(function(o){var s=o.unreadMessageCount,c=o.notificationStatus;(n||c!==1)&&(s=s||0,i+=Number(s))}),i},t.prototype.getUnreadCount=function(e,n,r){return this._store.get(e,n,r).unreadMessageCount||0},t.prototype.clearUnreadCount=function(e,n,r,i){i===void 0&&(i=!0);var o=this._store.get(e,n,r),s=o.unreadMessageCount,c=o.hasMentioned,d={};if(s&&(o.unreadMessageCount=0,d.unreadMessageCount={val:0,time:Date.now()}),c&&(o.hasMentioned=!1,o.unreadMentionedCount=0,o.mentionedInfo=void 0,d.hasMentioned={val:!1,time:Date.now()},d.mentionedInfo={val:void 0,time:Date.now()}),this._store.set(e,n,o,r),i&&Object.keys(d).length!==0){var l=Object.assign(o,{conversationType:e,targetId:n,channelId:r,updatedItems:d});this._setUpdatedConversation(l),this._notifyConversationChanged()}},t.prototype.clearAllUnreadCount=function(){var e=this;this._store.getValue().forEach(function(n){n.unreadMessageCount&&(n.unreadMessageCount=0,e._store.set(n.conversationType,n.targetId,n,n.channelId))})},t.prototype.startPullConversationStatus=function(e){this._statusManager.pull(e)},t.prototype.setDraft=function(e,n,r,i){var o=e+"_"+n+"_"+i;this._draftMap[o]=r},t.prototype.getDraft=function(e,n,r){var i=e+"_"+n+"_"+r;return this._draftMap[i]},t.prototype.clearDraft=function(e,n,r){var i=e+"_"+n+"_"+r;delete this._draftMap[i]},t.prototype.addTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;o=Object.assign(o,r),this._store.set(e,n,{tags:o},i)},t.prototype.deleteTagStatus=function(e,n,r,i){i===void 0&&(i="");var o=this._store.get(e,n,i).tags;r.forEach(function(s){delete o[s]}),this._store.set(e,n,{tags:o},i)},t.prototype.getConversationListForTag=function(){return this._store.getValueForTag()},t.prototype.getBlockConversationList=function(){return this._store.getValue().filter(function(e){return e.notificationStatus===Zt.OPEN}).map(function(e){return{conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId}})},t.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}})},t.prototype.adaptOldStore=function(){this._store.adaptOldStore()},t.prototype.getUnreadMentionedCount=function(e,n,r){return e===void 0&&(e=""),this.get(n,r,e).unreadMentionedCount||0},t.prototype.getAllUnreadMentionedCount=function(){var e=this._store.getValue(),n=0;return e.forEach(function(r){var i=r.unreadMentionedCount;i=i||0,n+=Number(i)}),n},t}(),wh=function(){function t(e,n,r,i){this._pullQueue=[],this._isPulling=!1,this._storageTagKey="tag-"+n+"-"+r,this._storagePullTimeKey="us-s-"+n+"-"+r,this._storage=vi(e.runtime),this._engine=e,this._tagWatcherFunc=i}return t.prototype._updateTag=function(e){var n=e.tags,r={};n.forEach(function(i){r[i.tagId]={tagName:i.tagName,createdTime:i.createdTime}}),this._storage.set(this._storageTagKey,r),this._tagWatcherFunc()},t.prototype.addTag=function(e,n){var r=this._storage.get(this._storageTagKey)||{};e.forEach(function(i){var o,s=((o=r[i.tagId])===null||o===void 0?void 0:o.createdTime)||i.createdTime||0;r[i.tagId]={tagName:i.tagName,createdTime:s}}),this._storage.set(this._storageTagKey,r),this._storage.set(this._storagePullTimeKey,n)},t.prototype.deleteTag=function(e,n){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,n)},t.prototype.getTagsInfo=function(){return this._storage.get(this._storageTagKey)||{}},t.prototype.getTags=function(){var e=this._storage.get(this._storageTagKey)||{},n=[];for(var r in e)n.push({tagId:r,tagName:e[r].tagName,createdTime:e[r].createdTime,conversationCount:0});return n.sort(function(i,o){return(i.createdTime||0)-(o.createdTime||0)})},t.prototype.getTagById=function(e){var n=this._storage.get(this._storageTagKey)||{};return n[e]?{tagId:e,tagName:n[e].tagName,createdTime:n[e].createdTime,conversationCount:0}:null},t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],[4,this._engine.pullUserSettings(e)]);case 1:return n=l.sent(),r=n.code,i=n.data,r!==N.SUCCESS||me(i)?(this._isPulling=!1,this._startPull()):(s=(o=i).settings,c=o.version,d=s.Tag,me(d)||this._updateTag(d),this._storage.set(this._storagePullTimeKey,c),this._isPulling=!1,this._startPull()),[2]}})})},t.prototype.pullUserSettings=function(e){var n=this._storage.get(this._storagePullTimeKey)||0;(e>n||e===0)&&(this._pullQueue.push(n),this._startPull())},t.prototype.getVersion=function(){return this._storage.get(this._storagePullTimeKey)||0},t}(),Oh=function(t){function e(n,r){var i=t.call(this,n,r)||this;return i._miniConnectUrl="",i._connectType=r.connectionType,i}return Ne(e,t),e.prototype._formatJSONPUrl=function(n,r,i,o){return n+"/"+(this._runtime.isSupportSocket()&&this._connectType==="websocket"?"navi":"cometnavi")+".js?appId="+i+"&token="+encodeURIComponent(r)+"&callBack="+o+"&v="+this._apiVersion+"&r="+Date.now()},e.prototype.getInfo=function(n,r,i){var o;return x(this,void 0,void 0,function(){var s;return B(this,function(c){return this._runtime.useNavi||(s=void 0,s=this._runtime.isSupportSocket()&&this._connectType==="websocket"?Ol.join(","):Al.join(","),this._miniConnectUrl=((o=this._options.miniCMPProxy)===null||o===void 0?void 0:o.length)?this._options.miniCMPProxy.join(","):s||"",r=[]),[2,t.prototype.getInfo.call(this,n,r,i)]})})},e.prototype._reqNavi=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:o="getServerEndpoint",s=0,c=n.length,p.label=1;case 1:return s<c?(d=this._formatJSONPUrl(n[s],i,r,o),$.debug("req navi => "+d),[4,this._runtime.httpReq({url:d,timeout:1e4,dataType:"text"})]):[3,4];case 2:if((l=p.sent()).status!==200)return l.status===403?$.error("request navi error: "+N.RC_CONN_USER_OR_PASSWD_ERROR):l.status===401&&$.error("request navi error: "+N.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+'"')),f=JSON.parse(a),u=/^https/.test(d)?"https":"http",f.protocol=u,this._runtime.useNavi||(f.server="",f.backupServer=this._miniConnectUrl,f.logSwitch=0),[2,f]}catch(m){$.error("parse navi err =>",m)}p.label=3;case 3:return s+=1,[3,1];case 4:return this._runtime.useNavi?[2,null]:[2,f={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}(vh),Ah=function(){function t(e){this._pullQueue=[],this._isPulling=!1,this._pullTime=0,this._engine=e}return t.prototype._startPull=function(){return x(this,void 0,void 0,function(){var e,n,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._isPulling||this._pullQueue.length===0?[2]:(this._isPulling=!0,e=this._pullQueue.splice(0,1)[0],n=e.roomId,r=e.timestamp,(i=this._pullTime)>r?(this._isPulling=!1,this._startPull(),[2]):[4,this._engine.pullRTCRoomEntry(n,i)]);case 1:return o=d.sent(),s=o.code,c=o.data,s===N.SUCCESS?(this._isPulling=!1,this._pullTime=c.syncTime||0,this._startPull()):this._startPull(),[2]}})})},t.prototype.pullEntry=function(e,n){this._pullQueue.push({roomId:e,timestamp:n}),this._startPull()},t.prototype.reset=function(){this._pullTime=0,this._isPulling=!1},t}(),Qi=function(t,e){return["send_msg",t,e].join("_")},Mh=function(){function t(e,n){this._runtime=e,this._appkey=n,this._sendMessageMap={},this._userId=""}return t.prototype.init=function(e){this._userId=e;var n=Qi(this._appkey,e);this._sendMessageMap=this._getLocalInfo(n)},t.prototype._getLocalInfo=function(e){var n=this._runtime.localStorage.getItem(e);try{return n?JSON.parse(n):{}}catch{return{}}},t.prototype.setMessage=function(e,n){this._sendMessageMap[e]=n;var r=Qi(this._appkey,this._userId),i=this._getLocalInfo(r);i[e]=n,this._runtime.localStorage.setItem(r,JSON.stringify(i))},t.prototype.getSendMessageMap=function(){return this._sendMessageMap},t.prototype.removeByUID=function(e){delete this._sendMessageMap[e]},t.prototype.removeByTimestamp=function(e){var n=Qi(this._appkey,this._userId),r=this._getLocalInfo(n);Object.keys(r).forEach(function(i){r[i]<e&&delete r[i]}),this._runtime.localStorage.setItem(n,JSON.stringify(r))},t}(),xu=function(t){var e="RCDeviceId",n=vi(t),r="",i=n.get(e);return i?r=i:(r=uu(),n.set(e,r)),r};(On={})[z.PRIVATE]=D.qryPMsg,On[z.GROUP]=D.qryGMsg,On[z.CHATROOM]=D.qryCHMsg,On[z.CUSTOMER_SERVICE]=D.qryCMsg,On[z.SYSTEM]=D.qrySMsg;var Ph=[D[D.recallMsg],D[D.ppMsgS],D[D.pgMsgS],D[D.ppMsgP],D[D.pgMsgP],D[D.chatMsg],D[D.pcMsgP],D[D.prMsgS]],Xi=function(t,e,n,r,i,o){return{conversationType:t,targetId:e,senderUserId:o,messageDirection:st.SEND,isCounted:!!n.isCounted,isMentioned:!!n.isMentioned,content:n.content,messageType:n.messageType,isOffLineMessage:!1,isPersited:!!n.isPersited,messageUId:r,sentTime:i,receivedTime:0,disableNotification:!!n.disableNotification,isStatusMessage:!!n.isStatusMessage,canIncludeExpansion:!!n.canIncludeExpansion,expansion:n.canIncludeExpansion?n.expansion:null,receivedStatus:Gn.UNREAD,pushConfig:n.pushConfig,channelId:n.channelId}},Lh=function(t){function e(n,r,i){var o=t.call(this,n,r,i)||this;return o._customMessageType={},o._reconnectTimer=-1,o._pullOfflineFinished=!1,o._connectedTime=0,o._localConnectedTime=0,o._pullingMsg=!1,o._pullQueue=[],o._chrmsQueue={},o._latestSyncTimestamp=0,o._intervalTimer=-1,o._letterbox=new yh(n,i.appkey),o._sendMessageStore=new Mh(n,i.appkey),o._chrmEntryHandler=new Eh(o),o}return Ne(e,t),e.prototype._createNavi=function(){return new Oh(this.runtime,this._options)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.connect=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l=this;return B(this,function(h){switch(h.label){case 0:return i=[],this._naviInfo=r,r.server?i.push(r.server):$.warn("navi.server is invalid"),(o=r.backupServer)&&o.split(",").forEach(function(a){i.indexOf(a)<0&&i.push(a)}),i.length===0?($.error("navi invaild.",i),[2,N.UNKNOWN]):(s=this.runtime.createDataChannel({status:function(a){l._connectionStatusHandler(a,n,i,r.protocol)},signal:this._signalHandler.bind(this)},this._options.connectionType),c=jt.V3,r.openAnti===1&&(c=jt.V4),[4,s.connect(this._appkey,n,i,r.protocol,this._apiVer,c)]);case 1:return(d=h.sent())===N.SUCCESS?(this._channel=s,this.currentUserId=s.userId,this._connectedTime=s.connectedTime,this._localConnectedTime=Math.floor((Date.now()+s.sendConnectTime)/2),this._watcher.status(ne.CONNECTED),this._pullOfflineFinished=!1,this._conversationManager=new Nh(this,this._appkey,this.currentUserId,this._watcher.conversation,this._watcher.conversationTag),this._conversationManager.startPullConversationStatus(0),this._userSettingManager=new wh(this,this._appkey,this.currentUserId,this._watcher.tag),this._userSettingManager.pullUserSettings(0),this._sendMessageStore.init(this.currentUserId),this._conversationManager.adaptOldStore(),this._rtcKVManager=new Ah(this),this._joinedChrmManager=new Rh(this.runtime,this._appkey,this.currentUserId,r.joinMChrm),this._startSyncInterval()):s.close(),[2,d]}})})},e.prototype._connectionStatusHandler=function(n,r,i,o){if($.warn("connection status changed:",n),n!==ne.CONNECTING)if(n!==ne.CONNECTED){if(this._channel&&n!==ne.DISCONNECTED)return n===ne.BLOCKED||n===ne.KICKED_OFFLINE_BY_OTHER_CLIENT||n===ne.DISCONNECT_BY_SERVER?(this.disconnect(),void this._watcher.status(n)):void(n!==ne.REDIRECT?(this._watcher.status(n),this._try2Reconnect(r,i,o)):this._watcher.status(n));this._watcher.status(n)}else this._watcher.status(n);else this._watcher.status(n)},e.prototype._try2Reconnect=function(n,r,i){return x(this,void 0,void 0,function(){var o,s=this;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=jt.V3,this._naviInfo.openAnti===1&&(o=jt.V4),[4,this._channel.connect(this._appkey,n,r,i,this._apiVer,o)]):[2];case 1:return c.sent()===N.SUCCESS?(this._pullOfflineFinished=!1,this._startSyncInterval(),this._watcher.status(ne.CONNECTED),this._rejoinChrm(),$.__insertLogIntoDatabase(),[2]):(this._watcher.status(ne.WEBSOCKET_UNAVAILABLE),this._reconnectTimer=setTimeout(function(){s._reconnectTimer=-1,s._try2Reconnect(n,r,i)},5e3),[2])}})})},e.prototype._signalHandler=function(n,r){var i=n.syncMsg,o=n.topic;if(i)this._receiveSyncMsg(n,r);else{var s=D[o];if(s)switch(s){case D.s_ntf:$.info("recv s_ntf -> signal.messageId: "+n.messageId),this._pullMsg(n);break;case D.s_msg:this._receiveMsg(n);break;case D.s_cmd:this._receiveStateNotify(n);break;case D.s_us:this._receiveSettingNotify(n);break;case D.rtc_ntf:this._receiveRtcKv(n)}else $.error("unknown topic:",o)}},e.prototype._receiveStateNotify=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Jr),o=i.time,s=i.type,c=i.chrmId;switch(s){case 2:this._chrmEntryHandler.pullEntry(c,o);break;case 3:this._conversationManager.startPullConversationStatus(o);break;case 4:this._chrmEntryHandler.reset(c),this._watcher.chatroom({chatroomDestroyed:n.targetId})}},e.prototype._receiveSettingNotify=function(n){var r,i=((r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,Ii)).version;this._userSettingManager.pullUserSettings(i)},e.prototype._receiveRtcKv=function(n){var r,i=(r=this._channel)===null||r===void 0?void 0:r.codec.decodeByPBName(n.data,zs),o=i.time,s=i.type,c=i.roomId;switch(s){case 1:this._rtcKVManager.pullEntry(c,o)}},e.prototype._receiveMessageExpansion=function(n){var r=n.content,i=r.put,o=r.del,s=r.mid;i&&this._watcher.expansion({updatedExpansion:{messageUId:s,expansion:i}}),o&&this._watcher.expansion({deletedExpansion:{messageUId:s,deletedKeys:o}})},e.prototype._receiveSyncMsg=function(n,r){var i;if(Ph.includes(n.topic)){var o=(i=this._channel)===null||i===void 0?void 0:i.codec.decodeByPBName(n.data,Jn,{currentUserId:this.currentUserId,signal:n});o=this._handleMsgProperties(o),r&&(o.sentTime=r.timestamp,o.messageUId=r.messageUId),this._pullingMsg?this._pullQueue.push((r==null?void 0:r.timestamp)||o.sentTime):(r&&this._sendMessageStore.setMessage(r.messageUId,r.timestamp),o.messageType!==$e.EXPANSION_NOTIFY?(o.messageType===$e.SYNC_READ_STATUS&&this._conversationManager.clearUnreadCount(o.conversationType,o.targetId,o.channelId),this._conversationManager.setConversationCacheByMessage(o,!0),this._watcher.batchMessage([o])):this._receiveMessageExpansion(o))}},e.prototype._pullMsg=function(n){if(this._channel){var r=this._channel.codec.decodeByPBName(n.data,Jr),i=r.type,o=r.chrmId,s=r.time;if($.info("s_ntf -> type: "+i+", chrmId: "+o+", time: "+s),i===2){var c=this._chrmsQueue[o];if(!c)return;c.queue.push(s),this._pullChrmMsg(o)}else this._pullQueue.push(s),this._syncMsg()}},e.prototype._startSyncInterval=function(){var n=this;this._stopSyncInterval(),this._intervalTimer=setInterval(function(){Date.now()-n._latestSyncTimestamp>=18e4&&n._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 n,r,i,o,s,c,d,l,h,a,u,f,p,m,_=this;return B(this,function(v){switch(v.label){case 0:return this._pullingMsg?[2]:this._channel?(this._pullingMsg=!0,n=this._letterbox.getOutboxTime(this.currentUserId),r=this._letterbox.getInboxTime(this.currentUserId),$.info("pullMsg -> sendboxTime: "+n+", inboxTime: "+r),i=this._channel.codec.encodeSyncMsg({sendboxTime:n,inboxTime:r}),o=new Q(D[D.pullMsg],i,this.currentUserId),[4,this._channel.send(o,Wn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})]):(this._pullingMsg=!1,[2]);case 1:return s=v.sent(),c=s.code,d=s.data,this._latestSyncTimestamp=Date.now(),c===N.SUCCESS&&d?(l=d.list,h=d.finished,a=d.syncTime,$.info("pullMsg success -> syncTime: "+a+", finished: "+h),u=0,f=[],l.forEach(function(y){if(y.messageDirection===st.SEND&&(u=Math.max(y.sentTime,u),_._sendMessageStore.getSendMessageMap()[y.messageUId]))return void _._sendMessageStore.removeByUID(y.messageUId);if(y.messageType!==$e.EXPANSION_NOTIFY){if(y.messageType===$e.SYNC_READ_STATUS){if(y.senderUserId!==_.currentUserId)return;_._conversationManager.clearUnreadCount(y.conversationType,y.targetId,y.channelId)}var C=_._handleMsgProperties(y);_._conversationManager.setConversationCacheByMessage(C,!0),f.push(C)}else _._receiveMessageExpansion(y)}),this._watcher.batchMessage(f),this._letterbox.setInboxTime(a,this.currentUserId),this._letterbox.setOutboxTime(u,this.currentUserId),this._sendMessageStore.removeByTimestamp(u),this._pullingMsg=!1,p=this._pullQueue.filter(function(y){return y>a}),this._pullQueue.length=0,(m=this._pullQueue).push.apply(m,p),h&&!this._pullOfflineFinished&&(this._pullOfflineFinished=!0,this._watcher.pullFinished()),(!h||p.length>0)&&this._syncMsg(),[2]):($.warn("pullMsg failed -> code:",c,", data: ",d),this._pullingMsg=!1,[2])}})})},e.prototype._receiveMsg=function(n){if(this._channel&&!this._pullingMsg)if(this._pullQueue.length>0)this._syncMsg();else{var r=this._channel.codec.decodeByPBName(n.data,Ci,{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!==$e.EXPANSION_NOTIFY?r.messageType===$e.SYNC_READ_STATUS&&r.senderUserId!==this.currentUserId||(this._conversationManager.setConversationCacheByMessage(r,!0),this._watcher.batchMessage([r])):this._receiveMessageExpansion(r)}},e.prototype._handleMsgProperties=function(n,r){r===void 0&&(r=!1);var i,o=n.messageType,s=n.isCounted,c=n.isPersited,d=n.isStatusMessage,l=o in ba,h=o in this._customMessageType;if(i=l?ba[o]:h?this._customMessageType[o]:{isCounted:!Oa(s)&&s,isPersited:!Oa(c)&&c},Object.assign(n,{isCounted:i.isCounted,isPersited:i.isPersited,isStatusMessage:Ml.includes(o)}),r&&(n.isStatusMessage=d),!r){var a=n.content.user;if(a){var u=a.portrait,f=a.portraitUri,p=u||f;p&&(a.portrait=a.portraitUri=p)}}return n},e.prototype.getHistoryMessage=function(n,r,i,o,s,c){return c===void 0&&(c=""),x(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_;return B(this,function(v){switch(v.label){case 0:return l=(d=this).currentUserId,h=d._channel,a=hh[n]||Su,u=o===1&&i===0,h?(f=h.codec.encodeGetHistoryMsg(r,{timestamp:i,count:u?2:o,order:s,channelId:c}),[4,h.send(new Q(a,f,l),zn,{currentUserId:l,connectedTime:h.connectedTime,conversation:{targetId:r}})]):[3,2];case 1:return p=v.sent(),(m=p.code)!==N.SUCCESS?[2,{code:m}]:(_=p.data,u&&_.list.length===2&&(_.hasMore=!0,s===0?_.list.shift():_.list.pop()),[2,{code:m,data:{list:_.list,hasMore:_.hasMore}}]);case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.reportSDKInfo=function(n){var r=this.currentUserId,i=this._channel;if(i){$.debug("reportSDKInfo ->",n);var o=i.codec.encodeReportSDKInfo(JSON.stringify(n)),s=new Q(D[D.reportsdk],o,r);i.send(s).then(function(c){var d=c.code;d!==N.SUCCESS&&$.warn("reportSDKInfo failed -> code: "+d)})}},e.prototype.deleteRemoteMessage=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeDeleteMessages(n,r,i,o),h=new Q(Xl,l,c),[4,d.send(h)]):[3,2];case 1:return a=f.sent(),u=a.code,N.SUCCESS,[2,u];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype.deleteRemoteMessageByTimestamp=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return c=(s=this).currentUserId,(d=s._channel)?(l=d.codec.encodeClearMessages(r,i,o),h=fh[n],a=new Q(h,l,c),[4,d.send(a)]):[3,2];case 1:return u=p.sent(),f=u.code,N.SUCCESS,[2,f];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversationList=function(n,r,i,o,s){return n===void 0&&(n=300),x(this,void 0,void 0,function(){var c,d,l,h,a,u,f,p,m=this;return B(this,function(_){switch(_.label){case 0:return d=(c=this).currentUserId,l=c._channel,r=r||z.PRIVATE,l?(h=l.codec.encodeOldConversationList({count:n,type:r,startTime:i,order:o}),a=new Q(ja,h,d),[4,l.send(a,Qn,{currentUserId:d,connectedTime:l.connectedTime,afterDecode:function(v){var y=v.conversationType,C=v.targetId,I=v.channelId,P=m._conversationManager.get(y,C,I);return Object.assign(v,P),v}})]):[3,2];case 1:return u=_.sent(),f=u.code,p=u.data,f!==N.SUCCESS?[2,{code:f}]:[2,{code:f,data:p}];case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.removeConversation=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(o=this._channel)?(s=o.codec.encodeRemoveOldConversationList({conversationType:n,channelId:i,targetId:r}),c=new Q(sh,s,r),[4,o.send(c)]):[3,2];case 1:return d=h.sent(),$.info("RemoveConversation =>",d),l=d.code,N.SUCCESS,[2,l];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype.getConversation=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(o=this._conversationManager.get(n,r,i))?[4,this.getHistoryMessage(n,r,0,1,0)]:[2,{code:N.CONVER_GET_ERROR}];case 1:return s=a.sent(),c=s.code,d=s.data,c!==N.SUCCESS?[2,{code:N.CONVER_GET_ERROR}]:(l=(d==null?void 0:d.list[0])||null,h={conversationType:n,targetId:r,channelId:i,unreadMessageCount:o.unreadMessageCount||0,latestMessage:l,notificationStatus:o.notificationStatus||Zt.CLOSE,isTop:o.isTop||!1,lastUnreadTime:o.lastUnreadTime||0,unreadMentionedCount:o.unreadMentionedCount||0},[2,{code:N.SUCCESS,data:h}])}})})},e.prototype.getAllConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getAllUnreadCount(n,r,i);return Promise.resolve({code:N.SUCCESS,data:o})},e.prototype.getConversationUnreadCount=function(n,r,i){var o=this._conversationManager.getUnreadCount(n,r,i);return Promise.resolve({code:N.SUCCESS,data:o})},e.prototype.clearConversationUnreadCount=function(n,r,i){return this._conversationManager.clearUnreadCount(n,r,i,!1),Promise.resolve(N.SUCCESS)},e.prototype.clearAllUnreadCount=function(){return this._conversationManager.clearAllUnreadCount(),Promise.resolve(N.SUCCESS)},e.prototype.getFirstUnreadMessage=function(n,r){throw new Error("Method not implemented.")},e.prototype.saveConversationMessageDraft=function(n,r,i,o){return this._conversationManager.setDraft(n,r,i,o),Promise.resolve(N.SUCCESS)},e.prototype.getConversationMessageDraft=function(n,r,i){var o=this._conversationManager.getDraft(n,r,i);return Promise.resolve({code:N.SUCCESS,data:o})},e.prototype.clearConversationMessageDraft=function(n,r,i){return this._conversationManager.clearDraft(n,r,i),Promise.resolve(N.SUCCESS)},e.prototype.pullConversationStatus=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeGetConversationStatus(n),c=new Q(D[D.pullSeAtts],s,o),[4,i.send(c,bi)]):[3,2];case 1:return d=a.sent(),l=d.code,h=d.data,l!==N.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}];case 2:return[2,{code:N.RC_NET_CHANNEL_INVALID}]}})})},e.prototype.batchSetConversationStatus=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return i=(r=this).currentUserId,(o=r._channel)?(s=o.codec.encodeSetConversationStatus(n),c=new Q(ah,s,i),[4,o.send(c,qs)]):[3,2];case 1:return d=f.sent(),l=d.code,h=d.data,l===N.SUCCESS?(a=h,n.forEach(function(p){u._conversationManager.addStatus(Ce(Ce({},p),{updatedTime:a.version}),!0)}),[2,l]):[2,l];case 2:return[2,N.RC_NET_CHANNEL_INVALID]}})})},e.prototype._joinChrm=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(o=this._channel)?(s=o.codec.encodeJoinOrQuitChatRoom(),c=new Q(i?eh:Zl,s,n),[4,o.send(c,Ss)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return d=u.sent(),l=d.code,h=d.data,l===N.SUCCESS&&(a=h.joinTime,this._chrmsQueue[n]||(this._chrmsQueue[n]={pulling:!1,queue:[],timestamp:0}),this._pullChrmMsg(n,r,a),this._naviInfo.kvStorage&&this._chrmEntryHandler.pullEntry(n,0),this._joinedChrmManager.set(n,r)),[2,l]}})})},e.prototype._rejoinChrm=function(){return x(this,void 0,void 0,function(){var n,r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:for(i in n=this._joinedChrmManager.get(),r=[],n)r.push(i);o=0,d.label=1;case 1:return o<r.length?(s=r[o],[4,this._joinChrm(s,n[s]||10,!0)]):[3,4];case 2:(c=d.sent())===N.SUCCESS?this._watcher.chatroom({rejoinedRoom:{chatroomId:s,count:n[s]}}):this._watcher.chatroom({rejoinedRoom:{chatroomId:s,errorCode:c}}),d.label=3;case 3:return o++,[3,1];case 4:return[2]}})})},e.prototype._pullChrmMsg=function(n,r,i){return r===void 0&&(r=10),i===void 0&&(i=0),x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p,m,_;return B(this,function(v){switch(v.label){case 0:return this._channel?(o=this._chrmsQueue[n],s=o.pulling,c=o.timestamp,s?[2]:(o.pulling=!0,d=this._channel.codec.encodeChrmSyncMsg(c,r),l=new Q(D[D.chrmPull],d,n),[4,this._channel.send(l,Wn,{connectedTime:this._channel.connectedTime,currentUserId:this.currentUserId})])):[2];case 1:return h=v.sent(),a=h.code,u=h.data,o.pulling=!1,a===N.SUCCESS&&u?(f=u.list,p=u.syncTime,m=u.finished,o.timestamp=i?Math.max(p,i):p,o.queue=o.queue.filter(function(y){return y>p}),_=[],f.forEach(function(y){y.sentTime<c||_.push(y)}),this._watcher.batchMessage(_),(!m||o.queue.length>0)&&this._pullChrmMsg(n),[2]):($.warn("pull chatroom msg failed, code:",a,", data:",u),[2])}})})},e.prototype.joinChatroom=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(n,r,!1)]})})},e.prototype.joinExistChatroom=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._joinChrm(n,r,!0)]})})},e.prototype.quitChatroom=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return(r=this._channel)?(i=r.codec.encodeJoinOrQuitChatRoom(),o=new Q(th,i,n),[4,r.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return s=d.sent(),(c=s.code)===N.SUCCESS&&(delete this._chrmsQueue[n],this._chrmEntryHandler.reset(n),this._joinedChrmManager.remove(n)),[2,c]}})})},e.prototype.getChatroomInfo=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(o=this._channel)?(s=o.codec.encodeGetChatRoomInfo(r,i),c=new Q(D[D.queryChrmI],s,n),[4,o.send(c,Ei)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l!==N.SUCCESS?[2,{code:l}]:[2,{code:l,data:h}]}})})},e.prototype.getChatroomHistoryMessages=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return(s=this._channel)?(c=s.codec.encodeGetHistoryMsg(n,{timestamp:r,count:i,order:o}),d=new Q(Iu,c,n),[4,s.send(d,zn,{conversation:{targetId:n}})]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,h!==N.SUCCESS?[2,{code:h}]:[2,{code:h,data:{list:a.list,hasMore:a.hasMore}}]}})})},e.prototype._modifyChatroomKV=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKV(n,r,s),d=r.type===Qe.UPDATE?nh:rh,l=new Q(d,c,n),[4,o.send(l)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return h=u.sent(),(a=h.code)===N.SUCCESS?(this._chrmEntryHandler.setLocal(n,{kvEntries:[r],syncTime:new Date().getTime()},s),[2,a]):[2,a]}})})},e.prototype._modifyChatroomKVS=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodeModifyChatRoomKVS(n,r,s),d=r.type===Qe.UPDATE?ih:oh,l=new Q(d,c,n),[4,o.send(l,Hs)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return h=_.sent(),a=h.code,[N.SUCCESS,N.CHATROOM_KV_STORE_NOT_ALL_SUCCESS].indexOf(a)!==-1&&(f=[],delete(p=Object.assign({},r)).entries,r.entries.forEach(function(v){f.push(Object.assign({},v,p))}),a===N.CHATROOM_KV_STORE_NOT_ALL_SUCCESS&&(m=h.data,$.warn("\u8BBE\u7F6E\u5931\u8D25\u7684\u5C5E\u6027\uFF1A",m.errorKeys),u=m.errorKeys,m&&Array.isArray(m.errorKeys)&&m.errorKeys.forEach(function(v){var y=f.findIndex(function(C){return v.key===C.key});y!==-1&&f.splice(y,1)})),$.warn("\u8BBE\u7F6E\u6210\u529F\u7684\u5C5E\u6027\uFF1A",f),this._chrmEntryHandler.setLocal(n,{kvEntries:f,syncTime:new Date().getTime()},s)),[2,{code:a,data:u}]}})})},e.prototype.setChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.setChatroomEntries=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.UPDATE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceSetChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.UPDATE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.removeChatroomEntries=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.DELETE,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKVS(n,r)]})})},e.prototype.forceRemoveChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return r.type=Qe.DELETE,r.isOverwrite=!0,r.userId=r.userId||this.currentUserId,[2,this._modifyChatroomKV(n,r)]})})},e.prototype.getChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return(i=this._chrmEntryHandler.getValue(n,r))?[2,Promise.resolve({code:N.SUCCESS,data:i})]:[3,1];case 1:return(o=this._channel)?(s=o.codec.encodePullChatRoomKV(0),c=new Q(D[D.pullKV],s,n),[4,o.send(c,rn)]):[2,Promise.reject({code:N.RC_NET_CHANNEL_INVALID})];case 2:return d=a.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&(h=l.kvEntries.find(function(u){return u.key===r}))!==void 0?[2,Promise.resolve({code:N.SUCCESS,data:h==null?void 0:h.value})]:[2,Promise.resolve({code:N.CHATROOM_KEY_NOT_EXIST})]}})})},e.prototype.getAllChatroomEntry=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return(r=this._chrmEntryHandler.getAll(n))&&Object.keys(r).length?[2,Promise.resolve({code:N.SUCCESS,data:r})]:[3,1];case 1:return(i=this._channel)?(o={},s=i.codec.encodePullChatRoomKV(0),c=new Q(D[D.pullKV],s,n),[4,i.send(c,rn)]):[2,Promise.reject({code:N.RC_NET_CHANNEL_INVALID})];case 2:return d=h.sent(),(l=d.data||{})&&l.kvEntries&&l.kvEntries.length&&l.kvEntries.forEach(function(a){a.key&&(o[a.key]=a.value||"")}),[2,Promise.resolve({code:N.SUCCESS,data:o})]}})})},e.prototype.pullChatroomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?(c=o.codec.encodePullChatRoomKV(r),d=new Q(D[D.pullKV],c,n),[4,o.send(d,rn)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=p.sent(),h=l.code,a=l.data,h===N.SUCCESS?($.info("Pull success ChrmKV, "+JSON.stringify(l)),this._chrmEntryHandler.setLocal(n,a,s),$.info("Save into cache success!"),u=a.kvEntries,f=[],u.length>0&&(u.forEach(function(m){var _=m.key,v=m.value,y=m.type,C=m.timestamp;f.push({key:_,value:v,type:y,timestamp:C,chatroomId:n})}),this._watcher.chatroom({updatedEntries:f})),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.sendMessage=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(i=function(_,v){return _.messageType==="RC:SRSMsg"&&Object.assign(_,{directionalUserIdList:[v]}),_}(i,this.currentUserId),i=this._handleMsgProperties(i,!0),o=!![z.PRIVATE,z.GROUP].includes(n)&&i.isStatusMessage,s=o?function(_){var v;return(v={},v[z.PRIVATE]=D.ppMsgS,v[z.GROUP]=D.pgMsgS,v)[_]}(n):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)[_]}(n)||D.ppMsgP,o&&(i.isPersited=!1,i.isCounted=!1),c=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},i),(d=new wn(D[s],c,r)).setHeaderQos(Tt.AT_LEAST_ONCE),o?(this._channel.sendOnly(d),[2,{code:N.SUCCESS,data:Xi(n,r,Ce({},i),"",0,this.currentUserId)}]):(l=Date.now()-this._localConnectedTime+this._connectedTime,h=Xi(n,r,Ce({},i),"",l,this.currentUserId),[4,this._channel.send(d)])):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,u!==N.SUCCESS?[2,{code:u,data:h}]:(p=f,this._sendMessageStore.setMessage(p.messageUId,p.timestamp),h.sentTime=p.timestamp,h.messageUId=p.messageUId,this._conversationManager.setConversationCacheByMessage(h,!0),[2,{code:N.SUCCESS,data:h}])}})})},e.prototype.recallMsg=function(n,r,i,o,s){var c;return x(this,void 0,void 0,function(){var d,l,h,a,u,f,p,m,_,v;return B(this,function(y){switch(y.label){case 0:return this._channel?(d=s.user,l={content:{conversationType:n,targetId:r,messageUId:i,sentTime:o,user:d},messageType:"RC:RcCmd",disableNotification:s==null?void 0:s.disableNotification,pushConfig:s==null?void 0:s.pushConfig,pushContent:((c=s.pushConfig)===null||c===void 0?void 0:c.pushContent)||s.pushContent||"",channelId:s.channelId},h=D[D.recallMsg],a=this._channel.codec.encodeUpMsg({conversationType:n,targetId:r},l),(u=new wn(h,a,this.currentUserId)).setHeaderQos(Tt.AT_LEAST_ONCE),[4,this._channel.send(u)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return f=y.sent(),p=f.code,m=f.data,p!==N.SUCCESS?[2,{code:p}]:(_=m,this._sendMessageStore.setMessage(_.messageUId,_.timestamp),v=Xi(n,r,Ce(Ce({},l),{isPersited:!0}),_.messageUId,_.timestamp,this.currentUserId),this._conversationManager.setConversationCacheByMessage(v,!0),[2,{code:N.SUCCESS,data:v}])}})})},e.prototype.sendReadReceiptMessage=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeReadReceipt(r,i),s=new Q(D[D.rrMsg],o,n),[4,this._channel.send(s)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.getMessageReader=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeMessageReader(r,i),s=new Q(D[D.rrList],o,n),[4,this._channel.send(s,Ni)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return[2,c.sent()]}})})},e.prototype.pullUserSettings=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodePullUserSetting(n),i=new Q(D[D.pullUS],r,this.currentUserId),[2,this._channel.send(i,Si)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getFileToken=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return this._channel?(s=o&&o!=="uploads"?r||"":Bl(n,r),c=this._channel.codec.encodeGetFileToken(n,s,i||"",o||""),d=new Q(D[D.qnTkn],c,this.currentUserId),[4,this._channel.send(d,ks)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=u.sent(),h=l.code,a=l.data,a=Object.assign(a,{fileName:s}),h===N.SUCCESS?[2,{code:h,data:a}]:[2,{code:h}]}})})},e.prototype.getFileUrl=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(s="",c="",d="",r===Je.QINIU?(c=Us,d=xs):(c=Ds,d=Bs),s=r===Je.QINIU?D[D.qnUrl]:r===Je.AWS?D[D.s3Url]:r===Je.STC?D[D.stcUrl]:D[D.aliUrl],l=this._channel.codec.encodeGetFileUrl(c,n,i,o),h=new Q(s,l,this.currentUserId),[4,this._channel.send(h,d)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return a=m.sent(),u=a.code,f=a.data,p=f,u===N.SUCCESS?[2,{code:u,data:p}]:[2,{code:u}]}})})},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(n,r,i,o){this._customMessageType[n]={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(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([n],r),o=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(o,on)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([Ce(Ce({},n),{createdTime:l})],l),[2,{code:N.SUCCESS,data:d}])}})})},e.prototype.removeTag=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeRemoveTag([n],r),o=new Q(D[D.delSeTag],i,this.currentUserId),[4,this._channel.send(o,on)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.deleteTag([n],l),[2,{code:N.SUCCESS}])}})})},e.prototype.updateTag=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(r=this._userSettingManager.getVersion(),i=this._channel.codec.encodeCreateTag([n],r),o=new Q(D[D.addSeTag],i,this.currentUserId),[4,this._channel.send(o,on)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return s=h.sent(),c=s.code,d=s.data,c!==N.SUCCESS?[2,{code:c}]:(l=d.version,this._userSettingManager.addTag([n],l),[2,{code:N.SUCCESS,data:d}])}})})},e.prototype.getTagList=function(){return x(this,void 0,void 0,function(){var n,r;return B(this,function(i){return n=this._userSettingManager.getTags(),r=this._conversationManager.getConversationListForTag(),n.forEach(function(o){o.conversationCount=r[o.tagId]?r[o.tagId].length:0}),[2,{code:N.SUCCESS,data:n}]})})},e.prototype.addTagForConversations=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d=this;return B(this,function(l){switch(l.label){case 0:return this._channel?this._userSettingManager.getTagById(n)?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new Q(D[D.addTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:N.TAG_NOT_EXIST}]:[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(s=l.sent().code)!==N.SUCCESS?[2,{code:s}]:((c={})[n]={},r.forEach(function(h){d._conversationManager.addTagStatus(h.conversationType,h.targetId,c,h.channelId)}),[2,{code:N.SUCCESS}])}})})},e.prototype.removeTagForConversations=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c=this;return B(this,function(d){switch(d.label){case 0:return this._channel?(i=this._channel.codec.encodeUpdateConversationTag([{tagId:n}],r),o=new Q(D[D.delTag],i,this.currentUserId),[4,this._channel.send(o)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(s=d.sent().code)!==N.SUCCESS?[2,{code:s}]:(r.forEach(function(l){c._conversationManager.deleteTagStatus(l.conversationType,l.targetId,[n],l.channelId)}),[2,{code:N.SUCCESS}])}})})},e.prototype.removeTagsForConversation=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return this._channel?(i=n.conversationType,o=n.targetId,s=n.channelId,c=r.map(function(u){return{tagId:u}}),d=this._channel.codec.encodeUpdateConversationTag(c,[n]),l=new Q(D[D.delTag],d,this.currentUserId),[4,this._channel.send(l)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(h=a.sent().code)!==N.SUCCESS?[2,{code:h}]:(this._conversationManager.deleteTagStatus(i,o,r,s),[2,{code:N.SUCCESS}])}})})},e.prototype.getConversationListByTag=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f;return B(this,function(p){switch(p.label){case 0:return s=(o=this).currentUserId,(c=o._channel)?(d=c.codec.encodeOldConversationList({count:i,type:z.PRIVATE,startTime:r}),l=new Q(ja,d,s),[4,c.send(l,Qn,{currentUserId:s,connectedTime:c.connectedTime})]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return h=p.sent(),a=h.code,u=h.data,f=this._conversationHasTagFilter(n,u),$.info("GetConversationListByTag",f),a!==N.SUCCESS?[2,{code:a}]:[2,{code:a,data:f}]}})})},e.prototype._conversationHasTagFilter=function(n,r){var i=this,o=[],s=[];function c(d,l){return d.latestMessage&&l.latestMessage?d.latestMessage.sentTime-l.latestMessage.sentTime:0}return r.forEach(function(d){var l=d.conversationType,h=d.targetId,a=d.channelId,u=i._conversationManager.get(l,h,a),f=u.hasMentioned,p=u.mentionedInfo,m=u.lastUnreadTime,_=u.notificationStatus,v=u.isTop,y=u.tags,C=u.unreadMessageCount,I=y&&y[n];if(I){var P=Ce(Ce({},d),{hasMentioned:f,mentionedInfo:p,lastUnreadTime:m,notificationStatus:_,isTop:v,unreadMessageCount:C});I.isTop?o.push(Ce(Ce({},P),{isTopInTag:!0})):s.push(Ce(Ce({},P),{isTopInTag:!1}))}}),Kt(Kt([],o.sort(c)),s.sort(c))},e.prototype.getUnreadCountByTag=function(n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return this._channel?(i=this._conversationManager.getUnreadCountByTag(n,r),[2,{code:N.SUCCESS,data:i}]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setConversationStatusInTag=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u,f,p;return B(this,function(m){switch(m.label){case 0:return this._channel?(o=r.targetId,s=r.conversationType,c=r.channelId,d=i.isTop,l=[{tagId:n,isTop:d}],(h=this._conversationManager.get(s,o,c)).tags&&Object.hasOwnProperty.call(h.tags,n)?(a=this._channel.codec.encodeUpdateConversationTag(l,[r]),u=new Q(D[D.addTag],a,this.currentUserId),[4,this._channel.send(u)]):[2,{code:N.NO_TAG_IN_CONVER}]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return(f=m.sent().code)!==N.SUCCESS?[2,{code:f}]:((p={})[n]={},d&&(p[n].isTop=!0),this._conversationManager.addTagStatus(s,o,p,c),[2,{code:N.SUCCESS}])}})})},e.prototype.getTagsForConversation=function(n){var r;return x(this,void 0,void 0,function(){var i,o,s,c;return B(this,function(d){if(!this._channel)return[2,{code:N.RC_NET_CHANNEL_INVALID}];if(i=this._conversationManager.get(n.conversationType,n.targetId,n.channelId),o=this._userSettingManager.getTagsInfo(),s=[],i.tags)for(c in i.tags)s.push({tagId:c,tagName:(r=o[c])===null||r===void 0?void 0:r.tagName});return[2,{code:N.SUCCESS,data:s}]})})},e.prototype.getBlockConversationList=function(){var n=this._conversationManager.getBlockConversationList();return Promise.resolve({code:N.SUCCESS,data:n})},e.prototype.getTopConversationList=function(){var n=this._conversationManager.getTopConversationList();return Promise.resolve({code:N.SUCCESS,data:n})},e.prototype.getUnreadMentionedCount=function(n){var r=this._conversationManager.getUnreadMentionedCount(n.channelId,n.conversationType,n.targetId);return Promise.resolve({code:N.SUCCESS,data:r})},e.prototype.getAllUnreadMentionedCount=function(){var n=this._conversationManager.getAllUnreadMentionedCount();return Promise.resolve({code:N.SUCCESS,data:n})},e.prototype.joinRTCRoom=function(n,r,i,o){return x(this,void 0,void 0,function(){var s,c;return B(this,function(d){return this._channel?(s=this._channel.codec.encodeJoinRTCRoom(r,i,o),c=new Q(D[D.rtcRJoin_data],s,n),[2,this._channel.send(c,$t)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.quitRTCRoom=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){switch(o.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.rtcRExit],r,n),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,o.sent().code]}})})},e.prototype.rtcPing=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(D[D.rtcPing],o,n),[4,this._channel.send(s)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCRoomInfo=function(n){return x(this,void 0,void 0,function(){var r,i;return B(this,function(o){return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcRInfo],r,n),[2,this._channel.send(i,gu)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.getRTCUserInfoList=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c;return B(this,function(d){switch(d.label){case 0:return this._channel?(r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUData],r,n),[4,this._channel.send(i,$t)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return o=d.sent(),s=o.code,c=o.data,[2,{code:s,data:c&&{users:c.users}}]}})})},e.prototype.setRTCUserInfo=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeSetRTCUserInfo(r,i),s=new Q(D[D.rtcUPut],o,n),[4,this._channel.send(s)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.removeRTCUserInfo=function(n,r){return x(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeRemoveRTCUserInfo(r),o=new wn(D[D.rtcUDel],i,n),[4,this._channel.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.setRTCData=function(n,r,i,o,s,c){return x(this,void 0,void 0,function(){var d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(d=this._channel.codec.encodeSetRTCData(r,i,o,s,c),l=new wn(D[D.rtcSetData],d,n),[4,this._channel.send(l)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,h.sent().code]}})})},e.prototype.setRTCTotalRes=function(n,r,i,o,s){return x(this,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeUserSetRTCData(r,i,o,s),d=new Q(D[D.userSetData],c,n),[4,this._channel.send(d)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCCDNUris=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){switch(c.label){case 0:return this._channel?(o=this._channel.codec.encodeUserSetRTCCDNUris(r,i),s=new Q(D[D.userSetData],o,n),[4,this._channel.send(s)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,c.sent().code]}})})},e.prototype.getRTCData=function(n,r,i,o){if(!this._channel)return Promise.resolve({code:N.RC_NET_CHANNEL_INVALID});var s=this._channel.codec.encodeGetRTCData(r,i,o),c=new Q(D[D.rtcQryData],s,n);return this._channel.send(c,Ti)},e.prototype.removeRTCData=function(n,r,i,o,s){return x(this,void 0,void 0,function(){var c,d;return B(this,function(l){switch(l.label){case 0:return this._channel?(c=this._channel.codec.encodeRemoveRTCData(r,i,o,s),d=new wn(D[D.rtcDelData],c,n),[4,this._channel.send(d)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,l.sent().code]}})})},e.prototype.setRTCOutData=function(n,r,i,o){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCOutData=function(n,r){throw new Error("JSEngine's method not implemented.")},e.prototype.getRTCToken=function(n,r,i){return x(this,void 0,void 0,function(){var o,s;return B(this,function(c){return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(D[D.rtcToken],o,n),[2,this._channel.send(s,Ri)]):[2,{code:N.RC_NET_CHANNEL_INVALID}]})})},e.prototype.setRTCState=function(n,r){return x(this,void 0,void 0,function(){var i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(i=this._channel.codec.encodeSetRTCState(r),o=new Q(D[D.rtcUserState],i,n),[4,this._channel.send(o)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return[2,s.sent().code]}})})},e.prototype.getRTCUserInfo=function(n){return x(this,void 0,void 0,function(){return B(this,function(r){throw new Error("Method not implemented.")})})},e.prototype.getRTCUserList=function(n){if(!this._channel)return Promise.resolve({code:N.RC_NET_CHANNEL_INVALID});var r=this._channel.codec.encodeGetRTCRoomInfo(),i=new Q(D[D.rtcUList],r,n);return this._channel.send(i,$t)},e.prototype.joinLivingRoomAsAudience=function(n,r,i){return r===void 0&&(r=qe.LIVE),x(this,void 0,void 0,function(){var o,s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return this._channel?(o=this._channel.codec.encodeJoinRTCRoom(r,i),s=new Q(D[D.viewerJoinR],o,n),[4,this._channel.send(s,Ru)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return c=f.sent(),d=c.code,l=c.data,d!==N.SUCCESS?[2,{code:d}]:(a=(h=l).rtcToken,u=h.entries,[2,{code:d,data:{token:a,kvEntries:u}}])}})})},e.prototype.quitLivingRoomAsAudience=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeQuitRTCRoom(),i=new Q(D[D.viewerExitR],r,n),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.rtcIdentityChange=function(n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l;return B(this,function(h){switch(h.label){case 0:return this._channel?(o=this._channel.codec.encodeIdentityChangeInfo(r,i),s=new Q(D[D.rtcIdentityChange],o,n),[4,this._channel.send(s,$t)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return c=h.sent(),d=c.code,l=c.data,d!==N.SUCCESS?[2,{code:d}]:[2,{code:d,data:l}]}})})},e.prototype.pullRTCRoomEntry=function(n,r){return x(this,void 0,void 0,function(){var i,o,s,c,d,l,h,a,u;return B(this,function(f){switch(f.label){case 0:return o=(i=this)._channel,s=i.currentUserId,o?($.info("audience in room start pull KV"),c=o.codec.encodePullRTCRoomKV(n,0),d=new Q(D[D.rtcPullKv],c,s),[4,o.send(d,wi)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return l=f.sent(),h=l.code,a=l.data,$.info("audience in room end pull KV, code: "+h+", data: "+JSON.stringify(a||{})),h===N.SUCCESS?(u=a.kvEntries,this._watcher.onRTCDataChange(u,n),[2,{code:h,data:a}]):[2,{code:h}]}})})},e.prototype.getRTCJoinedUserInfo=function(n){return x(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h;return B(this,function(a){switch(a.label){case 0:return i=(r=this)._channel,o=r.currentUserId,i?(s=i.codec.encodeQueryUserJoinedInfo(n),c=new Q(D[D.rtcQueryJoined],s,o),[4,i.send(c,Oi)]):[2,{code:N.RC_NET_CHANNEL_INVALID}];case 1:return d=a.sent(),l=d.code,h=d.data,l===N.SUCCESS?[2,{code:l,data:h}]:[2,{code:l}]}})})},e.prototype.getDeviceId=function(){return xu(this.runtime)},e.prototype.requestRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeRequestRoomPK(n),i=new Q(D[D.rtcInvite],r,n.roomId),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.cancelRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeCancelRoomPK(n),i=new Q(D[D.rtcCancelInvite],r,n.roomId),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.responseRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeResponseRoomPK(n),i=new Q(D[D.rtcInviteAnswer],r,n.roomId),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.endRoomPK=function(n){return x(this,void 0,void 0,function(){var r,i,o;return B(this,function(s){switch(s.label){case 0:return this._channel?(r=this._channel.codec.encodeEndRoomPK(n),i=new Q(D[D.rtcEndInvite],r,n.roomId),[4,this._channel.send(i)]):[2,N.RC_NET_CHANNEL_INVALID];case 1:return o=s.sent().code,this._rtcKVManager.reset(),[2,o]}})})},e.prototype.callExtra=function(n){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return Promise.resolve({code:N.EXTRA_METHOD_UNDEFINED})},e.prototype.getConversationListWithAllChannel=function(){throw new Error("Method not implemented.")},e.prototype.getConversationListWithAllChannelByPage=function(n,r){throw new Error("Method not implemented.")},e.prototype.clearConversations=function(){throw new Error("Method not implemented.")},e.prototype.setUserStatusListener=function(n,r){throw new Error("Method not implemented.")},e.prototype.setUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.subscribeUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.getUserStatus=function(n){throw new Error("Method not implemented.")},e.prototype.addToBlacklist=function(n){throw new Error("Method not implemented.")},e.prototype.removeFromBlacklist=function(n){throw new Error("Method not implemented.")},e.prototype.getBlacklist=function(){throw new Error("Method not implemented.")},e.prototype.getBlacklistStatus=function(n){throw new Error("Method not implemented.")},e.prototype.insertMessage=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.deleteMessages=function(n){throw new Error("Method not implemented.")},e.prototype.deleteMessagesByTimestamp=function(n,r,i,o,s){throw new Error("Method not implemented.")},e.prototype.clearMessages=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.getMessage=function(n){throw new Error("Method not implemented.")},e.prototype.setMessageContent=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.setMessageSearchField=function(n,r,i){throw new Error("Method not implemented.")},e.prototype.searchConversationByContent=function(n,r,i,o){throw new Error("Method not implemented.")},e.prototype.searchMessageByContent=function(n,r,i,o,s,c){throw new Error("Method not implemented.")},e.prototype.getUnreadMentionedMessages=function(n,r){throw new Error("Method not implemented.")},e.prototype.setMessageSentStatus=function(n,r){throw new Error("Method not implemented.")},e.prototype.setMessageReceivedStatus=function(n,r){throw new Error("Method not implemented.")},e.prototype.clearUnreadCountByTimestamp=function(n,r,i,o){throw new Error("Method not implemented.")},e.prototype.getConversationNotificationStatus=function(n,r,i){var o=this._conversationManager.get(n,r,i);return o?Promise.resolve({code:N.SUCCESS,data:o.notificationStatus}):Promise.resolve({code:N.CONVER_GET_ERROR})},e.prototype.getRemoteHistoryMessages=function(n,r,i,o,s,c){return this.getHistoryMessage(n,r,i,o,s,c)},e}(_h),Bu=function(){function t(e){this._context=e}return t.prototype.getCoreVersion=function(){return this._context.coreVersion},t.prototype.getAPIVersion=function(){return this._context.apiVersion},t.prototype.getAppkey=function(){return this._context.appkey},t.prototype.getCurrentId=function(){return this._context.getCurrentUserId()},t.prototype.getConnectionStatus=function(){return this._context.getConnectionStatus()},t.prototype.getDeviceId=function(){return this._context.getDeviceId()},t.prototype.sendMessage=function(e,n,r){return this._context.sendMessage(e,n,r)},t.prototype.registerMessageType=function(e,n,r,i){i===void 0&&(i=[]),this._context.registerMessageType(e,n,r,i)},t.prototype.getServerTime=function(){return this._context.getServerTime()},t.prototype.getRTCJoinedUserInfo=function(e){return this._context.getRTCJoinedUserInfo(e)},t}(),kh=function(t){function e(){return t!==null&&t.apply(this,arguments)||this}return Ne(e,t),e.prototype.getNaviInfo=function(){return this._context.getInfoFromCache()},e.prototype.joinRTCRoom=function(n,r,i,o){return this._context.joinRTCRoom(n,r,i,o)},e.prototype.quitRTCRoom=function(n){return this._context.quitRTCRoom(n)},e.prototype.rtcPing=function(n,r,i){return this._context.rtcPing(n,r,i)},e.prototype.getRTCRoomInfo=function(n){return this._context.getRTCRoomInfo(n)},e.prototype.getRTCUserInfoList=function(n){return this._context.getRTCUserInfoList(n)},e.prototype.getRTCUserInfo=function(n){return this._context.getRTCUserInfo(n)},e.prototype.setRTCUserInfo=function(n,r,i){return this._context.setRTCUserInfo(n,r,i)},e.prototype.removeRTCUserInfo=function(n,r){return this._context.removeRTCUserInfo(n,r)},e.prototype.setRTCData=function(n,r,i,o,s,c){return this._context.setRTCData(n,r,i,o,s,c)},e.prototype.setRTCTotalRes=function(n,r,i,o,s){return this._context.setRTCTotalRes(n,r,i,o,s)},e.prototype.setRTCCDNUris=function(n,r,i){return this._context.setRTCCDNUris(n,r,i)},e.prototype.getRTCData=function(n,r,i,o){return this._context.getRTCData(n,r,i,o)},e.prototype.removeRTCData=function(n,r,i,o,s){return this._context.removeRTCData(n,r,i,o,s)},e.prototype.setRTCOutData=function(n,r,i,o){return this._context.setRTCOutData(n,r,i,o)},e.prototype.getRTCOutData=function(n,r){return this._context.getRTCOutData(n,r)},e.prototype.getRTCToken=function(n,r,i){return this._context.getRTCToken(n,r,i)},e.prototype.setRTCState=function(n,r){return this._context.setRTCState(n,r)},e.prototype.getRTCUserList=function(n){return this._context.getRTCUserList(n)},e.prototype.joinLivingRoomAsAudience=function(n,r,i){return this._context.joinLivingRoomAsAudience(n,r,i)},e.prototype.quitLivingRoomAsAudience=function(n){return this._context.quitLivingRoomAsAudience(n)},e.prototype.rtcIdentityChange=function(n,r,i){return this._context.rtcIdentityChange(n,r,i)},e.prototype.requestRoomPK=function(n){return this._context.requestRoomPK(n)},e.prototype.cancelRoomPK=function(n){return this._context.cancelRoomPK(n)},e.prototype.responseRoomPK=function(n){return this._context.responseRoomPK(n)},e.prototype.endRoomPK=function(n){return this._context.endRoomPK(n)},e}(Bu),za=function(){function t(){}return t.compress=function(e){for(var n=this,r={},i=0;i<e.length-1;i++){var o=e.charAt(i)+e.charAt(i+1);r.hasOwnProperty(o)?r[o].push(i):r[o]=[i]}for(var s=[],c=[],d=function(){if(c.length>0){var _=c.join("");if(c=[],_.length>26){var v=n.numberEncode(_.length),y=String.fromCharCode(n.dataType.NormalExt|v.length);s.push(y+v)}else{var C=String.fromCharCode(n.dataType.Normal|_.length);s.push(C)}s.push(_)}},l=0;l<e.length;){var h=n.indexOf(r,e,l);if(h.length<2)c.push(e.charAt(l++));else if(h.length<4)c.push(e.substr(l,h.length)),l+=h.length;else{var a=n.numberEncode(l-h.offset),u=n.numberEncode(h.length);if(a.length+u.length>=h.length)c.push(e.substr(l,h.length)),l+=h.length;else{d();var f=String.fromCharCode(n.dataType.Compressed|a.length<<2|u.length);s.push(f+a+u),l+=h.length}}}d();var p=n.numberEncode(e.length),m=String.fromCharCode(n.dataType.Tail|p.length);return s.push(m+p),s.join("")},t.uncompress=function(e){var n=this,r=0,i="";e:do{var o=e.charCodeAt(r++),s=o&n.dataType.Mark,c=15&o,d=void 0;switch(s){case n.dataType.Compressed:var l=c>>2,h=3&c;if(l===0||h===0)throw new Error("Data parsing error,at "+r);var a=n.numberDecode(e.substr(r,l)),u=n.numberDecode(e.substr(r+=l,h));if((a=i.length-a)+u>i.length)throw new Error("Data parsing error,at "+r);r+=h,i+=i.substr(a,u);break;case n.dataType.Tail:if((d=n.numberDecode(e.substr(r,c)))!==i.length)throw console.log(i.length),console.log(d),new Error("Data parsing error,at "+r);r+=c;break e;case n.dataType.NormalExt:d=n.numberDecode(e.substr(r,c)),i+=e.substr(r+=c,d),r+=d;break;case n.dataType.Normal:i+=e.substr(r,c),r+=c;break;case n.dataType.Mark:if(c>10)throw new Error("Data parsing error,at "+r);i+=e.substr(r,16+c),r+=16+c;break;default:throw new Error("Data parsing error,at "+r+" header:"+s)}}while(r<e.length);return i},t.indexOf=function(e,n,r){var i={length:0,offset:-1};if(n.length,r>=n.length-1)return i;var o=e[n.charAt(r)+n.charAt(r+1)];if(o[0]===r)return i;for(var s=n.length-r,c=0,d=o.length;c<d;c++){var l=o[c],h=r-l;if(!(h>this.max)){var a=Math.min(s,h);if(a<=i.length)break;if(!(i.length>2&&n.charAt(l+i.length-1)!==n.charAt(r+i.length-1))){for(var u=2,f=u;f<a&&n.charAt(l+f)===n.charAt(r+f);f++)u++;u>=i.length&&(i.length=u,i.offset=l)}}}return i},t.numberEncode=function(e){var n=this,r=[],i=0;do i=e%n.scale,r.push(n.chars.charAt(i)),e=(e-i)/n.scale;while(e>0);return r.join("")},t.numberDecode=function(e){for(var n=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+'"');n=n*this.scale+r}return n},t.dataType={Tail:48,Compressed:64,NormalExt:80,Normal:96,Mark:112},t.chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t.scale=t.chars.length,t.max=238327,t}(),An=1,Mn=!1,Qa=typeof location!="undefined"&&location.protocol==="https://"?"https://":"http://",yr=function(){function t(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=xu(e.runtime),this.logSwitch=e.logSwitch;var n=jl(e.runtime);this.deviceInfo=n.type+"|"+n.version+"|"+Ut.sessionId,this.startReport()}return t.init=function(e){return Mn=!0,t._instance||(t._instance=new t(e)),t._instance},t.getInstance=function(){return t._instance},t.prototype.startReport=function(){var e=this;if(this.logSwitch&&Mn){var n=this.itv*Math.pow(2,An-1);An<this.times&&An++,setTimeout(function(){e.reportRealtimeLog()},1e3*n)}},t.prototype.reportRealtimeLog=function(){var e=this,n=Ut.realTimeLogList.filter(function(o){return o.level<=e.level});if(n.length!==0){var r=za.compress(n.map(function(o){return o.content}).join("")),i=""+Qa+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(o){$.__clearRealTimeLog(),$.debug("report real-time log success");var s=o.data;s&&(s=JSON.parse(s),e.itv=s.nextTime,e.level=s.level,e.logSwitch=s.logSwitch,An=1),e.startReport()}).catch(function(o){$.debug("report real-time log error -> "+o),e.startReport()})}else this.startReport()},t.prototype.reportFullLog=function(e){return x(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u=this;return B(this,function(f){switch(f.label){case 0:return n=e.startTime,r=e.endTime,i=e.platform,o=e.logId,s=e.uri,c=us.getInstance(),$.debug("received report log msg, "+i.toLowerCase(),c),i.toLowerCase()==="web"&&c?n>r?($.warn("report error: The start time("+n+") cannot be greater than the end time("+n+")"),[2]):[4,$.__insertLogIntoDatabase()]:[2];case 1:return f.sent(),[4,c.getRangeData(nn,"time",n,r)];case 2:return d=(d=f.sent()).filter(function(p){return!p.userId||p.userId===u.info.userId}),l=za.compress(d.map(function(p){return p.content}).join("")||"no data"),h=1,(a=function(){if(!(h>3)&&Mn){var p=s||u.logUrl,m=""+Qa+p+"?version="+u.info.version+"&appkey="+u.info.appkey+"&userId="+u.info.userId+"&logId="+o+"&deviceId="+u.deviceId+"&deviceInfo="+u.deviceInfo+"&platform=Web",_=5e3*(h-1);h++,setTimeout(function(){Mn&&u.info.runtime.httpReq({url:m,method:"POST",body:l}).then(function(){$.debug("report full log success!")}).catch(function(v){a(),$.warn("report full log error -> "+v)})},_)}})(),[2]}})})},t.prototype.distroy=function(){An=1,Mn=!1},t}();function Cr(t){return Object.assign({},t)}var Xa,Uh=function(){function t(e,n){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=ne.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({},n),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(o){return/^https?:\/\//.test(o)}),this._options.navigators=this._options.navigators.map(function(o){return o.replace(/\/$/g,"")}),this._options.navigators.length===0&&(r=this._options.navigators).push.apply(r,wl);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=xa()?new RCCppEngine(e,i,this._options):new Lh(e,i,this._options)}return t.init=function(e,n){return $.setLogLevel(n.logLevel),$.setLogStdout(n.logStdout),(n.indexDBSwitch||me(n.indexDBSwitch))&&us.init(),$.debug("APIContext.init =>",n.appkey,n.navigators),this._context?($.error("Repeat initialize!"),this._context):($.warn("RCEngine Commit:","41dbe38d1b376ca0a791b23ed94be291e3f92e81"),this._context=new t(e,n),$.__insertLogIntoDatabase(),this._context)},t.destroy=function(){this._context&&(this._context._destroy(),this._context=void 0)},t.prototype.install=function(e,n){if(this._pluginInstanseMap[e.tag])return $.warn("Repeat install plugin: "+e.tag),this._pluginInstanseMap[e.tag];var r=e.tag==="RCRTC"?new kh(this):new Bu(this),i=null;try{if(!e.verify(this._runtime))return null;i=e.setup(r,this._runtime,n)}catch(o){$.error(`install plugin error!
  796. `,o)}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},t.prototype._handleRedirect=function(){return x(this,void 0,void 0,function(){var e=this;return B(this,function(n){switch(n.label){case 0:return $.debug("_handleRedirct",this._token),[4,this.connect(this._token,!0)];case 1:return n.sent().code!==N.SUCCESS&&this._canRedirectConnect&&(this._handleSuspend(),setTimeout(function(){e._handleRedirect()},5e3)),[2]}})})},t.prototype._connectionStatusListener=function(e){var n;return x(this,void 0,void 0,function(){return B(this,function(r){return e===ne.REDIRECT?(this._canRedirectConnect=!0,this._handleSuspend(),this._handleRedirect()):e===ne.BLOCKED||e===ne.KICKED_OFFLINE_BY_OTHER_CLIENT||e===ne.DISCONNECT_BY_SERVER?(this._canRedirectConnect=!1,this._handleDisconnect()):e===ne.CONNECTING?this._handleConnecting():e===ne.CONNECTED?this._handleConnected():e===ne.DISCONNECTED?this._handleDisconnect():e===ne.NETWORK_UNAVAILABLE&&this._handleSuspend(),this._connectionStatus=e,((n=this._watcher.rtcInnerWatcher)===null||n===void 0?void 0:n.status)&&this._watcher.rtcInnerWatcher.status(e),this._pluginContextQueue.forEach(function(i){i.onconnectionstatechange&&i.onconnectionstatechange(e)}),this._watcher.connectionState&&this._watcher.connectionState(e),[2]})})},t.prototype._handleConnecting=function(){this._watcher.onConnecting&&this._watcher.onConnecting()},t.prototype._handleConnected=function(){this._watcher.onConnected&&this._watcher.onConnected()},t.prototype._handleDisconnect=function(){this._watcher.onDisconnect&&this._watcher.onDisconnect()},t.prototype._handleSuspend=function(){this._watcher.onSuspend&&this._watcher.onSuspend()},t.prototype._messageReceiver=function(e,n,r){var i,o,s;if((e.conversationType===z.RTC_ROOM||Object.prototype.hasOwnProperty.call(Ul,e.messageType))&&this._watcher.rtcInnerWatcher&&this._watcher.rtcInnerWatcher.message)this._watcher.rtcInnerWatcher.message(Cr(e));else if(["RC:ChrmJoinNtf","RC:ChrmQuitNtf"].indexOf(e.messageType)===-1||typeof this._watcher.chatroomState!="function"){if(e.messageType!=="RC:ChrmMemChange"){if(e.messageType!==$e.TYPING_STATUS||(this._addTypingInfo(Cr(e)),!this._watcher.typingState))if(e.messageType!==$e.LOG_COMMAND||e.senderUserId!=="rongcloudsystem")if(e.messageType!==$e.INTERCEPT){if(!this._pluginContextQueue.some(function(v){if(!v.onmessage)return!1;try{return v.onmessage(Cr(e))}catch(y){return $.error("plugin error =>",y),!1}}))if(e.messageType!=="RC:ReadNtf")if(e.messageType!=="RC:RRReqMsg"){if(e.messageType!=="RC:RRRspMsg")return this._watcher.message&&this._watcher.message(Cr(e),n,r),e;var c=(s=e.content)===null||s===void 0?void 0:s.receiptMessageDic;c&&Array.isArray(c[this._engine.currentUserId])&&typeof this._watcher.messageReceiptResponse=="function"&&this._watcher.messageReceiptResponse({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId},e.senderUserId,c[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,u=d.logId,f=d.uri,p=d.packageName,m={startTime:parseInt(l),endTime:parseInt(h),platform:a,logId:u,uri:f,packageName:p};(o=yr.getInstance())===null||o===void 0||o.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"?La.QUIT:La.JOIN,i),chatroomId:e.targetId}})},t.prototype._batchMessageReceiver=function(e,n,r){var i=this,o=[];e.forEach(function(s){var c=i._messageReceiver(s,n,r);c&&o.push(c)}),o.length&&this._watcher.batchMessage&&this._watcher.batchMessage(o)},t.prototype._chatroomInfoListener=function(e){this._watcher.chatroomState&&this._watcher.chatroomState(e)},t.prototype._conversationInfoListener=function(e){this._watcher.conversationState&&this._watcher.conversationState(e)},t.prototype._expansionInfoListener=function(e){this._watcher.expansion&&this._watcher.expansion(e)},t.prototype._tagListener=function(){this._watcher.tag&&this._watcher.tag()},t.prototype._conversationTagListener=function(){this._watcher.conversationTagChanged&&this._watcher.conversationTagChanged()},t.prototype._typingStatusListener=function(e){this._watcher.typingState&&this._watcher.typingState(e)},t.prototype._pullFinishedListener=function(){this._watcher.pullFinished&&this._watcher.pullFinished()},t.prototype._MessageBlockedListener=function(e){this._watcher.messageBlocked&&this._watcher.messageBlocked(e)},t.prototype._rtcDataChange=function(e,n){this._pluginContextQueue.forEach(function(r){r.onrtcdatachange&&r.onrtcdatachange(e,n)})},t.prototype.assignWatcher=function(e){var n=this;Object.keys(this._watcher).forEach(function(r){if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];n._watcher[r]=Gr(i)||Ve(i)?i:void 0}})},t.prototype.resetWatcher=function(){var e=this;Object.keys(this._watcher).forEach(function(n){e._watcher[n]=void 0})},t.prototype._addTypingInfo=function(e){var n=e.senderUserId,r=e.conversationType,i=e.targetId,o=e.content,s=e.channelId,c=o.typingContentType,d=r+"#"+i+"#"+(s||"");this._typingInfo[d]||(this._typingInfo[d]=[]);var l=this._typingInfo[d].findIndex(function(h){return h.userId===n});l>=0&&this._typingInfo[d][l].messageType===c?this._typingInfo[d][l].timestamp=Date.now():(l>=0&&this._typingInfo[d].splice(l,1),this._typingInfo[d].push({userId:n,messageType:c,timestamp:Date.now()}),this._typingChangedList.includes(d)||this._typingChangedList.push(d),this._startCheckTypingInfo())},t.prototype._startCheckTypingInfo=function(){var e=this;this._typingInternalTimer===-1&&Object.keys(this._typingInfo).length!==0&&(this._typingInternalTimer=setInterval(function(){for(var n in e._typingInfo){var r=e._typingInfo[n].length;e._typingInfo[n]=e._typingInfo[n].filter(function(o){return Date.now()-o.timestamp<e._typingExpireTime}),e._typingInfo[n].length===r||e._typingChangedList.includes(n)||e._typingChangedList.push(n),e._typingInfo[n].length===0&&delete e._typingInfo[n]}if(e._typingChangedList.length>0){var i=e._typingChangedList.map(function(o){return{conversationType:Number(o.split("#")[0]),targetId:o.split("#")[1],channelId:o.split("#")[2],list:e._typingInfo[o]||[]}});e._typingStatusListener(i),e._typingChangedList=[]}Object.keys(e._typingInfo).length===0&&(clearInterval(e._typingInternalTimer),e._typingInternalTimer=-1)},500))},t.prototype.getConnectedTime=function(){return this._engine.getConnectedTime()},t.prototype.getServerTime=function(){return this._engine.getServerTime()},t.prototype.getDeviceId=function(){return this._engine.getDeviceId()},t.prototype.getCurrentUserId=function(){return this._engine.currentUserId},t.prototype.getConnectionStatus=function(){return this._connectionStatus},Object.defineProperty(t.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),t.prototype.connect=function(e,n){return n===void 0&&(n=!1),x(this,void 0,void 0,function(){var r,i,o,s,c,d;return B(this,function(l){switch(l.label){case 0:return this._connectionStatus===ne.CONNECTED?[2,{code:N.SUCCESS,userId:this._engine.currentUserId}]:this._connectionStatus===ne.CONNECTING?[2,{code:N.BIZ_ERROR_CONNECTING}]:typeof e!="string"||e.length===0?[2,{code:N.RC_CONN_USER_OR_PASSWD_ERROR}]:(this._token=e,r=e.split("@"),i=r[1],o=i?i.split(";").map(function(h){return/^https?:/.test(h)?h:"https://"+h}):[],[4,this._engine.navi.getInfo(this._getTokenWithoutNavi(),o,n,this._options.checkCA)]);case 1:return(s=l.sent())?(s==null?void 0:s.type)===1?[2,{code:N.PACKAGE_ENVIRONMENT_ERROR}]:(c=qt.getInfo(),[4,this._engine.connect(this._getTokenWithoutNavi(),s)]):[2,{code:N.RC_NAVI_RESOURCE_ERROR}];case 2:return d=l.sent(),$.__insertLogIntoDatabase(),d!==He.REDIRECT?[3,4]:(this._connectionStatus=ne.REDIRECT,[4,this.connect(e,!0)]);case 3:return[2,l.sent()];case 4:return d===N.SUCCESS&&($.info("connect success, userId: "+this._engine.currentUserId),(s==null?void 0:s.type)!==1&&this._engine.reportSDKInfo&&this._engine.reportSDKInfo(c),yr.init({runtime:this._runtime,logSwitch:(s==null?void 0:s.logSwitch)||0,logPolicy:JSON.parse((s==null?void 0:s.logPolicy)||"{}"),appkey:this.appkey,version:this.apiVersion,userId:this._engine.currentUserId}),Ut.init(this._engine.currentUserId),this._isInternalConnected=!0),d!==N.SUCCESS||xa()||s.openUS===1&&this._pullUserSettings(),d!==N.SUCCESS&&(this._connectionStatus=ne.CONNECTION_CLOSED),[2,{code:d,userId:this._engine.currentUserId}]}})})},t.prototype._pullUserSettings=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2]})})},t.prototype.disconnect=function(){var e;return this._isInternalConnected=!1,clearInterval(this._typingInternalTimer),this._typingInternalTimer=-1,(e=yr.getInstance())===null||e===void 0||e.distroy(),$.__insertLogIntoDatabase(),Ut.reset(),this._engine.disconnect(),this._pluginContextQueue.forEach(function(n){if(n.ondisconnect)try{n.ondisconnect()}catch(r){$.error("plugin error =>",r)}}),Promise.resolve()},t.prototype.reconnect=function(){return this._isInternalConnected?Promise.resolve({code:N.CAN_NOT_RECONNECT}):this.connect(this._getTokenWithoutNavi())},t.prototype._getTokenWithoutNavi=function(){return this._token.replace(/@.+$/,"@")},t.prototype.getInfoFromCache=function(){return this._engine.navi.getInfoFromCache(this._getTokenWithoutNavi())},t.prototype.registerMessageType=function(e,n,r,i){i===void 0&&(i=[]),this._engine.registerMessageType(e,n,r,i)},t.prototype.sendMessage=function(e,n,r,i){var o=this.getInfoFromCache();if(((o==null?void 0:o.grpRRVer)||0)===1&&r.messageType===$e.READ_RECEIPT_RESPONSE)return Promise.resolve({code:N.READ_RECEIPT_ERROR});var s=JSON.stringify(r.content);return au(s)>131072?Promise.resolve({code:N.RC_MSG_CONTENT_EXCEED_LIMIT}):this._engine.sendMessage(e,n,r,i)},t.prototype.sendExpansionMessage=function(e){return x(this,void 0,void 0,function(){var n,r,i,o,s,c,d,l,h,a,u,f,p,m;return B(this,function(_){switch(_.label){case 0:if(n=e.channelId,r=e.conversationType,i=e.targetId,o=e.messageUId,s=e.keys,c=e.expansion,d=e.removeAll,!e.canIncludeExpansion)return[2,{code:N.MESSAGE_KV_NOT_SUPPORT}];if(l=!1,h=!1,a=!1,Ve(c)){for(f in u=Object.keys(c).length,l=u>20,c)if(p=c[f],h=Ze(f)&&!/^[A-Za-z0-9_=+-]+$/.test(f),(a=f.length>32||p.length>64)||h)break}return l||a?[2,{code:N.EXPANSION_LIMIT_EXCEET}]:h?[2,{code:N.BIZ_ERROR_INVALID_PARAMETER}]:(m={mid:o},c&&(m.put=c),s&&(m.del=s),d&&(m.removeAll=1),[4,this._engine.sendMessage(r,i,{content:m,messageType:$e.EXPANSION_NOTIFY,channelId:n})]);case 1:return[2,{code:_.sent().code}]}})})},t.prototype.sendReadReceiptMessage=function(e,n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:N.READ_RECEIPT_ERROR,data:"The read receipt switch is not on, please call the sendMessage method!"}]:[2,this._engine.sendReadReceiptMessage(e,n,r)]})})},t.prototype.getMessageReader=function(e,n,r){return x(this,void 0,void 0,function(){var i;return B(this,function(o){return i=this.getInfoFromCache(),((i==null?void 0:i.grpRRVer)||0)===0?[2,{code:N.READ_RECEIPT_ERROR}]:[2,this._engine.getMessageReader(e,n,r)]})})},t.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(n){if(n.ondestroy)try{n.ondestroy()}catch(r){$.error("plugin error =>",r)}}),this._pluginContextQueue.length=0,this._pluginInstanseMap={},(e=yr.getInstance())===null||e===void 0||e.distroy(),Ut.reset()},t.prototype.getHistoryMessage=function(e,n,r,i,o,s,c){return r===void 0&&(r=0),i===void 0&&(i=20),o===void 0&&(o=0),s===void 0&&(s=""),c===void 0&&(c=""),this._engine.getHistoryMessage(e,n,r,i,o,s,c||"")},t.prototype.getConversationList=function(e,n,r,i,o){return e===void 0&&(e=300),o===void 0&&(o=""),this._engine.getConversationList(e,n,r,i,o)},t.prototype.getConversation=function(e,n,r){return this._engine.getConversation(e,n,r)},t.prototype.removeConversation=function(e,n,r){return r===void 0&&(r=""),this._engine.removeConversation(e,n,r)},t.prototype.clearUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationUnreadCount(e,n,r)},t.prototype.clearAllUnreadCount=function(){return this._engine.clearAllUnreadCount()},t.prototype.getUnreadCount=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationUnreadCount(e,n,r)},t.prototype.getTotalUnreadCount=function(e,n,r){return this._engine.getAllConversationUnreadCount(e,n&&n.length>0?n:[z.PRIVATE,z.GROUP,z.SYSTEM,z.PUBLIC_SERVICE],!!r)},t.prototype.getFirstUnreadMessage=function(e,n,r){return r===void 0&&(r=""),this._engine.getFirstUnreadMessage(e,n,r)},t.prototype.setConversationStatus=function(e,n,r,i,o){o===void 0&&(o="");var s=[{conversationType:e,targetId:n,isTop:r,notificationStatus:i,channelId:o}];return this._engine.batchSetConversationStatus(s)},t.prototype.saveConversationMessageDraft=function(e,n,r,i){return i===void 0&&(i=""),this._engine.saveConversationMessageDraft(e,n,r,i)},t.prototype.getConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationMessageDraft(e,n,r)},t.prototype.clearConversationMessageDraft=function(e,n,r){return r===void 0&&(r=""),this._engine.clearConversationMessageDraft(e,n,r)},t.prototype.recallMessage=function(e,n,r,i,o){return this._engine.recallMsg(e,n,r,i,o)},t.prototype.deleteRemoteMessage=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessage(e,n,r,i)},t.prototype.deleteRemoteMessageByTimestamp=function(e,n,r,i){return i===void 0&&(i=""),this._engine.deleteRemoteMessageByTimestamp(e,n,r,i)},t.prototype.joinChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinChatroom(e,n)},t.prototype.joinExistChatroom=function(e,n){return n===void 0&&(n=10),this._engine.joinExistChatroom(e,n)},t.prototype.quitChatroom=function(e){return this._engine.quitChatroom(e)},t.prototype.getChatroomInfo=function(e,n,r){return n===void 0&&(n=0),r===void 0&&(r=0),this._engine.getChatroomInfo(e,n,r)},t.prototype.setChatroomEntry=function(e,n){var r=n.key,i=n.value;return zt(r)&&Gi(i)?this._engine.setChatroomEntry(e,n):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.setChatroomEntries=function(e,n){for(var r=0;r<n.entries.length;r++){var i=n.entries[r],o=i.key,s=i.value;if(!zt(o)||!Gi(s))return Promise.resolve({code:N.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.setChatroomEntries(e,n)},t.prototype.forceSetChatroomEntry=function(e,n){var r=n.key,i=n.value;return zt(r)&&Gi(i)?this._engine.forceSetChatroomEntry(e,n):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.removeChatroomEntry=function(e,n){var r=n.key;return zt(r)?this._engine.removeChatroomEntry(e,n):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.removeChatroomEntries=function(e,n){for(var r=0;r<n.entries.length;r++){var i=n.entries[r].key;if(!zt(i))return Promise.resolve({code:N.BIZ_ERROR_INVALID_PARAMETER})}return this._engine.removeChatroomEntries(e,n)},t.prototype.forceRemoveChatroomEntry=function(e,n){var r=n.key;return zt(r)?this._engine.forceRemoveChatroomEntry(e,n):Promise.resolve(N.BIZ_ERROR_INVALID_PARAMETER)},t.prototype.getChatroomEntry=function(e,n){return this._engine.getChatroomEntry(e,n)},t.prototype.getAllChatroomEntries=function(e){return this._engine.getAllChatroomEntry(e)},t.prototype.getChatroomHistoryMessages=function(e,n,r,i){return n===void 0&&(n=20),r===void 0&&(r=0),i===void 0&&(i=0),this._engine.getChatroomHistoryMessages(e,i,n,r)},t.prototype.getFileToken=function(e,n,r,i){return x(this,void 0,void 0,function(){var o,s,c,d,l,h,a;return B(this,function(u){switch(u.label){case 0:return o=this.getInfoFromCache(),s=(o==null?void 0:o.bosAddr)||"",c=(o==null?void 0:o.uploadServer)||"",d=(o==null?void 0:o.ossConfig)||"",[4,this._engine.getFileToken(e,n,r,i)];case 1:return l=u.sent(),h=l.code,a=l.data,h===N.SUCCESS?[2,Promise.resolve(Object.assign(a,{bos:s,qiniu:c,ossConfig:d}))]:[2,Promise.reject(h)]}})})},t.prototype.getFileUrl=function(e,n,r,i,o){return o===void 0&&(o=Je.QINIU),x(this,void 0,void 0,function(){var s,c,d;return B(this,function(l){switch(l.label){case 0:return(i==null?void 0:i.isBosRes)?[2,Promise.resolve(i)]:[4,this._engine.getFileUrl(e,o,n,r)];case 1:return s=l.sent(),c=s.code,d=s.data,c===N.SUCCESS?[2,Promise.resolve(d)]:[2,Promise.reject(c)]}})})},t.prototype.createTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.createTag(e)]})})},t.prototype.removeTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.removeTag(e)]})})},t.prototype.updateTag=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.updateTag(e)]})})},t.prototype.getTagList=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getTagList()]})})},t.prototype.addTagForConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return n.length>1e3?[2,Promise.reject(N.CONVER_OUT_LIMIT_ERROR)]:[2,this._engine.addTagForConversations(e,n)]})})},t.prototype.removeTagForConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagForConversations(e,n)]})})},t.prototype.removeTagsForConversation=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.removeTagsForConversation(e,n)]})})},t.prototype.getConversationListByTag=function(e,n,r,i){return x(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.getConversationListByTag(e,n,r,i)]})})},t.prototype.getUnreadCountByTag=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.getUnreadCountByTag(e,n)]})})},t.prototype.setConversationStatusInTag=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setConversationStatusInTag(e,n,r)]})})},t.prototype.getTagsForConversation=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getTagsForConversation(e)]})})},t.prototype.getBlockConversationList=function(){return this._engine.getBlockConversationList()},t.prototype.getTopConversationList=function(){return this._engine.getTopConversationList()},t.prototype.getUnreadMentionedCount=function(e){return this._engine.getUnreadMentionedCount(e)},t.prototype.getAllUnreadMentionedCount=function(){return this._engine.getAllUnreadMentionedCount()},t.prototype.callExtra=function(e){for(var n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(n=this._engine).callExtra.apply(n,Kt([e],r))},t.prototype.clearConversations=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){switch(r.label){case 0:return[4,this._engine.clearConversations(e,n)];case 1:return[2,r.sent()]}})})},t.prototype.setUserStatusListener=function(e,n){return this._engine.setUserStatusListener(e,function(r){try{n(r)}catch(i){$.error(i)}})},t.prototype.addToBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.addToBlacklist(e)]})})},t.prototype.removeFromBlacklist=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.removeFromBlacklist(e)]})})},t.prototype.getBlacklist=function(){return x(this,void 0,void 0,function(){return B(this,function(e){return[2,this._engine.getBlacklist()]})})},t.prototype.getBlacklistStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getBlacklistStatus(e)]})})},t.prototype.insertMessage=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.insertMessage(e,n,r)]})})},t.prototype.deleteMessages=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.deleteMessages(e)]})})},t.prototype.deleteMessagesByTimestamp=function(e,n,r,i,o){return o===void 0&&(o=""),x(this,void 0,void 0,function(){return B(this,function(s){return[2,this._engine.deleteMessagesByTimestamp(e,n,r,i,o)]})})},t.prototype.clearMessages=function(e,n,r){return r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.clearMessages(e,n,r)]})})},t.prototype.getMessage=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getMessage(e)]})})},t.prototype.setMessageContent=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageContent(e,n,r)]})})},t.prototype.setMessageSearchField=function(e,n,r){return x(this,void 0,void 0,function(){return B(this,function(i){return[2,this._engine.setMessageSearchField(e,n,r)]})})},t.prototype.setMessageSentStatus=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageSentStatus(e,n)]})})},t.prototype.setMessageReceivedStatus=function(e,n){return x(this,void 0,void 0,function(){return B(this,function(r){return[2,this._engine.setMessageReceivedStatus(e,n)]})})},t.prototype.setUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.setUserStatus(e)]})})},t.prototype.subscribeUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.subscribeUserStatus(e)]})})},t.prototype.getUserStatus=function(e){return x(this,void 0,void 0,function(){return B(this,function(n){return[2,this._engine.getUserStatus(e)]})})},t.prototype.searchConversationByContent=function(e,n,r,i){return n===void 0&&(n=[]),r===void 0&&(r=""),x(this,void 0,void 0,function(){return B(this,function(o){return[2,this._engine.searchConversationByContent(e,n,r,i)]})})},t.prototype.searchMessageByContent=function(e,n,r,i,o,s,c){return c===void 0&&(c=""),x(this,void 0,void 0,function(){return B(this,function(d){return[2,this._engine.searchMessageByContent(e,n,r,i,o,s,c)]})})},t.prototype.getUnreadMentionedMessages=function(e,n,r){return r===void 0&&(r=""),this._engine.getUnreadMentionedMessages(e,n,r)},t.prototype.clearUnreadCountByTimestamp=function(e,n,r,i){return i===void 0&&(i=""),this._engine.clearUnreadCountByTimestamp(e,n,r,i)},t.prototype.getConversationNotificationStatus=function(e,n,r){return r===void 0&&(r=""),this._engine.getConversationNotificationStatus(e,n,r)},t.prototype.getRemoteHistoryMessages=function(e,n,r,i,o,s){return this._engine.getRemoteHistoryMessages(e,n,r,i,o,s)},t.prototype.getConversationListWithAllChannel=function(){return this._engine.getConversationListWithAllChannel()},t.prototype.getConversationListWithAllChannelByPage=function(e,n){return this._engine.getConversationListWithAllChannelByPage(e,n)},t.prototype.joinRTCRoom=function(e,n,r,i){return this._engine.joinRTCRoom(e,n,r,i)},t.prototype.quitRTCRoom=function(e){return this._engine.quitRTCRoom(e)},t.prototype.rtcPing=function(e,n,r){return this._engine.rtcPing(e,n,r)},t.prototype.getRTCRoomInfo=function(e){return this._engine.getRTCRoomInfo(e)},t.prototype.getRTCUserInfoList=function(e){return this._engine.getRTCUserInfoList(e)},t.prototype.getRTCUserInfo=function(e){return this._engine.getRTCUserInfo(e)},t.prototype.setRTCUserInfo=function(e,n,r){return this._engine.setRTCUserInfo(e,n,r)},t.prototype.removeRTCUserInfo=function(e,n){return this._engine.removeRTCUserInfo(e,n)},t.prototype.setRTCData=function(e,n,r,i,o,s){return this._engine.setRTCData(e,n,r,i,o,s)},t.prototype.setRTCTotalRes=function(e,n,r,i,o){return o===void 0&&(o=""),this._engine.setRTCTotalRes(e,n,r,i,o)},t.prototype.setRTCCDNUris=function(e,n,r){return this._engine.setRTCCDNUris(e,n,r)},t.prototype.getRTCData=function(e,n,r,i){return this._engine.getRTCData(e,n,r,i)},t.prototype.removeRTCData=function(e,n,r,i,o){return this._engine.removeRTCData(e,n,r,i,o)},t.prototype.setRTCOutData=function(e,n,r,i){return this._engine.setRTCOutData(e,n,r,i)},t.prototype.getRTCOutData=function(e,n){return this._engine.getRTCOutData(e,n)},t.prototype.getRTCToken=function(e,n,r){return this._engine.getRTCToken(e,n,r)},t.prototype.setRTCState=function(e,n){return this._engine.setRTCState(e,n)},t.prototype.getRTCUserList=function(e){return this._engine.getRTCUserList(e)},t.prototype.joinLivingRoomAsAudience=function(e,n,r){return this._engine.joinLivingRoomAsAudience(e,n,r)},t.prototype.quitLivingRoomAsAudience=function(e){return this._engine.quitLivingRoomAsAudience(e)},t.prototype.rtcIdentityChange=function(e,n,r){return this._engine.rtcIdentityChange(e,n,r)},t.prototype.getRTCJoinedUserInfo=function(e){return this._engine.getRTCJoinedUserInfo(e)},t.prototype.requestRoomPK=function(e){return this._engine.requestRoomPK(e)},t.prototype.cancelRoomPK=function(e){return this._engine.cancelRoomPK(e)},t.prototype.responseRoomPK=function(e){return this._engine.responseRoomPK(e)},t.prototype.endRoomPK=function(e){return this._engine.endRoomPK(e)},t}();(function(t){t[t.add=1]="add",t[t.update=2]="update",t[t.delete=3]="delete"})(Xa||(Xa={}));/*! *****************************************************************************
  797. Copyright (c) Microsoft Corporation.
  798. Permission to use, copy, modify, and/or distribute this software for any
  799. purpose with or without fee is hereby granted.
  800. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  801. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  802. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  803. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  804. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  805. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  806. PERFORMANCE OF THIS SOFTWARE.
  807. ***************************************************************************** */var Bo=function(t,e){return Bo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Bo(t,e)},Vo=function(){return Vo=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Vo.apply(this,arguments)};function er(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}function tr(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(d){return function(l){return function(h){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=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 s.label++,{value:h[1],done:!1};case 5:s.label++,r=h[1],h=[0];continue;case 7:h=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||h[0]!==6&&h[0]!==2)){s=0;continue}if(h[0]===3&&(!i||h[1]>i[0]&&h[1]<i[3])){s.label=h[1];break}if(h[0]===6&&s.label<i[1]){s.label=i[1],i=h;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(h);break}i[2]&&s.ops.pop(),s.trys.pop();continue}h=e.call(t,s)}catch(a){h=[6,a],r=0}finally{n=i=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([d,l])}}}var Ge=new Ut("RCIM"),ar=function(){return!(typeof uni=="undefined"||!function(t){for(var e=["canIUse","getSystemInfo"],n=0,r=e.length;n<r;n++)if(!t[e[n]])return!1;return!0}(uni))},Dh=ar(),we,Za={tag:"browser",httpReq:function(t){var e=t.method||pt.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=yi(t.url,i);return new Promise(function(c){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,s),r&&l.setRequestHeader)for(var a in r)l.setRequestHeader(a,r[a]);if(h){l.timeout=n,l.onload=function(){c({data:l.responseText,status:l.status||200})},l.onerror=function(){c({status:l.status||0})},l.ontimeout=function(){c({status:l.status||0})};var u=typeof o=="object"?JSON.stringify(o):o;l.send(u)}else l.onreadystatechange=function(){l.readyState===4&&c({data:l.responseText,status:l.status})},l.onerror=function(){c({status:l.status||0})},setTimeout(function(){return c({status:l.status||0})},n),l.send(o)})},localStorage:window==null?void 0:window.localStorage,sessionStorage:window==null?void 0:window.sessionStorage,isSupportSocket:function(){var t=typeof WebSocket!="undefined";return t||Ge.warn("websocket not support"),t},useNavi:!0,connectPlatform:"",isFromUniapp:Dh,createWebSocket:function(t,e){var n=new WebSocket(t,e);return n.binaryType="arraybuffer",{onClose:function(r){n.onclose=function(i){var o=i.code,s=i.reason;r(o,s)}},onError:function(r){n.onerror=r},onMessage:function(r){n.onmessage=function(i){r(i.data)}},onOpen:function(r){n.onopen=r},send:function(r){n.send(r)},close:function(r,i){n.close(r,i)}}},createDataChannel:function(t,e){return this.isSupportSocket()&&e==="websocket"?new vn(this,t):new yn(this,t)}},xh=ar(),Er=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return wx[t].apply(wx,e)}catch(r){Ge.error(r)}}},ec={setItem:Er("setStorageSync"),getItem:Er("getStorageSync"),removeItem:Er("removeStorageSync"),clear:Er("clearStorageSync")},tc={tag:"wechat",httpReq:function(t){var e=t.method||pt.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=yi(t.url,i);return new Promise(function(c){wx.request({url:s,method:e,headers:r,timeout:n,data:o,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:ec,sessionStorage:ec,isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:xh,createWebSocket:function(t,e){var n=wx.connectSocket({url:t,protocols:e});return{onClose:function(r){n.onClose(function(i){r(i.code,i.reason)})},onError:function(r){n.onError(function(i){r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){r(i.data)})},onOpen:function(r){n.onOpen(r)},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new vn(this,t):new yn(this,t)}},Bh=ar(),Rr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return my[t].apply(my,e)}catch(r){Ge.error(r)}}},nc={setItem:Rr("setStorageSync"),getItem:Rr("getStorageSync"),removeItem:Rr("removeStorageSync"),clear:Rr("clearStorageSync")},rc={tag:"alipay",httpReq:function(t){var e=t.method||pt.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=yi(t.url,i),c=t.dataType||"json";return new Promise(function(d){my.request({url:s,method:e,headers:r,timeout:n,data:o,dataType:c,success:function(l){d({data:l.data,status:l.status})},fail:function(){d({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:nc,sessionStorage:nc,isSupportSocket:function(){return!1},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Bh,createDataChannel:function(t,e){return e==="websocket"?new vn(this,t):new yn(this,t)}},Vh=ar(),Tr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return console.log("tt",tt),tt[t].apply(tt,e)}catch(r){Ge.error(r)}}},ic={setItem:Tr("setStorageSync"),getItem:Tr("getStorageSync"),removeItem:Tr("removeStorageSync"),clear:Tr("clearStorageSync")},oc={tag:"toutiao",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Vh,localStorage:ic,sessionStorage:ic,httpReq:function(t){return new Promise(function(e,n){tt.request({url:t.url,data:t.body,header:t.headers,method:t.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},o={data:JSON.stringify(i),status:r.statusCode};e(o)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errMsg),n({data:r.errMsg})}})})},createWebSocket:function(t,e){var n=tt.connectSocket({url:t,protocols:e});return{onOpen:function(r){n.onOpen(r)},onClose:function(r){n.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){n.onError(function(i){return r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){return r(i.data)})},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new vn(this,t):new yn(this,t)}},Fh=ar(),Sr=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return console.log("swan",swan),swan[t].apply(swan,e)}catch(r){Ge.error(r)}}},sc={setItem:Sr("setStorageSync"),getItem:Sr("getStorageSync"),removeItem:Sr("removeStorageSync"),clear:Sr("clearStorageSync")},ac={tag:"baidu",isSupportSocket:function(){return!0},useNavi:!1,connectPlatform:"MiniProgram",isFromUniapp:Fh,localStorage:sc,sessionStorage:sc,httpReq:function(t){return new Promise(function(e,n){swan.request({url:t.url,data:t.body,header:t.headers,method:t.method,success:function(r){console.log("\u8C03\u7528\u6210\u529F",r.data);var i=(r==null?void 0:r.data)||{},o={data:JSON.stringify(i),status:r.statusCode};e(o)},fail:function(r){console.log("\u8C03\u7528\u5931\u8D25",r.errorCode),n({data:r.errorCode})}})})},createWebSocket:function(t,e){var n=swan.connectSocket({url:t,protocols:e});return{onOpen:function(r){n.onOpen(r)},onClose:function(r){n.onClose(function(i){return r(i.code,i.reason)})},onError:function(r){n.onError(function(i){return r(i.errMsg)})},onMessage:function(r){n.onMessage(function(i){return r(i.data)})},send:function(r){n.send({data:r})},close:function(r,i){n.close({code:r,reason:i})}}},createDataChannel:function(t,e){return e==="websocket"?new vn(this,t):new yn(this,t)}},Ir=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return uni[t].apply(uni,e)}catch(r){Ge.error(r)}}},cc={setItem:Ir("setStorageSync"),getItem:Ir("getStorageSync"),removeItem:Ir("removeStorageSync"),clear:Ir("clearStorageSync")},Hh={tag:"uniapp",httpReq:function(t){var e=t.method||pt.GET,n=t.timeout||6e4,r=t.headers,i=t.query,o=t.body,s=yi(t.url,i);return new Promise(function(c){uni.request({url:s,method:e,headers:r,timeout:n,data:o,success:function(d){c({data:d.data,status:d.statusCode})},fail:function(){c({status:N.RC_HTTP_REQ_TIMEOUT})}})})},localStorage:cc,sessionStorage:cc,isSupportSocket:function(){return!0},useNavi:!0,connectPlatform:"",isFromUniapp:!0,createWebSocket:function(t,e){var n={complete:function(){},url:t,protocols:e},r=uni.connectSocket(n);return{onClose:function(i){r.onClose(function(o){i(o.code,o.reason)})},onError:function(i){r.onError(function(o){i(o.errMsg)})},onMessage:function(i){r.onMessage(function(o){i(o.data)})},onOpen:function(i){r.onOpen(i)},send:function(i){r.send({data:i})},close:function(i,o){r.close({code:i,reason:o})}}},createDataChannel:function(t,e){return e==="websocket"?new vn(this,t):new yn(this,t)}},Pn=function(t){return t&&t.canIUse&&t.getSystemInfo},jh=typeof uni!="undefined"&&Pn(uni)?function(){switch({}.VUE_APP_PLATFORM){case"app-plus":return Hh;case"mp-baidu":return ac;case"mp-toutiao":return oc;case"mp-alipay":return rc;case"mp-weixin":return tc;default:return Za}}():typeof wx!="undefined"&&Pn(wx)?tc:typeof my!="undefined"&&Pn(my)?rc:typeof tt!="undefined"&&Pn(tt)?oc:typeof swan!="undefined"&&Pn(swan)?ac:Za;function ri(t){var e=t.conversationType,n=t.channelId,r=t.messageType,i=t.content,o=t.senderUserId,s=t.targetId,c=t.sentTime,d=t.receivedTime,l=t.messageUId,h=t.messageDirection,a=t.isPersited,u=t.isCounted,f=t.isOffLineMessage,p=t.canIncludeExpansion,m=t.expansion,_=t.receivedStatus,v=t.disableNotification,y=t.isMentioned,C=t.isStatusMessage,I=t.readReceiptInfo,P=t.pushConfig,b=t.messageId;return _||(_=Gn.UNREAD),{messageType:r,channelId:n||"",content:i,senderUserId:o,targetId:s,conversationType:e,sentTime:c,receivedTime:d,messageUId:l,messageDirection:h,isPersited:a,isCounted:u,isOffLineMessage:f,isMentioned:y,disableNotification:v,isStatusMessage:C,canIncludeExpansion:p,expansion:m,receivedStatus:_,readReceiptInfo:I,pushConfig:P,messageId:b}}(function(t){t.CONNECTING="CONNECTING",t.CONNECTED="CONNECTED",t.DISCONNECT="DISCONNECT",t.SUSPEND="SUSPEND",t.MESSAGES="MESSAGES",t.READ_RECEIPT_RECEIVED="READ_RECEIPT_RECEIVED",t.MESSAGE_RECEIPT_REQUEST="MESSAGE_RECEIPT_REQUEST",t.MESSAGE_RECEIPT_RESPONSE="MESSAGE_RECEIPT_RESPONSE",t.CONVERSATION="CONVERSATION",t.CHATROOM="CHATROOM",t.EXPANSION="EXPANSION",t.PULL_OFFLINE_MESSAGE_FINISHED="PULL_OFFLINE_MESSAGE_FINISHED",t.TAG="TAG",t.CONVERSATION_TAG="CONVERSATION_TAG",t.TYPING_STATUS="TYPING_STATUS",t.MESSAGE_BLOCKED="MESSAGE_BLOCKED"})(we||(we={}));var cn,dt=function(t){function e(n){var r=t.call(this)||this;if(e.imClient)return Ge.error("Please do not repeatedly perform the init method"),e.imClient;De("options.navigators",n.navigators,function(o){return We(o)&&(o.length===0||o.every(Yn))});var i=n==null?void 0:n.connectType;return i?Nt.WEBSOCKET!==i&&Nt.COMET!==i&&(Ge.warn("RongIMLib connectionType must be "+Nt.WEBSOCKET+" or "+Nt.COMET),i=Nt.WEBSOCKET):i=Nt.WEBSOCKET,r._context=Uh.init(jh,{appkey:n.appkey,apiVersion:"5.1.1",navigators:n.navigators||[],miniCMPProxy:n.customCMP||[],connectionType:i,logLevel:n.logLevel,logStdout:n.logStdout,indexDBSwitch:n.indexDBSwitch,checkCA:n.checkCA}),r.watch(),e.imClient=r,r}return function(n,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=n}Bo(n,r),n.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}(e,t),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 n=this,r={onConnecting:function(){n.emit(we.CONNECTING)},onConnected:function(){n.emit(we.CONNECTED)},onDisconnect:function(){n.emit(we.DISCONNECT)},onSuspend:function(){n.emit(we.SUSPEND)},batchMessage:function(i){n.emit(we.MESSAGES,{messages:i.map(function(o){return ri(o)})})},typingState:function(i){n.emit(we.TYPING_STATUS,{status:i})},readReceiptReceived:function(i,o,s){n.emit(we.READ_RECEIPT_RECEIVED,{conversation:i,messageUId:o,sentTime:s})},messageReceiptRequest:function(i,o,s){n.emit(we.MESSAGE_RECEIPT_REQUEST,{conversation:i,messageUId:o,senderUserId:s})},messageReceiptResponse:function(i,o,s){n.emit(we.MESSAGE_RECEIPT_RESPONSE,{conversation:i,receivedUserId:o,messageUIdList:s})},conversationState:function(i){var o=i.map(function(s){return{conversation:{conversationType:s.conversationType,latestMessage:s.latestMessage?ri(s.latestMessage):null,targetId:s.targetId,unreadMessageCount:s.unreadMessageCount,hasMentioned:s.hasMentioned,mentionedInfo:s.mentionedInfo,lastUnreadTime:s.lastUnreadTime,notificationStatus:s.notificationStatus,isTop:s.isTop,channelId:s.channelId,unreadMentionedCount:s.unreadMentionedCount},updatedItems:s.updatedItems}});n.emit(we.CONVERSATION,{conversationList:o})},chatroomState:function(i){n.emit(we.CHATROOM,i)},expansion:function(i){n.emit(we.EXPANSION,i)},pullFinished:function(){n.emit(we.PULL_OFFLINE_MESSAGE_FINISHED)},tag:function(){n.emit(we.TAG)},conversationTagChanged:function(){n.emit(we.CONVERSATION_TAG)},messageBlocked:function(i){n.emit(we.MESSAGE_BLOCKED,i)}};this.context.assignWatcher(r)},e}(ir),ii={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:N.NOT_SUPPORT,msg:"The method is not supported in a browser!"}},un={},$h={};for(var uc in ii){var dc=ii[uc],lc=dc.code;un[lc]=uc,$h[lc]=dc}ii.ROAMING_SERVICE_UNAVAILABLE.code;var Kh=function(t){cn=cn||new dt(t)};function qh(t,e){return cn==null?void 0:cn.context.install(t,e)}function Gh(t){return er(this,void 0,void 0,function(){var e;return tr(this,function(n){switch(n.label){case 0:return De("token",t,Ae.STRING,!0),Ge.warn("RongIMLib Version: 5.1.1, Commit: 756868a83166be55e30e49e5685b1644456ea30f"),[4,cn.context.connect(t,!0)];case 1:return(e=n.sent()).code===N.SUCCESS?[2,{code:e.code,data:{userId:e.userId}}]:[2,{code:e.code,msg:un[e.code]}]}})})}function cr(t,e,n){cn.on(t,e,n)}function Yh(t,e){return er(this,void 0,void 0,function(){var n,r;return tr(this,function(i){switch(i.label){case 0:return De("options.count",e.count,Ae.NUMBER,!0),n="id:"+t,Ge.debug("join chatroom ->"+n),[4,dt.imClient.context.joinChatroom(t,e.count)];case 1:return(r=i.sent())!==N.SUCCESS?(Ge.warn("join chatroom fail ->code+:"+un[r]+","+n),[2,{code:r,msg:un[r]}]):[2,{code:r}]}})})}var Vu=function(t,e,n,r){n===void 0&&(n=!0),r===void 0&&(r=!0),this.messageType=t,this.content=e,this.isPersited=n,this.isCounted=r};function ct(t,e,n){return e===void 0&&(e=!0),n===void 0&&(n=!0),function(r){return new Vu(t,r,e,n)}}var Fu,Fo,Jh=ct("RC:ImgMsg"),Wh=ct("RC:HQVCMsg"),zh=ct("RC:SightMsg"),Qh=ct("RC:TxtMsg"),Xh=ct("RC:CombineMsg"),Zh=ct("RC:FileMsg");ct("RC:GIFMsg");ct("RC:VcMsg");ct("RC:LBSMsg");ct("RC:ReferenceMsg");ct("RC:ImgTextMsg");var Xt={qiniu:function(t,e,n,r){var i,o="https://"+e.uploadHost.qiniu;i=Ln()+ve[0][1]||o,ve.shift();var s=new XMLHttpRequest;s.upload&&e.support_options&&(s.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),s.onreadystatechange=function(){if(s.readyState===4){var c=s.responseText||"{}";(c=JSON.parse(c)).filename=e.uniqueValue,c.uploadMethod=Je?Je.QINIU:"",s.status===200?n.onCompleted(c):ve.length?Xt[ve[0][0]](t,e,n,r):n.onError("upload fail")}},e.isChunk&&(i=function(c,d){var l="";return fc(d,function(h,a){h!=="token"&&(l+=(l?"&":"")+encodeURIComponent(h)+"="+encodeURIComponent(a))}),l&&(c+=(c.indexOf("?")>0?"&":"?")+l),c}(i+="/mkblk/"+t.size,e.multi_parmas)),s.open(e.method,i,!0),n.onOpen(s),e.stream&&s.setRequestHeader("authorization","UpToken "+e.multi_parmas.token),fc(e.headers,function(c,d){s.setRequestHeader(c,d)}),s.send(t)},baidu:function(t,e,n,r){if(console.log(r,e),r.size>hc)throw new Error("the file size is over 5GB!");var i=e||{};e=e||Fo;var o=new XMLHttpRequest,s=Ln();if(!(!i.uploadHost.bos&&!i.bosUploadPath)){var c=s+ve[0][1]+i.bosUploadPath;ve.shift();var d=i.bosHeader||{},l={filename:e.uniqueValue||r.uniqueName,name:r.name,downloadUrl:c,isBosRes:!0};o.upload&&e.support_options&&(o.upload.onprogress=function(h){n.onProgress(h.loaded,h.total,!0)}),o.onreadystatechange=function(){if(o.readyState===4){var h=o.responseText||"{}";(h=JSON.parse(h)).filename=e.uniqueValue,o.status===200?n.onCompleted(l,!0):ve.length?Xt[ve[0][0]](t,e,n,r):n.onError("upload fail")}},o.open(e.method,c,!0),o.setRequestHeader("authorization",d.bosToken),o.setRequestHeader("x-bce-date",d.bosDate),o.send(r)}},aliyun:function(t,e,n,r){if(r.size>hc)throw new Error("the file size is over 5GB!");const i=new FormData;i.set("file",t.get("file")),i.set("key",t.get("key")),i.set("token",t.get("token"));const o=ve[0][1];ve.shift(),t=t||Fu,e=(e=e||{})||Fo;var s=new XMLHttpRequest,c=Ln()+e.ossBucketName+"."+o;s.upload&&e.support_options&&(s.upload.onprogress=function(l){n.onProgress(l.loaded,l.total)}),s.onreadystatechange=function(){if(s.readyState===4){var l=s.responseText||"{}";(l=JSON.parse(l)).name=e.uniqueValue,l.filename=e.uploadFileName,l.uploadMethod=Je?Je.ALI:"",s.status===200?n.onCompleted(l):ve.length?Xt[ve[0][0]](i,e,n,r):n.onError("upload fail")}},s.open(e.method,c,!0),console.log("ali:url",c);var d=e.aliHeader||{};t.set("OSSAccessKeyId",d.osskeyId),t.set("policy",d.ossPolicy),t.set("Signature",d.ossSign),t.set("success_action_status",200),t.delete("key"),t.append("key",e.uploadFileName),t.delete("file"),t.append("file",r),s.send(t)},s3:function(t,e,n,r){var i=new FormData,o=new XMLHttpRequest,s=Ln();const c=ve[0][1];var d=s+e.s3BucketName+"."+c;console.log("uploadS3:url",d),ve.shift(),o.upload&&e.support_options&&(o.upload.onprogress=function(a){n.onProgress(a.loaded,a.total)}),o.onreadystatechange=function(){if(o.readyState===4){var a=o.responseText||"{}";if((a=JSON.parse(a)).name=e.uniqueValue,a.filename=e.uploadFileName,a.uploadMethod=Je.AWS,console.log("UploadMethod:",Je),o.status===200||o.status===204)n.onCompleted(a);else if(ve.length){const u=new FormData;u.set("file",t.get("file")),u.set("key",t.get("key")),u.set("token",t.get("token")),Xt[ve[0][0]](u,e,n,r)}else n.onError("upload fail")}},o.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),o.send(i)},stc:function(t,e,n,r){new FormData;var i=new XMLHttpRequest;Ln();var o="https://"+ve[0][1]+"/"+e.stcBucketName+"/"+e.uploadFileName;ve.shift(),i.upload&&e.support_options&&(i.upload.onprogress=function(c){n.onProgress(c.loaded,c.total)}),i.onreadystatechange=function(){if(i.readyState===4){var c=i.responseText||"{}";if((c=JSON.parse(c)).name=e.uniqueValue,c.filename=e.uploadFileName,c.uploadMethod=Je?Je.STC:"",i.status===200||i.status===204)n.onCompleted(c);else if(ve.length){const d=new FormData;d.set("file",t.get("file")),d.set("key",t.get("key")),d.set("token",t.get("token")),Xt[ve[0][0]](d,e,n,r)}else n.onError("upload fail")}},i.open("PUT",o,!0);var s=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",s.stcAuthorization),i.setRequestHeader("x-amz-content-sha256",s.stcContentSha256),i.setRequestHeader("x-amz-date",s.stcDate),i.send(r)}},ve=[],hc=5368709120;function fc(t,e){for(var n in t)e(n,t[n])}function Ln(){var t="https://";return location.protocol!=="http:"&&location.protocol!=="file:"||(t="http://"),t}function ef(t,e,n){var r,i,o=t&&t.type||"text/plain",s=o.indexOf("image")>-1?1:4,c=Math.ceil(t.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";dt.imClient.getFileToken(s,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),o==="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",o),_.send(),_.onreadystatechange=function(v){if(_.readyState===4){var y=_.response.match(/(?:<UploadId>)(\S*?)(?:<\/UploadId>)/);console.log("uploadId",y),_.status===200||_.status===204?function(C){for(var I=[],P=1;P<=c;P++)I.push(p(C,P));f(C,I)}(Array.isArray(y)&&y[1]):n.onError("uploadStcMultipart:did not get uploadId")}}},function(m){n.onError("uploadStcMultipart:"+m)});var a=[],u=new Map;function f(m,_){_&&Array.isArray(_)&&_.length!==0&&Promise.all(_).then(()=>{var v="uploadId="+m;if(u.size===c)dt.imClient.context.getFileToken(s,r,"POST",v).then(function(I){console.log("onSuccess",I),console.log("onSuccess:uploadId",m);var P=new XMLHttpRequest;P.open("POST",i+"?"+v,!0),P.setRequestHeader("Authorization",I&&I.stcAuthorization),P.setRequestHeader("x-amz-content-sha256",I&&I.stcContentSha256),P.setRequestHeader("x-amz-date",I&&I.stcDate),P.setRequestHeader("Content-Type",o);var b="<CompleteMultipartUpload xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>",R=Array.from(u.keys()||[]).sort((M,F)=>M-F);console.log("keys",R),R.map(M=>{b+=`<Part><ETag>${u.get(M)}</ETag><PartNumber>${M}</PartNumber></Part>`}),b+="</CompleteMultipartUpload>",P.send(b),console.log("xml",b),P.onreadystatechange=function(){if(P.readyState===4)if(P.status===200||P.status===204){var M={};M.name=t.name,M.filename=e.uploadFileName,M.uploadMethod=Je.STC,n.onCompleted(M)}else n.onError("uploadStcMultipart:upload does not end")}},function(I){n.onError("uploadStcMultipart:"+I)});else{var y=[];for(var C of a)y.push(p(m,C));f(m,y)}},v=>{console.error(v),n.onError("uploadStcMultipart: chunkFiles upload failed and those will reupload");var y=[];for(var C of a)y.push(p(m,C));f(m,y)})}function p(m,_){return new Promise((v,y)=>{var C="partNumber="+_+"&uploadId="+m;dt.imClient.context.getFileToken(s,r,"PUT",C).then(function(I){console.log("signature "+_+" onSuccess",I);var P=t&&t.slice((_-1)*e.stc_chunk_size,_*e.stc_chunk_size);console.log("fileChunk:size",P.size);var b=new XMLHttpRequest;b.open("PUT",i+"?"+C,!0),b.setRequestHeader("Authorization",I&&I.stcAuthorization),b.setRequestHeader("x-amz-content-sha256",I&&I.stcContentSha256),b.setRequestHeader("x-amz-date",I&&I.stcDate),b.setRequestHeader("Content-Type",o),b.send(P),b.onreadystatechange=function(){if(b.readyState===4)if(b.status===200||b.status===204){var R=b.getResponseHeader("etag");console.log("etag:"+_,R),u.set(_,R),v(R)}else a.includes(_)||a.push(_),y(_)}},function(I){console.log("getETags:\u7B7E\u540D\u9A8C\u8BC1\u5931\u8D25"),a.includes(_)||a.push(_),y(_)})})}}var Hu={form:function(t,e){var n=new FormData;if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Ho()+r;n.append(e.unique_key,i),e.uniqueValue=i}return n.append(e.file_data_name,t),jo(e.multi_parmas,function(o,s){n.append(o,s)}),n},json:function(t,e){var n={};if(e.unique_key){var r=t.name.substr(t.name.lastIndexOf(".")),i=Ho()+r;n[e.unique_key]=i,e.uniqueValue=i}return n[e.file_data_name]=t,jo(e.multi_parmas,function(o,s){n[o]=s}),JSON.stringify(n)},data:function(t,e){return t}};function Ho(){var t=new Date().getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),(e==="x"?n:3&n|8).toString(16)})}function jo(t,e){for(var n in t)e(n,t[n])}var br,Zi=0;function tf(t){this.options=function(e){var n={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:Hu.form,genUId:Ho};if(!e||!e.domain)throw new Error("domain is null");for(var r in e)n[r]=e[r];return n}(t),this.setOptions=function(e){var n=this;jo(e,function(r,i){n.options[r]=i})},console.log("options",t),this.upload=function(e,n){if(e){var r=this;(function(i,o,s){if(Fu=i,Fo=o,ve=[],o.ossConfig){const h=JSON.parse(o.ossConfig);let a,u,f="";const p=[];h.forEach(m=>{const _=Number(m.p)-1;for(const v in m)v==="aliyun"&&(f=m[v]),v==="s3"&&(a=m[v]),v==="stc"&&(u=m[v]),v!=="p"&&(p[_]=[v,m[v]])}),p.forEach(function(m){m&&ve.push(m)}),h.length!==ve.length&&(ve=[["qiniu",o.domain],["baidu",o.uploadHost.bos],["aliyun",f],["s3",a],["stc",u]])}else ve=[["qiniu",o.domain],["baidu",o.uploadHost.bos]];var c;if(o.ossConfig){var d=o&&JSON.parse(o.ossConfig);Array.isArray(d)||(d=[]),c=d.find(h=>Object.keys(h).includes("stc"))}if(c&&parseInt(c.p)===1&&i.size>=4194304)ef(i,o,s);else{var l=o.data(i,o);Xt[ve[0][0]](l,o,s,i)}})(e,this.options,{onProgress:function(i,o,s){br=i,s?br=Zi+i/o*(o-Zi):Zi=br,n.onProgress(br,o)},onCompleted:function(i){n.onCompleted(i)},onError:function(i){n.onError(i)},onOpen:function(i){r.xhr=i}})}else n.onError("upload file is null.")},this.cancel=function(){this.xhr&&this.xhr.abort()}}var pc={init:function(t){return new tf(t)},dataType:Hu,resize:function(t,e,n){t.type;var r=document.createElement("canvas"),i=new FileReader;i.readAsDataURL(t),i.onload=function(o){var s=o.target.result,c=new Image;c.src=s;var d=c.width,l=c.height,h=function(u,f){var p=1,m=u.width,_=f.maxWidth||0;_>0&&m>_&&(p=_/m);var v=u.height,y=f.maxHeight||0;if(y>0&&v>y){var C=y/v;p=Math.min(p,C)}var I=f.maxSize||0,P=Math.ceil(u.size/1e3);if(P>I){var b=I/P;p=Math.min(p,b)}return p}({width:d,height:l,size:o.total},e),a=s;h<1&&(a=function(u,f,p){r.width=f,r.height=p,r.getContext("2d").drawImage(u,0,0,f,p);var m="image/jpg";return r.toDataURL(m)}(c,d*h,l*h)),n(a)}}};const nf=function(t,e,n){var r=document.createElement("canvas"),i=r.getContext("2d"),o=new Image;o.onload=function(){var s=function(l,h,a){var u,f,p,m=l<h,_=0,v=0;return(m?h/l:l/h)>a.scale?(m?(f=100,v=((p=h/(u=l/100))-a.maxHeight)/2):(p=100,_=((f=l/(u=h/100))-a.maxWidth)/2),{w:f,h:p,x:-_,y:-v}):(m?(u=h/a.maxHeight,p=a.maxHeight,f=l/u):(u=l/a.maxWidth,f=a.maxWidth,p=h/u),{w:f,h:p,x:-_,y:-v})}(o.width,o.height,e);r.width=s.w>e.maxWidth?e.maxWidth:s.w,r.height=s.h>e.maxHeight?e.maxHeight:s.h,i.drawImage(o,s.x,s.y,s.w,s.h);try{var c=r.toDataURL(t.type,e.quality),d=new RegExp("^data:image/[^;]+;base64,");c=c.replace(d,""),n(c)}catch(l){throw new Error(l)}},o.src=typeof t=="string"?"data:image/jpg;base64,"+t:function(s){var c=window.URL||window.webkitURL;return c?c.createObjectURL(s):""}(t)},rf=function(t,e){var n=t.file,r=t.compress;nf(n,r,e)},ju=function(t,e){if(t.getToken)t.getToken(function(r,i){i=i||{},t.multi_parmas||(t.multi_parmas={}),t.multi_parmas.token=r,t.uploadHost||(t.uploadHost={}),t.uploadHost.bos=i.bos,t.ossConfig=i.ossConfig,t.bosHeader||(t.bosHeader={}),t.bosHeader.bosDate=i.bosDate,t.bosHeader.bosToken=i.bosToken,t.bosUploadPath=i.path,t.aliHeader={},t.aliHeader.osskeyId=i.osskeyId,t.aliHeader.ossPolicy=i.ossPolicy,t.aliHeader.ossSign=i.ossSign,t.ossBucketName=i.ossBucketName,t.uploadFileName=i.fileName,t.s3Header={},t.s3Header.s3Credential=i.s3Credential,t.s3Header.s3Algorithm=i.s3Algorithm,t.s3Header.s3Date=i.s3Date,t.s3Header.s3Policy=i.s3Policy,t.s3Header.s3Signature=i.s3Signature,t.s3BucketName=i.s3BucketName,t.stcHeader={},t.stcHeader.stcAuthorization=i.stcAuthorization,t.stcHeader.stcContentSha256=i.stcContentSha256,t.stcHeader.stcDate=i.stcDate,t.stcBucketName=i.stcBucketName,t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream",t.headers.Authorization="UpToken "+r),console.log("data",i);var o=pc.init(t);e(o)});else{t.headers||(t.headers={}),t.base64&&(t.headers["Content-type"]="application/octet-stream");var n=pc.init(t);e(n)}};var eo,Nr,$u=function(t,e,n){e.upload(t.file,{onError:function(r){n.onError(r)},onProgress:function(r,i){n.onProgress(r,i)},onCompleted:function(r){r.filename||(r.filename=r.hash);var i=t.compressThumbnail||rf;t.compress?i(t,function(o){r.thumbnail=o,n.onCompleted(r)}):n.onCompleted(r)}})},of=function(t){var e=this;this.instance=t,this.upload=function(n,r){$u({file:n},e.instance,r)},this.cancel=function(){e.instance.cancel()}},sf=function(t,e){var n=this;this.cfg=e,this.instance=t,this.upload=function(r,i){var o={file:r,compress:n.cfg};$u(o,n.instance,i)},this.cancel=function(){n.instance.cancel()}},af=function(t,e){ju(t,function(n){var r={maxHeight:t.maxHeight||160,maxWidth:t.maxWidth||160,quality:t.quality||.5,scale:t.scale||2.4},i=new sf(n,r);e(i)})},cf=function(t,e){ju(t,function(n){var r=new of(n);e(r)})},uf=af;function gc(t){return eo=eo||new AudioContext,new Promise(function(e,n){eo.decodeAudioData(t,function(r){e({duration:r.duration,length:r.length})},n)})}function df(t,e,n,r,i){return De("fileType",t,kl,!0),De("filename",e,Ae.STRING),De("saveName",n,Ae.STRING),De("serverType",i,Ae.NUMBER),new Promise(function(o){dt.imClient.context.getFileUrl(t,e,n,r,i).then(function(s){o({code:N.SUCCESS,data:s})}).catch(function(s){o({code:s})})})}function Ku(t,e,n){return er(this,void 0,void 0,function(){var r,i,o,s,c,d,l,h,a;return tr(this,function(u){switch(u.label){case 0:return n=n||{},e instanceof Vu?(De("conversation.channelId",t==null?void 0:t.channelId,Ae.CHANNEL_ID),r=t.conversationType,i=t.targetId,o=t.channelId,s="conversationType:"+r+",targetId:"+i,Ge.debug("send message ->"+s),(c=Object.assign(n,e)).channelId=o||"",[4,dt.imClient.context.sendMessage(r,i,c)]):(Ge.warn("send message fail -> message parameter is not an instance of BaseMessage"),[2,ii.ILLGAL_PARAMS]);case 1:return d=u.sent(),l=d.code,h=d.data,l===N.SUCCESS?(a=ri(h),[2,{code:l,data:a}]):(Ge.warn("send message fail ->"+l+":"+un[l]+","+s),[2,{code:l,msg:un[l],data:ri({isMentioned:!!n.isMentioned,content:e.content,messageType:e.messageType,isPersited:e.isPersited||!1,isCounted:e.isCounted||!1,disableNotification:!!(n==null?void 0:n.disableNotification),canIncludeExpansion:!!(n==null?void 0:n.canIncludeExpansion),expansion:(n==null?void 0:n.expansion)||null,conversationType:r,targetId:i,channelId:o||"",senderUserId:dt.imClient.context.getCurrentUserId(),messageUId:"",messageDirection:st.SEND,isOffLineMessage:!1,sentTime:(h==null?void 0:h.sentTime)||0,receivedTime:0,isStatusMessage:n.isStatusMessage||!1,receivedStatus:Gn.UNREAD})}])}})})}function ur(t,e){return function(n,r,i,o){return new Promise(function(s){var c;(function(d,l,h,a){var u,f=this;if(l===void 0&&(l=Le.FILE),u=l===Le.IMAGE?Le.IMAGE:Le.FILE,!Nr){Nr="upload.qiniup.com";var p=dt.imClient.context.getInfoFromCache();if(p&&p.ossConfig)try{var m=JSON.parse(p.ossConfig).find(function(v){return v.qiniu!==void 0});m&&(Nr=m.qiniu)}catch{}}var _=Vo({domain:Nr,getToken:function(v){dt.imClient.context.getFileToken(u).then(function(y){v(y.token,y)}).catch(function(y){h.onFail(y)})}},a);(u===Le.IMAGE?uf:cf)(_,function(v){v.upload(d,{onProgress:function(y,C){var I,P=Math.floor(y/C*100);(I=h.onProgress)===null||I===void 0||I.call(h,P)},onCompleted:function(y){return er(f,void 0,void 0,function(){var C=this;return tr(this,function(I){return df(u,y.filename,y.name,y,y.uploadMethod).then(function(P){return er(C,void 0,void 0,function(){var b,R;return tr(this,function(M){return P.code!==0?(h.onFail(P),[2]):((b=P.data).type=d.type,b.name=y.name||y.filename,l===Le.AUDIO?(typeof d.arrayBuffer=="function"?d.arrayBuffer().then(gc).then(function(F){Object.assign(b,F),h.onSuccess(b)},function(){h.onSuccess(b)}):((R=new FileReader).onload=function(){R.result?gc(R.result).then(function(F){Object.assign(b,F),h.onSuccess(b)},function(){h.onSuccess(b)}):h.onSuccess(b)},R.onerror=function(){b.duration=0,h.onSuccess(b)},R.readAsArrayBuffer(d)),[2]):(u===Le.IMAGE&&(b.thumbnail=y.thumbnail),h.onSuccess(b),[2]))})})}).catch(function(P){h.onFail(P)}),[2]})})},onError:function(y){h.onFail(y)}})})})(r.file,t,{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);Ku(n,h,o).then(s)},onFail:function(d){s({code:N.UPLOAD_FILE_FAILED,msg:d||N[N.UPLOAD_FILE_FAILED]})}},((c=o)===null||c===void 0?void 0:c.thumbnailConfig)||{})})}}ur(Le.FILE,function(t,e){return new Zh({name:t.name,size:e.file.size,type:e.file.type,fileUrl:t.downloadUrl,user:e.user,extra:e.extra})});ur(Le.IMAGE,function(t,e){return new Jh({content:t.thumbnail,imageUri:t.downloadUrl,user:e.user,extra:e.extra})});ur(Le.AUDIO,function(t,e){return new Wh({remoteUrl:t.downloadUrl,duration:t.duration,type:t.type,user:e.user,extra:e.extra})});ur(Le.SIGHT,function(t,e){return new zh({sightUrl:t.downloadUrl,content:e.thumbnail,duration:e.duration,size:e.file.size||t.size,name:e.name||t.name,user:e.user,extra:e.extra})});function Mi(t,e,n,r){return De("messageType",t,Ae.STRING,!0),De("isPersited",e,Ae.BOOLEAN,!0),De("isCounted",n,Ae.BOOLEAN,!0),dt.imClient.context.registerMessageType(t,e,n,r),ct(t,e,n)}ur(Le.COMBINE_HTML,function(t,e){return new Xh({remoteUrl:t.downloadUrl,nameList:e.nameList,summaryList:e.summaryList,conversationType:e.conversationType,user:e.user,extra:e.extra})});qt.add("imlib","5.1.1"),qt.validEngine("~5.1.1")||Ge.error("The current engine version '"+qt.getInfo().engine+"' error\uFF0Cimlib required engine version at least '~5.1.1'.");/*! *****************************************************************************
  808. Copyright (c) Microsoft Corporation.
  809. Permission to use, copy, modify, and/or distribute this software for any
  810. purpose with or without fee is hereby granted.
  811. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  812. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  813. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  814. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  815. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  816. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  817. PERFORMANCE OF THIS SOFTWARE.
  818. ***************************************************************************** */function H(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(l){try{d(r.next(l))}catch(h){o(h)}}function c(l){try{d(r.throw(l))}catch(h){o(h)}}function d(l){var h;l.done?i(l.value):(h=l.value,h instanceof n?h:new n(function(a){a(h)})).then(s,c)}d((r=r.apply(t,e||[])).next())})}const O=new Ut("RCRTC");var w,$o;(function(t){t[t.SUCCESS=1e4]="SUCCESS",t[t.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",t[t.PARAMS_ERROR=50001]="PARAMS_ERROR",t[t.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",t[t.NOT_IN_ROOM=50003]="NOT_IN_ROOM",t[t.SERVICE_INVALID=50004]="SERVICE_INVALID",t[t.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",t[t.SIGNAL_ERROR=53001]="SIGNAL_ERROR",t[t.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",t[t.REQUEST_FAILED=53004]="REQUEST_FAILED",t[t.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",t[t.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",t[t.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",t[t.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",t[t.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",t[t.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",t[t.PERMISSION_DENIED=53012]="PERMISSION_DENIED",t[t.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",t[t.INVALID_TAGS=53014]="INVALID_TAGS",t[t.INVALID_USER_ID=53015]="INVALID_USER_ID",t[t.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",t[t.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",t[t.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",t[t.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",t[t.TRACK_NOT_READY=53020]="TRACK_NOT_READY",t[t.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",t[t.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",t[t.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",t[t.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",t[t.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",t[t.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",t[t.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",t[t.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",t[t.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",t[t.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM"})(w||(w={})),function(t){t[t.JOIN_REFUSED=40032]="JOIN_REFUSED"}($o||($o={}));class qu{constructor(){this.queue=[],this.locked=!1}checkToStart(){return H(this,void 0,void 0,function*(){if(this.queue.length===0||this.locked)return;this.locked=!0;const{resolve:e,task:n,reject:r}=this.queue.shift();let i;try{i=yield n(),e(i)}catch(o){r(o)}this.locked=!1,this.checkToStart()})}push(e){const n=new Promise((r,i)=>{this.queue.push({resolve:r,task:e,reject:i})});return this.checkToStart(),n}}const lf=new qu,be=t=>lf.push(t);let Gu=!0,Yu=!0;function kn(t,e,n){const r=t.match(e);return r&&r.length>=n&&parseInt(r[n],10)}function Cn(t,e,n){if(!t.RTCPeerConnection)return;const r=t.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(s,c){if(s!==e)return i.apply(this,arguments);const d=l=>{const h=n(l);h&&(c.handleEvent?c.handleEvent(h):c(h))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(c,d),i.apply(this,[s,d])};const o=r.removeEventListener;r.removeEventListener=function(s,c){if(s!==e||!this._eventMap||!this._eventMap[e])return o.apply(this,arguments);if(!this._eventMap[e].has(c))return o.apply(this,arguments);const d=this._eventMap[e].get(c);return this._eventMap[e].delete(c),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[s,d])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(s){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),s&&this.addEventListener(e,this["_on"+e]=s)},enumerable:!0,configurable:!0})}function hf(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Gu=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function ff(t){return typeof t!="boolean"?new Error("Argument type: "+typeof t+". Please use a boolean."):(Yu=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function oa(){if(typeof window=="object"){if(Gu)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Pi(t,e){Yu&&console.warn(t+" is deprecated, please use "+e+" instead.")}function mc(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ju(t){return mc(t)?Object.keys(t).reduce(function(e,n){const r=mc(t[n]),i=r?Ju(t[n]):t[n],o=r&&!Object.keys(i).length;return i===void 0||o?e:Object.assign(e,{[n]:i})},{}):t}function Ko(t,e,n){e&&!n.has(e.id)&&(n.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?Ko(t,t.get(e[r]),n):r.endsWith("Ids")&&e[r].forEach(i=>{Ko(t,t.get(i),n)})}))}function _c(t,e,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const o=[];return t.forEach(s=>{s.type==="track"&&s.trackIdentifier===e.id&&o.push(s)}),o.forEach(s=>{t.forEach(c=>{c.type===r&&c.trackId===s.id&&Ko(t,c,i)})}),i}const vc=oa;function Wu(t,e){const n=t&&t.navigator;if(!n.mediaDevices)return;const r=function(s){if(typeof s!="object"||s.mandatory||s.optional)return s;const c={};return Object.keys(s).forEach(d=>{if(d==="require"||d==="advanced"||d==="mediaSource")return;const l=typeof s[d]=="object"?s[d]:{ideal:s[d]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(a,u){return a?a+u.charAt(0).toUpperCase()+u.slice(1):u==="deviceId"?"sourceId":u};if(l.ideal!==void 0){c.optional=c.optional||[];let a={};typeof l.ideal=="number"?(a[h("min",d)]=l.ideal,c.optional.push(a),a={},a[h("max",d)]=l.ideal,c.optional.push(a)):(a[h("",d)]=l.ideal,c.optional.push(a))}l.exact!==void 0&&typeof l.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",d)]=l.exact):["min","max"].forEach(a=>{l[a]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(a,d)]=l[a])})}),s.advanced&&(c.optional=(c.optional||[]).concat(s.advanced)),c},i=function(s,c){if(e.version>=61)return c(s);if((s=JSON.parse(JSON.stringify(s)))&&typeof s.audio=="object"){const d=function(l,h,a){h in l&&!(a in l)&&(l[a]=l[h],delete l[h])};d((s=JSON.parse(JSON.stringify(s))).audio,"autoGainControl","googAutoGainControl"),d(s.audio,"noiseSuppression","googNoiseSuppression"),s.audio=r(s.audio)}if(s&&typeof s.video=="object"){let d=s.video.facingMode;d=d&&(typeof d=="object"?d:{ideal:d});const l=e.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){let h;if(delete s.video.facingMode,d.exact==="environment"||d.ideal==="environment"?h=["back","rear"]:d.exact!=="user"&&d.ideal!=="user"||(h=["front"]),h)return n.mediaDevices.enumerateDevices().then(a=>{let u=(a=a.filter(f=>f.kind==="videoinput")).find(f=>h.some(p=>f.label.toLowerCase().includes(p)));return!u&&a.length&&h.includes("back")&&(u=a[a.length-1]),u&&(s.video.deviceId=d.exact?{exact:u.deviceId}:{ideal:u.deviceId}),s.video=r(s.video),vc("chrome: "+JSON.stringify(s)),c(s)})}s.video=r(s.video)}return vc("chrome: "+JSON.stringify(s)),c(s)},o=function(s){return e.version>=64?s:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[s.name]||s.name,message:s.message,constraint:s.constraint||s.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(s,c,d){i(s,l=>{n.webkitGetUserMedia(l,c,h=>{d&&d(o(h))})})}.bind(n),n.mediaDevices.getUserMedia){const s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(c){return i(c,d=>s(d).then(l=>{if(d.audio&&!l.getAudioTracks().length||d.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(o(l))))}}}function zu(t){t.MediaStream=t.MediaStream||t.webkitMediaStream}function Qu(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("ontrack"in t.RTCPeerConnection.prototype)){Object.defineProperty(t.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.track.id):{track:r.track};const o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)}),n.stream.getTracks().forEach(r=>{let i;i=t.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(s=>s.track&&s.track.id===r.id):{track:r};const o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Cn(t,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Xu(t){if(typeof t=="object"&&t.RTCPeerConnection&&!("getSenders"in t.RTCPeerConnection.prototype)&&"createDTMFSender"in t.RTCPeerConnection.prototype){const e=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!t.RTCPeerConnection.prototype.getSenders){t.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(s,c){let d=i.apply(this,arguments);return d||(d=e(this,s),this._senders.push(d)),d};const o=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(s){o.apply(this,arguments);const c=this._senders.indexOf(s);c!==-1&&this._senders.splice(c,1)}}const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(e(this,o))})};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{const s=this._senders.find(c=>c.track===o);s&&this._senders.splice(this._senders.indexOf(s),1)})}}else if(typeof t=="object"&&t.RTCPeerConnection&&"getSenders"in t.RTCPeerConnection.prototype&&"createDTMFSender"in t.RTCPeerConnection.prototype&&t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)){const e=t.RTCPeerConnection.prototype.getSenders;t.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n},Object.defineProperty(t.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 Zu(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[n,r,i]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const o=function(c){const d={};return c.result().forEach(l=>{const h={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(a=>{h[a]=l.stat(a)}),d[h.id]=h}),d},s=function(c){return new Map(Object.keys(c).map(d=>[d,c[d]]))};if(arguments.length>=2){const c=function(d){r(s(o(d)))};return e.apply(this,[c,n])}return new Promise((c,d)=>{e.apply(this,[function(l){c(s(o(l)))},d])}).then(r,i)}}function ed(t){if(!(typeof t=="object"&&t.RTCPeerConnection&&t.RTCRtpSender&&t.RTCRtpReceiver))return;if(!("getStats"in t.RTCRtpSender.prototype)){const n=t.RTCPeerConnection.prototype.getSenders;n&&(t.RTCPeerConnection.prototype.getSenders=function(){const i=n.apply(this,[]);return i.forEach(o=>o._pc=this),i});const r=t.RTCPeerConnection.prototype.addTrack;r&&(t.RTCPeerConnection.prototype.addTrack=function(){const i=r.apply(this,arguments);return i._pc=this,i}),t.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(o=>_c(o,i.track,!0))}}if(!("getStats"in t.RTCRtpReceiver.prototype)){const n=t.RTCPeerConnection.prototype.getReceivers;n&&(t.RTCPeerConnection.prototype.getReceivers=function(){const r=n.apply(this,[]);return r.forEach(i=>i._pc=this),r}),Cn(t,"track",r=>(r.receiver._pc=r.srcElement,r)),t.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(i=>_c(i,r.track,!1))}}if(!("getStats"in t.RTCRtpSender.prototype)||!("getStats"in t.RTCRtpReceiver.prototype))return;const e=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof t.MediaStreamTrack){const n=arguments[0];let r,i,o;return this.getSenders().forEach(s=>{s.track===n&&(r?o=!0:r=s)}),this.getReceivers().forEach(s=>(s.track===n&&(i?o=!0:i=s),s.track===n)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function td(t){t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addTrack=function(o,s){if(!s)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[s.id]?this._shimmedLocalStreams[s.id].indexOf(c)===-1&&this._shimmedLocalStreams[s.id].push(c):this._shimmedLocalStreams[s.id]=[s,c],c};const n=t.RTCPeerConnection.prototype.addStream;t.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(d=>{if(this.getSenders().find(l=>l.track===d))throw new DOMException("Track already exists.","InvalidAccessError")});const s=this.getSenders();n.apply(this,arguments);const c=this.getSenders().filter(d=>s.indexOf(d)===-1);this._shimmedLocalStreams[o.id]=[o].concat(c)};const r=t.RTCPeerConnection.prototype.removeStream;t.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};const i=t.RTCPeerConnection.prototype.removeTrack;t.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(s=>{const c=this._shimmedLocalStreams[s].indexOf(o);c!==-1&&this._shimmedLocalStreams[s].splice(c,1),this._shimmedLocalStreams[s].length===1&&delete this._shimmedLocalStreams[s]}),i.apply(this,arguments)}}function nd(t,e){if(!t.RTCPeerConnection)return;if(t.RTCPeerConnection.prototype.addTrack&&e.version>=65)return td(t);const n=t.RTCPeerConnection.prototype.getLocalStreams;t.RTCPeerConnection.prototype.getLocalStreams=function(){const l=n.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const r=t.RTCPeerConnection.prototype.addStream;t.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 t.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}r.apply(this,[l])};const i=t.RTCPeerConnection.prototype.removeStream;function o(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(p.id,"g"),f.id)}),new RTCSessionDescription({type:h.type,sdp:a})}function s(l,h){let a=h.sdp;return Object.keys(l._reverseStreams||[]).forEach(u=>{const f=l._reverseStreams[u],p=l._streams[f.id];a=a.replace(new RegExp(f.id,"g"),p.id)}),new RTCSessionDescription({type:h.type,sdp:a})}t.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]},t.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(p=>p===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(p=>p.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[h.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const p=new t.MediaStream([l]);this._streams[h.id]=p,this._reverseStreams[p.id]=h,this.addStream(p)}return this.getSenders().find(p=>p.track===l)},["createOffer","createAnswer"].forEach(function(l){const h=t.RTCPeerConnection.prototype[l],a={[l](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?h.apply(this,[f=>{const p=o(this,f);u[0].apply(null,[p])},f=>{u[1]&&u[1].apply(null,f)},arguments[2]]):h.apply(this,arguments).then(f=>o(this,f))}};t.RTCPeerConnection.prototype[l]=a[l]});const c=t.RTCPeerConnection.prototype.setLocalDescription;t.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=s(this,arguments[0]),c.apply(this,arguments)):c.apply(this,arguments)};const d=Object.getOwnPropertyDescriptor(t.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(t.RTCPeerConnection.prototype,"localDescription",{get(){const l=d.get.apply(this);return l.type===""?l:o(this,l)}}),t.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let h;this._streams=this._streams||{},Object.keys(this._streams).forEach(a=>{this._streams[a].getTracks().find(u=>l.track===u)&&(h=this._streams[a])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function qo(t,e){!t.RTCPeerConnection&&t.webkitRTCPeerConnection&&(t.RTCPeerConnection=t.webkitRTCPeerConnection),t.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=t.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};t.RTCPeerConnection.prototype[n]=i[n]})}function rd(t,e){Cn(t,"negotiationneeded",n=>{const r=n.target;if(!(e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return n})}var yc=Object.freeze({__proto__:null,shimMediaStream:zu,shimOnTrack:Qu,shimGetSendersWithDtmf:Xu,shimGetStats:Zu,shimSenderReceiverGetStats:ed,shimAddTrackRemoveTrackWithNative:td,shimAddTrackRemoveTrack:nd,shimPeerConnection:qo,fixNegotiationNeeded:rd,shimGetUserMedia:Wu,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(typeof e=="function"?t.navigator.mediaDevices.getDisplayMedia=function(n){return e(n).then(r=>{const i=n.video&&n.video.width,o=n.video&&n.video.height,s=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:s||3}},i&&(n.video.mandatory.maxWidth=i),o&&(n.video.mandatory.maxHeight=o),t.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),Cc,to,X=(Cc=function(t){var e={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(`
  819. `).map(function(r){return r.trim()})},e.splitSections=function(n){return n.split(`
  820. m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
  821. `})},e.getDescription=function(n){var r=e.splitSections(n);return r&&r[0]},e.getMediaSections=function(n){var r=e.splitSections(n);return r.shift(),r},e.matchPrefix=function(n,r){return e.splitLines(n).filter(function(i){return i.indexOf(r)===0})},e.parseCandidate=function(n){for(var r,i={foundation:(r=n.indexOf("a=candidate:")===0?n.substring(12).split(" "):n.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o<r.length;o+=2)switch(r[o]){case"raddr":i.relatedAddress=r[o+1];break;case"rport":i.relatedPort=parseInt(r[o+1],10);break;case"tcptype":i.tcpType=r[o+1];break;case"ufrag":i.ufrag=r[o+1],i.usernameFragment=r[o+1];break;default:i[r[o]]=r[o+1]}return i},e.writeCandidate=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);var i=n.type;return r.push("typ"),r.push(i),i!=="host"&&n.relatedAddress&&n.relatedPort&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(n){return n.substr(14).split(" ")},e.parseRtpMap=function(n){var r=n.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(n){var r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);var i=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(i!==1?"/"+i:"")+`\r
  822. `},e.parseExtmap=function(n){var r=n.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(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+`\r
  823. `},e.parseFmtp=function(n){for(var r,i={},o=n.substr(n.indexOf(" ")+1).split(";"),s=0;s<o.length;s++)i[(r=o[s].trim().split("="))[0].trim()]=r[1];return i},e.writeFmtp=function(n){var r="",i=n.payloadType;if(n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){var o=[];Object.keys(n.parameters).forEach(function(s){n.parameters[s]?o.push(s+"="+n.parameters[s]):o.push(s)}),r+="a=fmtp:"+i+" "+o.join(";")+`\r
  824. `}return r},e.parseRtcpFb=function(n){var r=n.substr(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(n){var r="",i=n.payloadType;return n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(function(o){r+="a=rtcp-fb:"+i+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
  825. `}),r},e.parseSsrcMedia=function(n){var r=n.indexOf(" "),i={ssrc:parseInt(n.substr(7,r-7),10)},o=n.indexOf(":",r);return o>-1?(i.attribute=n.substr(r+1,o-r-1),i.value=n.substr(o+1)):i.attribute=n.substr(r+1),i},e.parseSsrcGroup=function(n){var r=n.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},e.getMid=function(n){var r=e.matchPrefix(n,"a=mid:")[0];if(r)return r.substr(6)},e.parseFingerprint=function(n){var r=n.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},e.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:e.matchPrefix(n+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,r){var i="a=setup:"+r+`\r
  826. `;return n.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
  827. `}),i},e.parseCryptoLine=function(n){var r=n.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
  828. `},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;var r=n.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(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,r){return e.matchPrefix(n+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,r){var i=e.matchPrefix(n+r,"a=ice-ufrag:")[0],o=e.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},e.writeIceParameters=function(n){return"a=ice-ufrag:"+n.usernameFragment+`\r
  829. a=ice-pwd:`+n.password+`\r
  830. `},e.parseRtpParameters=function(n){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=e.splitLines(n)[0].split(" "),o=3;o<i.length;o++){var s=i[o],c=e.matchPrefix(n,"a=rtpmap:"+s+" ")[0];if(c){var d=e.parseRtpMap(c),l=e.matchPrefix(n,"a=fmtp:"+s+" ");switch(d.parameters=l.length?e.parseFmtp(l[0]):{},d.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+s+" ").map(e.parseRtcpFb),r.codecs.push(d),d.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(d.name.toUpperCase())}}}return e.matchPrefix(n,"a=extmap:").forEach(function(h){r.headerExtensions.push(e.parseExtmap(h))}),r},e.writeRtpDescription=function(n,r){var i="";i+="m="+n+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(s){return s.preferredPayloadType!==void 0?s.preferredPayloadType:s.payloadType}).join(" ")+`\r
  831. `,i+=`c=IN IP4 0.0.0.0\r
  832. `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
  833. `,r.codecs.forEach(function(s){i+=e.writeRtpMap(s),i+=e.writeFmtp(s),i+=e.writeRtcpFb(s)});var o=0;return r.codecs.forEach(function(s){s.maxptime>o&&(o=s.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r
  834. `),i+=`a=rtcp-mux\r
  835. `,r.headerExtensions&&r.headerExtensions.forEach(function(s){i+=e.writeExtmap(s)}),i},e.parseRtpEncodingParameters=function(n){var r,i=[],o=e.parseRtpParameters(n),s=o.fecMechanisms.indexOf("RED")!==-1,c=o.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(n,"a=ssrc:").map(function(u){return e.parseSsrcMedia(u)}).filter(function(u){return u.attribute==="cname"}),l=d.length>0&&d[0].ssrc,h=e.matchPrefix(n,"a=ssrc-group:FID").map(function(u){return u.substr(17).split(" ").map(function(f){return parseInt(f,10)})});h.length>0&&h[0].length>1&&h[0][0]===l&&(r=h[0][1]),o.codecs.forEach(function(u){if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){var f={ssrc:l,codecPayloadType:parseInt(u.parameters.apt,10)};l&&r&&(f.rtx={ssrc:r}),i.push(f),s&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:l,mechanism:c?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&l&&i.push({ssrc:l});var a=e.matchPrefix(n,"b=");return a.length&&(a=a[0].indexOf("b=TIAS:")===0?parseInt(a[0].substr(7),10):a[0].indexOf("b=AS:")===0?1e3*parseInt(a[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(u){u.maxBitrate=a})),i},e.parseRtcpParameters=function(n){var r={},i=e.matchPrefix(n,"a=ssrc:").map(function(c){return e.parseSsrcMedia(c)}).filter(function(c){return c.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=e.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var s=e.matchPrefix(n,"a=rtcp-mux");return r.mux=s.length>0,r},e.parseMsid=function(n){var r,i=e.matchPrefix(n,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=e.matchPrefix(n,"a=ssrc:").map(function(s){return e.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},e.parseSctpDescription=function(n){var r,i=e.parseMLine(n),o=e.matchPrefix(n,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var s=e.matchPrefix(n,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(e.matchPrefix(n,"a=sctpmap:").length>0){var c=e.matchPrefix(n,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:r}}},e.writeSctpDescription=function(n,r){var i=[];return i=n.protocol!=="DTLS/SCTP"?["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
  836. `,`c=IN IP4 0.0.0.0\r
  837. `,"a=sctp-port:"+r.port+`\r
  838. `]:["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
  839. `,`c=IN IP4 0.0.0.0\r
  840. `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
  841. `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
  842. `),i.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,21)},e.writeSessionBoilerplate=function(n,r,i){var o=r!==void 0?r:2;return`v=0\r
  843. o=`+(i||"thisisadapterortc")+" "+(n||e.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r
  844. s=-\r
  845. t=0 0\r
  846. `},e.writeMediaSection=function(n,r,i,o){var s=e.writeRtpDescription(n.kind,r);if(s+=e.writeIceParameters(n.iceGatherer.getLocalParameters()),s+=e.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),s+="a=mid:"+n.mid+`\r
  847. `,n.direction?s+="a="+n.direction+`\r
  848. `:n.rtpSender&&n.rtpReceiver?s+=`a=sendrecv\r
  849. `:n.rtpSender?s+=`a=sendonly\r
  850. `:n.rtpReceiver?s+=`a=recvonly\r
  851. `:s+=`a=inactive\r
  852. `,n.rtpSender){var c="msid:"+o.id+" "+n.rtpSender.track.id+`\r
  853. `;s+="a="+c,s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+c,n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
  854. `)}return s+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
  855. `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
  856. `),s},e.getDirection=function(n,r){for(var i=e.splitLines(n),o=0;o<i.length;o++)switch(i[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[o].substr(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(n){return e.splitLines(n)[0].split(" ")[0].substr(2)},e.isRejected=function(n){return n.split(" ",2)[1]==="0"},e.parseMLine=function(n){var r=e.splitLines(n)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},e.parseOLine=function(n){var r=e.matchPrefix(n,"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(n){if(typeof n!="string"||n.length===0)return!1;for(var r=e.splitLines(n),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},t.exports=e},Cc(to={exports:{}},to.exports),to.exports);function Ec(t,e,n,r,i){var o=X.writeRtpDescription(t.kind,e);if(o+=X.writeIceParameters(t.iceGatherer.getLocalParameters()),o+=X.writeDtlsParameters(t.dtlsTransport.getLocalParameters(),n==="offer"?"actpass":i||"active"),o+="a=mid:"+t.mid+`\r
  857. `,t.rtpSender&&t.rtpReceiver?o+=`a=sendrecv\r
  858. `:t.rtpSender?o+=`a=sendonly\r
  859. `:t.rtpReceiver?o+=`a=recvonly\r
  860. `:o+=`a=inactive\r
  861. `,t.rtpSender){var s=t.rtpSender._initialTrackId||t.rtpSender.track.id;t.rtpSender._initialTrackId=s;var c="msid:"+(r?r.id:"-")+" "+s+`\r
  862. `;o+="a="+c,o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+c,t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+c,o+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
  863. `)}return o+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+X.localCName+`\r
  864. `,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+X.localCName+`\r
  865. `),o}function wr(t,e){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(o,s){o=parseInt(o,10);for(var c=0;c<s.length;c++)if(s[c].payloadType===o||s[c].preferredPayloadType===o)return s[c]},i=function(o,s,c,d){var l=r(o.parameters.apt,c),h=r(s.parameters.apt,d);return l&&h&&l.name.toLowerCase()===h.name.toLowerCase()};return t.codecs.forEach(function(o){for(var s=0;s<e.codecs.length;s++){var c=e.codecs[s];if(o.name.toLowerCase()===c.name.toLowerCase()&&o.clockRate===c.clockRate){if(o.name.toLowerCase()==="rtx"&&o.parameters&&c.parameters.apt&&!i(o,c,t.codecs,e.codecs))continue;(c=JSON.parse(JSON.stringify(c))).numChannels=Math.min(o.numChannels,c.numChannels),n.codecs.push(c),c.rtcpFeedback=c.rtcpFeedback.filter(function(d){for(var l=0;l<o.rtcpFeedback.length;l++)if(o.rtcpFeedback[l].type===d.type&&o.rtcpFeedback[l].parameter===d.parameter)return!0;return!1});break}}}),t.headerExtensions.forEach(function(o){for(var s=0;s<e.headerExtensions.length;s++){var c=e.headerExtensions[s];if(o.uri===c.uri){n.headerExtensions.push(c);break}}}),n}function Rc(t,e,n){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][t].indexOf(n)!==-1}function no(t,e){var n=t.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 n||t.addRemoteCandidate(e),!n}function xe(t,e){var n=new Error(e);return n.name=t,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[t],n}var pf=function(t,e){function n(s,c){c.addTrack(s),c.dispatchEvent(new t.MediaStreamTrackEvent("addtrack",{track:s}))}function r(s,c,d,l){var h=new Event("track");h.track=c,h.receiver=d,h.transceiver={receiver:d},h.streams=l,t.setTimeout(function(){s._dispatchEvent("track",h)})}var i=function(s){var c=this,d=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(h){c[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",s=JSON.parse(JSON.stringify(s||{})),this.usingBundle=s.bundlePolicy==="max-bundle",s.rtcpMuxPolicy==="negotiate")throw xe("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(s.rtcpMuxPolicy||(s.rtcpMuxPolicy="require"),s.iceTransportPolicy){case"all":case"relay":break;default:s.iceTransportPolicy="all"}switch(s.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:s.bundlePolicy="balanced"}if(s.iceServers=function(h,a){var u=!1;return(h=JSON.parse(JSON.stringify(h))).filter(function(f){if(f&&(f.urls||f.url)){var p=f.urls||f.url;f.url&&!f.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var m=typeof p=="string";return m&&(p=[p]),p=p.filter(function(_){return _.indexOf("turn:")!==0||_.indexOf("transport=udp")===-1||_.indexOf("turn:[")!==-1||u?_.indexOf("stun:")===0&&a>=14393&&_.indexOf("?transport=udp")===-1:(u=!0,!0)}),delete f.url,f.urls=m?p[0]:p,!!p.length}})}(s.iceServers||[],e),this._iceGatherers=[],s.iceCandidatePoolSize)for(var l=s.iceCandidatePoolSize;l>0;l--)this._iceGatherers.push(new t.RTCIceGatherer({iceServers:s.iceServers,gatherPolicy:s.iceTransportPolicy}));else s.iceCandidatePoolSize=0;this._config=s,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(s,c){this._isClosed||(this.dispatchEvent(c),typeof this["on"+s]=="function"&&this["on"+s](c))},i.prototype._emitGatheringStateChange=function(){var s=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",s)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(s,c){var d=this.transceivers.length>0,l={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:s,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&d)l.iceTransport=this.transceivers[0].iceTransport,l.dtlsTransport=this.transceivers[0].dtlsTransport;else{var h=this._createIceAndDtlsTransports();l.iceTransport=h.iceTransport,l.dtlsTransport=h.dtlsTransport}return c||this.transceivers.push(l),l},i.prototype.addTrack=function(s,c){if(this._isClosed)throw xe("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var d;if(this.transceivers.find(function(h){return h.track===s}))throw xe("InvalidAccessError","Track already exists.");for(var l=0;l<this.transceivers.length;l++)this.transceivers[l].track||this.transceivers[l].kind!==s.kind||(d=this.transceivers[l]);return d||(d=this._createTransceiver(s.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(c)===-1&&this.localStreams.push(c),d.track=s,d.stream=c,d.rtpSender=new t.RTCRtpSender(s,d.dtlsTransport),d.rtpSender},i.prototype.addStream=function(s){var c=this;if(e>=15025)s.getTracks().forEach(function(l){c.addTrack(l,s)});else{var d=s.clone();s.getTracks().forEach(function(l,h){var a=d.getTracks()[h];l.addEventListener("enabled",function(u){a.enabled=u.enabled})}),d.getTracks().forEach(function(l){c.addTrack(l,d)})}},i.prototype.removeTrack=function(s){if(this._isClosed)throw xe("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(s instanceof t.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var c=this.transceivers.find(function(l){return l.rtpSender===s});if(!c)throw xe("InvalidAccessError","Sender was not created by this connection.");var d=c.stream;c.rtpSender.stop(),c.rtpSender=null,c.track=null,c.stream=null,this.transceivers.map(function(l){return l.stream}).indexOf(d)===-1&&this.localStreams.indexOf(d)>-1&&this.localStreams.splice(this.localStreams.indexOf(d),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(s){var c=this;s.getTracks().forEach(function(d){var l=c.getSenders().find(function(h){return h.track===d});l&&c.removeTrack(l)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(s){return!!s.rtpSender}).map(function(s){return s.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(s){return!!s.rtpReceiver}).map(function(s){return s.rtpReceiver})},i.prototype._createIceGatherer=function(s,c){var d=this;if(c&&s>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var l=new t.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(l,"state",{value:"new",writable:!0}),this.transceivers[s].bufferedCandidateEvents=[],this.transceivers[s].bufferCandidates=function(h){var a=!h.candidate||Object.keys(h.candidate).length===0;l.state=a?"completed":"gathering",d.transceivers[s].bufferedCandidateEvents!==null&&d.transceivers[s].bufferedCandidateEvents.push(h)},l.addEventListener("localcandidate",this.transceivers[s].bufferCandidates),l},i.prototype._gather=function(s,c){var d=this,l=this.transceivers[c].iceGatherer;if(!l.onlocalcandidate){var h=this.transceivers[c].bufferedCandidateEvents;this.transceivers[c].bufferedCandidateEvents=null,l.removeEventListener("localcandidate",this.transceivers[c].bufferCandidates),l.onlocalcandidate=function(a){if(!(d.usingBundle&&c>0)){var u=new Event("icecandidate");u.candidate={sdpMid:s,sdpMLineIndex:c};var f=a.candidate,p=!f||Object.keys(f).length===0;if(p)l.state!=="new"&&l.state!=="gathering"||(l.state="completed");else{l.state==="new"&&(l.state="gathering"),f.component=1,f.ufrag=l.getLocalParameters().usernameFragment;var m=X.writeCandidate(f);u.candidate=Object.assign(u.candidate,X.parseCandidate(m)),u.candidate.candidate=m,u.candidate.toJSON=function(){return{candidate:u.candidate.candidate,sdpMid:u.candidate.sdpMid,sdpMLineIndex:u.candidate.sdpMLineIndex,usernameFragment:u.candidate.usernameFragment}}}var _=X.getMediaSections(d._localDescription.sdp);_[u.candidate.sdpMLineIndex]+=p?`a=end-of-candidates\r
  866. `:"a="+u.candidate.candidate+`\r
  867. `,d._localDescription.sdp=X.getDescription(d._localDescription.sdp)+_.join("");var v=d.transceivers.every(function(y){return y.iceGatherer&&y.iceGatherer.state==="completed"});d.iceGatheringState!=="gathering"&&(d.iceGatheringState="gathering",d._emitGatheringStateChange()),p||d._dispatchEvent("icecandidate",u),v&&(d._dispatchEvent("icecandidate",new Event("icecandidate")),d.iceGatheringState="complete",d._emitGatheringStateChange())}},t.setTimeout(function(){h.forEach(function(a){l.onlocalcandidate(a)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var s=this,c=new t.RTCIceTransport(null);c.onicestatechange=function(){s._updateIceConnectionState(),s._updateConnectionState()};var d=new t.RTCDtlsTransport(c);return d.ondtlsstatechange=function(){s._updateConnectionState()},d.onerror=function(){Object.defineProperty(d,"state",{value:"failed",writable:!0}),s._updateConnectionState()},{iceTransport:c,dtlsTransport:d}},i.prototype._disposeIceAndDtlsTransports=function(s){var c=this.transceivers[s].iceGatherer;c&&(delete c.onlocalcandidate,delete this.transceivers[s].iceGatherer);var d=this.transceivers[s].iceTransport;d&&(delete d.onicestatechange,delete this.transceivers[s].iceTransport);var l=this.transceivers[s].dtlsTransport;l&&(delete l.ondtlsstatechange,delete l.onerror,delete this.transceivers[s].dtlsTransport)},i.prototype._transceive=function(s,c,d){var l=wr(s.localCapabilities,s.remoteCapabilities);c&&s.rtpSender&&(l.encodings=s.sendEncodingParameters,l.rtcp={cname:X.localCName,compound:s.rtcpParameters.compound},s.recvEncodingParameters.length&&(l.rtcp.ssrc=s.recvEncodingParameters[0].ssrc),s.rtpSender.send(l)),d&&s.rtpReceiver&&l.codecs.length>0&&(s.kind==="video"&&s.recvEncodingParameters&&e<15019&&s.recvEncodingParameters.forEach(function(h){delete h.rtx}),s.recvEncodingParameters.length?l.encodings=s.recvEncodingParameters:l.encodings=[{}],l.rtcp={compound:s.rtcpParameters.compound},s.rtcpParameters.cname&&(l.rtcp.cname=s.rtcpParameters.cname),s.sendEncodingParameters.length&&(l.rtcp.ssrc=s.sendEncodingParameters[0].ssrc),s.rtpReceiver.receive(l))},i.prototype.setLocalDescription=function(s){var c,d,l=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(xe("TypeError",'Unsupported type "'+s.type+'"'));if(!Rc("setLocalDescription",s.type,l.signalingState)||l._isClosed)return Promise.reject(xe("InvalidStateError","Can not set local "+s.type+" in state "+l.signalingState));if(s.type==="offer")c=X.splitSections(s.sdp),d=c.shift(),c.forEach(function(a,u){var f=X.parseRtpParameters(a);l.transceivers[u].localCapabilities=f}),l.transceivers.forEach(function(a,u){l._gather(a.mid,u)});else if(s.type==="answer"){c=X.splitSections(l._remoteDescription.sdp),d=c.shift();var h=X.matchPrefix(d,"a=ice-lite").length>0;c.forEach(function(a,u){var f=l.transceivers[u],p=f.iceGatherer,m=f.iceTransport,_=f.dtlsTransport,v=f.localCapabilities,y=f.remoteCapabilities;if(!(X.isRejected(a)&&X.matchPrefix(a,"a=bundle-only").length===0)&&!f.rejected){var C=X.getIceParameters(a,d),I=X.getDtlsParameters(a,d);h&&(I.role="server"),l.usingBundle&&u!==0||(l._gather(f.mid,u),m.state==="new"&&m.start(p,C,h?"controlling":"controlled"),_.state==="new"&&_.start(I));var P=wr(v,y);l._transceive(f,P.codecs.length>0,!1)}})}return l._localDescription={type:s.type,sdp:s.sdp},s.type==="offer"?l._updateSignalingState("have-local-offer"):l._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(s){var c=this;if(["offer","answer"].indexOf(s.type)===-1)return Promise.reject(xe("TypeError",'Unsupported type "'+s.type+'"'));if(!Rc("setRemoteDescription",s.type,c.signalingState)||c._isClosed)return Promise.reject(xe("InvalidStateError","Can not set remote "+s.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach(function(m){d[m.id]=m});var l=[],h=X.splitSections(s.sdp),a=h.shift(),u=X.matchPrefix(a,"a=ice-lite").length>0,f=X.matchPrefix(a,"a=group:BUNDLE ").length>0;c.usingBundle=f;var p=X.matchPrefix(a,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(m,_){var v=X.splitLines(m),y=X.getKind(m),C=X.isRejected(m)&&X.matchPrefix(m,"a=bundle-only").length===0,I=v[0].substr(2).split(" ")[2],P=X.getDirection(m,a),b=X.parseMsid(m),R=X.getMid(m)||X.generateIdentifier();if(C||y==="application"&&(I==="DTLS/SCTP"||I==="UDP/DTLS/SCTP"))c.transceivers[_]={mid:R,kind:y,protocol:I,rejected:!0};else{var M,F,q,E,T,A,L,k,V;!C&&c.transceivers[_]&&c.transceivers[_].rejected&&(c.transceivers[_]=c._createTransceiver(y,!0));var j,G,J=X.parseRtpParameters(m);C||(j=X.getIceParameters(m,a),(G=X.getDtlsParameters(m,a)).role="client"),L=X.parseRtpEncodingParameters(m);var oe=X.parseRtcpParameters(m),he=X.matchPrefix(m,"a=end-of-candidates",a).length>0,de=X.matchPrefix(m,"a=candidate:").map(function(U){return X.parseCandidate(U)}).filter(function(U){return U.component===1});if((s.type==="offer"||s.type==="answer")&&!C&&f&&_>0&&c.transceivers[_]&&(c._disposeIceAndDtlsTransports(_),c.transceivers[_].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[_].iceTransport=c.transceivers[0].iceTransport,c.transceivers[_].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[_].rtpSender&&c.transceivers[_].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[_].rtpReceiver&&c.transceivers[_].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),s.type!=="offer"||C)s.type==="answer"&&!C&&(F=(M=c.transceivers[_]).iceGatherer,q=M.iceTransport,E=M.dtlsTransport,T=M.rtpReceiver,A=M.sendEncodingParameters,k=M.localCapabilities,c.transceivers[_].recvEncodingParameters=L,c.transceivers[_].remoteCapabilities=J,c.transceivers[_].rtcpParameters=oe,de.length&&q.state==="new"&&(!u&&!he||f&&_!==0?de.forEach(function(U){no(M.iceTransport,U)}):q.setRemoteCandidates(de)),f&&_!==0||(q.state==="new"&&q.start(F,j,"controlling"),E.state==="new"&&E.start(G)),!wr(M.localCapabilities,M.remoteCapabilities).codecs.filter(function(U){return U.name.toLowerCase()==="rtx"}).length&&M.sendEncodingParameters[0].rtx&&delete M.sendEncodingParameters[0].rtx,c._transceive(M,P==="sendrecv"||P==="recvonly",P==="sendrecv"||P==="sendonly"),!T||P!=="sendrecv"&&P!=="sendonly"?delete M.rtpReceiver:(V=T.track,b?(d[b.stream]||(d[b.stream]=new t.MediaStream),n(V,d[b.stream]),l.push([V,T,d[b.stream]])):(d.default||(d.default=new t.MediaStream),n(V,d.default),l.push([V,T,d.default]))));else{(M=c.transceivers[_]||c._createTransceiver(y)).mid=R,M.iceGatherer||(M.iceGatherer=c._createIceGatherer(_,f)),de.length&&M.iceTransport.state==="new"&&(!he||f&&_!==0?de.forEach(function(U){no(M.iceTransport,U)}):M.iceTransport.setRemoteCandidates(de)),k=t.RTCRtpReceiver.getCapabilities(y),e<15019&&(k.codecs=k.codecs.filter(function(U){return U.name!=="rtx"})),A=M.sendEncodingParameters||[{ssrc:1001*(2*_+2)}];var ae,te=!1;P==="sendrecv"||P==="sendonly"?(te=!M.rtpReceiver,T=M.rtpReceiver||new t.RTCRtpReceiver(M.dtlsTransport,y),te&&(V=T.track,b&&b.stream==="-"||(b?(d[b.stream]||(d[b.stream]=new t.MediaStream,Object.defineProperty(d[b.stream],"id",{get:function(){return b.stream}})),Object.defineProperty(V,"id",{get:function(){return b.track}}),ae=d[b.stream]):(d.default||(d.default=new t.MediaStream),ae=d.default)),ae&&(n(V,ae),M.associatedRemoteMediaStreams.push(ae)),l.push([V,T,ae]))):M.rtpReceiver&&M.rtpReceiver.track&&(M.associatedRemoteMediaStreams.forEach(function(U){var Y=U.getTracks().find(function(ee){return ee.id===M.rtpReceiver.track.id});Y&&function(ee,re){re.removeTrack(ee),re.dispatchEvent(new t.MediaStreamTrackEvent("removetrack",{track:ee}))}(Y,U)}),M.associatedRemoteMediaStreams=[]),M.localCapabilities=k,M.remoteCapabilities=J,M.rtpReceiver=T,M.rtcpParameters=oe,M.sendEncodingParameters=A,M.recvEncodingParameters=L,c._transceive(c.transceivers[_],!1,te)}}}),c._dtlsRole===void 0&&(c._dtlsRole=s.type==="offer"?"active":"passive"),c._remoteDescription={type:s.type,sdp:s.sdp},s.type==="offer"?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach(function(m){var _=d[m];if(_.getTracks().length){if(c.remoteStreams.indexOf(_)===-1){c.remoteStreams.push(_);var v=new Event("addstream");v.stream=_,t.setTimeout(function(){c._dispatchEvent("addstream",v)})}l.forEach(function(y){var C=y[0],I=y[1];_.id===y[2].id&&r(c,C,I,[_])})}}),l.forEach(function(m){m[2]||r(c,m[0],m[1],[])}),t.setTimeout(function(){c&&c.transceivers&&c.transceivers.forEach(function(m){m.iceTransport&&m.iceTransport.state==="new"&&m.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),m.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(s){s.iceTransport&&s.iceTransport.stop(),s.dtlsTransport&&s.dtlsTransport.stop(),s.rtpSender&&s.rtpSender.stop(),s.rtpReceiver&&s.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(s){this.signalingState=s;var c=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",c)},i.prototype._maybeFireNegotiationNeeded=function(){var s=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,t.setTimeout(function(){if(s.needNegotiation){s.needNegotiation=!1;var c=new Event("negotiationneeded");s._dispatchEvent("negotiationneeded",c)}},0))},i.prototype._updateIceConnectionState=function(){var s,c={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&!l.rejected&&c[l.iceTransport.state]++}),s="new",c.failed>0?s="failed":c.checking>0?s="checking":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0?s="connected":c.completed>0&&(s="completed"),s!==this.iceConnectionState){this.iceConnectionState=s;var d=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",d)}},i.prototype._updateConnectionState=function(){var s,c={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(l){l.iceTransport&&l.dtlsTransport&&!l.rejected&&(c[l.iceTransport.state]++,c[l.dtlsTransport.state]++)}),c.connected+=c.completed,s="new",c.failed>0?s="failed":c.connecting>0?s="connecting":c.disconnected>0?s="disconnected":c.new>0?s="new":c.connected>0&&(s="connected"),s!==this.connectionState){this.connectionState=s;var d=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",d)}},i.prototype.createOffer=function(){var s=this;if(s._isClosed)return Promise.reject(xe("InvalidStateError","Can not call createOffer after close"));var c=s.transceivers.filter(function(u){return u.kind==="audio"}).length,d=s.transceivers.filter(function(u){return u.kind==="video"}).length,l=arguments[0];if(l){if(l.mandatory||l.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");l.offerToReceiveAudio!==void 0&&(c=l.offerToReceiveAudio===!0?1:l.offerToReceiveAudio===!1?0:l.offerToReceiveAudio),l.offerToReceiveVideo!==void 0&&(d=l.offerToReceiveVideo===!0?1:l.offerToReceiveVideo===!1?0:l.offerToReceiveVideo)}for(s.transceivers.forEach(function(u){u.kind==="audio"?--c<0&&(u.wantReceive=!1):u.kind==="video"&&--d<0&&(u.wantReceive=!1)});c>0||d>0;)c>0&&(s._createTransceiver("audio"),c--),d>0&&(s._createTransceiver("video"),d--);var h=X.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.transceivers.forEach(function(u,f){var p=u.track,m=u.kind,_=u.mid||X.generateIdentifier();u.mid=_,u.iceGatherer||(u.iceGatherer=s._createIceGatherer(f,s.usingBundle));var v=t.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"),u.remoteCapabilities&&u.remoteCapabilities.codecs&&u.remoteCapabilities.codecs.forEach(function(I){C.name.toLowerCase()===I.name.toLowerCase()&&C.clockRate===I.clockRate&&(C.preferredPayloadType=I.payloadType)})}),v.headerExtensions.forEach(function(C){(u.remoteCapabilities&&u.remoteCapabilities.headerExtensions||[]).forEach(function(I){C.uri===I.uri&&(C.id=I.id)})});var y=u.sendEncodingParameters||[{ssrc:1001*(2*f+1)}];p&&e>=15019&&m==="video"&&!y[0].rtx&&(y[0].rtx={ssrc:y[0].ssrc+1}),u.wantReceive&&(u.rtpReceiver=new t.RTCRtpReceiver(u.dtlsTransport,m)),u.localCapabilities=v,u.sendEncodingParameters=y}),s._config.bundlePolicy!=="max-compat"&&(h+="a=group:BUNDLE "+s.transceivers.map(function(u){return u.mid}).join(" ")+`\r
  868. `),h+=`a=ice-options:trickle\r
  869. `,s.transceivers.forEach(function(u,f){h+=Ec(u,u.localCapabilities,"offer",u.stream,s._dtlsRole),h+=`a=rtcp-rsize\r
  870. `,!u.iceGatherer||s.iceGatheringState==="new"||f!==0&&s.usingBundle||(u.iceGatherer.getLocalCandidates().forEach(function(p){p.component=1,h+="a="+X.writeCandidate(p)+`\r
  871. `}),u.iceGatherer.state==="completed"&&(h+=`a=end-of-candidates\r
  872. `))});var a=new t.RTCSessionDescription({type:"offer",sdp:h});return Promise.resolve(a)},i.prototype.createAnswer=function(){var s=this;if(s._isClosed)return Promise.reject(xe("InvalidStateError","Can not call createAnswer after close"));if(s.signalingState!=="have-remote-offer"&&s.signalingState!=="have-local-pranswer")return Promise.reject(xe("InvalidStateError","Can not call createAnswer in signalingState "+s.signalingState));var c=X.writeSessionBoilerplate(s._sdpSessionId,s._sdpSessionVersion++);s.usingBundle&&(c+="a=group:BUNDLE "+s.transceivers.map(function(h){return h.mid}).join(" ")+`\r
  873. `),c+=`a=ice-options:trickle\r
  874. `;var d=X.getMediaSections(s._remoteDescription.sdp).length;s.transceivers.forEach(function(h,a){if(!(a+1>d)){if(h.rejected)return h.kind==="application"?h.protocol==="DTLS/SCTP"?c+=`m=application 0 DTLS/SCTP 5000\r
  875. `:c+="m=application 0 "+h.protocol+` webrtc-datachannel\r
  876. `:h.kind==="audio"?c+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
  877. a=rtpmap:0 PCMU/8000\r
  878. `:h.kind==="video"&&(c+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
  879. a=rtpmap:120 VP8/90000\r
  880. `),void(c+=`c=IN IP4 0.0.0.0\r
  881. a=inactive\r
  882. a=mid:`+h.mid+`\r
  883. `);var u;h.stream&&(h.kind==="audio"?u=h.stream.getAudioTracks()[0]:h.kind==="video"&&(u=h.stream.getVideoTracks()[0]),u&&e>=15019&&h.kind==="video"&&!h.sendEncodingParameters[0].rtx&&(h.sendEncodingParameters[0].rtx={ssrc:h.sendEncodingParameters[0].ssrc+1}));var f=wr(h.localCapabilities,h.remoteCapabilities);!f.codecs.filter(function(p){return p.name.toLowerCase()==="rtx"}).length&&h.sendEncodingParameters[0].rtx&&delete h.sendEncodingParameters[0].rtx,c+=Ec(h,f,"answer",h.stream,s._dtlsRole),h.rtcpParameters&&h.rtcpParameters.reducedSize&&(c+=`a=rtcp-rsize\r
  884. `)}});var l=new t.RTCSessionDescription({type:"answer",sdp:c});return Promise.resolve(l)},i.prototype.addIceCandidate=function(s){var c,d=this;return s&&s.sdpMLineIndex===void 0&&!s.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(l,h){if(!d._remoteDescription)return h(xe("InvalidStateError","Can not add ICE candidate without a remote description"));if(s&&s.candidate!==""){var a=s.sdpMLineIndex;if(s.sdpMid){for(var u=0;u<d.transceivers.length;u++)if(d.transceivers[u].mid===s.sdpMid){a=u;break}}var f=d.transceivers[a];if(!f)return h(xe("OperationError","Can not add ICE candidate"));if(f.rejected)return l();var p=Object.keys(s.candidate).length>0?X.parseCandidate(s.candidate):{};if(p.protocol==="tcp"&&(p.port===0||p.port===9)||p.component&&p.component!==1)return l();if((a===0||a>0&&f.iceTransport!==d.transceivers[0].iceTransport)&&!no(f.iceTransport,p))return h(xe("OperationError","Can not add ICE candidate"));var m=s.candidate.trim();m.indexOf("a=")===0&&(m=m.substr(2)),(c=X.getMediaSections(d._remoteDescription.sdp))[a]+="a="+(p.type?m:"end-of-candidates")+`\r
  885. `,d._remoteDescription.sdp=X.getDescription(d._remoteDescription.sdp)+c.join("")}else for(var _=0;_<d.transceivers.length&&(d.transceivers[_].rejected||(d.transceivers[_].iceTransport.addRemoteCandidate({}),(c=X.getMediaSections(d._remoteDescription.sdp))[_]+=`a=end-of-candidates\r
  886. `,d._remoteDescription.sdp=X.getDescription(d._remoteDescription.sdp)+c.join(""),!d.usingBundle));_++);l()})},i.prototype.getStats=function(s){if(s&&s instanceof t.MediaStreamTrack){var c=null;if(this.transceivers.forEach(function(l){l.rtpSender&&l.rtpSender.track===s?c=l.rtpSender:l.rtpReceiver&&l.rtpReceiver.track===s&&(c=l.rtpReceiver)}),!c)throw xe("InvalidAccessError","Invalid selector.");return c.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(u){h.set(u.id,u)})}),h})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(s){var c=t[s];if(c&&c.prototype&&c.prototype.getStats){var d=c.prototype.getStats;c.prototype.getStats=function(){return d.apply(this).then(function(l){var h=new Map;return Object.keys(l).forEach(function(a){var u;l[a].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(u=l[a]).type]||u.type,h.set(a,l[a])}),h})}}});var o=["createOffer","createAnswer"];return o.forEach(function(s){var c=i.prototype[s];i.prototype[s]=function(){var d=arguments;return typeof d[0]=="function"||typeof d[1]=="function"?c.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])}):c.apply(this,arguments)}}),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(s){var c=i.prototype[s];i.prototype[s]=function(){var d=arguments;return typeof d[1]=="function"||typeof d[2]=="function"?c.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)},function(l){typeof d[2]=="function"&&d[2].apply(null,[l])}):c.apply(this,arguments)}}),["getStats"].forEach(function(s){var c=i.prototype[s];i.prototype[s]=function(){var d=arguments;return typeof d[1]=="function"?c.apply(this,arguments).then(function(){typeof d[1]=="function"&&d[1].apply(null)}):c.apply(this,arguments)}}),i};function id(t){const e=t&&t.navigator,n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(r){return n(r).catch(i=>Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function od(t){"getDisplayMedia"in t.navigator&&t.navigator.mediaDevices&&(t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||(t.navigator.mediaDevices.getDisplayMedia=t.navigator.getDisplayMedia.bind(t.navigator)))}function Go(t,e){if(t.RTCIceGatherer&&(t.RTCIceCandidate||(t.RTCIceCandidate=function(r){return r}),t.RTCSessionDescription||(t.RTCSessionDescription=function(r){return r}),e.version<15025)){const r=Object.getOwnPropertyDescriptor(t.MediaStreamTrack.prototype,"enabled");Object.defineProperty(t.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);const o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}t.RTCRtpSender&&!("dtmf"in t.RTCRtpSender.prototype)&&Object.defineProperty(t.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new t.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),t.RTCDtmfSender&&!t.RTCDTMFSender&&(t.RTCDTMFSender=t.RTCDtmfSender);const n=pf(t,e.version);t.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let s=!1;return(i=JSON.parse(JSON.stringify(i))).filter(c=>{if(c&&(c.urls||c.url)){let d=c.urls||c.url;c.url&&!c.urls&&Pi("RTCIceServer.url","RTCIceServer.urls");const l=typeof d=="string";return l&&(d=[d]),d=d.filter(h=>{if(h.indexOf("stun:")===0)return!1;const a=h.startsWith("turn")&&!h.startsWith("turn:[")&&h.includes("transport=udp");return a&&!s?(s=!0,!0):a&&!s}),delete c.url,c.urls=l?d[0]:d,!!d.length}})}(r.iceServers,e.version),oa("ICE servers after filtering:",r.iceServers)),new n(r)},t.RTCPeerConnection.prototype=n.prototype}function sd(t){t.RTCRtpSender&&!("replaceTrack"in t.RTCRtpSender.prototype)&&(t.RTCRtpSender.prototype.replaceTrack=t.RTCRtpSender.prototype.setTrack)}var Tc=Object.freeze({__proto__:null,shimPeerConnection:Go,shimReplaceTrack:sd,shimGetUserMedia:id,shimGetDisplayMedia:od});function ad(t,e){const n=t&&t.navigator,r=t&&t.MediaStreamTrack;if(n.getUserMedia=function(i,o,s){Pi("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(o,s)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const i=function(s,c,d){c in s&&!(d in s)&&(s[d]=s[c],delete s[c])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),o(s)},r&&r.prototype.getSettings){const s=r.prototype.getSettings;r.prototype.getSettings=function(){const c=s.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(r&&r.prototype.applyConstraints){const s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(c){return this.kind==="audio"&&typeof c=="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[c])}}}}function cd(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Yo(t,e){if(typeof t!="object"||!t.RTCPeerConnection&&!t.mozRTCPeerConnection)return;!t.RTCPeerConnection&&t.mozRTCPeerConnection&&(t.RTCPeerConnection=t.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const o=t.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?t.RTCIceCandidate:t.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};t.RTCPeerConnection.prototype[i]=s[i]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=t.RTCPeerConnection.prototype.getStats;t.RTCPeerConnection.prototype.getStats=function(){const[i,o,s]=arguments;return r.apply(this,[i||null]).then(c=>{if(e.version<53&&!o)try{c.forEach(d=>{d.type=n[d.type]||d.type})}catch(d){if(d.name!=="TypeError")throw d;c.forEach((l,h)=>{c.set(h,Object.assign({},l,{type:n[l.type]||l.type}))})}return c}).then(o,s)}}function ud(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpSender.prototype)return;const e=t.RTCPeerConnection.prototype.getSenders;e&&(t.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(i=>i._pc=this),r});const n=t.RTCPeerConnection.prototype.addTrack;n&&(t.RTCPeerConnection.prototype.addTrack=function(){const r=n.apply(this,arguments);return r._pc=this,r}),t.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function dd(t){if(typeof t!="object"||!t.RTCPeerConnection||!t.RTCRtpSender||t.RTCRtpSender&&"getStats"in t.RTCRtpReceiver.prototype)return;const e=t.RTCPeerConnection.prototype.getReceivers;e&&(t.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(r=>r._pc=this),n}),Cn(t,"track",n=>(n.receiver._pc=n.srcElement,n)),t.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ld(t){t.RTCPeerConnection&&!("removeStream"in t.RTCPeerConnection.prototype)&&(t.RTCPeerConnection.prototype.removeStream=function(e){Pi("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&e.getTracks().includes(n.track)&&this.removeTrack(n)})})}function hd(t){t.DataChannel&&!t.RTCDataChannel&&(t.RTCDataChannel=t.DataChannel)}function fd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.addTransceiver;e&&(t.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const n=arguments[1],r=n&&"sendEncodings"in n;r&&n.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(r){const{sender:o}=i,s=o.getParameters();(!("encodings"in s)||s.encodings.length===1&&Object.keys(s.encodings[0]).length===0)&&(s.encodings=n.sendEncodings,o.sendEncodings=n.sendEncodings,this.setParametersPromises.push(o.setParameters(s).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function pd(t){if(typeof t!="object"||!t.RTCRtpSender)return;const e=t.RTCRtpSender.prototype.getParameters;e&&(t.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function gd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createOffer;t.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 md(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype.createAnswer;t.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 Sc=Object.freeze({__proto__:null,shimOnTrack:cd,shimPeerConnection:Yo,shimSenderGetStats:ud,shimReceiverGetStats:dd,shimRemoveStream:ld,shimRTCDataChannel:hd,shimAddTransceiver:fd,shimGetParameters:pd,shimCreateOffer:gd,shimCreateAnswer:md,shimGetUserMedia:ad,shimGetDisplayMedia:function(t,e){t.navigator.mediaDevices&&"getDisplayMedia"in t.navigator.mediaDevices||t.navigator.mediaDevices&&(t.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,t.navigator.mediaDevices.getUserMedia(n)})}});function _d(t){if(typeof t=="object"&&t.RTCPeerConnection){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){const e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(r=>e.call(this,r,n)),n.getVideoTracks().forEach(r=>e.call(this,r,n))},t.RTCPeerConnection.prototype.addTrack=function(n,...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 t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(e);if(n===-1)return;this._localStreams.splice(n,1);const r=e.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function vd(t){if(typeof t=="object"&&t.RTCPeerConnection&&("getRemoteStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in t.RTCPeerConnection.prototype))){Object.defineProperty(t.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});const e=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(i)>=0)return;n._remoteStreams.push(i);const o=new Event("addstream");o.stream=i,n.dispatchEvent(o)})}),e.apply(n,arguments)}}}function yd(t){if(typeof t!="object"||!t.RTCPeerConnection)return;const e=t.RTCPeerConnection.prototype,n=e.createOffer,r=e.createAnswer,i=e.setLocalDescription,o=e.setRemoteDescription,s=e.addIceCandidate;e.createOffer=function(d,l){const h=arguments.length>=2?arguments[2]:arguments[0],a=n.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 c=function(d,l,h){const a=i.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a};e.setLocalDescription=c,c=function(d,l,h){const a=o.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.setRemoteDescription=c,c=function(d,l,h){const a=s.apply(this,[d]);return h?(a.then(l,h),Promise.resolve()):a},e.addIceCandidate=c}function Cd(t){const e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,r=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=i=>r(Ed(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(n,r,i){e.mediaDevices.getUserMedia(n).then(r,i)}.bind(e))}function Ed(t){return t&&t.video!==void 0?Object.assign({},t,{video:Ju(t.video)}):t}function Rd(t){if(!t.RTCPeerConnection)return;const e=t.RTCPeerConnection;t.RTCPeerConnection=function(n,r){if(n&&n.iceServers){const i=[];for(let o=0;o<n.iceServers.length;o++){let s=n.iceServers[o];!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")?(Pi("RTCIceServer.url","RTCIceServer.urls"),s=JSON.parse(JSON.stringify(s)),s.urls=s.url,delete s.url,i.push(s)):i.push(n.iceServers[o])}n.iceServers=i}return new e(n,r)},t.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(t.RTCPeerConnection,"generateCertificate",{get:()=>e.generateCertificate})}function Td(t){typeof t=="object"&&t.RTCTrackEvent&&"receiver"in t.RTCTrackEvent.prototype&&!("transceiver"in t.RTCTrackEvent.prototype)&&Object.defineProperty(t.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Sd(t){const e=t.RTCPeerConnection.prototype.createOffer;t.RTCPeerConnection.prototype.createOffer=function(n){if(n){n.offerToReceiveAudio!==void 0&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");n.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"):n.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),n.offerToReceiveVideo!==void 0&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");n.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"):n.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return e.apply(this,arguments)}}function Id(t){typeof t!="object"||t.AudioContext||(t.AudioContext=t.webkitAudioContext)}var Ic=Object.freeze({__proto__:null,shimLocalStreamsAPI:_d,shimRemoteStreamsAPI:vd,shimCallbacksAPI:yd,shimGetUserMedia:Cd,shimConstraints:Ed,shimRTCIceServerUrls:Rd,shimTrackEventTransceiver:Td,shimCreateOfferLegacy:Sd,shimAudioContext:Id});function Vr(t){if(!t.RTCIceCandidate||t.RTCIceCandidate&&"foundation"in t.RTCIceCandidate.prototype)return;const e=t.RTCIceCandidate;t.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&((n=JSON.parse(JSON.stringify(n))).candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){const r=new e(n),i=X.parseCandidate(n.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new e(n)},t.RTCIceCandidate.prototype=e.prototype,Cn(t,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new t.RTCIceCandidate(n.candidate),writable:"false"}),n))}function Dn(t,e){if(!t.RTCPeerConnection)return;"sctp"in t.RTCPeerConnection.prototype||Object.defineProperty(t.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});const n=function(c){if(!c||!c.sdp)return!1;const d=X.splitSections(c.sdp);return d.shift(),d.some(l=>{const h=X.parseMLine(l);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},r=function(c){const d=c.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(d===null||d.length<2)return-1;const l=parseInt(d[1],10);return l!=l?-1:l},i=function(c){let d=65536;return e.browser==="firefox"&&(d=e.version<57?c===-1?16384:2147483637:e.version<60?e.version===57?65535:65536:2147483637),d},o=function(c,d){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const h=X.matchPrefix(c.sdp,"a=max-message-size:");return h.length>0?l=parseInt(h[0].substr(19),10):e.browser==="firefox"&&d!==-1&&(l=2147483637),l},s=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const c=r(arguments[0]),d=i(c),l=o(arguments[0],c);let h;h=d===0&&l===0?Number.POSITIVE_INFINITY:d===0||l===0?Math.max(d,l):Math.min(d,l);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>h}),this._sctp=a}return s.apply(this,arguments)}}function xn(t){if(!t.RTCPeerConnection||!("createDataChannel"in t.RTCPeerConnection.prototype))return;function e(r,i){const o=r.send;r.send=function(){const s=arguments[0],c=s.length||s.size||s.byteLength;if(r.readyState==="open"&&i.sctp&&c>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}const n=t.RTCPeerConnection.prototype.createDataChannel;t.RTCPeerConnection.prototype.createDataChannel=function(){const r=n.apply(this,arguments);return e(r,this),r},Cn(t,"datachannel",r=>(e(r.channel,r.target),r))}function Jo(t){if(!t.RTCPeerConnection||"connectionState"in t.RTCPeerConnection.prototype)return;const e=t.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(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const r=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;const s=new Event("connectionstatechange",i);o.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function Wo(t,e){if(!t.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const n=t.RTCPeerConnection.prototype.setRemoteDescription;t.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
  887. a=extmap-allow-mixed`)!==-1){const i=r.sdp.split(`
  888. `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
  889. `);t.RTCSessionDescription&&r instanceof t.RTCSessionDescription?arguments[0]=new t.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return n.apply(this,arguments)}}function Fr(t,e){if(!t.RTCPeerConnection||!t.RTCPeerConnection.prototype)return;const n=t.RTCPeerConnection.prototype.addIceCandidate;n&&n.length!==0&&(t.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():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var gf=Object.freeze({__proto__:null,shimRTCIceCandidate:Vr,shimMaxMessageSize:Dn,shimSendThrowTypeError:xn,shimConnectionState:Jo,removeExtmapAllowMixed:Wo,shimAddIceCandidateNullOrEmpty:Fr});const mf=function({window:t}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=oa,r=function(o){const s={browser:null,version:null};if(o===void 0||!o.navigator)return s.browser="Not a browser.",s;const{navigator:c}=o;if(c.mozGetUserMedia)s.browser="firefox",s.version=kn(c.userAgent,/Firefox\/(\d+)\./,1);else if(c.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)s.browser="chrome",s.version=kn(c.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(c.mediaDevices&&c.userAgent.match(/Edge\/(\d+).(\d+)$/))s.browser="edge",s.version=kn(c.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!c.userAgent.match(/AppleWebKit\/(\d+)\./))return s.browser="Not a supported browser.",s;s.browser="safari",s.version=kn(c.userAgent,/AppleWebKit\/(\d+)\./,1),s.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return s}(t),i={browserDetails:r,commonShim:gf,extractVersion:kn,disableLog:hf,disableWarnings:ff};switch(r.browser){case"chrome":if(!yc||!qo||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=yc,Fr(t,r),Wu(t,r),zu(t),qo(t,r),Qu(t),nd(t,r),Xu(t),Zu(t),ed(t),rd(t,r),Vr(t),Jo(t),Dn(t,r),xn(t),Wo(t,r);break;case"firefox":if(!Sc||!Yo||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=Sc,Fr(t,r),ad(t,r),Yo(t,r),cd(t),ld(t),ud(t),dd(t),hd(t),fd(t),pd(t),gd(t),md(t),Vr(t),Jo(t),Dn(t,r),xn(t);break;case"edge":if(!Tc||!Go||!e.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=Tc,id(t),od(t),Go(t,r),sd(t),Dn(t,r),xn(t);break;case"safari":if(!Ic||!e.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=Ic,Fr(t,r),Rd(t),Sd(t),yd(t),_d(t),vd(t),Td(t),Cd(t),Id(t),Vr(t),Dn(t,r),xn(t),Wo(t,r);break;default:n("Unsupported browser!")}return i}({window:typeof window=="undefined"?void 0:window});var Ct,Re,_e;(function(t){t.FPS_10="FPS_10",t.FPS_15="FPS_15",t.FPS_24="FPS_24",t.FPS_30="FPS_30"})(Ct||(Ct={})),function(t){t.W176_H132="W176_H132",t.W176_H144="W176_H144",t.W256_H144="W256_H144",t.W320_H180="W320_H180",t.W240_H240="W240_H240",t.W320_H240="W320_H240",t.W480_H360="W480_H360",t.W640_H360="W640_H360",t.W480_H480="W480_H480",t.W640_H480="W640_H480",t.W720_H480="W720_H480",t.W1280_H720="W1280_H720",t.W1920_H1080="W1920_H1080"}(Re||(Re={})),function(t){t[t.AUDIO_ONLY=0]="AUDIO_ONLY",t[t.VIDEO_ONLY=1]="VIDEO_ONLY",t[t.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(_e||(_e={}));const bc={[Re.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Re.W176_H144]:{width:176,height:144,maxBitrate:160,minBitrate:80},[Re.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Re.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Re.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Re.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Re.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Re.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Re.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Re.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Re.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Re.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Re.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400}},bd=(t,e)=>{const n=t*e;let r=Number.MAX_VALUE,i=null;for(const o in bc){const s=bc[o],c=Math.abs(s.width*s.height-n);c<r&&(i=s,r=c)}return i},Nc={10:1,15:1,24:1.5,30:1.5},Nd=t=>{let e=Number.MAX_VALUE,n=1;for(const r in Nc){const i=Math.abs(t-parseInt(r));i<e&&(e=i,n=Nc[r])}return n},sa={getCameras:()=>H(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="videoinput")}),getMicrophones:()=>H(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput")}),getSpeakers:()=>H(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audiooutput")})};class aa extends ir{constructor(e,n,r,i,o){super(),this._tag=e,this._userId=n,this._kind=r,this._isLocalTrack=i,this._roomId=o,this._localMuted=!1,this._remoteMuted=!1,this._streamId=[this._userId||this._roomId,this._tag].join("_"),this._id=[this._streamId,this.isAudioTrack()?0:1].join("_")}getStreamId(){return this._streamId}getTrackId(){return this._id}getUserId(){return this._userId}__innerGetMediaStreamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return this._kind==="video"}isAudioTrack(){return this._kind==="audio"}isReady(){var e;return((e=this._msTrack)===null||e===void 0?void 0:e.readyState)==="live"}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const n=this._msStream=this._msStream||new MediaStream,r=n.getTracks()[0];r&&n.removeTrack(r),e?n.addTrack(e):this._element&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e}mute(){O.info(`set ${this._id} enabled: false`),this._setLocalMuted(!0)}unmute(){O.info(`set ${this._id} enabled: true`),this._setLocalMuted(!1)}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}play(e,n){return H(this,void 0,void 0,function*(){if(!this._msTrack)return O.warn(`the track is not ready to play -> id: ${this._id}`),{code:w.TRACK_NOT_READY};if(this._msTrack.readyState==="ended"&&O.warn(`the track's readyState is 'ended' -> id: ${this._id}`),n==null?void 0:n.volume){if(!Ie(n==null?void 0:n.volume))return O.error(`${n==null?void 0:n.volume} is not a number, the valid range of options.volume is 0-100`),{code:w.PARAMS_ERROR};(n==null?void 0:n.volume)<0&&(n.volume=0,O.warn("the valid range of options.volume is 0-100, the value of volume has been set 0")),(n==null?void 0:n.volume)>100&&(n.volume=100,O.warn("the valid range of options.volume is 0-100, the value of volume has been set 100"))}if((n==null?void 0:n.audioDeviceId)&&!(yield sa.getSpeakers()).map(i=>i.deviceId).includes(n.audioDeviceId))return O.error(`the options.audioDeviceId is invalid --> ${n.audioDeviceId}`),{code:w.PARAMS_ERROR};const r=this.isVideoTrack();if(r&&(!e||!(e instanceof HTMLVideoElement)))return O.error(`the video track need an <video> to play -> id: ${this._id}`),{code:w.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 o;O.debug(`HTMLMediaElement onloadstart -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.ondurationchange=i=>{var o;O.debug(`HTMLMediaElement ondurationchange -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onloadedmetadata=i=>{var o;O.debug(`HTMLMediaElement onloadedmetadata -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onloadeddata=i=>{var o;O.debug(`HTMLMediaElement onloadeddata -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onabort=i=>{var o;O.info(`HTMLMediaElement onabort -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.oncanplay=i=>{var o;O.info(`HTMLMediaElement oncanplay -> id: ${(o=i.target)===null||o===void 0?void 0:o.id}, trackId: ${this._id}`)},this._element.onvolumechange=i=>{var o;const s=Math.floor(100*((o=i.target)===null||o===void 0?void 0:o.volume));O.info(`HTMLMediaElement onvolumechange -> volume: ${s}, 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||!(n==null?void 0:n.volume)&&(n==null?void 0:n.volume)!==0||(this._element.volume=(n==null?void 0:n.volume)/100);try{(n==null?void 0:n.audioDeviceId)&&!r?yield this._element.setSinkId(n.audioDeviceId):this._element.play()}catch(i){return i.message==="No permission to use requested device"?(O.error(`setSinkId failed -> ${i.message}`),{code:w.NO_PERMISSION_TO_USE_REQUESTED_DEVICE}):(O.error(i),{code:w.TRACK_PLAY_ERROR})}return{code:w.SUCCESS}})}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&(this._element.remove(),this._element.srcObject=null)}}class pe extends aa{constructor(e,n,r,i){super(e,n,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 n=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,n&&this.emit(pe.__INNER_EVENT_MUTED_CHANGE__,this)}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(){var e;O.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,n=0,r=0){!Ie(e)||!Ie(n)||!Ie(r)||e<=0||n<=0||e<n?O.error("setBitrate params error ->"):this._bitrateInfo={max:e,min:n,start:r}}getBitrate(){var e,n;const{min:r,max:i}=this._msTrack?Ef(this._msTrack):{min:0,max:0};return{min:((e=this._bitrateInfo)===null||e===void 0?void 0:e.min)||r,max:((n=this._bitrateInfo)===null||n===void 0?void 0:n.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 zo extends pe{constructor(e,n,r){super(e,n,"audio",r)}setBitrate(e,n,r){O.warn("`setBitrate` invalid for audio track")}getBitrate(){return{start:32,max:32,min:32}}}class dn extends pe{constructor(e,n,r,i=!1){super(e,n,"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 ln extends pe{constructor(e,n,r,i,o){super(e,n,r,i),this._resource=o,ln.__innerSetMapping(this.getTrackId(),o)}static __innerSetMapping(e,n){const r=this._mapping.get(n)||[];r.push(e),this._mapping.set(n,r)}static __innerRemoveMapping(e,n){var r,i;const o=(r=this._mapping.get(n))===null||r===void 0?void 0:r.filter(s=>s!==e);o&&o.length>0?this._mapping.set(n,o):(this._mapping.delete(n),n.pause(),n.src="",(i=n.parentNode)===null||i===void 0||i.removeChild(n))}destroy(){this.isAudioTrack()&&this.mute(),ln.__innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}ln._mapping=new Map;class _f extends ln{constructor(e,n,r,i){super(e,n,"video",r,i)}}class vf extends ln{constructor(e,n,r,i){super(e,n,"audio",r,i)}_setLocalMuted(e){this._resource&&(this._resource.muted=e),super._setLocalMuted(e)}play(){return this._setLocalMuted(!1),Promise.resolve({code:w.SUCCESS})}}class wc extends zo{}class Oc extends dn{}class yf extends dn{}class Be extends aa{constructor(e,n,r,i){super(e,n,r,!1,i),this._isSubscribed=!1}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class wt extends Be{constructor(e,n,r){super(e,n,"audio",r)}}class Ot extends Be{constructor(e,n,r){super(e,n,"video",r)}}const Or=(t,e)=>({name:t,content:JSON.stringify({uris:e,ignore:!0})}),Ft=t=>JSON.stringify(t),It=t=>/^[a-zA-Z\d-=]+$/g.test(t),Cf=location.protocol!=="http:"||["localhost","127.0.0.1"].includes(location.hostname),ro=t=>{if(t===void 0)return 0;if(Ie(t))return t;const e=t;return e.exact||e.ideal||e.max||0},ca=t=>{const e=t.getConstraints();return{width:ro(e.width),height:ro(e.height),frameRate:ro(e.frameRate)}},Ef=t=>{const{width:e,height:n,frameRate:r}=ca(t),i=bd(e,n),o=Nd(r);return{min:i.minBitrate*o,max:i.maxBitrate*o}},fe=t=>[t.msid,t.mediaType].join("_"),Ke=t=>{const e=t.split("_");return{mediaType:parseInt(e.pop()),tag:e.pop(),userId:e.join("_")}},io=(t,e)=>[t,e].join("_"),Ar=t=>t.map(e=>Object.assign({},e)),Hr=(t,e,n=!1)=>{t=t.slice();const r=[],i=[],o=[];return e.forEach(s=>{const c=fe(s);let d=t.findIndex(h=>fe(h)===c);if(n&&(d=t.findIndex(h=>h.uri===s.uri)),d===-1)return void r.push(s);const l=t[d];l.uri!==s.uri?r.push(s):l.state!==s.state&&o.push(s),t.splice(d,1)}),i.push(...t),{publishedList:r,unpublishedList:i,modifiedList:o}},Rf=()=>{let t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const n=16*Math.random()|0;return(e==="x"?n:3&n|8).toString(16)});return t=t.replace(/-/g,"")+"0",t=parseInt(t,16),t=(e=>{const n="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=n.length+1;let i=+e;const o=[];do{const s=i%r;i=(i-s)/r,o.unshift(n[s])}while(i);return o.join("")})(t),t.length>22&&(t=t.slice(0,22)),t},Et=t=>{const[e,n]=t.split("_").map(r=>parseInt(r.replace(/[^\d]/g,"")));return{width:e,height:n}},sn=t=>!!Re[t],Qo=t=>!!Ct[t],Rt=t=>parseInt(t.replace("FPS_","")),ut=(()=>{const{browser:t,version:e,supportsUnifiedPlan:n}=mf.browserDetails;return{browser:t,version:e,supportsUnifiedPlan:n!==!1}})();function wd(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Od(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const Xo=t=>Object.prototype.toString.call(t)==="[object Null]",jr=t=>t.type===1,Zo=t=>{const e={},n=Object.keys(t.users);return n.length&&n.forEach(r=>{const i=[],o=t.users[r];if(o.uris)try{i.push(...JSON.parse(o.uris))}catch{O.warn(`invalid user data -> userId: ${r}, userData: ${o}`)}e[r]=i}),e};var ce,oi;(function(t){t.PUBLISH="RCRTC:PublishResource",t.UNPUBLISH="RCRTC:UnpublishResource",t.MODIFY="RCRTC:ModifyResource",t.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",t.STATE="RCRTC:state",t.ROOM_NOTIFY="RCRTC:RoomNtf",t.USER_NOTIFY="RCRTC:UserNtf",t.KICK="RCRTC:kick",t.PK_INVITE="RCRTC:invite",t.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",t.PK_CANCEL_INVITE="RCRTC:cancelInvite",t.PK_INVITE_ANSWER="RCRTC:answerInvite",t.PK_END="RCRTC:endInvite",t.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline"})(ce||(ce={})),function(t){t.SUCCESS="Success",t.FAIL="Fail"}(oi||(oi={}));class Tf{constructor(e,n,r,i=1e4){this._roomId=e,this._roomMode=n,this._context=r,this._gap=i,this._latestTimestamp=Date.now(),this._timer=null}start(){return H(this,void 0,void 0,function*(){this._timer||(this._timer=setInterval(this._loop.bind(this),this._gap))})}_loop(){var e,n,r;return H(this,void 0,void 0,function*(){const i=yield new Promise(s=>{this._context.rtcPing(this._roomId,this._roomMode).then(s).catch(c=>{O.error(`rtcping receive unknown error -> ${c}`),s(N.UNKNOWN)}),setTimeout(s,1e4,N.TIMEOUT)}),o=Date.now();if(i===N.SUCCESS)return this._latestTimestamp=o,void((e=this.onPingResult)===null||e===void 0||e.call(this,oi.SUCCESS));(n=this.onPingResult)===null||n===void 0||n.call(this,oi.FAIL),O.warn(`rtcping failed -> code: ${i}`),(i===40003||o-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 at;(function(t){t[t.NORMAL=1]="NORMAL",t[t.TINY=2]="TINY"})(at||(at={}));const Ac=(t,e)=>Math.round(8*e/t),Mc=(t,e=2)=>{const n=10**e;return Math.round(t*n)/n},At=(t,e=2)=>{t>1&&(t/=32767);const n=10**e;return Math.ceil(t*n)},Mr=(t,e,n,r)=>{if(e===0)return 0;if(!n||!r)return Mc(t/e,3);const i=e-r;if(i===0)return 0;const o=t-n;return o<0||i<0?0:Mc(o/i,3)},Ad=t=>{const{jitter:e,rtt:n,packetsLostRate:r}=t;return!Xo(e)||!Xo(n)||r!==0};class ua{constructor(e,n){this._rtcPeerConn=e,this._sdpSemantics=n,this._latestPacketsSent={},this._latestBytesSent={},this._latestBytesRecv={},this._latestPacketsRecv={}}updateBytesSent(e,n,r){let i,o;if(this._latestBytesSent[e]&&n<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:c}=this._latestBytesSent[e];i=n-s,o=r-c,this._latestBytesSent[e]={bytesSent:n,timestamp:r}}else i=n,o=1e3,this._latestBytesSent[e]={bytesSent:n,timestamp:r};return Ac(o,i)}updateBytesRecv(e,n,r){let i,o;if(this._latestBytesRecv[e]&&n<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:c}=this._latestBytesRecv[e];i=n-s,o=r-c,this._latestBytesRecv[e]={bytesRecv:n,timestamp:r}}else i=n,o=1e3,this._latestBytesRecv[e]={bytesRecv:n,timestamp:r};return Ac(o,i)}updateSenderPacketsLost(e,n,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:o,packetsSent:s}=this._latestPacketsSent[e];i=Mr(n,r,o,s),this._latestPacketsSent[e].packetsLost=n,this._latestPacketsSent[e].packetsSent=o===n?s:r}else i=Mr(n,r),this._latestPacketsSent[e].packetsLost=n,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,n,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:o,packetsRecv:s}=this._latestPacketsRecv[e];i=Mr(n,r+n,o,s+o)}else i=Mr(n,r);return this._latestPacketsRecv[e]={packetsLost:n,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach(n=>{if(parseInt(n.split("_").pop())===_e.VIDEO_ONLY){const r=`${n}_tiny`;delete this._latestPacketsSent[r],delete this._latestBytesSent[r]}delete this._latestPacketsSent[n],delete this._latestBytesSent[n]})}clearLatestPacketsRecv(e){e.forEach(n=>{delete this._latestPacketsRecv[n],delete this._latestBytesRecv[n]})}parseRTCStatsReport(e){const n=e.keys(),r={};let i=n.next();for(;!i.done;){const o=i.value,s=e.get(o);/^RTCCodec_/.test(o)||(r[o]=s),i=n.next()}return r}formatRCRTCStateReport(e){return{senders:[],receivers:[]}}getAudioLevelList(e){return[]}getResourceIdByParseSdp(e){var n,r;const i=e.ssrc,o=e.kind||e.mediaType,s=(n=this._rtcPeerConn.currentLocalDescription)===null||n===void 0?void 0:n.sdp,c=(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=s==null?void 0:s.split(`\r
  890. m=`),h=l==null?void 0:l.filter(_=>_.includes(`a=ssrc:${i}`))[0],a=h==null?void 0:h.match(d);let u=a?a[1]:"";if(u)return`${u}_${o==="video"?1:0}`;const f=c==null?void 0:c.split(`\r
  891. m=`),p=f==null?void 0:f.filter(_=>_.includes(`a=ssrc:${i}`))[0],m=p==null?void 0:p.match(d);return u=m?m[1]:"",`${u}_${o==="video"?1:0}`}isValidSender(e){var n;const r=(n=this._rtcPeerConn.currentLocalDescription)===null||n===void 0?void 0:n.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
  892. m=`).some(o=>o.includes(i)&&o.includes("a=inactive")))}isValidReceiver(e){var n;const r=(n=this._rtcPeerConn.currentRemoteDescription)===null||n===void 0?void 0:n.sdp,{ssrc:i}=e;return!(r==null?void 0:r.split(`\r
  893. m=`).some(o=>o.includes(i)&&o.includes("a=inactive")))}}class Sf extends ua{formatRCRTCStateReport(e){const n={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);n.timestamp=r;const i=Object.keys(e);let o=0,s=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:u,transportId:f,mediaSourceId:p,remoteId:m,packetsSent:_,bytesSent:v,trackId:y,encoderImplementation:C,pliCount:I,nackCount:P,firCount:b}=h;if(!y)return;let{framesPerSecond:R,frameWidth:M,frameHeight:F}=h;u!=="video"||M||F||R||(M=e[y].frameWidth,F=e[y].frameHeight,R=p?e[p].framesPerSecond:null);const q=e[m];let E=null,T=null,A=0;q&&(E=q.jitter,T=q.roundTripTime,A=q.packetsLost),o+=A;const L=this.getResourceIdByParseSdp(h),k=p?e[p].audioLevel:e[y].audioLevel;let V=null;!this._latestPacketsSent[L]&&(this._latestPacketsSent[L]={}),q?V=this.updateSenderPacketsLost(L,A,_):this._latestPacketsSent[L].crtPacketsSent=_;let j=this.updateBytesSent(L,v,r);j<0&&(j=0),s+=j,n.senders.push({id:a,trackId:L,kind:u,packetsLostRate:V,remoteResource:!1,audioLevel:k||k===0?At(k):null,frameWidth:M,frameHeight:F,frameRate:R,bitrate:j,jitter:E&&Math.round(1e3*E),rtt:T,encoderImplementation:C,pliCount:I,nackCount:P,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:u,packetsLost:f}=e[l],p=n.senders.filter(m=>m.id===h)[0];if(p&&!Ad(p)){const m=this.getResourceIdByParseSdp(e[p.id]);p.jitter=Math.round(1e3*a),p.rtt=u;const _=this._latestPacketsSent[m].crtPacketsSent;p.packetsLostRate=this.updateSenderPacketsLost(m,f,_)}});let c=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:u,packetsReceived:f,jitter:p,bytesReceived:m,framesPerSecond:_,kind:v,codecImplementationName:y,nackCount:C,pliCount:I}=h;if(!a)return;let{frameWidth:P,frameHeight:b,audioLevel:R}=h;v==="video"?P||b||(P=e[a].frameWidth,b=e[a].frameHeight):R||(R=e[a].audioLevel),o+=u;const M=this.getResourceIdByParseSdp(h),F=this.updateReceiverPacketsLost(M,u,f);let q=this.updateBytesRecv(M,m,r);q<0&&(q=0),c+=q,n.receivers.push({trackId:M,kind:v,packetsLostRate:F,remoteResource:!0,audioLevel:R||R===0?At(R):null,frameWidth:P,frameHeight:b,frameRate:_,bitrate:q,jitter:p?Math.round(1e3*p):0,codecImplementationName:y,nackCount:C,pliCount:I,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:u,availableIncomingBitrate:f,currentRoundTripTime:p,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{ip:y,port:C,networkType:I}=v,P=e[_],{ip:b,port:R,protocol:M}=P;n.iceCandidatePair={IP:y,port:C,networkType:I,remoteIP:b,remotePort:R,protocol:M,bitrateRecv:c,bitrateSend:s,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:o},n.receivers.forEach(F=>{F.rtt=p})}}return n}getAudioLevelList(e){const n=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTPAudioStream_/.test(i)).forEach(i=>{var o;const s=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(s))return;const{mediaSourceId:c,trackId:d}=s,l=this.getResourceIdByParseSdp(s),h=c&&e[c]?e[c].audioLevel:((o=e[d])===null||o===void 0?void 0:o.audioLevel)||null;n.push({trackId:l,audioLevel:h||h===0?At(h):null})}),r.filter(i=>/^RTCInboundRTPAudioStream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(o))return;const{trackId:s}=o,c=o.audioLevel||e[s].audioLevel,d=this.getResourceIdByParseSdp(o);n.push({trackId:d,audioLevel:c||c===0?At(c):null})}),n}}class If extends ua{formatRCRTCStateReport(e){const n=+new Date,r={senders:[],receivers:[],timestamp:n};let i=0,o=0,s=0;for(const c in e){const d=e[c],l=d.type;if(l==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(d))continue;const{id:h,kind:a,bytesSent:u,packetsSent:f,bitrateMean:p,framerateMean:m,nackCount:_,pliCount:v,remoteId:y}=d,{jitter:C,roundTripTime:I,packetsLost:P}=y?e[y]:{jitter:null,roundTripTime:null,packetsLost:0},b=this.getResourceIdByParseSdp(d);i+=P;let R=null;!this._latestPacketsSent[b]&&(this._latestPacketsSent[b]={}),y?R=this.updateSenderPacketsLost(b,P,f):this._latestPacketsSent[b].crtPacketsSent=f;let M=0;a==="video"?p&&(M=Math.floor(p/1e3)):M=this.updateBytesSent(b,u,n),M<0&&(M=0),o+=M,r.senders.push({trackId:b,kind:a,packetsLostRate:R,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:M,jitter:C?Math.round(1e3*C):null,rtt:I,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]),u=r.senders.filter(f=>f.trackId===a)[0];u&&Ad(u)&&(u.jitter=Math.round(1e3*d.jitter),u.rtt=d.rtt,u.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:u,packetsReceived:f,jitter:p,framerateMean:m,kind:_,bitrateMean:v,nackCount:y,pliCount:C}=d,I=this.getResourceIdByParseSdp(d);i+=a;const P=this.updateReceiverPacketsLost(I,a,f);let b=0;_==="video"?v&&(b=Math.floor(v/1e3)):b=this.updateBytesRecv(I,u,n),b<0&&(b=0),s+=b,r.receivers.push({trackId:I,kind:_,packetsLostRate:P,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(m),bitrate:b,jitter:p?Math.round(1e3*p):null,codecImplementationName:null,nackCount:y,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:u}=h,f=e[d.remoteCandidateId],{address:p,port:m,protocol:_}=f;r.iceCandidatePair={IP:a,port:u,networkType:null,remoteIP:p,remotePort:m,protocol:_,bitrateRecv:s,bitrateSend:o,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:i}}}return r.iceCandidatePair&&(r.iceCandidatePair.bitrateSend=o),r.iceCandidatePair&&(r.iceCandidatePair.bitrateRecv=s),r}getAudioLevelList(e){const n=[];for(const r in e){const i=e[r],o=i.type;if(o==="outbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(i))continue;const{kind:s}=i;if(s==="video")continue;const c=this.getResourceIdByParseSdp(i);n.push({trackId:c,audioLevel:null})}if(o==="inbound-rtp"){if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(i))continue;const{kind:s}=i;if(s==="video")continue;const c=this.getResourceIdByParseSdp(i);n.push({trackId:c,audioLevel:null})}}return n}}class bf extends ua{formatRCRTCStateReport(e){const n={senders:[],receivers:[]},r=Math.floor(e.RTCPeerConnection.timestamp);n.timestamp=r;const i=Object.keys(e);let o=0,s=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:u,transportId:f,remoteId:p,packetsSent:m,bytesSent:_,trackId:v,encoderImplementation:y,pliCount:C,nackCount:I,firCount:P}=h;if(!v)return;const{audioLevel:b,frameHeight:R,frameWidth:M}=e[v];let F=this.updateBytesSent(a,_,r);F<0&&(F=0),s+=F,n.senders.push({trackId:a,kind:u,packetsLostRate:null,remoteResource:!1,audioLevel:b||b===0?At(b):null,frameWidth:M,frameHeight:R,frameRate:null,bitrate:F,jitter:null,rtt:null,encoderImplementation:y,pliCount:C,nackCount:I,googFirsSent:-1,samplingRate:-1,googRenderDelayMs:-1,trackState:-1})});let c=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:u,packetsReceived:f,jitter:p,bytesReceived:m,mediaType:_,nackCount:v,pliCount:y}=h,C=this.getResourceIdByParseSdp(h);if(!a)return;const{frameHeight:I,frameWidth:P,audioLevel:b}=e[a];o+=u;const R=this.updateReceiverPacketsLost(C,u,f);let M=this.updateBytesRecv(C,m,r);M<0&&(M=0),c+=M,n.receivers.push({trackId:C,kind:_,packetsLostRate:R,remoteResource:!0,audioLevel:b||b===0?At(b):null,frameWidth:P,frameHeight:I,frameRate:null,bitrate:M,jitter:p,codecImplementationName:null,nackCount:v,pliCount:y,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:u,availableIncomingBitrate:f,currentRoundTripTime:p,localCandidateId:m,remoteCandidateId:_}=a,v=e[m],{address:y,port:C}=v,I=e[_],{address:P,port:b,protocol:R}=I;n.iceCandidatePair={IP:y||null,port:C,networkType:null,remoteIP:P,remotePort:b,protocol:R,bitrateRecv:c,bitrateSend:s,rtt:1e3*p,availableOutgoingBitrate:u,availableIncomingBitrate:f,totalPacketsLost:o},n.receivers.forEach(M=>{M.rtt=p})}}return n}getAudioLevelList(e){const n=[],r=Object.keys(e);return r.filter(i=>/^RTCOutboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidSender(o))return;const{trackId:s,mediaType:c}=o;if(c==="video")return;const d=this.getResourceIdByParseSdp(o),l=e[s];n.push({trackId:d,audioLevel:l||l===0?At(l):null})}),r.filter(i=>/^RTCInboundRTP(Video|Audio)Stream_/.test(i)).forEach(i=>{const o=e[i];if(this._sdpSemantics==="unified-plan"&&!this.isValidReceiver(o))return;const{trackId:s,mediaType:c}=o;if(!s||c==="video")return;const{audioLevel:d}=e[s],l=this.getResourceIdByParseSdp(o);n.push({trackId:l,audioLevel:d||d===0?At(d):null})}),n}}class En{constructor(e){this._peer=e,this._outboundStreams={}}static setSdpSemantics(e){const{browser:n,version:r,supportsUnifiedPlan:i}=ut;i?/chrome/i.test(n)?this._sdpSemantics=r>92?"unified-plan":r<72?"plan-b":e:/firefox/i.test(n)?this._sdpSemantics="unified-plan":/safari/i.test(n)?this._sdpSemantics=r<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan":this._sdpSemantics="plan-b"}static getSdpSemantics(){return En._sdpSemantics}getOutboundVideoInfo(){const e=[];for(const n in this._outboundStreams){const r=this._outboundStreams[n].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(n),{width:o,height:s}=ca(r);e.push({trackId:r.id,simulcast:i?at.TINY:at.NORMAL,resolution:`${o}x${s}`})}return e}setRemoteAnswer(e){return H(this,void 0,void 0,function*(){e=e.replace(/\s+\r\n/g,`\r
  894. `);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(n){return O.error(n),w.SET_REMOTE_DESCRIPTION_FAILED}return w.SUCCESS})}getStatParsr(e,n){return/chrome/i.test(ut.browser)?new Sf(e,n):/Firefox/i.test(ut.browser)?new If(e,n):/Safari/i.test(ut.browser)?new bf(e,n):null}}class Nf extends En{constructor(){super(...arguments),this.senders={},this._localTracks=[]}addLocalTrack(e){this._localTracks.includes(e)||this._localTracks.push(e);const n=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[n]||(this._outboundStreams[n]=new MediaStream);i.getTracks().forEach(c=>{c.kind===r.kind&&i.removeTrack(c)}),i.addTrack(r);const o=e.getTrackId(),s=this.senders[o];s?s.replaceTrack(r):this.senders[o]=this._peer.addTrack(r,i)}removeLocalTrack(e){const n=this._localTracks.findIndex(o=>o===e);n>=0&&this._localTracks.splice(n,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,n){}setBitrate(e,n,r){this._maxBitrate=e,this._minBitrate=n,this._startBitrate=r||.7*e}createOffer(e){return H(this,void 0,void 0,function*(){const n=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const r in this._outboundStreams){const i=this._outboundStreams[r].id;n.sdp=n.sdp.replace(new RegExp(i,"g"),r)}return yield this._peer.setLocalDescription(n),{type:"offer",semantics:"plan-b",sdp:n.sdp}})}setRemoteAnswer(e){let n=0,r=0;this._localTracks.forEach(c=>{const{min:d,max:l}=c.getBitrate();r+=d,n+=l}),n=this._maxBitrate&&this._maxBitrate>0?Math.min(n,this._maxBitrate):n,r=this._minBitrate&&this._minBitrate>0?Math.max(r,this._minBitrate):r;const i=this._startBitrate||Math.round(.7*n),o=`b=AS:${n}`;e=e.replace(/[\r\n]+m=video[^\r\n]+/,c=>`${c}\r
  895. ${o}`);const s=[`;x-google-min-bitrate=${r}`,`;x-google-max-bitrate=${n}`,`;x-google-start-bitrate=${i}`].join("");return e=e.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,c=>c+s),super.setRemoteAnswer(e)}}class wf extends En{constructor(){super(...arguments),this._sendTransceiver={},this._localTracks={},this._recvAudio=[],this._recvVideo=[],this._recvTransceiver={},this._subedTracks=[]}setBitrate(e,n,r){O.warn("the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}addLocalTrack(e){const n=e.getTrackId(),r=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[n]=e;const o=this._outboundStreams[r]||(this._outboundStreams[r]=new MediaStream);o.getTracks().forEach(c=>{c.kind===i.kind&&o.removeTrack(c)}),o.addTrack(i);const s=this._sendTransceiver[n];s?(s.sender.replaceTrack(i),s.direction="sendonly"):this._sendTransceiver[n]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[o]})}removeLocalTrack(e){const n=e.getTrackId(),r=e.getStreamId();e.__innerGetMediaStreamTrack(),delete this._localTracks[n];const i=this._sendTransceiver[n];if(!i)return;i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null);const o=this._outboundStreams[r];(e.isAudioTrack()?o.getAudioTracks():o.getVideoTracks()).forEach(l=>o.removeTrack(l));const s=this._sendTransceiver[`${n}_tiny`];if(!s||s.direction==="inactive")return;s.direction="inactive";const c=s.sender,d=c.track;this._peer.removeTrack(c),c.replaceTrack(null),this._outboundStreams[`${r}_tiny`].removeTrack(d),d.stop()}updateRecvTransceiverMap(e,n){const{mediaType:r}=Ke(e);this._recvTransceiver[e]=n;const i=r===_e.AUDIO_ONLY?this._recvAudio:this._recvVideo,o=i.findIndex(s=>s===n);o>=0&&i.splice(o,1)}updateSubRemoteTracks(e){const n=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let o=n.length-1;o>=0;o-=1){const s=n[o],c=r.findIndex(d=>d===s);c>=0&&(n.splice(o,1),r.splice(c,1))}r.length&&r.forEach(o=>{const s=o.getTrackId();o.__innerSetMediaStreamTrack(void 0);const c=this._recvTransceiver[s];c&&(c.direction="inactive")});const i={audio:0,video:0};n.length&&n.forEach(o=>{const s=o.isAudioTrack()?"audio":"video",c=this._recvTransceiver[o.getTrackId()];c?c.direction="recvonly":i[s]+=1});for(let o=this._recvAudio.length;o<i.audio;o+=1)this._recvAudio.push(this._peer.addTransceiver("audio",{direction:"recvonly"}));for(let o=this._recvVideo.length;o<i.video;o+=1)this._recvVideo.push(this._peer.addTransceiver("video",{direction:"recvonly"}))}createOffer(e){return H(this,void 0,void 0,function*(){const n=yield this._peer.createOffer({iceRestart:e});let r=n.sdp;for(const i in this._outboundStreams){const o=this._outboundStreams[i].id;r=r.replace(new RegExp(o,"g"),i)}return r=(i=>i.split(/\r\n(?=m=)/).map(o=>(s=>/a=(recvonly|inactive)/.test(s)?s.replace(/\r\na=(ssrc|msid)[^\r\n]+/g,""):s)(o)).join(`\r
  896. `))(r),r=r.replace(/a=ice-options:trickle/g,`a=ice-options:trickle\r
  897. a=ice-options:renomination`),n.sdp=r,yield this._peer.setLocalDescription(n),{type:"offer",semantics:"unified-plan",sdp:r}})}setRemoteAnswer(e){e=e.split(/\r\n(?=m=)/).map(r=>{var i;const o=r.match(/a=mid:[^\s]+/);if(!o)return r;const s=o[0].replace("a=mid:","");let c="";for(const p in this._sendTransceiver)if(this._sendTransceiver[p].mid===s){c=p;break}if(!c)return r;const d=(i=this._localTracks[c])===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,u=[];if(l&&l>0&&u.push(`;x-google-max-bitrate=${l}`),h&&h>0&&u.push(`;x-google-min-bitrate=${h}`),a>0&&u.push(`;x-google-start-bitrate=${a}`),u.length===0)return r;const f=u.join("");return r.replace(/[\r\n]+[^\r\n]+profile-level-id[^\r\n]+/g,p=>p+f)}).join(`\r
  898. `);const n=/[\r\n]+\r\n[\r\n]+/g;return n.test(e)&&(O.warn(`answer sdp invalid -> ${JSON.stringify(e)}`),e=e.replace(n,`\r
  899. `)),super.setRemoteAnswer(e)}}class St extends ir{constructor(e,n){super(),this._reTryExchange=e,this._polarisReport=n,this.pubLocalTracks={},this._reTryExchangeTimer=null,this._reportStatsTimer=null,this._reportListener=null;const r=En.getSdpSemantics(),i=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:r});this._sdpStrategy=r==="plan-b"?new Nf(i):new wf(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(){O.info(`onconnectionstatechange -> ${this._rtcPeerConn.connectionState}`)}_onICEConnectionStateChange(){var e,n;O.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"||(O.warn("iceconenction state is `failed`, exchange SDP to try again."),this._reTryExchange(),this._reTryExchangeTimer=setInterval(this._reTryExchange,15e3));try{(n=(e=this._reportListener)===null||e===void 0?void 0:e.onICEConnectionStateChange)===null||n===void 0||n.call(e,this._rtcPeerConn.iceConnectionState)}catch(r){O.error("onICEConnectionStateChange error",r)}}_onTrackReady(e){if(!e.streams.length)return;const n=[e.streams[0].id,e.receiver.track.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY].join("_");this._updateRecvTransceiverMap(n,e.transceiver),this.emit(St.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,n,r){return H(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,n,r)})}createOffer(e){return H(this,void 0,void 0,function*(){const n=yield this._sdpStrategy.createOffer(e);return O.debug(`offer -> ${JSON.stringify(n.sdp)}`),n})}setRemoteAnswer(e){return H(this,void 0,void 0,function*(){return O.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 n=this.getLocalTrack(e);n&&this.removeLocalTrack(n)}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach(e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)})}removeLocalTrack(e){const n=e.getTrackId();delete this.pubLocalTracks[n],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=`${n}_tiny`,i=this.getLocalTrack(r);i&&(this._sdpStrategy.removeLocalTrack(i),delete this.pubLocalTracks[r],i.destroy())}_updateRecvTransceiverMap(e,n){this._sdpStrategy.updateRecvTransceiverMap(e,n)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e){const n=this.getLocalTrack(`${e.getTrackId()}_tiny`);n&&(n.__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:n,iceCandidatePair:r,senders:i,receivers:o}=JSON.parse(JSON.stringify(e));r==null||delete r.totalPacketsLost;for(const s in r)Xo(r[s])&&delete r[s];return{timestamp:n,iceCandidatePair:r,senders:i.map(s=>{const c={};return s.trackId&&(c.trackId=s.trackId),s.kind&&(c.kind=s.kind),(s.packetsLostRate||s.packetsLostRate===0)&&(c.packetsLostRate=s.packetsLostRate),c.remoteResource=s.remoteResource,(s.audioLevel||s.audioLevel===0)&&(c.audioLevel=s.audioLevel),s.frameWidth&&(c.frameWidth=s.frameWidth),s.frameHeight&&(c.frameHeight=s.frameHeight),s.frameRate&&(c.frameRate=s.frameRate),(s.bitrate||s.bitrate===0)&&(c.bitrate=s.bitrate),s.jitter&&(c.jitter=s.jitter),c}),receivers:o.map(s=>{const c={};return s.trackId&&(c.trackId=s.trackId),s.kind&&(c.kind=s.kind),(s.packetsLostRate||s.packetsLostRate===0)&&(c.packetsLostRate=s.packetsLostRate),c.remoteResource=s.remoteResource,(s.audioLevel||s.audioLevel===0)&&(c.audioLevel=s.audioLevel),s.frameWidth&&(c.frameWidth=s.frameWidth),s.frameHeight&&(c.frameHeight=s.frameHeight),s.frameRate&&(c.frameRate=s.frameRate),(s.bitrate||s.bitrate===0)&&(c.bitrate=s.bitrate),s.jitter&&(c.jitter=s.jitter),c})}}_getStatsData(){var e,n;return H(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(n=this.reportParser)===null||n===void 0?void 0:n.formatRCRTCStateReport(i)})}getAudioLevelReportData(){var e,n;return H(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?(n=this.reportParser)===null||n===void 0?void 0:n.getAudioLevelList(i):[]})}_reportHandle(){var e,n,r;return H(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 o=this._createRCRTCStateReport(i);(r=(n=this._reportListener)===null||n===void 0?void 0:n.onStateReport)===null||r===void 0||r.call(n,o)})}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 tn,si,Mt,Pt,ai;St.__INNER_EVENT_TRACK_READY__="inner-track-ready",function(t){t[t.DISABLE=0]="DISABLE",t[t.ENABLE=1]="ENABLE"}(tn||(tn={})),function(t){t[t.MeetingOrAnchor=1]="MeetingOrAnchor",t[t.Audience=2]="Audience"}(si||(si={}));class Md{constructor(e,n,r,i,o=si.MeetingOrAnchor){this._context=e,this._runtime=n,this._roomId=r,this._crtRTCRoom=i,this._userRole=o}_send(e){this._context.getConnectionStatus()===ne.CONNECTED&&this._context.setRTCState(this._roomId,e)}_getClientID(){const e="uuid";let n=this._runtime.localStorage.getItem(e);return n||(n=Rf(),this._runtime.localStorage.setItem(e,n)),n}_getRealResourceId(e){let n=e;const r=e.indexOf("_tiny");return r>-1&&(n=e.slice(0,r)),n}_getPolarisTrackId(e){let n="";const r=e.split("_");if(e.includes("_tiny")){const i=r.pop(),o=parseInt(r.pop())===_e.AUDIO_ONLY?"audio":"video",s=r.pop();n=[r.join("_"),s,i,o].join("_")}else{const i=parseInt(r.pop())===_e.AUDIO_ONLY?"audio":"video",o=r.pop();n=[r.join("_"),o,i].join("_")}return n}sendR3R4Data(e){const{iceCandidatePair:n,senders:r,receivers:i}=e,o=(n==null?void 0:n.bitrateSend)||-1,s=(n==null?void 0:n.bitrateRecv)||-1,c=(n==null?void 0:n.networkType)||"unknown",d=(n==null?void 0:n.rtt)||-1,l=`${(n==null?void 0:n.IP)||-1}:${n==null?void 0:n.port}`,h=(n==null||n.remoteIP,n==null||n.remotePort,(n==null?void 0:n.availableIncomingBitrate)||-1),a=(n==null?void 0:n.availableOutgoingBitrate)||-1,u=(n==null?void 0:n.totalPacketsLost)||-1,f=this._context.getCurrentId();let p=`R3 ${o} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`,m=`R4 ${s} -1 -1 -1 ${c} ${d} ${l} ${h} ${a} ${u} ${f}\r`;const _=r.map(y=>{var C;const{trackId:I,audioLevel:P,samplingRate:b,bitrate:R,packetsLostRate:M,frameRate:F,frameWidth:q,frameHeight:E,googRenderDelayMs:T,jitter:A,nackCount:L,pliCount:k,rtt:V,googFirsSent:j,encoderImplementation:G}=y,J=this._getPolarisTrackId(I),oe=this._getRealResourceId(I);return{trackId:J,googCodecName:G||String(-1),audioLevel:P||P===0?P:-1,bitrate:R||R===0?R:-1,packetsLostRate:M||M===0?M:-1,frameRate:F||-1,resolution:q&&E?`${q} * ${E}`:"-1",jitter:A||-1,nackCount:L||L===0?L:-1,pliCount:k||k===0?k:-1,rtt:V||-1,googFirsSent:j,samplingRate:b,googRenderDelayMs:T,encoderImplementation:G||String(-1),trackState:((C=this._crtRTCRoom.getLocalTrack(oe))===null||C===void 0?void 0:C.isLocalMuted())?tn.DISABLE:tn.ENABLE}}),v=i.filter(y=>!!y.trackId).map(y=>{var C;const{trackId:I,audioLevel:P,samplingRate:b,bitrate:R,packetsLostRate:M,frameRate:F,frameWidth:q,frameHeight:E,googRenderDelayMs:T,jitter:A,nackCount:L,pliCount:k,rtt:V,googFirsReceived:j,codecImplementationName:G}=y,J=this._getPolarisTrackId(I),oe=this._getRealResourceId(I);return{trackId:J,googCodecName:G||String(-1),audioLevel:P||P===0?P:-1,bitrate:R||R===0?R:-1,packetsLostRate:M||M===0?M:-1,frameRate:F||-1,resolution:q&&E?`${q} * ${E}`:"-1",jitter:A||-1,nackCount:L||L===0?L:-1,pliCount:k||k===0?k:-1,rtt:V||-1,googFirsReceived:j,samplingRate:b,googRenderDelayMs:T,codecImplementationName:G||String(-1),trackState:((C=this._crtRTCRoom.getRemoteTrack(oe))===null||C===void 0?void 0:C.isLocalMuted())?tn.DISABLE:tn.ENABLE}});p+=_.map(y=>`${y.trackId} ${y.googCodecName} ${y.audioLevel} ${y.samplingRate} ${y.bitrate} ${y.packetsLostRate} ${y.frameRate} ${y.resolution} ${y.googRenderDelayMs} ${y.jitter} ${y.nackCount} ${y.pliCount} ${y.rtt} ${y.googFirsSent} ${y.encoderImplementation} ${y.trackState}`).join(`
  900. `),e.senders.length&&this._send(p+`\r${this._userRole}`),m+=v.map(y=>`${y.trackId} ${y.googCodecName} ${y.audioLevel} ${y.samplingRate} ${y.bitrate} ${y.packetsLostRate} ${y.frameRate} ${y.resolution} ${y.googRenderDelayMs} ${y.jitter} ${y.nackCount} ${y.pliCount} ${y.rtt} ${y.googFirsReceived} ${y.codecImplementationName} ${y.trackState}`).join(`
  901. `),e.receivers.length&&this._send(m+`\r${this._userRole}`)}sendR1(){const e=`R1 5.3.1 ${this._context.getCoreVersion()} web ${navigator.platform} -1 ${ut.browser} ${ut.version} ${this._getClientID()} ${this._userRole}`;this._send(e)}sendR2(e,n,r){const i=`R2 ${e} ${n} ${this._getClientID()}\r${r.join(" ")}\r${this._userRole}`;this._send(i)}}(function(t){t.PUBLISH="publish",t.SUBSCRIBE="subscribe"})(Mt||(Mt={})),function(t){t.BEGIN="begin",t.END="end"}(Pt||(Pt={}));class Pd{constructor(e){this._room=e,this._audioLevelChangeHandler=null,this._timer=null,this._pc=this._room.__getPC()}_audioLevelReport(){return H(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().iceConnectionState==="new"||!this._audioLevelChangeHandler)return;const e=(yield this._pc.getAudioLevelReportData()).map(n=>{const{userId:r}=Df.parseTrackId(n.trackId);return{track:this._room.getCrtUserId()===r?this._room.getLocalTrack(n.trackId):this._room.getRemoteTrack(n.trackId),audioLevel:n.audioLevel||0}}).filter(n=>n.track);this._audioLevelChangeHandler(e)})}onAudioLevelChange(e,n){n<300||n>1e3?O.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000'):e?(this._audioLevelChangeHandler=e,this._timer=setInterval(this._audioLevelReport.bind(this),n)):this._audioLevelChangeHandler=null}clearAudioLevelReportTimer(){this._timer&&(clearInterval(this._timer),this._timer=null)}}(function(t){t[t.ANCHOR=1]="ANCHOR",t[t.AUDIENCE=2]="AUDIENCE"})(ai||(ai={}));const Un=t=>t instanceof aa?t.getTrackId():t.track.getTrackId();class Ld{constructor(e,n,r,i,o,s,c,d,l,h){this._context=e,this._runtime=n,this._roomId=r,this._roomMode=o,this._service=s,this._initOptions=c,this._ntfClearRoomItem=d,this._isMainRoom=h,this._remoteTracks={},this._subscribedList=[],this._destroyed=!1,this.msgTaskQueue=new qu,this._appListener=null,this._onRecvPKMsg=null,this._token=i.token,this._sessionId=i.sessionId,this._roomResources=l?{}:Zo(i),this._initRemoteTracks();const a=this._context.getCurrentId(),u=this._roomResources[a]=this._roomResources[a]||[];O.debug(`room data -> ${JSON.stringify(this._roomResources)}`),u.length>0&&be(()=>this._unpublishPrev(u)),l&&this._afterChangedRole(i),this._pinger=new Tf(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 Md(this._context,this._runtime,this._roomId,this),this._polarisReport.sendR1(),this._pc=new St(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(St.__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 n in this._roomResources){const r=this._roomResources[n];n!==e&&r.length!==0&&r.forEach(i=>{const o=fe(i),{tag:s,userId:c,mediaType:d}=Ke(o),l=d===_e.AUDIO_ONLY?new wt(s,c):new Ot(s,c);l.__innerSetRemoteMuted(i.state===0),this._remoteTracks[o]=l})}}_handlePingResult(e){this._callAppListener("onPing",e)}setBitrate(e,n,r){O.warn("`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),De("max",e,i=>Ie(i)&&i>Math.max(n||1,200),!0),De("min",n,i=>Ie(i)&&i>=1&&(!Ie(e)||i<e),!0),De("start",r,i=>Ie(i)&&i>n&&i<=e),this._pc.setBitrate(e,n,r)}_onTrackReady(e){const n=e.streams[0].id,r=e.receiver.track,i=[n,r.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY].join("_"),o=this._remoteTracks[i];o?(o.__innerSetMediaStreamTrack(r),this._callAppListener("onTrackReady",o)):O.warn(`cannot found remote track ${r.id}`)}_callAppListener(e,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){O.error(o)}}_onUserUnpublish(e){return H(this,void 0,void 0,function*(){yield this.unsubscribe(e),e.forEach(n=>{n.__innerDestroy(),delete this._remoteTracks[n.getTrackId()]}),this._onTrackUnpublish(e)})}_onTrackUnpublish(e){this._callAppListener("onTrackUnpublish",e)}_unpublishPrev(e){return H(this,void 0,void 0,function*(){const n=e.slice();e.length=0,O.info(`unpublish uris prev login: ${JSON.stringify(n)}`);const r=yield this._context.setRTCTotalRes(this._roomId,Or(ce.UNPUBLISH,n),Ft([]),ce.TOTAL_CONTENT_RESOURCE,Ft([]));r!==N.SUCCESS?O.error(`unpublish prev uris failed -> code: ${r}`):O.debug("unpublish uris prev login succeed")})}__parseInnerMessage(e){const{targetId:n,conversationType:r}=e;if(r!==z.RTC_ROOM)return!1;if(n!==this._roomId)return!0;O.info(`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`);const i=e.content;switch(e.messageType){case ce.KICK:this._kickoff(!0,i);break;case ce.STATE:this.msgTaskQueue.push(()=>this._stateHandle(i));break;case ce.MODIFY:case ce.PUBLISH:case ce.UNPUBLISH:case ce.TOTAL_CONTENT_RESOURCE:this.msgTaskQueue.push(()=>this._resourceHandle(i,e.messageType,e.senderUserId));break;case ce.ROOM_NOTIFY:this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case ce.USER_NOTIFY:O.warn(`TODO: ${ce.USER_NOTIFY}`);break;case ce.PK_INVITE:case ce.PK_CANCEL_INVITE:case ce.PK_INVITE_TIMEOUT:case ce.PK_INVITE_ANSWER:case ce.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case ce.OTHER_ROOM_OFFLINE:break;default:this._callAppListener("onMessageReceive",e.messageType,e.content,e.senderUserId,e.messageUId)}return!0}_kickoff(e,n){let r;O.warn(`onKickOff -> byServer: ${e}`),this._ntfClearRoomItem(),this._leaveHandle(!e),e&&((n==null?void 0:n.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,n,r){return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return void O.warn(`room has been destroyed. -> roomId: ${this._roomId}`);const{uris:i,ignore:o}=e;if(o||!i)return;const s=[],c=[],d=[];let l;const h=this._roomResources[r]||(this._roomResources[r]=[]);switch(n){case ce.MODIFY:d.push(...i);break;case ce.PUBLISH:s.push(...i);break;case ce.UNPUBLISH:c.push(...i);break;case ce.TOTAL_CONTENT_RESOURCE:l=Hr(h,i),s.push(...l.publishedList),c.push(...l.unpublishedList),d.push(...l.modifiedList)}if(s.length>0){const a=h.map(fe),u=[],f=[];if(s.forEach(p=>{const m=fe(p),_=a.indexOf(m),{userId:v,tag:y,mediaType:C}=Ke(m);_>-1?h[_]=p:h.push(p);let I=this._remoteTracks[m];I?I.isSubscribed()&&u.push(I):(I=C===_e.AUDIO_ONLY?new wt(y,v):new Ot(y,v),this._remoteTracks[m]=I,f.push(I)),I.__innerSetRemoteMuted(p.state===0)}),u.length){const p=u.map(_=>_.getTrackId());O.debug(`resub tracks -> ${JSON.stringify(p)}`);const{code:m}=yield be(()=>this.__subscribe(u,!0));m!==w.SUCCESS&&O.error(`resub tracks failed -> code: ${m}, ids: ${JSON.stringify(p)}`)}this._onTrackPublish(f)}if(c.length>0){const a=c.map(fe);for(let f=h.length-1;f>=0;f-=1){const p=h[f];a.includes(fe(p))&&h.splice(f,1)}const u=c.map(f=>{const p=fe(f);return this._remoteTracks[p]});yield this._onUserUnpublish(u)}if(d.length>0){const a=h.map(fe);for(let u=0;u<d.length;u+=1){const f=d[u],p=fe(f),m=a.indexOf(p);h[m].state=f.state;const _=this._remoteTracks[p];_.__innerSetRemoteMuted(f.state===0),_.isAudioTrack()?this._onAudioMuteChange(_):this._onVideoMuteChange(_)}}})}_onTrackPublish(e){this._callAppListener("onTrackPublish",e)}_stateHandle(e){var n;return H(this,void 0,void 0,function*(){const{users:r}=e;if(r.length===0)return;const i=[],o=[],s=[],c=[];r.forEach(h=>{+h.state==0?(O.debug(`user joined -> ${h.userId}`),this._roomResources[h.userId]||(h.switchRoleType?s.push(h.userId):i.push(h.userId)),this._roomResources[h.userId]=this._roomResources[h.userId]||[]):(O.debug(`user left -> ${h.userId}`),h.switchRoleType?c.push(h.userId):o.push(h.userId))});const d=[...i,...s],l=[...o,...c];if(l.length){const h=[],a=[];l.forEach(u=>{h.push(...this.getRemoteTracksByUserId(u)),a.push(u)}),h.length&&(yield this.unsubscribe(h),h.forEach(u=>delete this._remoteTracks[u.getTrackId()])),a.length&&a.forEach(u=>delete this._roomResources[u])}if((n=this._appListener)===null||n===void 0?void 0:n.onSwitchRole)return s.length&&s.forEach(h=>this._callAppListener("onSwitchRole",h,ai.ANCHOR)),c.length&&c.forEach(h=>this._callAppListener("onSwitchRole",h,ai.AUDIENCE)),i.length&&this._callAppListener("onUserJoin",i),void(o.length&&this._callAppListener("onUserLeave",o));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(n=>n!==e)}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach(n=>{e.push(...this.getRemoteTracksByUserId(n))}),e}getRemoteTracksByUserId(e){const n=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&n.push(i)}return n}getSessionId(){return this._sessionId}sendMessage(e,n){return H(this,void 0,void 0,function*(){const{code:r}=yield this._context.sendMessage(z.RTC_ROOM,this._roomId,{messageType:e,content:n,isStatusMessage:!0});return r!==N.SUCCESS?(O.error(`send message failed -> code: ${r}`),{code:w.SIGNAL_ERROR}):{code:w.SUCCESS}})}setRoomAttribute(e,n,r,i=!1){return H(this,void 0,void 0,function*(){const o=yield this._context.setRTCData(this._roomId,e,n,i,yt.ROOM,r);return o!==N.SUCCESS?(O.error(`SetRoomAttributeValue Failed: ${o}`),{code:w.SIGNAL_ERROR}):{code:w.SUCCESS}})}deleteRoomAttributes(e,n,r=!1){return H(this,void 0,void 0,function*(){const i=yield this._context.removeRTCData(this._roomId,e,r,yt.ROOM,n);return i!==N.SUCCESS?(O.error(`DeleteRoomAttribute Failed: ${i}`),{code:w.SIGNAL_ERROR}):{code:w.SUCCESS}})}getRoomAttributes(e=[],n=!1){return H(this,void 0,void 0,function*(){const{code:r,data:i}=yield this._context.getRTCData(this._roomId,e,n,yt.ROOM);return r!==N.SUCCESS?(O.error(`GetRoomAttributes Failed: ${r}`),{code:w.SIGNAL_ERROR}):{code:w.SUCCESS,data:i}})}_setUserAttributeValue(e,n,r){return this._context.setRTCData(this._roomId,e,n,!1,yt.PERSON,r)}_deleteUserAttributes(e,n){return this._context.removeRTCData(this._roomId,e,!1,yt.PERSON,n)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,yt.PERSON)}isDestroyed(){return this._destroyed}__destroy(e){return this._leaveHandle(e)}_leaveHandle(e){var n;return H(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(n=this._audioLevelReport)===null||n===void 0||n.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 dn&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e){return H(this,void 0,void 0,function*(){const n=e.getTrackId(),r=this._context.getCurrentId(),i=[{resourceId:n,enabled:!e.isLocalMuted()}],o=this._roomResources[r]||[],s=[];for(let d=0;d<o.length;d+=1){const l=o[d],h=fe(l),a=i.findIndex(u=>u.resourceId===h);if(a>=0){const{enabled:u}=i[a];l.state=u?1:0,s.push(l);break}}const c=yield be(()=>this._context.setRTCTotalRes(this._roomId,Or(ce.MODIFY,s),Ft(o),ce.TOTAL_CONTENT_RESOURCE));c!==N.SUCCESS&&O.error("notice `track.enabled` change failed -> code: "+c)})}_removePubFailedTracks(e){e.forEach(n=>{const r=n instanceof pe?n:n.track;O.debug(`remove pub failed track from peerconnection -> trackId: ${r.getTrackId()}`),this._pc.removeLocalTrackById(r.getTrackId())})}publish(e){return H(this,void 0,void 0,function*(){return be(()=>this.__publish(e))})}__publish(e){return H(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Lt)return O.error("the `publish` is disabled in PK room "),{code:w.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return O.error(`publish failed, room has been destroyed. -> roomId: ${this._roomId}`),{code:w.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>We(e)&&e.length>0&&e.every(C=>C instanceof pe||C.track instanceof pe),!0))return O.error(`publish failed, tracks is invalid -> roomId: ${this._roomId}`),{code:w.PARAMS_ERROR};const n=this._context.getCurrentId();if(this._pc.getLocalTracks().length+(C=>{let I=0;return C.forEach(P=>{P instanceof pe?I++:P.pubTiny&&P.track.isVideoTrack()?I+=2:I++}),I})(e)>10)return O.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`),{code:w.PUBLISH_TRACK_LIMIT_EXCEEDED};O.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${e.map(Un)}`),e.forEach(C=>{const{track:I,pubTiny:P}=C instanceof pe?{pubTiny:!1,track:C}:C;if(this._pc.addLocalTrack(I),I.isVideoTrack()&&P){let b;try{b=I.__innerGetMediaStreamTrack().clone();const R=P.frameRate||Ct.FPS_15,M=P.resolution||Re.W176_H144,{width:F,height:q}=Et(M),E=Rt(R);b.applyConstraints({width:F,height:q,frameRate:E})}catch(R){return b==null||b.stop(),void O.warn(`pubTiny failed -> id: ${I.getTrackId()}, msg: ${R.message}`)}this._pc.addLocalTrack(new dn(I.getTag(),I.getUserId(),b,!0))}}),this._pc.clearReTryExchangeTimer();const r=yield this._createExchangeParams(this._subscribedList,!1),i=this._getPushOtherRoomsParams();i&&(r.pushOtherRooms=i);const o=yield this._exchangeHandle(r);if(o.code!==w.SUCCESS)return O.error(`publish failed -> roomId: ${this._roomId}, code: ${o.code}`),this._removePubFailedTracks(e),{code:o.code};const{publishList:s,sdp:c,resultCode:d,message:l,urls:h,mcuPublishList:a}=o.data;if(d!==w.SUCCESS)return O.error(`publish failed -> roomId: ${this._roomId}, code: ${d}, msg: ${l}`),this._removePubFailedTracks(e),{code:d};const u=yield this._pc.setRemoteAnswer(c.sdp);if(u!==w.SUCCESS)return{code:u};const f=this._roomResources[n],p=s.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(fe(C))},C)),{publishedList:m}=Hr(f,p),_=(a==null?void 0:a.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)))||[],v=yield this._context.setRTCTotalRes(this._roomId,Or(ce.PUBLISH,m),Ft(p),ce.TOTAL_CONTENT_RESOURCE,Ft(_));if(v!==N.SUCCESS)return O.error(`send publish streams notification failed: ${v}`),{code:w.SIGNAL_ERROR};this._roomResources[n]=p;const y=m.map(C=>fe(C));return this._polarisReport&&this._polarisReport.sendR2(Mt.PUBLISH,Pt.BEGIN,y),e.forEach(C=>{const{track:I}=C instanceof pe?{track:C}:C;I.__innerSetPublished(!0)}),O.debug(`publish success: ${y.join(",")}`),this._roomMode===qe.LIVE?{code:w.SUCCESS,liveUrl:h==null?void 0:h.liveUrl}:{code:w.SUCCESS}})}_getPushOtherRoomsParams(){if(this instanceof Lt){const{code:e,roomPKHandler:n}=this.getRoomPKHandler(),r=[];if(e===w.SUCCESS&&n){const i=n.getJoinedPKRooms();for(const o in i){const s=i[o].getSessionId(),c=n.getPKInfo(o);if(!c)return;const{inviterUserAutoMix:d,inviteeUserAutoMix:l,inviterUserId:h}=c,a=this._context.getCurrentId()===h;r.push({roomId:o,sessionId:s,autoMix:a?!!d:!!l})}}return r}}_reTryExchange(){return H(this,void 0,void 0,function*(){be(()=>H(this,void 0,void 0,function*(){const e=yield this._createExchangeParams(this._subscribedList,!0),n=this._getPushOtherRoomsParams();n&&(e.pushOtherRooms=n);const r=yield this._exchangeHandle(e);if(r.code!==w.SUCCESS)return O.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:o}=r.data;if(o!==w.SUCCESS)return O.error(`reTryExchange failed: ${o}`),{code:o};this._pc.clearReTryExchangeTimer();const s=yield this._pc.setRemoteAnswer(i.sdp);return s!==w.SUCCESS?{code:s}: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,n){return H(this,void 0,void 0,function*(){return{sdp:yield this._pc.createOffer(n),extend:JSON.stringify({resolutionInfo:this._pc.getOutboundVideoInfo()}),subscribeList:e.filter(r=>{const i=r.track.getTrackId(),{userId:o}=Ke(i);return this._roomResources[o]?this._roomResources[o].filter(c=>i===`${c.msid}_${c.mediaType}`).length:!1}).map(r=>({simulcast:r.subTiny?at.TINY:at.NORMAL,resolution:"",uri:this._getResourceById(r.track.getTrackId()).uri})),switchstream:!1}})}_getResourceState(e){var n;return((n=this.getLocalTrack(e))===null||n===void 0?void 0:n.isLocalMuted())?0:1}unpublish(e){return H(this,void 0,void 0,function*(){return be(()=>this.__unpublish(e))})}__unpublish(e){var n;return H(this,void 0,void 0,function*(){if(!this._isMainRoom&&this instanceof Lt)return O.error("the `unpublish` is disabled in PK room "),{code:w.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(this._assertRoomDestroyed())return O.warn(`room has been destroyed, no need to unpublish tracks -> roomId: ${this._roomId}`),{code:w.SUCCESS};const r=this._context.getCurrentId();if(!Ee("tracks",e,()=>e.every(C=>C.getUserId()===r&&C instanceof pe),!0))return O.warn(`unpublish failed, tracks is invalid -> roomId: ${this._roomId}, tracks: ${e.map(Un)}`),{code:w.PARAMS_ERROR};const i=e.map(C=>C.getTrackId()),o=i.map(this._getResourceById.bind(this)).filter(C=>!!C);if(o.length===0)return{code:w.SUCCESS};const s=this._roomResources[r].filter(C=>!o.includes(C));i.forEach(C=>this._pc.removeLocalTrackById(C)),(n=this._polarisReport)===null||n===void 0||n.sendR2(Mt.PUBLISH,Pt.END,i),this._pc.clearReTryExchangeTimer();const c=yield this._createExchangeParams(this._subscribedList,!1),d=this._getPushOtherRoomsParams();d&&(c.pushOtherRooms=d);const l=yield this._exchangeHandle(c);if(l.code!==w.SUCCESS)return O.error(`exchange failed -> code: ${l.code}`),{code:l.code};const{publishList:h,sdp:a,resultCode:u,message:f,mcuPublishList:p}=l.data;u!==w.SUCCESS&&O.error(`unpublish streams failed -> code: ${u}, msg: ${f}`);const m=p?p.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:1},C)):[],_=yield this._context.setRTCTotalRes(this._roomId,Or(ce.UNPUBLISH,o),Ft(s),ce.TOTAL_CONTENT_RESOURCE,Ft(m));if(_!==N.SUCCESS)return O.error("send unpublish notification failed:",_),{code:w.SIGNAL_ERROR};O.debug(`unpublish success -> tracks: ${i.join(",")}`);const v=yield this._pc.setRemoteAnswer(a.sdp);if(v!==w.SUCCESS)return{code:v};const y=h.map(C=>Object.assign({tag:C.msid.split("_").pop(),state:this._getResourceState(fe(C))},C));return this._roomResources[r]=y,{code:w.SUCCESS}})}_getResourceById(e){const{userId:n}=Ke(e);return this._roomResources[n].find(r=>fe(r)===e)}_isValidResourceId(e){var n;const{userId:r}=Ke(e);return!!((n=this._roomResources[r])===null||n===void 0?void 0:n.find(i=>fe(i)===e))}subscribe(e){return H(this,void 0,void 0,function*(){return be(()=>this.__subscribe(e,!1))})}__subscribe(e,n=!1){var r;return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return O.error(`subscribe failed, room has been destroyed -> roomId: ${this._roomId}`),{code:w.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>We(e)&&e.length>0&&e.every(d=>d instanceof Be||d.track instanceof Be),!0))return O.error(`subscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:w.PARAMS_ERROR};O.info(`subscribe -> roomId: ${this._roomId}, tracks: ${e.map(Un)}`);const i=this._subscribedList.map(d=>Object.assign({},d)),o=e.map(d=>d instanceof Be?{track:d}:d);let s=!1;const c=[];return o.forEach(d=>{const l=d.track.getTrackId();c.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),s=!0)}),s||n?((r=this._polarisReport)===null||r===void 0||r.sendR2(Mt.SUBSCRIBE,Pt.BEGIN,c),this._updateSubListHandle(i,!0)):{code:w.SUCCESS}})}unsubscribe(e){return H(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe(e))})}__unsubscribe(e){var n;return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return O.warn(`room has beed destroyed, no need to unsubscribe tracks -> roomId: ${this._roomId}`),{code:w.SUCCESS};if(!Ee("tracks",e,()=>We(e)&&e.length>0&&e.every(i=>i instanceof Be),!0))return O.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:w.PARAMS_ERROR};O.info(`unsubscribe -> roomId: ${this._roomId}, tracks: ${e.map(Un)}`);const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(n=this._polarisReport)===null||n===void 0||n.sendR2(Mt.SUBSCRIBE,Pt.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 O.warn(e),w.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 H(this,void 0,void 0,function*(){return be(()=>this._updateSubListHandle(e,!1))})}_updateSubListHandle(e,n=!1){return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:w.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>We(e)&&e.every(y=>y instanceof Be||y.track instanceof Be),!0))return O.error(`update sublist failed, tracks is invalid -> roomId: ${this._roomId}`),{code:w.PARAMS_ERROR};O.info(`update subscribe list -> roomId: ${this._roomId}, forceReq: ${n}, tracks: ${e.map(Un)}`);let r=e.map(y=>y instanceof Be?{track:y}:Object.assign({},y));const i={};r=r.filter(y=>{const C=y.track.getTrackId();return this._remoteTracks[C]?!i[C]&&(i[C]=!0):(O.warn(`track cannot found in room -> trackId: ${C}`),!1)}).map(y=>Object.assign({},y));const o=this._subscribedList.map(y=>Object.assign({},y));if(!n){let y=!1;if(r.forEach(C=>{const I=o.findIndex(P=>P.track===C.track);if(I===-1)return void(y=!0);o.splice(I,1)[0].subTiny!==C.subTiny&&(y=!0)}),o.length&&(y=!0),!y)return{code:w.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(r.map(y=>y.track));const s=yield this._createExchangeParams(r,!1),c=this._getPushOtherRoomsParams();c&&(s.pushOtherRooms=c);const d=yield this._exchangeHandle(s),l=r.map(y=>y.track.getTrackId());if(d.code!==w.SUCCESS)return{code:d.code};const{sdp:h,resultCode:a,message:u,subscribedList:f}=d.data;if(a!==w.SUCCESS)return O.error(`change subscribe list failed: ${a}`),{code:a};O.debug(`subscribe success: ${l.join(",")}`);const p=yield this._pc.setRemoteAnswer(h.sdp);if(p!==w.SUCCESS)return{code:p};const m=f==null?void 0:f.map(y=>`${y.msid}_${y.mediaType}`),_=r.filter(y=>m==null?void 0:m.includes(y.track.getTrackId())),v=r.filter(y=>!(m==null?void 0:m.includes(y.track.getTrackId())));for(const y in this._remoteTracks){const C=_.some(I=>I.track.getTrackId()===y);this._remoteTracks[y].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,..._),v.length?{code:w.SUCCESS,failedList:v}:{code:w.SUCCESS}})}registerRoomEventListener(e){this._appListener=e}registerReportListener(e){this._pc.registerReportListener(e)}onAudioLevelChange(e,n){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Pd(this),this._audioLevelReport.onAudioLevelChange(e,n||1e3)}__onReconnected(e){return H(this,void 0,void 0,function*(){if(this._pc.getRTCPeerConn().connectionState==="closed")return O.warn("RTCPeerConnection closed. Please rejoin room to restore services."),void this._rtcpeerClosed();const{code:n,data:r}=yield this._context.joinRTCRoom(this._roomId,this._roomMode,e);if(n!==N.SUCCESS)return void O.error(`RTC __onReconnected getRTCRoomInfo failed: ${n}`);O.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(r)}`);const i=[],o={},s={},c={},d=Zo(r),l=Object.keys(d),h=Object.keys(this._roomResources);for(let a=l.length-1;a>=0;a-=1){const u=l[a],f=h.indexOf(u);if(f===-1){i.push(u),o[u]=Ar(d[u]);continue}const p=this._roomResources[u],m=d[u],{publishedList:_,modifiedList:v,unpublishedList:y}=Hr(p,m,!0);o[u]=Ar(_),s[u]=Ar(y),c[u]=Ar(v),h.splice(f,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 s){const u=s[a];if(u.length){const f=u.map(p=>this._remoteTracks[fe(p)]);yield this._onUserUnpublish(f)}}return Object.keys(o).forEach(a=>{const u=o[a];if(u.length===0)return;const f=u.map(p=>{const m=fe(p),{userId:_,tag:v,mediaType:y}=Ke(m),C=this._remoteTracks[m]=y===_e.AUDIO_ONLY?new wt(v,_):new Ot(v,_);return C.__innerSetRemoteMuted(p.state===0),C});this._onTrackPublish(f)}),Object.keys(c).forEach(a=>{c[a].forEach(u=>{const f=fe(u),p=this._remoteTracks[f];p.__innerSetRemoteMuted(u.state===0),p.isAudioTrack()?this._onAudioMuteChange(p):this._onVideoMuteChange(p)})}),{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(n=>{n.isAudioTrack()&&n.__releaseMediaElement()}),this._remoteTracks={})}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){}}var jn,an,nr;(function(t){t[t.CROP=1]="CROP",t[t.WHOLE=2]="WHOLE"})(jn||(jn={})),function(t){t[t.CUSTOMIZE=1]="CUSTOMIZE",t[t.SUSPENSION=2]="SUSPENSION",t[t.ADAPTATION=3]="ADAPTATION"}(an||(an={})),function(t){t[t.CROP=1]="CROP",t[t.WHOLE=2]="WHOLE"}(nr||(nr={}));const Pc=()=>({version:1,mode:an.SUSPENSION});class Of{constructor(e,n,r){this._onFlush=e,this._isValidTrackId=n,this._sendCDNInfoSignal=r,this._values=Pc()}setHostVideoTrack(e){if(!this._isValidTrackId(e))return O.error(`setHostVideoTrack failed: videoTrackId is invalid -> ${e}`),this;const{mediaType:n,tag:r,userId:i}=Ke(e);return n!==_e.VIDEO_ONLY?(O.error(`setHostVideoTrack failed: kind of resource is not 'video' -> ${e}`),this):(this._values.host_stream_id=io(i,r),this)}setMixLayoutMode(e){return[an.CUSTOMIZE,an.SUSPENSION,an.ADAPTATION].includes(e)?(this._values.mode=e,this):(O.error(`layout mode is invalid: ${e}`),this)}_addOutputValue(e,n,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if(e==="cdn")return void(i.cdn=n);if(e==="audio")return void(i.audio={bitrate:n});const o=i.video;if(r!=="normal"&&r!=="tiny")if(r!=="backgroundColor")if(r!=="exparams"){if(r==="backgroundPicture"){const s=o.backgroundPicture||(o.backgroundPicture={fillMode:jn.CROP,picture:[]});Object.assign(s,n)}}else o.exparams={renderMode:n};else o.backgroundColor=n;else{const s=o[r]||(o[r]={});Object.assign(s,n)}}setOutputVideoResolution(e){if(!sn(e))return O.warn("setOutputVideoResolution failed: `resolution` is invalid"),this;const{width:n,height:r}=Et(e);return this._addOutputValue("video",{width:n,height:r},"normal"),this}setOutputVideoFPS(e){if(!Qo(e))return O.warn("setOutputVideoFPS failed: `fps` is invalid"),this;const n=Rt(e);return this._addOutputValue("video",{fps:n},"normal"),this}setOutputVideoBitrate(e){return!Ie(e)||e<=0?O.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"normal"),this}setOutputTinyVideoResolution(e){if(!sn(e))return O.warn("setOutputTinyVideoResolution failed: `resolution` is invalid"),this;const{width:n,height:r}=Et(e);return this._addOutputValue("video",{width:n,height:r},"tiny"),this}setOutputTinyVideoFPS(e){if(!Qo(e))return O.warn("setOutputTinyVideoFPS failed: `fps` is invalid"),this;const n=Rt(e);return this._addOutputValue("video",{fps:n},"tiny"),this}setOutputTinyVideoBitrate(e){return!Ie(e)||e<=0?O.error(`bitrate is invalid: ${e}`):this._addOutputValue("video",{bitrate:e},"tiny"),this}setOutputVideoRenderMode(e){return[nr.CROP,nr.WHOLE].includes(e)?this._addOutputValue("video",e,"exparams"):O.error(`renderMode is invalid: ${e}`),this}setOutputAudioBitrate(e){return Ie(e)&&e>0?this._addOutputValue("audio",e):O.error(`bitrate is invalid: ${e}`),this}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?this._addOutputValue("video",e,"backgroundColor"):O.error(`color is invalid: ${e}`),this}addOutputBackgroundPicture(e,n,r,i,o){var s,c,d;if(!Yn(e))return O.error(`uri is invalid: ${e}`),this;if([n,r,i,o].some(h=>!Ie(h)||h<0||h>1))return O.error(`some attrs of (x, y, w, h) is invalid: ${n}, ${r}, ${i}, ${o}`),this;const l=((d=(c=(s=this._values.output)===null||s===void 0?void 0:s.video)===null||c===void 0?void 0:c.backgroundPicture)===null||d===void 0?void 0:d.picture)||[];return l.push({uri:e,w:i,h:o,x:n,y:r}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this}removeOutputBackgroundPicture(e){var n,r,i;if(!Yn(e))return O.error(`uri is invalid: ${e}`),this;let o=(i=(r=(n=this._values.output)===null||n===void 0?void 0:n.video)===null||r===void 0?void 0:r.backgroundPicture)===null||i===void 0?void 0:i.picture;return o&&(o=o.filter(s=>s.uri!==e),this._addOutputValue("video",{pictures:o},"backgroundPicture")),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this}setOutputBackgroundPictureFillMode(e){return[jn.CROP,jn.WHOLE].includes(e)?this._addOutputValue("video",{fillMode:e},"backgroundPicture"):O.error(`fillMode is invalid: ${e}`),this}addPublishStreamUrls(e){var n,r;const i=/^rtmp:\/\/.+/;if(!We(e)||e.length===0||e.some(c=>!i.test(c)))return O.error(`urls is invalid: ${e}`),this;const o=((r=(n=this._values.output)===null||n===void 0?void 0:n.cdn)===null||r===void 0?void 0:r.concat())||[];let s=!1;return e.forEach(c=>{o.some(d=>d.pushurl===c)||(s=!0,o.push({pushurl:c}))}),o.length>5?(O.error("publish stream url no more than 5"),this):(s&&this._addOutputValue("cdn",o),this)}removePublishStreamUrls(e){var n,r;const i=/^rtmp:\/\/.+/;if(!We(e)||e.length===0||e.some(s=>!i.test(s)))return O.error(`urls is invalid: ${e}`),this;const o=((r=(n=this._values.output)===null||n===void 0?void 0:n.cdn)===null||r===void 0?void 0:r.concat())||[];for(let s=o.length-1;s>=0;s-=1){const{pushurl:c}=o[s],d=e.indexOf(c);d>=0&&(e.splice(d,1),o.splice(s,1))}return this._addOutputValue("cdn",o),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this}addCustomizeLayoutVideo(e,n,r,i,o){if(!this._isValidTrackId(e))return O.error(`trackId is invalid: ${e}`),this;if(!Ie(n)||!Ie(r))return O.error(`some attrs of (x, y) is invalid: ${n}, ${r}`),this;if([i,o].some(h=>!Ie(h)||h<0))return O.error(`some attrs of (width, height) is invalid: ${i}, ${o}`),this;const{userId:s,tag:c,mediaType:d}=Ke(e);if(d!==_e.VIDEO_ONLY)return O.error(`kind of resource is not 'video': ${e}`),this;const l=io(s,c);return(this._values.input||(this._values.input={video:[]})).video.push({user_id:s,stream_id:l,x:n,y:r,width:i,height:o}),this}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return O.error(`trackId is invalid: ${e}`),this;const{userId:n,tag:r,mediaType:i}=Ke(e);if(i!==_e.VIDEO_ONLY)return O.error(`kind of resource is not 'video': ${e}`),this;const o=io(n,r),s=this._values.input||(this._values.input={video:[]});return s.video=s.video.filter(c=>c.stream_id===o),this}clearCustomizeLayoutVideo(){return(this._values.input||(this._values.input={video:[]})).video=[],this}flush(){var e,n,r,i;return H(this,void 0,void 0,function*(){const o=JSON.parse(JSON.stringify(this._values)),{code:s}=yield this._onFlush(o);return s===w.SUCCESS&&(((n=(e=this._values.output)===null||e===void 0?void 0:e.video.normal)===null||n===void 0?void 0:n.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=Pc(),{code:s}})}}var ci,ui,di,ft;(function(t){t[t.OPEN=1]="OPEN",t[t.STOP=2]="STOP"})(ci||(ci={})),function(t){t[t.SPREAD=0]="SPREAD",t[t.NO_SPREAD=-1]="NO_SPREAD"}(ui||(ui={})),function(t){t[t.AUTOMATIC=0]="AUTOMATIC",t[t.MANUAL=1]="MANUAL"}(di||(di={})),function(t){t[t.VIDEO=0]="VIDEO",t[t.AUDIO=1]="AUDIO"}(ft||(ft={}));const kd=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)});class Af{constructor(e,n,r,i,o,s,c,d){this._context=e,this._runtime=n,this._service=r,this._initOptions=i,this._mainLivingRoom=o,this._registerPKMsgListener=s,this._onJoinedPKRoom=c,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,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){O.error(o)}}_onInvite(e){const n=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:o}=n,s={inviterRoomId:r,inviterUserId:i};o&&Object.assign(s,{extra:o}),this._PKInfo[r]=n,this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:n,inviterUserId:r,extra:i}=e.inviteInfo||{},o={inviterRoomId:n,inviterUserId:r};i&&Object.assign(o,{extra:i}),delete this._PKInfo[n],this._callAppListener("onCancelRequestOtherRoom",o)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:n,inviteContent:r,inviteeUserAutoMix:i}=e,{inviterUserId:o,inviterRoomId:s,inviteeUserId:c,inviteeRoomId:d,extra:l}=r,h={agree:n===1,inviterRoomId:s,inviterUserId:o,inviteeRoomId:d,inviteeUserId:c};this._PKInfo[d].inviteeUserAutoMix=i,this._callAppListener("onResponseJoinOtherRoom",h)}_onPKEnd(e){return H(this,void 0,void 0,function*(){const{inviteeRoomId:n,inviterRoomId:r,userId:i}=e.inviteInfo,o=r===this._mainRoomId?n:r,s={endRoomId:o,endUserId:i};yield this.leaveOtherRoom(this._joinedPKRooms[o]),delete this._PKInfo[o],this._callAppListener("onFinishOtherRoom",s)})}_onRecvPKMsg(e){const{targetId:n,content:r,messageType:i}=e;switch(i){case ce.PK_INVITE:this._onInvite(r);break;case ce.PK_CANCEL_INVITE:this._onCancelInvite(r);break;case ce.PK_INVITE_TIMEOUT:this._onInviteTimeout(r);break;case ce.PK_INVITE_ANSWER:this._onInviteAnswer(r);break;case ce.PK_END:this._onPKEnd(r)}}registerRoomPKEventListener(e){this._appListener=e}requestJoinOtherRoom(e,n,r){return H(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,Xe,!0)||!Ee("inviteeUserId",n,Xe,!0))return{code:w.PARAMS_ERROR};O.debug(`requestRoomPK -> inviteeRoomId: ${e}; inviteeUserId: ${n}; options: ${JSON.stringify(r||{})}`);const i=kd(),o=!qr(r==null?void 0:r.autoMix)||(r==null?void 0:r.autoMix),s={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e,inviteeUserId:n,inviteeTimeoutTime:this._inviteTimeout,extra:(r==null?void 0:r.extra)||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:n,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(s),inviteSessionId:i};O.debug(`requestRoomPK -> params: ${JSON.stringify(c)}`);const d=yield this._context.requestRoomPK(c);return d!==N.SUCCESS?(O.error(`requestRoomPK failed: ${d}`),{code:d}):(O.debug("requestRoomPK success"),this._PKInfo[e]={inviteSessionId:i,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e},{code:w.SUCCESS})})}cancelRequestJoinOtherRoom(e,n,r){return H(this,void 0,void 0,function*(){if(!Ee("inviteeRoomId",e,Xe,!0)||!Ee("inviteeUserId",n,Xe,!0))return{code:w.PARAMS_ERROR};if(!this._PKInfo[e])return O.error(`\u672A\u53D1\u8D77\u8FC7\u4E0E ${e} \u623F\u95F4\u5185 ${n} \u8FDE\u9EA6\u7684\u8BF7\u6C42`),{code:w.PARAMS_ERROR};O.debug(`canceRequestJoinPK -> inviteeRoomId: ${e}; inviteeUserId: ${n}; extra: ${r}`);const i={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:n,extra:r||""},o={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:n,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(i)};O.debug(`canceRequestJoinPK -> params: ${JSON.stringify(o)}`);const s=yield this._context.cancelRoomPK(o);return s!==N.SUCCESS?(O.error(`canceRequestJoinPK failed: ${s}`),{code:s}):(O.debug("canceRequestJoinPK success"),delete this._PKInfo[e],{code:w.SUCCESS})})}responseJoinOtherRoom(e,n,r,i){return H(this,void 0,void 0,function*(){if(!Ee("inviterRoomId",e,Xe,!0)||!Ee("inviterUserId",n,Xe,!0))return{code:w.PARAMS_ERROR};if(!this._PKInfo[e])return O.error(`${e} \u623F\u95F4\u5185\u7684 ${n} \u672A\u53D1\u8D77\u8FC7\u8FDE\u9EA6\u8BF7\u6C42`),{code:w.PARAMS_ERROR};O.debug(`responseRoomPK -> inviterRoomId: ${e}; inviterUserId: ${n}; agree: ${r}; options: ${JSON.stringify(i||{})}`);const{inviteSessionId:o,inviterUserAutoMix:s}=this._PKInfo[e],c=!qr(i==null?void 0:i.autoMix)||(i==null?void 0:i.autoMix),d={inviteSessionId:o,inviterRoomId:e,inviterUserId:n,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:c},l=Object.assign(d,{inviterUserAutoMix:s}),h=r?Object.assign(d,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(l)}):d;!me(i==null?void 0:i.extra)&&Object.assign(h,{extra:i.extra});const a={agree:r,roomId:this._mainRoomId,inviteSessionId:o,inviteRoomId:e,inviteUserId:n,content:JSON.stringify(h),key:`${e}|${n}`,value:JSON.stringify(d)};O.debug(`responseRoomPK -> params: ${JSON.stringify(a)}`);const u=yield this._context.responseRoomPK(a);return u!==N.SUCCESS?(O.error(`responseRoomPK failed: ${u}`),{code:u}):(O.debug("responseRoomPK success"),this._PKInfo[e].inviteeUserAutoMix=c,{code:w.SUCCESS})})}_quitRoomPK(e){return H(this,void 0,void 0,function*(){const{inviterRoomId:n,inviteeRoomId:r,inviterUserId:i}=this._PKInfo[e],o={inviteeRoomId:r,inviterRoomId:n,userId:this._context.getCurrentId()},s={roomId:this._mainRoomId,endRoomId:e,sessionId:this._PKInfo[e].inviteSessionId,content:JSON.stringify(o),keys:[`${n}|${i}`]};O.debug(`quitRoomPK -> params: ${JSON.stringify(s)}`);const c=yield this._context.endRoomPK(s);return c!==N.SUCCESS?(O.error(`quitRoomPK failed: ${c}`),{code:w.SIGNAL_ERROR}):(O.debug("quitRoomPK success"),delete this._PKInfo[e],{code:w.SUCCESS})})}_relaseCrtRoom(){}joinOtherRoom(e){return H(this,void 0,void 0,function*(){if(!Ee("roomId",e,Xe,!0))return{code:w.PARAMS_ERROR};if(this._context.getConnectionStatus()!==ne.CONNECTED)return{code:w.SIGNAL_DISCONNECTED};if(O.debug(`joinPKRoom, roomId: ${e}`),this._joinedPKRooms[e])return{code:w.REPERT_JOIN_ROOM};const n=ft.VIDEO,{code:r,data:i}=yield this._context.joinRTCRoom(e,qe.LIVE,n);if(r!==N.SUCCESS)return O.error(`joinRoom failed -> code: ${r}`),{code:r};O.debug(`JoinPKRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const o=new Lt(this._context,this._runtime,e,i,this._service,this._initOptions,this._relaseCrtRoom.bind(this),n,!1,!1);return this._joinedPKRooms[e]=o,this._onJoinedPKRoom(e,o),{room:o,code:w.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()}})}leaveOtherRoom(e,n){return H(this,void 0,void 0,function*(){return be(()=>H(this,void 0,void 0,function*(){const r=e.getRoomId();return O.debug(`leavePKRoom -> userId: ${this._context.getCurrentId()} , roomId: ${r}`),yield e.__destroy(!0),delete this._joinedPKRooms[r],this._onLeavePKRoom(r),this._PKInfo[r]?(n&&this._quitRoomPK(r),{code:w.SUCCESS}):{code:w.SUCCESS}}))})}getPKInfo(e){return this._PKInfo[e]}getJoinedPKRooms(){return this._joinedPKRooms}}class Lt extends Ld{constructor(e,n,r,i,o,s,c,d,l=!1,h){var a;super(e,n,r,i,qe.LIVE,o,s,c,l,h),this._livingType=d,this._isMainRoom=h,this._CDNUris=null,this._CDNEnable=!1,this._mcuConfigBuilder=new Of(this._onMCUConfigFlush.bind(this),this._isValidResourceId.bind(this),this._sendCDNInfoSignal.bind(this)),this._isMainRoom&&(this._roomPKHandler=new Af(e,n,o,s,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._onLeavePKRoom.bind(this)));const u=(a=i.roomInfo.filter(f=>f.key==="cdn_uris")[0])===null||a===void 0?void 0:a.value;u&&(this._CDNUris=JSON.parse(u)[0])}_isValidResourceId(e){var n;const{userId:r}=Ke(e),i=!!((n=this._roomResources[r])===null||n===void 0?void 0:n.find(h=>fe(h)===e));let o=!1;const{code:s,roomPKHandler:c}=this.getRoomPKHandler();if(s!==w.SUCCESS||!c)return i;const d=c.getJoinedPKRooms(),l=[];return Object.values(d).map(h=>{l.push(...h.getRemoteTracks())}),o=l.some(h=>e===h.getTrackId()),i||o}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._isMainRoom?this._mcuConfigBuilder:(O.error("the `getMCUConfigBuilder` is disabled in PK room "),{code:w.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_onMCUConfigFlush(e){return H(this,void 0,void 0,function*(){const n={"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(n,e);return r!==w.SUCCESS?(O.error(`set MCU config failed: ${r}`),{code:r}):(O.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 n,r;return H(this,void 0,void 0,function*(){const i=yield e.__onReconnected.call(this,this._livingType);if(!i||!i.data)return;const o=i.data.roomInfo,s=(n=o.filter(d=>d.key==="cdn_uris")[0])===null||n===void 0?void 0:n.value;if(!s)return;const c=JSON.parse(s);((r=this._CDNUris)===null||r===void 0?void 0:r.enableInnerCDN)!==c.enableInnerCDN&&this._callAppListener("onCDNEnableChange",c.enableInnerCDN),this._CDNUris=c})}enableInnerCDN(e){return H(this,void 0,void 0,function*(){if(!this._isMainRoom)return O.error("the `enableInnerCDN` is disabled in PK room "),{code:w.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!qr(e))return O.error("`enable` is invalid"),{code:w.PARAMS_ERROR};this._CDNEnable=e;const n={version:2,output:{inCDNModel:e?ci.OPEN:ci.STOP}},{code:r}=yield this._onMCUConfigFlush(n);if(r!==w.SUCCESS)return O.error(`enableInnerCDN failed -> code: ${r}`),{code:w.SIGNAL_ERROR};if(this._CDNUris&&this._CDNUris.broadcast!==ui.SPREAD)return O.info("enableInnerCDN succeed"),{code:w.SUCCESS};const{code:i}=yield be(()=>H(this,void 0,void 0,function*(){return this._sendCDNInfoSignal()}));return i===w.SUCCESS?(O.info("enableInnerCDN succeed"),{code:w.SUCCESS}):(O.error(`enableInnerCDN failed -> code: ${i}`),{code:i})})}_sendCDNInfoSignal(){return H(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===w.SUCCESS)?{code:w.SUCCESS}:{code:w.SIGNAL_ERROR}})}_spreadCDNInfo(e){return H(this,void 0,void 0,function*(){const n=yield this._context.setRTCCDNUris(this._roomId,ce.TOTAL_CONTENT_RESOURCE,JSON.stringify([e]));return n!==N.SUCCESS?(O.error(`spreadCDNInfo failed -> code: ${n}`),{code:w.SIGNAL_ERROR}):(O.info("spreadCDNInfo succeed"),{code:w.SUCCESS})})}_setRoomCDNInfo(e){return H(this,void 0,void 0,function*(){const n=yield this._context.setRTCData(this._roomId,"cdn_uris",JSON.stringify([e]),!0,yt.ROOM);return n!==N.SUCCESS?(O.error(`setRoomCDNInfo failed -> code: ${n}`),{code:w.SIGNAL_ERROR}):(O.info("setRoomCDNInfo succeed"),{code:w.SUCCESS})})}_resourceHandle(e,n,r){const i=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});var o;return H(this,void 0,void 0,function*(){i._resourceHandle.call(this,e,n,r),e.cdn_uris&&(((o=this._CDNUris)===null||o===void 0?void 0:o.enableInnerCDN)!==e.cdn_uris[0].enableInnerCDN&&this._callAppListener("onCDNEnableChange",!this.__getCDNEnable()),this._CDNUris=e.cdn_uris[0])})}_exchangeHandle(e){var n,r,i;return H(this,void 0,void 0,function*(){const o=yield this._service.exchange(this._getRTCReqestHeaders(),e),s=(r=(n=o.data)===null||n===void 0?void 0:n.urls)===null||r===void 0?void 0:r.pull_url;return o.code===w.SUCCESS&&s&&(this._CDNUris=JSON.parse(s),((i=this._CDNUris)===null||i===void 0?void 0:i.broadcast)===ui.SPREAD&&(this._CDNEnable=!0,this._sendCDNInfoSignal())),o})}_afterChangedRole(e){const n=Zo(e),r=this._context.getCurrentId(),i=Object.keys(n);setTimeout(()=>{var o,s,c;const d=i.filter(l=>l!==r);d.length>0&&this._callAppListener("onUserJoin",d);for(const l in n)l!==r&&this._resourceHandle({uris:n[l]},ce.TOTAL_CONTENT_RESOURCE,l);((o=e.roomInfo.filter(l=>l.key==="cdn_uris")[0])===null||o===void 0?void 0:o.value)&&((s=this._CDNUris)===null||s===void 0?void 0:s.push_mode)===di.MANUAL&&this._callAppListener("onCDNEnableChange",(c=this._CDNUris)===null||c===void 0?void 0:c.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,n){const{code:r,roomPKHandler:i}=this.getRoomPKHandler();if(r===w.SUCCESS&&i){if(!i.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_onLeavePKRoom(e){const{code:n,roomPKHandler:r}=this.getRoomPKHandler();if(n===w.SUCCESS&&r){if(!r.getPKInfo(e))return;this._exchangeWithPushOtherRoom()}}_exchangeWithPushOtherRoom(){return H(this,void 0,void 0,function*(){if(!this.getLocalTracks().length)return;const e=yield this._createExchangeParams(this._subscribedList,!1),n=this._getPushOtherRoomsParams();n&&(e.pushOtherRooms=n);const r=yield this._exchangeHandle(e);if(r.code!==w.SUCCESS)return O.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:o}=r.data;if(o!==w.SUCCESS)return O.error(`exchange with pushOtherRoom failed: ${o}`),{code:o};const s=yield this._pc.setRemoteAnswer(i.sdp);return s!==w.SUCCESS?{code:s}:void 0})}getRoomPKHandler(){return this._isMainRoom?{code:w.SUCCESS,roomPKHandler:this._roomPKHandler}:(O.error("the `getRoomPKHandler` is disabled in PK room "),{code:w.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){const e=this._roomPKHandler.getJoinedPKRooms();for(const n in e){const r=e[n];this._roomPKHandler.leaveOtherRoom(r)}}}class Mf extends Ld{constructor(e,n,r,i,o,s,c){super(e,n,r,i,qe.RTC,o,s,c,!1)}}const oo=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${ut.browser}|${ut.version}`,ClientVersion:"5.3.1","Client-Session-Id":kd(),"Request-Id":Date.now().toString()});class da{constructor(e,n,r,i=5e3){this._runtime=e,this._context=n,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 n;if(!e)return[];let r;try{r=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch{return O.warn("parse `voipCallInfo` of navi failed: "+e.voipCallInfo),[]}if(r.strategy===0)return[];const i=(n=r.callEngine)===null||n===void 0?void 0:n.filter(c=>c.engineType===4);if(!i||i.length===0)return[];const o=i[0],s=[];return o.mediaServer&&s.push(o.mediaServer.replace(/^(https?:\/\/)?/,"https://")),o.backupMediaServer&&o.backupMediaServer.forEach(c=>{s.push(c.replace(/^(https?:\/\/)?/,"https://"))}),s})(this._context.getNaviInfo())):(this._msInNavi.push(...this._failedMs),this._failedMs.length=0)),this._msInNavi.map(e=>e.trim()))}_request(e,n,r){return H(this,void 0,void 0,function*(){const i=this.getNaviMS();if(i.length===0)return{code:w.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(r.rtcFinger=this._rtcFinger);for(let o=0;o<i.length;o+=1){const s=`${i[o]}${e}`,c=oo();O.debug(`request -> Request-Id: ${c["Request-Id"]}, url: ${s}`);const{status:d,data:l}=yield this._runtime.httpReq({url:s,body:JSON.stringify(r),headers:Object.assign(Object.assign({},c),n),method:pt.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),O.debug(`request success -> Request-Id: ${c["Request-Id"]}`),{code:w.SUCCESS,data:h}}O.warn(`request failed -> Request-Id: ${c["Request-Id"]}, status: ${d}, url: ${s}`),this._failedMs.push(...this._msInNavi.splice(o,1))}return{code:w.REQUEST_FAILED}})}exchange(e,n){var r;return H(this,void 0,void 0,function*(){const i=yield this._request("/exchange",e,n);if(i.code===w.SUCCESS&&((r=i.data)===null||r===void 0?void 0:r.resultCode)===w.SUCCESS){const o=i.data.urls;o&&(this._configUrl=o.configUrl)}return i})}exit(e){return H(this,void 0,void 0,function*(){const{code:n}=yield this._request("/exit",e,{});return n})}broadcastSubscribe(e,n){return this._request("/broadcast/subscribe",e,n)}broadcastExit(e){return H(this,void 0,void 0,function*(){const{code:n}=yield this._request("/broadcast/exit",e,{});return{code:n}})}setMcuConfig(e,n){return H(this,void 0,void 0,function*(){if(!this._configUrl)return{code:w.MCU_SERVER_NOT_FOUND};const r=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,i=oo();O.debug(`request -> Request-Id: ${i["Request-Id"]}, url: ${r}`);const{status:o,data:s}=yield this._runtime.httpReq({url:r,headers:Object.assign(Object.assign({},i),e),body:JSON.stringify(n),method:pt.POST});if(o===200){O.debug(`request success -> Request-Id: ${i["Request-Id"]}`);const c=JSON.parse(s);return{code:c.resultCode,res:c}}return{code:w.REQUEST_FAILED}})}getCDNResourceInfo(e,n){return H(this,void 0,void 0,function*(){const r=oo(),{status:i,data:o}=yield this._runtime.httpReq({url:n,headers:Object.assign(Object.assign({},r),e),method:pt.GET});if(i===200){const s=JSON.parse(o);return{code:s.resultCode,res:s}}return O.warn(`request failed -> Request-Id: ${r["Request-Id"]}, status: ${i}, url: ${n}`),{code:w.REQUEST_FAILED}})}}class Pf{constructor(e,n,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 da(n,e,r.mediaServer)}_getReqHeaders(e){return H(this,void 0,void 0,function*(){const n=this._context.getCurrentId(),r=n;if(!this._rtcToken){const{code:i,data:o}=yield this._context.getRTCToken(r,qe.LIVE,e);if(i!==N.SUCCESS)return O.error(`getRTCToken failed: ${i}`),{code:w.SIGNAL_ERROR};this._rtcToken=o.rtcToken}return{code:w.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:n,RoomId:r,RoomType:qe.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 H(this,void 0,void 0,function*(){this._fromRetry=!0;const{code:n}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);n===w.SUCCESS&&((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer())})}subscribe(e,n,r,i=!1){return H(this,void 0,void 0,function*(){return be(()=>this.__subscribe(e,n,r,i))})}__subscribe(e,n,r,i=!1){var o;return H(this,void 0,void 0,function*(){const s=[];if(jr(this._context.getNaviInfo()))return{code:w.PACKAGE_ENVIRONMENT_ERROR,tracks:s};if(!this._fromRetry&&((o=this._pc)===null||o===void 0||o.clearReTryExchangeTimer()),this._fromRetry=!1,!Ze(e))return O.error(`liveUrl is invalid: ${e}`),{code:w.PARAMS_ERROR,tracks:s};if(![ft.AUDIO,ft.VIDEO].includes(n))return O.error(`livingType is invalid: ${n}`),{code:w.PARAMS_ERROR,tracks:s};if(![_e.AUDIO_ONLY,_e.VIDEO_ONLY,_e.AUDIO_VIDEO].includes(r))return O.error(`mediaType is invalid: ${r}`),{code:w.PARAMS_ERROR,tracks:s};if(this._liveUrl&&this._liveUrl!==e)return{code:w.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s};this._pc||(this._pc=new St(this._reTryExchange.bind(this)),this._pc.on(St.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this.registerReportListener(this._reportListener)),this._liveUrl=e;const{code:c,headers:d}=yield this._getReqHeaders(n);if(c!==w.SUCCESS)return{code:c,tracks:s};const l=`rc_mcu_${Date.now()}`,h="RongCloudRTC";this._subTracks.length===0&&(this._subTracks.push(new wt(h,l),new Ot(h,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const a={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?at.TINY:at.NORMAL,switchstream:!1},u=yield this._service.broadcastSubscribe(d,a);if(u.code!==w.SUCCESS)return O.error(`andience subscribe failed: ${u.code}`),{code:u.code,tracks:s};const f=u.data;if(f.resultCode!==w.SUCCESS)return O.error(`andience subscribe failed! code: ${f.resultCode}; message: ${f.message}`),{code:f.resultCode,tracks:s};O.debug(`andience subscribe success: ${e}`),this._livingType=n,this._mediaType=r,this._subTiny=i;const{sdp:p,subscribedList:m}=f,_=[];return m.forEach(v=>{const{mediaType:y}=v,C=this._subTracks[y];_.push(C),C.__innerSetRemoteMuted(!0)}),this._pc.setRemoteAnswer(p.sdp),{code:w.SUCCESS,tracks:_}})}unsubscribe(){return H(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe())})}__unsubscribe(){var e;return H(this,void 0,void 0,function*(){if((e=this._pc)===null||e===void 0||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return{code:w.SUCCESS};const{headers:n}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(n);return r!==w.SUCCESS?O.error(`broadcast unsubscribe failed: ${r}`):O.debug("broadcast unsubscribe success"),this._clearSubscribeInfo(),{code:r}})}registerReportListener(e){var n;this._reportListener=e,(n=this._pc)===null||n===void 0||n.registerReportListener(e)}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var n,r;const i=e.receiver.track,o=i.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY,s=this._subTracks[o];s.__innerSetMediaStreamTrack(i);try{(r=(n=this._appListener)===null||n===void 0?void 0:n.onTrackReady)===null||r===void 0||r.call(n,s)}catch(c){O.error(c)}}}var es,$n;(function(t){t.RTMP="rtmp",t.FLV="flv",t.HLS="hls"})(es||(es={})),function(t){t[t.NOT_HTTPS=0]="NOT_HTTPS",t[t.HTTPS=1]="HTTPS"}($n||($n={}));const Lf=Object.assign(Object.assign({},Et(Re.W176_H144)),{frameRate:Rt(Ct.FPS_15)});class Lc{constructor(e,n,r,i,o,s){this._context=e,this._runtime=n,this._initOptions=r,this._roomId=i,this._joinResData=o,this._livingType=s,this._roomAnchorList=[],this._roomRes={},this._roomAnchorRes={},this._remoteTracks={},this._appListener=null,this._subscribedList=[],this._sessionId="",this._destroyed=!1,this._setInitData(),this._service=new da(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout),this._polarisReport=new Md(this._context,this._runtime,this._roomId,this,si.Audience),this._polarisReport.sendR1(),this._pc=new St(this._reTryExchange.bind(this),this._polarisReport),this._pc.on(St.__INNER_EVENT_TRACK_READY__,c=>{const d=c.streams[0].id,l=c.receiver.track,h=[d,l.kind==="audio"?_e.AUDIO_ONLY:_e.VIDEO_ONLY].join("_"),a=this._remoteTracks[h];a?(a.__innerSetMediaStreamTrack(l),this._callAppListener("onTrackReady",a)):O.warn("cannot found RCRemoteTrack:",l.id)}),this._context.onrtcdatachange=this.singalDataChange.bind(this)}_setInitData(){const{sessionId:e,remoteUserIds:n,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:o,CDNUris:s}=((c,d)=>{const l=d.filter(y=>y.key==="RC_RTC_SESSIONID")[0],h=l?l.value:"",a=d.filter(y=>y.key==="RC_ANCHOR_LIST").map(y=>JSON.parse(y.value||"[]"))[0],u=d.filter(y=>y.key.includes("RC_RES_")).map(y=>JSON.parse(y.value||"{}")),f=u.length?JSON.parse(u[0].mcu_uris||"[]"):[],p=[];f.forEach(y=>{const{mediaType:C,tag:I}=y,P=C===_e.AUDIO_ONLY?new wt(I,"",c):new Ot(I,"",c);p.push(P)});const m=[],_=[];u.forEach(y=>{const C=JSON.parse(y.uris||"[]");m.push(...C),C.forEach(I=>{const{mediaType:P,tag:b,msid:R}=I,M=R.split("_")[0],F=P===_e.AUDIO_ONLY?new wt(b,M):new Ot(b,M);_.push(F)})});const v=d.filter(y=>y.key==="RC_CDN").map(y=>{const C=JSON.parse(y.value||"[]");return JSON.parse(C.cdn_uris)[0]})[0];return{sessionId:h,remoteUserIds:a||[],remoteRTCUris:m,remoteMUCUris:f,remoteRTCTracks:_,remoteMCUTracks:p,remoteTracks:[..._,...p],CDNUris:v||{}}})(this._roomId,this._joinResData.kvEntries);this._sessionId=e,this._roomAnchorList=n,o.forEach(c=>{this._remoteTracks[c.getTrackId()]=c}),this._CDNUris=s,r.forEach(c=>{const d=c.msid.split("_")[0];this._roomAnchorRes[d]?this._roomAnchorRes[d].push(c):this._roomAnchorRes[d]=[c]}),i.forEach(c=>{const{mediaType:d,tag:l}=c,h=[this._roomId,l,d].join("_");this._roomRes[h]=c}),r.forEach(c=>{const d=fe(c);this._roomRes[d]=c})}_assertRoomDestroyed(){if(this._destroyed){const e="This room has been destroyed. Please use `RCRTCClient.joinLivingRoomAsAudience` to catch another instance.";return O.warn(e),w.ROOM_HAS_BEEN_DESTROYED}}singalDataChange(e,n){var r;if(n!==this._roomId)return void O.warn(`singalDataChange -> not the current room data: data roomId: ${n}, current roomId: ${this._roomId}`);O.debug("singalDataChange -> singalData:",JSON.stringify(e||{}));const i=[],o=(r=e.filter(s=>s.key==="RC_CDN")[0])===null||r===void 0?void 0:r.value;o&&this._diffCDNUris(JSON.parse(JSON.parse(o).cdn_uris)[0]),e.forEach(s=>{const{key:c,value:d,timestamp:l,uid:h}=s;if(c.indexOf("RC_RES_")!==-1){const a=JSON.parse(d||"{}"),u=JSON.parse(a.mcu_uris||"[]"),f=JSON.parse(a.uris||"[]");return i.push(...u),void this._diffAnchorResource(f,h)}if(c==="RC_ANCHOR_LIST"){const a=JSON.parse(d||"[]"),{joinUserIds:u,leftUserIds:f}=this._diffAnchorList(a);u.length>0&&this._handleNewJoinedAnchor(u),f.length>0&&this._handleLeftedAnchor(f)}}),this._diffRoomResource(i)}_diffAnchorList(e){const n=e.filter(r=>this._roomAnchorList.indexOf(r)<0);return{leftUserIds:this._roomAnchorList.filter(r=>e.indexOf(r)<0),joinUserIds:n}}_handleNewJoinedAnchor(e){this._roomAnchorList.push(...e),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e){return H(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(r=>!(e.indexOf(r)>-1));const n=[];e.forEach(r=>{n.push(...this.getRemoteTracksByUserId(r)),delete this._roomAnchorRes[r]}),n.length&&(yield this.unsubscribe(n),n.forEach(r=>delete this._remoteTracks[r.getTrackId()])),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e){return H(this,void 0,void 0,function*(){const n=[],r=[],i=[];e.forEach(o=>{const s=fe(o),{userId:c,tag:d,mediaType:l}=Ke(s),h=[this._roomId,d,l].join("_");if(!this._remoteTracks[h]){const a=l===_e.AUDIO_ONLY?new wt(d,"",this._roomId):new Ot(d,"",this._roomId);n.push(a),this._remoteTracks[h]=a,this._roomRes[a.getTrackId()]=o}i.push(h)}),Object.keys(this._remoteTracks).forEach(o=>{i.indexOf(o)<0&&this._remoteTracks[o].isMCUTrack()&&r.push(this._remoteTracks[o])}),n.length>0&&this._callAppListener("onTrackPublish",n),r.length>0&&this._onUserUnpublish(r,"onTrackUnpublish")})}_diffAnchorResource(e,n){return H(this,void 0,void 0,function*(){const r=this._roomAnchorRes[n]||(this._roomAnchorRes[n]=[]),{publishedList:i,unpublishedList:o,modifiedList:s}=Hr(r,e);if(i.length){const c=r.map(fe),d=[],l=[];if(i.forEach(h=>{const a=fe(h),u=c.indexOf(a),{userId:f,tag:p,mediaType:m}=Ke(a);u>-1?r[u]=h:r.push(h);let _=this._remoteTracks[a];this._roomRes[a]=h,_?_.isSubscribed()&&d.push(_):(_=m===_e.AUDIO_ONLY?new wt(p,f):new Ot(p,f),this._remoteTracks[a]=_,l.push(_)),_.__innerSetRemoteMuted(h.state===0)}),d.length){const h=d.map(u=>u.getTrackId());O.debug(`resub tracks -> ${JSON.stringify(h)}`);const{code:a}=yield be(()=>this._subscribeHandle(d,!0));a!==w.SUCCESS&&O.error(`resub tracks failed -> code: ${a}, ids: ${JSON.stringify(h)}`)}this._callAppListener("onAnchorTrackPublish",l)}if(o.length){const c=o.map(fe);for(let l=r.length-1;l>=0;l-=1){const h=r[l];c.includes(fe(h))&&r.splice(l,1)}const d=o.map(l=>{const h=fe(l);return this._remoteTracks[h]});yield this._onUserUnpublish(d,"onAnchorTrackUnpublish")}if(s.length){const c=r.map(fe);for(let d=0;d<s.length;d++){const l=s[d],h=fe(l),a=c.indexOf(h);r[a].state=l.state;const u=this._remoteTracks[h];u.__innerSetRemoteMuted(l.state===0),u.isAudioTrack()?this._callAppListener("onAudioMuteChange",u):this._callAppListener("onVideoMuteChange",u)}}})}_onUserUnpublish(e,n){return H(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(n,e)})}_callAppListener(e,...n){var r;const i=(r=this._appListener)===null||r===void 0?void 0:r[e];if(i)try{i(...n)}catch(o){O.error(o)}}_reTryExchange(){return H(this,void 0,void 0,function*(){be(()=>H(this,void 0,void 0,function*(){var e;const{reqBody:n}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(n);if(r.code!==w.SUCCESS)return O.error(`reTryExchange failed: ${r.code}`),{code:r.code};const{sdp:i,resultCode:o}=r.data;if(o!==w.SUCCESS)return O.error(`reTryExchange failed: ${o}`),{code:o};this._pc.clearReTryExchangeTimer();const s=this._subscribedList.filter(d=>d.track.isMCUTrack());if(s.length>0){const d=s[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 c=yield this._pc.setRemoteAnswer(i.sdp);return c!==w.SUCCESS?{code:c}:void 0}))})}_createSubscribeParams(e,n,r){return H(this,void 0,void 0,function*(){const i=yield this._pc.createOffer(r),o={resolutionInfo:[]},s={min:0,max:0};return Object.keys(n).forEach(c=>{const{mediaStream:d,tinyStream:l}=n[c];[d,l].forEach((h,a)=>{var u;const f=a===1?[c,"tiny"].join("_"):c;i.sdp=(u=i.sdp)===null||u===void 0?void 0:u.replace(new RegExp(h.id,"g"),f);const p=h.getVideoTracks()[0];if(!p)return;const m=a===0,{width:_,height:v,frameRate:y}=m?ca(p):Lf;o.resolutionInfo.push({trackId:p.id,simulcast:m?at.NORMAL:at.TINY,resolution:`${_}x${v}`});const C=bd(_,v),I=Nd(y);s.min+=C.minBitrate*I,s.max+=C.maxBitrate*I})}),{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(c=>({simulcast:c.subTiny?at.TINY:at.NORMAL,resolution:"",uri:this._roomRes[c.track.getTrackId()].uri}))},dynamicBitrate:s,offer:i}})}_subscribeHandle(e,n=!1){var r;return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:w.ROOM_HAS_BEEN_DESTROYED};if(!Ee("tracks",e,()=>We(e)&&e.length>0&&e.every(d=>d instanceof Be||d.track instanceof Be),!0))return{code:w.PARAMS_ERROR};const i=this._subscribedList.map(d=>Object.assign({},d)),o=e.map(d=>d instanceof Be?{track:d}:d);let s=!1;const c=[];return o.forEach(d=>{const l=d.track.getTrackId();c.push(l);const h=i.find(a=>a.track.getTrackId()===l);h&&h.subTiny===d.subTiny||(h?h.subTiny=d.subTiny:i.push(d),s=!0)}),s||n?((r=this._polarisReport)===null||r===void 0||r.sendR2(Mt.SUBSCRIBE,Pt.BEGIN,c),this._updateSubListHandle(i,!0)):{code:w.SUCCESS}})}_getReqHeaders(){const e=this._context.getCurrentId();return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:qe.LIVE,UserId:e,"Session-Id":this._sessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_updateSubListHandle(e,n=!1){var r;return H(this,void 0,void 0,function*(){if(this._assertRoomDestroyed())return{code:w.ROOM_HAS_BEEN_DESTROYED};if(!Ee("resources",e,()=>We(e)&&e.every(y=>y instanceof Be||y.track instanceof Be),!0))return{code:w.PARAMS_ERROR};let i=e.map(y=>y instanceof Be?{track:y}:Object.assign({},y));const o={};i=i.filter(y=>{const C=y.track.getTrackId();return!o[C]&&(o[C]=!0)}).map(y=>Object.assign({},y));const s=this._subscribedList.map(y=>Object.assign({},y));if(!n){let y=!1;if(i.forEach(C=>{const I=s.findIndex(P=>P.track===C.track);if(I===-1)return void(y=!0);s.splice(I,1)[0].subTiny!==C.subTiny&&(y=!0)}),s.length&&(y=!0),!y)return{code:w.SUCCESS}}this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(i.map(y=>y.track));const{reqBody:c}=yield this._createSubscribeParams(i,{},!1),d=yield this._exchangeHandle(c);if(s.length){const y=[];s.forEach(C=>{y.push(C.track.getTrackId())}),(r=this._pc.reportParser)===null||r===void 0||r.clearLatestPacketsRecv(y)}if(d.code!==w.SUCCESS)return{code:d.code};const{sdp:l,resultCode:h,message:a,subscribedList:u}=d.data;if(h!==w.SUCCESS)return O.error("change subscribe list failed:",a,h),{code:h};i.forEach(y=>{const{track:C}=y;if(C.isMCUTrack()){const I=this._roomRes[C.getTrackId()].msid,{tag:P,userId:b}=Ke(C.getTrackId()),R=[b,P].join("_");l.sdp=l.sdp.replace(new RegExp(I,"g"),R)}});const f=yield this._pc.setRemoteAnswer(l.sdp);if(f!==w.SUCCESS)return{code:f};const p=u==null?void 0:u.map(y=>`${y.msid}_${y.mediaType}`),m=i.filter(y=>{if(y.track.isMCUTrack()){const C=this._roomRes[y.track.getTrackId()],I=`${C.msid}_${C.mediaType}`;return p.includes(I)}return p==null?void 0:p.includes(y.track.getTrackId())}),_=m==null?void 0:m.map(y=>`${y.track.getTrackId()}`),v=i.filter(y=>!(_==null?void 0:_.includes(y.track.getTrackId())));for(const y in this._remoteTracks){const C=m.some(I=>I.track.getTrackId()===y);this._remoteTracks[y].__innerSetSubscribed(C)}return this._subscribedList.splice(0,this._subscribedList.length,...m),v.length?{code:w.SUCCESS,failedList:v}:{code:w.SUCCESS}})}_diffCDNUris(e){return H(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 n=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;(n||r||i)&&this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),this._CDNUris=e})}_getCDNPlayUrl(e){return H(this,void 0,void 0,function*(){const{w:n,h:r,fps:i}=e,o=this._initOptions.pullInnerCDNProtocol||es.FLV,s=this._initOptions.pullInnerCDNUseHttps===$n.NOT_HTTPS?$n.NOT_HTTPS:$n.HTTPS;if(!this._CDNUris.url)return O.error(`cdn_uris url is empty, the anchor need to open or push CDN, code: ${w.CDN_RESOURCE_IS_EMPTY}`),{code:w.CDN_RESOURCE_IS_EMPTY};const c={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._context.getCurrentId(),SessionId:this.getSessionId()},d=[];n&&d.push(`w=${n}`),r&&d.push(`h=${r}`),i&&d.push(`fps=${i}`),d.push(`kind=${o}`),d.push(`is_https=${s}`);const l=d.join("&");let h=`${this._CDNUris.url}?`;l&&(h+=l);const{code:a,res:u}=yield this._service.getCDNResourceInfo(c,h);return a!==w.SUCCESS?(O.error(`getCDNPlayUrl failed: ${a}`),{code:a}):(O.info(`getCDNPlayUrl success: ${u==null?void 0:u.data.pull_url}`),{code:a,CDNPlayUrl:u==null?void 0:u.data.pull_url})})}getCDNPlayUrl(e,n){return H(this,void 0,void 0,function*(){if(e&&!sn(e))return O.error("`resolution` is invalid"),{code:w.PARAMS_ERROR};if(n&&!Qo(n))return O.error("`fps` is invalid"),{code:w.PARAMS_ERROR};const{width:r,height:i}=e?Et(e):{width:null,height:null},o=n?Rt(n):null,s={};return r&&(s.w=r),i&&(s.h=i),o&&(s.fps=o),this._getCDNPlayUrl(s)})}subscribe(e){return H(this,void 0,void 0,function*(){return be(()=>this._subscribeHandle(e,!1))})}__unsubscribe(e){var n;return H(this,void 0,void 0,function*(){if(!Ee("tracks",e,()=>We(e)&&e.length>0&&e.every(i=>i instanceof Be),!0))return O.error(`unsubscribe failed, tracks is invalid -> roomId: ${this._roomId}`),{code:w.PARAMS_ERROR};const r=this._subscribedList.map(i=>Object.assign({},i)).filter(i=>!e.includes(i.track));return(n=this._polarisReport)===null||n===void 0||n.sendR2(Mt.SUBSCRIBE,Pt.END,e.map(i=>i.getTrackId())),this._updateSubListHandle(r,!1)})}unsubscribe(e){return H(this,void 0,void 0,function*(){return be(()=>this.__unsubscribe(e))})}__destroy(e){var n;return H(this,void 0,void 0,function*(){this._destroyed||(this._destroyed=!0,(n=this._audioLevelReport)===null||n===void 0||n.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 H(this,void 0,void 0,function*(){const{code:e}=yield this._context.joinLivingRoomAsAudience(this._roomId,qe.LIVE);e!==N.SUCCESS&&O.error("join living room error when on reconnected")})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,n){var r;(r=this._audioLevelReport)===null||r===void 0||r.clearAudioLevelReportTimer(),this._audioLevelReport=new Pd(this),this._audioLevelReport.onAudioLevelChange(e,n||1e3)}registerReportListener(e){var n;(n=this._pc)===null||n===void 0||n.registerReportListener(e)}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const n=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&n.push(i)}return n}getRemoteTracks(){const e=[],n=[];for(const r in this._remoteTracks){if(n.length===2)break;const i=this._remoteTracks[r];i.isMCUTrack()&&n.push(i)}return this._roomAnchorList.forEach(r=>{e.push(...this.getRemoteTracksByUserId(r))}),[...n,...e]}getRemoteRTCTracks(){const e=[];for(const n in this._remoteTracks){const r=this._remoteTracks[n];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const n in this._remoteTracks){const r=this._remoteTracks[n];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 kc=(t,e)=>{const n=[];return n[0]=(e==null?void 0:e.withoutAudio)?void 0:t.getAudioTracks()[0],n[1]=(e==null?void 0:e.withoutVideo)?void 0:t.getVideoTracks()[0],n};class kf{constructor(e,n,r){this._context=e,this._runtime=n,this._options=r,this._crtRoom=null,this._audience=null,this._crtAudienceLivingRoom=null,En.setSdpSemantics(r.sdpSemantics||"plan-b"),this._service=new da(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 n;return e.conversationType!==z.RTC_ROOM?!1:(this._crtRoom instanceof Lt&&this._getJoinedPKRoomList().forEach(r=>{r.__parseInnerMessage(e)}),(n=this._crtRoom)===null||n===void 0||n.__parseInnerMessage(e),!0)}_getJoinedPKRoomList(){const{code:e,roomPKHandler:n}=this._crtRoom.getRoomPKHandler();if(e===w.SUCCESS&&n){const r=n.getJoinedPKRooms()||{};return Object.values(r)}return[]}getCurrentId(){return this._context.getCurrentId()}joinRTCRoom(e,n){return be(()=>this._joinRTCRoom(e,n))}_joinRTCRoom(e,n){return H(this,void 0,void 0,function*(){if(jr(this._context.getNaviInfo()))return{code:w.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Xe,!0))return{code:w.PARAMS_ERROR};if(this._crtRoom)return{code:w.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==ne.CONNECTED)return{code:w.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:w.NOT_OPEN_VIDEO_AUDIO_SERVER};O.debug(`joinRoom -> roomId: ${e}; joinType: ${n||ko.KICK}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,qe.RTC,void 0,n);if(r!==N.SUCCESS)return O.error(`joinRoom failed -> code: ${r}`),{code:r===$o.JOIN_REFUSED?w.SIGNAL_JOIN_RTC_ROOM_REFUSED:r};O.debug(`joinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const o=new Mf(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this));return this._crtRoom=o,{room:o,code:w.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()}})}joinLivingRoom(e,n){return be(()=>this._joinLivingRoom(e,n))}_joinLivingRoom(e,n){return H(this,void 0,void 0,function*(){if(jr(this._context.getNaviInfo()))return{code:w.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Xe,!0)||!Ee("livingType",n,c=>c===ft.AUDIO||c===ft.VIDEO))return{code:w.PARAMS_ERROR};if(this._crtRoom)return{code:w.REPERT_JOIN_ROOM};if(this._context.getConnectionStatus()!==ne.CONNECTED)return{code:w.SIGNAL_DISCONNECTED};if(!this._service.getNaviMS().length)return{code:w.NOT_OPEN_VIDEO_AUDIO_SERVER};O.debug(`joinRoom, roomId: ${e}`);const{code:r,data:i}=yield this._context.joinRTCRoom(e,qe.LIVE,n);if(r!==N.SUCCESS)return O.error(`joinRoom failed -> code: ${r}`),{code:r};O.debug(`JoinRoom success -> userId: ${this._context.getCurrentId()}, roomId: ${e}, data: ${JSON.stringify(i)}`);const o=new Lt(this._context,this._runtime,e,i,this._service,this._options,this._releaseCrtRoomObj.bind(this),n,!1,!0);this._crtRoom=o;const s={room:o,code:w.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()};return o.__getCDNPushMode()===di.MANUAL&&Object.assign(s,{CDNEnable:o.__getCDNEnable()}),s})}getAudienceClient(){return this._audience||(this._audience=new Pf(this._context,this._runtime,this._options)),this._audience}_onIMStatusChange(e){O.debug(`signal server connection state change: ${e}`),e===ne.CONNECTED&&(this._crtRoom instanceof Lt&&this._getJoinedPKRoomList().forEach(n=>{n.__onReconnected()}),this._crtRoom&&this._crtRoom.__onReconnected())}_onIMDisconnect(){O.debug("TODO -> on IM disconnect")}_onIMUninit(){O.debug("TODO -> on IM client ondestroy")}leaveRoom(e){return be(()=>this._leaveRoom(e))}_leaveRoom(e){return H(this,void 0,void 0,function*(){return this._crtRoom?(yield this._crtRoom.__destroy(!0),O.debug(`quitRTCRoom -> userId: ${this._context.getCurrentId()} , roomId: ${this._crtRoom.getRoomId()}`),this._crtRoom=null,{code:w.SUCCESS}):{code:w.SUCCESS}})}_releaseCrtRoomObj(){this._crtRoom=null}_getMediaStream(e,n="getUserMedia"){return H(this,void 0,void 0,function*(){try{const r=yield navigator.mediaDevices[n](e);return{code:w.SUCCESS,stream:r}}catch(r){if(r.message==="Permission denied")return{code:w.PERMISSION_DENIED};O.error(`get user media failed -> ${r.message}`)}return{code:n==="getUserMedia"?w.GET_USER_MEDIA_FAILED:w.GET_DISPLAY_MEDIA_FAILED}})}createMicrophoneAudioTrack(e="RongCloudRTC",n){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:w.INVALID_USER_ID};const{stream:i,code:o}=yield this._getMediaStream({audio:{deviceId:n==null?void 0:n.micphoneId,sampleRate:n==null?void 0:n.sampleRate}});if(o!==w.SUCCESS)return{code:o};const s=i.getAudioTracks()[0];return{code:o,track:new wc(e,r,s)}})}createCameraVideoTrack(e="RongCloudRTC",n){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:w.INVALID_USER_ID};const i=sn(n==null?void 0:n.resolution)?n.resolution:Re.W640_H480,{width:o,height:s}=Et(i),{stream:c,code:d}=yield this._getMediaStream({video:{deviceId:n==null?void 0:n.cameraId,frameRate:Rt((n==null?void 0:n.frameRate)||Ct.FPS_15),width:o,height:s,facingMode:n==null?void 0:n.faceMode}});if(d!==w.SUCCESS)return{code:d};const l=c.getVideoTracks()[0];return{code:d,track:new Oc(e,r,l)}})}createMicrophoneAndCameraTracks(e="RongCloudRTC",n){var r,i,o,s,c,d;return H(this,void 0,void 0,function*(){const l=[];if(!It(e))return{code:w.INVALID_TAGS,tracks:l};const h=this._context.getCurrentId();if(!h)return{code:w.INVALID_USER_ID,tracks:l};const a=sn((r=n==null?void 0:n.video)===null||r===void 0?void 0:r.resolution)?n.video.resolution:Re.W640_H480,{width:u,height:f}=Et(a),{stream:p,code:m}=yield this._getMediaStream({video:{deviceId:(i=n==null?void 0:n.video)===null||i===void 0?void 0:i.cameraId,frameRate:Rt(((o=n==null?void 0:n.video)===null||o===void 0?void 0:o.frameRate)||Ct.FPS_15),width:u,height:f,facingMode:(s=n==null?void 0:n.video)===null||s===void 0?void 0:s.faceMode},audio:{deviceId:(c=n==null?void 0:n.audio)===null||c===void 0?void 0:c.micphoneId,sampleRate:(d=n==null?void 0:n.audio)===null||d===void 0?void 0:d.sampleRate}});return m!==w.SUCCESS||p.getTracks().forEach(_=>{_.kind==="video"?l.push(new Oc(e,h,_)):l.unshift(new wc(e,h,_))}),{code:m,tracks:l}})}createScreenVideoTrack(e="screenshare",n){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return{code:w.INVALID_USER_ID};if(!Od())return{code:w.BROWSER_NOT_SUPPORT};const i=/Electron/.test(navigator.userAgent);if(i&&!(n==null?void 0:n.chromeMediaSourceId))return{code:w.PARAMS_ERROR};const o=sn(n==null?void 0:n.resolution)?n.resolution:Re.W1280_H720,{width:s,height:c}=Et(o),d=i?{mandatory:{chromeMediaSourceId:n.chromeMediaSourceId,chromeMediaSource:"desktop",minWidth:s,maxWidth:s,minHeight:c,maxHeight:c}}:{frameRate:Rt((n==null?void 0:n.frameRate)||Ct.FPS_15),width:s,height:c},{stream:l,code:h}=yield this._getMediaStream({video:d,audio:!1},i?"getUserMedia":"getDisplayMedia");if(h!==w.SUCCESS)return{code:h};const a=l.getVideoTracks()[0];return{code:h,track:new yf(e,r,a)}})}createLocalAudioTrack(e,n){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS};if(!n||n.toString()!=="[object MediaStreamTrack]"||n.kind!=="audio")return{code:w.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:w.SUCCESS,track:new zo(e,r,n)}:{code:w.INVALID_USER_ID}})}createLocalVideoTrack(e,n){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS};if(!n||n.toString()!=="[object MediaStreamTrack]"||n.kind!=="video")return{code:w.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();return r?{code:w.SUCCESS,track:new dn(e,r,n)}:{code:w.INVALID_USER_ID}})}createLocalFileTracks(e,n,r){return H(this,void 0,void 0,function*(){if(!It(e))return{code:w.INVALID_TAGS,tracks:[]};if(!wd())return{code:w.BROWSER_NOT_SUPPORT,tracks:[]};const i=n instanceof File?URL.createObjectURL(n):n;if(!Yn(i)&&!/^blob:/.test(i))return O.warn(`createLocalFileTracks failed: params error -> url: ${i}`),{code:w.PARAMS_ERROR,tracks:[]};const o=this._context.getCurrentId();return o?new Promise(s=>{const c=document.createElement("video");(r==null?void 0:r.withoutAudio)&&(c.muted=!0),c.onloadedmetadata=()=>{const d=[];let l;try{const u=c.mozCaptureStream?"mozCaptureStream":"captureStream";l=c[u]()}catch(u){O.error(`create RCLocalFileTrack failed, captureSteam error. -> url: ${i}`),O.error(u),s({code:w.CREATE_FILE_TRACK_FAILED,tracks:d})}const[h,a]=kc(l,r);h&&d.push(new vf(e,o,h,c)),a&&d.push(new _f(e,o,a,c)),d.length===0&&(c.pause(),c.src=""),c.onerror=null,s({code:w.SUCCESS,tracks:d})},c.onerror=()=>{O.error(`create RCLocalFileTrack failed -> url: ${i}`),s({code:w.CREATE_FILE_TRACK_FAILED,tracks:[]})},c.src=i,c.loop=!0,c.play()}):{code:w.INVALID_USER_ID,tracks:[]}})}createLocalTracks(e,n,r){return H(this,void 0,void 0,function*(){const i=[];if(!It(e))return{code:w.INVALID_TAGS,tracks:i};if(!(n instanceof MediaStream))return{code:w.PARAMS_ERROR,tracks:i};const o=this._context.getCurrentId();if(!o)return{code:w.INVALID_USER_ID,tracks:i};const[s,c]=kc(n,r);return s&&i.push(new zo(e,o,s)),c&&i.push(new dn(e,o,c)),{code:w.SUCCESS,tracks:i}})}joinLivingRoomAsAudience(e,n){return H(this,void 0,void 0,function*(){if(jr(this._context.getNaviInfo()))return{code:w.PACKAGE_ENVIRONMENT_ERROR};if(!Ee("roomId",e,Xe,!0)||!Ee("livingType",n,s=>s===ft.AUDIO||s===ft.VIDEO))return{code:w.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:w.REPERT_JOIN_ROOM};if(!this._service.getNaviMS().length)return{code:w.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:r,data:i}=yield this._context.joinLivingRoomAsAudience(e,qe.LIVE,n);if(r!==N.SUCCESS)return O.error("audienceJoinLivingRoomError:",r),{code:w.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};O.info(`joinLivingRoomAsAudience success, room data: ${JSON.stringify(i)}`);const o=new Lc(this._context,this._runtime,this._options,e,i,n);return this._crtAudienceLivingRoom=o,{room:o,code:w.SUCCESS,userIds:o.getRemoteUserIds(),RTCTracks:o.getRemoteRTCTracks(),MCUTracks:o.getRemoteMCUTracks(),CDNUris:o.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return H(this,void 0,void 0,function*(){return this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?{code:w.PARAMS_ERROR}:(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,{code:w.SUCCESS}):{code:w.SUCCESS}})}upgradeToAnchorRoom(e){return H(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,Xe,!0))return{code:w.PARAMS_ERROR};if(this._crtRoom)return{code:w.REPERT_JOIN_ROOM};const{code:n,data:r}=yield this._context.rtcIdentityChange(e._roomId,Yr.ViewerToAnchor,e._livingType);if(n!==N.SUCCESS)return O.error("change room identity error",n),{code:w.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};yield this._crtAudienceLivingRoom.__destroy(!1);const i=new Lt(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:w.SUCCESS,userIds:e.getRemoteUserIds(),tracks:i.getRemoteTracks()}})}downgradeToAudienceRoom(e){return H(this,void 0,void 0,function*(){if(!Ee("room._roomId",e._roomId,Xe,!0))return{code:w.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return{code:w.REPERT_JOIN_ROOM};const{code:n,data:r}=yield this._context.rtcIdentityChange(e._roomId,Yr.AnchorToViewer,e.getLivingType());if(n!==N.SUCCESS)return O.error("change room identity error",n),{code:w.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};O.info(`downgradeToAudienceRoom success, room data: ${JSON.stringify(r)}`);const i=new Lc(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:w.SUCCESS,userIds:i.getRemoteUserIds(),RTCTracks:i.getRemoteRTCTracks(),MCUTracks:i.getRemoteMCUTracks(),CDNUris:i.getCDNInfo()}})}getJoinedRoomInfo(){return H(this,void 0,void 0,function*(){const{code:e,data:n}=yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());return e!==N.SUCCESS?(O.error("getJoinedUserInfo error",e),{code:w.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}):{code:w.SUCCESS,data:n}})}}var Uc;(function(t){t[t.SERVER_KICK=1]="SERVER_KICK",t[t.OTHER_KICK=2]="OTHER_KICK"})(Uc||(Uc={}));const Uf={tag:"RCRTC",verify:t=>t.tag!=="browser"?(O.error(`RCRTC Plugin is not support the runtime '${t.tag}'`),!1):Cf?(qt.add("plugin-rtc","5.3.1"),!!qt.validEngine("5.1.0")||(O.error(`The current engine version '${qt.getInfo().engine}' error, plugin-rtc required engine version at least '5.1.0'.`),!1)):(O.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup:(t,e,n={})=>(O.setLogLevel(n.logLevel),O.setLogStdout(n.logStdout),O.warn("RCRTC Version: 5.3.1, Commit: e1af0f5ccb06a0084c94e1219d8af54c9793c06b"),O.warn(`browserInfo.browser -> ${ut.browser}`),O.warn(`browserInfo.supportsUnifiedPlan -> ${ut.supportsUnifiedPlan}`),O.warn(`browserInfo.version -> ${ut.version}`),De("options.mediaServer",n.mediaServer,r=>!(!Yn(r)||location.protocol==="https:"&&!/^https/.test(r))),De("options.timeout",n.timeout,r=>Ie(r)&&r>=5e3&&r<=3e4),De("options.pingGap",n.pingGap,r=>Ie(r)&&r>=3e3&&r<=1e4),new kf(t,e,n))},Df={transResolution:Et,transFrameRate:Rt,parseTrackId:Ke,ifSupportLocalFileTrack:wd,ifSupportScreenShare:Od};function xf(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(i){i(n)}),(r=t.get("*"))&&r.slice().map(function(i){i(e,n)})}}}const ke={"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 Ue=xf();const W=nu({roomUid:"LIVE-2112263-12345",imConnectStatus:"connecting",screenShareStatus:!1,videoRef:as(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 se=W;const Bf="c9kqb3rdc451j";Kh({appkey:Bf});const Vf=Mi("RC:Chatroom:SeatsCtrl",!0,!0),Ff=Mi("RC:Chatroom:ChatBan",!0,!0),Hf=Mi("RC:Chatroom:SeatApply",!0,!0),jf=Mi("RC:Chatroom:SeatResponse",!0,!0),dr=we,Sa=dr,{MESSAGES:__}=Sa,$f=Ta(Sa,["MESSAGES"]);cr(dr.MESSAGES,t=>{console.log(t,"\u6536\u5230\u6D88\u606F");const{messages:e}=t;for(const n of e)ke[n.messageType]&&Ue.emit(ke[n.messageType],In(rt({},n.content),{$EventMessage:n}))});for(const t of Object.values($f))cr(t,e=>{console.log(t,e),Ue.emit(t,{$EventMessage:null})});cr(dr.CONNECTING,()=>{console.log("connecting"),W.imConnectStatus="connecting"});cr(dr.CONNECTED,()=>{console.log("connected"),W.imConnectStatus="connected"});cr(dr.DISCONNECT,()=>{console.log("disconnect"),W.imConnectStatus="disconnect"});const Kf=async t=>{var e;try{const n=await Gh(t);return W.rtcClient=qh(Uf,{}),console.log("connect success",(e=n.data)==null?void 0:e.userId),n}catch(n){throw n}},qf=t=>{W.videoRef&&(W.videoRef.volume=t/100)},Gf=async()=>{var t;if(W.rtcClient){const e=await hn("screen"),n=W.activeTracks.camera;(t=W.joinedRoom)==null||t.unpublish([n]),fn([e],"screen"),W.videoRef&&e.play(W.videoRef),e==null||e.on(pe.EVENT_LOCAL_TRACK_END,r=>{W.screenShareStatus=!1,r.destroy(),fn([n],"camera"),W.videoRef&&n.play(W.videoRef)})}},Yf=async()=>{const t=await sa.getMicrophones();return W.microphones=t,t},Jf=async()=>{const t=await sa.getCameras();return W.cameras=t,t},Ud=t=>{W.selectedCamera=t},Dd=t=>{W.selectedMicrophone=t},hn=async t=>{var r,i,o,s,c;let e,n=null;return t==="microphone"?e=await((i=W.rtcClient)==null?void 0:i.createMicrophoneAudioTrack("RongCloudRTC",{micphoneId:(r=W.selectedMicrophone)==null?void 0:r.deviceId})):t==="camera"?e=await((s=W.rtcClient)==null?void 0:s.createCameraVideoTrack("RongCloudRTC",{cameraId:(o=W.selectedCamera)==null?void 0:o.deviceId,faceMode:"user",frameRate:Ct.FPS_15,resolution:Re.W1280_H720})):e=await((c=W==null?void 0:W.rtcClient)==null?void 0:c.createScreenVideoTrack()),n=e==null?void 0:e.track,e.code===w.PERMISSION_DENIED?W.deviceStatus[t]="denied":W.deviceStatus[t]="granted",n},fn=async(t,e,n=!0)=>{var r;for(const i of t)W.activeTracks[e]=i;n&&await((r=W.joinedRoom)==null?void 0:r.publish(t))},xd=async(t,e,n=!0)=>{var r;for(const i of t)i.destroy(),W.activeTracks[e]=null;n&&await((r=W.joinedRoom)==null?void 0:r.unpublish(t))},Wf=async(t,e,n)=>{var i,o;await Yh(t,{count:-1});const r=await((i=W.rtcClient)==null?void 0:i.joinLivingRoom(t,e));if((r==null?void 0:r.code)!=w.SUCCESS)throw Error("\u52A0\u5165\u623F\u95F4\u5931\u8D25");return(o=r.room)==null||o.registerRoomEventListener(n),r},zf=async()=>{var e,n;if(W.videoStatus!=="stream")throw Error("\u5F53\u524D\u65E0\u89C6\u9891\u6D41");if(W.joinedRoom){const r=await hn("microphone");console.log(r);const i=await hn("camera");await fn([i],"camera"),W.videoStatus="liveing",await fn([r],"microphone");const o=await((e=W.joinedRoom)==null?void 0:e.getMCUConfigBuilder());await((n=o.setOutputVideoRenderMode)==null?void 0:n.call(o,nr.WHOLE)),await o.flush()}},Qf=async()=>{var t;await Dt.post("/api-im/user/statusImUser",{data:{os:"PC",status:2,userId:(t=ge.user)==null?void 0:t.id}}),W.videoStatus="stopped";for(const e in W.activeTracks)if(Object.prototype.hasOwnProperty.call(W.activeTracks,e)){const n=W.activeTracks[e];n&&xd([n],e)}},Bd=async()=>{if(W.likeCount!==W.lastLikeCount||W.likeCount===0)try{await Dt.get("/api-web/imLiveBroadcastRoom/syncLike",{hideLoading:!0,hideMessage:!0,params:{likeNum:W.likeCount,roomUid:W.roomUid}}),W.lastLikeCount=W.likeCount}catch{}setTimeout(()=>{Bd()},1e3*60)},li=()=>{var t,e,n,r;return{id:(t=ge.user)==null?void 0:t.speakerId,name:(e=ge.user)==null?void 0:e.speakerName,userId:(n=ge.user)==null?void 0:n.speakerId,userName:(r=ge.user)==null?void 0:r.speakerName}},Yt=async(t,e="text")=>{var i;let n=null;if(!t)return;const r={conversationType:z.CHATROOM,targetId:(i=W.joinedRoom)==null?void 0:i._roomId};if(e==="text"?n=new Qh({user:li(),content:t}):e==="SeatsCtrl"?n=new Vf(t):e==="ChatBan"?n=new Ff(t):e==="SeatApply"?n=new Hf(t):e==="SeatResponse"&&(n=new jf(t)),!!n)return console.log(n),await Ku(r,n)},Vd=async(t,e=!0)=>{var n;if(t==="microphone"&&W.activeTracks[t])(n=W.activeTracks[t])==null||n.unmute();else{const r=await hn(t);await fn([r],t,e),W.videoRef&&r.play(W.videoRef)}},hi=async(t,e=!0)=>{const n=W.activeTracks[t];t!=="microphone"?(await xd([n],t,e),n==null||n.destroy()):n==null||n.mute()},Xf=async t=>{const e=W.activeTracks[t],n=W.videoStatus==="liveing";e?hi(t,n):Vd(t,n)};var Zf=Fe({methods:{async loginOut(){try{await Dt.post("/api-auth/exit",{data:{}}),hi("camera"),hi("microphone"),ge.user=null,Ur.success("\u9000\u51FA\u6210\u529F"),pl(),this.$router.push({path:"/login",query:rt({},this.$route.query)})}catch{}}},render(){var t,e,n;return S("div",{class:Vt.liveHeader},[S("div",{class:Vt.liveHeaderLeft},[S("div",{class:Vt.liveHeaderLeftIcon},[S("img",{class:Vt.liveLogo,src:(t=ge.user)==null?void 0:t.tenantLogo,alt:""},null),(e=ge.user)==null?void 0:e.tenantName]),S("div",{class:Vt.liveHeaderLeftText},[Z("\u300A"),(n=ge.user)==null?void 0:n.roomTitle,Z("\u300B")])]),S(Dr,{trigger:"hover"},{default:()=>{var r;return[S("div",{class:Vt.avatarWrapper},[S("img",{class:Vt.userAvatar,src:"/src/assets/home/placehorder-icon.png"},null),S("span",null,[(r=ge.user)==null?void 0:r.speakerName])])]},dropdown:()=>S(yo,null,{default:()=>[S(Co,{command:"1",onClick:this.loginOut},{default:()=>[S("span",null,[Z("\u5B89\u5168\u9000\u51FA")])]})]})})])}});const ep="_header_22t18_1",tp="_title_22t18_9";var Dc={header:ep,title:tp},np=Fe({name:"LiveBroadcastHeader",methods:{async startLive(){try{await Ia.confirm("\u662F\u5426\u786E\u8BA4\u5F00\u59CB\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await zf()}catch{}},async closeLive(){var t;try{await Ia.confirm("\u662F\u5426\u786E\u8BA4\u7ED3\u675F\u76F4\u64AD\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}),await Dt.post("/api-im/user/statusImUser",{data:{os:"IOS",status:"2",userid:(t=ge.user)==null?void 0:t.id}}),await Qf()}catch{}}},render(){var t;return S("div",{class:Dc.header},[S("h3",{class:Dc.title},[Z("\u76F4\u64AD\u5185\u5BB9\uFF1A"),(t=ge.user)==null?void 0:t.liveRemark]),se.videoStatus==="liveing"?S(lt,{type:"danger",color:"#EA4132",onClick:this.closeLive},{default:()=>[Z("\u5173\u95ED\u76F4\u64AD")]}):S(lt,{type:"primary",color:"#01A79E",onClick:this.startLive},{default:()=>[Z("\u5F00\u59CB\u76F4\u64AD")]})])}});const rp="_volumeSlider_1akc3_71",ip="_volumeIcon_1akc3_80",op="_btnInner_1akc3_85";var Te={"action-bar":"_action-bar_1akc3_1","bar-btn":"_bar-btn_1akc3_12","bar-btn-text":"_bar-btn-text_1akc3_19",volumeSlider:rp,volumeIcon:ip,btnInner:op};const sp="_shareWrap_d61fv_1",ap="_shareBtn_d61fv_27";var _t={shareWrap:sp,shareBtn:ap};function cp(){let t=window.location.href,e="";return/online/.test(t)?e="https://mstuonline.dayaedu.com":/dev/.test(t)?e="http://mstudev.dayaedu.com":/test/.test(t)?e="http://mstutest.dayaedu.com":e="http://mstudev.dayaedu.com",e}var Fd=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const xc="application/font-woff",Bc="image/jpeg",up={woff:xc,woff2:xc,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Bc,jpeg:Bc,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function dp(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function fi(t){const e=dp(t).toLowerCase();return up[e]||""}function lp(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),e&&(r.href=e),i.href=t,i.href}function ts(t){return t.search(/^(data:)/)!==-1}function pi(t,e){return`data:${e};base64,${t}`}function hp(t){return t.split(/,/)[1]}const fp=function(){let e=0;const n=()=>`0000${(Math.random()*Math.pow(36,4)<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${n()}${e}`)}();function xt(t){const e=[];for(let n=0,r=t.length;n<r;n+=1)e.push(t[n]);return e}function gi(t,e){const n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}function pp(t){const e=gi(t,"border-left-width"),n=gi(t,"border-right-width");return t.clientWidth+e+n}function gp(t){const e=gi(t,"border-top-width"),n=gi(t,"border-bottom-width");return t.clientHeight+e+n}function mp(){let t,e;try{e=process}catch{}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}function la(t){return new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=n,r.crossOrigin="anonymous",r.decoding="sync",r.src=t})}function _p(t){return Fd(this,void 0,void 0,function*(){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)})}function vp(t,e,n){return Fd(this,void 0,void 0,function*(){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),o=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${e} ${n}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),i.appendChild(o),o.appendChild(t),_p(i)})}const so={};function yp(t){let e=t.replace(/\?.*/,"");return/ttf|otf|eot|woff2?/i.test(e)&&(e=e.replace(/.*\//,"")),e}function ha(t,e){const n=yp(t);if(so[n]!=null)return so[n];e.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());const r=o=>{let s="";if(e.imagePlaceholder){const d=e.imagePlaceholder.split(/,/);d&&d[1]&&(s=d[1])}let c=`Failed to fetch resource: ${t}`;return o&&(c=typeof o=="string"?o:o.message),c&&console.error(c),{blob:s,contentType:""}},i=window.fetch(t).then(o=>o.blob().then(s=>({blob:s,contentType:o.headers.get("Content-Type")||""}))).then(({blob:o,contentType:s})=>new Promise((c,d)=>{const l=new FileReader;l.onloadend=()=>c({contentType:s,blob:l.result}),l.onerror=d,l.readAsDataURL(o)})).then(({blob:o,contentType:s})=>({contentType:s,blob:hp(o)})).catch(r);return so[n]=i,i}function Cp(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function Ep(t){return xt(t).map(e=>{const n=t.getPropertyValue(e),r=t.getPropertyPriority(e);return`${e}: ${n}${r?" !important":""};`}).join(" ")}function Rp(t,e,n){const r=`.${t}:${e}`,i=n.cssText?Cp(n):Ep(n);return document.createTextNode(`${r}{${i}}`)}function Vc(t,e,n){const r=window.getComputedStyle(t,n),i=r.getPropertyValue("content");if(i===""||i==="none")return;const o=fp();try{e.className=`${e.className} ${o}`}catch{return}const s=document.createElement("style");s.appendChild(Rp(o,n,r)),e.appendChild(s)}function Tp(t,e){Vc(t,e,":before"),Vc(t,e,":after")}var Rn=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function Sp(t){return Rn(this,void 0,void 0,function*(){const e=t.toDataURL();return e==="data:,"?Promise.resolve(t.cloneNode(!1)):la(e)})}function Ip(t,e){return Rn(this,void 0,void 0,function*(){return Promise.resolve(t.poster).then(n=>ha(n,e)).then(n=>pi(n.blob,fi(t.poster)||n.contentType)).then(n=>la(n))})}function bp(t,e){return Rn(this,void 0,void 0,function*(){return t instanceof HTMLCanvasElement?Sp(t):t instanceof HTMLVideoElement&&t.poster?Ip(t,e):Promise.resolve(t.cloneNode(!1))})}const Np=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT";function wp(t,e,n){var r;return Rn(this,void 0,void 0,function*(){const i=Np(t)&&t.assignedNodes?xt(t.assignedNodes()):xt(((r=t.shadowRoot)!==null&&r!==void 0?r:t).childNodes);return i.length===0||t instanceof HTMLVideoElement?Promise.resolve(e):i.reduce((o,s)=>o.then(()=>Hd(s,n)).then(c=>{c&&e.appendChild(c)}),Promise.resolve()).then(()=>e)})}function Op(t,e){const n=window.getComputedStyle(t),r=e.style;!r||(n.cssText?r.cssText=n.cssText:xt(n).forEach(i=>{r.setProperty(i,n.getPropertyValue(i),n.getPropertyPriority(i))}))}function Ap(t,e){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function Mp(t,e){return Rn(this,void 0,void 0,function*(){return e instanceof Element?Promise.resolve().then(()=>Op(t,e)).then(()=>Tp(t,e)).then(()=>Ap(t,e)).then(()=>e):Promise.resolve(e)})}function Hd(t,e,n){return Rn(this,void 0,void 0,function*(){return!n&&e.filter&&!e.filter(t)?Promise.resolve(null):Promise.resolve(t).then(r=>bp(r,e)).then(r=>wp(t,r,e)).then(r=>Mp(t,r))})}var Pp=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const jd=/url\((['"]?)([^'"]+?)\1\)/g,Lp=/url\([^)]+\)\s*format\((["'])([^"']+)\1\)/g,kp=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Up(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function Dp(t){const e=[];return t.replace(jd,(n,r,i)=>(e.push(i),n)),e.filter(n=>!ts(n))}function xp(t,e,n,r,i){const o=n?lp(e,n):e;return Promise.resolve(o).then(s=>i?i(s):ha(s,r)).then(s=>typeof s=="string"?pi(s,fi(e)):pi(s.blob,fi(e)||s.contentType)).then(s=>t.replace(Up(e),`$1${s}$3`)).then(s=>s,()=>o)}function Bp(t,{preferredFontFormat:e}){return e?t.replace(kp,n=>{for(;;){const[r,,i]=Lp.exec(n)||[];if(!i)return"";if(i===e)return`src: ${r};`}}):t}function $d(t){return t.search(jd)!==-1}function Kd(t,e,n){return Pp(this,void 0,void 0,function*(){if(!$d(t))return Promise.resolve(t);const r=Bp(t,n);return Promise.resolve(r).then(Dp).then(i=>i.reduce((o,s)=>o.then(c=>xp(c,s,e,n)),Promise.resolve(r)))})}var Li=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function Vp(t,e){var n;return Li(this,void 0,void 0,function*(){const r=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue("background");return r?Promise.resolve(r).then(i=>Kd(i,null,e)).then(i=>(t.style.setProperty("background",i,t.style.getPropertyPriority("background")),t)):Promise.resolve(t)})}function Fp(t,e){return Li(this,void 0,void 0,function*(){if(!(t instanceof HTMLImageElement&&!ts(t.src))&&!(t instanceof SVGImageElement&&!ts(t.href.baseVal)))return Promise.resolve(t);const n=t instanceof HTMLImageElement?t.src:t.href.baseVal;return Promise.resolve(n).then(r=>ha(r,e)).then(r=>pi(r.blob,fi(n)||r.contentType)).then(r=>new Promise((i,o)=>{t.onload=i,t.onerror=o,t instanceof HTMLImageElement?(t.srcset="",t.src=r):t.href.baseVal=r})).then(()=>t,()=>t)})}function Hp(t,e){return Li(this,void 0,void 0,function*(){const r=xt(t.childNodes).map(i=>qd(i,e));return Promise.all(r).then(()=>t)})}function qd(t,e){return Li(this,void 0,void 0,function*(){return t instanceof Element?Promise.resolve(t).then(n=>Vp(n,e)).then(n=>Fp(n,e)).then(n=>Hp(n,e)):Promise.resolve(t)})}function jp(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const r=e.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),t}var lr=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};const Fc={};function Hc(t){const e=Fc[t];if(e!=null)return e;const n=window.fetch(t).then(r=>({url:t,cssText:r.text()}));return Fc[t]=n,n}function jc(t){return lr(this,void 0,void 0,function*(){return t.cssText.then(e=>{let n=e;const r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map(s=>{let c=s.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,t.url).href),window.fetch(c).then(d=>d.blob()).then(d=>new Promise((l,h)=>{const a=new FileReader;a.onloadend=()=>{n=n.replace(s,`url(${a.result})`),l([s,a.result])},a.onerror=h,a.readAsDataURL(d)}))});return Promise.all(o).then(()=>n)})})}function $c(t){if(t==null)return[];const e=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=t.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=i.exec(r);if(d===null)break;e.push(d[0])}r=r.replace(i,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(s,"gi");for(;;){let d=o.exec(r);if(d===null){if(d=c.exec(r),d===null)break;o.lastIndex=c.lastIndex}else c.lastIndex=o.lastIndex;e.push(d[0])}return e}function $p(t){return lr(this,void 0,void 0,function*(){const e=[],n=[];return t.forEach(r=>{if("cssRules"in r)try{xt(r.cssRules).forEach((i,o)=>{if(i.type===CSSRule.IMPORT_RULE){let s=o+1;const c=i.href,d=Hc(c).then(l=>l?jc(l):"").then(l=>$c(l).forEach(h=>{try{r.insertRule(h,h.startsWith("@import")?s+=1:r.cssRules.length)}catch(a){console.error("Error inserting rule from remote css",{rule:h,error:a})}})).catch(l=>{console.error("Error loading remote css",l.toString())});n.push(d)}})}catch(i){const o=t.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&n.push(Hc(r.href).then(s=>s?jc(s):"").then(s=>$c(s).forEach(c=>{o.insertRule(c,r.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s.toString())})),console.error("Error inlining remote css file",i.toString())}}),Promise.all(n).then(()=>(t.forEach(r=>{if("cssRules"in r)try{xt(r.cssRules).forEach(i=>{e.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${r.href}`,i.toString())}}),e))})}function Kp(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>$d(e.style.getPropertyValue("src")))}function qp(t){return lr(this,void 0,void 0,function*(){return new Promise((e,n)=>{t.ownerDocument==null&&n(new Error("Provided element is not within a Document")),e(xt(t.ownerDocument.styleSheets))}).then(e=>$p(e)).then(Kp)})}function Gp(t,e){return lr(this,void 0,void 0,function*(){return qp(t).then(n=>Promise.all(n.map(r=>{const i=r.parentStyleSheet?r.parentStyleSheet.href:null;return Kd(r.cssText,i,e)}))).then(n=>n.join(`
  902. `))})}function Yp(t,e){return lr(this,void 0,void 0,function*(){return(e.fontEmbedCSS!=null?Promise.resolve(e.fontEmbedCSS):Gp(t,e)).then(n=>{const r=document.createElement("style"),i=document.createTextNode(n);return r.appendChild(i),t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),t})})}var fa=globalThis&&globalThis.__awaiter||function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function c(h){try{l(r.next(h))}catch(a){s(a)}}function d(h){try{l(r.throw(h))}catch(a){s(a)}}function l(h){h.done?o(h.value):i(h.value).then(c,d)}l((r=r.apply(t,e||[])).next())})};function Gd(t,e={}){const n=e.width||pp(t),r=e.height||gp(t);return{width:n,height:r}}function Jp(t,e={}){return fa(this,void 0,void 0,function*(){const{width:n,height:r}=Gd(t,e);return Promise.resolve(t).then(i=>Hd(i,e,!0)).then(i=>Yp(i,e)).then(i=>qd(i,e)).then(i=>jp(i,e)).then(i=>vp(i,n,r))})}const ze=16384;function Wp(t){(t.width>ze||t.height>ze)&&(t.width>ze&&t.height>ze?t.width>t.height?(t.height*=ze/t.width,t.width=ze):(t.width*=ze/t.height,t.height=ze):t.width>ze?(t.height*=ze/t.width,t.width=ze):(t.width*=ze/t.height,t.height=ze))}function zp(t,e={}){return fa(this,void 0,void 0,function*(){return Jp(t,e).then(la).then(n=>{const r=document.createElement("canvas"),i=r.getContext("2d"),o=e.pixelRatio||mp(),{width:s,height:c}=Gd(t,e),d=e.canvasWidth||s,l=e.canvasHeight||c;return r.width=d*o,r.height=l*o,e.skipAutoScale||Wp(r),r.style.width=`${d}`,r.style.height=`${l}`,e.backgroundColor&&(i.fillStyle=e.backgroundColor,i.fillRect(0,0,r.width,r.height)),i.drawImage(n,0,0,r.width,r.height),r})})}function Qp(t,e={}){return fa(this,void 0,void 0,function*(){return zp(t,e).then(n=>n.toDataURL())})}var Xp=function(){var t=document.getSelection();if(!t.rangeCount)return function(){};for(var e=document.activeElement,n=[],r=0;r<t.rangeCount;r++)n.push(t.getRangeAt(r));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return t.removeAllRanges(),function(){t.type==="Caret"&&t.removeAllRanges(),t.rangeCount||n.forEach(function(i){t.addRange(i)}),e&&e.focus()}},Zp=Xp,Kc={"text/plain":"Text","text/html":"Url",default:"Text"},eg="Copy to clipboard: #{key}, Enter";function tg(t){var e=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return t.replace(/#{\s*key\s*}/g,e)}function ng(t,e){var n,r,i,o,s,c,d=!1;e||(e={}),n=e.debug||!1;try{i=Zp(),o=document.createRange(),s=document.getSelection(),c=document.createElement("span"),c.textContent=t,c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",function(h){if(h.stopPropagation(),e.format)if(h.preventDefault(),typeof h.clipboardData=="undefined"){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var a=Kc[e.format]||Kc.default;window.clipboardData.setData(a,t)}else h.clipboardData.clearData(),h.clipboardData.setData(e.format,t);e.onCopy&&(h.preventDefault(),e.onCopy(h.clipboardData))}),document.body.appendChild(c),o.selectNodeContents(c),s.addRange(o);var l=document.execCommand("copy");if(!l)throw new Error("copy command was unsuccessful");d=!0}catch(h){n&&console.error("unable to copy using execCommand: ",h),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",t),e.onCopy&&e.onCopy(window.clipboardData),d=!0}catch(a){n&&console.error("unable to copy using clipboardData: ",a),n&&console.error("falling back to prompt"),r=tg("message"in e?e.message:eg),window.prompt(r,t)}}finally{s&&(typeof s.removeRange=="function"?s.removeRange(o):s.removeAllRanges()),c&&document.body.removeChild(c),i()}return d}var rg=ng,ig=rg;const og="_shareWrap_ap100_1",sg="_chioseBox_ap100_5",ag="_cell_ap100_17",cg="_dotle_ap100_27",ug="_teamInfo_ap100_38",dg="_title_ap100_42",lg="_subInfo_ap100_47",hg="_tableWrap_ap100_51";var bt={shareWrap:og,chioseBox:sg,cell:ag,dotle:cg,teamInfo:ug,title:dg,subInfo:lg,tableWrap:hg};function fg(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!ou(t)}var pg=Fe({name:"LiveBroadcastGroupChat",data(){return{searchForm:{search:""},checkList:[],tableList:[]}},async mounted(){this.getList()},beforeUnmount(){},methods:{onReSet(){this.searchForm.search="",this.checkList=[],this.search()},search(){this.getList()},async getList(){try{const t=await Dt("/api-web/imGroup/queryGroupList",{params:rt({},this.searchForm)});this.tableList=t.data}catch(t){console.log(t)}},resectCheck(t){const e=t;this.checkList.indexOf(e)==-1?this.checkList.push(e):this.checkList.splice(this.checkList.indexOf(e),1)}},render(){let t;return S("div",null,[S(ru,{model:this.searchForm,ref:"form",inline:!0,class:bt.form},{default:()=>[S(Eo,null,{default:()=>[S(iu,{clearable:!0,placeholder:"\u7FA4\u804A\u540D\u79F0/\u4E50\u56E2\u7F16\u53F7",modelValue:this.searchForm.search,onInput:e=>this.searchForm.search=e},null)]}),S(Eo,null,{default:()=>[S(lt,{type:"primary",onClick:this.search},{default:()=>[Z("\u641C\u7D22")]}),S(lt,{type:"danger",onClick:this.onReSet},{default:()=>[Z("\u91CD\u7F6E")]})]})]}),S("div",{class:bt.tableWrap},[S(gl,{modelValue:this.checkList},fg(t=this.tableList.map(e=>S("div",{class:bt.cell,onClick:()=>this.resectCheck(e.id)},[S(ml,{class:bt.chioseBox,label:e.id,onChange:()=>this.resectCheck(e.id)},{default:()=>[S("br",null,null)]}),S("div",{class:bt.dotle},[e.type=="MUSIC"?"\u4E50\u56E2":"VIP"]),S("div",{class:bt.teamInfo},[S("p",{class:bt.title},[e.name]),S("p",{class:bt.subInfo},[e.memo,Z("\uFF08\u5171"),e.memberNum,Z("\u4EBA\uFF09")])])])))?t:{default:()=>[t]})])])}});const gg="_third_z0wkr_1",mg="_preCore_z0wkr_15",_g="_title_z0wkr_15",vg="_second_z0wkr_18",yg="_first_z0wkr_35",Cg="_icon_z0wkr_49",Eg="_teacher_z0wkr_56",Rg="_start_z0wkr_73",Tg="_time_z0wkr_92",Sg="_content_z0wkr_101",Ig="_pre_z0wkr_15",bg="_end_z0wkr_121",Ng="_bottom_z0wkr_128",wg="_logo_z0wkr_134",Og="_code_z0wkr_138";var ie={third:gg,preCore:mg,title:_g,second:vg,first:yg,icon:Cg,teacher:Eg,start:Rg,time:Tg,content:Sg,pre:Ig,end:bg,bottom:Ng,logo:wg,code:Og},hr={},Ag=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Yd={},nt={};let pa;const Mg=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];nt.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};nt.getSymbolTotalCodewords=function(e){return Mg[e]};nt.getBCHDigit=function(t){let e=0;for(;t!==0;)e++,t>>>=1;return e};nt.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');pa=e};nt.isKanjiModeEnabled=function(){return typeof pa!="undefined"};nt.toSJIS=function(e){return pa(e)};var ki={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit!="undefined"&&r.bit>=0&&r.bit<4},t.from=function(r,i){if(t.isValid(r))return r;try{return e(r)}catch{return i}}})(ki);function Jd(){this.buffer=[],this.length=0}Jd.prototype={get:function(t){const e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)===1},put:function(t,e){for(let n=0;n<e;n++)this.putBit((t>>>e-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Pg=Jd;function fr(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}fr.prototype.set=function(t,e,n,r){const i=t*this.size+e;this.data[i]=n,r&&(this.reservedBit[i]=!0)};fr.prototype.get=function(t,e){return this.data[t*this.size+e]};fr.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n};fr.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var Lg=fr,Wd={};(function(t){const e=nt.getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,o=e(r),s=o===145?26:Math.ceil((o-13)/(2*i-2))*2,c=[o-7];for(let d=1;d<i-1;d++)c[d]=c[d-1]-s;return c.push(6),c.reverse()},t.getPositions=function(r){const i=[],o=t.getRowColCoords(r),s=o.length;for(let c=0;c<s;c++)for(let d=0;d<s;d++)c===0&&d===0||c===0&&d===s-1||c===s-1&&d===0||i.push([o[c],o[d]]);return i}})(Wd);var zd={};const kg=nt.getSymbolSize,qc=7;zd.getPositions=function(e){const n=kg(e);return[[0,0],[n-qc,0],[0,n-qc]]};var Qd={};(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},t.from=function(i){return t.isValid(i)?parseInt(i,10):void 0},t.getPenaltyN1=function(i){const o=i.size;let s=0,c=0,d=0,l=null,h=null;for(let a=0;a<o;a++){c=d=0,l=h=null;for(let u=0;u<o;u++){let f=i.get(a,u);f===l?c++:(c>=5&&(s+=e.N1+(c-5)),l=f,c=1),f=i.get(u,a),f===h?d++:(d>=5&&(s+=e.N1+(d-5)),h=f,d=1)}c>=5&&(s+=e.N1+(c-5)),d>=5&&(s+=e.N1+(d-5))}return s},t.getPenaltyN2=function(i){const o=i.size;let s=0;for(let c=0;c<o-1;c++)for(let d=0;d<o-1;d++){const l=i.get(c,d)+i.get(c,d+1)+i.get(c+1,d)+i.get(c+1,d+1);(l===4||l===0)&&s++}return s*e.N2},t.getPenaltyN3=function(i){const o=i.size;let s=0,c=0,d=0;for(let l=0;l<o;l++){c=d=0;for(let h=0;h<o;h++)c=c<<1&2047|i.get(l,h),h>=10&&(c===1488||c===93)&&s++,d=d<<1&2047|i.get(h,l),h>=10&&(d===1488||d===93)&&s++}return s*e.N3},t.getPenaltyN4=function(i){let o=0;const s=i.data.length;for(let d=0;d<s;d++)o+=i.data[d];return Math.abs(Math.ceil(o*100/s/5)-10)*e.N4};function n(r,i,o){switch(r){case t.Patterns.PATTERN000:return(i+o)%2===0;case t.Patterns.PATTERN001:return i%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(i+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return i*o%2+i*o%3===0;case t.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case t.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(i,o){const s=o.size;for(let c=0;c<s;c++)for(let d=0;d<s;d++)o.isReserved(d,c)||o.xor(d,c,n(i,d,c))},t.getBestMask=function(i,o){const s=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let l=0;l<s;l++){o(l),t.applyMask(l,i);const h=t.getPenaltyN1(i)+t.getPenaltyN2(i)+t.getPenaltyN3(i)+t.getPenaltyN4(i);t.applyMask(l,i),h<d&&(d=h,c=l)}return c}})(Qd);var Ui={};const kt=ki,Pr=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Lr=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Ui.getBlocksCount=function(e,n){switch(n){case kt.L:return Pr[(e-1)*4+0];case kt.M:return Pr[(e-1)*4+1];case kt.Q:return Pr[(e-1)*4+2];case kt.H:return Pr[(e-1)*4+3];default:return}};Ui.getTotalCodewordsCount=function(e,n){switch(n){case kt.L:return Lr[(e-1)*4+0];case kt.M:return Lr[(e-1)*4+1];case kt.Q:return Lr[(e-1)*4+2];case kt.H:return Lr[(e-1)*4+3];default:return}};var Xd={},Di={};const Kn=new Uint8Array(512),mi=new Uint8Array(256);(function(){let e=1;for(let n=0;n<255;n++)Kn[n]=e,mi[e]=n,e<<=1,e&256&&(e^=285);for(let n=255;n<512;n++)Kn[n]=Kn[n-255]})();Di.log=function(e){if(e<1)throw new Error("log("+e+")");return mi[e]};Di.exp=function(e){return Kn[e]};Di.mul=function(e,n){return e===0||n===0?0:Kn[mi[e]+mi[n]]};(function(t){const e=Di;t.mul=function(r,i){const o=new Uint8Array(r.length+i.length-1);for(let s=0;s<r.length;s++)for(let c=0;c<i.length;c++)o[s+c]^=e.mul(r[s],i[c]);return o},t.mod=function(r,i){let o=new Uint8Array(r);for(;o.length-i.length>=0;){const s=o[0];for(let d=0;d<i.length;d++)o[d]^=e.mul(i[d],s);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},t.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let o=0;o<r;o++)i=t.mul(i,new Uint8Array([1,e.exp(o)]));return i}})(Xd);const Zd=Xd;function ga(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}ga.prototype.initialize=function(e){this.degree=e,this.genPoly=Zd.generateECPolynomial(this.degree)};ga.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(e.length+this.degree);n.set(e);const r=Zd.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r};var Ug=ga,el={},Bt={},ma={};ma.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var gt={};const tl="[0-9]+",Dg="[A-Z $%*+\\-./:]+";let rr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";rr=rr.replace(/u/g,"\\u");const xg="(?:(?![A-Z0-9 $%*+\\-./:]|"+rr+`)(?:.|[\r
  903. ]))+`;gt.KANJI=new RegExp(rr,"g");gt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");gt.BYTE=new RegExp(xg,"g");gt.NUMERIC=new RegExp(tl,"g");gt.ALPHANUMERIC=new RegExp(Dg,"g");const Bg=new RegExp("^"+rr+"$"),Vg=new RegExp("^"+tl+"$"),Fg=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");gt.testKanji=function(e){return Bg.test(e)};gt.testNumeric=function(e){return Vg.test(e)};gt.testAlphanumeric=function(e){return Fg.test(e)};(function(t){const e=ma,n=gt;t.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(o,s){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!e.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?o.ccBits[0]:s<27?o.ccBits[1]:o.ccBits[2]},t.getBestModeForData=function(o){return n.testNumeric(o)?t.NUMERIC:n.testAlphanumeric(o)?t.ALPHANUMERIC:n.testKanji(o)?t.KANJI:t.BYTE},t.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},t.isValid=function(o){return o&&o.bit&&o.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+i)}}t.from=function(o,s){if(t.isValid(o))return o;try{return r(o)}catch{return s}}})(Bt);(function(t){const e=nt,n=Ui,r=ki,i=Bt,o=ma,s=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,c=e.getBCHDigit(s);function d(u,f,p){for(let m=1;m<=40;m++)if(f<=t.getCapacity(m,p,u))return m}function l(u,f){return i.getCharCountIndicator(u,f)+4}function h(u,f){let p=0;return u.forEach(function(m){p+=l(m.mode,f)+m.getBitsLength()}),p}function a(u,f){for(let p=1;p<=40;p++)if(h(u,p)<=t.getCapacity(p,f,i.MIXED))return p}t.from=function(f,p){return o.isValid(f)?parseInt(f,10):p},t.getCapacity=function(f,p,m){if(!o.isValid(f))throw new Error("Invalid QR Code version");typeof m=="undefined"&&(m=i.BYTE);const _=e.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,p),y=(_-v)*8;if(m===i.MIXED)return y;const C=y-l(m,f);switch(m){case i.NUMERIC:return Math.floor(C/10*3);case i.ALPHANUMERIC:return Math.floor(C/11*2);case i.KANJI:return Math.floor(C/13);case i.BYTE:default:return Math.floor(C/8)}},t.getBestVersionForData=function(f,p){let m;const _=r.from(p,r.M);if(Array.isArray(f)){if(f.length>1)return a(f,_);if(f.length===0)return 1;m=f[0]}else m=f;return d(m.mode,m.getLength(),_)},t.getEncodedBits=function(f){if(!o.isValid(f)||f<7)throw new Error("Invalid QR Code version");let p=f<<12;for(;e.getBCHDigit(p)-c>=0;)p^=s<<e.getBCHDigit(p)-c;return f<<12|p}})(el);var nl={};const ns=nt,rl=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,Hg=1<<14|1<<12|1<<10|1<<4|1<<1,Gc=ns.getBCHDigit(rl);nl.getEncodedBits=function(e,n){const r=e.bit<<3|n;let i=r<<10;for(;ns.getBCHDigit(i)-Gc>=0;)i^=rl<<ns.getBCHDigit(i)-Gc;return(r<<10|i)^Hg};var il={};const jg=Bt;function pn(t){this.mode=jg.NUMERIC,this.data=t.toString()}pn.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};pn.prototype.getLength=function(){return this.data.length};pn.prototype.getBitsLength=function(){return pn.getBitsLength(this.data.length)};pn.prototype.write=function(e){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),e.put(i,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),i=parseInt(r,10),e.put(i,o*3+1))};var $g=pn;const Kg=Bt,ao=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function gn(t){this.mode=Kg.ALPHANUMERIC,this.data=t}gn.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};gn.prototype.getLength=function(){return this.data.length};gn.prototype.getBitsLength=function(){return gn.getBitsLength(this.data.length)};gn.prototype.write=function(e){let n;for(n=0;n+2<=this.data.length;n+=2){let r=ao.indexOf(this.data[n])*45;r+=ao.indexOf(this.data[n+1]),e.put(r,11)}this.data.length%2&&e.put(ao.indexOf(this.data[n]),6)};var qg=gn,Gg=function(e){for(var n=[],r=e.length,i=0;i<r;i++){var o=e.charCodeAt(i);if(o>=55296&&o<=56319&&r>i+1){var s=e.charCodeAt(i+1);s>=56320&&s<=57343&&(o=(o-55296)*1024+s-56320+65536,i+=1)}if(o<128){n.push(o);continue}if(o<2048){n.push(o>>6|192),n.push(o&63|128);continue}if(o<55296||o>=57344&&o<65536){n.push(o>>12|224),n.push(o>>6&63|128),n.push(o&63|128);continue}if(o>=65536&&o<=1114111){n.push(o>>18|240),n.push(o>>12&63|128),n.push(o>>6&63|128),n.push(o&63|128);continue}n.push(239,191,189)}return new Uint8Array(n).buffer};const Yg=Gg,Jg=Bt;function mn(t){this.mode=Jg.BYTE,this.data=new Uint8Array(Yg(t))}mn.getBitsLength=function(e){return e*8};mn.prototype.getLength=function(){return this.data.length};mn.prototype.getBitsLength=function(){return mn.getBitsLength(this.data.length)};mn.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var Wg=mn;const zg=Bt,Qg=nt;function _n(t){this.mode=zg.KANJI,this.data=t}_n.getBitsLength=function(e){return e*13};_n.prototype.getLength=function(){return this.data.length};_n.prototype.getBitsLength=function(){return _n.getBitsLength(this.data.length)};_n.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=Qg.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
  904. Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),t.put(n,13)}};var Xg=_n,ol={exports:{}};(function(t){var e={single_source_shortest_paths:function(n,r,i){var o={},s={};s[r]=0;var c=e.PriorityQueue.make();c.push(r,0);for(var d,l,h,a,u,f,p,m,_;!c.empty();){d=c.pop(),l=d.value,a=d.cost,u=n[l]||{};for(h in u)u.hasOwnProperty(h)&&(f=u[h],p=a+f,m=s[h],_=typeof s[h]=="undefined",(_||m>p)&&(s[h]=p,c.push(h,p),o[h]=l))}if(typeof i!="undefined"&&typeof s[i]=="undefined"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],o=r;o;)i.push(o),o=n[o];return i.reverse(),i},find_path:function(n,r,i){var o=e.single_source_shortest_paths(n,r,i);return e.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var r=e.PriorityQueue,i={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(ol);(function(t){const e=Bt,n=$g,r=qg,i=Wg,o=Xg,s=gt,c=nt,d=ol.exports;function l(v){return unescape(encodeURIComponent(v)).length}function h(v,y,C){const I=[];let P;for(;(P=v.exec(C))!==null;)I.push({data:P[0],index:P.index,mode:y,length:P[0].length});return I}function a(v){const y=h(s.NUMERIC,e.NUMERIC,v),C=h(s.ALPHANUMERIC,e.ALPHANUMERIC,v);let I,P;return c.isKanjiModeEnabled()?(I=h(s.BYTE,e.BYTE,v),P=h(s.KANJI,e.KANJI,v)):(I=h(s.BYTE_KANJI,e.BYTE,v),P=[]),y.concat(C,I,P).sort(function(R,M){return R.index-M.index}).map(function(R){return{data:R.data,mode:R.mode,length:R.length}})}function u(v,y){switch(y){case e.NUMERIC:return n.getBitsLength(v);case e.ALPHANUMERIC:return r.getBitsLength(v);case e.KANJI:return o.getBitsLength(v);case e.BYTE:return i.getBitsLength(v)}}function f(v){return v.reduce(function(y,C){const I=y.length-1>=0?y[y.length-1]:null;return I&&I.mode===C.mode?(y[y.length-1].data+=C.data,y):(y.push(C),y)},[])}function p(v){const y=[];for(let C=0;C<v.length;C++){const I=v[C];switch(I.mode){case e.NUMERIC:y.push([I,{data:I.data,mode:e.ALPHANUMERIC,length:I.length},{data:I.data,mode:e.BYTE,length:I.length}]);break;case e.ALPHANUMERIC:y.push([I,{data:I.data,mode:e.BYTE,length:I.length}]);break;case e.KANJI:y.push([I,{data:I.data,mode:e.BYTE,length:l(I.data)}]);break;case e.BYTE:y.push([{data:I.data,mode:e.BYTE,length:l(I.data)}])}}return y}function m(v,y){const C={},I={start:{}};let P=["start"];for(let b=0;b<v.length;b++){const R=v[b],M=[];for(let F=0;F<R.length;F++){const q=R[F],E=""+b+F;M.push(E),C[E]={node:q,lastCount:0},I[E]={};for(let T=0;T<P.length;T++){const A=P[T];C[A]&&C[A].node.mode===q.mode?(I[A][E]=u(C[A].lastCount+q.length,q.mode)-u(C[A].lastCount,q.mode),C[A].lastCount+=q.length):(C[A]&&(C[A].lastCount=q.length),I[A][E]=u(q.length,q.mode)+4+e.getCharCountIndicator(q.mode,y))}}P=M}for(let b=0;b<P.length;b++)I[P[b]].end=0;return{map:I,table:C}}function _(v,y){let C;const I=e.getBestModeForData(v);if(C=e.from(y,I),C!==e.BYTE&&C.bit<I.bit)throw new Error('"'+v+'" cannot be encoded with mode '+e.toString(C)+`.
  905. Suggested mode is: `+e.toString(I));switch(C===e.KANJI&&!c.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new n(v);case e.ALPHANUMERIC:return new r(v);case e.KANJI:return new o(v);case e.BYTE:return new i(v)}}t.fromArray=function(y){return y.reduce(function(C,I){return typeof I=="string"?C.push(_(I,null)):I.data&&C.push(_(I.data,I.mode)),C},[])},t.fromString=function(y,C){const I=a(y,c.isKanjiModeEnabled()),P=p(I),b=m(P,C),R=d.find_path(b.map,"start","end"),M=[];for(let F=1;F<R.length-1;F++)M.push(b.table[R[F]].node);return t.fromArray(f(M))},t.rawSplit=function(y){return t.fromArray(a(y,c.isKanjiModeEnabled()))}})(il);const xi=nt,co=ki,Zg=Pg,em=Lg,tm=Wd,nm=zd,rs=Qd,is=Ui,rm=Ug,_i=el,im=nl,om=Bt,uo=il;function sm(t,e){const n=t.size,r=nm.getPositions(e);for(let i=0;i<r.length;i++){const o=r[i][0],s=r[i][1];for(let c=-1;c<=7;c++)if(!(o+c<=-1||n<=o+c))for(let d=-1;d<=7;d++)s+d<=-1||n<=s+d||(c>=0&&c<=6&&(d===0||d===6)||d>=0&&d<=6&&(c===0||c===6)||c>=2&&c<=4&&d>=2&&d<=4?t.set(o+c,s+d,!0,!0):t.set(o+c,s+d,!1,!0))}}function am(t){const e=t.size;for(let n=8;n<e-8;n++){const r=n%2===0;t.set(n,6,r,!0),t.set(6,n,r,!0)}}function cm(t,e){const n=tm.getPositions(e);for(let r=0;r<n.length;r++){const i=n[r][0],o=n[r][1];for(let s=-2;s<=2;s++)for(let c=-2;c<=2;c++)s===-2||s===2||c===-2||c===2||s===0&&c===0?t.set(i+s,o+c,!0,!0):t.set(i+s,o+c,!1,!0)}}function um(t,e){const n=t.size,r=_i.getEncodedBits(e);let i,o,s;for(let c=0;c<18;c++)i=Math.floor(c/3),o=c%3+n-8-3,s=(r>>c&1)===1,t.set(i,o,s,!0),t.set(o,i,s,!0)}function lo(t,e,n){const r=t.size,i=im.getEncodedBits(e,n);let o,s;for(o=0;o<15;o++)s=(i>>o&1)===1,o<6?t.set(o,8,s,!0):o<8?t.set(o+1,8,s,!0):t.set(r-15+o,8,s,!0),o<8?t.set(8,r-o-1,s,!0):o<9?t.set(8,15-o-1+1,s,!0):t.set(8,15-o-1,s,!0);t.set(r-8,8,1,!0)}function dm(t,e){const n=t.size;let r=-1,i=n-1,o=7,s=0;for(let c=n-1;c>0;c-=2)for(c===6&&c--;;){for(let d=0;d<2;d++)if(!t.isReserved(i,c-d)){let l=!1;s<e.length&&(l=(e[s]>>>o&1)===1),t.set(i,c-d,l),o--,o===-1&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function lm(t,e,n){const r=new Zg;n.forEach(function(d){r.put(d.mode.bit,4),r.put(d.getLength(),om.getCharCountIndicator(d.mode,t)),d.write(r)});const i=xi.getSymbolTotalCodewords(t),o=is.getTotalCodewordsCount(t,e),s=(i-o)*8;for(r.getLengthInBits()+4<=s&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const c=(s-r.getLengthInBits())/8;for(let d=0;d<c;d++)r.put(d%2?17:236,8);return hm(r,t,e)}function hm(t,e,n){const r=xi.getSymbolTotalCodewords(e),i=is.getTotalCodewordsCount(e,n),o=r-i,s=is.getBlocksCount(e,n),c=r%s,d=s-c,l=Math.floor(r/s),h=Math.floor(o/s),a=h+1,u=l-h,f=new rm(u);let p=0;const m=new Array(s),_=new Array(s);let v=0;const y=new Uint8Array(t.buffer);for(let R=0;R<s;R++){const M=R<d?h:a;m[R]=y.slice(p,p+M),_[R]=f.encode(m[R]),p+=M,v=Math.max(v,M)}const C=new Uint8Array(r);let I=0,P,b;for(P=0;P<v;P++)for(b=0;b<s;b++)P<m[b].length&&(C[I++]=m[b][P]);for(P=0;P<u;P++)for(b=0;b<s;b++)C[I++]=_[b][P];return C}function fm(t,e,n,r){let i;if(Array.isArray(t))i=uo.fromArray(t);else if(typeof t=="string"){let l=e;if(!l){const h=uo.rawSplit(t);l=_i.getBestVersionForData(h,n)}i=uo.fromString(t,l||40)}else throw new Error("Invalid data");const o=_i.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=o;else if(e<o)throw new Error(`
  906. The chosen QR Code version cannot contain this amount of data.
  907. Minimum version required to store current data is: `+o+`.
  908. `);const s=lm(e,n,i),c=xi.getSymbolSize(e),d=new em(c);return sm(d,e),am(d),cm(d,e),lo(d,n,0),e>=7&&um(d,e),dm(d,s),isNaN(r)&&(r=rs.getBestMask(d,lo.bind(null,d,n))),rs.applyMask(r,d),lo(d,n,r),{modules:d,version:e,errorCorrectionLevel:n,maskPattern:r,segments:i}}Yd.create=function(e,n){if(typeof e=="undefined"||e==="")throw new Error("No input text");let r=co.M,i,o;return typeof n!="undefined"&&(r=co.from(n.errorCorrectionLevel,co.M),i=_i.from(n.version),o=rs.from(n.maskPattern),n.toSJISFunc&&xi.setToSJISFunction(n.toSJISFunc)),fm(e,i,r,o)};var sl={},_a={};(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin=="undefined"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,s=r.scale||4;return{width:o,scale:o?4:s,margin:i,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},t.getImageWidth=function(r,i){const o=t.getScale(r,i);return Math.floor((r+i.margin*2)*o)},t.qrToImageData=function(r,i,o){const s=i.modules.size,c=i.modules.data,d=t.getScale(s,o),l=Math.floor((s+o.margin*2)*d),h=o.margin*d,a=[o.color.light,o.color.dark];for(let u=0;u<l;u++)for(let f=0;f<l;f++){let p=(u*l+f)*4,m=o.color.light;if(u>=h&&f>=h&&u<l-h&&f<l-h){const _=Math.floor((u-h)/d),v=Math.floor((f-h)/d);m=a[c[_*s+v]?1:0]}r[p++]=m.r,r[p++]=m.g,r[p++]=m.b,r[p]=m.a}}})(_a);(function(t){const e=_a;function n(i,o,s){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=s,o.width=s,o.style.height=s+"px",o.style.width=s+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(o,s,c){let d=c,l=s;typeof d=="undefined"&&(!s||!s.getContext)&&(d=s,s=void 0),s||(l=r()),d=e.getOptions(d);const h=e.getImageWidth(o.modules.size,d),a=l.getContext("2d"),u=a.createImageData(h,h);return e.qrToImageData(u.data,o,d),n(a,l,h),a.putImageData(u,0,0),l},t.renderToDataURL=function(o,s,c){let d=c;typeof d=="undefined"&&(!s||!s.getContext)&&(d=s,s=void 0),d||(d={});const l=t.render(o,s,d),h=d.type||"image/png",a=d.rendererOpts||{};return l.toDataURL(h,a.quality)}})(sl);var al={};const pm=_a;function Yc(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function ho(t,e,n){let r=t+e;return typeof n!="undefined"&&(r+=" "+n),r}function gm(t,e,n){let r="",i=0,o=!1,s=0;for(let c=0;c<t.length;c++){const d=Math.floor(c%e),l=Math.floor(c/e);!d&&!o&&(o=!0),t[c]?(s++,c>0&&d>0&&t[c-1]||(r+=o?ho("M",d+n,.5+l+n):ho("m",i,0),i=0,o=!1),d+1<e&&t[c+1]||(r+=ho("h",s),s=0)):i++}return r}al.render=function(e,n,r){const i=pm.getOptions(n),o=e.modules.size,s=e.modules.data,c=o+i.margin*2,d=i.color.light.a?"<path "+Yc(i.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",l="<path "+Yc(i.color.dark,"stroke")+' d="'+gm(s,o,i.margin)+'"/>',h='viewBox="0 0 '+c+" "+c+'"',a=i.width?'width="'+i.width+'" height="'+i.width+'" ':"",u='<svg xmlns="http://www.w3.org/2000/svg" '+a+h+' shape-rendering="crispEdges">'+d+l+`</svg>
  909. `;return typeof r=="function"&&r(null,u),u};const mm=Ag,os=Yd,cl=sl,_m=al;function va(t,e,n,r,i){const o=[].slice.call(arguments,1),s=o.length,c=typeof o[s-1]=="function";if(!c&&!mm())throw new Error("Callback required as last argument");if(c){if(s<2)throw new Error("Too few arguments provided");s===2?(i=n,n=e,e=r=void 0):s===3&&(e.getContext&&typeof i=="undefined"?(i=r,r=void 0):(i=r,r=n,n=e,e=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(n=e,e=r=void 0):s===2&&!e.getContext&&(r=n,n=e,e=void 0),new Promise(function(d,l){try{const h=os.create(n,r);d(t(h,e,r))}catch(h){l(h)}})}try{const d=os.create(n,r);i(null,t(d,e,r))}catch(d){i(d)}}hr.create=os.create;hr.toCanvas=va.bind(null,cl.render);hr.toDataURL=va.bind(null,cl.renderToDataURL);hr.toString=va.bind(null,function(t,e,n){return _m.render(t,n)});var vm=hr,ym="./assets/icon1.ef6bbd86.png",Cm="./assets/icon2.e7f0fa2e.png",Em="./assets/icon3.0d23bbac.png",fo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAmCAYAAACyAQkgAAAAAXNSR0IArs4c6QAAA7pJREFUWEftmF1oHFUUx8+5k2yhIVILUosSv0AtrYKiSO2DaB9E1EIfUpBiQaxLqybM3hkCfqBBq+JmzrkLiwuNWCOUolBEFFREqgiiVkQUg5FiaWkrwopIoiZNsvfILK2kde98RZ/ceVr2nvOf3/zvOXfuXAQACMOwr9Vq3RT/LnDNGmMOJ+UNDw8PeJ53RQFtUEodI6LjGCdXKpXrEPHbIkIAcJSZr0rK1Vo/AQB7iuiLyNPGmGe6oEvd6zqas5a6NRob1m2mTmXTbaZuM+V0oNtMLsP+F80EAE8x87P/xqZkkpk3/Ie7pxFjzFgbdHBw0BsYGLjQdTMReQgAnneMf87MG5NAy+Xyyv7+/pUJ+u8BgGs/vIuZ97ZB064wDLdaa990xH3AzHemaSSNB0Hwtojc2ylGRLYbYw5kBd1mrX2jkxAiHiSiweWAaq0/BIDNDtAtxph3MoEGQbBTRF52wDAzB8sBDYLgGxG53mHEbUT0SSbQlOXlQWbetxxQrfXPALCmk0ZPT88l1Wr1p6ygBwDgPsfU3JL2cZf0ECMjI5cuLi6ecMT8wswXxWNZQb8HgGs7iFml1AVRFP1R1NEgCLaLyH7HtB8ionbtpoL6vn+lUupHh9BnRHRrUcg4T2sd1/5Oh0aNmSuZQLXWIQCMOYQeZ+YXioLG5wnW2pMAsMphxFYieisVdHR0tGd6evoIAFzuqM8NxpjJoqBa690A0HDk/7awsHBxvV4/nQoahuED1lpXR08x87qikENDQytKpVK8LF3j0HiFmf8uCWeN+r6/Vin1HQCsdgi1X21FQbXWdQB41JWvlNocRdGhs+MdQSuVympEfB8AbnYINUXkMmPMbBHQIAjuF5HXXM2MiB8T0e1Ltf8B6vv+RqVU3InrXRBnP2HzQpbL5d6+vr4xRBx2QYpIy/O8G6MoOucsrA16pvt2AMA9InIXIjpLQkR+AIAb8riptb5aRB5GxG0AsDbpARGxQUSPnB+Tdz+6gIibiOjLPG5m3eEj4hczMzN3jI+P/7lc0CeZ+bk8kGcW9dRjR0Q8Mj8/v6lerzc7rqnxnxnORy0iPkZE1byQGUGnrLV312q1oy79LFM/i4g7iOhgEcgMoPvn5uZ2NxqN3xNrN8HR04j4aqvVerFWqx0rCpkAOqmU2hNF0etZtM93NH5dfQ0AH4nIS8aYU1lE0mKWNNOvIvKp53l7oyh6Nz6sS8s9Z8H3fX9Vb2/v+maz+dXExMRc1uSscb7vryuVSlCtVqfywC3V/ws13CRFlZXvUwAAAABJRU5ErkJggg==",po="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAoCAYAAACIC2hQAAAAAXNSR0IArs4c6QAAA/dJREFUWEftmF9oHUUUxr9zbwgqmJAo/kET6luMKCoo1KAIIv6hoYpESkEIiD7UJu7MXGLUQhatKNe7Z3OTglp9UEECKlJC7YMKFdqCgloQBAsSUR9UEB9iija5mSNzzY2x7uxuNlgQ7jzunPPNb7+ZM7OzhP9JoyKcQRBcXi6Xh0RkO4BPmPmdIjpJOWEYlpaWlgattU77lkajMTUzM/P9pkCDIBgqlUoTAHYAKLmBiOiJKIqqWwUdGxvr6uzs3CsijwO4pKVHRFdHUfR1LtDx8fH+crn8BhHdfjbQVkFHRkbKfX19TwFQAHoS9POBaq13ENHrInJRkmtbAZ2YmLiw0Wi8DeBu34zkclQptQfAASLyOl8UVCl1BYAjRHRd2rLJBDXG3Cci7wIoZwhteo266e7v7z+2VoypyzsVVCl1MxF9DOD8rCIRkbE4jg9kxW3s11o/DWB/jpwz1trB6enphX9N6drbfiEiaVPyB4BYRN6K4/irHAOuh2itb3BbGoDOlLyTRPQMEX1Yq9VON3eXs4O11o+5dZki8g2AB5n55GYAW7HGmHkRGfblishUd3f3/jAM7caYf4BOTk72LC8vO5Bej9BPq6ur19fr9Z8LQg6IiJuB5h6csBU9GUXRC4l9Gx8qpfYS0awHworIPXEcf1AE0uUYY14RkUc9+UeZ+Q4AkgmqtT7hji2P0Bwz7y4KGYbhBYuLi794CtQS0TXuBPLpr099EATbiGghZc/czsyuCAq1SqWy01p7yJM8z8w704TXQY0xRkRqnuDPmPmmQoRrSVrr1wA87NEYZubDeUHnRGSXJ3gfMz+3BVDSWv8I4NIEjdNdXV0Xh2HotjxvW3dUa+2qcTApUkRui+P4WFHQSqVylbV2waP9URzHd2ZpN0FHR0fP6+3t/Q1AR0LC7ysrKz2zs7NnssR8/UqpYSKa9/RPM7P7ckptTdAgCG4slUqfJ0US0akoigayhNL6jTGTIvK8J2YPM7+Upd8E1VrfC+B9T/BxZr41SyitXyn1JhE95DFidxRFc1n6TVCl1C4i8gUfYub7s4QyHD3iDgtPTGbFu7yWo48AOOgROszM3rM5zwtorY8DGPI4+kAURe9l6bQcNUTk20O/I6KXfUKNRuNovV7/NG0grfWXAK71GUFE7kRMbNbag3Ec/9pydApAmPVWHkcyP5y11t8C2FZQ/+87kzHmWRHZV0TI3UprtdqLGcX0AxFdWUS/o6NjoFqtnmo62gZds1Ap1XY093Jqr9E1q9rFlLRm2sWUu5Lcvbe94f9lV7uY/tNi0loHANw/pyKtysyvZnzmuYvhZUXErbV3Jf7NKyJ2LnJy/cM/FyBZY/wJeqwNR6eju2QAAAAASUVORK5CYII=",go="./assets/logo.6e1120ae.png",mo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAB2CAYAAAA+/DbEAAAAAXNSR0IArs4c6QAADDRJREFUeF7tnXtwHXUVx7/f3aRNSqE8hkcRkbZJ7oYGqpSRljJIEWxxHHGqWKkjomJ5yKPFNvemKF4HaO6mD0BsoQgoIFaLDI4ODx9UdAaUl1htm5ublOIUseUhBZomTe7d4+zeNDQ1j737unvvZv9qJ+d3zvl9P/vbu4/f7/yI0SNUCjBU2QSUjLQnDwPeBmvveC+gkLbDRBNI69JPoLIiy5rmZ2wrFZBhNIGkGxeBSg9jqbUB6Ww7TFSBPACii7GWy20rFZBhNIG0JbZApJOa/vGAdLYdJnJApGPJMcgqOwFmka0+kg3JPbbVCsAwekDS8S8C+IWlrWAu6/XfBqCz7RDRA5JJ3AlDrrAUIpYzpt9gW60ADKMHpDXeDqImry3/Qi11ZgA62w4RKSCydUkDFPWfB6hjIGt8iA0rdtpWzGfDaAFpbfweyOQATRVcwTp9nc8623YfLSBtiU0QOXWgOnySWuoC24r5bBgZILIlPhUqNg+iZw9U5QTWNr/ps9a23EcHSCZxOwy5dlBVFGUp65pX2lLMZ6NIAJEdi6vRWfk6wMOH0DNDTY/5rLUt99EAkmn6GgzjvuEV4SeppTbaUs1Ho7IHIpJU0Na9BRBtWB0Fv2e9/ikftbbluvyBZOILYOAhW2qoMpO1LX+1ZeuTUVkDsUZHpmszBPW29COeYEz/tC1bn4zKG0g6fiWAwj5CCeewPvU7n/Qe0W3ZApFNS47BWDUN4IgRVRhokIG691TW3rGvwHaemJcvkNb4/SAucajSd6npNzts66pZWQKRTOM8CH8JgdP+7YNwFutTL7lS10Fjpwk7CBVME2lNnATK3xxcqgYmSHZA6Zwe9FShsgIi25NV6Ol+GiJneINfHkasZT4J8cbfyF7KBojIRSoyk83L1OdG7nYBFsRqxvRvF9DClWn5AGlLrIPIQldqDNmYjdRSK/zxfdCVMoggfsboGxl3QvBNH+MIyBsYSzX7GMNyXdIjRJ5dXI0jx6wHcKHfQvWpdQfWVy9iMmn4Fa9kgciWRA1U+TmA6X6JM7hfeRyqeqlfH7RKEoikG78MKmshcliwMPqjmd9WvuLH6/qSAiIdiRrkcCtEPlMkEAeGNUD8GGpuGWtWvuFVPiUBRFqbjoJiLIFgMYCxXnXeIz/vgrwJh1bdyeOTe936DDUQ66lbkesh+DqAQ9x21tf2xFsA1wC9P2Rs1VtOY4UOiLW6SbrnQWQBRM4FqDrtXJHadQN4DArXo7LqMU5Kmv+3fRQdSP45YtJ0gOdCMBvA2QCqbPcg3IbvgXgKIk9D+Edo+uaRXsMEAkTarxmL3jHHAepEqMpEgJMgRgOABgimghgXbl09yo7YDeEWiLEFxBYAr4LYiV7uxNTqnWSyJyAg5iLLzo/BUE+DyGkAzgJwkkfdLDU35keBbRA+Z0FRjHYYbEd3roPTVnYGAmQwxaxb2KycD2IOROYCDNvdk3egia0QPA5iIwzledY3vz2U86IBOTAh2RafgJwyDzljAYhzASjeqVEkT8TLEHkAovyK9alX7WYRCiAD4LQ21UExroXgqwDG2+1ISOw6QZgT8u5lTN/kJKfQAdnfCdm+6HD0VC+GGNeHH4zsBrAGzN3m5hnE7HtogfSDeWXZsegxbrS+dRAVTs46/9pIDlTWoQrf4UdS73gRJ/RA+sFsXXoaFN4L8KNedNwDHy9A5eWsTb3sga9+FyUDxMxYJFmBTFej+Q+AlV4KYdsXYUBkFfbsvoGn391ru51Nw5IC0j9a0ktnAcoGAMfb7KdXZu+igl9iTepJrxwe7KckgVijxfxt2ZfbAFqvWoI4XscY9QJOXv4PP4OVLBALivlKJjfOnNn+eT9Fsp6sDZ5XyPOE03xKGogFZcNFKqZN9m+SA7ELSuUs1t68zanIhbQreSD9vyv+TAN6H6p6DmuXmzMhAznKB4i1UqrLrGHyBQ+Vm09NN28eAjvKBoh1+dqcHIOKLrOYzDkeKLiOmp6viRLgUVZALChm+aWc+hIEJzjWkdyKMVXTC/3a5zjeAQ3LDkj+7qtpJnLG0wDGFC6SCFSZzdoVfyq8rfsWZQnEgpJOxAFJFS6RPEitxelCn8LDHdSifIGY3+rbJj9X4MzGPehVa3jK8l2ulXXooGyBWKOkLT4NghcA2H3v1UJNjzvU0pNmZQ2k79J1OzBEjZOBEu4BqycxlnQ8p8oLIuUPpL3paBjSYWMe8Epq+lIvRHXjo+yB9F26boTg+8MIZQC5Gmort7sR04u20QDSfs1hyI3bAWCo2fJPUCtuBYf9MCMBJP9bEr8NwHWDn8VyIbWWX3txhrv1ER0g7UunwFDaIBg4V9icJP169UTOTmbdiulF+8gAyY+SxicAzh0gHHkPYyk/1ycWxClaQLbGL4GC+wcopHIOa4tXbOZgWtECkm48FOQuCKotIQTvQKs+hgzH5cpMKVJA+m6BH4FgXt+Z+Qg13cvvJwVdngYzjiCQxEKI5AsnK7ySdam7XKvooYPoAckkJsOQ/Pdxw6jjySvaPdTTtavIAem7bG0DpJKxlhNdK+ixA1+BWPVydwA889Yuj/N25U7yxc3GUdMvcuXIh8b+AtnaOANjK7OccsuLPuTu2KWYm4JBGUstpTt24lNDf4GYRSjJXsZS9/iUvyO3komfDYMVflRicJTQAY38BdKWeACQbsZ0n8omOeu+tfRa6SKn6O868+BfK5+BxHdAsDcsddX9k9E7z74BkbYmDWK0wiyP1y0nclrLa96lXb6efATS2AThcks68lth3FUzjFj9A5KOm3dW+2tZPUVNPy+MAoQtJ1+ASHrZqUDug1WoRA657BSevOpfYRMgbPn4A6QtsQYiVw3sLG+ilroxbAKELR/PgeS3NlVf+b9ySsSbmJCbxONWdoZNhDDl4z2QdKIFkMGn0yhsZF0w5VbDJHIhuXgKpK8wpblx41Dlld5BRU7zsiReIZ0tBVtvgaTj5urUOcN3nA9SSxVtMnPYoXgGRNJxc4qNOdVm5IO4mDHdLPE6ehykgCdApC1+FgR/KKBA5XuoUGexZvlgGz1GGpJrINKxrAHZ3J8dbA/xb4ypmMXJt4w+mxxwCroCIq1LZoLqbwAc5fC0fg05zOVU3Sx3N3q4mXUi6aZvAMYPALf1EmU3RLmM9alHRok4mAYk2+InImtWl+6fSuNeR/ONMPETdOUSnOZdlWj3iQXvwfYlS15dNhHduUUQXO1bFdF81c7VEK4dri5h8DIFF3FYINYkhb2VcyBYAPCzBdxFue1BJ0hzQtt6ZKs2siHZ49ZhqbS3gOTrUPUeC+SOh0gMChtgYAYgMwKEMJRmeyF4FuRzEKvWbQY0/oPYuDfCNAXUK+B5IOZIeL9yGlROh1hVEMzKoEd6FcS1H8L89v0swOch8jIUyYBdrxRr80fX/RnGwaCXrHyFnUnnALwYgvlFKkL5FhT+DDk8is7/PuNH9TY/hXXqe8Qfdas6aG/1ZRBru4hjnQay346boSKFfVUPR+m3Y78+IwLZbyibk+NR2b0EIuY6bj+K5e8EEUed/uBIBevtwy09S9tA+sFYs0nkPkBmetZdhQ+jsnshJ91m1r+N9FEwEOsm4MWFlRh/RAuI61zsN2u6MrcNWsqYvjrSFA7ovCMgH4yWxEJA1v7fQko76poTHwSXUtN/asc8KjaugFijpS0xH2I8VPBOOMTVjOlroiK03X66BmJBaU0shCJ32b58ET8K23xfu4L5becJkDyU+GrQ2kVtpKMVh/RM54fDtWZkpKSD+rt3QMzXL21dZhW2M4dJXqAqs1nbXJRqbUGJ6iaOZ0CsUbKtqQ5Z4+/9y44PzozYwJhuPvmPHkMo4CmQ/I98fKjKOwZU5RTWNm8dpTG0At4D2bTkEIxVOwAcNyCs4FHW6/vXh48yCWqE9I0Sc3fOVQNiKjyfdSlzZsroMYwCno8QC8iL8QkYb66/xaF9sbcjpk+J8jsqu2ehL0D6RsndEPRV2ZEV1Foa7SYVZTv/gHQsm41sbqMlrpKbwbqVZsnW0WMEBfwDki+Ob+4zTsSqjyaTxiiNkRXwDYh12Uo3bgCohK3izsiyFM/CXyBtjVeBrGSdfnvxulhakf0Fkmk6A0a2gtqKZ0pLluJl6y8QczbLrgnk6cm9xetiaUX2FUhpSRGObP8HG0q4pBQy2GYAAAAASUVORK5CYII=",Rm=Fe({name:"LiveBroadcastSharePreview",props:["form","url"],data(){return{detail:{roomTitle:"",liveStartTime:"",liveRemark:""}}},mounted(){let t=document.getElementById("canvas"),e=this.url;vm.toCanvas(t,e,{width:80},function(n){n&&console.error(n),console.log("QRCode success!")})},methods:{copyText(){},shareImage(){}},render(){return S("div",{id:"preview"},[this.form.preTemplate==="1"?S("div",{class:ie.first},[S("h2",null,[this.form.roomTitle]),S("p",{class:ie.teacher},[Z(" \u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),S("img",{src:ym,class:ie.icon,alt:""},null),S("div",{class:ie.preCore},[S("img",{src:mo,class:ie.start,alt:""},null),S("p",{class:ie.title},[Z("\u5F00\u64AD\u65F6\u95F4")]),S("p",{class:ie.time},[this.form.liveStartTime]),S("p",{class:ie.title},[Z("\u76F4\u64AD\u5185\u5BB9")]),S("div",{class:ie.content},[S("img",{class:ie.pre,src:po,alt:""},null),S("img",{class:ie.end,src:fo,alt:""},null),this.form.liveRemark])]),S("div",{class:ie.bottom},[S("img",{class:ie.logo,src:go,alt:""},null),S("div",{class:ie.code},[S("div",null,[S("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null,this.form.preTemplate==="2"?S("div",{class:ie.second},[S("h2",null,[this.form.roomTitle]),S("p",{class:ie.teacher},[Z("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),S("img",{src:Cm,class:ie.icon,alt:""},null),S("div",{class:ie.preCore},[S("img",{src:mo,class:ie.start,alt:""},null),S("p",{class:ie.title},[Z("\u5F00\u64AD\u65F6\u95F4")]),S("p",{class:ie.time},[this.form.liveStartTime]),S("p",{class:ie.title},[Z("\u76F4\u64AD\u5185\u5BB9")]),S("div",{class:ie.content},[S("img",{class:ie.pre,src:po,alt:""},null),S("img",{class:ie.end,src:fo,alt:""},null),this.form.liveRemark])]),S("div",{class:ie.bottom},[S("img",{class:ie.logo,src:go,alt:""},null),S("div",{class:ie.code},[S("div",null,[S("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null,this.form.preTemplate==="3"?S("div",{class:ie.third},[S("h2",null,[this.form.roomTitle]),S("p",{class:ie.teacher},[Z("\u4E3B\u8BB2\u4EBA\uFF1A"),this.form.speakerName]),S("img",{src:Em,class:ie.icon,alt:""},null),S("div",{class:ie.preCore},[S("img",{src:mo,class:ie.start,alt:""},null),S("p",{class:ie.title},[Z("\u5F00\u64AD\u65F6\u95F4")]),S("p",{class:ie.time},[this.form.liveStartTime]),S("p",{class:ie.title},[Z("\u76F4\u64AD\u5185\u5BB9")]),S("div",{class:ie.content},[S("img",{class:ie.pre,src:po,alt:""},null),S("img",{class:ie.end,src:fo,alt:""},null),this.form.liveRemark])]),S("div",{class:ie.bottom},[S("img",{class:ie.logo,src:go,alt:""},null),S("div",{class:ie.code},[S("div",null,[S("canvas",{id:"canvas",height:"80",width:"80",style:"width: 80px; margin:0"},null)])])])]):null])}});const Jc=as(null);var Tm=Fe({name:"LiveBroadcastShare",props:{onClose:{type:Function,default:()=>{}}},data(){return{form:{shareType:"1"},detail:{roomTitle:"",liveStartTime:"",liveRemark:"",roomUid:""},url:""}},async mounted(){let t=JSON.parse(sessionStorage.getItem("details")||"");if(t)this.detail=rt({},t);else{const e=sessionStorage.getItem("roomUid"),n=await Dt.get("/api-web/imLiveBroadcastRoom/queryRoom",{params:{roomUid:e}});sessionStorage.setItem("details",n.data),this.detail=rt({},n.data)}this.url=cp()+`/#/liveClassTransfer?roomUid=${this.detail.roomUid}`},methods:{copyText(){let t=`\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01
  910. ${this.detail.roomTitle||""}
  911. \u76F4\u64AD\u65F6\u95F4:${this.detail.liveStartTime||""}
  912. \u76F4\u64AD\u5185\u5BB9:${this.detail.liveRemark||""}
  913. \u76F4\u64AD\u5730\u5740:${this.url}
  914. `;t&&(ig(t),Ur.success("\u590D\u5236\u6210\u529F"),this.onClose())},shareImage(){var t=document.getElementById("preview");t&&Qp(t).then(e=>{var n=new Image;n.src=e;let r=document.createElement("a"),i=this.detail.roomTitle||"\u5206\u4EAB\u56FE\u7247\u6587\u4EF6.png";r.href=e,r.setAttribute("download",i),document.body.appendChild(r),r.click(),this.onClose()}).catch(function(e){console.error("oops, something went wrong!",e)})},async shareChat(){var e;let t=((e=Jc.value)==null?void 0:e.checkList)||[];if(!(t.length>0)){Ur.error("\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u7FA4\u804A");return}try{let n={groupIds:t.join(","),roomUid:this.detail.roomUid};const r=await Dt.get("/api-web/imLiveBroadcastRoom/shareGroup",{params:rt({},n)});Ur.success("\u5206\u4EAB\u6210\u529F"),this.onClose()}catch(n){console.log(n)}},changeRafdio(t){this.form.shareType=t}},render(){return S("div",null,[S(ru,{model:this.form,ref:"form",class:_t.form},{default:()=>[S(Eo,{label:"\u5206\u4EAB\u65B9\u5F0F"},{default:()=>[S(Fi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("1")},label:"1"},{default:()=>[Z("\u94FE\u63A5\u5206\u4EAB")]}),S(Fi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("2")},label:"2"},{default:()=>[Z("\u4E8C\u7EF4\u7801\u5206\u4EAB")]}),S(Fi,{modelValue:this.form.shareType,onChange:()=>{this.changeRafdio("3")},label:"3"},{default:()=>[Z("\u7FA4\u804A\u5206\u4EAB")]})]})]}),S("div",null,[this.form.shareType==="1"?S("div",{class:"linkWrap"},[S("div",{class:_t.shareWrap},[S("h2",null,[Z("\u4E50\u56E2\u8001\u5E08\u9080\u8BF7\u60A8\u53C2\u4E0E\u76F4\u64AD\u8BFE\uFF01")]),S("h4",null,[this.detail.roomTitle]),S("p",null,[Z("\u76F4\u64AD\u65F6\u95F4:"),this.detail.liveStartTime]),S("p",null,[Z("\u76F4\u64AD\u5185\u5BB9:"),this.detail.liveRemark]),S("p",null,[Z("\u76F4\u64AD\u5730\u5740:"),this.url])]),S("div",{class:_t.shareBtn,onClick:this.copyText},[Z("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null]),this.form.shareType==="2"?S("div",{class:_t.codeWrap},[S("div",{class:_t.shareWrap},[S(Rm,{form:this.detail,url:this.url},null)]),S("div",{class:_t.shareBtn,onClick:this.shareImage},[Z("\u590D\u5236\u5206\u4EAB\u5185\u5BB9")])]):null,this.form.shareType=="3"?S("div",{class:_t.shareWrap},[S("div",{class:_t.groupWrap},[S(pg,{ref:Jc},null)]),S("div",{class:_t.shareBtn,onClick:this.shareChat},[Z("\u53D1\u9001\u5206\u4EAB\u4FE1\u606F")])]):null])}});function Wc(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!ou(t)}var Sm=Fe({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&&se.deviceStatus.camera!=="denied"&&se.cameras.length},isMicrophoneDisabled(){return this.barStatus.microphone&&se.deviceStatus.microphone!=="denied"&&se.microphones.length},isVolumeDisabled(){return this.barStatus.volume&&this.volume===0}},methods:{startShare(){console.log("\u8C03\u7528"),this.shareVisiable=!0},volumeChange(t){this.volume=t,qf(t)}},render(){return S("div",{class:Te["action-bar"],id:"action-bar"},[S("div",{style:{display:"flex"}},[S("div",{class:Te["bar-btn"]},[S("div",{class:Te.btnInner},[S(Pe("SvgIcon"),{onClick:()=>{this.barStatus.camera=!this.barStatus.camera,Xf("camera")},name:this.isCameraDisabled?"bar-camera-disabled":"bar-camera",style:{width:"22px",cursor:"pointer"}},null),S(Dr,{placement:"top",disabled:se.cameras.length===0,onCommand:Ud},{default:()=>[S("div",{class:Te["bar-btn"],style:{height:"32px"}},[S(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let t;return S(yo,null,Wc(t=se.cameras.map(e=>S(Co,{disabled:e===se.selectedCamera,command:e},{default:()=>[e.label]})))?t:{default:()=>[t]})}})]),S("span",{class:Te["bar-btn-text"]},[Z("\u6444\u50CF\u5934")])]),S("div",{class:Te["bar-btn"]},[S("div",{class:Te.btnInner},[S(Pe("SvgIcon"),{onClick:()=>{this.barStatus.volume=!this.barStatus.volume,this.barStatus.volume?(sessionStorage.setItem("volume",this.volume.toString()),this.volumeChange(0)):sessionStorage.getItem("volume")&&this.volumeChange(Number(sessionStorage.getItem("volume")))},name:this.isVolumeDisabled?"bar-volume-disabled":"bar-volume",style:{width:"22px",cursor:"pointer"}},null),S(Dr,{placement:"top-start","popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1}},{default:()=>[S("div",{class:Te["bar-btn"],style:{height:"32px"}},[S(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>S("div",{class:Te.volumeSlider},[S(Pe("SvgIcon"),{class:Te.volumeIcon,name:"message-voice",color:"#fff"},null),S(_l,{modelValue:this.volume,onInput:this.volumeChange,size:"small"},null)])})]),S("span",{class:Te["bar-btn-text"]},[Z("\u97F3\u91CF\u8C03\u8282")])]),S("div",{class:Te["bar-btn"],onClick:Gf},[S("div",{class:Te.btnInner},[S(Pe("SvgIcon"),{name:"bar-screen-share",style:{width:"22px",cursor:"pointer"}},null)]),S("span",{class:Te["bar-btn-text"]},[Z("\u5C4F\u5E55\u5171\u4EAB")])]),S("div",{class:Te["bar-btn"]},[S("div",{class:Te.btnInner},[S(Pe("SvgIcon"),{onClick:()=>{const t=se.videoStatus==="liveing";this.barStatus.microphone=!this.barStatus.microphone,this.barStatus.microphone?hi("microphone",t):Vd("microphone",t)},name:this.isMicrophoneDisabled?"bar-mike-disabled":"bar-mike",style:{width:"22px",cursor:"pointer"}},null),S(Dr,{placement:"top-start",disabled:se.microphones.length===0,"popper-options":{boundariesElement:"#action-bar",gpuAcceleration:!1},onCommand:Dd},{default:()=>[S("div",{class:Te["bar-btn"],style:{height:"32px"}},[S(Pe("SvgIcon"),{name:"bar-arrow-down",style:{width:"18px"}},null)])],dropdown:()=>{let t;return S(yo,null,Wc(t=se.microphones.map(e=>S(Co,{disabled:e===se.selectedMicrophone,command:e},{default:()=>[e.label]})))?t:{default:()=>[t]})}})]),S("span",{class:Te["bar-btn-text"]},[Z("\u9EA6\u514B\u98CE")])])]),S("div",{style:{display:"flex"},onClick:this.startShare},[S("div",{class:Te["bar-btn"]},[S("div",{class:Te.btnInner},[S(Pe("SvgIcon"),{name:"bar-share",style:{width:"22px",cursor:"pointer"}},null)]),S("span",{class:Te["bar-btn-text"]},[Z("\u5206\u4EAB")])])]),S(vl,{width:"510px","destroy-on-close":!0,"append-to-body":!0,modelValue:this.shareVisiable,title:"\u5206\u4EAB","before-close":()=>{this.shareVisiable=!1}},{default:()=>[S(Tm,{onClose:()=>this.shareVisiable=!1},null)]})])}});const Im="_container_19awp_1",bm="_title_19awp_21",Nm="_tips_19awp_25";var vt={container:Im,title:bm,tips:Nm},wm=Fe({name:"VideoStatus",render(){return S("div",{class:vt.container},[se.deviceStatus.camera==="denied"?S("div",{class:vt.denied},[S(Pe("SvgIcon"),{name:"camera-status",class:vt.icon},null),S("p",{class:vt.title},[Z("\u6444\u50CF\u5934\u88AB\u7981\u7528")]),S("p",{class:vt.tips},[Z("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null,se.deviceStatus.camera==="init"?S("div",{class:vt.init},[S(Pe("SvgIcon"),{name:"camera-status",class:vt.icon},null),S("p",{class:vt.title},[Z("\u8BF7\u5B8C\u6210\u6444\u50CF\u5934\u6388\u6743")]),S("p",{class:vt.tips},[Z("\u8BF7\u6388\u6743\u5141\u8BB8\u8BBF\u95EE\u6444\u50CF\u5934")])]):null])}});const Om=async(t,e)=>{if(!navigator)throw new Error("\u6D4F\u89C8\u5668\u7248\u672C\u8FC7\u4F4E");return t?(e||[]).map(n=>t.removeTrack(n)):[]},Am="_main_1b4ip_1",Mm="_video_1b4ip_12";var zc={main:Am,video:Mm};const Qc=as(null);let Xc,_o;var Pm=Fe({name:"LiveBroadcast",async mounted(){this.initializeRoom(),Bd(),Ue.on(ke["RC:Chatroom:Like"],this.onLikeMessage)},beforeUnmount(){Ue.off(ke["RC:Chatroom:Like"],this.onLikeMessage)},methods:{onLikeMessage(t){se.likeCount+=t.counts},async initializeRoom(){var t,e;if(!ge.user)throw Error("\u8BF7\u5148\u767B\u5F55");try{await Kf((t=ge.user)==null?void 0:t.imToken),se.videoRef=Qc.value,await Yf(),await Jf(),Ud(se.cameras[0]),Dd(se.microphones[0]),_o=await hn("camera"),se.videoRef&&_o.play(se.videoRef),await fn([_o],"camera"),Xc=await hn("microphone"),se.videoRef&&Xc.play(se.videoRef),console.log(se.deviceStatus),se.videoStatus="stream";const n=await Wf((e=ge.user)==null?void 0:e.roomUid,ft.VIDEO,{onMessageReceive(r,i){console.log(r,i)},onKickOff(r){console.log(r)},async onTrackPublish(r){var o;const i=await((o=n==null?void 0:n.room)==null?void 0:o.subscribe(r));console.log(i),(i==null?void 0:i.code)&&i.code!==w.SUCCESS&&console.log("\u8D44\u6E90\u8BA2\u9605\u5931\u8D25 ->",i.code)},onTrackUnpublish(r){console.log(r),Ue.emit(ke["RM:RTC:TrackUnpublish"],r)},onSwitchRole(r,i){Ue.emit(ke["RM:RTC:SwitchRole"],{userId:r,role:i})},onTrackReady(r){r.isAudioTrack()&&r.play()},onUserJoin(r){console.log("onUserJoin",r)},onUserLeave(r){Ue.emit(ke["RM:RTC:UserLeave"],r),console.log("onUserLeave",r)}});n.room&&n.code===w.SUCCESS&&(se.joinedRoom=n.room)}catch(n){se.videoStatus="error",console.log(n)}},closeLive(){Om(se.mediaStreams,se.mediaStreamTrack),se.videoStatus="stopped"}},render(){return S("div",{class:zc.main},[S(np,null,null),S("div",{class:zc.video},[S("video",{ref:Qc},null),S(wm,null,null)]),S(Sm,null,null)])}});const Lm="_container_jmhhf_1",km="_dataCount_jmhhf_6",Um="_num_jmhhf_17",Dm="_text_jmhhf_22",xm="_dataIcon_jmhhf_26",Bm="_tabContainer_jmhhf_31",Vm="_tabIcon_jmhhf_31",Fm="_tabContent_jmhhf_58",Hm="_tabList_jmhhf_64";var Ye={container:Lm,dataCount:km,num:Um,text:Dm,dataIcon:xm,tabContainer:Bm,tabIcon:Vm,tabContent:Fm,tabList:Hm};const jm="_message_4zab7_1",$m="_buttonGroup_4zab7_1";var Zc={message:jm,buttonGroup:$m},Km=Fe({name:"message",data(){return{options:"ALL"}},methods:{async SeatsCtrl(){await Yt(rt({seatBan:se.allowSeatsCtrl},li()),"SeatsCtrl"),se.allowSeatsCtrl=!se.allowSeatsCtrl},async ChatBan(){await Yt(rt({chatBan:se.allowChatCtrl},li()),"ChatBan"),se.allowChatCtrl=!se.allowChatCtrl}},render(){return S("div",{class:Zc.message},[S("div",{class:Zc.buttonGroup},[S(lt,{type:se.allowChatCtrl?"info":"primary",onClick:this.ChatBan},{default:()=>[se.allowChatCtrl?"\u5168\u4F53\u7981\u8A00":"\u5173\u95ED\u5168\u4F53\u7981\u8A00"]}),S(lt,{type:se.allowSeatsCtrl?"info":"primary",onClick:this.SeatsCtrl},{default:()=>[se.allowSeatsCtrl?"\u7981\u6B62\u8FDE\u9EA6":"\u5173\u95ED\u7981\u6B62\u8FDE\u9EA6"]})])])}});const qm="_sendMessage_p2cnx_1",Gm="_form_p2cnx_10";var eu={sendMessage:qm,form:Gm};const Tn=nu({messageList:[],joinList:{},lookList:{}});var Se=Tn;const ss=t=>{Tn.messageList.push(t)},qn=(t,e)=>{Tn.joinList[t]=e},kr=t=>{delete Tn.joinList[t]},Bn=(t,e)=>{Tn.lookList[t]=e},Ym=t=>{delete Tn.lookList[t]};var Jm=Fe({data(){return{message:""}},methods:{onKeyDown(t){t.keyCode===13&&this.message.trim()!==""&&this.sendMessage()},async sendMessage(){try{await Yt(this.message);const t=li();ss({id:t.id,name:t.name,content:this.message,isSelf:!0,sendTime:$r(new Date).format("HH:mm:ss")}),this.message="",this.scrollToBottom()}catch{}},scrollToBottom(){this.$nextTick(()=>{var t,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((t=document.querySelector("#messageList"))==null?void 0:t.scrollHeight)||0)})}},render(){return S("div",{class:eu.sendMessage},[S("div",{class:eu.form},[S(iu,{modelValue:this.message,onKeydown:this.onKeyDown,onInput:t=>this.message=t,placeholder:"\u8BF7\u8F93\u5165\u6D88\u606F"},null),S(lt,{disabled:!this.message,onClick:this.sendMessage,round:!0,type:"primary"},{default:()=>[Z("\u53D1\u9001")]})])])}});const Wm="_itemContent_1wo39_1",zm="_itemInfo_1wo39_11",Qm="_itemName_1wo39_14",Xm="_userName_1wo39_20",Zm="_rightTime_1wo39_30",e_="_itemText_1wo39_38",t_="_active_1wo39_42",n_="_joinText_1wo39_45",r_="_join_1wo39_45",i_="_btn_1wo39_54",o_="_downBtn_1wo39_66",s_="_loadingStyle_1wo39_71";var le={itemContent:Wm,itemInfo:zm,itemName:Qm,userName:Xm,"name-style":"_name-style_1wo39_26",rightTime:Zm,itemText:e_,active:t_,joinText:n_,join:r_,btn:i_,downBtn:o_,loadingStyle:s_};const a_="_icon_1svqd_9";var vo={"empty-container":"_empty-container_1svqd_1",icon:a_},ya=Fe({props:{text:{type:String,default:"\u6682\u65E0\u6570\u636E"},icon:{type:String,default:"noData-no-message"}},render(){return S("div",{class:vo["empty-container"]},[S(Pe("SvgIcon"),{name:this.icon,class:[vo.icon]},null),S("p",{class:vo["empty-text"]},[this.text])])}}),c_=Fe({data(){return{joinList:{},loadingJoin:!1}},computed:{count(){let t=0;for(const e in Se.joinList)if(Object.prototype.hasOwnProperty.call(Se.joinList,e)&&(Se.joinList[e].type===3&&(t+=1),t>3))break;return t}},mounted(){Ue.on(ke["RC:Chatroom:SeatApply"],this.onSeatApply),Ue.on(ke["RC:Chatroom:SeatResponse"],this.onSeatApply),Ue.on(ke["RM:RTC:UserLeave"],this.onSeatApply),Ue.on(ke["RM:RTC:SwitchRole"],this.onSwitchRole),Ue.on(ke["RC:Chatroom:Leave"],this.onLeave)},methods:{onLeave(t){kr(t.userId),Ym(t.userId)},onSeatApply(t){if(console.log(t,"onSeatApply joinModel"),Array.isArray(t)){for(const r of t)console.log("onSeatApply",r),kr(r);return}const n=t.$EventMessage.messageType==="RC:Chatroom:SeatResponse"?4:3;if(t.type===3){const r={name:t.audienceName,id:t.audienceId,userRoomType:n,type:t.type};qn(t.audienceId,r),Bn(t.audienceId,r)}if(t.type===4&&(console.log(t,"\u53D6\u6D88\u8FDE\u9EA6"),Se.joinList[t.audienceId]&&kr(t.audienceId),Se.lookList[t.audienceId])){let r=Se.lookList[t.audienceId];r.userRoomType=1,Bn(t.audienceId,r)}},agree(t){var n,r;if(this.count>3)return;const e=In(rt({},t),{audienceName:t.name,audienceId:t.id,teacherId:(n=ge.user)==null?void 0:n.id,teacherName:(r=ge.user)==null?void 0:r.speakerName,userRoomType:4,type:1});qn(t.id,e),Bn(t.id,e),Yt(e,"SeatResponse")},refuse(t){var n,r;const e=In(rt({},t),{audienceName:t.name,audienceId:t.id,teacherId:(n=ge.user)==null?void 0:n.id,teacherName:(r=ge.user)==null?void 0:r.speakerName,userRoomType:4,type:5});qn(t.id,e),Yt(e,"SeatApply")},onSwitchRole(t){if(console.log(t,"onSwitchRole"),Se.joinList[t.userId]&&t.role===2&&kr(t.userId),Se.lookList[t.userId]&&t.role===2){let e=Se.lookList[t.userId];e.userRoomType=1,Bn(t.userId,e)}}},render(){const t=Object.values(Se.joinList);return S("div",{style:{minHeight:"100%",position:"relative"}},[t.length>0?t.map(e=>S("div",{class:le.itemContent},[S("div",{class:le.itemInfo},[S("div",{class:le.itemName},[S("p",{class:le.userName},[S("span",{class:le["name-style"]},[e.name]),e.userRoomType!==4?S("span",{style:{paddingLeft:"10px"}},[Z("\u7533\u8BF7\u8FDE\u9EA6")]):S("span",{style:{paddingLeft:"10px",color:"var(--live-text-color)"}},[Z("\u6B63\u5728\u8FDE\u9EA6")])]),e.userRoomType!==4?S("div",{class:le.joinText},[S("div",{class:le.join},null),S(lt,{size:"small",type:"primary",disabled:this.count>3,class:le.btn,onClick:()=>this.agree(e)},{default:()=>[Z("\u4E0A\u9EA6")]})]):S("div",{class:le.joinText},[S("div",{class:le.join},null),S(lt,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.refuse(e)},{default:()=>[Z("\u4E0B\u9EA6")]})])])])])):this.loadingJoin?S("div",{class:le.loadingStyle},[S("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[S("div",{class:"el-loading-spinner"},[S("svg",{class:"circular",viewBox:"25 25 50 50"},[S("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):S(ya,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u53D1\u8D77\u8FDE\u9EA6\uFF01",icon:"noData-no-join"},null)])}}),u_=Fe({data(){return{loadingLook:!1}},computed:{count(){let t=0;for(const e in Se.joinList)if(Object.prototype.hasOwnProperty.call(Se.joinList,e)&&(Se.joinList[e].type===3&&(t+=1),t>3))break;return t}},mounted(){this.loadingLook=!0,Ue.on(ke["RC:Chatroom:Welcome"],this.onWelcome),setTimeout(()=>{this.loadingLook=!1})},methods:{async _init(){try{const t=sessionStorage.getItem("roomUid"),e=await Dt.get("/api-web/imLiveBroadcastRoom/queryRoomUserInfo",{params:{roomUid:t}});console.log("_init",e)}catch{}},onSeatResponse(t){var e,n;if(console.log(t,"onSeatResponse"),t.type==3){Se.lookList.forEach(i=>{i.id==t.audienceId&&(i.type=1)});let r=Se.joinList[t.audienceId];console.log(Se.joinList),r?Se.joinList[t.audienceId].type=1:qn(t.audienceId,{id:t.audienceId,name:t.audienceName,audienceId:t.audienceId,audienceName:t.audienceName,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(n=ge.user)==null?void 0:n.speakerName,type:1})}},onWelcome(t){if(console.log(t),t&&t.user){const e=$r(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");let n={name:t.user.name,id:t.user.id,sendTime:e,userRoomType:1,type:3};!!Se.lookList[n.id]||Bn(n.id,n),this.loadingLook=!1}},async onUpLook(t){var e,n;try{const r={audienceName:t.name,audienceId:t.id,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(n=ge.user)==null?void 0:n.speakerName,userRoomType:2,type:1};await Yt(r,"SeatApply")}catch{}},async onDownLook(t){var e,n;try{const r=In(rt({},t),{audienceName:t.name,audienceId:t.id,teacherId:(e=ge.user)==null?void 0:e.id,teacherName:(n=ge.user)==null?void 0:n.speakerName,type:5});qn(t.id,r),Yt(r,"SeatApply")}catch{}}},render(){const t=Object.values(Se.lookList);return S("div",null,[t.length>0?t.map(e=>S("div",{class:le.itemContent},[S("div",{class:le.itemInfo},[S("div",{class:le.itemName},[S("p",{class:le.userName},[S("span",{class:le["name-style"]},[e.name])]),e.userRoomType!==4?S(lt,{size:"small",type:"primary",disabled:this.count>3,class:le.btn,onClick:()=>this.onUpLook(e)},{default:()=>[Z("\u4E0A\u9EA6")]}):S(lt,{size:"small",plain:!0,class:[le.btn,le.downBtn],onClick:()=>this.onDownLook(e)},{default:()=>[Z("\u4E0B\u9EA6")]})])])])):this.loadingLook?S("div",{class:le.loadingStyle},[S("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[S("div",{class:"el-loading-spinner"},[S("svg",{class:"circular",viewBox:"25 25 50 50"},[S("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):S(ya,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u89C2\u770B\uFF01",icon:"noData-no-user"},null)])}}),d_=Fe({data(){return{messageList:[],loadingMessage:!1}},mounted(){this.loadingMessage=!0,Ue.on(ke["RC:TxtMsg"],this.onMessage),Ue.on(ke["RC:Chatroom:Like"],this.onLike),setTimeout(()=>{this.loadingMessage=!1},2e3),this.scrollToBottom()},beforeUnmount(){Ue.off(ke["RC:TxtMsg"],this.onMessage),Ue.off(ke["RC:Chatroom:Like"],this.onLike)},methods:{onLike(t){var e;if(t&&t.user){const n=$r(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");console.log(t,"like");let r={name:(e=t.user)==null?void 0:e.name,id:t.user.id,isSelf:!1,content:"\u7ED9\u60A8\u70B9\u4E86"+t.counts+"\u4E2A\u8D5E",sendTime:n};ss(r),this.loadingMessage=!1}this.scrollToBottom()},onMessage(t){var e;if(t&&t.user){const n=$r(t.$EventMessage.sentTime||new Date).format("HH:mm:ss");let r={name:(e=t.user)==null?void 0:e.name,id:t.user.id,isSelf:!1,content:t.content,sendTime:n};t.user.id===ge.user.speakerId&&(r.isSelf=!0),ss(r),this.loadingMessage=!1}this.scrollToBottom()},scrollToBottom(){this.$nextTick(()=>{var t,e;(e=document.querySelector("#tabList"))==null||e.scrollTo(0,((t=document.querySelector("#messageList"))==null?void 0:t.scrollHeight)||0)})}},render(){return S("div",{style:{minHeight:"100%",position:"relative"},id:"messageList"},[Se.messageList.length>0?Se.messageList.map(t=>S("div",{class:le.itemContent},[S("div",{class:le.itemInfo},[S("div",{class:le.itemName},[S("div",{class:le.userName},[t.isSelf?S(yl,{effect:"dark",color:"#01A79E"},{default:()=>[Z("\u4E3B\u8BB2\u4EBA")]}):null,S("span",{class:le["name-style"]},[t.name,Z("\uFF1A")]),S("span",{class:[le.itemText,t.isSelf?le.active:null]},[t.content])]),S("p",{class:le.rightTime},[t.sendTime])])])])):this.loadingMessage?S("div",{class:le.loadingStyle},[S("div",{class:"el-loading-mask",style:"background-color: rgba(0, 0, 0, 0.8);"},[S("div",{class:"el-loading-spinner"},[S("svg",{class:"circular",viewBox:"25 25 50 50"},[S("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none"},null)])])])]):S(ya,{style:{paddingTop:"120px"},text:"\u6682\u65E0\u5B66\u5458\u4E92\u52A8\uFF01",icon:"noData-no-message"},null)])}}),l_=Fe({name:"LiveMessage",data(){return{modelIndex:"message"}},mounted(){var t;se.likeCount=((t=ge.user)==null?void 0:t.likeNum)||0},methods:{tabChange(t){this.modelIndex=t.props.name}},render(){var t;return S("div",{class:Ye.container},[S("div",{class:Ye.dataCount},[S("div",null,[S("p",{class:Ye.num},[(t=ge.user)==null?void 0:t.likeNum]),S("p",{class:Ye.text},[S(Pe("SvgIcon"),{name:"message-look",color:"#fff",class:Ye.dataIcon},null),Z("\u5F53\u524D\u89C2\u770B")])]),S("div",null,[S("p",{class:Ye.num},[se.likeCount]),S("p",{class:Ye.text},[S(Pe("SvgIcon"),{name:"message-giveUp",color:"#fff",class:Ye.dataIcon},null),Z("\u7D2F\u8BA1\u70B9\u8D5E")])])]),S(Cl,{modelValue:this.modelIndex,"onTab-click":this.tabChange,class:Ye.tabContainer},{default:()=>[S(Hi,{name:"message"},{label:()=>S("span",{style:{display:"flex",alignItems:"center"}},[S(Pe("SvgIcon"),{name:"message-message",color:this.modelIndex==="message"?"#00FFF0":"#fff",class:Ye.tabIcon},null),Z("\u804A\u5929")])}),S(Hi,{name:"join"},{label:()=>S("span",{style:{display:"flex",alignItems:"center"}},[S(Pe("SvgIcon"),{name:"message-evenEtc",color:this.modelIndex==="join"?"#00FFF0":"#fff",class:Ye.tabIcon},null),Z("\u8FDE\u9EA6")])}),S(Hi,{name:"look"},{label:()=>S("span",{style:{display:"flex",alignItems:"center"}},[S(Pe("SvgIcon"),{name:"message-look",color:this.modelIndex==="look"?"#00FFF0":"#fff",class:Ye.tabIcon},null),Z("\u89C2\u770B")])})]}),S("div",{class:Ye.tabContent},[S(Km,null,null),S("div",{class:Ye.tabList,id:"tabList"},[ji(S(d_,null,null),[[$i,this.modelIndex==="message"]]),ji(S(c_,null,null),[[$i,this.modelIndex==="join"]]),ji(S(u_,null,null),[[$i,this.modelIndex==="look"]])]),S(Jm,null,null)])])}});const h_="_container_13n1h_1",f_="_home_13n1h_4";var tu={container:h_,home:f_},v_=Fe({render(){return S("div",{class:tu.home},[S(Zf,null,null),S("div",{class:tu.container},[S(Pm,null,null),S(l_,null,null)])])}});export{v_ as default};