!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rtc_sdk={})}(this,function(j){function L(e,t){this.v=e,this.k=t}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[s++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t,n){(t=Q(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function Y(){return(Y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=G(e)););return e}(e,t);if(r)return(r=Object.getOwnPropertyDescriptor(r,t)).get?r.get.call(arguments.length<3?e:n):r.value}).apply(null,arguments)}function G(e){return(G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&K(e,t)}function V(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(V=function(){return!!e})()}function J(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function z(t){for(var e=1;e>>0,r=0;rAe(e)?(s=e+1,t-Ae(e)):(s=e,t);return{year:s,dayOfYear:n}}function Ke(e,t,n){var r,i,s=Je(e.year(),t,n),s=Math.floor((e.dayOfYear()-s-1)/7)+1;return s<1?r=s+M(i=e.year()-1,t,n):s>M(e.year(),t,n)?(r=s-M(e.year(),t,n),i=e.year()+1):(i=e.year(),r=s),{week:r,year:i}}function M(e,t,n){var r=Je(e,t,n),t=Je(e+1,t,n);return(Ae(e)-r+t)/7}r("w",["ww",2],"wo","week"),r("W",["WW",2],"Wo","isoWeek"),y("w",n,d),y("ww",n,t),y("W",n,d),y("WW",n,t),Ce(["w","ww","W","WW"],function(e,t,n,r){t[r.substr(0,1)]=k(e)});function $e(e,t){return e.slice(t,7).concat(e.slice(0,t))}r("d",0,"do","day"),r("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),r("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),r("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),r("e",0,0,"weekday"),r("E",0,0,"isoWeekday"),y("d",n),y("e",n),y("E",n),y("dd",function(e,t){return t.weekdaysMinRegex(e)}),y("ddd",function(e,t){return t.weekdaysShortRegex(e)}),y("dddd",function(e,t){return t.weekdaysRegex(e)}),Ce(["dd","ddd","dddd"],function(e,t,n,r){r=n._locale.weekdaysParse(e,r,n._strict);null!=r?t.d=r:m(n).invalidWeekday=e}),Ce(["d","e","E"],function(e,t,n,r){t[r]=k(e)});var Xe="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Ze="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Qe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),et=i,tt=i,nt=i;function rt(){function e(e,t){return t.length-e.length}for(var t,n,r,i=[],s=[],a=[],o=[],c=0;c<7;c++)r=u([2e3,1]).day(c),t=b(this.weekdaysMin(r,"")),n=b(this.weekdaysShort(r,"")),r=b(this.weekdays(r,"")),i.push(t),s.push(n),a.push(r),o.push(t),o.push(n),o.push(r);i.sort(e),s.sort(e),a.sort(e),o.sort(e),this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+i.join("|")+")","i")}function it(){return this.hours()%12||12}function st(e,t){r(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function at(e,t){return t._meridiemParse}r("H",["HH",2],0,"hour"),r("h",["hh",2],0,it),r("k",["kk",2],0,function(){return this.hours()||24}),r("hmm",0,0,function(){return""+it.apply(this)+s(this.minutes(),2)}),r("hmmss",0,0,function(){return""+it.apply(this)+s(this.minutes(),2)+s(this.seconds(),2)}),r("Hmm",0,0,function(){return""+this.hours()+s(this.minutes(),2)}),r("Hmmss",0,0,function(){return""+this.hours()+s(this.minutes(),2)+s(this.seconds(),2)}),st("a",!0),st("A",!1),y("a",at),y("A",at),y("H",n,f),y("h",n,d),y("k",n,d),y("HH",n,t),y("hh",n,t),y("kk",n,t),y("hmm",pe),y("hmmss",ve),y("Hmm",pe),y("Hmmss",ve),_(["H","HH"],E),_(["k","kk"],function(e,t,n){e=k(e);t[E]=24===e?0:e}),_(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),_(["h","hh"],function(e,t,n){t[E]=k(e),m(n).bigHour=!0}),_("hmm",function(e,t,n){var r=e.length-2;t[E]=k(e.substr(0,r)),t[C]=k(e.substr(r)),m(n).bigHour=!0}),_("hmmss",function(e,t,n){var r=e.length-4,i=e.length-2;t[E]=k(e.substr(0,r)),t[C]=k(e.substr(r,2)),t[T]=k(e.substr(i)),m(n).bigHour=!0}),_("Hmm",function(e,t,n){var r=e.length-2;t[E]=k(e.substr(0,r)),t[C]=k(e.substr(r))}),_("Hmmss",function(e,t,n){var r=e.length-4,i=e.length-2;t[E]=k(e.substr(0,r)),t[C]=k(e.substr(r,2)),t[T]=k(e.substr(i))});i=De("Hours",!0);var ot,ct={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Le,monthsShort:Ue,week:{dow:0,doy:6},weekdays:Xe,weekdaysMin:Qe,weekdaysShort:Ze,meridiemParse:/[ap]\.?m?\.?/i},P={},ut={};function ht(e){return e&&e.toLowerCase().replace("_","-")}function lt(e){for(var t,n,r,i,s=0;s=t&&function(e,t){for(var n=Math.min(e.length,t.length),r=0;r=t-1)break;t--}s++}return ot}function dt(t){var e;if(void 0===P[t]&&Mn&&Mn.exports&&(e=t)&&e.match("^[^/\\\\]*$"))try{ot._abbr;throw new Error('Could not dynamically require "'+("./locale/"+t)+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}catch(e){P[t]=null}return P[t]}function ft(e,t){return!e||(e=o(t)?A(e):pt(e,t))&&(ot=e),ot._abbr}function pt(e,t){if(null===t)return delete P[e],null;var n,r=ct;if(t.abbr=e,null!=P[e])X("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),r=P[e]._config;else if(null!=t.parentLocale)if(null!=P[t.parentLocale])r=P[t.parentLocale]._config;else{if(null==(n=dt(t.parentLocale)))return ut[t.parentLocale]||(ut[t.parentLocale]=[]),ut[t.parentLocale].push({name:e,config:t}),null;r=n._config}return P[e]=new Q(Z(r,t)),ut[e]&&ut[e].forEach(function(e){pt(e.name,e.config)}),ft(e),P[e]}function A(e){var t;if(!(e=e&&e._locale&&e._locale._abbr?e._locale._abbr:e))return ot;if(!a(e)){if(t=dt(e))return t;e=[e]}return lt(e)}function vt(e){var t=e._a;return t&&-2===m(e).overflow&&(t=t[x]<0||11je(t[w],t[x])?S:t[E]<0||24M(r,a,o)?m(h)._overflowWeeks=!0:null!=c?m(h)._overflowWeekday=!0:(u=ze(r,i,s,a,o),h._a[w]=u.year,h._dayOfYear=u.dayOfYear)),null!=e._dayOfYear&&(l=Tt(e._a[w],n[w]),(e._dayOfYear>Ae(l)||0===e._dayOfYear)&&(m(e)._overflowDayOfYear=!0),c=Ve(l,0,e._dayOfYear),e._a[x]=c.getUTCMonth(),e._a[S]=c.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=d[t]=n[t];for(;t<7;t++)e._a[t]=d[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[E]&&0===e._a[C]&&0===e._a[T]&&0===e._a[Oe]&&(e._nextDay=!0,e._a[E]=0),e._d=(e._useUTC?Ve:Ge).apply(null,d),r=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[E]=24),e._w&&void 0!==e._w.d&&e._w.d!==r&&(m(e).weekdayMismatch=!0)}}function Mt(e){if(e._f!==p.ISO_8601)if(e._f!==p.RFC_2822){e._a=[],m(e).empty=!0;for(var t,n,r,i=""+e._i,s=i.length,a=0,o=(n=ae(e._f,e._locale).match(te)||[]).length,c=0;c(s=M(e,r,i))&&(t=s),function(e,t,n,r,i){e=ze(e,t,n,r,i),t=Ve(e.year,0,e.dayOfYear);return this.year(t.getUTCFullYear()),this.month(t.getUTCMonth()),this.date(t.getUTCDate()),this}.call(this,e,t,n,r,i))}r("N",0,0,"eraAbbr"),r("NN",0,0,"eraAbbr"),r("NNN",0,0,"eraAbbr"),r("NNNN",0,0,"eraName"),r("NNNNN",0,0,"eraNarrow"),r("y",["y",1],"yo","eraYear"),r("y",["yy",2],0,"eraYear"),r("y",["yyy",3],0,"eraYear"),r("y",["yyyy",4],0,"eraYear"),y("N",sn),y("NN",sn),y("NNN",sn),y("NNNN",function(e,t){return t.erasNameRegex(e)}),y("NNNNN",function(e,t){return t.erasNarrowRegex(e)}),_(["N","NN","NNN","NNNN","NNNNN"],function(e,t,n,r){r=n._locale.erasParse(e,r,n._strict);r?m(n).era=r:m(n).invalidEra=e}),y("y",ge),y("yy",ge),y("yyy",ge),y("yyyy",ge),y("yo",function(e,t){return t._eraYearOrdinalRegex||ge}),_(["y","yy","yyy","yyyy"],w),_(["yo"],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[w]=n._locale.eraYearOrdinalParse(e,i):t[w]=parseInt(e,10)}),r(0,["gg",2],0,function(){return this.weekYear()%100}),r(0,["GG",2],0,function(){return this.isoWeekYear()%100}),on("gggg","weekYear"),on("ggggg","weekYear"),on("GGGG","isoWeekYear"),on("GGGGG","isoWeekYear"),y("G",ke),y("g",ke),y("GG",n,t),y("gg",n,t),y("GGGG",ye,de),y("gggg",ye,de),y("GGGGG",be,fe),y("ggggg",be,fe),Ce(["gggg","ggggg","GGGG","GGGGG"],function(e,t,n,r){t[r.substr(0,2)]=k(e)}),Ce(["gg","GG"],function(e,t,n,r){t[r]=p.parseTwoDigitYear(e)}),r("Q",0,"Qo","quarter"),y("Q",he),_("Q",function(e,t){t[x]=3*(k(e)-1)}),r("D",["DD",2],"Do","date"),y("D",n,d),y("DD",n,t),y("Do",function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),_(["D","DD"],S),_("Do",function(e,t){t[S]=k(e.match(n)[0])});ye=De("Date",!0);r("DDD",["DDDD",3],"DDDo","dayOfYear"),y("DDD",me),y("DDDD",le),_(["DDD","DDDD"],function(e,t,n){n._dayOfYear=k(e)}),r("m",["mm",2],0,"minute"),y("m",n,f),y("mm",n,t),_(["m","mm"],C);de=De("Minutes",!1);r("s",["ss",2],0,"second"),y("s",n,f),y("ss",n,t),_(["s","ss"],T);var un,be=De("Seconds",!1);for(r("S",0,0,function(){return~~(this.millisecond()/100)}),r(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),r(0,["SSS",3],0,"millisecond"),r(0,["SSSS",4],0,function(){return 10*this.millisecond()}),r(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),r(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),r(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),r(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),r(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),y("S",me,he),y("SS",me,t),y("SSS",me,le),un="SSSS";un.length<=9;un+="S")y(un,ge);function hn(e,t){t[Oe]=k(1e3*("0."+e))}for(un="S";un.length<=9;un+="S")_(un,hn);fe=De("Milliseconds",!1),r("z",0,0,"zoneAbbr"),r("zz",0,0,"zoneName");d=K.prototype;function ln(e){return e}d.add=Le,d.calendar=function(e,t){1===arguments.length&&(arguments[0]?$t(arguments[0])?(e=arguments[0],t=void 0):function(e){for(var t=L(e)&&!U(e),n=!1,r=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i=0;ie.valueOf():e.valueOf()"}),d.toJSON=function(){return this.isValid()?this.toISOString():null},d.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},d.unix=function(){return Math.floor(this.valueOf()/1e3)},d.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},d.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},d.eraName=function(){for(var e,t=this.localeData().eras(),n=0,r=t.length;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},d.isLocal=function(){return!!this.isValid()&&!this._isUTC},d.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},d.isUtc=Wt,d.isUTC=Wt,d.zoneAbbr=function(){return this._isUTC?"UTC":""},d.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},d.dates=e("dates accessor is deprecated. Use date instead.",ye),d.months=e("months accessor is deprecated. Use month instead",He),d.years=e("years accessor is deprecated. Use year instead",Ne),d.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),d.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){var e,t;return o(this._isDSTShifted)&&(z(t={},this),(t=Pt(t))._a?(e=(t._isUTC?u:N)(t._a),this._isDSTShifted=this.isValid()&&0c.maxLostRate&&(c.maxLostRate=s),c.lastPacketsLost=e.packetsLost,c.lastPacketsReceived=e.packetsReceived,c.decodedCount=e.framesDecoded,a=e.framesPerSecond,0!=c.lastSecondDecodedCount&&void 0===e.framesPerSecond&&(a=c.decodedCount-c.lastSecondDecodedCount),c.lastSecondDecodedCount=c.decodedCount,{framesPerSecond:a,currentRoundTripTime:e.currentRoundTripTime,lostRate:Math.floor(s),secondsBytes:Math.floor(t),secondsKBytes:Math.floor(n),secondsMBytes:Math.floor(r),pliCount:e.pliCount,averageDecodeTime:1e4*e.totalDecodeTime/e.framesDecoded});c.stateCallBack("StreamStates",o,"流状态"),c._emit.emit("NETWORK_STATS",o)}).catch(function(e){})}},{key:"getReceiversStats",value:function(){var d,e=this.pc;if(e)return d=this,new Promise(function(l,t){e.getStats(null).then(function(e){var t=0,n=0,r=0,i=0,s=0,a=0,o=0,c=0,u=0,h=Date.now();d.previousTime,d.previousTime=h,e.forEach(function(e){"inbound-rtp"===e.type&&"video"===e.kind&&(t=e.framesPerSecond,n=e.totalDecodeTime,a+=e.bytesReceived,i+=e.packetsLost,s+=e.packetsReceived,o=e.framesDecoded,c=e.framesReceived,u=e.pliCount,u+=e.firCount,d.previousBytesReceived,d.previousBytesReceived=e.bytesReceived),"inbound-rtp"===e.type&&"audio"===e.kind&&(a+=e.bytesReceived,i+=e.packetsLost,s+=e.packetsReceived),"candidate-pair"===e.type&&void 0===(r=e.currentRoundTripTime)&&(r=0===e.totalRoundTripTime&&0===e.responsesReceived?0:e.totalRoundTripTime/e.responsesReceived)}),null!=r?r*=1e3:r=0,l({framesPerSecond:t,totalDecodeTime:n,currentRoundTripTime:r,packetsLost:i,packetsReceived:s,bytesReceived:a,framesDecoded:o,framesReceived:c,pliCount:u})}).catch(function(e){t(e)})})}},{key:"startMonitoringFirstFrame",value:(we=y(O().mark(function e(){var i,s=this;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pc){e.next=3;break}return e.abrupt("return");case 3:i=setInterval(y(O().mark(function e(){var t,n,r;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,null!=(n=s.pc)&&n.getStats())return e.next=4,s.pc.getStats();e.next=26;break;case 4:t=H(e.sent.values()),e.prev=6,t.s();case 8:if((n=t.n()).done)e.next=18;else{if("inbound-rtp"===(r=n.value).type&&"video"===r.kind&&0"===e)throw new Error("inbox prefixes cannot have wildcards '".concat(t,"'"))}),"".concat(t,".").concat(De.next())}var Ye,Ge="127.0.0.1";function Ve(n){for(var e=arguments,r=0;r<(arguments.length<=1?0:arguments.length-1);r++)!function(){var t=r+1<1||e.length<=r+1?void 0:e[r+1];Object.keys(t).forEach(function(e){n[e]=t[e]})}();return n}function Je(n,e){var r,i,s=1","/","\\"," ","\t","\n","\r"].forEach(function(e){if(-1!==n.indexOf(e)){switch(e){case"\n":e="\\n";break;case"\r":e="\\r";break;case"\t":e="\\t"}throw Error("invalid ".concat(t," name - ").concat(t," name cannot contain '").concat(e,"'"))}}),""}function lt(e,t){t=1e.interval&&e.missed++,e.missed>=e.maxOut)try{!0===e.callback(e.missed)&&e.cancel()}catch(e){}},this.interval)}}]),Et=((a=mt=mt||{}).Limits="limits",a.Interest="interest",a.Workqueue="workqueue",(n=yt=yt||{}).Old="old",n.New="new",(s=bt=bt||{}).File="file",s.Memory="memory",(r=v=v||{}).All="all",r.Last="last",r.New="new",r.StartSequence="by_start_sequence",r.StartTime="by_start_time",r.LastPerSubject="last_per_subject",(i=m=m||{}).None="none",i.All="all",i.Explicit="explicit",i.NotSet="",(o=gt=gt||{}).Instant="instant",o.Original="original",(a=kt=kt||{}).None="none",a.S2="s2",(n=_t=_t||{}).CreateOrUpdate="",n.Update="update",n.Create="create",0,(s=S=S||{}).StreamSourceHdr="Nats-Stream-Source",s.LastConsumerSeqHdr="Nats-Last-Consumer",s.LastStreamSeqHdr="Nats-Last-Stream",s.ConsumerStalledHdr="Nats-Consumer-Stalled",s.MessageSizeHdr="Nats-Msg-Size",s.RollupHdr="Nats-Rollup",s.RollupValueSubject="sub",s.RollupValueAll="all",s.PendingMessagesHdr="Nats-Pending-Messages",s.PendingBytesHdr="Nats-Pending-Bytes",(r=wt=wt||{}).LastValue="",r.AllHistory="history",r.UpdatesOnly="updates",(i=xt=xt||{}).Stream="Nats-Stream",i.Sequence="Nats-Sequence",i.TimeStamp="Nats-Time-Stamp",i.Subject="Nats-Subject","KV_"),Ct=e(function e(t){l(this,e),u(this,"config",void 0),u(this,"ordered",void 0),u(this,"mack",void 0),u(this,"stream",void 0),u(this,"callbackFn",void 0),u(this,"max",void 0),u(this,"qname",void 0),u(this,"isBind",void 0),u(this,"filters",void 0),this.stream="",this.mack=!1,this.ordered=!1,this.config=function(e,t){return Object.assign({name:"",deliver_policy:v.All,ack_policy:m.Explicit,ack_wait:3e10,replay_policy:gt.Instant},1>16&255,i[a++]=t>>8&255,i[a++]=255&t;return 2===n?(t=c[e.charCodeAt(o)]<<2|c[e.charCodeAt(o+1)]>>4,i[a++]=255&t):1===n&&(t=c[e.charCodeAt(o)]<<10|c[e.charCodeAt(o+1)]<<4|c[e.charCodeAt(o+2)]>>2,i[a++]=t>>8&255,i[a++]=255&t),i},fromUint8Array:function(e){for(var t,n,r=e.length,i=r%3,s=r-i,a=new Array(Math.ceil(s/16383)+(i?1:0)),o=0,c=0;c>18&63]+u[r>>12&63]+u[r>>6&63]+u[63&r]);return i.join("")}(e,c,s<(t=c+16383)?s:t);return 1==i?(n=e[s],a[o]=u[n>>2]+u[n<<4&63],h||(a[o]+="==")):2==i&&(n=e[s]<<8|255&e[1+s],a[o]=u[n>>10]+u[n>>4&63]+u[n<<2&63],h||(a[o]+="=")),a.join("")}}}(Rt,It,!0),Ut=o.toUint8Array,Ft=o.fromUint8Array,qt=new TextDecoder,Bt=new TextEncoder;var Wt=e(function e(){l(this,e),u(this,"hashSize",32),u(this,"_buf",void 0),u(this,"_bufIdx",void 0),u(this,"_count",void 0),u(this,"_K",void 0),u(this,"_H",void 0),u(this,"_finalized",void 0),this._buf=new Uint8Array(64),this._K=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),this.init()},[{key:"init",value:function(){return this._H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),this._bufIdx=0,this._count=new Uint32Array(2),this._buf.fill(0),this._finalized=!1,this}},{key:"update",value:function(e,t){if(null===e)throw new TypeError("msg must be a string or Uint8Array.");for(var n=0,r=(e="string"==typeof e?function(e,t){if(t=1>>29,this}},{key:"digest",value:function(e){if(this._finalized)throw new Error("digest has already been called.");this._finalized=!0;var t=this._buf,n=this._bufIdx;for(t[n++]=128;56!==n;)64===n&&(this._transform(),n=0),t[n++]=0;var r=this._count;t[56]=r[1]>>>24&255,t[57]=r[1]>>>16&255,t[58]=r[1]>>>8&255,t[59]=r[1]>>>0&255,t[60]=r[0]>>>24&255,t[61]=r[0]>>>16&255,t[62]=r[0]>>>8&255,t[63]=r[0]>>>0&255,this._transform();for(var i=new Uint8Array(32),s=0;s<8;s++)i[s<<2]=this._H[s]>>>24&255,i[1+(s<<2)]=this._H[s]>>>16&255,i[2+(s<<2)]=this._H[s]>>>8&255,i[3+(s<<2)]=this._H[s]>>>0&255;return this.init(),e?function(e,t){t=1>>7^l>>>18^l>>>3^l<<25^l<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+u[15&h]+u[h+9&15]|0))+c+(s>>>6^s>>>11^s>>>25^s<<26^s<<21^s<<7)+(o^s&(a^o))+this._K[h]|0,c=o,o=a,a=s,s=i+f,i=r,r=n,t=f+((n=t)&r^i&(n^r))+(n>>>2^n>>>13^n>>>22^n<<30^n<<19^n<<10)|0}e[0]=e[0]+t|0,e[1]=e[1]+n|0,e[2]=e[2]+r|0,e[3]=e[3]+i|0,e[4]=e[4]+s|0,e[5]=e[5]+a|0,e[6]=e[6]+o|0,e[7]=e[7]+c|0}}]),a=e(function e(t,n){var r=!(2=this.pageInfo.total)return e.abrupt("return",[]);e.next=4;break;case 4:return r={offset:this.offset},this.payload&&Object.assign(r,this.payload),e.prev=6,e.next=9,this.jsm._request(this.subject,r,{timeout:this.jsm.timeout});case 9:if(t=e.sent,this.pageInfo=t,0===(n=this.countResponse(t)))return e.abrupt("return",[]);e.next=14;break;case 14:return this.offset+=n,r=this.filter(t),e.abrupt("return",r);case 19:throw e.prev=19,e.t0=e.catch(6),this.err=e.t0,e.t0;case 23:case"end":return e.stop()}},e,this,[[6,19]])})),function(){return Jt.apply(this,arguments)})},{key:"countResponse",value:function(e){var t;switch(null==e?void 0:e.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return(null==(t=e.streams)?void 0:t.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return(null==(t=e.consumers)?void 0:t.length)||0;default:return(null==(t=e.streams)?void 0:t.length)||0}return 0}},{key:Symbol.asyncIterator,value:function(){var i=this;return te(O().mark(function e(){var t,n,r;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B(i.next());case 2:t=e.sent;case 3:if(!(0"===(v=null!=(p=n.filter_subject)?p:void 0)?void 0:v)?"".concat(this.prefix,".CONSUMER.CREATE.").concat(t,".").concat(u,".").concat(v):"".concat(this.prefix,".CONSUMER.CREATE.").concat(t,".").concat(u):n.durable_name?"".concat(this.prefix,".CONSUMER.DURABLE.CREATE.").concat(t,".").concat(n.durable_name):"".concat(this.prefix,".CONSUMER.CREATE.").concat(t),e.next=42,this._request(v,i);case 42:return e.abrupt("return",e.sent);case 44:case"end":return e.stop()}},e,this,[[17,21]])})),function(e,t){return nn.apply(this,arguments)})},{key:"update",value:(tn=y(O().mark(function e(t,n,r){var i;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.info(t,n);case 2:return i=e.sent,e.abrupt("return",this.add(t,Object.assign(i.config,r),_t.Update));case 5:case"end":return e.stop()}},e,this)})),function(e,t,n){return tn.apply(this,arguments)})},{key:"info",value:(en=y(O().mark(function e(t,n){return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return k(t),ut(n),e.next=4,this._request("".concat(this.prefix,".CONSUMER.INFO.").concat(t,".").concat(n));case 4:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e,this)})),function(e,t){return en.apply(this,arguments)})},{key:"delete",value:(Qt=y(O().mark(function e(t,n){return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return k(t),ut(n),e.next=4,this._request("".concat(this.prefix,".CONSUMER.DELETE.").concat(t,".").concat(n));case 4:return e.abrupt("return",e.sent.success);case 7:case"end":return e.stop()}},e,this)})),function(e,t){return Qt.apply(this,arguments)})},{key:"list",value:function(e){k(e);e="".concat(this.prefix,".CONSUMER.LIST.").concat(e);return new $t(e,function(e){return e.consumers},this)}},{key:"pause",value:function(e,t,n){e="".concat(this.prefix,".CONSUMER.PAUSE.").concat(e,".").concat(t),t={pause_until:n.toISOString()};return this._request(e,t)}},{key:"resume",value:function(e,t){return this.pause(e,t,new Date(0))}}]));function an(e,t){return l(this,an),c(this,an,[e,t])}function on(e,t,n){if(!0===(2>8,r[s+1]=o,s+=2,0===(n=n.substring(c)).length)break;if(":"!==n[0]||1==n.length)return;if(":"===(n=n.substring(1))[0]){if(0<=i)return;if(i=s,0===(n=n.substring(1)).length)break}}if(0!==n.length)return;if(s<16){if(i<0)return;for(var u=16-s,h=s-1;i<=h;h--)r[h+u]=r[h];for(var l=i+u-1;i<=l;l--)r[l]=0}else if(0<=i)return}return r}}(e)}function _n(e){for(var t,n,r,i,s,a=new Uint8Array(4),o=0;o<4;o++){if(0===e.length)return;if(0r&&(e=e.subarray(0,r)),t.set(e,n),e.byteLength}var C,Rn=e(function e(t){l(this,e),u(this,"_buf",void 0),u(this,"_off",void 0),this._off=0,this._buf=null!=t?new Uint8Array(t):new Uint8Array(0)},[{key:"bytes",value:function(){return!1===(0this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+e)}else this.reset()}},{key:"reset",value:function(){this._reslice(0),this._off=0}},{key:"_tryGrowByReslice",value:function(e){var t=this._buf.byteLength;return e<=this.capacity-t?(this._reslice(t+e),t):-1}},{key:"_reslice",value:function(e){!function(e,t){if(!e)throw new On(1=this.ma.size?(n=this.msgBuf.bytes({copy:!1}),this.dispatcher.push({kind:C.MSG,msg:this.ma,data:n}),this.argBuf=void 0,this.msgBuf=void 0,this.state=T.MSG_END):(n=this.ma.size-this.msgBuf.length,0<(n=(r=e.length-t)=this.ma.size&&(this.dispatcher.push({kind:C.MSG,msg:this.ma,data:e.subarray(this.as,t)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=T.MSG_END);break;case T.MSG_END:i===M.NL&&(this.drop=0,this.as=t+1,this.state=T.OP_START);break;case T.OP_PLUS:switch(i){case M.O:case M.o:this.state=T.OP_PLUS_O;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PLUS_O:switch(i){case M.K:case M.k:this.state=T.OP_PLUS_OK;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PLUS_OK:i===M.NL&&(this.dispatcher.push({kind:C.OK}),this.drop=0,this.state=T.OP_START);break;case T.OP_MINUS:switch(i){case M.E:case M.e:this.state=T.OP_MINUS_E;break;default:throw this.fail(e.subarray(t))}break;case T.OP_MINUS_E:switch(i){case M.R:case M.r:this.state=T.OP_MINUS_ER;break;default:throw this.fail(e.subarray(t))}break;case T.OP_MINUS_ER:switch(i){case M.R:case M.r:this.state=T.OP_MINUS_ERR;break;default:throw this.fail(e.subarray(t))}break;case T.OP_MINUS_ERR:switch(i){case M.SPACE:case M.TAB:this.state=T.OP_MINUS_ERR_SPC;break;default:throw this.fail(e.subarray(t))}break;case T.OP_MINUS_ERR_SPC:switch(i){case M.SPACE:case M.TAB:continue;default:this.state=T.MINUS_ERR_ARG,this.as=t}break;case T.MINUS_ERR_ARG:switch(i){case M.CR:this.drop=1;break;case M.NL:var a=void 0;this.argBuf?(a=this.argBuf.bytes(),this.argBuf=void 0):a=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:C.ERR,data:a}),this.drop=0,this.as=t+1,this.state=T.OP_START;break;default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case T.OP_P:switch(i){case M.I:case M.i:this.state=T.OP_PI;break;case M.O:case M.o:this.state=T.OP_PO;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PO:switch(i){case M.N:case M.n:this.state=T.OP_PON;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PON:switch(i){case M.G:case M.g:this.state=T.OP_PONG;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PONG:i===M.NL&&(this.dispatcher.push({kind:C.PONG}),this.drop=0,this.state=T.OP_START);break;case T.OP_PI:switch(i){case M.N:case M.n:this.state=T.OP_PIN;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PIN:switch(i){case M.G:case M.g:this.state=T.OP_PING;break;default:throw this.fail(e.subarray(t))}break;case T.OP_PING:i===M.NL&&(this.dispatcher.push({kind:C.PING}),this.drop=0,this.state=T.OP_START);break;case T.OP_I:switch(i){case M.N:case M.n:this.state=T.OP_IN;break;default:throw this.fail(e.subarray(t))}break;case T.OP_IN:switch(i){case M.F:case M.f:this.state=T.OP_INF;break;default:throw this.fail(e.subarray(t))}break;case T.OP_INF:switch(i){case M.O:case M.o:this.state=T.OP_INFO;break;default:throw this.fail(e.subarray(t))}break;case T.OP_INFO:switch(i){case M.SPACE:case M.TAB:this.state=T.OP_INFO_SPC;break;default:throw this.fail(e.subarray(t))}break;case T.OP_INFO_SPC:switch(i){case M.SPACE:case M.TAB:continue;default:this.state=T.INFO_ARG,this.as=t}break;case T.INFO_ARG:switch(i){case M.CR:this.drop=1;break;case M.NL:var o=void 0;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:C.INFO,data:o}),this.drop=0,this.as=t+1,this.state=T.OP_START;break;default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(e.subarray(t))}}this.state!==T.MSG_ARG&&this.state!==T.MINUS_ERR_ARG&&this.state!==T.INFO_ARG||this.argBuf||(this.argBuf=new Rn(e.subarray(this.as,t-this.drop))),this.state!==T.MSG_PAYLOAD||this.msgBuf||(this.argBuf||this.cloneMsgArg(),this.msgBuf=new Rn(e.subarray(this.as)))}},{key:"cloneMsgArg",value:function(){var e=this.ma.subject.length,t=this.ma.reply?this.ma.reply.length:0,t=new Uint8Array(e+t);t.set(this.ma.subject),this.ma.reply&&t.set(this.ma.reply,e),this.argBuf=new Rn(t),this.ma.subject=t.subarray(0,e),this.ma.reply&&(this.ma.reply=t.subarray(e))}},{key:"processMsgArgs",value:function(e){if(0<=this.hdr)return this.processHeaderMsgArgs(e);for(var t=[],n=-1,r=0;rthis.ma.size)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Size Error")}},{key:"protoParseInt",value:function(e){if(0===e.length)return-1;for(var t=0,n=0;n>>32-t}function rr(e,t){return(((255&e[t+3])<<8|255&e[t+2])<<8|255&e[t+1])<<8|255&e[t+0]}function ir(e,t){var n=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return new A(n,e[t+4]<<24|e[t+5]<<16|e[t+6]<<8|e[t+7])}function sr(e,t,n){for(var r=0;r<4;r++)e[t+r]=255&n,n>>>=8}function ar(e,t,n){e[t]=n.hi>>24&255,e[t+1]=n.hi>>16&255,e[t+2]=n.hi>>8&255,e[t+3]=255&n.hi,e[t+4]=n.lo>>24&255,e[t+5]=n.lo>>16&255,e[t+6]=n.lo>>8&255,e[t+7]=255&n.lo}function or(e,t,n,r,i){for(var s=0,a=0;a>>8)-1}function cr(e,t,n,r){return or(e,t,n,r,16)}function ur(e,t,n,r){return or(e,t,n,r,32)}function hr(e,t,n,r,i){for(var s,a,o=new Uint32Array(16),c=new Uint32Array(16),u=new Uint32Array(16),h=new Uint32Array(4),l=0;l<4;l++)c[5*l]=rr(r,4*l),c[1+l]=rr(n,4*l),c[6+l]=rr(t,4*l),c[11+l]=rr(n,16+4*l);for(l=0;l<16;l++)u[l]=c[l];for(l=0;l<20;l++){for(s=0;s<4;s++){for(a=0;a<4;a++)h[a]=c[(5*s+4*a)%16];for(h[1]^=nr(h[0]+h[3]|0,7),h[2]^=nr(h[1]+h[0]|0,9),h[3]^=nr(h[2]+h[1]|0,13),h[0]^=nr(h[3]+h[2]|0,18),a=0;a<4;a++)o[4*s+(s+a)%4]=h[a]}for(a=0;a<16;a++)c[a]=o[a]}if(i){for(l=0;l<16;l++)c[l]=c[l]+u[l]|0;for(l=0;l<4;l++)c[5*l]=c[5*l]-rr(r,4*l)|0,c[6+l]=c[6+l]-rr(t,4*l)|0;for(l=0;l<4;l++)sr(e,4*l,c[5*l]),sr(e,16+4*l,c[6+l])}else for(l=0;l<16;l++)sr(e,4*l,c[l]+u[l]|0)}function lr(e,t,n,r){hr(e,t,n,r,!1)}function dr(e,t,n,r){return hr(e,t,n,r,!0),0}function fr(e,t,n,r,i,s,a){var o,c,u=new Uint8Array(16),h=new Uint8Array(64);if(i){for(c=0;c<16;c++)u[c]=0;for(c=0;c<8;c++)u[c]=s[c];for(;64<=i;){for(lr(h,u,a,Jn),c=0;c<64;c++)e[t+c]=(n?n[r+c]:0)^h[c];for(o=1,c=8;c<16;c++)o=o+(255&u[c])|0,u[c]=255&o,o>>>=8;i-=64,t+=64,n&&(r+=64)}if(0>>=8}function br(e,t,n,r,i,s){for(var a,o,c,u=new Uint32Array(17),h=new Uint32Array(17),l=new Uint32Array(17),d=new Uint32Array(17),f=new Uint32Array(17),p=0;p<17;p++)h[p]=l[p]=0;for(p=0;p<16;p++)h[p]=s[p];for(h[3]&=15,h[4]&=252,h[7]&=15,h[8]&=252,h[11]&=15,h[12]&=252,h[15]&=15;0>>=8;for(c=c+l[16]|0,l[16]=3&c,c=5*(c>>>2)|0,p=0;p<16;p++)c=c+l[p]|0,l[p]=255&c,c>>>=8;c=c+l[16]|0,l[16]=c}for(p=0;p<17;p++)f[p]=l[p];for(yr(l,zn),a=0|-(l[16]>>>7),p=0;p<17;p++)l[p]^=a&(f[p]^l[p]);for(p=0;p<16;p++)d[p]=s[p+16];for(d[16]=0,yr(l,d),p=0;p<16;p++)e[t+p]=l[p];return 0}function gr(e,t,n,r,i,s){var a=new Uint8Array(16);return br(a,0,n,r,i,s),cr(e,t,a,0)}function kr(e,t,n,r,i){var s;if(n<32)return-1;for(mr(e,0,t,0,n,r,i),br(e,16,e,32,n-32,e),s=0;s<16;s++)e[s]=0;return 0}function _r(e,t,n,r,i){var s,a=new Uint8Array(32);if(n<32)return-1;if(vr(a,0,32,r,i),0!==gr(t,16,t,32,n-32,a))return-1;for(mr(e,0,t,0,n,r,i),s=0;s<32;s++)e[s]=0;return 0}function wr(e,t){for(var n=0;n<16;n++)e[n]=0|t[n]}function xr(e){for(var t,n=0;n<16;n++)e[n]+=65536,t=Math.floor(e[n]/65536),e[(n+1)*(n<15?1:0)]+=t-1+37*(t-1)*(15===n?1:0),e[n]-=65536*t}function Sr(e,t,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(e[s]^t[s]),e[s]^=r,t[s]^=r}function Er(e,t){for(var n,r,i=N(),s=N(),a=0;a<16;a++)s[a]=t[a];for(xr(s),xr(s),xr(s),n=0;n<2;n++){for(i[0]=s[0]-65517,a=1;a<15;a++)i[a]=s[a]-65535-(i[a-1]>>16&1),i[a-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),r=i[15]>>16&1,i[14]&=65535,Sr(s,i,1-r)}for(a=0;a<16;a++)e[2*a]=255&s[a],e[2*a+1]=s[a]>>8}function Cr(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return Er(n,e),Er(r,t),ur(n,0,r,0)}function Tr(e){var t=new Uint8Array(32);return Er(t,e),1&t[0]}function Or(e,t){for(var n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function Mr(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]|0}function Pr(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]|0}function D(e,t,n){for(var r,i=new Float64Array(31),s=0;s<31;s++)i[s]=0;for(s=0;s<16;s++)for(r=0;r<16;r++)i[s+r]+=t[s]*n[r];for(s=0;s<15;s++)i[s]+=38*i[s+16];for(s=0;s<16;s++)e[s]=i[s];xr(e),xr(e)}function Ar(e,t){D(e,t,t)}function Nr(e,t){for(var n=N(),r=0;r<16;r++)n[r]=t[r];for(r=253;0<=r;r--)Ar(n,n),2!==r&&4!==r&&D(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}function Dr(e,t){for(var n=N(),r=0;r<16;r++)n[r]=t[r];for(r=250;0<=r;r--)Ar(n,n),1!==r&&D(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}function Rr(e,t,n){for(var r,i=new Uint8Array(32),s=new Float64Array(80),a=N(),o=N(),c=N(),u=N(),h=N(),l=N(),d=0;d<31;d++)i[d]=t[d];for(i[31]=127&t[31]|64,i[0]&=248,Or(s,n),d=0;d<16;d++)o[d]=s[d],u[d]=a[d]=c[d]=0;for(a[0]=u[0]=1,d=254;0<=d;--d)Sr(a,o,r=i[d>>>3]>>>(7&d)&1),Sr(c,u,r),Mr(h,a,c),Pr(a,a,c),Mr(c,o,u),Pr(o,o,u),Ar(u,h),Ar(l,a),D(a,c,a),D(c,o,h),Mr(h,a,c),Pr(a,a,c),Ar(o,a),Pr(c,u,l),D(a,c,Bn),Mr(a,a,u),D(c,c,a),D(a,u,l),D(u,o,s),Ar(o,h),Sr(a,o,r),Sr(c,u,r);for(d=0;d<16;d++)s[d+16]=a[d],s[d+32]=c[d],s[d+48]=o[d],s[d+64]=u[d];var n=s.subarray(32),f=s.subarray(16);return Nr(n,n),D(f,f,n),Er(e,f),0}function Ir(e,t){return Rr(e,t,Un)}function jr(e,t){return jn(t,32),Ir(e,t)}function Lr(e,t,n){var r=new Uint8Array(32);return Rr(r,n,t),dr(e,Ln,r,Jn)}function Ur(){for(var e,t=0,n=0,r=0,i=0,s=65535,a=0;a>>16,r+=(e=arguments[a].hi)&s,i+=e>>>16;return new A((r+=(n+=t>>>16)>>>16)&s|(i+=r>>>16)<<16,t&s|n<<16)}function Fr(e,t){return new A(e.hi>>>t,e.lo>>>t|e.hi<<32-t)}function qr(){for(var e=0,t=0,n=0;n>>t|e.lo<>>t|e.hi<>>t|e.hi<>>t|e.lo<>(7&i)&1),Yr(t,e),Yr(e,e),Gr(e,t,r)}function zr(e,t){var n=[N(),N(),N(),N()];wr(n[0],Yn),wr(n[1],Gn),wr(n[2],qn),D(n[3],Yn,Gn),Jr(e,n,t)}function Kr(e,t,n){var r,i=new Uint8Array(64),s=[N(),N(),N(),N()];for(n||jn(t,32),Hr(i,t,32),i[0]&=248,i[31]&=127,i[31]|=64,zr(s,i),Vr(e,s),r=0;r<32;r++)t[r+32]=e[r];return 0}function $r(e,t){for(var n,r,i,s=63;32<=s;--s){for(n=0,r=s-32,i=s-12;r>4)*Qn[r],n=t[r]>>8,t[r]&=255;for(r=0;r<32;r++)t[r]-=n*Qn[r];for(s=0;s<32;s++)t[s+1]+=t[s]>>8,e[s]=255&t[s]}function Xr(e){for(var t=new Float64Array(64),n=0;n<64;n++)t[n]=e[n];for(n=0;n<64;n++)e[n]=0;$r(e,t)}function Zr(e,t,n,r){for(var i,s=new Uint8Array(64),a=new Uint8Array(64),o=new Uint8Array(64),c=new Float64Array(64),u=[N(),N(),N(),N()],h=(Hr(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,n+64),l=0;l>7&&Pr(s[0],Fn,s[0]),D(s[3],s[0],s[1]),0))return-1;for(i=0;i=a&&this.servers.removeCurrentServer();case 34:e.next=39;break;case 36:return r=Math.min(r,i.lastConnect+n-s),e.next=39,ze(r);case 39:e.next=0;break;case 41:case"end":return e.stop()}},e,this,[[18,24]])})),function(){return oi.apply(this,arguments)})},{key:"processMsg",value:function(e,t){var n;this.inMsgs++,this.inBytes+=t.length,this.subscriptions.sidCounter&&(n=this.subscriptions.get(e.sid))&&(n.received+=1,n.callback&&n.callback(null,new ct(e,t,this)),void 0!==n.max)&&n.max<=n.received&&n.unsubscribe()}},{key:"processError",value:function(e){var t,n,e=Me(e),e=_i.toError(e),r={type:Ae.Error,data:e.code};e.isPermissionError()&&(n=!1,e.permissionContext&&(r.permissionContext=e.permissionContext,n=(null==(t=this.subscriptions.getMux())?void 0:t.subject)===e.permissionContext.subject),this.subscriptions.handleError(e),this.muxSubscriptions.handleError(n,e),n)&&this.subscriptions.setMux(null),this.dispatchStatus(r),this.handleError(e)}},{key:"handleError",value:function(e){e.isAuthError()?this.handleAuthError(e):(e.isProtocolError()||e.isAuthTimeout())&&(this.lastError=e),e.isPermissionError()||(this.lastError=e)}},{key:"handleAuthError",value:function(e){this.lastError&&e.code===this.lastError.code&&!1===this.options.ignoreAuthErrorAbort&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}},{key:"processPing",value:function(){this.transport.send(di)}},{key:"processPong",value:function(){var e=this.pongs.shift();e&&e.resolve()}},{key:"processInfo",value:function(e){var t=JSON.parse(Me(e)),n=(this.info=t,this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(t,this.transport.isEncrypted()));if(!this.infoReceived){this.features.update(Xt(t.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();var r=this.transport,i=r.version,r=r.lang;try{var s=new pi({version:i,lang:r},this.options,t.nonce),a=(t.headers&&(s.headers=!0,s.no_responders=!0),JSON.stringify(s));this.transport.send(Oe("CONNECT ".concat(a).concat(dn))),this.transport.send(fi)}catch(e){this._close(e)}}n&&this.dispatchStatus({type:Ae.Update,data:n}),void 0!==t.ldm&&t.ldm&&this.dispatchStatus({type:Ae.LDM,data:this.servers.getCurrentServer().toString()})}},{key:"push",value:function(e){switch(e.kind){case C.MSG:this.processMsg(e.msg,e.data);break;case C.OK:break;case C.ERR:this.processError(e.data);break;case C.PING:this.processPing();break;case C.PONG:this.processPong();break;case C.INFO:this.processInfo(e.data)}}},{key:"sendCommand",value:function(e){for(var t,n=this,r=this.outbound.length(),e="string"==typeof e?Oe(e):e,i=arguments.length,s=new Array(1=this.pendingLimit&&this.flushPending()}},{key:"publish",value:function(e){var t,n=1this.info.max_payload)throw g.errorForCode(b.MaxPayloadExceeded);this.outBytes+=n,this.outMsgs++,r.headers?(i=(r.reply?"HPUB ".concat(e," ").concat(r.reply," "):"HPUB ".concat(e," ")).concat(a," ").concat(n,"\r\n"),this.sendCommand(i,s,t,fn)):(i=(r.reply?"PUB ".concat(e," ").concat(r.reply," "):"PUB ".concat(e," ")).concat(n,"\r\n"),this.sendCommand(i,t,fn))}},{key:"request",value:function(e){return this.initMux(),this.muxSubscriptions.add(e),e}},{key:"subscribe",value:function(e){return this.subscriptions.add(e),this._subunsub(e),e}},{key:"_sub",value:function(e){e.queue?this.sendCommand("SUB ".concat(e.subject," ").concat(e.queue," ").concat(e.sid,"\r\n")):this.sendCommand("SUB ".concat(e.subject," ").concat(e.sid,"\r\n"))}},{key:"_subunsub",value:function(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}},{key:"unsubscribe",value:function(e,t){this.unsub(e,t),(void 0===e.max||e.max<=e.received)&&this.subscriptions.cancel(e)}},{key:"unsub",value:function(e,t){e&&!this.isClosed()&&(t?this.sendCommand("UNSUB ".concat(e.sid," ").concat(t,"\r\n")):this.sendCommand("UNSUB ".concat(e.sid,"\r\n")),e.max=t)}},{key:"resub",value:function(e,t){e&&!this.isClosed()&&(this.unsub(e),e.subject=t,this.subscriptions.resub(e),this._sub(e))}},{key:"flush",value:function(e){return e=e||x(),this.pongs.push(e),this.outbound.fill(fi),this.flushPending(),e}},{key:"sendSubscriptions",value:function(){var t=[];this.subscriptions.all().forEach(function(e){e.queue?t.push("SUB ".concat(e.subject," ").concat(e.queue," ").concat(e.sid).concat(dn)):t.push("SUB ".concat(e.subject," ").concat(e.sid).concat(dn))}),t.length&&this.transport.send(Oe(t.join("")))}},{key:"_close",value:(ai=y(O().mark(function e(t){return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._closed)return e.abrupt("return");e.next=2;break;case 2:return this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(t),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(function(e){e.stop()}),this._closed=!0,e.next=11,this.transport.close(t);case 11:return e.next=13,this.closed.resolve(t);case 13:case"end":return e.stop()}},e,this)})),function(e){return ai.apply(this,arguments)})},{key:"close",value:function(){return this._close()}},{key:"isClosed",value:function(){return this._closed}},{key:"drain",value:function(){var t=this,e=this.subscriptions.all(),n=[];return e.forEach(function(e){n.push(e.drain())}),Promise.all(n).then(y(O().mark(function e(){return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t.noMorePublishing=!0,e.next=3,t.flush();case 3:return e.abrupt("return",t.close());case 4:case"end":return e.stop()}},e)}))).catch(function(){})}},{key:"flushPending",value:function(){var e;this.infoReceived&&this.connected&&this.outbound.size()&&(e=this.outbound.drain(),this.transport.send(e))}},{key:"initMux",value:function(){var e;this.subscriptions.getMux()||(e=this.muxSubscriptions.init(this.options.inboxPrefix),(e=new vi(this,"".concat(e,"*"))).callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(e),this.subscribe(e))}},{key:"selectServer",value:function(){var e=this.servers.selectServer();if(void 0!==e)return this.server=e,this.server}},{key:"getServer",value:function(){return this.server}}],[{key:"connect",value:(si=y(O().mark(function e(t,n){var r;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=new _i(t,n),e.next=3,r.dialLoop();case 3:return e.abrupt("return",r);case 4:case"end":return e.stop()}},e)})),function(e,t){return si.apply(this,arguments)})},{key:"toError",value:function(e){var t,n,r=e?e.toLowerCase():"";return-1!==r.indexOf("permissions violation")?(t=new g(e,b.PermissionsViolation),(n=e.match(/(Publish|Subscription) to "(\S+)"/))&&(t.permissionContext={operation:n[1].toLowerCase(),subject:n[2],queue:void 0},n=e.match(/using queue "(\S+)"/))&&(t.permissionContext.queue=n[1]),t):-1!==r.indexOf("authorization violation")?new g(e,b.AuthorizationViolation):-1!==r.indexOf("user authentication expired")?new g(e,b.AuthenticationExpired):-1!=r.indexOf("account authentication expired")?new g(e,b.AccountExpired):-1!==r.indexOf("authentication timeout")?new g(e,b.AuthenticationTimeout):new g(e,b.ProtocolError)}}]),bi=e(function e(t){l(this,e),u(this,"msg",void 0),this.msg=t},[{key:"data",get:function(){return this.msg.data}},{key:"sid",get:function(){return this.msg.sid}},{key:"subject",get:function(){return this.msg.subject}},{key:"reply",get:function(){return this.msg.reply||""}},{key:"headers",get:function(){return this.msg.headers}},{key:"respond",value:function(e,t){return this.msg.respond(e,t)}},{key:"respondError",value:function(e,t,n,r){var i;return(r=r||{}).headers=r.headers||et(),null!=(i=r.headers)&&i.set(qe,"".concat(e)),null!=(i=r.headers)&&i.set(Fe,t),this.msg.respond(n,r)}},{key:"json",value:function(e){return this.msg.json(e)}},{key:"string",value:function(){return this.msg.string()}}]),gi=e(ki,[{key:"calcSubject",value:function(e){var t=1"===e&&t!==o.length-1)throw new Error("".concat(s," cannot have internal '>': '").concat(a,"'"))}),{name:e,subject:this.calcSubject(this.subject,n),queue:t,handler:r,metadata:i});return this.srv._addEndpoint(e)}},{key:"addGroup",value:function(){return new ki(this,0"===e)throw new Error("".concat(r," name cannot contain internal '>': '").concat(i,"'"))})}var s="";if(e instanceof Ei)this.srv=e,s="";else{if(!(e instanceof ki))throw new Error("unknown ServiceGroup type");this.srv=e.srv,""===n&&""!==e.queue&&(n=e.queue),s=e.subject}this.subject=this.calcSubject(s,t),this.queue=n}function _i(e,t){l(this,_i),u(this,"connected",void 0),u(this,"connectedOnce",void 0),u(this,"infoReceived",void 0),u(this,"info",void 0),u(this,"muxSubscriptions",void 0),u(this,"options",void 0),u(this,"outbound",void 0),u(this,"pongs",void 0),u(this,"subscriptions",void 0),u(this,"transport",void 0),u(this,"noMorePublishing",void 0),u(this,"connectError",void 0),u(this,"publisher",void 0),u(this,"_closed",void 0),u(this,"closed",void 0),u(this,"listeners",void 0),u(this,"heartbeats",void 0),u(this,"parser",void 0),u(this,"outMsgs",void 0),u(this,"inMsgs",void 0),u(this,"outBytes",void 0),u(this,"inBytes",void 0),u(this,"pendingLimit",void 0),u(this,"lastError",void 0),u(this,"abortReconnect",void 0),u(this,"whyClosed",void 0),u(this,"servers",void 0),u(this,"server",void 0),u(this,"features",void 0),u(this,"connectPromise",void 0),this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=32768,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=t,this.subscriptions=new mi,this.muxSubscriptions=new Cn,this.outbound=new At,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new rn({major:0,minor:0,micro:0}),this.connectPromise=null;t="string"==typeof e.servers?[e.servers]:e.servers;this.servers=new En(t,{randomize:!e.noRandomize}),this.closed=x(),this.parser=new tr(this),this.heartbeats=new Tn(this,this.options.pingInterval||ni,this.options.maxPingOut||2)}function wi(e,t){var n,r=2*\w]+$/,Di=/^[-\w]+$/;function Ri(e){if(e.startsWith(".")||e.endsWith(".")||!Ai.test(e))throw new Error("invalid key: ".concat(e))}function Ii(e){if(e.startsWith(".")||e.endsWith(".")||!Ni.test(e))throw new Error("invalid key: ".concat(e))}function ji(e){if(e.startsWith(".")||e.endsWith("."))throw new Error("invalid key: ".concat(e));for(var t=e.split("."),n=!1,r=0;r":if(r!==t.length-1)throw new Error("invalid key: ".concat(e));n=!0}return n}function Li(e){if(!Di.test(e))throw new Error("invalid bucket name: ".concat(e))}(i=Mi=Mi||{}).MsgIdHdr="Nats-Msg-Id",i.ExpectedStreamHdr="Nats-Expected-Stream",i.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",i.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",i.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence";var Ui,Fi,qi,Bi,Wi,Hi,Yi,Gi,Vi,Ji,zi,Ki,$i,Xi=e(ts,[{key:"init",value:($i=y(O().mark(function e(){var t,n,r,i,s,a,o,c=this,u=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0"),dest:"$KV.".concat(c.bucket,".>")}]),t}),r.sources=i),r.subjects=[this.subjectForBucket()]),t.metadata&&(r.metadata=t.metadata),"boolean"==typeof t.compression&&(r.compression=t.compression?kt.S2:kt.None),i=this.js.nc,a=i.getServerVersion(),s=!!a&&0<=Zt(a,Xt("2.7.2")),r.discard=s?yt.New:yt.Old,s=i.features.get(w.JS_ALLOW_DIRECT),i=s.ok,s=s.min,i||!0!==t.allow_direct){e.next=27;break}return a=a?"".concat(a.major,".").concat(a.minor,".").concat(a.micro):"unknown",e.abrupt("return",Promise.reject(new Error("allow_direct is not available on server version ".concat(a," - requires ").concat(s))));case 27:return t.allow_direct="boolean"==typeof t.allow_direct?t.allow_direct:i,r.allow_direct=t.allow_direct,this.direct=r.allow_direct,r.num_replicas=n.replicas,n.ttl&&(r.max_age=1e6*n.ttl),r.allow_rollup_hdrs=!0,e.prev=33,e.next=36,this.jsm.streams.info(r.name);case 36:(o=e.sent).config.allow_direct||!0!==this.direct||(this.direct=!1),e.next=49;break;case 40:if(e.prev=40,e.t0=e.catch(33),"stream not found"===e.t0.message)return e.next=45,this.jsm.streams.add(r);e.next=48;break;case 45:o=e.sent,e.next=49;break;case 48:throw e.t0;case 49:this.initializePrefixes(o);case 50:case"end":return e.stop()}},e,this,[[33,40]])})),function(){return $i.apply(this,arguments)})},{key:"initializePrefixes",value:function(e){this._prefixLen=0,this.prefix="$KV.".concat(this.bucket),this.useJsPrefix="$JS.API"!==this.js.apiPrefix;var t,n,e=e.config.mirror;e&&((t=e.name).startsWith(Et)&&(t=t.substring(3)),e.external&&""!==e.external.api?(n=e.name.substring(3),this.useJsPrefix=!1,this.prefix="$KV.".concat(n),this.editPrefix="".concat(e.external.api,".$KV.").concat(t)):this.editPrefix=this.prefix)}},{key:"bucketName",value:function(){var e;return null!=(e=this.stream)?e:"".concat(Et).concat(this.bucket)}},{key:"subjectForBucket",value:function(){return"".concat(this.prefix,".").concat(this.bucket,".>")}},{key:"subjectForKey",value:function(e){var t=[];return 1":case"*":n.push(i);break;default:n.push(this.codec.key.encode(i))}}}catch(e){r.e(e)}finally{r.f()}return n.join(".")}},{key:"decodeKey",value:function(e){var t,n=[],r=H(e.split("."));try{for(r.s();!(t=r.n()).done;){var i=t.value;switch(i){case">":case"*":n.push(i);break;default:n.push(this.codec.key.decode(i))}}}catch(e){r.e(e)}finally{r.f()}return n.join(".")}},{key:"close",value:function(){return Promise.resolve()}},{key:"dataLen",value:function(e,t){t=t&&t.get(S.MessageSizeHdr)||"";return""!==t?parseInt(t,10):e.length}},{key:"smToEntry",value:function(e){return new Da(this.bucket,this.prefixLen,e)}},{key:"jmToEntry",value:function(e){var t=this.decodeKey(e.subject.substring(this.prefixLen));return new Ra(this.bucket,t,e)}},{key:"create",value:(Ki=y(O().mark(function e(t,n){var r,i,s,a;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.put(t,n,{previousSeq:0});case 3:return i=e.sent,e.abrupt("return",Promise.resolve(i));case 7:if(e.prev=7,e.t0=e.catch(0),r=e.t0,10071!==(null==e.t0||null==(i=e.t0.api_error)?void 0:i.err_code))return e.abrupt("return",Promise.reject(e.t0));e.next=12;break;case 12:return s=0,e.prev=13,e.next=16,this.get(t);case 16:if("DEL"===(null==(a=e.sent)?void 0:a.operation)||"PURGE"===(null==a?void 0:a.operation))return s=null!==a?a.revision:0,e.abrupt("return",this.update(t,n,s));e.next=22;break;case 22:return e.abrupt("return",Promise.reject(r));case 23:e.next=28;break;case 25:return e.prev=25,e.t1=e.catch(13),e.abrupt("return",Promise.reject(e.t1));case 28:case"end":return e.stop()}},e,this,[[0,7],[13,25]])})),function(e,t){return Ki.apply(this,arguments)})},{key:"update",value:function(e,t,n){if(n<=0)throw new Error("version must be greater than 0");return this.put(e,t,{previousSeq:n})}},{key:"put",value:(zi=y(O().mark(function e(t,n){var r,i,s,a,o=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s=2",initializedFn:function(){n.resolve()}});case 5:return o=e.sent,y(O().mark(function e(){var t,n,r,i,s;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t=!1,e.prev=2,i=d(o);case 4:return e.next=6,i.next();case 6:if(!(t=!(s=e.sent).done)){e.next=12;break}"DEL"!==(s=s.value).operation&&"PURGE"!==s.operation||a.push(s);case 9:t=!1,e.next=4;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(2),n=!0,r=e.t0;case 18:if(e.prev=18,e.prev=19,t&&null!=i.return)return e.next=23,i.return();e.next=23;break;case 23:if(e.prev=23,n)throw r;e.next=26;break;case 26:return e.finish(23);case 27:return e.finish(18);case 28:case"end":return e.stop()}},e,null,[[2,14,18,28],[19,,23,27]])}))().then(),e.next=9,n;case 9:return o.stop(),r=Date.now()-t,i=a.map(function(e){var t=s.subjectForKey(e.key);return e.created.getTime()>=r?s.jsm.streams.purge(s.stream,{filter:t,keep:1}):s.jsm.streams.purge(s.stream,{filter:t,keep:0})}),e.next=14,Promise.all(i);case 14:return(i=e.sent).unshift({success:!0,purged:0}),e.abrupt("return",i.reduce(function(e,t){return e.purged+=t.purged,e}));case 17:case"end":return e.stop()}},e,this)})),function(){return Ji.apply(this,arguments)})},{key:"_deleteOrPurge",value:(Vi=y(O().mark(function e(t,n,r){var i,s,a,o,c,u;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasWildcards(t)){e.next=2;break}return e.abrupt("return",this._doDeleteOrPurge(t,n,r));case 2:return e.next=4,this.keys(t);case 4:c=e.sent,a=s=!(i=[]),e.prev=8,c=d(c);case 10:return e.next=12,c.next();case 12:if(s=!(u=e.sent).done){if(u=u.value,i.push(this._doDeleteOrPurge(u,n)),100===i.length)return e.next=18,Promise.all(i);e.next=19}else e.next=22;break;case 18:i.length=0;case 19:s=!1,e.next=10;break;case 22:e.next=28;break;case 24:e.prev=24,e.t0=e.catch(8),a=!0,o=e.t0;case 28:if(e.prev=28,e.prev=29,s&&null!=c.return)return e.next=33,c.return();e.next=33;break;case 33:if(e.prev=33,a)throw o;e.next=36;break;case 36:return e.finish(33);case 37:return e.finish(28);case 38:if(0",n=new _,(t={}).headers_only=a.headers_only||!1,r=function(){n.stop()},i=0,a=this._buildCC(o,wt.AllHistory,t),o=a.filter_subject,(t=Tt(a)).bindStream(this.stream),t.orderedConsumer(),t.callback(function(e,t){e?n.stop(e):t&&(e=c.jmToEntry(t),n.push(e),n.received++,r&&0=i||0===t.info.pending)&&(n.push(r),r=void 0)}),e.next=15,this.js.subscribe(o,t);case 15:if(s=e.sent,r)if(a=s.info.last,0===(o=a.num_pending+a.delivered.consumer_seq)||n.received>=o)try{r()}catch(e){n.stop(e)}finally{r=void 0}else i=o;return n._data=s,n.iterClosed.then(function(){s.unsubscribe()}),s.closed.then(function(){n.stop()}).catch(function(e){n.stop(e)}),e.abrupt("return",n);case 21:case"end":return e.stop()}},e,this)})),function(){return Yi.apply(this,arguments)})},{key:"canSetWatcherName",value:function(){return this.js.nc.features.get(w.JS_NEW_CONSUMER_CREATE_API).ok}},{key:"watch",value:(Hi=y(O().mark(function e(){var n,r,i,s,t,a,o,c,u,h=this,l=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return c=null!=(c=(u=0",n=new _,(a={}).headers_only=u.headers_only||!1,t=wt.LastValue,u.include===wt.AllHistory?t=wt.AllHistory:u.include===wt.UpdatesOnly&&(t=wt.UpdatesOnly),r=!0===u.ignoreDeletes,i=u.initializedFn,s=0,c=this._buildCC(c,t,a),t=c.filter_subject,a=Tt(c),this.canSetWatcherName()&&a.consumerName(De.next()),a.bindStream(this.stream),u.resumeFromRevision&&0=s||0===t.info.pending)&&(n.push(i),i=void 0)))}),e.next=20,this.js.subscribe(t,a);case 20:if(o=e.sent,i)if(c=o.info.last,0===(u=c.num_pending+c.delivered.consumer_seq)||n.received>=u)try{i()}catch(e){n.stop(e)}finally{i=void 0}else s=u;return n._data=o,n.iterClosed.then(function(){o.unsubscribe()}),o.closed.then(function(){n.stop()}).catch(function(e){n.stop(e)}),e.abrupt("return",n);case 26:case"end":return e.stop()}},e,this)})),function(){return Hi.apply(this,arguments)})},{key:"keys",value:(Wi=y(O().mark(function e(){var o,t,n,c,u=this,r=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=0",o=new _,n=this._buildCC(t,wt.LastValue,{headers_only:!0}),t=Array.isArray(t)?">":n.filter_subject,(n=Tt(n)).bindStream(this.stream),n.orderedConsumer(),e.next=9,this.js.subscribe(t,n);case 9:return c=e.sent,y(O().mark(function e(){var t,n,r,i,s,a;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t=!1,e.prev=2,i=d(c);case 4:return e.next=6,i.next();case 6:if(!(t=!(s=e.sent).done)){e.next=14;break}s=s.value,"DEL"!==(a=null==(a=s.headers)?void 0:a.get(Pi))&&"PURGE"!==a&&(a=u.decodeKey(s.subject.substring(u.prefixLen)),o.push(a)),0===s.info.pending&&c.unsubscribe();case 11:t=!1,e.next=4;break;case 14:e.next=20;break;case 16:e.prev=16,e.t0=e.catch(2),n=!0,r=e.t0;case 20:if(e.prev=20,e.prev=21,t&&null!=i.return)return e.next=25,i.return();e.next=25;break;case 25:if(e.prev=25,n)throw r;e.next=28;break;case 28:return e.finish(25);case 29:return e.finish(20);case 30:case"end":return e.stop()}},e,null,[[2,16,20,30],[21,,25,29]])}))().then(function(){o.stop()}).catch(function(e){o.stop(e)}),0===c.info.last.num_pending&&c.unsubscribe(),e.abrupt("return",o);case 14:case"end":return e.stop()}},e,this)})),function(){return Wi.apply(this,arguments)})},{key:"purgeBucket",value:function(e){return this.jsm.streams.purge(this.bucketName(),e)}},{key:"destroy",value:function(){return this.jsm.streams.delete(this.bucketName())}},{key:"status",value:(Bi=y(O().mark(function e(){var t,n;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.js.nc,t=null!=(t=null==(t=t.info)?void 0:t.cluster)?t:"",n=this.bucketName(),e.next=5,this.jsm.streams.info(n);case 5:return e.abrupt("return",new Zi(e.sent,t));case 7:case"end":return e.stop()}},e,this)})),function(){return Bi.apply(this,arguments)})}],[{key:"create",value:(qi=y(O().mark(function e(t,n){var r,i,s=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=2"),this.consumerOpts.opt_start_time&&(delete t.opt_start_seq,t.deliver_policy=v.StartTime,t.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold)&&(t.inactive_threshold=1e6*this.consumerOpts.inactive_threshold),t}},{key:"resetConsumer",value:(Ns=y(O().mark(function e(){var t,n,r,i,s,a,o,c=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=0",{callback:function(e,t){if(e)throw e;try{var n=s.parseJsResponse(t),r=n.type.split("."),i=r[r.length-1];a.push({kind:i,data:n})}catch(e){a.stop(e)}}}),a}}]),$s=e(function e(t){l(this,e),u(this,"_header",void 0),u(this,"smr",void 0),this.smr=t},[{key:"subject",get:function(){return this.smr.message.subject}},{key:"seq",get:function(){return this.smr.message.seq}},{key:"timestamp",get:function(){return this.smr.message.time}},{key:"time",get:function(){return new Date(Date.parse(this.timestamp))}},{key:"data",get:function(){return this.smr.message.data?this._parse(this.smr.message.data):p}},{key:"header",get:function(){var e;return this._header||(this.smr.message.hdrs?(e=this._parse(this.smr.message.hdrs),this._header=nt.decode(e)):this._header=et()),this._header}},{key:"_parse",value:function(e){for(var t=atob(e),n=t.length,r=new Uint8Array(n),i=0;ih?h:a,t.options.max_chunk_size=a,e.next=14,this.info(t.name);case 14:if(o=e.sent,c=this._checkNotEmpty(t.name),u=c.name,h=c.error)return e.abrupt("return",Promise.reject(h));e.next=18;break;case 18:p=De.next(),l=this._chunkSubject(p),d=this._metaSubject(u),f=Object.assign({bucket:this.name,nuid:p,size:0,chunks:0},ea(t)),p=x(),v=[],m=new At,e.prev=25,y=n?n.getReader():null,b=new Wt;case 28:if(y)return e.next=32,y.read();e.next=35;break;case 32:e.t0=e.sent,e.next=36;break;case 35:e.t0={done:!0,value:void 0};case 36:if(k=(g=e.t0).done,g=g.value,k)return 0a;)f.chunks++,f.size+=a,w=m.drain(t.options.max_chunk_size),b.update(w),v.push(this.js.publish(l,w,{timeout:i}));e.next=28;break;case 70:e.next=77;break;case 72:return e.prev=72,e.t2=e.catch(25),e.next=76,this.jsm.streams.purge(this.stream,{filter:l});case 76:p.reject(e.t2);case 77:return e.abrupt("return",p);case 78:case"end":return e.stop()}},e,this,[[25,72],[58,63]])})),function(e,t,n){return _a.apply(this,arguments)})},{key:"putBlob",value:function(e,t,n){return null===t&&(t=new Uint8Array(0)),this.put(e,(r=t,new ReadableStream({pull:function(e){e.enqueue(r),e.close()}})),n);var r}},{key:"put",value:function(e,t,n){var r;return null!=e&&null!=(r=e.options)&&r.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(e,t,n)}},{key:"getBlob",value:(ka=y(O().mark(function e(t){var n,r,i,s;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=function(){return(r=y(O().mark(function e(t){var n,r,i,s;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=new At,r=t.getReader();case 2:return e.next=5,r.read();case 5:if(i=(s=e.sent).done,s=s.value,i)return e.abrupt("return",n.drain());e.next=10;break;case 10:s&&s.length&&n.fill(s),e.next=2;break;case 13:case"end":return e.stop()}},e)}))).apply(this,arguments)},n=function(e){return r.apply(this,arguments)},e.next=4,this.get(t);case 4:if(null===(i=e.sent))return e.abrupt("return",Promise.resolve(null));e.next=7;break;case 7:return e.next=9,Promise.all([i.error,n(i.data)]);case 9:if((s=e.sent)[0])return e.abrupt("return",Promise.reject(s[0]));e.next=14;break;case 14:return e.abrupt("return",Promise.resolve(s[1]));case 15:case"end":return e.stop()}},e,this)})),function(e){return ka.apply(this,arguments)})},{key:"get",value:(ga=y(O().mark(function e(t){var o,n,r,i,c,s,u,a,h;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.rawInfo(t);case 2:if(null===(o=e.sent))return e.abrupt("return",Promise.resolve(null));e.next=5;break;case 5:if(o.deleted)return e.abrupt("return",Promise.resolve(null));e.next=7;break;case 7:if(o.options&&o.options.link){if(""===(n=o.options.link.name||""))throw new Error("link is a bucket");e.next=11}else e.next=20;break;case 11:if(o.options.link.bucket!==this.name)return e.next=14,Ba.create(this.js,o.options.link.bucket);e.next=17;break;case 14:e.t0=e.sent,e.next=18;break;case 17:e.t0=this;case 18:return s=e.t0,e.abrupt("return",s.get(n));case 20:if(r=x(),i={info:new Qs(o),error:r},0===o.size)return i.data=new ReadableStream({pull:function(e){e.enqueue(new Uint8Array(0)),e.close()}}),r.resolve(null),e.abrupt("return",Promise.resolve(i));e.next=26;break;case 26:return(s=Tt()).orderedConsumer(),u=new Wt,a="$O.".concat(this.name,".C.").concat(o.nuid),e.next=32,this.js.subscribe(a,s);case 32:return h=e.sent,y(O().mark(function e(){var t,n,r,i,s,a;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t=!1,e.prev=2,i=d(h);case 4:return e.next=6,i.next();case 6:if(!(t=!(a=e.sent).done)){e.next=13;break}0<(a=a.value).data.length&&(u.update(a.data),c.enqueue(a.data)),0===a.info.pending&&(a=u.digest("base64"),s=a.length%3,s=0")}},{key:"init",value:(pa=y(O().mark(function e(){var n,r,i,s=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=0"),"$O.".concat(this.name,".M.>")],r.placement&&(i.placement=r.placement),r.metadata&&(i.metadata=r.metadata),"boolean"==typeof r.compression&&(i.compression=r.compression?kt.S2:kt.None),e.prev=20,e.next=23,this.jsm.streams.info(i.name);case 23:e.next=30;break;case 25:if(e.prev=25,e.t1=e.catch(20),"stream not found"===e.t1.message)return e.next=30,this.jsm.streams.add(i);e.next=30;break;case 30:case"end":return e.stop()}var t},e,this,[[1,5],[20,25]])})),function(){return pa.apply(this,arguments)})}],[{key:"create",value:(fa=y(O().mark(function e(t,n){var r,i,s=arguments;return O().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=2e.height?{width:"".concat(this.height,"px"),height:"".concat(this.width,"px"),transform:"rotate(90deg)",position:"absolute",top:"".concat((this.height-this.width)/2,"px"),left:"".concat(-(this.height-this.width)/2,"px"),objectFit:"fill"}:{width:"".concat(this.width,"px"),height:"".concat(this.height,"px"),transform:"rotate(0deg)",position:"absolute",top:"0",left:"0",objectFit:"fill"};this.node&&Object.assign(null==(t=this.node)?void 0:t.style,e)}},{key:"toggleTouchMode",value:function(e){this.isTouchMode=e,this.clearEvents(),this.enableTouchEvents(),this.enableMouseEvents()}},{key:"enableTouchEvents",value:function(){this.node.addEventListener("touchmove",this.onTouchMoveHandler),this.node.addEventListener("touchstart",this.onTouchStartHandler),this.node.addEventListener("touchend",this.onTouchEndHandler)}},{key:"disableTouchEvents",value:function(){this.node.removeEventListener("touchmove",this.onTouchMoveHandler),this.node.removeEventListener("touchstart",this.onTouchStartHandler),this.node.removeEventListener("touchend",this.onTouchEndHandler)}},{key:"enableMouseEvents",value:function(){this.node.addEventListener("mousemove",this.onMouseMoveHandler),this.node.addEventListener("mousedown",this.onMouseDownHandler),this.node.addEventListener("mouseup",this.onMouseUpHandler),this.node.addEventListener("mouseleave",this.onMouseLeaveHandler),this.node.addEventListener("wheel",this.onMouseWheelHandler)}},{key:"disableMouseEvents",value:function(){this.node.removeEventListener("mousemove",this.onMouseMoveHandler),this.node.removeEventListener("mousedown",this.onMouseDownHandler),this.node.removeEventListener("mouseup",this.onMouseUpHandler),this.node.removeEventListener("mouseleave",this.onMouseLeaveHandler),this.node.removeEventListener("wheel",this.onMouseWheelHandler)}},{key:"onTouchMove",value:function(e){e.preventDefault(),1===e.touches.length&&this._touchClick(e,2)}},{key:"onTouchStart",value:function(e){e.preventDefault(),this._touchClick(e,0)}},{key:"onTouchEnd",value:function(e){e.preventDefault(),this._touchClick(e,1)}},{key:"onMouseMove",value:function(e){e.preventDefault(),1===e.buttons&&(this.isMouseOutside=!0,this._touchClick(e,2))}},{key:"onMouseDown",value:function(e){e.preventDefault(),1===e.buttons&&this._touchClick(e,0)}},{key:"onMouseUp",value:function(e){e.preventDefault(),this.isMouseOutside=!1,this._touchClick(e,1)}},{key:"onMouseLeave",value:function(e){e.preventDefault(),this.isMouseOutside&&(this._touchClick(e,1),this.isMouseOutside=!1)}},{key:"onMouseWheel",value:function(e){var t=Math.sign(e.deltaY),n=(e.preventDefault(),/(Win32|Win16|WinCE|Mac68K|MacIntel|MacIntel|MacPPC|Linux mips64)/i.test(navigator.platform)),r="ontouchstart"in window&&0this.processedConfig.maxModify?this.emit("MAXRECEIVE_BITRATE_STATUS",{type:"maxbitrate_Status",state:"failed",code:10054,maxdata:this.processedConfig.maxModify}):this.FunctionManager.setMaxBitrate(e):this.emit("MAXRECEIVE_BITRATE_STATUS",{type:"maxbitrate_Status",state:"failed",code:10053})}},{key:"setMaxBitrate",value:function(e){var t={"超清":(null==(t=this.processedConfig)?void 0:t.ultraClear)||2800,"高清":(null==(t=this.processedConfig)?void 0:t.highDefinition)||2200,"标清":(null==(t=this.processedConfig)?void 0:t.standardDefinition)||1500,"流畅":(null==(t=this.processedConfig)?void 0:t.smooth)||500}[e]||2800;this.FunctionManager.setBitrateMode(t)}},{key:"setCustomBitrate",value:function(e,t){this.FunctionManager.setCustomBitrate(e,t)}},{key:"setCardSize",value:function(e){this.FunctionManager.setCardSize(e)}},{key:"setEncoderSize",value:function(e){this.FunctionManager.setEncoderSize(e)}},{key:"setFps",value:function(e){this.streamParam.fps=e,this.RtcEngine(this.pubilcOptions)}},{key:"setMultiterminalLogin",value:function(e){this.FunctionManager.setMultiterminalLogin(e)}},{key:"ExexuteKeyBoard",value:function(e){this.FunctionManager.ExexuteKeyBoard(e)}},{key:"ExexuteChannel",value:function(e){this.FunctionManager.ExexuteChannel(e)}},{key:"openCameraStream",value:function(e){this.FunctionManager.openCameraStream(e)}},{key:"closeCameraStream",value:function(){this.FunctionManager.closeCameraStream()}},{key:"setControlAudio",value:function(e){this.FunctionManager.setControlAudio(e)}},{key:"setControlStream",value:function(e){this.FunctionManager.setControlStream(e)}},{key:"setMessageTransmission",value:function(e){this.FunctionManager.setMessageTransmission(e)}},{key:"KeyboardAddText",value:function(e){this.FunctionManager.KeyboardAddText(e)}},{key:"KeyboardDeleteText",value:function(e){this.FunctionManager.KeyboardDeleteText(e)}},{key:"removeKeyBoard",value:function(){this.player.removeKeyBoard()}},{key:"startApp",value:function(e){this.websocketProxy.startApp(e)}},{key:"stopApp",value:function(e){this.websocketProxy.stopApp(e)}},{key:"unInstallApp",value:function(e){this.websocketProxy.unInstallApp(e)}},{key:"hideApp",value:function(e){this.websocketProxy.hideApp(e)}},{key:"displayApp",value:function(e){this.websocketProxy.displayApp(e)}},{key:"rootApp",value:function(e){this.websocketProxy.rootApp(e)}},{key:"systemRoot",value:function(e){this.websocketProxy.systemRoot(e)}},{key:"virtualLocation",value:function(e){this.websocketProxy.virtualLocation(e)}},{key:"sysPreviewStart",value:function(e){this.websocketProxy.sysPreviewStart(e)}},{key:"sysPreviewStop",value:function(e){this.websocketProxy.sysPreviewStop(e)}},{key:"clipBoard",value:function(e){this.websocketProxy.clipBoard(e)}},{key:"sysResolution",value:function(e){this.websocketProxy.sysResolution(e)}},{key:"sysDpi",value:function(e){this.websocketProxy.sysDpi(e)}},{key:"enableApp",value:function(e){this.websocketProxy.enableApp(e)}},{key:"disableApp",value:function(e){this.websocketProxy.disableApp(e)}},{key:"cleanApp",value:function(e){this.websocketProxy.cleanApp(e)}},{key:"sysScreenshot",value:function(e){this.websocketProxy.sysScreenshot(e)}},{key:"sysGetScreenOrientation",value:function(e){this.websocketProxy.sysGetScreenOrientation(e)}},{key:"sysSetScreenOrientation",value:function(e){this.websocketProxy.sysSetScreenOrientation(e)}},{key:"sysGetBarStatus",value:function(e){this.websocketProxy.sysGetBarStatus(e)}},{key:"messageTransmissionApp",value:function(e){this.websocketProxy.messageTransmissionApp(e)}},{key:"EnableTextKeyboard",value:function(e){this.websocketProxy.EnableTextKeyboard(e)}},{key:"disableTextKeyboard",value:function(e){this.websocketProxy.disableTextKeyboard(e)}},{key:"addTextTransmission",value:function(e){this.websocketProxy.sysTextTransmission(e)}},{key:"deleteTextTransmission",value:function(e){this.websocketProxy.deleteTextTransmission(e)}},{key:"addInputTransmission",value:function(e){this.websocketProxy.sysInputTransmission(e)}},{key:"deleteInputTransmission",value:function(e){this.websocketProxy.deleteInputTransmission(e)}},{key:"sysHideBar",value:function(e){this.websocketProxy.sysHideBar(e)}},{key:"sysDisplayBar",value:function(e){this.websocketProxy.sysDisplayBar(e)}},{key:"previewApp",value:function(e){this.websocketProxy.previewApp(e)}},{key:"openSubscribeTopic",value:function(e){this.websocketProxy.openSubscribeTopic(e)}},{key:"unsubscribeTopic",value:function(e){this.websocketProxy.unsubscribeTopic(e)}},{key:"sysNewDevice",value:function(e){this.websocketProxy.sysSetprop(e)}},{key:"sysBlow",value:function(e){this.websocketProxy.sysSetBlow(e)}},{key:"sysShake",value:function(e){this.websocketProxy.sysSetShake(e)}},{key:"fileDownload",value:function(e){this.FileDownloader.downloadFile(e)}},{key:"fileUpload",value:function(e){this.FileUpload.upload(e)}},{key:"changeTouchMode",value:function(e){this.mediaElement&&this.mediaElement.toggleTouchMode(e)}},{key:"getCurrentTime",value:function(){return fe().format("HH:mm:ss")}},{key:"pushRecord",value:function(e){this.chatRecords.push(e),"sub"===e.type&&this.sub(e.data)}},{key:"querySubjects",value:function(){var e=this.pubilcConnection.topic;return e?JSON.parse(e):[]}},{key:"renderChatWindow",value:function(e){e={id:oe(),data:e.data,type:e.type,topic:e.topic,color:e.color,time:this.getCurrentTime()};this.pushRecord(e)}},{key:"start",value:function(){var e;this.publication.data=JSON.stringify(this.streamParam),null!=(e=this.mq)&&e.pub&&null!=(e=this.mq)&&e.pub("".concat(this.publication.topic,".media.").concat(this.subscriptionDat.topic),this.publication.data),this.renderChatWindow({topic:"".concat(this.publication.topic,".media.").concat(this.subscriptionDat.topic),type:this.publication.type,data:this.publication.data,color:this.publication.color})}},{key:"open",value:function(){this.streamParam.name=oe(),this.subscriptionDat.topic=this.streamParam.name,this.addSubscribe(JSON.parse(JSON.stringify(this.subscriptionDat)))}},{key:"subscription",value:function(){var t=this;this.querySubjects().forEach(function(e){t.subscribe(e)})}},{key:"addSubscribe",value:function(t){return!(0