diff --git a/videochat/dist/main.js b/videochat/dist/main.js index 3c020d8..3cb78b0 100644 --- a/videochat/dist/main.js +++ b/videochat/dist/main.js @@ -1,2 +1,2 @@ /*! For license information please see main.js.LICENSE.txt */ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("node-fetch"),require("form-data"));else if("function"==typeof define&&define.amd)define(["node-fetch","form-data"],t);else{var r="object"==typeof exports?t(require("node-fetch"),require("form-data")):t(e["node-fetch"],e["form-data"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,((e,t)=>(()=>{var r={1862:(e,t,r)=>{"use strict";e.exports.encode=function(e){return r.g.btoa(e)},e.exports.decode=function(e){return r.g.atob(e)}},5734:(e,t,r)=>{"use strict";const n=r(5251),s=r(7930),i=r(1192);e.exports.Client=n,e.exports.xml=s,e.exports.jid=i},5251:(e,t,r)=>{"use strict";const n=r(3073);class s extends n{constructor(e){super(e),this.transports=[]}send(e,...t){return this.Transport.prototype.send.call(this,e,...t)}_findTransport(e){return this.transports.find((t=>{try{return void 0!==t.prototype.socketParameters(e)}catch(e){return!1}}))}connect(e){const t=this._findTransport(e);if(!t)throw new Error("No compatible connection method found.");return this.Transport=t,this.Socket=t.prototype.Socket,this.Parser=t.prototype.Parser,super.connect(e)}socketParameters(...e){return this.Transport.prototype.socketParameters(...e)}header(...e){return this.Transport.prototype.header(...e)}headerElement(...e){return this.Transport.prototype.headerElement(...e)}footer(...e){return this.Transport.prototype.footer(...e)}footerElement(...e){return this.Transport.prototype.footerElement(...e)}}s.prototype.NS="jabber:client",e.exports=s},5150:e=>{"use strict";e.exports=function(e){return(e.split("://")[1]||e).split(":")[0].split("/")[0]}},3113:(e,t,r)=>{"use strict";const{xml:n,jid:s,Client:i}=r(5734),o=r(5150),a=r(6826),c=r(3312),l=r(5013),u=r(3323),d=r(3812),h=r(353),p=r(7127),f=r(7802),m=r(145),g=r(9717),y=r(7718),v=r(4767);e.exports.xml=n,e.exports.jid=s,e.exports.client=function(e={}){const{resource:t,credentials:r,username:n,password:s,...b}=e,{domain:S,service:C}=b;!S&&C&&(b.domain=o(C));const w=new i(b),k=a({entity:w}),_=c({entity:w}),x=l({entity:w}),I=u({middleware:x}),E=d({middleware:x,entity:w}),T=h({middleware:x,entity:w}),P=p({entity:w}),L=f({streamFeatures:I},r||{username:n,password:s}),D=m({iqCaller:E,streamFeatures:I},t),A=g({iqCaller:E,streamFeatures:I}),O=Object.entries({plain:v,anonymous:y}).map((([e,t])=>({[e]:t(L)})));return Object.assign(w,{entity:w,reconnect:k,websocket:_,middleware:x,streamFeatures:I,iqCaller:E,iqCallee:T,resolve:P,sasl:L,resourceBinding:D,sessionEstablishment:A,mechanisms:O})}},3073:(e,t,r)=>{"use strict";const{EventEmitter:n,promise:s}=r(3572),i=r(1192),o=r(7930),a=r(3611),{parseHost:c,parseService:l}=r(1473);class u extends n{constructor(e={}){super(),this.jid=null,this.timeout=2e3,this.options=e,this.socketListeners=Object.create(null),this.parserListeners=Object.create(null),this.status="offline",this.socket=null,this.parser=null,this.root=null}_reset(){this.jid=null,this.status="offline",this._detachSocket(),this._detachParser()}async _streamError(e,t){try{await this.send(o("stream:error",{},[o(e,{xmlns:"urn:ietf:params:xml:ns:xmpp-streams"},t)]))}catch(e){}return this._end()}_onData(e){const t=e.toString("utf8");this.emit("input",t),this.parser.write(t)}_onParserError(e){this._streamError("bad-format"),this._detachParser(),this.emit("error",e)}_attachSocket(e){const t=this.socket=e,r=this.socketListeners;r.data=this._onData.bind(this),r.close=(e,t)=>{this._reset(),this._status("disconnect",{clean:!e,event:t})},r.connect=()=>{this._status("connect")},r.error=e=>{this.emit("error",e)},t.on("close",r.close),t.on("data",r.data),t.on("error",r.error),t.on("connect",r.connect)}_detachSocket(){const{socketListeners:e,socket:t}=this;return Object.getOwnPropertyNames(e).forEach((r=>{t.removeListener(r,e[r]),delete e[r]})),this.socket=null,t}_onElement(e){this.emit("element",e),this.emit(this.isStanza(e)?"stanza":"nonza",e),"stream:error"===e.name&&this._onStreamError(e)}_onStreamError(e){const t=a.fromElement(e);"see-other-host"===t.condition?this._onSeeOtherHost(t):this.emit("error",t),this._end()}async _onSeeOtherHost(e){const{protocol:t}=l(this.options.service),r=e.element.getChildText("see-other-host"),{port:n}=c(r);let i;i=n?`${t||"xmpp:"}//${r}`:(t?`${t}//`:"")+r;try{await s(this,"disconnect");const{domain:e,lang:t}=this.options;await this.connect(i),await this.open({domain:e,lang:t})}catch(e){this.emit("error",e)}}_attachParser(e){const t=this.parser=e,r=this.parserListeners;r.element=this._onElement.bind(this),r.error=this._onParserError.bind(this),r.end=e=>{this._detachParser(),this._status("close",e)},r.start=e=>{this._status("open",e)},t.on("error",r.error),t.on("element",r.element),t.on("end",r.end),t.on("start",r.start)}_detachParser(){const e=this.parserListeners;Object.getOwnPropertyNames(e).forEach((t=>{this.parser.removeListener(t,e[t]),delete e[t]})),this.parser=null}_jid(e){return this.jid=i(e),this.jid}_status(e,...t){this.status=e,this.emit("status",e,...t),this.emit(e,...t)}async _end(){let e;try{e=await this.close()}catch(e){}try{await this.disconnect()}catch(e){}return e}async start(){if("offline"!==this.status)throw new Error("Connection is not offline");const{service:e,domain:t,lang:r}=this.options;await this.connect(e);const n=s(this,"online");return await this.open({domain:t,lang:r}),n}async connect(e){this._status("connecting",e);const t=new this.Socket;return this._attachSocket(t),t.connect(this.socketParameters(e)),s(t,"connect")}async disconnect(e=this.timeout){this.socket&&this._status("disconnecting"),this.socket.end(),await s(this.socket,"close","error",e)}async open(e){this._status("opening"),"string"==typeof e&&(e={domain:e});const{domain:t,lang:r,timeout:n=this.timeout}=e,i=this.headerElement();return i.attrs.to=t,i.attrs["xml:lang"]=r,this.root=i,this._attachParser(new this.Parser),await this.write(this.header(i)),s(this,"open","error",n)}async stop(){const e=await this._end();return"offline"!==this.status&&this._status("offline",e),e}async close(e=this.timeout){const t=Promise.all([s(this.parser,"end","error",e),this.write(this.footer(this.footerElement()))]);this.parser&&this.socket&&this._status("closing");const[r]=await t;return this.root=null,r}async restart(){this._detachParser();const{domain:e,lang:t}=this.options;return this.open({domain:e,lang:t})}async send(e){e.parent=this.root,this.emit("outgoing",e),await this.write(e),this.emit("send",e)}sendReceive(e,t=this.timeout){return Promise.all([this.send(e),s(this,"element","error",t)]).then((([,e])=>e))}write(e){return new Promise(((t,r)=>{if("closing"===this.status)return void r(new Error("Connection is closing"));const n=e.toString("utf8");this.socket.write(n,(e=>{if(e)return r(e);this.emit("output",n),t()}))}))}isStanza(e){const{name:t}=e;return"iq"===t||"message"===t||"presence"===t}isNonza(e){return!this.isStanza(e)}header(e){return e.toString()}headerElement(){return new o.Element("",{version:"1.0",xmlns:this.NS})}footer(e){return e.toString()}footerElement(){}socketParameters(){}}u.prototype.NS="",u.prototype.Socket=null,u.prototype.Parser=null,e.exports=u},3611:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(...e){super(...e),this.name="StreamError"}}},1473:e=>{"use strict";function t(e){let{port:t,hostname:r,protocol:n}=new URL(e);return"[::1]"===r&&(r="::1"),{port:t,hostname:r,protocol:n}}function r(e){const{port:r,hostname:n}=t(`http://${e}`);return{port:r,hostname:n}}Object.assign(e.exports,{parseURI:t,parseHost:r,parseService:function(e){return e.includes("://")?t(e):r(e)}})},2649:e=>{"use strict";class t extends Error{constructor(e,t,r){super(e+(t?` - ${t}`:"")),this.name="XMPPError",this.condition=e,this.text=t,this.application=r}static fromElement(e){const[t,r,n]=e.children;let s,i;r&&(r.is("text")?s=r:r&&(i=r),n&&(i=n));const o=new this(t.name,s?s.text():"",i);return o.element=e,o}}e.exports=t},3572:(e,t,r)=>{"use strict";const n=r(5407),s=r(9639),i=r(6585),o=r(7989),a=r(7007),c=r(4845);t.EventEmitter=a,t.timeout=n,t.delay=s,t.TimeoutError=i,t.promise=o,t.Deferred=c},4845:e=>{"use strict";e.exports=function(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},6585:e=>{"use strict";e.exports=class extends Error{constructor(e){super(e),this.name="TimeoutError"}}},9639:e=>{"use strict";e.exports=function(e){let t;const r=new Promise((r=>{t=setTimeout(r,e)}));return r.timeout=t,r}},7989:(e,t,r)=>{"use strict";const n=r(6585);e.exports=function(e,t,r="error",s){return new Promise(((i,o)=>{let a;const c=()=>{clearTimeout(a),e.removeListener(t,u),e.removeListener(r,l)};function l(e){o(e),c()}function u(e){i(e),c()}e.once(t,u),r&&e.once(r,l),s&&(a=setTimeout((()=>{c(),o(new n)}),s))}))}},5407:(e,t,r)=>{"use strict";const n=r(6585),s=r(9639);e.exports=function(e,t){const r=s(t);return Promise.race([e.finally((function(){clearTimeout(r.timeout)})),r.then((()=>{throw new n}))])}},1208:e=>{"use strict";e.exports=function(){let e;for(;!e;)e=Math.random().toString(36).slice(2,12);return e}},353:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-stanzas";function i({stanza:e}){return n("iq",{to:e.attrs.from,from:e.attrs.to,id:e.attrs.id})}function o(e,t,r){const n=i(e);return n.attrs.type="error",r&&n.append(r),n.append(t),n}function a(e,t){return n("error",{type:e},n(t,s))}function c(e,t,r,n){return function(s,i){return s.type!==e|!s.element||!s.element.is(r,t)?i():n(s,i)}}e.exports=function({middleware:e,entity:t}){return e.use(function(e){return async function(t,r){if(!function({name:e,type:t}){return"iq"===e&&"error"!==t&&"result"!==t}(t))return r();const{stanza:s}=t,c=s.getChildElements(),[l]=c;if(!function({type:e},t,r){return("get"===e||"set"===e)&&1===t.length&&!!r}(t,c,l))return o(t,a("modify","bad-request"),l);let u;t.element=l;try{u=await r()}catch(t){e.emit("error",t),u=a("cancel","internal-server-error")}return u||(u=a("cancel","service-unavailable")),u instanceof n.Element&&u.is("error")?o(t,u,l):function(e,t){const r=i(e);return r.attrs.type="result",t&&r.append(t),r}(t,u instanceof n.Element?u:void 0)}}(t)),{get(t,r,n){e.use(c("get",t,r,n))},set(t,r,n){e.use(c("set",t,r,n))}}}},3812:(e,t,r)=>{"use strict";const n=r(1208),s=r(6808),{Deferred:i}=r(3572),o=r(3572).timeout,a=r(7930);class c{constructor({entity:e,middleware:t}){this.handlers=new Map,this.entity=e,this.middleware=t}start(){this.middleware.use(this._route.bind(this))}_route({type:e,name:t,id:r,stanza:n},i){if(!function({name:e,type:t}){return"iq"===e&&("error"===t||"result"===t)}({name:t,type:e}))return i();const o=this.handlers.get(r);if(!o)return i();"error"===e?o.reject(s.fromElement(n.getChild("error"))):o.resolve(n),this.handlers.delete(r)}async request(e,t=3e4){e.attrs.id||(e.attrs.id=n());const r=new i;this.handlers.set(e.attrs.id,r);try{await this.entity.send(e),await o(r.promise,t)}catch(t){throw this.handlers.delete(e.attrs.id),t}return r.promise}_childRequest(e,t,r,...n){const{name:s}=t,{xmlns:i}=t.attrs;return this.request(a("iq",{type:e,to:r},t),...n).then((e=>e.getChild(s,i)))}async get(...e){return this._childRequest("get",...e)}async set(...e){return this._childRequest("set",...e)}}e.exports=function(...e){const t=new c(...e);return t.start(),t}},1192:(e,t,r)=>{"use strict";const n=r(3435),s=r(5294),i=r(1287);function o(...e){return e[1]||e[2]?new n(...e):i(...e)}(t=e.exports=o.bind()).jid=o,t.JID=n,t.equal=function(e,t){return e.equals(t)},t.detectEscape=s.detect,t.escapeLocal=s.escape,t.unescapeLocal=s.unescape,t.parse=i},3435:(e,t,r)=>{"use strict";const n=r(5294);class s{constructor(e,t,r){if("string"!=typeof t||!t)throw new TypeError("Invalid domain.");this.setDomain(t),this.setLocal("string"==typeof e?e:""),this.setResource("string"==typeof r?r:"")}[Symbol.toPrimitive](e){return"number"===e?NaN:this.toString()}toString(e){let t=this._domain;return this._local&&(t=this.getLocal(e)+"@"+t),this._resource&&(t=t+"/"+this._resource),t}bare(){return this._resource?new s(this._local,this._domain,null):this}equals(e){return this._local===e._local&&this._domain===e._domain&&this._resource===e._resource}setLocal(e,t){return(t=t||n.detect(e))&&(e=n.escape(e)),this._local=e&&e.toLowerCase(),this}getLocal(e){let t=null;return t=(e=e||!1)?n.unescape(this._local):this._local,t}setDomain(e){return this._domain=e.toLowerCase(),this}getDomain(){return this._domain}setResource(e){return this._resource=e,this}getResource(){return this._resource}}Object.defineProperty(s.prototype,"local",{get:s.prototype.getLocal,set:s.prototype.setLocal}),Object.defineProperty(s.prototype,"domain",{get:s.prototype.getDomain,set:s.prototype.setDomain}),Object.defineProperty(s.prototype,"resource",{get:s.prototype.getResource,set:s.prototype.setResource}),e.exports=s},5294:e=>{"use strict";e.exports.detect=function(e){return!!e&&-1!==e.replace(/\\20/g,"").replace(/\\22/g,"").replace(/\\26/g,"").replace(/\\27/g,"").replace(/\\2f/g,"").replace(/\\3a/g,"").replace(/\\3c/g,"").replace(/\\3e/g,"").replace(/\\40/g,"").replace(/\\5c/g,"").search(/\\| |"|&|'|\/|:|<|>|@/g)},e.exports.escape=function(e){return null===e?null:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(//g,"\\3e").replace(/@/g,"\\40").replace(/\3a/g,"c3a")},e.exports.unescape=function(e){return null===e?null:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")}},1287:(e,t,r)=>{"use strict";const n=r(3435);e.exports=function(e){let t,r;const s=e.indexOf("/");-1!==s&&(r=e.slice(s+1),e=e.slice(0,s));const i=e.indexOf("@");return-1!==i&&(t=e.slice(0,i),e=e.slice(i+1)),new n(t,e,r)}},5013:(e,t,r)=>{"use strict";const n=r(8287),s=r(6210),i=r(1600);function o(e,t,r){return function(s){const i=new r(e,s);return n(t)(i)}}function a(e){return function(t,r){r().then((t=>t&&e.send(t))).catch((t=>e.emit("error",t)))}}e.exports=function({entity:e}){const t=[a(e)],r=[],n=o(e,t,s),c=o(e,r,i);return e.on("element",n),e.hookOutgoing=c,{use:e=>(t.push(e),e),filter:e=>(r.push(e),e)}}},1354:e=>{"use strict";e.exports=class{constructor(e,t){this.stanza=t,this.entity=e;const{name:r,attrs:n}=t,{type:s,id:i}=n;this.name=r,this.id=i||"",this.type="message"===r?s||"normal":"presence"===r?s||"available":s||"",this.from=null,this.to=null,this.local="",this.domain="",this.resource=""}}},6210:(e,t,r)=>{"use strict";const n=r(1354),s=r(1192);e.exports=class extends n{constructor(e,t){super(e,t);const{jid:r,domain:n}=e,i=t.attrs.to||r&&r.toString(),o=t.attrs.from||n;i&&(this.to=new s(i)),o&&(this.from=new s(o),this.local=this.from.local,this.domain=this.from.domain,this.resource=this.from.resource)}}},1600:(e,t,r)=>{"use strict";const n=r(1354),s=r(1192);e.exports=class extends n{constructor(e,t){super(e,t);const{jid:r,domain:n}=e,i=t.attrs.from||r&&r.toString(),o=t.attrs.to||n;i&&(this.from=new s(i)),o&&(this.to=new s(o),this.local=this.to.local,this.domain=this.to.domain,this.resource=this.to.resource)}}},6808:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(e,t,r,n){super(e,t,r),this.type=n,this.name="StanzaError"}static fromElement(e){const t=super.fromElement(e);return t.type=e.attrs.type,t}}},6826:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(3572);class s extends n{constructor(e){super(),this.delay=1e3,this.entity=e,this._timeout=null}scheduleReconnect(){const{entity:e,delay:t,_timeout:r}=this;clearTimeout(r),this._timeout=setTimeout((async()=>{if("disconnect"===e.status)try{await this.reconnect()}catch(e){}}),t)}async reconnect(){const{entity:e}=this;this.emit("reconnecting");const{service:t,domain:r,lang:n}=e.options;await e.connect(t),await e.open({domain:r,lang:n}),this.emit("reconnected")}start(){const{entity:e}=this,t={};t.disconnect=()=>{this.scheduleReconnect()},this.listeners=t,e.on("disconnect",t.disconnect)}stop(){const{entity:e,listeners:t,_timeout:r}=this;e.removeListener("disconnect",t.disconnect),clearTimeout(r)}}e.exports=function({entity:e}){const t=new s(e);return t.start(),t}},7127:(e,t,r)=>{"use strict";const n=r(6119),{promise:s}=r(3572);async function i(e,t){if(0===t.length)throw new Error("Couldn't connect");const r=t.shift(),n=e._findTransport(r);if(!n)return i(e,t);e._status("connecting",r);const o=n.prototype.socketParameters(r),a=new n.prototype.Socket;try{a.connect(o),await s(a,"connect")}catch(r){return i(e,t)}e._attachSocket(a),a.emit("connect"),e.Transport=n,e.Socket=n.prototype.Socket,e.Parser=n.prototype.Parser}e.exports=function({entity:e}){const t=e.connect;e.connect=async function(r){if(!r||r.match(/:\/\//))return t.call(this,r);const s=function(e,t){return t.filter((t=>e._findTransport(t)))}(e,await async function(e){return[...new Set((await n(e,{srv:[{service:"xmpps-client",protocol:"tcp"},{service:"xmpp-client",protocol:"tcp"}]})).map((e=>e.uri)))]}(r));if(0===s.length)throw new Error("No compatible transport found.");try{await i(e,s)}catch(t){throw e._reset(),e._status("disconnect"),t}}}},8096:e=>{"use strict";function t(e){return e.startsWith("https")||e.startsWith("wss")}e.exports.U=function(e,r){let n,s;return n=t(e.uri)&&!t(r.uri)?-1:!t(e.uri)&&t(r.uri)?1:0,0!==n?n:(s=e.method===r.method?0:"websocket"===e.method?-1:"websocket"===r.method?1:"xbosh"===e.method?-1:"xbosh"===r.method?1:"httppoll"===e.method?-1:"httppoll"===r.method?1:0,0!==s?s:0)}},163:(e,t,r)=>{"use strict";const n=r.g.fetch||r(8849),s=r(3837),i=r(8096).U;e.exports.resolve=function(e){return n(`https://${e}/.well-known/host-meta`).then((e=>e.text())).then((e=>s(e).getChildren("Link").filter((e=>["urn:xmpp:alt-connections:websocket","urn:xmpp:alt-connections:httppoll","urn:xmpp:alt-connections:xbosh"].includes(e.attrs.rel))).map((({attrs:e})=>({rel:e.rel,href:e.href,method:e.rel.split(":").pop(),uri:e.href}))).sort(i))).catch((()=>[]))}},6119:(e,t,r)=>{"use strict";const n=r(2969),s=r(163);e.exports=function(...e){return Promise.all([n.resolve?n.resolve(...e):Promise.resolve([]),s.resolve(...e)]).then((([e,t])=>e.concat(t)))},n.resolve&&(e.exports.dns=n),e.exports.http=s},145:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-bind";async function i(e,t,r){const i=await t.set(function(e){return n("bind",{xmlns:s},e&&n("resource",{},e))}(r)),o=i.getChildText("jid");return e._jid(o),o}e.exports=function({streamFeatures:e,iqCaller:t},r){e.use("bind",s,function({iqCaller:e},t){return async function({entity:r},n){"function"==typeof t?await t((t=>i(r,e,t))):await i(r,e,t),n()}}({iqCaller:t},r))}},7718:(e,t,r)=>{"use strict";const n=r(3481);e.exports=function(e){e.use(n)}},4767:(e,t,r)=>{"use strict";const n=r(1978);e.exports=function(e){e.use(n)}},7802:(e,t,r)=>{"use strict";const{encode:n,decode:s}=r(1862),i=r(401),o=r(7930),a=r(5591),c="urn:ietf:params:xml:ns:xmpp-sasl";async function l(e,t,r,a){const l=e.create([r]);if(!l)throw new Error("No compatible mechanism");const{domain:u}=t.options,d={username:null,password:null,server:u,host:u,realm:u,serviceType:"xmpp",serviceName:u,...a};return new Promise(((e,r)=>{const a=u=>{if(u.attrs.xmlns===c)if("challenge"!==u.name)"failure"===u.name?r(i.fromElement(u)):"success"===u.name&&e(),t.removeListener("nonza",a);else{l.challenge(s(u.text()));const e=l.response(d);t.send(o("response",{xmlns:c,mechanism:l.name},"string"==typeof e?n(e):""))}};t.on("nonza",a),l.clientFirst&&t.send(o("auth",{xmlns:c,mechanism:l.name},n(l.response(d))))}))}e.exports=function({streamFeatures:e},t){const r=new a;return e.use("mechanisms",c,(async({stanza:e,entity:n})=>{const s=e.getChild("mechanisms",c).children.map((e=>e.text())),i=r._mechs.map((({name:e})=>e)).filter((e=>s.includes(e)));let o=i[0];"function"==typeof t?await t((e=>l(r,n,o,e)),o):(t.username||t.password||(o="ANONYMOUS"),await l(r,n,o,t)),await n.restart()})),{use:(...e)=>r.use(...e)}}},401:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(...e){super(...e),this.name="SASLError"}}},9717:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-session";e.exports=function({iqCaller:e,streamFeatures:t}){t.use("session",s,(async(t,r,i)=>(i.getChild("optional")||await e.set(n("session",s)),r())))}},3323:(e,t,r)=>{"use strict";const n=r(7342);e.exports=function({middleware:e}){return e.use(n()),{use:function(t,r,n){return e.use(((e,s)=>{const{stanza:i}=e;if(!i.is("features","http://etherx.jabber.org/streams"))return s();const o=i.getChild(t,r);return o?n(e,s,o):s()}))}}}},7342:e=>{"use strict";e.exports=function(){return async function({stanza:e,entity:t},r){if(!e.is("features","http://etherx.jabber.org/streams"))return r();await r(),t.jid&&t._status("online",t.jid)}}},3312:(e,t,r)=>{"use strict";const n=r(6174);e.exports=function({entity:e}){e.transports.push(n)}},6174:(e,t,r)=>{"use strict";const n=r(47),s=r(3073),i=r(7930),o=r(9558),a="urn:ietf:params:xml:ns:xmpp-framing";class c extends s{send(e,...t){return!e.attrs.xmlns&&super.isStanza(e)&&(e.attrs.xmlns="jabber:client"),super.send(e,...t)}footerElement(){return new i.Element("close",{xmlns:a})}headerElement(){const e=super.headerElement();return e.name="open",e.attrs.xmlns=a,e}socketParameters(e){return e.match(/^wss?:\/\//)?e:void 0}}c.prototype.Socket=n,c.prototype.NS="jabber:client",c.prototype.Parser=o,e.exports=c},9558:(e,t,r)=>{"use strict";const{Parser:n,Element:s,XMLError:i}=r(7930);e.exports=class extends n{onStartElement(e,t){const r=new s(e,t),{cursor:n}=this;n&&n.append(r),this.cursor=r}onEndElement(e){const{cursor:t}=this;e===t.name?t.parent?this.cursor=t.parent:(t.is("open","urn:ietf:params:xml:ns:xmpp-framing")?this.emit("start",t):t.is("close","urn:ietf:params:xml:ns:xmpp-framing")?this.emit("end",t):this.emit("element",t),this.cursor=null):this.emit("error",new i(`${t.name} must be closed.`))}}},47:(e,t,r)=>{"use strict";const n=r(732),s=r.g.WebSocket||n,i=r(7007),o="ECONNERROR";e.exports=class extends i{constructor(){super(),this.listeners=Object.create(null)}connect(e){this.url=e,this._attachSocket(new s(e,["xmpp"]))}_attachSocket(e){const t=this.socket=e,{listeners:r}=this;r.open=()=>{this.emit("connect")},r.message=({data:e})=>this.emit("data",e),r.error=e=>{let{error:t}=e;t||(t=new Error(`WebSocket ${o} ${this.url}`),t.errno=o,t.code=o),t.event=e,t.url=this.url,this.emit("error",t)},r.close=e=>{this._detachSocket(),this.emit("close",!e.wasClean,e)},t.addEventListener("open",r.open),t.addEventListener("message",r.message),t.addEventListener("error",r.error),t.addEventListener("close",r.close)}_detachSocket(){delete this.url;const{socket:e,listeners:t}=this;Object.getOwnPropertyNames(t).forEach((r=>{e.removeEventListener(r,t[r]),delete t[r]})),delete this.socket}end(){this.socket.close()}write(e,t){s===n?this.socket.send(e,t):(this.socket.send(e),t())}}},7930:(e,t,r)=>{"use strict";const n=r(118),s=r(7858),i=r(4063),{escapeXML:o,unescapeXML:a,escapeXMLText:c,unescapeXMLText:l}=r(8712),u=r(2037);t=e.exports=function(...e){return n(...e)},Object.assign(t,{x:n,Element:s,Parser:i,escapeXML:o,unescapeXML:a,escapeXMLText:c,unescapeXMLText:l,XMLError:u})},7858:(e,t,r)=>{"use strict";const n=r(8775);e.exports=class extends n{setAttrs(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach((function(t){if("__source"===t||"__self"===t)return;const r=e[t];null!=r&&(this.attrs[t.toString()]=r.toString())}),this)}append(e){return(e=Array.isArray(e)?e:[e]).forEach((e=>{this.children.push(e),"object"==typeof e&&(e.parent=this)})),this}prepend(e){return(e=Array.isArray(e)?e:[e]).forEach((e=>{this.children.unshift(e),"object"==typeof e&&(e.parent=this)})),this}}},4063:(e,t,r)=>{"use strict";const n=r(9416),s=r(7858),i=r(7007),o=r(2037);class a extends i{constructor(){super();const e=new n;this.root=null,this.cursor=null,e.on("startElement",this.onStartElement.bind(this)),e.on("endElement",this.onEndElement.bind(this)),e.on("text",this.onText.bind(this)),this.parser=e}onStartElement(e,t){const r=new s(e,t),{root:n,cursor:i}=this;n?i!==n&&i.append(r):(this.root=r,this.emit("start",r)),this.cursor=r}onEndElement(e){const{root:t,cursor:r}=this;if(e===r.name){if(r!==t)return r.parent?void(this.cursor=r.parent):(r.parent=t,this.emit("element",r),void(this.cursor=t));this.emit("end",t)}else this.emit("error",new o(`${r.name} must be closed.`))}onText(e){const{cursor:t}=this;t?t.t(e):this.emit("error",new o(`${e} must be a child.`))}write(e){this.parser.write(e)}end(e){e&&this.parser.write(e)}}a.XMLError=o,e.exports=a},2037:e=>{"use strict";e.exports=class extends Error{constructor(...e){super(...e),this.name="XMLError"}}},3837:(e,t,r)=>{"use strict";const n=r(4063);e.exports=function(e){const t=new n;let r=null,s=null;if(t.on("start",(e=>{r=e})),t.on("element",(e=>{r.append(e)})),t.on("error",(e=>{s=e})),t.write(e),t.end(),s)throw s;return r}},118:(e,t,r)=>{"use strict";const n=r(7858);function s(e,t){!1!==t&&null!=t&&(t instanceof n?e.append(t):Array.isArray(t)?t.forEach((t=>s(e,t))):e.append(String(t)))}e.exports=function(e,t,...r){const i=new n(e,t);for(let e=0;e{const n=r(9028),s=r(330);e.exports=class{constructor(e){this.proxy=e}uploadAddressBook(e,t){if(!n.isArray(e))return void new Error("First parameter must be an Array.");const r={contacts:e};t&&(t.force&&(r.force=t.force),t.udid&&(r.udid=t.udid));const i={type:"POST",url:n.getUrl(s.urls.addressbook),data:r};return this.proxy.ajax(i)}get(e){const t={type:"GET",url:n.getUrl(s.urls.addressbook)};return e&&(t.data={udid:e}),this.proxy.ajax(t)}getRegisteredUsers(e){const t={type:"GET",url:n.getUrl(s.urls.addressbookRegistered)};return e&&(t.data={compact:1}),this.proxy.ajax(t)}}},9694:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e,this.webSessionCheckInterval=null}setSession(e){this.proxy.setSession(e)}getSession(){const e={type:"GET",url:s.getUrl(n.urls.session)};return new Promise(((t,r)=>{this.proxy.ajax(e).then((e=>{t(e.session)})).catch((e=>{r(e)}))}))}createSession(e){if(""===n.creds.appId||""===n.creds.authKey||""===n.creds.authSecret)throw new Error("Cannot create a new session without app credentials (app ID, auth key and auth secret)");const t=e&&e.hasOwnProperty("long")?n.urls.webSession:n.urls.session,r=s.generateCreateSessionParams(e);r.signature=s.signParams(r,n.creds.authSecret);const i={type:"POST",url:s.getUrl(t),data:r};return new Promise(((e,t)=>{this.proxy.ajax(i).then((t=>{const r=t.qr_code?t.qr_code:t.session;this.proxy.setSession(t.session),this.proxy.setCurrentUserId(t.session.user_id),e(r)})).catch((e=>{t(e)}))}))}destroySession(){const e={type:"DELETE",url:s.getUrl(n.urls.session),dataType:"text"};return new Promise(((t,r)=>{this.proxy.ajax(e).then((e=>{this.proxy.setSession(null),this.proxy.setCurrentUserId(null),t()})).catch((e=>{r(e)}))}))}createWebSession(e){return e||(e={long:0}),this.createSession(e)}checkWebSessionUntilUpgrade(e){const t=n.webSession.getSessionTimeInterval,r=new Error("The web session check interval was stopped (timeout)");let s=n.webSession.getSessionTimeout;const i=()=>{this.webSessionCheckInterval&&clearInterval(this.webSessionCheckInterval)};return i(),this.webSessionCheckInterval=setInterval((()=>{this.getSession().then((n=>{0!==n.user_id?(i(),this.proxy.setCurrentUserId(n.user_id),this.proxy.setSession(n),e(null,n)):s>t?s-=t:(i(),e(r,null))})).catch((t=>{i(),e(t,null)}))}),1e3*t),this.webSessionCheckInterval}upgradeWebSession(e){const t={type:"PATCH",url:s.getUrl(n.urls.webSession),dataType:"text",data:{web_token:e}};return this.proxy.ajax(t)}login(e){const t={type:"POST",url:s.getUrl(n.urls.login),data:e};return new Promise(((e,r)=>{this.proxy.ajax(t).then((t=>{this.proxy.setCurrentUserId(t.user.id),e(t.user)})).catch((e=>{r(e)}))}))}logout(){const e={type:"DELETE",url:s.getUrl(n.urls.login),dataType:"text"};return this.proxy.setCurrentUserId(null),this.proxy.ajax(e)}}},330:(e,t,r)=>{const n={version:r(2122).rE,creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.connectycube.com",chat:"chat.connectycube.com",muc:"muc.chat.connectycube.com"},hash:"sha1",chatProtocol:{bosh:"https://chat.connectycube.com:5281",websocket:"wss://chat.connectycube.com:5291",active:2},webSession:{getSessionTimeInterval:3,getSessionTimeout:120},chat:{contactList:{subscriptionMode:{mutual:!0}},streamManagement:{enable:!1},ping:{enable:!1,timeInterval:60},reconnect:{enable:!0,timeInterval:5}},videochat:{alwaysRelayCalls:!1,answerTimeInterval:60,dialingTimeInterval:5,disconnectTimeInterval:30,statsReportTimeInterval:!1,iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:turn.connectycube.com"},{urls:"turn:turn.connectycube.com:5349?transport=udp",username:"connectycube",credential:"4c29501ca9207b7fb9c4b4b6b04faeb1"},{urls:"turn:turn.connectycube.com:5349?transport=tcp",username:"connectycube",credential:"4c29501ca9207b7fb9c4b4b6b04faeb1"}]},conference:{server:"wss://janus.connectycube.com:8989"},whiteboard:{server:"https://whiteboard.connectycube.com"},urls:{session:"session",webSession:"session/web",login:"login",users:"users",chat:"chat",blobs:"blobs",subscriptions:"subscriptions",events:"events",data:"data",addressbook:"address_book",addressbookRegistered:"address_book/registered_users",meetings:"meetings",whiteboards:"whiteboards",calls:"calls",type:".json"},on:{sessionExpired:null,xmppDataWrite:null,xmppDataRead:null},timeout:null,debug:{mode:0},set:function(e){"object"==typeof e.endpoints&&e.endpoints.chat&&(n.endpoints.muc="muc."+e.endpoints.chat,n.chatProtocol.bosh="https://"+e.endpoints.chat+":5281",n.chatProtocol.websocket="wss://"+e.endpoints.chat+":5291"),Object.keys(e).forEach((function(t){"set"!==t&&n.hasOwnProperty(t)&&("object"!=typeof e[t]?n[t]=e[t]:Object.keys(e[t]).forEach((function(r){n[t].hasOwnProperty(r)&&(n[t][r]=e[t][r])})))}))}};e.exports=n},0:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e}create(e,t){const r={type:"POST"};return s.isArray(t)?(r.url=s.getUrl(n.urls.data,`${e}/multi`),r.data={record:{}},t.forEach(((e,t)=>r.data.record[t]=e))):(r.url=s.getUrl(n.urls.data,e),r.data=t),this.proxy.ajax(r)}list(e,t={}){const r={};return"string"==typeof t?r.url=s.getUrl(n.urls.data,`${e}/${t}`):s.isArray(t)?r.url=s.getUrl(n.urls.data,`${e}/${t.toString()}`):s.isObject(t)&&(r.url=s.getUrl(n.urls.data,e),r.data=t),this.proxy.ajax(r)}readPermissions(e,t){const r={url:s.getUrl(n.urls.data,`${e}/${t}`),data:{permissions:1}};return this.proxy.ajax(r)}update(e,t={}){const r={type:"PUT"};return s.isArray(t)?(r.url=s.getUrl(n.urls.data,`${e}/multi`),r.data={record:{}},t.forEach(((e,t)=>{const n=e.id?e:{id:e._id,...e};r.data.record[t+1]=n}))):t.search_criteria?(r.url=s.getUrl(n.urls.data,`${e}/by_criteria`),r.data=t):(r.url=s.getUrl(n.urls.data,`${e}/${t._id||t.id}`),r.data=t),this.proxy.ajax(r)}delete(e,t){const r={type:"DELETE"};let i;return"string"==typeof t?i=1:s.isArray(t)?i=t.length>1?2:1:s.isObject(t)&&(i=3),1===i?(r.url=s.getUrl(n.urls.data,`${e}/${t}`),r.dataType="text"):2===i?r.url=s.getUrl(n.urls.data,`${e}/${t.toString()}`):3===i&&(r.url=s.getUrl(n.urls.data,`${e}/by_criteria`),r.data=t),this.proxy.ajax(r)}}},8009:(e,t,r)=>{const n=r(9028);let s,i,o,a,c,l,u,d,h,p,f,m,g=r(3113);n.getEnv().browser?(s=fetch,i=FormData,o=window.adapter,m=navigator,a=navigator.mediaDevices,c=window.MediaStream,l=window.MediaStreamTrack,h=window.RTCIceCandidate,u=window.RTCPeerConnection,d=window.RTCSessionDescription,p=window.RTCRtpReceiver,f=window.RTCRtpSender):n.getEnv().node&&(s=r(8849),i=r(6245)),e.exports={fetchImpl:s,formDataImpl:i,XMPPClient:g,adapter:o,mediaDevices:a,MediaStream:c,MediaStreamTrack:l,RTCIceCandidate:h,RTCPeerConnection:u,RTCRtpReceiver:p,RTCRtpSender:f,RTCSessionDescription:d,navigator:m}},9028:(e,t,r)=>{const n=r(330),s="undefined"!=typeof document,i="undefined"!=typeof navigator&&"ReactNative"==navigator.product,o="object"==typeof r.g&&(void 0!==r.g.android||void 0!==r.g.NSObject),a={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0};e.exports=class{static getEnv(){return{nativescript:o,reactnative:i,browser:s,node:!s&&!o&&!i}}static isRNWebRTCAvailble(){if(i&&"undefined"==typeof Expo){const{RTCView:e,RTCPeerConnection:t,RTCIceCandidate:n,RTCSessionDescription:s,MediaStream:i,mediaDevices:o}=r(8009);return e&&t&&n&&s&&i&&o}return!1}static isWebRTCAvailble(){return i&&this.isRNWebRTCAvailble()||s&&window.RTCPeerConnection&&window.RTCIceCandidate&&window.RTCSessionDescription}static safeCallbackCall(){const e=arguments[0];if("function"!=typeof e)return;const t=e.toString().split("(")[0].split(" ")[1],r=[];let n;for(let e=0;e16777215&&(a.increment=0),"00000000".substr(0,8-e.length)+e+"000000".substr(0,6-a.machine.length)+a.machine+"0000".substr(0,4-a.pid.length)+a.pid+"000000".substr(0,6-t.length)+t}static DLog(){if(this.loggers){for(let e=0;e{const n=r(330),s=r(9028);class i{constructor(){s.getEnv().reactnative&&s.isWebRTCAvailble()&&(this.RTCView=r(8009).RTCView)}init(e,t){t&&"object"==typeof t&&n.set(t);const i=r(5854),o=r(9694),a=r(8266),c=r(215),l=r(4002),u=r(0),d=r(1563),h=r(7999),p=r(3873),f=r(6462),m=r(611),g=r(8979);if(this.service=new i,this.auth=new o(this.service),this.users=new a(this.service),this.storage=new c(this.service),this.pushnotifications=new l(this.service),this.data=new u(this.service),this.addressbook=new d(this.service),this.chat=new h(this.service),this.chat.dialog=new p(this.service),this.chat.message=new f(this.service),this.meeting=new m(this.service),this.whiteboard=new g(this.service),this.utils=s,s.isWebRTCAvailble()){const e=r(5888),t=r(8852);this.videochat=new e(this.chat.xmppClient,this.service),this.videochatconference=new t(this.service),this.chat.webrtcSignalingProcessor=this.videochat.signalingProcessor}else this.videochat=null,this.videochatconference=null;e.token?(n.creds.appId=e.appId,this.service.setSession({token:e.token})):(n.creds.appId=e.appId,n.creds.authKey=e.authKey,n.creds.authSecret=e.authSecret)}setSession(e){this.auth.setSession(e)}getSession(){return this.auth.getSession()}createSession(e){return this.auth.createSession(e)}destroySession(){return this.auth.destroySession()}createWebSession(e){return this.auth.createWebSession(e)}checkWebSessionUntilUpgrade(e){return this.auth.checkWebSessionUntilUpgrade(e)}upgradeWebSession(e){return this.auth.upgradeWebSession(e)}login(e){return this.auth.login(e)}logout(){return this.auth.logout()}}const o=new i;o.ConnectyCube=i,e.exports=o},611:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.meetings;e.exports=class{constructor(e){this.proxy=e}get(e={}){const t={type:"GET",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e={}){const t=Math.ceil(Date.now()/1e3),r=t+3600,n={name:new Date(t).toLocaleString("en",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}),start_date:t,end_date:r,attendees:[],record:!1,chat:!1},o={type:"POST",url:s.getUrl(i),data:{...n,...e}};return this.proxy.ajax(o)}update(e,t){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e){const t={type:"DELETE",url:s.getUrl(i,e),dataType:"text"};return this.proxy.ajax(t)}getRecordings(e){const t={type:"GET",url:s.getUrl(i,`recordings/${e}`)};return this.proxy.ajax(t)}}},5854:(e,t,r)=>{const n=r(330),s=r(9028),i=r(8009).fetchImpl,o=r(8009).formDataImpl;e.exports=class{constructor(){this.sdkInstance={config:n,session:null},this.currentUserId=null,this.requestsNumber=0,this.fetchImpl=i,this.abortControllersMap={}}setSession(e){this.sdkInstance.session=e,e&&e.user_id&&this.setCurrentUserId(e.user_id)}getSession(){return this.sdkInstance.session}setCurrentUserId(e){this.currentUserId=e}getCurrentUserId(){return this.currentUserId}logRequest(e,t){s.DLog(`[Request][${t}]`,`${e.type||"GET"} ${e.url}`,e)}logResponse(e,t){s.DLog(`[Response][${t}]`,e)}buildRequestAndURL(e){const t=!e.type||"GET"===e.type||"HEAD"===e.type,r=e.type&&("POST"===e.type||"PUT"===e.type),s=this.sdkInstance&&this.sdkInstance.session&&this.sdkInstance.session.token,i=-1===e.url.indexOf("s3.amazonaws.com"),o=!1===e.contentType;let a,c=e.url;const l={};return l.method=e.type||"GET",e.data&&(a=this.buildRequestBody(e,o,r),t?c+="?"+a:l.body=a),o||(l.headers={"Content-Type":r?"application/json;charset=utf-8":"application/x-www-form-urlencoded; charset=UTF-8"}),i&&(l.headers||(l.headers={}),l.headers["CB-SDK"]="JS "+n.version+" - Client",s&&(l.headers["CB-Token"]=s)),n.timeout&&(l.timeout=n.timeout),[l,c]}buildRequestBody(e,t,r){const n=e.data,s=e.useArrayQuery;let i;return t?(i=new o,Object.keys(n).forEach((function(t){e.fileToCustomObject&&"file"===t?i.append(t,n[t].data,n[t].name):i.append(t,e.data[t])}))):i=r?JSON.stringify(n):this.serializeQueryParams(n,null,s,0),i}serializeQueryParams(e,t,r,n){n=n||0;const i=[];let o;for(o in e){let a=this.encodeURIComponent(o);s.isArray(e)&&(a="");const c=t?t+`[${a}]`:a;let l=e[o];const u=s.isArray(l);u&&(r||0===n)||s.isObject(l)?i.push(this.serializeQueryParams(l,c,r,++n)):(l=u?l.sort().join(","):l,i.push(`${c}=${this.encodeURIComponent(l)}`))}return i.sort().join("&")}encodeURIComponent(e){return encodeURIComponent(e).replace(/[#$&+,/:;=?@\[\]]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}abortRequest(e){if(this.abortControllersMap[e]){const t=this.abortControllersMap[e].controllers||{};Object.values(t).forEach((e=>{e.abort()}))}}processSuccessfulOrFailedRequest(e){if(!this.abortControllersMap[e])return;const t=this.abortControllersMap[e].controllers||{},r=Object.keys(t).length;this.abortControllersMap[e].doneRequestsCount?this.abortControllersMap[e].doneRequestsCount+=1:this.abortControllersMap[e].doneRequestsCount=1,this.abortControllersMap[e].doneRequestsCount===r&&delete this.abortControllersMap[e]}ajax(e){const t=++this.requestsNumber;return new Promise(((r,n)=>{this.logRequest(e,t);const s=this.buildRequestAndURL(e);let o=s[0];const a=s[1],c=e.abort_id;if(c){let e;if(this.abortControllersMap[c]){const t=this.abortControllersMap[c].controllers||[],r=Object.keys(t).length;this.abortControllersMap[c].controllers.push(new AbortController),e=r}else this.abortControllersMap[c]={controllers:[new AbortController]},e=0;const t=this.abortControllersMap[c].controllers[e].signal;o={...o,signal:t}}let l;i(a,o).then((t=>(l=t,"text"===(e.dataType||"json")?l.text():l.json()))).then((s=>{this.processSuccessfulOrFailedRequest(c),l.ok?this.processAjaxResponse(s,r,t):this.processAjaxError(l,s,null,n,r,e,t)})).catch((s=>{this.processSuccessfulOrFailedRequest(c),this.processAjaxError(l," ",s,n,r,e,t)}))}))}processAjaxResponse(e,t,r){const n=e&&" "!==e?e:"empty body";this.logResponse(n,r),t(e)}processAjaxError(e,t,r,i,o,a,c){if(!e&&r&&!r.code)return void i(r);const l=e&&(e.status||e.statusCode),u={code:e&&l||r&&r.code,info:(t&&"string"==typeof t&&" "!==t?JSON.parse(t):t)||r&&r.errno},d=t||r||t.errors;this.logResponse(d,c),-1===e.url.indexOf(n.urls.session)&&s.isExpiredSessionError(u)&&"function"==typeof n.on.sessionExpired?this.handleExpiredSessionResponse(u,null,i,o,a):i(u)}handleExpiredSessionResponse(e,t,r,s,i){n.on.sessionExpired((()=>{e?r(e):s(t)}),(e=>{e&&(this.setSession(e),this.ajax(i).then(s).catch(r))}))}}},4002:(e,t,r)=>{const n=r(330),s=r(9028);class i{constructor(e){this.proxy=e}create(e){const t={type:"POST",url:s.getUrl(n.urls.subscriptions),data:e};return this.proxy.ajax(t)}list(){const e={type:"GET",url:s.getUrl(n.urls.subscriptions)};return this.proxy.ajax(e)}delete(e){const t={type:"DELETE",dataType:"text",url:s.getUrl(n.urls.subscriptions,e)};return this.proxy.ajax(t)}}class o{constructor(e){this.proxy=e}create(e){const t={type:"POST",url:s.getUrl(n.urls.events),data:{event:e}};return this.proxy.ajax(t)}}e.exports=class{constructor(e){this.proxy=e,this.subscriptions=new i(e),this.events=new o(e),this.base64Encode=function(e){return s.toBase64(e)}}}},215:(e,t,r)=>{const n=r(330),s=r(9028);function i(e){const t=i.options,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={};let s=14;for(;s--;)n[t.key[s]]=r[s]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,r,s){r&&(n[t.q.name][r]=s)})),n}e.exports=class{constructor(e){this.proxy=e}list(e){const t={type:"GET",url:s.getUrl(n.urls.blobs),data:e};return this.proxy.ajax(t)}create(e){const t={type:"POST",url:s.getUrl(n.urls.blobs),data:{blob:e}};return this.proxy.ajax(t)}delete(e){const t={type:"DELETE",url:s.getUrl(n.urls.blobs,e),dataType:"text"};return this.proxy.ajax(t)}createAndUpload(e){const t=e.file,r=e.public,n=e.name||t.name,s=e.size||t.size,o=e.type||t.type,a=e.abort_id,c={name:n,content_type:o,public:r};let l;return this.create(c).then((({blob:e})=>{l=e;const r=i(l.blob_object_access.params),n={url:`${r.protocol}://${r.authority}${r.path}`,data:{}};return a&&(n.abort_id=a),Object.keys(r.queryKey).forEach((e=>{n.data[e]=decodeURIComponent(r.queryKey[e])})),n.data.file=t,this.upload(n).then((()=>l))})).then((e=>this.markUploaded({id:e.id,size:s}).then((()=>e)))).then((e=>({...e,size:s}))).catch((e=>{if(l)return{...l,size:s}}))}upload(e){const t={...e,type:"POST",dataType:"text",contentType:!1};return this.proxy.ajax(t)}markUploaded(e){const t={type:"PUT",url:s.getUrl(n.urls.blobs,e.id,"complete"),data:{size:e.size},dataType:"text"};return this.proxy.ajax(t)}getInfo(e){const t={url:s.getUrl(n.urls.blobs,e)};return this.proxy.ajax(t)}getFile(e){const t={url:s.getUrl(n.urls.blobs,e)};return this.proxy.ajax(t)}getFileObject(e,t){const r={type:"GET",url:s.getUrl(n.urls.blobs,e,"object"),data:t};return this.proxy.ajax(r)}update(e){const t={blob:{}};void 0!==e.name&&(t.blob.name=e.name);const r={url:s.getUrl(n.urls.blobs,e.id),data:t};return this.proxy.ajax(r)}privateUrl(e){return"https://"+n.endpoints.api+"/blobs/"+e+"?token="+this.proxy.getSession().token}publicUrl(e){return"https://"+n.endpoints.api+"/blobs/"+e}},i.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},8266:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e}getV2(e){const t={type:"GET",url:s.getUrl(`${n.urls.users}/v2`),data:e,useArrayQuery:!0};return this.proxy.ajax(t)}get(e){let t,r,c=s.cloneObject(e);const l=[];c.order&&(c.order=function(e){const t=e.field in i?"date":e.field in o?"number":"string";return[e.sort,t,e.field].join(" ")}(c.order)),c&&c.filter&&(s.isArray(c.filter)?c.filter.forEach((function(e){r=a(e),l.push(r)})):(r=a(c.filter),l.push(r)),c.filter=l),"number"==typeof c?(t=c,c={}):c.login?t="by_login":c.full_name?t="by_full_name":c.facebook_id?t="by_facebook_id":c.twitter_id?t="by_twitter_id":c.phone?t="phone":c.email?t="by_email":c.tags?t="by_tags":c.external&&(t="external/"+c.external,c={});const u={type:"GET",url:s.getUrl(n.urls.users,t),data:c};return this.proxy.ajax(u)}signup(e){const t={type:"POST",url:s.getUrl(n.urls.users),data:{user:e}};return this.proxy.ajax(t)}update(e){const t={type:"PUT",url:s.getUrl(n.urls.users,this.proxy.getCurrentUserId()),data:{user:e}};return this.proxy.ajax(t)}delete(){const e={type:"DELETE",url:s.getUrl(n.urls.users,this.proxy.getCurrentUserId()),dataType:"text"};return this.proxy.ajax(e)}resetPassword(e){const t={type:"GET",url:s.getUrl(n.urls.users+"/password/reset"),data:{email:e},dataType:"text"};return this.proxy.ajax(t)}};const i=["created_at","updated_at","last_request_at"],o=["id","external_user_id"];function a(e){const t=s.cloneObject(e);let r=i.includes(t.field)?"date":typeof t.value;return s.isArray(t.value)&&("object"===r&&(r=typeof t.value[0]),t.value=t.value.toString()),[r,t.field,t.param,t.value].join(" ")}},8979:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.whiteboards,o=n.whiteboard.server;e.exports=class{constructor(e){this.proxy=e}getURL({id:e,title:t,username:r}){return`${o}?whiteboardid=${e}&username=${r}&title=${t}`}get(e){const t={type:"GET",url:s.getUrl(i),data:"string"==typeof e?{chat_dialog_id:e}:e};return this.proxy.ajax(t)}create(e={}){const t={type:"POST",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}update(e,t={}){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e){const t={type:"DELETE",url:s.getUrl(i,e),dataType:"text"};return this.proxy.ajax(t)}}},7999:(e,t,r)=>{const n=r(330),s=r(9028),i=r(3173),o=r(1458),a=r(278),c=r(1341),l=r(9965),u=r(6349),d=r(8009).XMPPClient;e.exports=class{constructor(e){this.proxy=e,this.xmppClient=d.client({service:n.chatProtocol.websocket,credentials:(e,t)=>e({username:this.xmppClient.options.username,password:this.xmppClient.options.password})}),this.webrtcSignalingProcessor=null,this.stanzasCallbacks={},this.earlyIncomingMessagesQueue=[],this.isConnected=!1,this._isConnecting=!1,this._isLogout=!1,this._isReconnect=!1,this._checkPingTimer=void 0,this.helpers=new o,this.xmppClientListeners=[],this.connectPromise=null;var t={xmppClient:this.xmppClient,helpers:this.helpers,stanzasCallbacks:this.stanzasCallbacks};this.contactList=new c(t),this.privacylist=new l(t),this.muc=new u(t),n.chat.streamManagement.enable&&2===n.chatProtocol.active&&(this.streamManagement=new a,this._sentMessageCallback=(e,t)=>{"function"==typeof this.onSentMessageCallback&&(t?this.onSentMessageCallback(null,t):this.onSentMessageCallback(e))}),n.chat.reconnect.enable&&(this.xmppClient.reconnect.delay=1e3*n.chat.reconnect.timeInterval)}get connectionStatus(){return this.xmppClient.status}connect(e){return this.connectPromise=new Promise(((t,r)=>{if(s.DLog("[Chat]","Connect with parameter:",e),this._isConnecting)return s.DLog("[Chat]","Warning! Already in CONNECTING state"),void t();if(this.isConnected)return s.DLog("[Chat]","Warning! Chat is already connected!"),void t();this._isConnecting=!0,this._isLogout=!1,this.xmppClientListeners.forEach((e=>{this.xmppClient.removeListener(e.name,e.callback)}));const o=()=>{s.DLog("[Chat]",this._isReconnect?"RECONNECTING":"CONNECTING")};this.xmppClient.on("connect",o),this.xmppClientListeners.push({name:"connect",callback:o});const a=()=>{s.DLog("[Chat]","ONLINE"),this.startPingTimer(),this._postConnectActions(),t(),this.connectPromise=null};this.xmppClient.on("online",a),this.xmppClientListeners.push({name:"online",callback:a});const c=()=>{s.DLog("[Chat]","OFFLINE")};this.xmppClient.on("offline",c),this.xmppClientListeners.push({name:"offline",callback:c});const l=()=>{s.DLog("[Chat]","DISCONNECTED"),"function"==typeof this.onDisconnectedListener&&s.safeCallbackCall(this.onDisconnectedListener),n.chat.reconnect.enable?(this.isConnected=!1,this._isConnecting=!1):this.disconnect(),this.stopPingTimer()};this.xmppClient.on("disconnect",l),this.xmppClientListeners.push({name:"disconnect",callback:l});const u=(e,t)=>{s.DLog("[Chat]",`status - ${e}`,"object"==typeof t?JSON.stringify(t):""),"function"==typeof this.onChatStatusListener&&s.safeCallbackCall(this.onChatStatusListener,e)};this.xmppClient.on("status",u),this.xmppClientListeners.push({name:"status",callback:u});const d=e=>{if(e.is("message")&&!this.isConnected)return this.earlyIncomingMessagesQueue.push(e),void s.DLog("[Chat]","on 'stanza': enqueue incoming stanza (isConnected=false)");e.is("presence")?this._onPresence(e):e.is("iq")?this._onIQ(e):e.is("message")&&("headline"===e.attrs.type?this._onSystemMessageListener(e):"error"===e.attrs.type?this._onMessageErrorListener(e):this._onMessage(e))};this.xmppClient.on("stanza",d),this.xmppClientListeners.push({name:"stanza",callback:d});const h=e=>{s.DLog("[Chat]","ERROR:",e,{_isReconnect:this._isReconnect,connectPromise:!!this.connectPromise}),this.connectPromise?this._isReconnect||("SASLError"==e.name&&(e=e.condition),r(e),this.connectPromise=null):"function"==typeof this.onConnectionErrorListener&&s.safeCallbackCall(this.onConnectionErrorListener,e)};this.xmppClient.on("error",h),this.xmppClientListeners.push({name:"error",callback:h});const p=e=>{s.callTrafficUsageCallback("xmppDataWrite",{body:e}),s.DLog("[Chat]","SENT:",e)};this.xmppClient.on("output",p),this.xmppClientListeners.push({name:"output",callback:p});const f=e=>{s.callTrafficUsageCallback("xmppDataRead",{body:e}),s.DLog("[Chat]","RECV:",e)};this.xmppClient.on("input",f),this.xmppClientListeners.push({name:"input",callback:f}),this.xmppClient.options.username=i.buildUserJidLocalPart(e.userId),this.xmppClient.options.password=e.password,this.xmppClient.start().catch((e=>{console.error("[Chat] xmppClient.start error",e),this.connectPromise?(r(e),this.connectPromise=null):"function"==typeof this.onConnectionErrorListener&&s.safeCallbackCall(this.onConnectionErrorListener,e)}))})),this.connectPromise}getContacts(){return new Promise(((e,t)=>{this.contactList.get().then((t=>{this.contactList.contacts=t,e(t)})).catch((e=>{t(t)}))}))}ping(){return new Promise(((e,t)=>{const r={id:i.getUniqueId("ping"),to:n.endpoints.chat,type:"get"},s=i.createIqStanza(r);s.c("ping",{xmlns:"urn:xmpp:ping"}),this.stanzasCallbacks[r.id]=r=>{const n=i.getElement(r,"error");n?t(i.buildErrorFromXMPPErrorStanza(n)):e()},this.xmppClient.send(s)}))}pingWithTimeout(e=5e3){return Promise.race([this.ping(),new Promise(((t,r)=>setTimeout((()=>r(new Error("Chat ping() timed out"))),e)))])}startPingTimer(){if(this.stopPingTimer(),n.chat.ping.enable){const e=n.chat.ping.timeInterval<30?30:n.chat.ping.timeInterval;this._checkPingTimer=setInterval((()=>{this.ping()}),1e3*e)}}stopPingTimer(){this._checkPingTimer&&(clearInterval(this._checkPingTimer),this._checkPingTimer=null)}send(e,t){const r={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:t.type?t.type:this.helpers.typeChat(e),id:t.id?t.id:s.getBsonObjectId()};let o=i.createMessageStanza(r);return t.body&&o.c("body").t(t.body).up(),t.markable&&o.c("markable",{xmlns:"urn:xmpp:chat-markers:0"}).up(),t.extension&&(o.c("extraParams",{xmlns:"jabber:client"}),o=i.filledExtraParams(o,t.extension)),n.chat.streamManagement.enable?(t.id=r.id,this.xmppClient.send(o,t)):this.xmppClient.send(o),r.id}sendSystemMessage(e,t){const r={type:"headline",id:t.id?t.id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e)};let n=i.createMessageStanza(r);return t.body&&n.c("body").t(t.body).up(),t.extension&&(n.c("extraParams",{xmlns:"jabber:client"}).c("moduleIdentifier").t("SystemNotifications").up(),n=i.filledExtraParams(n,t.extension)),this.xmppClient.send(n),r.id}sendIsTypingStatus(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},r=i.createMessageStanza(t);r.c("composing",{xmlns:"http://jabber.org/protocol/chatstates"}),this.xmppClient.send(r)}sendIsStopTypingStatus(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},r=i.createMessageStanza(t);r.c("paused",{xmlns:"http://jabber.org/protocol/chatstates"}),this.xmppClient.send(r)}sendDeliveredStatus(e){const t={type:"chat",from:this.helpers.getUserCurrentJid(),id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e.userId)},r=i.createMessageStanza(t);r.c("received",{xmlns:"urn:xmpp:chat-markers:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}sendReadStatus(e){const t={type:"chat",from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.userId),id:s.getBsonObjectId()},r=i.createMessageStanza(t);r.c("displayed",{xmlns:"urn:xmpp:chat-markers:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}editMessage(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.to),type:this.helpers.typeChat(e.to),id:s.getBsonObjectId()};let r=i.createMessageStanza(t);r.c("body").t(e.body).up(),r.c("replace",{xmlns:"urn:xmpp:message-correct:0",id:e.originMessageId,last:e.last?"true":"false"}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),e.extension&&(r=i.filledExtraParams(r,e.extension)),this.xmppClient.send(r)}deleteMessage(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.to),type:this.helpers.typeChat(e.to),id:s.getBsonObjectId()},r=i.createMessageStanza(t);r.c("remove",{xmlns:"urn:xmpp:message-delete:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}getLastUserActivity(e){return new Promise(((t,r)=>{const n={from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("lastActivity"),to:this.helpers.jidOrUserId(e),type:"get"},s=i.createIqStanza(n);s.c("query",{xmlns:"jabber:iq:last"}),this.stanzasCallbacks[n.id]=e=>{const n=i.getElement(e,"error"),{userId:s,seconds:o}=this._onLastActivityStanza(e);n?r(i.buildErrorFromXMPPErrorStanza(e)):t({userId:s,seconds:o})},this.xmppClient.send(s)}))}_onLastActivityStanza(e){const t=i.getAttr(e,"from"),r=this.helpers.getUserIdFromJID(t),n=i.getElement(e,"query"),o=+i.getAttr(n,"seconds");return s.safeCallbackCall(this.onLastUserActivityListener,r,o),{userId:r,seconds:o}}markActive(){const e={id:this.helpers.getUniqueId("markActive"),type:"set"},t=i.createIqStanza(e);t.c("mobile",{xmlns:"http://tigase.org/protocol/mobile#v2",enable:"false"}),this.xmppClient.send(t)}markInactive(){const e={id:this.helpers.getUniqueId("markActive"),type:"set"},t=i.createIqStanza(e);t.c("mobile",{xmlns:"http://tigase.org/protocol/mobile#v2",enable:"true"}),this.xmppClient.send(t)}disconnect(){if(s.DLog("[Chat]","disconnect"),!this._isLogout)return this.muc.joinedRooms={},this.isConnected=!1,this._isConnecting=!1,this._isLogout=!0,this._isReconnect=!1,this.helpers.setUserCurrentJid(""),n.chat.streamManagement.enable&&this.streamManagement._removeElementHandler(),this.xmppClient.stop();s.DLog("[Chat]","Warning! Chat is already disconnected!")}search(e){let t=Object.assign({},e);t.start_date&&(t.start_date=new Date(t.start_date).toISOString()),t.end_date&&(t.end_date=new Date(t.end_date).toISOString()),s.isArray(t.chat_dialog_ids)&&(t.chat_dialog_ids=t.chat_dialog_ids.join(","));const r={type:"GET",url:s.getUrl(`${n.urls.chat}/search`),data:t};return this.proxy.ajax(r)}_onMessage(e){const t=i.getElementTreePath(e,["sent","forwarded","message"]),r=t||e,n=i.getAttr(r,"from"),o=i.getAttr(r,"type"),a=i.getAttr(r,"id"),c=i.getElement(r,"markable"),l=i.getElement(r,"received"),u=i.getElement(r,"displayed"),d=i.getElement(r,"replace"),h=i.getElement(r,"reactions"),p=i.getElement(r,"remove"),f=i.getElement(r,"composing"),m=i.getElement(r,"paused"),g=i.getElement(r,"invite"),y=i.getElement(r,"delay"),v=i.getElement(r,"extraParams"),b=i.getElementText(r,"body"),S=!!t,C=this.xmppClient.jid&&this.xmppClient.jid._resource||"";if("chat"===o&&-1!==n.indexOf(C))return!0;let w,k,_;_="chat"===o?i.getAttr(r,"to"):null,k=_?this.helpers.getUserIdFromJID(_):null;let x="groupchat"===o?this.helpers.getDialogIdFromJID(n):null,I="groupchat"===o?this.helpers.getIdFromResource(n):this.helpers.getUserIdFromJID(n),E=l||u||null;if(g)return!0;if(v&&(w=i.parseExtraParams(v),w.dialogId&&(x=w.dialogId)),f||m)return"function"!=typeof this.onMessageTypingListener||"chat"!==o&&"groupchat"!==o&&y||s.safeCallbackCall(this.onMessageTypingListener,!!f,I,x),!0;if(d)return"function"==typeof this.onMessageUpdateListener&&s.safeCallbackCall(this.onMessageUpdateListener,i.getAttr(d,"id"),"true"===i.getAttr(d,"last"),b,x,I,w?w.extension:null),!0;if(h){if(S&&"groupchat"===o)return!0;if("function"==typeof this.onMessageReactionsListener){const e=i.getAttr(h,"message_id"),t=+i.getAttr(h,"user_id"),{add:r,remove:n}=i.parseReactions(h),{dialogId:o}=w;s.safeCallbackCall(this.onMessageReactionsListener,e,t,o,r,n)}return!0}if(p)return"function"==typeof this.onMessageDeleteListener&&s.safeCallbackCall(this.onMessageDeleteListener,i.getAttr(p,"id"),x,I),!0;if(E)return void(l?"function"==typeof this.onDeliveredStatusListener&&"chat"===o&&s.safeCallbackCall(this.onDeliveredStatusListener,i.getAttr(l,"id"),x,I):"function"==typeof this.onReadStatusListener&&"chat"===o&&s.safeCallbackCall(this.onReadStatusListener,i.getAttr(u,"id"),x,I));if(c&&I!=this.helpers.getUserIdFromJID(this.helpers.userCurrentJid(this.xmppClient))){const e={messageId:a,userId:I,dialogId:x};this.sendDeliveredStatus(e)}const T={id:a,dialog_id:x,recipient_id:k,is_forwarded:S,type:o,body:b,extension:w?w.extension:null,delay:y};c&&(T.markable=1),"function"!=typeof this.onMessageListener||"chat"!==o&&"groupchat"!==o||s.safeCallbackCall(this.onMessageListener,I,T)}_onPresence(e){const t=i.getAttr(e,"from"),r=i.getAttr(e,"id"),n=i.getAttr(e,"type"),o=this.helpers.getUserIdFromJID(this.helpers.userCurrentJid(this.xmppClient)),a=i.getElement(e,"x");let c,l,u;if(a&&(c=i.getAttr(a,"xmlns"),l=i.getElement(a,"status"),l&&(u=i.getAttr(l,"code"))),c&&c.startsWith("http://jabber.org/protocol/muc")){if("error"===n)return void(r.endsWith(":join")&&"function"==typeof this.stanzasCallbacks[r]&&this.stanzasCallbacks[r](e));const c=this.helpers.getDialogIdFromJID(t),p=this.helpers.getUserIdFromRoomJid(t);if(l){if("301"==u){if("function"==typeof this.onKickOccupant){var d=i.getElement(i.getElement(a,"item"),"actor"),h=i.getAttr(d,"jid");s.safeCallbackCall(this.onKickOccupant,c,this.helpers.getUserIdFromJID(h))}return void delete this.muc.joinedRooms[this.helpers.getRoomJidFromRoomFullJid(t)]}if("unavailable"===n)return void(l&&"110"==u&&"function"==typeof this.stanzasCallbacks["muc:leave"]&&s.safeCallbackCall(this.stanzasCallbacks["muc:leave"],null));if(r.endsWith(":join")&&l&&"110"==u)return void("function"==typeof this.stanzasCallbacks[r]&&this.stanzasCallbacks[r](e))}else if(p!=o)return"unavailable"===n?void("function"==typeof this.onLeaveOccupant&&s.safeCallbackCall(this.onLeaveOccupant,c,parseInt(p))):void("function"==typeof this.onJoinOccupant&&s.safeCallbackCall(this.onJoinOccupant,c,parseInt(p)))}const p=this.helpers.getUserIdFromJID(t);let f=this.contactList.contacts[p];if(n)switch(n){case"subscribe":f&&"to"===f.subscription?(f?f.ask=null:f={ask:null},f.subscription="both",this.contactList._sendSubscriptionPresence({jid:t,type:"subscribed"})):"function"==typeof this.onSubscribeListener&&s.safeCallbackCall(this.onSubscribeListener,p);break;case"subscribed":f&&"from"===f.subscription?(f?f.ask=null:f={ask:null},f.subscription="both"):(f?f.ask=null:f={ask:null},f.subscription="to","function"==typeof this.onConfirmSubscribeListener&&s.safeCallbackCall(this.onConfirmSubscribeListener,p));break;case"unsubscribed":f?f.ask=null:f={ask:null},f.subscription="none","function"==typeof this.onRejectSubscribeListener&&s.safeCallbackCall(this.onRejectSubscribeListener,p);break;case"unsubscribe":f?f.ask=null:f={ask:null},f.subscription="to";break;case"unavailable":"function"==typeof this.onContactListListener&&f&&"none"!==f.subscription&&s.safeCallbackCall(this.onContactListListener,p,n),p===o&&this.xmppClient.send(i.createPresenceStanza())}else"function"==typeof this.onContactListListener&&f&&"none"!==f.subscription&&s.safeCallbackCall(this.onContactListListener,p)}_onIQ(e){const t=i.getAttr(e,"id");if(this.stanzasCallbacks[t])s.safeCallbackCall(this.stanzasCallbacks[t],e),delete this.stanzasCallbacks[t];else{const t=i.getAttr(e,"from"),r=i.getElement(e,"query");if(!t||!r)return;this._onLastActivityStanza(e)}}_onSystemMessageListener(e){const t=i.getElementTreePath(e,["sent","forwarded","message"])||e,r=i.getAttr(t,"from"),n=i.getAttr(t,"id"),o=i.getElement(t,"extraParams"),a=this.helpers.getUserIdFromJID(r),c=i.getElement(t,"delay"),l=i.getElementText(o,"moduleIdentifier"),u=i.getElementText(t,"body"),d=i.parseExtraParams(o);if("SystemNotifications"===l&&"function"==typeof this.onSystemMessageListener){const e={id:n,userId:a,body:u,extension:d.extension};s.safeCallbackCall(this.onSystemMessageListener,e)}else this.webrtcSignalingProcessor&&!c&&"WebRTCVideoChat"===l&&this.webrtcSignalingProcessor._onMessage(a,o)}_onMessageErrorListener(e){const t=i.getAttr(e,"id"),r=i.buildErrorFromXMPPErrorStanza(e);"function"==typeof this.onMessageErrorListener&&s.safeCallbackCall(this.onMessageErrorListener,t,r)}_postConnectActions(){s.DLog("[Chat]",this._isReconnect?"RECONNECTED":"CONNECTED");const e=i.createPresenceStanza();if(n.chat.streamManagement.enable&&2===n.chatProtocol.active&&(this.streamManagement.enable(this.xmppClient),this.streamManagement.sentMessageCallback=this._sentMessageCallback),this.helpers.setUserCurrentJid(this.helpers.userCurrentJid(this.xmppClient)),this.isConnected=!0,this._isConnecting=!1,this._enableCarbons(),this.xmppClient.send(e),this._isReconnect?"function"==typeof this.onReconnectListener&&s.safeCallbackCall(this.onReconnectListener):this._isReconnect=!0,this.earlyIncomingMessagesQueue.length>0){s.DLog("[Chat]",`Flush 'earlyIncomingMessagesQueue' (length=${this.earlyIncomingMessagesQueue.length})`);const e=this.xmppClientListeners.filter((e=>"stanza"===e.name))[0].callback;this.earlyIncomingMessagesQueue.forEach((t=>{e(t)})),this.earlyIncomingMessagesQueue=[]}}_enableCarbons(){const e={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("enableCarbons")},t=i.createIqStanza(e);t.c("enable",{xmlns:"urn:xmpp:carbons:2"}),this.xmppClient.send(t)}_setSubscriptionToUserLastActivity(e,t){var r={id:this.helpers.getUniqueId("statusStreaming"),type:"set"},n=i.createIqStanza(r);n.c("subscribe",{xmlns:"https://connectycube.com/protocol/status_streaming",user_jid:this.helpers.jidOrUserId(e),enable:t}),this.xmppClient.send(n)}subscribeToUserLastActivityStatus(e){this._setSubscriptionToUserLastActivity(e,!0)}unsubscribeFromUserLastActivityStatus(e){this._setSubscriptionToUserLastActivity(e,!1)}}},1458:(e,t,r)=>{const n=r(9028),s=r(330),i=r(3173);e.exports=class{constructor(){this._userCurrentJid=null}getUniqueId(e){return i.getUniqueId(e)}isNumeric(e){return/^-?\d+$/.test(e)||/^\d+\.\d+$/.test(e)}jidOrUserId(e){let t;return t="string"==typeof e?this.isNumeric(e)?this.getUserJid(e):e.includes("@")?e:this.getRoomJidFromDialogId(e):this.getUserJid(e),t}typeChat(e){let t;if("string"==typeof e)t=this.isNumeric(e)?"chat":e.includes("@")?e.includes("muc")?"groupchat":"chat":"groupchat";else{if("number"!=typeof e)throw new Error("Unsupported chat type");t="chat"}return t}getUserJid(e,t){return t?e+"-"+t+"@"+s.endpoints.chat:e+"-"+s.creds.appId+"@"+s.endpoints.chat}getUserNickWithMucDomain(e){return s.endpoints.muc+"/"+e}getUserIdFromJID(e){return e?.includes("@")?parseInt(e.split("@")[0].split("-")[0]):null}getDialogIdFromJID(e){return e?.includes("@")?e.split("@")[0].split("_")[1]:null}getRoomJidFromDialogId(e){return s.creds.appId+"_"+e+"@"+s.endpoints.muc}getRoomJid(e){return e+"/"+this.getUserIdFromJID(this._userCurrentJid)}getIdFromResource(e){let t=e.split("/");return t.length<2?null:(t.splice(0,1),parseInt(t.join("/")))}getRoomJidFromRoomFullJid(e){let t=e.split("/");return t.length<2?null:t[0]}getBsonObjectId(){return n.getBsonObjectId()}getUserIdFromRoomJid(e){let t=e.toString().split("/");return 0===t.length?null:t[t.length-1]}userCurrentJid(e){return e.jid._local+"@"+e.jid._domain+"/"+e.jid._resource}getUserCurrentJid(){return this._userCurrentJid}setUserCurrentJid(e){this._userCurrentJid=e}getDialogJid(e){return e.indexOf("@")>0?e:this.getRoomJidFromDialogId(e)}}},3173:(e,t,r)=>{r(9028);const n=r(330),s=r(8009).XMPPClient;e.exports=class{static buildUserJid(e){let t;return"userId"in e?(t=e.userId+"-"+n.creds.appId+"@"+n.endpoints.chat,"resource"in e&&(t=t+"/"+e.resource)):"jid"in e&&(t=e.jid),t}static buildUserJidLocalPart(e){return e+"-"+n.creds.appId}static createMessageStanza(e){return s.xml("message",e)}static createIqStanza(e){return s.xml("iq",e)}static createPresenceStanza(e){return s.xml("presence",e)}static createNonza(e,t){return s.xml(e,t)}static getAttr(e,t){if(!e)return null;let r;return"function"==typeof e.getAttribute?r=e.getAttribute(t):e.attrs&&(r=e.attrs[t]),r}static getElement(e,t){let r;return"function"==typeof e.querySelector?r=e.querySelector(t):"function"==typeof e.getChild&&(r=e.getChild(t)),r}static isErrorStanza(e){return!!e.getChild("error")}static getAllElements(e,t){let r;return"function"==typeof e.querySelectorAll?r=e.querySelectorAll(t):"function"==typeof e.getChild&&(r=e.getChild(t)),r}static getElementText(e,t){let r,n;return"function"==typeof e.querySelector?(r=e.querySelector(t),n=r?r.textContent:null):"function"==typeof e.getChildText&&(n=e.getChildText(t)),n}static getElementTreePath(e,t){return t.reduce(((e,t)=>e?this.getElement(e,t):e),e)}static _JStoXML(e,t,r){r=r.c(e),Object.keys(t).forEach((e=>{"object"==typeof t[e]?this._JStoXML(e,t[e],r):r=r.c(e).t(t[e]).up()})),r=r.up()}static _XMLtoJS(e,t,r){e[t]={};let n=r.childNodes||r.children;for(let r=0;r=1?e[t]=this._XMLtoJS(e[t],o,s):e[t][o]=a}return e}static filledExtraParams(e,t){return Object.keys(t).forEach((r=>{"attachments"===r?t[r].forEach((t=>{e.getChild("extraParams").c("attachment",t).up()})):"object"==typeof t[r]?this._JStoXML(r,t[r],e.getChild("extraParams")):e.getChild("extraParams").c(r).t(t[r]).up()})),e.up(),e}static parseExtraParams(e){if(!e)return null;let t,r,n,s={},i=[];for(let o=0,a=e.children.length;o0&&(s.attachments=i),s.moduleIdentifier&&delete s.moduleIdentifier,{extension:s,dialogId:t}}static buildErrorFromXMPPErrorStanza(e){const t=this.getElement(e,"error");return{code:parseInt(this.getAttr(t,"code")),info:this.getElementText(t,"text")}}static getUniqueId(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}static parseReactions(e){let t=e.children;return t=t.map((e=>({add:"true"===this.getAttr(e,"add"),remove:"true"===this.getAttr(e,"remove"),reaction:this.getAttr(e,"type")}))),t.reduce(((e,t)=>(t.add&&(e.add=t.reaction),t.remove&&(e.remove=t.reaction),e)),{})}}},1341:(e,t,r)=>{const n=r(3173),s=r(9028),i=r(330);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.contacts={},this.xmlns="jabber:iq:roster"}get(){return new Promise(((e,t)=>{const r=n.getUniqueId("getRoster");let s={},o=n.createIqStanza({type:"get",from:this.helpers.getUserCurrentJid(),id:r});o.c("query",{xmlns:this.xmlns}),this.stanzasCallbacks[r]=t=>{const r=t.getChild("query").children;for(let e=0,t=r.length;e{const s=e.userId||e,i=this.helpers.jidOrUserId(s),o=n.getUniqueId("addContactInRoster");let a=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:o});this.contacts[s]={subscription:"none",ask:"subscribe",name:e.name||null},a.c("query",{xmlns:this.xmlns}).c("item",{jid:i,name:e.name||null}),this.stanzasCallbacks[o]=()=>{this._sendSubscriptionPresence({jid:i,type:"subscribe"}),t()},this.xmppClient.send(a)}))}confirm(e){return new Promise(((t,r)=>{const n=e.userId||e,s=this.helpers.jidOrUserId(n);this._sendSubscriptionPresence({jid:s,type:"subscribed"}),i.chat.contactList.subscriptionMode.mutual?this.add(e,(function(){t()})):t()}))}reject(e){return new Promise(((t,r)=>{const n=this.helpers.jidOrUserId(e);this.contacts[e]={subscription:"none",ask:null},this._sendSubscriptionPresence({jid:n,type:"unsubscribed"}),t()}))}updateName(e){return new Promise(((t,r)=>{const i=this.helpers.jidOrUserId(e.userId),o=n.getUniqueId("updateContactInRoster");let a=this.contacts[e.userId];if(!s.isObject(a))return void r("No contact exists with provided user id");a.name=e.name||null;let c=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:o});c.c("query",{xmlns:this.xmlns}).c("item",{jid:i,name:e.name||null}),this.stanzasCallbacks[o]=e=>{"result"===e.attrs.type?t():r(e)},this.xmppClient.send(c)}))}remove(e){return new Promise(((t,r)=>{const s=this.helpers.jidOrUserId(e),i=n.getUniqueId("removeConactInRoster");let o=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:i});o.c("query",{xmlns:this.xmlns}).c("item",{jid:s,subscription:"remove"}),this.stanzasCallbacks[i]=()=>{delete this.contacts[e],t()},this.xmppClient.send(o)}))}_sendSubscriptionPresence(e){const t={to:e.jid,type:e.type},r=n.createPresenceStanza(t);this.xmppClient.send(r)}}},3873:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.chat+"/Dialog";e.exports=class{constructor(e){this.proxy=e}list(e){const t={type:"GET",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e){const t=s.cloneObject(e);t&&t.occupants_ids&&s.isArray(t.occupants_ids)&&(t.occupants_ids=t.occupants_ids.join(", "));const r={type:"POST",url:s.getUrl(i),data:t};return this.proxy.ajax(r)}update(e,t){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e,t){const r={type:"DELETE",url:s.getUrl(i,e)};return("string"==typeof e||s.isArray(e)&&1===e.length)&&(r.dataType="text"),t&&(r.data=t),this.proxy.ajax(r)}addAdmins(e,t){const r={push_all:{admins_ids:t}},n={type:"PUT",url:s.getUrl(i,e,"admins"),data:r};return this.proxy.ajax(n)}removeAdmins(e,t){const r={pull_all:{admins_ids:t}},n={type:"PUT",url:s.getUrl(i,e,"admins"),data:r};return this.proxy.ajax(n)}subscribe(e){const t={type:"POST",url:s.getUrl(i,e,"subscribe")};return this.proxy.ajax(t)}unsubscribe(e){const t={type:"DELETE",url:s.getUrl(i,e,"subscribe"),dataType:"text"};return this.proxy.ajax(t)}subscribeToPublic(e){return this.subscribe(e)}unsubscribeFromPublic(e){return this.unsubscribe(e)}updateNotificationsSettings(e,t){const r={enabled:t?1:0},n={type:"PUT",url:s.getUrl(i,e,"notifications"),data:r};return this.proxy.ajax(n)}getNotificationsSettings(e){const t={type:"GET",url:s.getUrl(i,e,"notifications")};return this.proxy.ajax(t)}getPublicOccupants(e,t){const r={type:"GET",url:s.getUrl(i,e,"occupants"),data:t};return this.proxy.ajax(r)}clearHistory(e){const t={type:"DELETE",url:s.getUrl(i,"clearHistory",e),dataType:"text"};return this.proxy.ajax(t)}}},6462:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.chat+"/Message";e.exports=class{constructor(e){this.proxy=e}list(e){const t={url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e){const t={url:s.getUrl(i),type:"POST",data:e};return this.proxy.ajax(t)}update(e,t){const r={type:"PUT",dataType:"text",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e,t={}){const r={url:s.getUrl(i,e),type:"DELETE",dataType:"text"};return t&&(r.data=t),this.proxy.ajax(r)}createSystem(e){const t={url:s.getUrl(i+"/system"),type:"POST",data:e};return this.proxy.ajax(t)}unreadCount(e){const t=s.cloneObject(e);t&&t.chat_dialog_ids&&s.isArray(t.chat_dialog_ids)&&(t.chat_dialog_ids=t.chat_dialog_ids.join(", "));const r={url:s.getUrl(i+"/unread"),data:t};return this.proxy.ajax(r)}listReactions(e){const t={type:"GET",dataType:"json",url:s.getUrl(i,e,"reactions"),data:{}};return this.proxy.ajax(t)}addReaction(e,t){return this.updateReaction(e,t)}removeReaction(e,t){return this.updateReaction(e,null,t)}updateReaction(e,t,r){const n={};t&&(n.add=t),r&&(n.remove=r);const o={type:"PUT",dataType:"text",url:s.getUrl(i,e,"reactions"),data:n};return this.proxy.ajax(o)}}},6349:(e,t,r)=>{const n=r(3173);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.joinedRooms={},this.xmlns="http://jabber.org/protocol/muc"}join(e){return new Promise(((t,r)=>{const s=n.getUniqueId("join"),i=this.helpers.getDialogJid(e),o={id:s,from:this.helpers.getUserCurrentJid(),to:this.helpers.getRoomJid(i)};let a=n.createPresenceStanza(o);a.c("x",{xmlns:this.xmlns}).c("history",{maxstanzas:0}),this.stanzasCallbacks[s]=e=>{const o=n.getAttr(e,"from"),a=(this.helpers.getDialogIdFromJID(o),n.getElement(e,"x")),c=n.getAttr(a,"xmlns"),l=n.getElement(a,"status"),u=n.getAttr(l,"code");if(l&&"110"==u)this.joinedRooms[i]=!0,t();else{const t=n.getAttr(e,"type");if(t&&"error"===t&&c===this.xmlns&&s.endsWith(":join")){const t=n.getElement(e,"error"),s=n.getAttr(t,"code"),i=n.getElementText(t,"text");r({code:s||500,message:i||"Unknown issue"})}}},this.xmppClient.send(a)}))}leave(e){return new Promise(((t,r)=>{const s=this.helpers.getDialogJid(e),i={type:"unavailable",from:this.helpers.getUserCurrentJid(),to:this.helpers.getRoomJid(s)},o=n.createPresenceStanza(i);delete this.joinedRooms[s],this.stanzasCallbacks["muc:leave"]=e=>{t()},this.xmppClient.send(o)}))}listOnlineUsers(e){return new Promise(((t,r)=>{const s={type:"get",to:this.helpers.getDialogJid(e),from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("muc_disco_items")};let i=n.createIqStanza(s);i.c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),this.stanzasCallbacks[s.id]=e=>{var r=e.attrs.id;if(this.stanzasCallbacks[r]){const r=e.getChild("query").getChildElements("item");let i=[];for(var n=0,s=r.length;n{const n=r(3173),s=r(9028);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.xmlns="jabber:iq:privacy"}create(e){return new Promise(((t,r)=>{let s,i,o,a,c,l={},u=[];for(let t=e.items.length-1;t>=0;t--){const r=e.items[t];l[r.user_id]={action:r.action,mutualBlock:!0===r.mutualBlock}}u=Object.keys(l);const d={type:"set",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("edit")};let h=n.createIqStanza(d);function p(e,t){return e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up(),e}function f(e,t){return e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up(),e}h.c("query",{xmlns:this.xmlns}).c("list",{name:e.name});for(let e=0,t=0,r=u.length;e{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(h)}))}getList(e){return new Promise(((t,r)=>{let s,i,o,a=[],c={};const l={type:"get",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("getlist")};let u=n.createIqStanza(l);u.c("query",{xmlns:this.xmlns}).c("list",{name:e}),this.stanzasCallbacks[l.id]=e=>{const r=e.getChild("query");c=r?r.getChild("list"):null,s=c?c.getChildElements("item"):null;for(let e=0,t=s.length;e{this.getList(e.name).then((n=>{const i={items:s.mergeArrays(n.items,e.items),name:e.name};this.create(i).then((()=>{t()})).catch((e=>{r(e)}))})).catch((e=>{r(e)}))}))}getNames(){return new Promise(((e,t)=>{const r={type:"get",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("getNames")};let s=n.createIqStanza(r);s.c("query",{xmlns:this.xmlns}),this.stanzasCallbacks[s.attrs.id]=r=>{if(n.isErrorStanza(r))t(n.buildErrorFromXMPPErrorStanza(r));else{const t=r.getChild("query"),n=t.getChild("default"),s=t.getChild("active"),i=t.getChildElements("list");let o=n?n.attrs.name:null,a=s?s.attrs.name:null,c=[];for(let e=0,t=i.length;e{const s={from:this.xmppClient.jid||this.xmppClient.jid.user,type:"set",id:n.getUniqueId("remove")};let i=n.createIqStanza(s);i.c("query",{xmlns:this.xmlns}).c("list",{name:e||""}),this.stanzasCallbacks[i.attrs.id]=e=>{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(i)}))}setAsDefault(e){return new Promise(((t,r)=>{const s={from:this.xmppClient.jid||this.xmppClient.jid.user,type:"set",id:n.getUniqueId("default")};let i=n.createIqStanza(s);i.c("query",{xmlns:this.xmlns}).c("default",e&&e.length>0?{name:e}:{}),this.stanzasCallbacks[i.attrs.id]=e=>{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(i)}))}}},278:(e,t,r)=>{const n=r(9028),s=r(3173);e.exports=class{constructor(){this._NS="urn:xmpp:sm:3",this._isStreamManagementEnabled=!1,this._clientProcessedStanzasCounter=0,this._clientSentStanzasCounter=0,this.sentMessageCallback=null,this._lastAck=0,this._xmppClient=null,this._originalSend=null,this._unackedQueue=[],this._incomingStanzaHandler=e=>{let t=e.name||e.tagName||e.nodeTree.tagName;if("enabled"!==t)if(s.getAttr(e,"xmlns")!==this._NS&&this._increaseReceivedStanzasCounter(),"r"!==t){if("a"===t){const t=parseInt(s.getAttr(e,"h"));this._checkCounterOnIncomeStanza(t)}}else{let e={xmlns:this._NS,h:this._clientProcessedStanzasCounter},t=s.createNonza("a",e);this._originalSend.call(this._xmppClient,t)}else this._isStreamManagementEnabled=!0}}enable(e){let t={xmlns:this._NS};this._isStreamManagementEnabled||(this._xmppClient=e,this._originalSend=this._xmppClient.send,this._xmppClient.send=this.send.bind(this)),this._clientProcessedStanzasCounter=0,this._clientSentStanzasCounter=0,this._lastAck=0,this._removeElementHandler(),this._addElementHandler();const r=s.createNonza("enable",t);this._xmppClient.send(r)}_removeElementHandler(){this._xmppClient.removeListener("element",this._incomingStanzaHandler)}_addElementHandler(){this._xmppClient.on("element",this._incomingStanzaHandler)}send(e,t){let r=e.name||e.tagName||e.nodeTree.tagName,n=s.getAttr(e,"type"),i=s.getElementText(e,"body")||"",o=s.getAllElements(e,"attachment")||"";this._originalSend.call(this._xmppClient,e),"message"!==r||"chat"!==n&&"groupchat"!==n||!i&&!o.length||this._sendStanzasRequest({message:t,expect:this._clientSentStanzasCounter}),++this._clientSentStanzasCounter}_sendStanzasRequest(e){if(this._isStreamManagementEnabled){this._unackedQueue.push(e);const t=s.createNonza("r",{xmlns:this._NS});this._originalSend.call(this._xmppClient,t)}}getClientSentStanzasCounter(){return this._clientSentStanzasCounter}_checkCounterOnIncomeStanza(e){const t=e-this._lastAck;n.DLog("[Chat][SM][_checkCounterOnIncomeStanza]",t,e,this._lastAck);for(let e=0;e0;e++)this.sentMessageCallback(null,this._unackedQueue.shift().message);this._lastAck=e}_increaseReceivedStanzasCounter(){++this._clientProcessedStanzasCounter}}},2555:(e,t,r)=>{const n=r(330),s=r(1366),i=r(8666).SessionConnectionState,o=r(8009).RTCPeerConnection,a=r(8009).RTCSessionDescription,c=r(8009).RTCIceCandidate,l=r(8009).MediaStream,u=r(8666).PeerConnectionState;o.prototype._init=function(e,t,r,n){s.trace("RTCPeerConnection init. userID: "+t+", sessionID: "+r+", type: "+n),this.delegate=e,this.sessionID=r,this.userID=t,this.type=n,this.remoteSDP=null,this.state=u.NEW,this.remoteStream=new l,this.ontrack=this.onAddRemoteMediaCallback.bind(this),this.onicecandidate=this.onIceCandidateCallback.bind(this),this.onsignalingstatechange=this.onSignalingStateCallback.bind(this),this.oniceconnectionstatechange=this.onIceConnectionStateCallback.bind(this),this.onStatusClosedChecker=void 0,this.dialingTimer=null,this.answerTimeInterval=0,this.statsReportTimer=null,this.iceCandidates=[],this.released=!1},o.prototype.release=function(){this._clearDialingTimer(),this._clearStatsReportTimer(),this.close(),s.getVersionSafari()>=11&&this.onIceConnectionStateCallback(),this.released=!0},o.prototype.updateRemoteSDP=function(e){if(!e)throw new Error("sdp string can't be empty.");this.remoteSDP=e},o.prototype.getRemoteSDP=function(){return this.remoteSDP},o.prototype.setRemoteSessionDescription=function(e,t){const r=new a({sdp:t,type:e});return this.setRemoteDescription(r)},o.prototype.getAndSetLocalSessionDescription=function(e,t={}){return new Promise(((r,n)=>{if(this.state=u.CONNECTING,"offer"===this.type)this.createOffer(t).then((t=>{this.setLocalDescription(t).then((n=>{this.setRTCRtpSenderMaxBandwidth(e),r(t)})).catch(n)})).catch(n);else{if(t.iceRestart)throw new Error("iceRestart is possible only from offer side");this.createAnswer(t).then((t=>{this.setLocalDescription(t).then((n=>{this.setRTCRtpSenderMaxBandwidth(e),r(t)})).catch(n)})).catch(n)}}))},o.prototype.setRTCRtpSenderMaxBandwidth=function(e){(this.getSenders()||[]).forEach((t=>{if("video"===t.track.kind){const r=t.getParameters();r.encodings||(r.encodings=[]),e?r.encodings[0].maxBitrate=1e3*e:delete r.encodings[0]?.maxBitrate,t.setParameters(r).then((()=>{s.trace("Set maxBandwidth success ["+this.userID+"]: "+e+" kbps")})).catch((e=>{s.trace("Set maxBandwidth error ["+this.userID+"]: "+e)}))}}))},o.prototype.addCandidates=function(e){for(let t=0,r=e.length;t{}),(e=>{s.traceError("Error on 'addIceCandidate': "+e)}))}},o.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", type: "+this.type+", state: "+this.state},o.prototype.onSignalingStateCallback=function(){s.trace("onSignalingStateCallback: "+this.signalingState),"stable"===this.signalingState&&this.iceCandidates.length>0&&(this.delegate._processIceCandidates(this,this.iceCandidates),this.iceCandidates.length=0)},o.prototype.onIceCandidateCallback=function(e){const t=e.candidate;if(t){const e={sdpMLineIndex:t.sdpMLineIndex,sdpMid:t.sdpMid,candidate:t.candidate};"stable"===this.signalingState?this.delegate._processIceCandidates(this,[e]):this.iceCandidates.push(e)}},o.prototype.onAddRemoteMediaCallback=function(e){"function"==typeof this.delegate._onRemoteStreamListener&&(this.remoteStream.addTrack(e.track),(1==this.delegate.callType&&this.remoteStream.getVideoTracks().length||2==this.delegate.callType&&this.remoteStream.getAudioTracks().length)&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream),this._getStatsWrap())},o.prototype.onIceConnectionStateCallback=function(){if(s.trace("onIceConnectionStateCallback: "+this.iceConnectionState),"function"==typeof this.delegate._onSessionConnectionStateChangedListener){let e=null;switch(s.getVersionSafari()>=11&&clearTimeout(this.onStatusClosedChecker),this.iceConnectionState){case"checking":this.state=u.CHECKING,e=i.CONNECTING;break;case"connected":this._clearWaitingReconnectTimer(),this.state=u.CONNECTED,e=i.CONNECTED;break;case"completed":this._clearWaitingReconnectTimer(),this.state=u.COMPLETED,e=i.COMPLETED;break;case"failed":this.state=u.FAILED,e=i.FAILED;break;case"disconnected":this._startWaitingReconnectTimer(),this.state=u.DISCONNECTED,e=i.DISCONNECTED,s.getVersionSafari()>=11&&(this.onStatusClosedChecker=setTimeout((()=>{this.onIceConnectionStateCallback()}),500));break;case"closed":this._clearWaitingReconnectTimer(),this.state=u.CLOSED,e=i.CLOSED}e&&this.delegate._onSessionConnectionStateChangedListener(this.userID,e)}},o.prototype._clearStatsReportTimer=function(){this.statsReportTimer&&(clearInterval(this.statsReportTimer),this.statsReportTimer=null)},o.prototype._getStatsWrap=function(){let e,t;if(n.videochat&&n.videochat.statsReportTimeInterval){if(isNaN(+n.videochat.statsReportTimeInterval))return void s.traceError("statsReportTimeInterval ("+n.videochat.statsReportTimeInterval+") must be integer.");e=1e3*n.videochat.statsReportTimeInterval;const r=()=>{!function(e,t,r,n){let i={local:{audio:{},video:{},candidate:{}},remote:{audio:{},video:{},candidate:{}}};if(s.getVersionFirefox()){let t=e.getLocalStreams().length?e.getLocalStreams()[0]:e.delegate.localStream,r=t.getVideoTracks().length?t.getVideoTracks()[0].getSettings():null;i.local.video.frameHeight=r&&r.height,i.local.video.frameWidth=r&&r.width}e.getStats(null).then((e=>{e.forEach((e=>{let r;e.bytesReceived&&"inbound-rtp"===e.type?(r=i.remote[e.mediaType],r.bitrate=o(e,t,!1),r.bytesReceived=e.bytesReceived,r.packetsReceived=e.packetsReceived,r.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(r.framesPerSecond=Math.round(10*e.framerateMean)/10)):e.bytesSent&&"outbound-rtp"===e.type?(r=i.local[e.mediaType],r.bitrate=o(e,t,!0),r.bytesSent=e.bytesSent,r.packetsSent=e.packetsSent,r.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(r.framesPerSecond=Math.round(10*e.framerateMean)/10)):"local-candidate"===e.type?(r=i.local.candidate,"host"===e.candidateType&&"udp"===e.mozLocalTransport&&"udp"===e.transport?(r.protocol=e.transport,r.ip=e.ipAddress,r.port=e.portNumber):s.getVersionFirefox()||(r.protocol=e.protocol,r.ip=e.ip,r.port=e.port)):"remote-candidate"===e.type?(r=i.remote.candidate,r.protocol=e.protocol||e.transport,r.ip=e.ip||e.ipAddress,r.port=e.port||e.portNumber):"track"!==e.type||"video"!==e.kind||s.getVersionFirefox()||(e.remoteSource?(r=i.remote.video,r.frameHeight=e.frameHeight,r.frameWidth=e.frameWidth,r.framesPerSecond=a(e,t,!1)):(r=i.local.video,r.frameHeight=e.frameHeight,r.frameWidth=e.frameWidth,r.framesPerSecond=a(e,t,!0)))})),r(i,e)}),n);const o=(e,t,r)=>{let n,s=t&&t.get(e.id),i=s?(e.timestamp-s.timestamp)/1e3:5;return n=s?r?8*(e.bytesSent-s.bytesSent)/(1024*i):8*(e.bytesReceived-s.bytesReceived)/(1024*i):0,Math.round(n)},a=(e,t,r)=>{let n,s=t&&t.get(e.id),i=s?(e.timestamp-s.timestamp)/1e3:5;return n=s?r?(e.framesSent-s.framesSent)/i:(e.framesReceived-s.framesReceived)/i:0,Math.round(10*n)/10}}(this,t,((e,r)=>{t=r,this.delegate._onCallStatsReport(this.userID,e,null)}),(e=>{s.traceError("_getStats error. "+e.name+": "+e.message),this.delegate._onCallStatsReport(this.userID,null,e)}))};s.trace("Stats tracker has been started."),this.statsReportTimer=setInterval(r,e)}},o.prototype._clearWaitingReconnectTimer=function(){this.waitingReconnectTimeoutCallback&&(s.trace("_clearWaitingReconnectTimer"),clearTimeout(this.waitingReconnectTimeoutCallback),this.waitingReconnectTimeoutCallback=null)},o.prototype._startWaitingReconnectTimer=function(){const e=1e3*n.videochat.disconnectTimeInterval;s.trace("_startWaitingReconnectTimer, timeout: "+e),this.waitingReconnectTimeoutCallback=setTimeout((()=>{s.trace("waitingReconnectTimeoutCallback"),clearTimeout(this.waitingReconnectTimeoutCallback),this.release(),this.delegate._closeSessionIfAllConnectionsClosed()}),e)},o.prototype._clearDialingTimer=function(){this.dialingTimer&&(s.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},o.prototype._startDialingTimer=function(e,t){const r=1e3*n.videochat.dialingTimeInterval;s.trace("_startDialingTimer, dialingTimeInterval: "+r);const i=(e,t,r)=>{r||(this.answerTimeInterval+=1e3*n.videochat.dialingTimeInterval),s.trace("_dialingCallback, answerTimeInterval: "+this.answerTimeInterval),this.answerTimeInterval>=1e3*n.videochat.answerTimeInterval?(this._clearDialingTimer(),t&&this.delegate._processOnNotAnswer(this)):this.delegate._processCall(this,e)};this.dialingTimer=setInterval(i,r,e,t,!1),i(e,t,!0)},e.exports=o},5888:(e,t,r)=>{const n=r(3191),s=r(5395),i=r(2382),o=r(1366),a=r(8666),c=r(8666).SessionState,l=r(9028),u=r(8009).mediaDevices,d=r(330);e.exports=class{constructor(e,t){this.connection=e,this.proxy=t,this.signalingProcessor=new s(this),this.signalingProvider=new i(e),this.SessionConnectionState=a.SessionConnectionState,this.PeerConnectionState=a.PeerConnectionState,this.CallType=a.CallType,this.sessions={},u&&(u.ondevicechange=this._onDevicesChangeListener.bind(this))}getMediaDevices(e){const t=[];return new Promise(((r,n)=>{u&&u.enumerateDevices?u.enumerateDevices().then((n=>{e?(n.forEach(((r,n)=>{r.kind===e&&t.push(r)})),r(t)):r(n)})):n("No 'enumerateDevices' API supported")}))}createNewSession(e,t){const r=o.getUserIdFromJID(o.userCurrentJid(this.connection));if(!e)throw new Error("Can't create a session without opponentsIDs.");return this._createAndStoreSession(null,r,e,t)}_createAndStoreSession(e,t,r,s,i){const a=new n({sessionID:e,initiatorID:t,opIDs:r,callType:s,signalingProvider:this.signalingProvider,currentUserID:o.getUserIdFromJID(o.userCurrentJid(this.connection)),maxBandwidth:i});return a.onUserNotAnswerListener=this.onUserNotAnswerListener,a.onRemoteStreamListener=this.onRemoteStreamListener,a.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,a.onSessionCloseListener=this.onSessionCloseListener,a.onCallStatsReport=this.onCallStatsReport,this.sessions[a.ID]=a,a}clearSession(e){delete this.sessions[e]}callRejectRequest(e){const t={type:"POST",url:l.getUrl(d.urls.calls,"reject"),data:{...e}};return this.proxy.ajax(t)}_onCallListener(e,t,r){const n=r.userInfo||{},s=+n.maxBandwidth||0;let i=this.sessions[t];o.trace("onCall. UserID:"+e+". SessionID: "+t+". extension: ",n),i?i._processOnCall(e,r):(i=this._createAndStoreSession(t,r.callerID,r.opponentsIDs,r.callType,s),i._processOnCall(e,r),l.safeCallbackCall(this.onCallListener,i,n))}_onAcceptListener(e,t,r){const n=this.sessions[t],s=r.userInfo||{};o.trace("onAccept. UserID:"+e+". SessionID: "+t),!n||n.state!==c.ACTIVE&&n.state!==c.NEW?o.traceWarning("Ignore 'onAccept', there is no information about session "+t):(l.safeCallbackCall(this.onAcceptCallListener,n,e,s),n._processOnAccept(e,r))}_onRejectListener(e,t,r){const n=this.sessions[t];if(o.trace("onReject. UserID:"+e+". SessionID: "+t),n){const t=r.userInfo||{};l.safeCallbackCall(this.onRejectCallListener,n,e,t),n._processOnReject(e,r)}else o.traceWarning("Ignore 'onReject', there is no information about session "+t)}_onStopListener(e,t,r){o.trace("onStop. UserID:"+e+". SessionID: "+t);const n=this.sessions[t],s=r.userInfo||{};!n||n.state!==c.ACTIVE&&n.state!==c.NEW?(l.safeCallbackCall(this.onInvalidEventsListener,"onStop",n,e,s),o.traceWarning("Ignore 'onStop', there is no information about session "+t+" by some reason.")):(n._processOnStop(e,r),l.safeCallbackCall(this.onStopCallListener,n,e,s))}_onIceCandidatesListener(e,t,r){const n=this.sessions[t];o.trace("onIceCandidates. UserID:"+e+". SessionID: "+t+". ICE candidates count: "+r.iceCandidates.length),n?n.state===c.ACTIVE?n._processOnIceCandidates(e,r):o.traceWarning("Ignore 'OnIceCandidates', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'OnIceCandidates', there is no information about session "+t)}_onIceRestartListener(e,t,r){const n=this.sessions[t];o.trace("onIceRestart. UserID:"+e+". SessionID: "+t),n?n.state===c.ACTIVE?n._processOnIceRestart(e,r):o.traceWarning("Ignore 'OnIceRestart', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'OnIceRestart', there is no information about session "+t)}_onIceRestartAcceptListener(e,t,r){const n=this.sessions[t];o.trace("onIceRestartAccept. UserID:"+e+". SessionID: "+t),n?n.state===c.ACTIVE?n._processOnIceRestartAccept(e,r):o.traceWarning("Ignore 'onIceRestartAccept', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'onIceRestartAccept', there is no information about session "+t)}_onDevicesChangeListener(){l.safeCallbackCall(this.onDevicesChangeListener)}}},8666:e=>{e.exports={SignalingConstants:{MODULE_ID:"WebRTCVideoChat",SignalingType:{CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",RESTART:"iceRestart",RESTART_ACCEPT:"iceRestartAccept",CANDIDATE:"iceCandidates"}},SessionConnectionState:{UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},SessionState:{NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5},PeerConnectionState:{NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},CallType:{VIDEO:1,AUDIO:2}}},1366:(e,t,r)=>{const n=r(330);e.exports=class{static getUserJid(e,t){return e+"-"+t+"@"+n.endpoints.chat}static getUserIdFromJID(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])}static userCurrentJid(e){return e.jid._local+"@"+e.jid._domain+"/"+e.jid._resource}static trace(e){n.debug&&console.log("[VideoChat]:",e)}static traceWarning(e){n.debug&&console.warn("[VideoChat]:",e)}static traceError(e){n.debug&&console.error("[VideoChat]:",e)}static getVersionFirefox(){const e=!!navigator&&navigator.userAgent;let t;if(e){const r=e.match(/(?:firefox)[ \/](\d+)/i)||[];t=r[1]?+r[1]:null}return t}static getVersionSafari(){const e=!!navigator&&navigator.userAgent;let t;if(e)if((e.match(/(?:safari)[ \/](\d+)/i)||[]).length){const r=e.match(/(?:version)[ \/](\d+)/i)||[];t=r&&r[1]?+r[1]:null}else t=null;return t}}},3191:(e,t,r)=>{const n=r(330),s=r(2555),i=r(9028),o=r(1366),a=r(8666).SignalingConstants,c=r(8666).SessionState,l=r(8666).PeerConnectionState,u=r(8009).mediaDevices;function d(e={}){const t={userInfo:e};try{i.isObject(e)?t.userInfo=i.cloneObject(e,!0):o.traceWarning("Ignore 'extension', must be an object.")}catch(e){o.traceWarning(e.message)}return t}function h(e){const t=i.cloneObject(e);return Object.keys(t).forEach(((e,r,n)=>{t[r].hasOwnProperty("url")?t[r].urls=t[r].url:t[r].url=t[r].urls})),t}e.exports=class{constructor(e){this.ID=e.sessionID?e.sessionID:function(){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}(),this.state=c.NEW,this.initiatorID=parseInt(e.initiatorID),this.opponentsIDs=e.opIDs,this.callType=parseInt(e.callType),this.peerConnections={},this.localStream=null,this.mediaParams=null,this.signalingProvider=e.signalingProvider,this.currentUserID=e.currentUserID,this.maxBandwidth=e.maxBandwidth,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0}getDisplayMedia(e){if(!u.getDisplayMedia)throw new Error("Your environment does not support 'getDisplayMedia' API");const t=e&&e.elementId,r=e&&e.options,n={...e};return this.mediaParams=n,delete n.elementId,delete n.options,u.getDisplayMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}getUserMedia(e){const t=e&&e.elementId,r=e&&e.options,n={...e};return this.mediaParams=n,delete n.elementId,delete n.options,u.getUserMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}_upsertStream(e,t,r){const n=!!this.localStream;n?(this.localStream.getTracks().forEach((t=>{"audio"===t.kind&&0===e.getAudioTracks().length||(t.stop(),this.localStream.removeTrack(t))})),this._replaceTracks(e)):this.localStream=e,t&&(n&&this.detachMediaStream(t,r),this.attachMediaStream(t,this.localStream,r))}_replaceTracks(e){const t=this.peerConnections;e.getTracks().forEach((e=>{"audio"===e.kind?e.enabled=this.localStream.getAudioTracks().every((e=>e.enabled)):e.enabled=this.localStream.getVideoTracks().every((e=>e.enabled))}));for(let r in t)t[r].getSenders().map((t=>{const r=e.getTracks().find((e=>e.kind===t.track.kind));r&&(t.replaceTrack(r),this.localStream.addTrack(r))}))}setMaxBandwidth(e){const t=this.peerConnections||[];if(t.length<1)o.trace("No 'RTCPeerConnection' to set 'maxBandwidth'");else for(let r in t)t[r].setRTCRtpSenderMaxBandwidth(e)}connectionStateForUser(e){const t=this.peerConnections[e];return t?t.state:null}attachMediaStream(e,t,r){const n=document.getElementById(e);if(!n)throw new Error("Unable to attach media stream, element "+e+" is undefined");"object"==typeof n.srcObject?n.srcObject=t:n.src=window.URL.createObjectURL(t),r&&r.muted&&(n.muted=!0),r&&r.mirror&&(n.style.webkitTransform="scaleX(-1)",n.style.transform="scaleX(-1)"),n.onloadedmetadata=function(e){n.play()}}detachMediaStream(e,t){const r=document.getElementById(e);if(!r)throw new Error("Unable to attach media stream, element "+e+" is undefined");r.pause(),"object"==typeof r.srcObject?r.srcObject=null:r.src="",t&&!t.mirror&&(r.style.webkitTransform="",r.style.transform="")}switchMediaTracks(e){return i.DLog("switchMediaTracks(deviceIds)",{deviceIds:e}),e&&e.audio&&("boolean"==typeof this.mediaParams.audio&&(this.mediaParams.audio={}),this.mediaParams.audio.deviceId=e.audio),e&&e.video&&("boolean"==typeof this.mediaParams.video&&(this.mediaParams.video={}),this.mediaParams.video.deviceId=e.video),this.localStream.getTracks().forEach((e=>{e.stop()})),u.getUserMedia({audio:this.mediaParams.audio||!1,video:this.mediaParams.video||!1}).then((e=>this._replaceTracks(e))).catch((e=>{throw new Error(e)}))}call(e){const t=d(e);o.trace("Call, extension: "+JSON.stringify(t)),this.state=c.ACTIVE,this.maxBandwidth=+t.userInfo.maxBandwidth||0,this.opponentsIDs.forEach(((e,r,n)=>{this._callInternal(e,t,!0)}))}_callInternal(e,t,r){const n=this._createPeer(e,"offer");this.localStream.getTracks().forEach((e=>{n.addTrack(e,this.localStream)})),this.peerConnections[e]=n,n.getAndSetLocalSessionDescription(this.maxBandwidth).then((()=>{o.trace("getAndSetLocalSessionDescription success"),n._startDialingTimer(t,r)})).catch((e=>{o.trace("getAndSetLocalSessionDescription error: "+e)}))}accept(e){const t=d(e);if(o.trace("Accept, extension: "+JSON.stringify(t.userInfo)),this.state===c.ACTIVE)return void o.traceError("Can't accept, the session is already active, return.");if(this.state===c.CLOSED)return o.traceError("Can't accept, the session is already closed, return."),void this.stop({});this.state=c.ACTIVE,this.acceptCallTime=new Date,this._clearAnswerTimer(),this._acceptInternal(this.initiatorID,t);const r=this._uniqueOpponentsIDsWithoutInitiator();if(r.length>0){const e=(this.acceptCallTime-this.startCallTime)/1e3;this._startWaitingOfferOrAnswerTimer(e),r.forEach((e=>{this.currentUserID>e&&this._callInternal(e,{},!0)}))}}_acceptInternal(e,t){const r=this.peerConnections[e];r?(this.localStream.getTracks().forEach((e=>{r.addTrack(e,this.localStream)})),r.setRemoteSessionDescription("offer",r.getRemoteSDP()).then((()=>{o.trace("'setRemoteSessionDescription' success"),r.getAndSetLocalSessionDescription(this.maxBandwidth).then((()=>{o.trace("'getAndSetLocalSessionDescription' success"),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,t.sdp=r.localDescription.sdp,this.signalingProvider.sendMessage(e,t,a.SignalingType.ACCEPT)})).catch((e=>{o.trace("'getAndSetLocalSessionDescription' error: "+e)}))})).catch((e=>{o.traceError("'setRemoteSessionDescription' error: "+e)}))):o.traceError("Can't accept the call, there is no information about peer connection by some reason.")}reject(e){const t=d(e);o.trace("Reject, extension: "+JSON.stringify(t.userInfo)),this.state=c.REJECTED,this._clearAnswerTimer(),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,Object.keys(this.peerConnections).forEach((e=>{const r=this.peerConnections[e];this.signalingProvider.sendMessage(r.userID,t,a.SignalingType.REJECT)})),this._close()}stop(e){const t=d(e);o.trace("Stop, extension: "+JSON.stringify(t.userInfo)),this.state=c.HUNGUP,this.answerTimer&&this._clearAnswerTimer(),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,Object.keys(this.peerConnections).forEach((e=>{const r=this.peerConnections[e];this.signalingProvider.sendMessage(r.userID,t,a.SignalingType.STOP)})),this._close()}canInitiateIceRestart(e){return"offer"===this.peerConnections[e].type}iceRestart(e){this.peerConnections[e].getAndSetLocalSessionDescription(this.maxBandwidth,{iceRestart:!0}).then((t=>{o.trace("[iceRestart][getAndSetLocalSessionDescription] Ok");const r={sessionID:this.ID,sdp:t.sdp};this.signalingProvider.sendMessage(e,r,a.SignalingType.RESTART)})).catch((e=>{o.trace("[iceRestart][getAndSetLocalSessionDescription] Error: "+e)}))}mute(e){this._muteStream(0,e)}unmute(e){this._muteStream(1,e)}_processOnCall(e,t){this._uniqueOpponentsIDs().forEach((r=>{const n=this.peerConnections[r];if(n)r==e&&(n.updateRemoteSDP(t.sdp),e!=this.initiatorID&&this.state===c.ACTIVE&&this._acceptInternal(e,{}));else{let n;n=r!=e&&this.currentUserID>r?this._createPeer(r,"offer"):this._createPeer(r,"answer"),this.peerConnections[r]=n,r==e&&(n.updateRemoteSDP(t.sdp),this._startAnswerTimer())}}))}_processOnAccept(e,t){const r=this.peerConnections[e];r?(r._clearDialingTimer(),r.setRemoteSessionDescription("answer",t.sdp).then((()=>{o.trace("'setRemoteSessionDescription' success")})).catch((e=>{o.traceError("'setRemoteSessionDescription' error: "+e)}))):o.traceWarning("Ignore 'OnAccept', there is no information about peer connection by some reason.")}_processOnReject(e,t){const r=this.peerConnections[e];this._clearWaitingOfferOrAnswerTimer(),r?r.release():o.traceWarning("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()}_processOnStop(e,t){if(this._clearAnswerTimer(),e===this.initiatorID){const e=Object.keys(this.peerConnections);e.length>0?e.forEach((e=>{this.peerConnections[e].release()})):o.traceWarning("Ignore 'OnStop', there is no information about peer connections by some reason.")}else{const t=this.peerConnections[e];t?t.release():o.traceWarning("Ignore 'OnStop', there is no information about peer connection by some reason.")}this._closeSessionIfAllConnectionsClosed()}_processOnIceCandidates(e,t){const r=this.peerConnections[e];r?r.addCandidates(t.iceCandidates):o.traceWarning("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")}_processOnIceRestart(e,t){const r=this.peerConnections[e];r?r.setRemoteSessionDescription("offer",t.sdp).then((()=>{o.trace("[_processOnIceRestart]'setRemoteSessionDescription' success"),r.getAndSetLocalSessionDescription(this.maxBandwidth).then((t=>{o.trace("[_processOnIceRestart]'getAndSetLocalSessionDescription' success");const r={sessionID:this.ID,sdp:t.sdp};this.signalingProvider.sendMessage(e,r,a.SignalingType.RESTART_ACCEPT)})).catch((e=>{o.trace("[_processOnIceRestart] 'getAndSetLocalSessionDescription' error: "+e)}))})).catch((e=>{o.traceError("[_processOnIceRestart] 'setRemoteSessionDescription' error: "+e)})):o.traceWarning("[_processOnIceRestart] Ignore 'OnIceRestart', there is no information about peer connection by some reason.")}_processOnIceRestartAccept(e,t){const r=this.peerConnections[e];r?r.setRemoteSessionDescription("answer",t.sdp).then((()=>{o.trace("[_processOnIceRestartAccept] 'setRemoteSessionDescription' success")})).catch((e=>{o.traceError("[_processOnIceRestartAccept] 'setRemoteSessionDescription' error: "+e)})):o.traceWarning("[_processOnIceRestartAccept] Ignore 'OnIceRestartAccept', there is no information about peer connection by some reason.")}_processCall(e,t){const r=t||{};r.sessionID=this.ID,r.callType=this.callType,r.callerID=this.initiatorID,r.opponentsIDs=this.opponentsIDs,r.sdp=e.localDescription.sdp,r.userInfo=t.userInfo||{},this.signalingProvider.sendMessage(e.userID,r,a.SignalingType.CALL)}_processIceCandidates(e,t){const r={};r.sessionID=this.ID,r.callType=this.callType,r.callerID=this.initiatorID,r.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(e.userID,t,r)}_processOnNotAnswer(e){o.trace("Answer timeout callback for session "+this.ID+" for user "+e.userID),this._clearWaitingOfferOrAnswerTimer(),e.release(),i.safeCallbackCall(this.onUserNotAnswerListener,this,e.userID),this._closeSessionIfAllConnectionsClosed()}_onRemoteStreamListener(e,t){i.safeCallbackCall(this.onRemoteStreamListener,this,e,t)}_onCallStatsReport(e,t,r){i.safeCallbackCall(this.onCallStatsReport,this,e,t,r)}_onSessionConnectionStateChangedListener(e,t){i.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e,t)}_createPeer(e,t){this.startCallTime=new Date;const r={iceServers:h(n.videochat.iceServers)};n.videochat.alwaysRelayCalls&&(r.iceTransportPolicy="relay"),o.trace("_createPeer, iceServers: "+JSON.stringify(r));const i=new s(r);return i._init(this,e,this.ID,t),i}_close(){Object.keys(this.peerConnections).forEach((e=>{const t=this.peerConnections[e];try{t.release()}catch(e){i.DLog("Peer close error:",e)}})),this._closeLocalMediaStream(),this.state=c.CLOSED,i.safeCallbackCall(this.onSessionCloseListener,this)}_closeSessionIfAllConnectionsClosed(){let e=!0;Object.keys(this.peerConnections).forEach((t=>{const r=this.peerConnections[t];let n;try{n="closed"===r.iceConnectionState||"closed"===r.signalingState||r.released?"closed":null}catch(e){o.traceError(e),n="closed"}"closed"!==n&&(e=!1)})),o.trace("All peer connections closed: "+e),e&&(this._closeLocalMediaStream(),i.safeCallbackCall(this.onSessionCloseListener,this),this.state=c.CLOSED)}_closeLocalMediaStream(){this.localStream&&(this.localStream.getAudioTracks().forEach((e=>{e.stop()})),this.localStream.getVideoTracks().forEach((e=>{e.stop()})),this.localStream=null)}_muteStream(e,t){"audio"===t&&this.localStream.getAudioTracks().length>0?this.localStream.getAudioTracks().forEach((t=>{t.enabled=!!e})):"video"===t&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach((t=>{t.enabled=!!e}))}_clearAnswerTimer(){this.answerTimer&&(o.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)}_startAnswerTimer(){o.trace("_startAnswerTimer");const e=1e3*n.videochat.answerTimeInterval;this.answerTimer=setTimeout((()=>{o.trace("_answerTimeoutCallback"),"function"==typeof this.onSessionCloseListener&&this._close(),this.answerTimer=null}),e)}_clearWaitingOfferOrAnswerTimer(){this.waitingOfferOrAnswerTimer&&(o.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)}_startWaitingOfferOrAnswerTimer(e){const t=n.videochat.answerTimeInterval-e<0?1:n.videochat.answerTimeInterval-e;o.trace("_startWaitingOfferOrAnswerTimer, timeout: "+t),this.waitingOfferOrAnswerTimer=setTimeout((()=>{o.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(this.peerConnections).forEach((e=>{const t=this.peerConnections[e];t.state!==l.CONNECTING&&t.state!==l.NEW||this._processOnNotAnswer(t)})),this.waitingOfferOrAnswerTimer=null}),1e3*t)}_uniqueOpponentsIDs(){const e=[];return this.initiatorID!==this.currentUserID&&e.push(this.initiatorID),this.opponentsIDs.forEach((t=>{t!=this.currentUserID&&e.push(parseInt(t))})),e}_uniqueOpponentsIDsWithoutInitiator(){const e=[];return this.opponentsIDs.forEach((t=>{t!=this.currentUserID&&e.push(parseInt(t))})),e}toString(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType}}},5395:(e,t,r)=>{const n=r(8666).SignalingConstants,s=r(3173);e.exports=class{constructor(e){this.delegate=e}_onMessage(e,t){const r=this._getExtension(t),s=r.sessionID,i=r.signalType;switch(delete r.moduleIdentifier,delete r.sessionID,delete r.signalType,i){case n.SignalingType.CALL:this.delegate._onCallListener(e,s,r);break;case n.SignalingType.ACCEPT:this.delegate._onAcceptListener(e,s,r);break;case n.SignalingType.REJECT:this.delegate._onRejectListener(e,s,r);break;case n.SignalingType.STOP:this.delegate._onStopListener(e,s,r);break;case n.SignalingType.CANDIDATE:this.delegate._onIceCandidatesListener(e,s,r);break;case n.SignalingType.RESTART:this.delegate._onIceRestartListener(e,s,r);break;case n.SignalingType.RESTART_ACCEPT:this.delegate._onIceRestartAcceptListener(e,s,r)}}_getExtension(e){if(!e)return null;let t,r,n,i={},o=[],a=[],c=e.childNodes||e.children;for(let e=0,l=c.length;e1)if((c[e].textContent||c[e].children[0]).length>4096){let e="";for(let t=0;t0&&(i.iceCandidates=o),a.length>0&&(i.opponentsIDs=a),i}}},2382:(e,t,r)=>{const n=r(1366),s=r(8666).SignalingConstants,i=r(9028),o=r(330),a=r(3173);e.exports=class{constructor(e){this.signalingConnection=e}sendCandidate(e,t,r){const n=r||{};n.iceCandidates=t,this.sendMessage(e,n,s.SignalingType.CANDIDATE)}sendMessage(e,t,r){const c=t||{};c.moduleIdentifier=s.MODULE_ID,c.signalType=r,c.platform="web",c.userInfo&&(Object.keys(c.userInfo).length?0===c.userInfo.maxBandwidth&&delete c.userInfo.maxBandwidth:delete c.userInfo);const l={to:n.getUserJid(e,o.creds.appId),type:"headline",id:i.getBsonObjectId()};let u=a.createMessageStanza(l).c("extraParams",{xmlns:"jabber:client"});Object.keys(c).forEach((e=>{"iceCandidates"===e?(u=u.c("iceCandidates"),c[e].forEach((e=>{u=u.c("iceCandidate"),Object.keys(e).forEach((t=>{u=u.c(t).t(e[t]).up()})),u=u.up()})),u=u.up()):"opponentsIDs"===e?(u=u.c("opponentsIDs"),c[e].forEach((e=>{u=u.c("opponentID").t(e).up()})),u=u.up()):"object"==typeof c[e]?a._JStoXML(e,c[e],u):u=u.c(e).t(c[e]).up()})),u=u.up(),this.signalingConnection.send(u)}}},936:(e,t,r)=>{const{EventEmitter:n}=r(2881),{MediaStream:s}=r(8009),i=r(9171),o=r(9028),a=r(330),{JANUS_EVENTS:c,JANUS_MEDIA_TRACKS_REASONS:l}=r(9454);e.exports={Client:class{constructor(e){if(!o.getEnv().reactnative&&!adapter)throw"Error: in order to use this library please connect adapter.js. More info https://github.com/webrtc/adapter";if(this.token=e.token,delete e.token,this.configs=e,!this.configs.server)throw"'server' parameter is mandatory.";this.configs.server.includes("http")&&(this.configs.server=this.configs.server+"/janus"),this.configs.debug||(this.configs.debug="all"),this.engine=null,this.videoRoomPlugin=null,this.isOnlyAudio=!1,this.currentRoomId=null,this.remoteFeeds={},this.remoteJseps={},this.remoteFeedsAttachingInProgress={},this.bitrateTimers={},this.emitter=new n}createSession(e){i.init({debug:this.configs.debug,callback:()=>{i.isWebrtcSupported()?this.engine=new i({server:this.configs.server,iceServers:a.videochat.iceServers,token:this.token,success:()=>{o.safeCallbackCall(e.success)},error:t=>{o.safeCallbackCall(e.error,t)},destroyed:()=>{o.safeCallbackCall(e.destroyed)},timeoutSessionCallback:()=>{o.safeCallbackCall(e.timeoutSessionCallback)}}):o.safeCallbackCall(e.error,"Your browser does not support WebRTC, so you can't use this functionality.")}})}getSessionId(){return this.engine?this.engine.getSessionId():null}destroySession(e){this.engine.destroy({}),o.safeCallbackCall(e.success)}attachVideoConferencingPlugin(e,t,r,n){let s=null;const i=n.localStream;delete n.localStream;const a=n.displayName;delete n.displayName,this.engine.attach({plugin:"janus.plugin.videoroom",success:r=>{if(e){s=r,s.userId=t,this.remoteFeedsAttachingInProgress[t]=s;const e={request:"join",room:this.currentRoomId,ptype:"listener",feed:t,display:a};s.send({message:e})}else this.videoRoomPlugin=r;o.safeCallbackCall(n.success)},error:e=>{o.safeCallbackCall(n.error,e)},consentDialog:e=>{o.safeCallbackCall(n.consentDialog,e)},mediaState:(e,t)=>{o.safeCallbackCall(n.mediaState,e,t)},webrtcState:e=>{o.safeCallbackCall(n.webrtcState,e)},slowLink:(e,t)=>{o.safeCallbackCall(n.slowLink,e,t)},iceState:e=>{o.safeCallbackCall(n.iceState,e)},onmessage:(t,s)=>{const a=t.videoroom;if(e){if(a)if("attached"===a){const e=t.id;this.remoteFeeds[e]=this.remoteFeedsAttachingInProgress[e],this.remoteFeedsAttachingInProgress[e]=null}else t.error&&o.safeCallbackCall(n.error,t.error);if(s){const e=t.id;this.remoteJseps[e]=s,this.createAnswer({remoteFeed:this.remoteFeeds[e],jsep:s},i,{success:()=>{},error:e=>{o.safeCallbackCall(n.error,e)}})}}else{if(a)if("joined"===a){const e={media:r?{audio:!1,video:!1}:{audio:!0,video:!0},stream:r?null:i};this.createOffer(e,{success:()=>{if(t.publishers){const e=t.publishers;for(const t in e){const r=e[t].id,n=e[t].display;this.emitter.emit(c.PARTICIPANT_JOINED,r,n,!0)}}},error:e=>{o.safeCallbackCall(n.error,e)}})}else if("event"===a)if(t.publishers){const e=t.publishers;for(const t in e){const r=e[t].id,n=e[t].display;this.emitter.emit(c.PARTICIPANT_JOINED,r,n,!1)}}else if(t.leaving){const e=t.leaving;this.detachRemoteFeed(e)&&this.emitter.emit(c.PARTICIPANT_LEFT,e,null)}else if(t.unpublished){const e=t.unpublished;"ok"!=e&&this.detachRemoteFeed(e)&&this.emitter.emit(c.PARTICIPANT_LEFT,e,null)}else t.error&&(o.DLog("[janus error message]",t.error),this.emitter.emit(c.ERROR,t),o.safeCallbackCall(n.error,t.error));s&&this.videoRoomPlugin.handleRemoteJsep({jsep:s})}},onlocaltrack:(e,t)=>{o.DLog("[onlocaltrack]",e,t),this.onLocalTrack(e,t)},onremotetrack:(e,t,r,n)=>{o.DLog("[onremotetrack]",e,t,r,n),this.onRemoteTrack(s,e,t,r,n)},ondataopen:e=>{o.DLog("[ondataopen]",e),this.emitter.emit(c.DATA_CHANNEL_OPEN,e)},ondata:(e,t)=>{o.DLog("[ondata]",t,e),this.emitter.emit(c.DATA_CHANNEL_MESSAGE,t,e)},oncleanup:()=>{o.safeCallbackCall(n.oncleanup)},detached:()=>{}})}onLocalTrack(e,t){}onRemoteTrack(e,t,r,n,i){const o=i&&i.reason;if(o===l.CREATED){const n=!e.stream||!e.tracks;n?(e.tracks={[r]:t},e.stream=new s([t])):(e.tracks[r]=t,e.stream.addTrack(t)),n&&this.emitter.emit(c.REMOTE_STREAM,e.userId,e.stream)}else if(o===l.ENDED){delete e.tracks[r];const n=e.stream.getTracks().find((e=>e.kind===t.kind));e.stream.removeTrack(n)}this.emitter.emit(c.REMOTE_TRACKS_UPDATED,e.userId,t,o)}getPluginId(){return this.videoRoomPlugin?this.videoRoomPlugin.getId():null}detachVideoConferencingPlugin(e){const t=()=>{this.videoRoomPlugin=null,Object.keys(this.remoteFeeds).forEach((e=>{this.detachRemoteFeed(e)})),this.remoteFeeds={},this.remoteJseps={}};this.videoRoomPlugin.detach({success:()=>{t(),o.safeCallbackCall(e.success)},error:r=>{t(),o.safeCallbackCall(e.error,r)}})}join(e,t,r,n){const s=n.displayName;delete n.displayName,this.isOnlyAudio=!!r,o.DLog("isOnlyAudio: "+this.isOnlyAudio);const i={request:"join",room:e,ptype:"publisher",id:t,display:s};this.videoRoomPlugin.send({message:i,success:r=>{this.currentRoomId=e,this.currentUserId=t,o.safeCallbackCall(n.success)},error:e=>{o.safeCallbackCall(n.error,e)}})}leave(e){if(o.DLog("leave"),!this.engine.isConnected())return void o.safeCallbackCall(e.success);const t={request:"leave",room:this.currentRoomId,id:this.currentUserId};this.videoRoomPlugin&&this.videoRoomPlugin.send({message:t}),this.currentRoomId=null,this.currentUserId=null,o.safeCallbackCall(e.success)}listOnlineParticipants(e,t){const r={request:"listparticipants",room:e};this.videoRoomPlugin.send({message:r,success:e=>{const r=[];e&&(r=e.participants),o.safeCallbackCall(t.success,r)},error:e=>{o.safeCallbackCall(t.error,e)}})}toggleAudioMute(){return this.videoRoomPlugin.isAudioMuted()?this.videoRoomPlugin.unmuteAudio():this.videoRoomPlugin.muteAudio(),this.videoRoomPlugin.isAudioMuted()}isAudioMuted(){return this.videoRoomPlugin.isAudioMuted()}toggleRemoteAudioMute(e){const t=this.remoteFeeds[e];if(!t)return!1;const r=t.stream.getAudioTracks();if(r&&r.length>0){for(let e=0;e0)&&!r[0].enabled}toggleVideoMute(){return this.videoRoomPlugin.isVideoMuted()?this.videoRoomPlugin.unmuteVideo():this.videoRoomPlugin.muteVideo(),this.videoRoomPlugin.isVideoMuted()}isVideoMuted(){return this.videoRoomPlugin.isVideoMuted()}toggleRemoteVideoMute(e){const t=this.remoteFeeds[e];if(!t)return!1;const r=t.stream.getVideoTracks();if(r&&r.length>0){for(let e=0;e0)&&!r[0].enabled}switchVideoinput(e,t){console.warn('[ConnectyCube.videochatconference] The method "switchVideoinput(mediaDeviceId, callbacks)" was deprecated. Use "videoConferenceSession.switchMediaTracks(mediaDeviceId): Promise" instead.')}switchAudioinput(e,t){console.warn('[ConnectyCube.videochatconference] The method "switchAudioinput(mediaDeviceId, callbacks)" was deprecated. Use "videoConferenceSession.switchMediaTracks(mediaDeviceId): Promise" instead.')}sendKeyframeRequest(e,t){const r={request:"configure",room:e,keyframe:!0};this.videoRoomPlugin.send({message:r,success:e=>{o.safeCallbackCall(t.success)},error:e=>{o.safeCallbackCall(t.error,e)}})}getTracksFromStream(e){const t=[],r=e.getAudioTracks();if(r.length){const e=r[0];t.push({type:"audio",capture:e,recv:!1})}const n=e.getVideoTracks();if(n.length){const e=n[0];t.push({type:"video",capture:e,recv:!1})}return t}createOffer(e,t){o.DLog("[JanusWrapper][createOffer]",e);const{stream:r,media:n,replace:s}=e,i={tracks:[{type:"data"}]};if(r){const e=this.getTracksFromStream(r);i.tracks=i.tracks.concat(e)}else if(n){const e=[];n.audio&&e.push({type:"audio",capture:n.audio,recv:!1,replace:!!s}),n.video&&e.push({type:"video",capture:n.video,recv:!1,replace:!!s}),i.tracks=i.tracks.concat(e)}else i.tracks=i.tracks.concat([{type:"audio",capture:!0,recv:!1,replace:!!s},{type:"video",capture:!0,recv:!1,replace:!!s}]);o.DLog("[JanusWrapper][createOffer][params]",i),i.customizeSdp=e=>{},i.success=e=>{const r={request:"configure",audio:!!n.audio,video:!!n.video};o.DLog("[JanusWrapper][createOffer][success]",r),this.videoRoomPlugin.send({message:r,jsep:e}),o.safeCallbackCall(t.success)},i.error=e=>{o.DLog("[JanusWrapper][createOffer][error]",e),n.audio?this.createOffer({media:{video:!1,audio:!1}},t):o.safeCallbackCall(t.error,e)},this.videoRoomPlugin.createOffer(i)}getTracksMidsFromStream(e){const t=[],r=e.getAudioTracks();if(r.length){const e=r[0];t.push({type:"audio",mid:e.id,recv:!0})}const n=e.getVideoTracks();if(n.length){const e=n[0];t.push({type:"video",mid:e.id,recv:!0})}return t}createAnswer({remoteFeed:e,jsep:t},r,n){o.DLog("[JanusWrapper][createAnswer]",t,r);let s=[{type:"data"}];if(r){const e=this.getTracksMidsFromStream(r);s=s.concat(e)}o.DLog("[JanusWrapper][createAnswer][tracks]",s),e.createAnswer({jsep:t,tracks:s,success:t=>{const r={request:"start",room:this.currentRoomId};o.DLog("[JanusWrapper][createAnswer][success]",r),e.send({message:r,jsep:t}),o.safeCallbackCall(n.success)},error:e=>{o.DLog("[JanusWrapper][createAnswer][error]",e),o.safeCallbackCall(n.error,e)}})}detachRemoteFeed(e){const t=this.remoteFeeds[e];return!!t&&(t.detach(),this.remoteFeeds[e]=null,this.remoteJseps[e]=null,!0)}getUserBitrate(e){return this.remoteFeeds[e].getBitrate()}getVolume(e){return this.videoRoomPlugin.getLocalVolume(null,e)}getUserVolume(e,t){return this.remoteFeeds[e].getRemoteVolume(null,t)}showBitrate(e,t){const r=this.remoteFeeds[e];o.getEnv().reactnative||"chrome"!==adapter.browserDetails.browser&&"firefox"!==adapter.browserDetails.browser||(this.bitrateTimers[e]=setInterval((()=>{const e=r.getBitrate();t.text(e)}),1e3))}hideBitrate(e,t){this.bitrateTimers[e]&&clearInterval(this.bitrateTimers[e]),this.bitrateTimers[e]=null,t.text=null}on(e,t){return this.emitter.addListener(e,t)}removeAllListeners(e){e?this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}}}},8852:(e,t,r)=>{const n=r(330),s=r(5992),{DEVICE_INPUT_TYPES:i,CALL_TYPES:o}=r(9454),{mediaDevices:a}=r(8009);e.exports=class{constructor(e){this.proxy=e,this.DEVICE_INPUT_TYPES=i,this.CALL_TYPES=o,this.sessionsStore={},this.onParticipantJoinedListener,this.onParticipantLeftListener,this.onSlowLinkListener,this.onRemoteStreamListener,this.onRemoteTracksUpdatedListener,this.onRemoteConnectionStateChangedListener,this.onDataChannelOpenedListener,this.onDataChannelMessageListener,this.onSessionConnectionStateChangedListener,this.onErrorListener}createNewSession(){const e=new s(Object.assign(n.conference,{token:this.getCurrentSessionToken()}));return e.onParticipantJoinedListener=this.onParticipantJoinedListener,e.onParticipantLeftListener=this.onParticipantLeftListener,e.onSlowLinkListener=this.onSlowLinkListener,e.onRemoteStreamListener=this.onRemoteStreamListener,e.onRemoteTracksUpdatedListener=this.onRemoteTracksUpdatedListener,e.onRemoteConnectionStateChangedListener=this.onRemoteConnectionStateChangedListener,e.onDataChannelOpenedListener=this.onDataChannelOpenedListener,e.onDataChannelMessageListener=this.onDataChannelMessageListener,e.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,e.onErrorListener=this.onErrorListener,this.sessionsStore[e.id]=e,e}async getMediaDevices(e){const t=await this._listDevices();return e===i.VIDEO?t.filter((({kind:e})=>e===i.VIDEO)):e===i.AUDIO?t.filter((({kind:e})=>e===i.AUDIO)):t}_listDevices(){return a.enumerateDevices()}clearSession(e){delete this.sessionsStore[e]}getCurrentSessionToken(){if(!this.proxy.getSession())throw new Error("Session does not exist");return this.proxy.getSession().token}}},9454:e=>{e.exports={CALL_TYPES:{VIDEO:"video",AUDIO:"audio"},DEVICE_INPUT_TYPES:{VIDEO:"videoinput",AUDIO:"audioinput"},JANUS_EVENTS:{PARTICIPANT_JOINED:"participant_joined",PARTICIPANT_LEFT:"participant_left",LOCAL_STREAM:"local_stream",REMOTE_STREAM:"remote_stream",REMOTE_TRACKS_UPDATED:"remote_tracks_updated",DATA_CHANNEL_OPEN:"data_channel_open",DATA_CHANNEL_MESSAGE:"data_channel_message",ERROR:"error"},JANUS_MEDIA_TRACKS_REASONS:{CREATED:"created",ENDED:"ended",MUTE:"mute",UNMUTE:"unmute"}}},5992:(e,t,r)=>{const n=r(9028),{mediaDevices:s}=r(8009),{Client:i}=r(936),{CALL_TYPES:o,JANUS_EVENTS:a}=r(9454);e.exports=class{constructor(e){this.id=`${Math.random()}`,this._clientConf=new i(e),this._setOnParticipantJoinListener(),this._setOnParticipantLeftListener(),this._setOnRemoteStreamListener(),this._setOnRemoteTracksUpdatedListener(),this._setOnDataChannelOpenListener(),this._setOnDataChannelMessageListener(),this._setOnErrorListener(),this.currentUserDisplayName,this.localStream,this.onParticipantJoinedListener,this.onParticipantLeftListener,this.onSlowLinkListener,this.onRemoteStreamListener,this.onRemoteTracksUpdatedListener,this.onRemoteConnectionStateChangedListener,this.onDataChannelOpenedListener,this.onDataChannelMessageListener,this.onSessionConnectionStateChangedListener,this.onErrorListener}get currentRoomId(){return this._clientConf.currentRoomId}set currentRoomId(e){return this._clientConf.currentRoomId=e}get currentPublisherPC(){return this._clientConf.videoRoomPlugin.webrtcStuff.pc}_createSession(){let e=!1;return new Promise(((t,r)=>{this._clientConf.createSession({success:()=>{e=!0,t()},error:t=>{e?this._onError(t):r(t)}})}))}async join(e,t,r){this.currentUserDisplayName=r,await this._createSession(),this.currentRoomId=e,await this._createHandler(!1,t),await this._join(this.currentRoomId,t)}async joinAsListener(e,t,r){this.currentUserDisplayName=r,await this._createSession(),this.currentRoomId=e,await this._createHandler(!1,t,!0),await this._join(this.currentRoomId,t)}sendKeyframeRequest(e){return new Promise(((t,r)=>{this._clientConf.sendKeyframeRequest(e,{success:t,error:r})}))}async _createListener(e){await this._createHandler(!0,e)}_createHandler(e,t,r=!1){return new Promise(((n,s)=>{this._clientConf.attachVideoConferencingPlugin(e,t,r,{success:n,error:s,iceState:e?this._onRemoteIceStateChanged.bind(this,t):this._onLocalIceStateChanged.bind(this),slowLink:e?this._onSlowLink.bind(this,t):this._onSlowLink.bind(this,void 0),localStream:this.localStream,displayName:this.currentUserDisplayName})}))}_join(e,t){return new Promise(((r,n)=>{this._clientConf.join(e,t,!1,{success:r,error:n,displayName:this.currentUserDisplayName})}))}_setOnParticipantJoinListener(){this._clientConf.on(a.PARTICIPANT_JOINED,this._onParticipantJoined.bind(this))}_setOnParticipantLeftListener(){this._clientConf.on(a.PARTICIPANT_LEFT,this._onParticipantLeft.bind(this))}_setOnRemoteStreamListener(){this._clientConf.on(a.REMOTE_STREAM,this._onRemoteStream.bind(this))}_setOnRemoteTracksUpdatedListener(){this._clientConf.on(a.REMOTE_TRACKS_UPDATED,this._onRemoteTracksUpdated.bind(this))}_setOnDataChannelOpenListener(){this._clientConf.on(a.DATA_CHANNEL_OPEN,this._onDataChannelOpen.bind(this))}_setOnDataChannelMessageListener(){this._clientConf.on(a.DATA_CHANNEL_MESSAGE,this._onDataChannelMessage.bind(this))}_setOnErrorListener(){this._clientConf.on(a.ERROR,this._onError.bind(this))}_onParticipantJoined(e,t,r){n.DLog("[_onParticipantJoined]",e,t,r),this._createListener(e),n.safeCallbackCall(this.onParticipantJoinedListener,this,e,t,r)}_onParticipantLeft(e,t){n.DLog("[_onParticipantLeft]",e,t),n.safeCallbackCall(this.onParticipantLeftListener,this,e,t)}_onError(e){n.DLog("[_onError]",e),n.safeCallbackCall(this.onErrorListener,this,e)}_onDataChannelOpen(e){n.DLog("[_onDataChannelOpen]",e),n.safeCallbackCall(this.onDataChannelOpenedListener,this,e)}_onDataChannelMessage(e,t){n.DLog("[_onDataChannelMessage]",e,t),n.safeCallbackCall(this.onDataChannelMessageListener,this,e,t)}_onLocalIceStateChanged(e){n.DLog("[_onLocalIceStateChanged]",e),n.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e)}_onRemoteIceStateChanged(e,t){n.DLog("[_onRemoteIceStateChanged]",e,t),n.safeCallbackCall(this.onRemoteConnectionStateChangedListener,this,e,t)}_onRemoteStream(e,t){n.DLog("[_onRemoteStream]",e,t),n.safeCallbackCall(this.onRemoteStreamListener,this,e,t)}_onRemoteTracksUpdated(e,t,r){n.DLog("[_onRemoteTracksUpdated]",e,t,r),n.safeCallbackCall(this.onRemoteTracksUpdatedListener,this,e,t,r)}_onSlowLink(e,t,r){n.DLog("[_onSlowLink]",e,t,r),n.safeCallbackCall(this.onSlowLinkListener,this,e,t,r)}listOfOnlineParticipants(){return new Promise(((e,t)=>{this._clientConf.listOnlineParticipants(this.currentRoomId,{success:e,error:t})}))}async leave(){await this._leaveGroup(),this.currentRoomId=void 0,this.currentUserDisplayName=void 0,await this._detachVideoConferencingPlugin(),await this._destroy(),this.localStream&&(this.localStream.getTracks().forEach((e=>e.stop())),this.localStream=void 0)}_leaveGroup(){return new Promise(((e,t)=>{this._clientConf.leave({success:e,error:t})}))}_destroy(){return new Promise(((e,t)=>{this._clientConf.destroySession({success:e,error:t})}))}_detachVideoConferencingPlugin(){return new Promise(((e,t)=>{this._clientConf.detachVideoConferencingPlugin({success:e,error:t})}))}getDisplayMedia(e){if(!s.getDisplayMedia)throw new Error("Your environment does not support 'getDisplayMedia' API");const t=e&&e.elementId,r=e&&e.options,n={...e};return delete n.elementId,delete n.options,s.getDisplayMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}getUserMedia(e){const t=e&&e.elementId,r=e&&e.options,n={...e};return delete n.elementId,delete n.options,s.getUserMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}_upsertStream(e,t,r){const n=!!this.localStream;return n?(this.localStream.getTracks().forEach((t=>{t.kind===o.AUDIO&&0===e.getAudioTracks().length||(t.stop(),this.localStream.removeTrack(t))})),this._replaceTracks(e)):this.localStream=e,t&&(n&&this.detachMediaStream(t,r),this.attachMediaStream(t,this.localStream,r)),this.localStream}_replaceTracks(e){e.getTracks().forEach((e=>{const t=this.currentPublisherPC.getSenders().find((t=>e.kind===t.track.kind));e.kind===o.AUDIO?e.enabled=this.localStream.getAudioTracks().every((e=>e.enabled)):e.enabled=this.localStream.getVideoTracks().every((e=>e.enabled)),t?(t.replaceTrack(e),this.localStream.addTrack(e)):console.warn(`No sender found for track kind: ${e.kind}`)}))}switchMediaTracks(e){return e[o.VIDEO]?this._switchVideo(e[o.VIDEO]):e[o.AUDIO]?this._switchAudio(e[o.AUDIO]):Promise.reject()}_switchVideo(e){return this._switchMediaTracks({audio:!0,video:{deviceId:e}})}_switchAudio(e){return this._switchMediaTracks({audio:{deviceId:e},video:!0})}_switchMediaTracks(e){return this.getUserMedia(e,!0).then((e=>{const t=e.getTracks(),r=this.currentPublisherPC.getSenders();return t.forEach((e=>{r.find((t=>e.kind===t.track.kind)).replaceTrack(e)})),this.localStream}))}muteVideo(){this.isVideoMuted()||this._clientConf.toggleVideoMute()}unmuteVideo(){this.isVideoMuted()&&this._clientConf.toggleVideoMute()}muteAudio(){this.isAudioMuted()||this._clientConf.toggleAudioMute()}unmuteAudio(){this.isAudioMuted()&&this._clientConf.toggleAudioMute()}isVideoMuted(){return this._clientConf.isVideoMuted()}isAudioMuted(){return this._clientConf.isAudioMuted()}getUserVolume(){return new Promise(((e,t)=>this._clientConf.getVolume(e)))}getRemoteUserBitrate(e){return this._clientConf.getUserBitrate(e)}getRemoteUserVolume(e){return new Promise(((t,r)=>this._clientConf.getUserVolume(e,t)))}attachMediaStream(e,t,r){const n=document.getElementById(e);if(!n)throw new Error("Unable to attach media stream, element "+e+" is undefined");"object"==typeof n.srcObject?n.srcObject=t:n.src=window.URL.createObjectURL(t),r&&r.muted&&(n.muted=!0),r&&r.mirror&&(n.style.webkitTransform="scaleX(-1)",n.style.transform="scaleX(-1)"),n.onloadedmetadata=function(e){n.play()}}detachMediaStream(e,t){const r=document.getElementById(e);if(!r)throw new Error("Unable to attach media stream, element "+e+" is undefined");r.pause(),"object"==typeof r.srcObject?r.srcObject=null:r.src="",t&&!t.mirror&&(r.style.webkitTransform="",r.style.transform="")}async sendData(e,t){const r={data:e,label:t};return new Promise(((e,t)=>{const n={success:e,error:t};Object.assign(n,r),this._clientConf.videoRoomPlugin.data(n)}))}}},9171:(e,t,r)=>{const{adapter:n,navigator:s,MediaStream:i,MediaStreamTrack:o,RTCPeerConnection:a,RTCRtpReceiver:c,RTCRtpSender:l}=r(8009),u=r(9028);h.sessions={},h.mobile=u.getEnv().reactnative,h.isExtensionEnabled=function(){if(h.mobile)return!1;if(s.mediaDevices&&s.mediaDevices.getDisplayMedia)return!0;if(window.navigator.userAgent.match("Chrome")){let e=parseInt(window.navigator.userAgent.match(/Chrome\/(.*) /)[1],10),t=33;return window.navigator.userAgent.match("Linux")&&(t=35),e>=26&&e<=t||h.extension.isInstalled()}return!0};var d={extensionId:"hapfgfdkleiggjjpfpenajgdnfckjpaj",isInstalled:function(){return!h.mobile&&null!==document.querySelector("#janus-extension-installed")},getScreen:function(e){if(h.mobile)e();else{let t=window.setTimeout((function(){let t=new Error("NavigatorUserMediaError");return t.name='The required Chrome extension is not installed: click here to install it. (NOTE: this will need you to refresh the page)',e(t)}),1e3);this.cache[t]=e,window.postMessage({type:"janusGetScreen",id:t},"*")}},init:function(){let e={};this.cache=e,h.mobile||window.addEventListener("message",(function(t){if(t.origin==window.location.origin)if("janusGotScreen"==t.data.type&&e[t.data.id]){let r=e[t.data.id];if(delete e[t.data.id],""===t.data.sourceId){let e=new Error("NavigatorUserMediaError");e.name="You cancelled the request for permission, giving up...",r(e)}else r(null,t.data.sourceId)}else"janusGetScreenPending"==t.data.type&&window.clearTimeout(t.data.id)}))}};function h(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.destroyed="function"==typeof e.destroyed?e.destroyed:h.noop,!h.initDone)return e.error("Library not initialized"),{};if(!h.isWebrtcSupported())return e.error("WebRTC not supported by this browser"),{};if(h.log("Library initialized: "+h.initDone),!e.server)return e.error("Invalid server url"),{};let t=!1,r=null,n={},u=null,d=null,p=0,f=e.server;h.isArray(f)?(h.log("Multiple servers provided ("+f.length+"), will use the first that works"),f=null,d=e.server,h.debug(d)):0===f.indexOf("ws")?(t=!0,h.log("Using WebSockets to contact Janus: "+f)):(t=!1,h.log("Using REST API to contact Janus: "+f));let m=e.iceServers||[{urls:"stun:stun.l.google.com:19302"}],g=e.iceTransportPolicy,y=e.bundlePolicy,v=!1;void 0!==e.withCredentials&&null!==e.withCredentials&&(v=!0===e.withCredentials);let b=10;void 0!==e.max_poll_events&&null!==e.max_poll_events&&(b=e.max_poll_events),b<1&&(b=1);let S=null;void 0!==e.token&&null!==e.token&&(S=e.token);let C=null;void 0!==e.apisecret&&null!==e.apisecret&&(C=e.apisecret),this.destroyOnUnload=!0,void 0!==e.destroyOnUnload&&null!==e.destroyOnUnload&&(this.destroyOnUnload=!0===e.destroyOnUnload);let w=25e3;void 0!==e.keepAlivePeriod&&null!==e.keepAlivePeriod&&(w=e.keepAlivePeriod),isNaN(w)&&(w=25e3);let k=6e4;function _(e){let t={high:9e5,medium:3e5,low:1e5};return null!=e&&(e.high&&(t.high=e.high),e.medium&&(t.medium=e.medium),e.low&&(t.low=e.low)),t}void 0!==e.longPollTimeout&&null!==e.longPollTimeout&&(k=e.longPollTimeout),isNaN(k)&&(k=6e4);let x=!1,I=null,E={},T=this,P=0,L={};function D(){if(null==I)return;if(h.debug("Long poll..."),!x)return void h.warn("Is the server down? (connected=false)");let t=f+"/"+I+"?rid="+(new Date).getTime();b&&(t=t+"&maxev="+b),S&&(t=t+"&token="+encodeURIComponent(S)),C&&(t=t+"&apisecret="+encodeURIComponent(C)),h.httpAPICall(t,{verb:"GET",withCredentials:v,success:A,timeout:k,error:function(t,r){if(h.error(t+":",r),P++,P>3)return x=!1,void e.error("Lost connection to the server (is it down?)");D()}})}function A(e,n){if(P=0,t||null==I||!0===n||D(),t||!h.isArray(e))if("keepalive"!==e.janus)if("server_info"!==e.janus)if("ack"!==e.janus)if("success"!==e.janus)if("trickle"===e.janus){const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");let n=e.candidate;h.debug("Got a trickled candidate on session "+I),h.debug(n);let s=r.webrtcStuff;s.pc&&s.remoteSdp?(h.debug("Adding remote candidate:",n),n&&!0!==n.completed?s.pc.addIceCandidate(n):s.pc.addIceCandidate(h.endOfCandidates)):(h.debug("We didn't do setRemoteDescription (trickle got here before the offer?), caching candidate"),s.candidates||(s.candidates=[]),s.candidates.push(n),h.debug(s.candidates))}else{if("webrtcup"===e.janus){h.debug("Got a webrtcup event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];return r?void r.webrtcState(!0):void h.debug("This handle is not attached to this session")}if("hangup"===e.janus){h.debug("Got a hangup event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.webrtcState(!1,e.reason),r.hangup()}else if("detached"===e.janus){h.debug("Got a detached event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return;r.ondetached(),r.detach()}else if("media"===e.janus){h.debug("Got a media event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.mediaState(e.type,e.receiving,e.mid)}else if("slowlink"===e.janus){h.debug("Got a slowlink event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.slowLink(e.uplink,e.lost,e.mid)}else{if("error"===e.janus){h.error("Ooops: "+e.error.code+" "+e.error.reason),h.debug(e);let t=e.transaction;if(t){let r=L[t];r&&r(e),delete L[t]}return}if("event"===e.janus){h.debug("Got a plugin event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");let r=e.plugindata;if(!r)return void h.warn("Missing plugindata...");h.debug(" -- Event is coming from "+t+" ("+r.plugin+")");let n=r.data;h.debug(n);const s=E[t];if(!s)return void h.warn("This handle is not attached to this session");let i=e.jsep;i&&(h.debug("Handling SDP as well..."),h.debug(i));let o=s.onmessage;o?(h.debug("Notifying application..."),o(n,i)):h.debug("No provided notification callback")}else{if("timeout"===e.janus)return h.error("Timeout on session "+I),h.debug(e),void(t&&r.close(3504,"Gateway timeout"));h.warn("Unknown message/event '"+e.janus+"' on session "+I),h.debug(e)}}}else{h.debug("Got a success on session "+I),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else{h.debug("Got an ack on session "+I),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else{h.debug("Got info on the Janus instance"),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else h.vdebug("Got a keepalive on session "+I);else for(let t=0;t data channel: "+n),"open"===n){if(o.dataChannel[t].pending&&o.dataChannel[t].pending.length>0){h.log("Sending pending messages on <"+t+">:",o.dataChannel[t].pending.length);for(let e of o.dataChannel[t].pending)h.log("Sending data on data channel <"+t+">"),h.debug(e),o.dataChannel[t].send(e);o.dataChannel[t].pending=[]}i.ondataopen(t,r)}};if(n)o.dataChannel[t]=n;else{let e=o.dataChannelOptions;r&&(e.protocol=r),o.dataChannel[t]=o.pc.createDataChannel(t,e)}o.dataChannel[t].onmessage=function(e){h.log("Received message on data channel:",e);let t=e.target.label;i.ondata(e.data,t)},o.dataChannel[t].onopen=a,o.dataChannel[t].onclose=a,o.dataChannel[t].onerror=function(e){h.error("Got error on data channel:",e)},o.dataChannel[t].pending=[],s&&o.dataChannel[t].pending.push(s)}function U(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),void t.error("Invalid handle");let n=r.webrtcStuff,s=t.text||t.data;if(!s)return h.warn("Invalid data"),void t.error("Invalid data");let i=t.label?t.label:h.dataChanDefaultLabel;return n.dataChannel[i]?"open"!==n.dataChannel[i].readyState?(n.dataChannel[i].pending.push(s),void t.success()):(h.log("Sending data on data channel <"+i+">"),h.debug(s),n.dataChannel[i].send(s),void t.success()):(N(e,i,t.protocol,!1,s,t.protocol),void t.success())}function B(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),void t.error("Invalid handle");let n=r.webrtcStuff;if(!n.dtmfSender){if(n.pc){let e=n.pc.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(!e)return h.warn("Invalid DTMF configuration (no audio track)"),void t.error("Invalid DTMF configuration (no audio track)");n.dtmfSender=e.dtmf,n.dtmfSender&&(h.log("Created DTMF Sender"),n.dtmfSender.ontonechange=function(e){h.debug("Sent DTMF tone: "+e.tone)})}if(!n.dtmfSender)return h.warn("Invalid DTMF configuration"),void t.error("Invalid DTMF configuration")}let s=t.dtmf;if(!s)return h.warn("Invalid DTMF parameters"),void t.error("Invalid DTMF parameters");let i=s.tones;if(!i)return h.warn("Invalid DTMF string"),void t.error("Invalid DTMF string");let o="number"==typeof s.duration?s.duration:500,a="number"==typeof s.gap?s.gap:50;h.debug("Sending DTMF string "+i+" (duration "+o+"ms, gap "+a+"ms)"),n.dtmfSender.insertDTMF(i,o,a),t.success()}function F(e,n){(n=n||{}).success="function"==typeof n.success?n.success:h.noop,n.error="function"==typeof n.error?n.error:h.noop;let s=!0===n.noRequest;h.log("Destroying handle "+e+" (only-locally="+s+")"),Z(e);let i=E[e];if(!i||i.detached)return delete E[e],void n.success();if(i.detached=!0,s)return delete E[e],void n.success();if(!x)return h.warn("Is the server down? (connected=false)"),void n.error("Is the server down? (connected=false)");let o={janus:"detach",transaction:h.randomString(12)};if(i.token&&(o.token=i.token),C&&(o.apisecret=C),t)return o.session_id=I,o.handle_id=e,r.send(JSON.stringify(o)),delete E[e],void n.success();h.httpAPICall(f+"/"+I+"/"+e,{verb:"POST",withCredentials:v,body:o,success:function(t){h.log("Destroyed handle:"),h.debug(t),"success"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),delete E[e],n.success()},error:function(t,r){h.error(t+":",r),delete E[e],n.success()}})}async function z(e,t,r){(r=r||{}).success="function"==typeof r.success?r.success:h.noop,r.error="function"==typeof r.error?r.error:Y;let n=r.jsep;if(t&&n)return h.error("Provided a JSEP to a createOffer"),void r.error("Provided a JSEP to a createOffer");if(!(t||n&&n.type&&n.sdp))return h.error("A valid JSEP is required for createAnswer"),void r.error("A valid JSEP is required for createAnswer");if(r.media&&!r.tracks){if(r.tracks=h.mediaToTracks(r.media),!0===r.simulcast||!0===r.simulcast2||r.svc)for(let e of r.tracks)if("video"===e.type){!0===r.simulcast||!0===r.simulcast2?e.simulcast=!0:r.svc&&(e.svc=r.svc);break}h.warn("Deprecated media object passed, use tracks instead. Automatically translated to:",r.tracks)}if(r.tracks&&!Array.isArray(r.tracks))return h.error("Tracks must be an array"),void r.error("Tracks must be an array");let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),void r.error("Invalid handle");let i=s.webrtcStuff;var o;i.trickle=(o=r.trickle,h.debug("isTrickleEnabled:",o),!1!==o);try{if(function(e,t){let r=E[e];if(!r||!r.webrtcStuff)throw h.warn("Invalid handle"),"Invalid handle";let n=r.webrtcStuff;if(n.pc)return;let s={iceServers:m,iceTransportPolicy:g,bundlePolicy:y,sdpSemantics:"unified-plan"},i=!1;if(t.tracks)for(let e of t.tracks)if(e.transforms&&(e.transforms.sender||e.transforms.receiver)){i=!0;break}l&&(l.prototype.createEncodedStreams||l.prototype.createEncodedAudioStreams&&l.prototype.createEncodedVideoStreams)&&i&&(n.insertableStreams=!0,s.forceEncodedAudioInsertableStreams=!0,s.forceEncodedVideoInsertableStreams=!0,s.encodedInsertableStreams=!0),h.log("Creating PeerConnection"),n.pc=new a(s),h.debug(n.pc),n.pc.getStats&&(n.volume={},n.bitrate.value="0 kbits/sec"),h.log("Preparing local SDP and gathering candidates (trickle="+n.trickle+")"),n.pc.oniceconnectionstatechange=function(){n.pc&&r.iceState(n.pc.iceConnectionState)},n.pc.onicecandidate=function(r){if(!r.candidate||r.candidate.candidate&&r.candidate.candidate.indexOf("endOfCandidates")>0)h.log("End of candidates."),n.iceDone=!0,!0===n.trickle?M(e,{completed:!0}):function(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return void h.warn("Invalid handle, not sending anything");let n=r.webrtcStuff;h.log("Sending offer/answer SDP..."),n.mySdp?(n.mySdp={type:n.pc.localDescription.type,sdp:n.pc.localDescription.sdp},!1===n.trickle&&(n.mySdp.trickle=!1),h.debug(t),n.sdpSent=!0,t.success(n.mySdp)):h.warn("Local SDP instance is invalid, not sending anything...")}(e,t);else{let t={candidate:r.candidate.candidate,sdpMid:r.candidate.sdpMid,sdpMLineIndex:r.candidate.sdpMLineIndex};!0===n.trickle&&M(e,t)}},n.pc.ontrack=function(e){if(h.log("Handling Remote Track",e),!e.streams)return;if(!e.track)return;let t=e.transceiver?e.transceiver.mid||e.transceiver._mid:e.track.id;try{r.onremotetrack(e.track,t,!0,{reason:"created"})}catch(e){h.error("Error calling onremotetrack",e)}if(e.track.onended)return;let s=null;h.log("Adding onended callback to track:",e.track),e.track.onended=function(e){h.log("Remote track removed:",e),clearTimeout(s);let t=n.pc?n.pc.getTransceivers():null,i=t?t.find((t=>{const r=t.receiver||t._receiver;return(r.track||r._track)===e.target})):null,o=i?i.mid||i._mid:e.target.id;try{r.onremotetrack(e.target,o,!1,{reason:"ended"})}catch(e){h.error("Error calling onremotetrack on removal",e)}},e.track.onmute=function(e){if(h.log("Remote track muted:",e),!s){const t=e.target;s=setTimeout((function(){h.log("Removing remote track");let e=n.pc?n.pc.getTransceivers():null,i=e?e.find((e=>{const r=e.receiver||e._receiver;return(r.track||r._track)===t})):null,o=i?i.mid||i._mid:t.id;try{r.onremotetrack(t,o,!1,{reason:"mute"})}catch(e){h.error("Error calling onremotetrack on mute",e)}s=null}),2520)}},e.track.onunmute=function(e){if(h.log("Remote track flowing again:",e),null!=s)clearTimeout(s),s=null;else try{let t=n.pc?n.pc.getTransceivers():null,s=t?t.find((t=>{const r=t.receiver||t._receiver;return(r.track||r._track)===e.target})):null,i=s?s.mid||s._mid:e.target.id;r.onremotetrack(e.target,i,!0,{reason:"unmute"})}catch(e){h.error("Error calling onremotetrack on unmute",e)}}}}(e,r),t&&await J(e,r),n){if(await i.pc.setRemoteDescription(n),h.log("Remote description accepted!"),i.remoteSdp=n.sdp,i.candidates&&i.candidates.length>0){for(let e=0;e0){for(let e=0;ee.mid===t.mid&&e.receiver.track.kind===a)):n.pc.getTransceivers().find((e=>e.receiver.track.kind===a)),t.replace||t.remove){if(!p){h.warn("Couldn't find a transceiver for track:",t);continue}if(!p.sender){h.warn("No sender in the transceiver for track:",t);continue}m=p.sender}if(f&&!p&&(p=n.pc.getTransceivers().find((e=>e.receiver.track.kind===a)),!p)){h.warn("Couldn't find a transceiver for track:",t);continue}let g=null,y=null;if(t.remove)h.log("Removing track from PeerConnection",t),y=m.track?m.track.id:null,await m.replaceTrack(null);else if(t.capture){if(t.gumGroup&&d[t.gumGroup]&&d[t.gumGroup].stream){let e=d[t.gumGroup].stream;g="audio"===t.type?e.getAudioTracks()[0]:e.getVideoTracks()[0],delete d[t.gumGroup].stream,delete d[t.gumGroup],delete t.gumGroup}else if(t.capture instanceof o)g=t.capture;else{u||(u=!0,r.consentDialog(!0));let e=h.trackConstraints(t),n=null;if("audio"===t.type||"video"===t.type){if(t.gumGroup){let r="audio"===t.type?"video":"audio";if(d[t.gumGroup]&&d[t.gumGroup][r]){let n=d[t.gumGroup][r],s=h.trackConstraints(n);e[r]=s[r]}}n=await s.mediaDevices.getUserMedia(e),t.gumGroup&&e.audio&&e.video&&(d[t.gumGroup].stream=n,delete t.gumGroup)}else n=await s.mediaDevices.getDisplayMedia(e);g="audio"===t.type?n.getAudioTracks()[0]:n.getVideoTracks()[0]}if(t.replace){await m.replaceTrack(g);let e="sendrecv";!1!==t.recv&&"inactive"!==p.direction&&"sendonly"!==p.direction||(e="sendonly"),p.setDirection?p.setDirection(e):p.direction=e}else{if(n.myStream||(n.myStream=new i),"audio"===a||!t.simulcast&&!t.svc)m=n.pc.addTrack(g,n.myStream),p=n.pc.getTransceivers().find((e=>e.sender===m));else if(t.simulcast){if("firefox"!==h.webRTCAdapter.browserDetails.browser){h.log("Enabling rid-based simulcasting:",g);let e=_(t.simulcastMaxBitrates);p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream],sendEncodings:t.sendEncodings||[{rid:"h",active:!0,maxBitrate:e.high},{rid:"m",active:!0,maxBitrate:e.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:e.low,scaleResolutionDownBy:4}]})}else if(h.log("Enabling Simulcasting for Firefox (RID)"),p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream]}),m=p?p.sender:null,m){let e=m.getParameters();e||(e={});let r=_(t.simulcastMaxBitrates);e.encodings=t.sendEncodings||[{rid:"h",active:!0,maxBitrate:r.high},{rid:"m",active:!0,maxBitrate:r.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:r.low,scaleResolutionDownBy:4}],m.setParameters(e)}}else h.log("Enabling SVC ("+t.svc+"):",g),p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream],sendEncodings:[{scalabilityMode:t.svc}]});if(m||(m=p?p.sender:null),t.codec)if("firefox"===h.webRTCAdapter.browserDetails.browser)h.warn("setCodecPreferences not supported in Firefox, ignoring codec for track:",t);else if("string"!=typeof t.codec)h.warn("Invalid codec value, ignoring for track:",t);else{let e=a+"/"+t.codec.toLowerCase(),r=c.getCapabilities(a).codecs.filter((function(t){return t.mimeType.toLowerCase()===e}));if(r&&0!==r.length){if(p)try{p.setCodecPreferences(r)}catch(e){h.warn("Failed enforcing codec for this "+a+" track:",e)}}else h.warn("Codec not supported in this browser for this track, ignoring:",t)}if(t.bitrate)if(t.simulcast||t.svc)h.warn("Ignoring bitrate for simulcast/SVC track, use sendEncodings for that");else if(isNaN(t.bitrate)||t.bitrate<0)h.warn("Ignoring invalid bitrate for track:",t);else if(m){let e=m.getParameters();e&&e.encodings&&0!==e.encodings.length?(e.encodings[0].maxBitrate=t.bitrate,await m.setParameters(e)):h.warn("No encodings in the sender parameters, ignoring bitrate for track:",t)}if("video"===a&&t.framerate)if(t.simulcast||t.svc)h.warn("Ignoring framerate for simulcast/SVC track, use sendEncodings for that");else if(isNaN(t.framerate)||t.framerate<0)h.warn("Ignoring invalid framerate for track:",t);else if(m){let e=m.getParameters();e&&e.encodings&&0!==e.encodings.length?(e.encodings[0].maxFramerate=t.framerate,await m.setParameters(e)):h.warn("No encodings in the sender parameters, ignoring framerate for track:",t)}if(t.transforms){if(m&&t.transforms.sender){let e=null;l.prototype.createEncodedStreams?e=m.createEncodedStreams():(l.prototype.createAudioEncodedStreams||l.prototype.createEncodedVideoStreams)&&("audio"===a?e=m.createEncodedAudioStreams():"video"===a&&(e=m.createEncodedVideoStreams())),e&&(h.log("Insertable Streams sender transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.sender).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.sender).pipeTo(e.writable))}if(p&&p.receiver&&t.transforms.receiver){let e=null;c.prototype.createEncodedStreams?e=p.receiver.createEncodedStreams():(c.prototype.createAudioEncodedStreams||c.prototype.createEncodedVideoStreams)&&("audio"===a?e=p.receiver.createEncodedAudioStreams():"video"===a&&(e=p.receiver.createEncodedVideoStreams())),e&&(h.log("Insertable Streams receiver transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.receiver).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.receiver).pipeTo(e.writable))}}}g&&!0===t.dontStop&&(g.dontStop=!0)}else if(t.recv&&!p&&(p=n.pc.addTransceiver(a),p)){if(t.codec)if("firefox"===h.webRTCAdapter.browserDetails.browser)h.warn("setCodecPreferences not supported in Firefox, ignoring codec for track:",t);else if("string"!=typeof t.codec)h.warn("Invalid codec value, ignoring for track:",t);else{let e=a+"/"+t.codec.toLowerCase(),r=c.getCapabilities(a).codecs.filter((function(t){return t.mimeType.toLowerCase()===e}));if(r&&0!==r.length)try{p.setCodecPreferences(r)}catch(e){h.warn("Failed enforcing codec for this "+a+" track:",e)}else h.warn("Codec not supported in this browser for this track, ignoring:",t)}if(p.receiver&&t.transforms&&t.transforms.receiver){let e=null;c.prototype.createEncodedStreams?e=p.receiver.createEncodedStreams():(c.prototype.createAudioEncodedStreams||c.prototype.createEncodedVideoStreams)&&("audio"===a?e=p.receiver.createEncodedAudioStreams():"video"===a&&(e=p.receiver.createEncodedVideoStreams())),e&&(h.log("Insertable Streams receiver transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.receiver).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.receiver).pipeTo(e.writable))}}if(y&&n.myStream){let e=null;if("audio"===a&&n.myStream.getAudioTracks()&&n.myStream.getAudioTracks().length)for(let t of n.myStream.getAudioTracks())t.id===y&&(e=t,h.log("Removing audio track:",e));else if("video"===a&&n.myStream.getVideoTracks()&&n.myStream.getVideoTracks().length)for(let t of n.myStream.getVideoTracks())t.id===y&&(e=t,h.log("Removing video track:",e));if(e){try{n.myStream.removeTrack(e),r.onlocaltrack(e,!1)}catch(e){h.error("Error calling onlocaltrack on removal for renegotiation",e)}if(!0!==e.dontStop)try{e.stop()}catch(e){}}}if(g){n.myStream.addTrack(g),g.onended=function(e){h.log("Local track removed:",e);try{r.onlocaltrack(e.target,!1)}catch(e){h.error("Error calling onlocaltrack following end",e)}};try{r.onlocaltrack(g,!0)}catch(e){h.error("Error calling onlocaltrack for track add",e)}}if(p){let e=p.direction,r=null,n=g&&p.sender.track,s=!1!==t.recv&&p.receiver.track;n&&s?r="sendrecv":n&&!s?r="sendonly":!n&&s?r="recvonly":n||s||(r="inactive"),r&&r!==e&&(h.warn("Changing direction of transceiver to "+r+" (was "+e+")",t),p.setDirection?p.setDirection(r):p.direction=r)}}u&&r.consentDialog(!1)}function $(e){let t=E[e];if(!t||!t.webrtcStuff)return h.warn("Invalid handle"),null;let r=t.webrtcStuff;if(!r.pc)return h.warn("Invalid PeerConnection"),null;let n=[],s=r.pc.getTransceivers();for(let e of s){let t=null;e.sender&&e.sender.track&&(t={mid:e.mid},t.type=e.sender.track.kind,t.id=e.sender.track.id,t.label=e.sender.track.label),t&&n.push(t)}return n}function H(e){let t=E[e];if(!t||!t.webrtcStuff)return h.warn("Invalid handle"),null;let r=t.webrtcStuff;if(!r.pc)return h.warn("Invalid PeerConnection"),null;let n=[],s=r.pc.getTransceivers();for(let e of s){let t=null;e.receiver&&e.receiver.track&&(t={mid:e.mid},t.type=e.receiver.track.kind,t.id=e.receiver.track.id,t.label=e.receiver.track.label),t&&n.push(t)}return n}function W(e,t,r,n){n="function"==typeof n?n:h.noop;let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),void n(0);let i=r?"remote":"local",o=s.webrtcStuff;if(o.volume[i]||(o.volume[i]={value:0}),o.pc&&o.pc.getStats&&("chrome"===h.webRTCAdapter.browserDetails.browser||"safari"===h.webRTCAdapter.browserDetails.browser)){let e=o.pc;if(t){let s=o.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));if(!s)return h.warn("No audio transceiver with mid "+t),void n(0);if(r&&!s.receiver)return h.warn("Remote transceiver track unavailable"),void n(0);if(!r&&!s.sender)return h.warn("Local transceiver track unavailable"),void n(0);e=r?s.receiver:s.sender}return e.getStats().then((function(e){e.forEach((function(e){e&&"audio"===e.kind&&(r&&!e.remoteSource||!r&&"media-source"!==e.type||n(e.audioLevel?e.audioLevel:0))}))})),o.volume[i].value}return h.warn("Getting the "+i+" volume unsupported by browser"),void n(0)}function G(e,t,r){let n=E[e];if(!n||!n.webrtcStuff)return h.warn("Invalid handle"),!0;let s=n.webrtcStuff;if(!s.pc)return h.warn("Invalid PeerConnection"),!0;if(!s.myStream)return h.warn("Invalid local MediaStream"),!0;if(r){if(!s.myStream.getVideoTracks()||0===s.myStream.getVideoTracks().length)return h.warn("No video track"),!0;if(t){let e=s.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));return e?e.sender&&e.sender.track?!e.sender.track.enabled:(h.warn("No video sender with mid "+t),!0):(h.warn("No video transceiver with mid "+t),!0)}return!s.myStream.getVideoTracks()[0].enabled}if(!s.myStream.getAudioTracks()||0===s.myStream.getAudioTracks().length)return h.warn("No audio track"),!0;if(t){let e=s.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));return e?e.sender&&e.sender.track?!e.sender.track.enabled:(h.warn("No audio sender with mid "+t),!0):(h.warn("No audio transceiver with mid "+t),!0)}return!s.myStream.getAudioTracks()[0].enabled}function K(e,t,r,n){let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),!1;let i=s.webrtcStuff;if(!i.pc)return h.warn("Invalid PeerConnection"),!1;if(!i.myStream)return h.warn("Invalid local MediaStream"),!1;if(r){if(!i.myStream.getVideoTracks()||0===i.myStream.getVideoTracks().length)return h.warn("No video track"),!1;if(t){let e=i.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));if(!e)return h.warn("No video transceiver with mid "+t),!1;if(!e.sender||!e.sender.track)return h.warn("No video sender with mid "+t),!1;e.sender.track.enabled=!n}else for(const e of i.myStream.getVideoTracks())e.enabled=!n}else{if(!i.myStream.getAudioTracks()||0===i.myStream.getAudioTracks().length)return h.warn("No audio track"),!1;if(t){let e=i.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));if(!e)return h.warn("No audio transceiver with mid "+t),!1;if(!e.sender||!e.sender.track)return h.warn("No audio sender with mid "+t),!1;e.sender.track.enabled=!n}else for(const e of i.myStream.getAudioTracks())e.enabled=!n}return!0}function X(e,t){let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),"Invalid handle";let n=r.webrtcStuff;if(!n.pc)return"Invalid PeerConnection";if(n.pc.getStats){let e=n.pc,r=t||"default";if(t){let r=n.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));if(!r)return h.warn("No video transceiver with mid "+t),"No video transceiver with mid "+t;if(!r.receiver)return h.warn("No video receiver with mid "+t),"No video receiver with mid "+t;e=r.receiver}return n.bitrate[r]||(n.bitrate[r]={timer:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,value:"0 kbits/sec"}),n.bitrate[r].timer?n.bitrate[r].value:(h.log("Starting bitrate timer"+(t?" for mid "+t:"")+" (via getStats)"),n.bitrate[r].timer=setInterval((function(){e.getStats().then((function(e){e.forEach((function(e){if(!e)return;let t=!1;if(("video"===e.mediaType||e.id.toLowerCase().indexOf("video")>-1)&&"inbound-rtp"===e.type&&e.id.indexOf("rtcp")<0?t=!0:"ssrc"!=e.type||!e.bytesReceived||"VP8"!==e.googCodecName&&""!==e.googCodecName||(t=!0),t)if(n.bitrate[r].bsnow=e.bytesReceived,n.bitrate[r].tsnow=e.timestamp,null===n.bitrate[r].bsbefore||null===n.bitrate[r].tsbefore)n.bitrate[r].bsbefore=n.bitrate[r].bsnow,n.bitrate[r].tsbefore=n.bitrate[r].tsnow;else{let e=n.bitrate[r].tsnow-n.bitrate[r].tsbefore;"safari"===h.webRTCAdapter.browserDetails.browser&&(e/=1e3);let t=Math.round(8*(n.bitrate[r].bsnow-n.bitrate[r].bsbefore)/e);"safari"===h.webRTCAdapter.browserDetails.browser&&(t=parseInt(t/1e3)),n.bitrate[r].value=t+" kbits/sec",n.bitrate[r].bsbefore=n.bitrate[r].bsnow,n.bitrate[r].tsbefore=n.bitrate[r].tsnow}}))}))}),1e3),"0 kbits/sec")}return h.warn("Getting the video bitrate unsupported by browser"),"Feature unsupported by browser"}function Q(e,t,r){let n=E[e];if(!n||!n.webrtcStuff)return void h.warn("Invalid handle");let s=n.webrtcStuff;if(!s.pc)return void h.warn("Invalid PeerConnection");let i=s.pc.getTransceivers().find((e=>e.mid===t));if(!i)return void h.warn("No transceiver with mid",t);if(!i.sender)return void h.warn("No sender for transceiver with mid",t);let o=i.sender.getParameters();o&&o.encodings&&0!==o.encodings.length?o.encodings.length>1?h.warn("Ignoring bitrate for simulcast track, use sendEncodings for that"):isNaN(r)||r<0?h.warn("Invalid bitrate (must be a positive integer)"):(o.encodings[0].maxBitrate=r,i.sender.setParameters(o)):h.warn("No parameters encodings")}function Y(e){h.error("WebRTC error:",e)}function Z(e,n){h.log("Cleaning WebRTC stuff");let s=E[e];if(!s)return;let i=s.webrtcStuff;if(i){if(!0===n){let n={janus:"hangup",transaction:h.randomString(12)};s.token&&(n.token=s.token),C&&(n.apisecret=C),h.debug("Sending hangup request (handle="+e+"):"),h.debug(n),t?(n.session_id=I,n.handle_id=e,r.send(JSON.stringify(n))):h.httpAPICall(f+"/"+I+"/"+e,{verb:"POST",withCredentials:v,body:n})}i.volume&&(i.volume.local&&i.volume.local.timer&&clearInterval(i.volume.local.timer),i.volume.remote&&i.volume.remote.timer&&clearInterval(i.volume.remote.timer));for(let e in i.bitrate)i.bitrate[e].timer&&clearInterval(i.bitrate[e].timer);i.bitrate={},!i.streamExternal&&i.myStream&&(h.log("Stopping local stream tracks"),h.stopAllTracks(i.myStream)),i.streamExternal=!1,i.myStream=null;try{i.pc.close()}catch(e){}i.pc=null,i.candidates=null,i.mySdp=null,i.remoteSdp=null,i.iceDone=!1,i.dataChannel={},i.dtmfSender=null,i.insertableStreams=!1}s.oncleanup()}R(e),this.getServer=function(){return f},this.isConnected=function(){return x},this.reconnect=function(e){(e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.reconnect=!0,R(e)},this.getSessionId=function(){return I},this.getInfo=function(e){!function(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,h.log("Getting info on Janus instance"),!x)return h.warn("Is the server down? (connected=false)"),void e.error("Is the server down? (connected=false)");let n=h.randomString(12),s={janus:"info",transaction:n};if(S&&(s.token=S),C&&(s.apisecret=C),t)return L[n]=function(t){h.log("Server info:"),h.debug(t),"server_info"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),e.success(t)},void r.send(JSON.stringify(s));h.httpAPICall(f,{verb:"POST",withCredentials:v,body:s,success:function(t){h.log("Server info:"),h.debug(t),"server_info"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),e.success(t)},error:function(t,r){h.error(t+":",r),""===r?e.error(t+": Is the server down?"):e.error(t+": "+r)}})}(e)},this.destroy=function(i){!function(i){(i=i||{}).success="function"==typeof i.success?i.success:h.noop,i.error="function"==typeof i.error?i.error:h.noop;let o=!0===i.unload,a=!0;void 0!==i.notifyDestroyed&&null!==i.notifyDestroyed&&(a=!0===i.notifyDestroyed);let c=!0===i.cleanupHandles;if(h.log("Destroying session "+I+" (unload="+o+")"),!I)return h.warn("No session to destroy"),i.success(),void(a&&e.destroyed());if(c)for(let e in E)F(e,{noRequest:!0});if(!x)return h.warn("Is the server down? (connected=false)"),I=null,void i.success();let l={janus:"destroy",transaction:h.randomString(12)};if(S&&(l.token=S),C&&(l.apisecret=C),o)return t?(r.onclose=null,r.close(),r=null):s.sendBeacon(f+"/"+I,JSON.stringify(l)),h.log("Destroyed session:"),I=null,x=!1,i.success(),void(a&&e.destroyed());if(t){l.session_id=I;let t=function(){for(let e in n)r.removeEventListener(e,n[e]);r.removeEventListener("message",s),r.removeEventListener("error",o),u&&clearTimeout(u),r.close()},s=function(r){let n=JSON.parse(r.data);n.session_id==l.session_id&&n.transaction==l.transaction&&(t(),i.success(),a&&e.destroyed())},o=function(){t(),i.error("Failed to destroy the server: Is the server down?"),a&&e.destroyed()};return r.addEventListener("message",s),r.addEventListener("error",o),void(1===r.readyState?r.send(JSON.stringify(l)):o())}h.httpAPICall(f+"/"+I,{verb:"POST",withCredentials:v,body:l,success:function(t){h.log("Destroyed session:"),h.debug(t),I=null,x=!1,"success"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),i.success(),a&&e.destroyed()},error:function(t,r){h.error(t+":",r),I=null,x=!1,i.success(),a&&e.destroyed()}})}(i)},this.attach=function(e){!function(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.dataChannelOptions=e.dataChannelOptions||{ordered:!0},e.consentDialog="function"==typeof e.consentDialog?e.consentDialog:h.noop,e.iceState="function"==typeof e.iceState?e.iceState:h.noop,e.mediaState="function"==typeof e.mediaState?e.mediaState:h.noop,e.webrtcState="function"==typeof e.webrtcState?e.webrtcState:h.noop,e.slowLink="function"==typeof e.slowLink?e.slowLink:h.noop,e.onmessage="function"==typeof e.onmessage?e.onmessage:h.noop,e.onlocaltrack="function"==typeof e.onlocaltrack?e.onlocaltrack:h.noop,e.onremotetrack="function"==typeof e.onremotetrack?e.onremotetrack:h.noop,e.ondata="function"==typeof e.ondata?e.ondata:h.noop,e.ondataopen="function"==typeof e.ondataopen?e.ondataopen:h.noop,e.oncleanup="function"==typeof e.oncleanup?e.oncleanup:h.noop,e.ondetached="function"==typeof e.ondetached?e.ondetached:h.noop,!x)return h.warn("Is the server down? (connected=false)"),void e.error("Is the server down? (connected=false)");let n=e.plugin;if(!n)return h.error("Invalid plugin"),void e.error("Invalid plugin");let s=e.opaqueId,i=e.loopIndex,o=e.token?e.token:S,a=h.randomString(12),c={janus:"attach",plugin:n,opaque_id:s,loop_index:i,transaction:a};if(o&&(c.token=o),C&&(c.apisecret=C),t)return L[a]=function(t){if(h.debug(t),"success"!==t.janus)return h.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);let r=t.data.id;h.log("Created handle: "+r);let s={session:T,plugin:n,id:r,token:o,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,mySdp:null,mediaConstraints:null,pc:null,dataChannelOptions:e.dataChannelOptions,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,bitrate:{}},getId:function(){return r},getPlugin:function(){return n},getVolume:function(e,t){return W(r,e,!0,t)},getRemoteVolume:function(e,t){return W(r,e,!0,t)},getLocalVolume:function(e,t){return W(r,e,!1,t)},isAudioMuted:function(e){return G(r,e,!1)},muteAudio:function(e){return K(r,e,!1,!0)},unmuteAudio:function(e){return K(r,e,!1,!1)},isVideoMuted:function(e){return G(r,e,!0)},muteVideo:function(e){return K(r,e,!0,!0)},unmuteVideo:function(e){return K(r,e,!0,!1)},getBitrate:function(e){return X(r,e)},setMaxBitrate:function(e,t){return Q(r,e,t)},send:function(e){j(r,e)},data:function(e){U(r,e)},dtmf:function(e){B(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){z(r,!0,e)},createAnswer:function(e){z(r,!1,e)},handleRemoteJsep:function(e){V(r,e)},replaceTracks:function(e){q(r,e)},getLocalTracks:function(){return $(r)},getRemoteTracks:function(){return H(r)},onlocaltrack:e.onlocaltrack,onremotetrack:e.onremotetrack,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){Z(r,!0===e)},detach:function(e){F(r,e)}};E[r]=s,e.success(s)},c.session_id=I,void r.send(JSON.stringify(c));h.httpAPICall(f+"/"+I,{verb:"POST",withCredentials:v,body:c,success:function(t){if(h.debug(t),"success"!==t.janus)return h.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);let r=t.data.id;h.log("Created handle: "+r);let s={session:T,plugin:n,id:r,token:o,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,mySdp:null,mediaConstraints:null,pc:null,dataChannelOptions:e.dataChannelOptions,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,bitrate:{}},getId:function(){return r},getPlugin:function(){return n},getVolume:function(e,t){return W(r,e,!0,t)},getRemoteVolume:function(e,t){return W(r,e,!0,t)},getLocalVolume:function(e,t){return W(r,e,!1,t)},isAudioMuted:function(e){return G(r,e,!1)},muteAudio:function(e){return K(r,e,!1,!0)},unmuteAudio:function(e){return K(r,e,!1,!1)},isVideoMuted:function(e){return G(r,e,!0)},muteVideo:function(e){return K(r,e,!0,!0)},unmuteVideo:function(e){return K(r,e,!0,!1)},getBitrate:function(e){return X(r,e)},setMaxBitrate:function(e,t){return Q(r,e,t)},send:function(e){j(r,e)},data:function(e){U(r,e)},dtmf:function(e){B(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){z(r,!0,e)},createAnswer:function(e){z(r,!1,e)},handleRemoteJsep:function(e){V(r,e)},replaceTracks:function(e){q(r,e)},getLocalTracks:function(){return $(r)},getRemoteTracks:function(){return H(r)},onlocaltrack:e.onlocaltrack,onremotetrack:e.onremotetrack,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){Z(r,!0===e)},detach:function(e){F(r,e)}};E[r]=s,e.success(s)},error:function(t,r){h.error(t+":",r),""===r?e.error(t+": Is the server down?"):e.error(t+": "+r)}})}(e)}}h.useDefaultDependencies=function(e){let t=e&&e.fetch||fetch,r=e&&e.Promise||Promise,s=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new s(e,t)},extension:e&&e.extension||d,isArray:function(e){return Array.isArray(e)},webRTCAdapter:e&&e.adapter||n,httpAPICall:function(e,n){let s={method:n.verb,headers:{Accept:"application/json, text/plain, */*"},cache:"no-cache"};"POST"===n.verb&&(s.headers["Content-Type"]="application/json"),void 0!==n.withCredentials&&(s.credentials=!0===n.withCredentials?"include":n.withCredentials?n.withCredentials:"omit"),n.body&&(s.body=JSON.stringify(n.body));let i=t(e,s).catch((function(e){return r.reject({message:"Probably a network error, is the server down?",error:e})}));if(n.timeout){let e=new r((function(e,t){let r=setTimeout((function(){return clearTimeout(r),t({message:"Request timed out",timeout:n.timeout})}),n.timeout)}));i=r.race([i,e])}return i.then((function(e){return e.ok?typeof n.success==typeof h.noop?e.json().then((function(e){try{n.success(e)}catch(e){h.error("Unhandled httpAPICall success callback error",e)}}),(function(t){return r.reject({message:"Failed to parse response body",error:t,response:e})})):void 0:r.reject({message:"API call failed",response:e})})).catch((function(e){typeof n.error==typeof h.noop&&n.error(e.message||"<< internal error >>",e)})),i}}},h.useOldDependencies=function(e){let t=e&&e.jQuery||jQuery,r=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new r(e,t)},isArray:function(e){return t.isArray(e)},extension:e&&e.extension||d,webRTCAdapter:e&&e.adapter||n,httpAPICall:function(e,r){let n=void 0!==r.body?{contentType:"application/json",data:JSON.stringify(r.body)}:{},s=void 0!==r.withCredentials?{xhrFields:{withCredentials:r.withCredentials}}:{};return t.ajax(t.extend(n,s,{url:e,type:r.verb,cache:!1,dataType:"json",async:r.async,timeout:r.timeout,success:function(e){typeof r.success==typeof h.noop&&r.success(e)},error:function(e,t,n){typeof r.error==typeof h.noop&&r.error(t,n)}}))}}},h.mediaToTracks=function(e){let t=[];if(e){if(!e.keepAudio&&!1!==e.audio&&(void 0===e.audio||e.audio||e.audioSend||e.audioRecv||e.addAudio||e.replaceAudio||e.removeAudio)){let r={type:"audio"};e.removeAudio?r.remove=!0:(e.addAudio?r.add=!0:e.replaceAudio&&(r.replace=!0),!1!==e.audioSend&&(r.capture=e.audio||!0),!1!==e.audioRecv&&(r.recv=!0)),(r.remove||r.capture||r.recv)&&t.push(r)}if(!e.keepVideo&&!1!==e.video&&(void 0===e.video||e.video||e.videoSend||e.videoRecv||e.addVideo||e.replaceVideo||e.removeVideo)){let r={type:"video"};e.removeVideo?r.remove=!0:(e.addVideo?r.add=!0:e.replaceVideo&&(r.replace=!0),!1!==e.videoSend&&(r.capture=e.video||!0,["screen","window","desktop"].includes(r.capture)&&(r.type="screen",r.capture={video:{}},e.screenshareFrameRate&&(r.capture.frameRate=e.screenshareFrameRate),e.screenshareHeight&&(r.capture.height=e.screenshareHeight),e.screenshareWidth&&(r.capture.width=e.screenshareWidth))),!1!==e.videoRecv&&(r.recv=!0)),(r.remove||r.capture||r.recv)&&t.push(r)}e.data&&t.push({type:"data"})}else t.push({type:"audio",capture:!0,recv:!0}),t.push({type:"video",capture:!0,recv:!0});return t},h.trackConstraints=function(e){let t={};if(!e||!e.capture)return t;if("audio"===e.type)t.audio=e.capture;else if("video"===e.type)if((e.simulcast||e.svc)&&!0===e.capture&&(e.capture="hires"),!0===e.capture||"object"==typeof e.capture)t.video=e.capture;else{let r=0,n=0;"lowres"===e.capture?(r=320,n=240):"lowres-16:9"===e.capture?(r=320,n=180):"hires"===e.capture||"hires-16:9"===e.capture||"hdres"===e.capture?(r=1280,n=720):"fhdres"===e.capture?(r=1920,n=1080):"4kres"===e.capture?(r=3840,n=2160):"stdres"===e.capture?(r=640,n=480):"stdres-16:9"===e.capture?(r=640,n=360):(h.log("Default video setting is stdres 4:3"),r=640,n=480),t.video={width:{ideal:r},height:{ideal:n}}}else"screen"===e.type&&(t.video=e.capture);return t},h.noop=function(){},h.dataChanDefaultLabel="JanusDataChannel",h.endOfCandidates=null,h.stopAllTracks=function(e){try{let t=e.getTracks();for(let e of t)h.log(e),e&&!0!==e.dontStop&&e.stop()}catch(e){}},h.init=function(e){if((e=e||{}).callback="function"==typeof e.callback?e.callback:h.noop,h.initDone)e.callback();else{if(void 0===console.log&&(console.log=function(){}),h.trace=h.noop,h.debug=h.noop,h.vdebug=h.noop,h.log=h.noop,h.warn=h.noop,h.error=h.noop,!0===e.debug||"all"===e.debug)h.trace=console.trace.bind(console),h.debug=console.debug.bind(console),h.vdebug=console.debug.bind(console),h.log=console.log.bind(console),h.warn=console.warn.bind(console),h.error=console.error.bind(console);else if(Array.isArray(e.debug))for(let t of e.debug)switch(t){case"trace":h.trace=console.trace.bind(console);break;case"debug":h.debug=console.debug.bind(console);break;case"vdebug":h.vdebug=console.debug.bind(console);break;case"log":h.log=console.log.bind(console);break;case"warn":h.warn=console.warn.bind(console);break;case"error":h.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+t+"' (supported: 'trace', 'debug', 'vdebug', 'log', warn', 'error')")}h.log("Initializing library");let t=e.dependencies||h.useDefaultDependencies();if(h.isArray=t.isArray,h.webRTCAdapter=t.webRTCAdapter,h.httpAPICall=t.httpAPICall,h.newWebSocket=t.newWebSocket,h.extension=t.extension,h.extension.init(),h.listDevices=function(e,t){e="function"==typeof e?e:h.noop,t||(t={audio:!0,video:!0}),h.isGetUserMediaAvailable()?s.mediaDevices.getUserMedia(t).then((function(t){s.mediaDevices.enumerateDevices().then((function(r){h.debug(r),e(r),h.stopAllTracks(t)}))})).catch((function(t){h.error(t),e([])})):(h.warn("navigator.mediaDevices unavailable"),e([]))},h.safariVp8=!1,"safari"===h.webRTCAdapter.browserDetails.browser&&h.webRTCAdapter.browserDetails.version>=605)if(l&&l.getCapabilities&&l.getCapabilities("video")&&l.getCapabilities("video").codecs&&l.getCapabilities("video").codecs.length){for(let e of l.getCapabilities("video").codecs)if(e&&e.mimeType&&"video/vp8"===e.mimeType.toLowerCase()){h.safariVp8=!0;break}h.safariVp8?h.log("This version of Safari supports VP8"):h.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu")}else{let e=new a({});e.createOffer({offerToReceiveVideo:!0}).then((function(t){h.safariVp8=-1!==t.sdp.indexOf("VP8"),h.safariVp8?h.log("This version of Safari supports VP8"):h.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu"),e.close(),e=null}))}h.initDone=!0,e.callback()}},h.isWebrtcSupported=function(){return!!a},h.isGetUserMediaAvailable=function(){return s.mediaDevices&&s.mediaDevices.getUserMedia},h.randomString=function(e){let t="";for(let r=0;r>>2]>>>24-i%4*8&255;t[n+i>>>2]|=o<<24-(n+i)%4*8}else for(var a=0;a>>2]=r[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r>>2]>>>24-s%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],s=0;s>>2]>>>24-s%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},h=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,s=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*l,i);if(l){for(var d=0;dn&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),o=this._iKey=t.clone(),a=s.words,c=o.words,l=0;l>>31}var d=(n<<5|n>>>27)+a+c[l];d+=l<20?1518500249+(s&i|~s&o):l<40?1859775393+(s^i^o):l<60?(s&i|s&o|i&o)-1894007588:(s^i^o)-899497514,a=o,o=i,i=s<<30|s>>>2,s=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=o._createHelper(l),n.HmacSHA1=o._createHmacHelper(l),u.SHA1)},3009:function(e,t,r){var n;e.exports=(n=r(9021),function(e){var t=n,r=t.lib,s=r.WordArray,i=r.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,s=0;s<64;)t(n)&&(s<8&&(a[s]=r(e.pow(n,.5))),c[s]=r(e.pow(n,1/3)),s++),n++}();var l=[],u=o.SHA256=i.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],s=r[1],i=r[2],o=r[3],a=r[4],u=r[5],d=r[6],h=r[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var f=l[p-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=l[p-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=m+l[p-7]+y+l[p-16]}var v=n&s^n&i^s&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&d)+c[p]+l[p];h=d,d=u,u=a,a=o+S|0,o=i,i=s,s=n,n=S+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+u|0,r[6]=r[6]+d|0,r[7]=r[7]+h|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=e.floor(n/4294967296),r[15+(s+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(u),t.HmacSHA256=i._createHmacHelper(u)}(Math),n.SHA256)},7007:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var s,i,o,l;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(n);return s.listener=r,n.wrapFn=s,s}function h(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=f(c,l);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},2881:(e,t,r)=>{var n={EventEmitter:r(4566),EmitterSubscription:r(7274)};e.exports=n},4566:(e,t,r)=>{"use strict";var n=r(7274),s=r(9402),i=r(646),o=r(9395),a=function(){function e(){this._subscriber=new s,this._currentSubscription=null}var t=e.prototype;return t.addListener=function(e,t,r){return this._subscriber.addSubscription(e,new n(this._subscriber,t,r))},t.once=function(e,t,r){var n=this;return this.addListener(e,(function(){n.removeCurrentListener(),t.apply(r,arguments)}))},t.removeAllListeners=function(e){this._subscriber.removeAllSubscriptions(e)},t.removeCurrentListener=function(){this._currentSubscription||i(!1),this._subscriber.removeSubscription(this._currentSubscription)},t.listeners=function(e){var t=this._subscriber.getSubscriptionsForType(e);return t?t.filter(o.thatReturnsTrue).map((function(e){return e.listener})):[]},t.emit=function(e){var t=this._subscriber.getSubscriptionsForType(e);if(t){for(var r=Object.keys(t),n=0;n{"use strict";var n=function(e){var t,r;function n(t,r,n){var s;return(s=e.call(this,t)||this).listener=r,s.context=n,s}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n}(r(5856));e.exports=n},5856:e=>{"use strict";var t=function(){function e(e){this.subscriber=e}return e.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},e}();e.exports=t},9402:(e,t,r)=>{"use strict";var n=r(646),s=function(){function e(){this._subscriptionsForType={},this._currentSubscription=null}var t=e.prototype;return t.addSubscription=function(e,t){t.subscriber!==this&&n(!1),this._subscriptionsForType[e]||(this._subscriptionsForType[e]=[]);var r=this._subscriptionsForType[e].length;return this._subscriptionsForType[e].push(t),t.eventType=e,t.key=r,t},t.removeAllSubscriptions=function(e){void 0===e?this._subscriptionsForType={}:delete this._subscriptionsForType[e]},t.removeSubscription=function(e){var t=e.eventType,r=e.key,n=this._subscriptionsForType[t];n&&delete n[r]},t.getSubscriptionsForType=function(e){return this._subscriptionsForType[e]},e}();e.exports=s},9395:e=>{"use strict";function t(e){return function(){return e}}var r=function(){};r.thatReturns=t,r.thatReturnsFalse=t(!1),r.thatReturnsTrue=t(!0),r.thatReturnsNull=t(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},646:e=>{"use strict";e.exports=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=n(r(261)),i=n(r(2300)),o=r(9027),a=r(1127),c=n(r(6727)),l=n(r(1350)),u=n(r(1148)),d=s.default.create;function h(){var e=d();return e.compile=function(t,r){return a.compile(t,r,e)},e.precompile=function(t,r){return a.precompile(t,r,e)},e.AST=i.default,e.Compiler=a.Compiler,e.JavaScriptCompiler=c.default,e.Parser=o.parser,e.parse=o.parse,e.parseWithoutProcessing=o.parseWithoutProcessing,e}var p=h();p.create=h,u.default(p),p.Visitor=l.default,p.default=p,t.default=p,e.exports=t.default},261:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}t.__esModule=!0;var i=s(r(2871)),o=n(r(9613)),a=n(r(3769)),c=s(r(2849)),l=s(r(7624)),u=n(r(1148));function d(){var e=new i.HandlebarsEnvironment;return c.extend(e,i),e.SafeString=o.default,e.Exception=a.default,e.Utils=c,e.escapeExpression=c.escapeExpression,e.VM=l,e.template=function(t){return l.template(t,e)},e}var h=d();h.create=d,u.default(h),h.default=h,t.default=h,e.exports=t.default},2871:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.HandlebarsEnvironment=d;var s=r(2849),i=n(r(3769)),o=r(2277),a=r(5940),c=n(r(566)),l=r(3865);t.VERSION="4.7.8",t.COMPILER_REVISION=8,t.LAST_COMPATIBLE_COMPILER_REVISION=7,t.REVISION_CHANGES={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};var u="[object Object]";function d(e,t,r){this.helpers=e||{},this.partials=t||{},this.decorators=r||{},o.registerDefaultHelpers(this),a.registerDefaultDecorators(this)}d.prototype={constructor:d,logger:c.default,log:c.default.log,registerHelper:function(e,t){if(s.toString.call(e)===u){if(t)throw new i.default("Arg not supported with multiple helpers");s.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if(s.toString.call(e)===u)s.extend(this.partials,e);else{if(void 0===t)throw new i.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if(s.toString.call(e)===u){if(t)throw new i.default("Arg not supported with multiple decorators");s.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]},resetLoggedPropertyAccesses:function(){l.resetLoggedProperties()}};var h=c.default.log;t.log=h,t.createFrame=s.createFrame,t.logger=c.default},2300:(e,t)=>{"use strict";t.__esModule=!0;var r={helpers:{helperExpression:function(e){return"SubExpression"===e.type||("MustacheStatement"===e.type||"BlockStatement"===e.type)&&!!(e.params&&e.params.length||e.hash)},scopedId:function(e){return/^\.|this\b/.test(e.original)},simpleId:function(e){return 1===e.parts.length&&!r.helpers.scopedId(e)&&!e.depth}}};t.default=r,e.exports=t.default},9027:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.parseWithoutProcessing=l,t.parse=function(e,t){var r=l(e,t);return new i.default(t).accept(r)};var s=n(r(6201)),i=n(r(915)),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8425)),a=r(2849);t.parser=s.default;var c={};function l(e,t){return"Program"===e.type?e:(s.default.yy=c,c.locInfo=function(e){return new c.SourceLocation(t&&t.srcName,e)},s.default.parse(e))}a.extend(c,o)},9632:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849),s=void 0;function i(e,t,r){if(n.isArray(e)){for(var s=[],i=0,o=e.length;i{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.Compiler=c,t.precompile=function(e,t,r){if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new s.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+e);"data"in(t=t||{})||(t.data=!0),t.compat&&(t.useDepths=!0);var n=r.parse(e,t),i=(new r.Compiler).compile(n,t);return(new r.JavaScriptCompiler).compile(i,t)},t.compile=function(e,t,r){if(void 0===t&&(t={}),null==e||"string"!=typeof e&&"Program"!==e.type)throw new s.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+e);"data"in(t=i.extend({},t))||(t.data=!0),t.compat&&(t.useDepths=!0);var n=void 0;function o(){var n=r.parse(e,t),s=(new r.Compiler).compile(n,t),i=(new r.JavaScriptCompiler).compile(s,t,void 0,!0);return r.template(i)}function a(e,t){return n||(n=o()),n.call(this,e,t)}return a._setup=function(e){return n||(n=o()),n._setup(e)},a._child=function(e,t,r,s){return n||(n=o()),n._child(e,t,r,s)},a};var s=n(r(3769)),i=r(2849),o=n(r(2300)),a=[].slice;function c(){}function l(e,t){if(e===t)return!0;if(i.isArray(e)&&i.isArray(t)&&e.length===t.length){for(var r=0;r1)throw new s.default("Unsupported number of partial arguments: "+r.length,e);r.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):r.push({type:"PathExpression",parts:[],depth:0}));var n=e.name.original,i="SubExpression"===e.name.type;i&&this.accept(e.name),this.setupFullMustacheParams(e,t,void 0,!0);var o=e.indent||"";this.options.preventIndent&&o&&(this.opcode("appendContent",o),o=""),this.opcode("invokePartial",i,n,o),this.opcode("append")},PartialBlockStatement:function(e){this.PartialStatement(e)},MustacheStatement:function(e){this.SubExpression(e),e.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(e){this.DecoratorBlock(e)},ContentStatement:function(e){e.value&&this.opcode("appendContent",e.value)},CommentStatement:function(){},SubExpression:function(e){u(e);var t=this.classifySexpr(e);"simple"===t?this.simpleSexpr(e):"helper"===t?this.helperSexpr(e):this.ambiguousSexpr(e)},ambiguousSexpr:function(e,t,r){var n=e.path,s=n.parts[0],i=null!=t||null!=r;this.opcode("getContext",n.depth),this.opcode("pushProgram",t),this.opcode("pushProgram",r),n.strict=!0,this.accept(n),this.opcode("invokeAmbiguous",s,i)},simpleSexpr:function(e){var t=e.path;t.strict=!0,this.accept(t),this.opcode("resolvePossibleLambda")},helperSexpr:function(e,t,r){var n=this.setupFullMustacheParams(e,t,r),i=e.path,a=i.parts[0];if(this.options.knownHelpers[a])this.opcode("invokeKnownHelper",n.length,a);else{if(this.options.knownHelpersOnly)throw new s.default("You specified knownHelpersOnly, but used the unknown helper "+a,e);i.strict=!0,i.falsy=!0,this.accept(i),this.opcode("invokeHelper",n.length,i.original,o.default.helpers.simpleId(i))}},PathExpression:function(e){this.addDepth(e.depth),this.opcode("getContext",e.depth);var t=e.parts[0],r=o.default.helpers.scopedId(e),n=!e.depth&&!r&&this.blockParamIndex(t);n?this.opcode("lookupBlockParam",n,e.parts):t?e.data?(this.options.data=!0,this.opcode("lookupData",e.depth,e.parts,e.strict)):this.opcode("lookupOnContext",e.parts,e.falsy,e.strict,r):this.opcode("pushContext")},StringLiteral:function(e){this.opcode("pushString",e.value)},NumberLiteral:function(e){this.opcode("pushLiteral",e.value)},BooleanLiteral:function(e){this.opcode("pushLiteral",e.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(e){var t=e.pairs,r=0,n=t.length;for(this.opcode("pushHash");r=0)return[t,s]}}}},8425:(e,t,r)=>{"use strict";t.__esModule=!0,t.SourceLocation=function(e,t){this.source=e,this.start={line:t.first_line,column:t.first_column},this.end={line:t.last_line,column:t.last_column}},t.id=function(e){return/^\[.*\]$/.test(e)?e.substring(1,e.length-1):e},t.stripFlags=function(e,t){return{open:"~"===e.charAt(2),close:"~"===t.charAt(t.length-3)}},t.stripComment=function(e){return e.replace(/^\{\{~?!-?-?/,"").replace(/-?-?~?\}\}$/,"")},t.preparePath=function(e,t,r){r=this.locInfo(r);for(var n=e?"@":"",i=[],o=0,a=0,c=t.length;a0)throw new s.default("Invalid path: "+n,{loc:r});".."===l&&o++}}return{type:"PathExpression",data:e,depth:o,parts:i,original:n,loc:r}},t.prepareMustache=function(e,t,r,n,s,i){var o=n.charAt(3)||n.charAt(2),a="{"!==o&&"&"!==o;return{type:/\*/.test(n)?"Decorator":"MustacheStatement",path:e,params:t,hash:r,escaped:a,strip:s,loc:this.locInfo(i)}},t.prepareRawBlock=function(e,t,r,n){i(e,r);var s={type:"Program",body:t,strip:{},loc:n=this.locInfo(n)};return{type:"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:s,openStrip:{},inverseStrip:{},closeStrip:{},loc:n}},t.prepareBlock=function(e,t,r,n,o,a){n&&n.path&&i(e,n);var c=/\*/.test(e.open);t.blockParams=e.blockParams;var l=void 0,u=void 0;if(r){if(c)throw new s.default("Unexpected inverse block on decorator",r);r.chain&&(r.program.body[0].closeStrip=n.strip),u=r.strip,l=r.program}return o&&(o=l,l=t,t=o),{type:c?"DecoratorBlock":"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:t,inverse:l,openStrip:e.strip,inverseStrip:u,closeStrip:n&&n.strip,loc:this.locInfo(a)}},t.prepareProgram=function(e,t){if(!t&&e.length){var r=e[0].loc,n=e[e.length-1].loc;r&&n&&(t={source:r.source,start:{line:r.start.line,column:r.start.column},end:{line:n.end.line,column:n.end.column}})}return{type:"Program",body:e,strip:{},loc:t}},t.preparePartialBlock=function(e,t,r,n){return i(e,r),{type:"PartialBlockStatement",name:e.path,params:e.params,hash:e.hash,program:t,openStrip:e.strip,closeStrip:r&&r.strip,loc:this.locInfo(n)}};var n,s=(n=r(3769))&&n.__esModule?n:{default:n};function i(e,t){if(t=t.path?t.path.original:t,e.path.original!==t){var r={loc:e.path.loc};throw new s.default(e.path.original+" doesn't match "+t,r)}}},6727:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=r(2871),i=n(r(3769)),o=r(2849),a=n(r(9632));function c(e){this.value=e}function l(){}l.prototype={nameLookup:function(e,t){return this.internalNameLookup(e,t)},depthedLookup:function(e){return[this.aliasable("container.lookup"),"(depths, ",JSON.stringify(e),")"]},compilerInfo:function(){var e=s.COMPILER_REVISION;return[e,s.REVISION_CHANGES[e]]},appendToBuffer:function(e,t,r){return o.isArray(e)||(e=[e]),e=this.source.wrap(e,t),this.environment.isSimple?["return ",e,";"]:r?["buffer += ",e,";"]:(e.appendToBuffer=!0,e)},initializeBuffer:function(){return this.quotedString("")},internalNameLookup:function(e,t){return this.lookupPropertyFunctionIsUsed=!0,["lookupProperty(",e,",",JSON.stringify(t),")"]},lookupPropertyFunctionIsUsed:!1,compile:function(e,t,r,n){this.environment=e,this.options=t,this.stringParams=this.options.stringParams,this.trackIds=this.options.trackIds,this.precompile=!n,this.name=this.environment.name,this.isChild=!!r,this.context=r||{decorators:[],programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(e,t),this.useDepths=this.useDepths||e.useDepths||e.useDecorators||this.options.compat,this.useBlockParams=this.useBlockParams||e.useBlockParams;var s=e.opcodes,o=void 0,a=void 0,c=void 0,l=void 0;for(c=0,l=s.length;c0&&(r+=", "+n.join(", "));var s=0;Object.keys(this.aliases).forEach((function(e){var n=t.aliases[e];n.children&&n.referenceCount>1&&(r+=", alias"+ ++s+"="+e,n.children[0]="alias"+s)})),this.lookupPropertyFunctionIsUsed&&(r+=", "+this.lookupPropertyFunctionVarDeclaration());var i=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&i.push("blockParams"),this.useDepths&&i.push("depths");var o=this.mergeSource(r);return e?(i.push(o),Function.apply(this,i)):this.source.wrap(["function(",i.join(","),") {\n ",o,"}"])},mergeSource:function(e){var t=this.environment.isSimple,r=!this.forceBuffer,n=void 0,s=void 0,i=void 0,o=void 0;return this.source.each((function(e){e.appendToBuffer?(i?e.prepend(" + "):i=e,o=e):(i&&(s?i.prepend("buffer += "):n=!0,o.add(";"),i=o=void 0),s=!0,t||(r=!1))})),r?i?(i.prepend("return "),o.add(";")):s||this.source.push('return "";'):(e+=", buffer = "+(n?"":this.initializeBuffer()),i?(i.prepend("return buffer + "),o.add(";")):this.source.push("return buffer;")),e&&this.source.prepend("var "+e.substring(2)+(n?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(e){var t=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs(e,0,r);var n=this.popStack();r.splice(1,0,n),this.push(this.source.functionCall(t,"call",r))},ambiguousBlockValue:function(){var e=this.aliasable("container.hooks.blockHelperMissing"),t=[this.contextName(0)];this.setupHelperArgs("",0,t,!0),this.flushInline();var r=this.topStack();t.splice(1,0,r),this.pushSource(["if (!",this.lastHelper,") { ",r," = ",this.source.functionCall(e,"call",t),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack((function(e){return[" != null ? ",e,' : ""']})),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,t,r,n){var s=0;n||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(e[s++])),this.resolvePath("context",e,s,t,r)},lookupBlockParam:function(e,t){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",t,1)},lookupData:function(e,t,r){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",t,0,!0,r)},resolvePath:function(e,t,r,n,s){var i=this;if(this.options.strict||this.options.assumeObjects)this.push(function(e,t,r,n,s){var i=t.popStack(),o=r.length;for(e&&o--;nthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var t=0,r=e.length;t{"use strict";t.__esModule=!0;var r=function(){var e={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,program_repetition0:6,statement:7,mustache:8,block:9,rawBlock:10,partial:11,partialBlock:12,content:13,COMMENT:14,CONTENT:15,openRawBlock:16,rawBlock_repetition0:17,END_RAW_BLOCK:18,OPEN_RAW_BLOCK:19,helperName:20,openRawBlock_repetition0:21,openRawBlock_option0:22,CLOSE_RAW_BLOCK:23,openBlock:24,block_option0:25,closeBlock:26,openInverse:27,block_option1:28,OPEN_BLOCK:29,openBlock_repetition0:30,openBlock_option0:31,openBlock_option1:32,CLOSE:33,OPEN_INVERSE:34,openInverse_repetition0:35,openInverse_option0:36,openInverse_option1:37,openInverseChain:38,OPEN_INVERSE_CHAIN:39,openInverseChain_repetition0:40,openInverseChain_option0:41,openInverseChain_option1:42,inverseAndProgram:43,INVERSE:44,inverseChain:45,inverseChain_option0:46,OPEN_ENDBLOCK:47,OPEN:48,mustache_repetition0:49,mustache_option0:50,OPEN_UNESCAPED:51,mustache_repetition1:52,mustache_option1:53,CLOSE_UNESCAPED:54,OPEN_PARTIAL:55,partialName:56,partial_repetition0:57,partial_option0:58,openPartialBlock:59,OPEN_PARTIAL_BLOCK:60,openPartialBlock_repetition0:61,openPartialBlock_option0:62,param:63,sexpr:64,OPEN_SEXPR:65,sexpr_repetition0:66,sexpr_option0:67,CLOSE_SEXPR:68,hash:69,hash_repetition_plus0:70,hashSegment:71,ID:72,EQUALS:73,blockParams:74,OPEN_BLOCK_PARAMS:75,blockParams_repetition_plus0:76,CLOSE_BLOCK_PARAMS:77,path:78,dataName:79,STRING:80,NUMBER:81,BOOLEAN:82,UNDEFINED:83,NULL:84,DATA:85,pathSegments:86,SEP:87,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"COMMENT",15:"CONTENT",18:"END_RAW_BLOCK",19:"OPEN_RAW_BLOCK",23:"CLOSE_RAW_BLOCK",29:"OPEN_BLOCK",33:"CLOSE",34:"OPEN_INVERSE",39:"OPEN_INVERSE_CHAIN",44:"INVERSE",47:"OPEN_ENDBLOCK",48:"OPEN",51:"OPEN_UNESCAPED",54:"CLOSE_UNESCAPED",55:"OPEN_PARTIAL",60:"OPEN_PARTIAL_BLOCK",65:"OPEN_SEXPR",68:"CLOSE_SEXPR",72:"ID",73:"EQUALS",75:"OPEN_BLOCK_PARAMS",77:"CLOSE_BLOCK_PARAMS",80:"STRING",81:"NUMBER",82:"BOOLEAN",83:"UNDEFINED",84:"NULL",85:"DATA",87:"SEP"},productions_:[0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[13,1],[10,3],[16,5],[9,4],[9,4],[24,6],[27,6],[38,6],[43,2],[45,3],[45,1],[26,3],[8,5],[8,5],[11,5],[12,3],[59,5],[63,1],[63,1],[64,5],[69,1],[71,3],[74,3],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[56,1],[56,1],[79,2],[78,1],[86,3],[86,1],[6,0],[6,2],[17,0],[17,2],[21,0],[21,2],[22,0],[22,1],[25,0],[25,1],[28,0],[28,1],[30,0],[30,2],[31,0],[31,1],[32,0],[32,1],[35,0],[35,2],[36,0],[36,1],[37,0],[37,1],[40,0],[40,2],[41,0],[41,1],[42,0],[42,1],[46,0],[46,1],[49,0],[49,2],[50,0],[50,1],[52,0],[52,2],[53,0],[53,1],[57,0],[57,2],[58,0],[58,1],[61,0],[61,2],[62,0],[62,1],[66,0],[66,2],[67,0],[67,1],[70,1],[70,2],[76,1],[76,2]],performAction:function(e,t,r,n,s,i,o){var a=i.length-1;switch(s){case 1:return i[a-1];case 2:this.$=n.prepareProgram(i[a]);break;case 3:case 4:case 5:case 6:case 7:case 8:case 20:case 27:case 28:case 33:case 34:case 40:case 41:this.$=i[a];break;case 9:this.$={type:"CommentStatement",value:n.stripComment(i[a]),strip:n.stripFlags(i[a],i[a]),loc:n.locInfo(this._$)};break;case 10:this.$={type:"ContentStatement",original:i[a],value:i[a],loc:n.locInfo(this._$)};break;case 11:this.$=n.prepareRawBlock(i[a-2],i[a-1],i[a],this._$);break;case 12:this.$={path:i[a-3],params:i[a-2],hash:i[a-1]};break;case 13:this.$=n.prepareBlock(i[a-3],i[a-2],i[a-1],i[a],!1,this._$);break;case 14:this.$=n.prepareBlock(i[a-3],i[a-2],i[a-1],i[a],!0,this._$);break;case 15:this.$={open:i[a-5],path:i[a-4],params:i[a-3],hash:i[a-2],blockParams:i[a-1],strip:n.stripFlags(i[a-5],i[a])};break;case 16:case 17:this.$={path:i[a-4],params:i[a-3],hash:i[a-2],blockParams:i[a-1],strip:n.stripFlags(i[a-5],i[a])};break;case 18:this.$={strip:n.stripFlags(i[a-1],i[a-1]),program:i[a]};break;case 19:var c=n.prepareBlock(i[a-2],i[a-1],i[a],i[a],!1,this._$),l=n.prepareProgram([c],i[a-1].loc);l.chained=!0,this.$={strip:i[a-2].strip,program:l,chain:!0};break;case 21:this.$={path:i[a-1],strip:n.stripFlags(i[a-2],i[a])};break;case 22:case 23:this.$=n.prepareMustache(i[a-3],i[a-2],i[a-1],i[a-4],n.stripFlags(i[a-4],i[a]),this._$);break;case 24:this.$={type:"PartialStatement",name:i[a-3],params:i[a-2],hash:i[a-1],indent:"",strip:n.stripFlags(i[a-4],i[a]),loc:n.locInfo(this._$)};break;case 25:this.$=n.preparePartialBlock(i[a-2],i[a-1],i[a],this._$);break;case 26:this.$={path:i[a-3],params:i[a-2],hash:i[a-1],strip:n.stripFlags(i[a-4],i[a])};break;case 29:this.$={type:"SubExpression",path:i[a-3],params:i[a-2],hash:i[a-1],loc:n.locInfo(this._$)};break;case 30:this.$={type:"Hash",pairs:i[a],loc:n.locInfo(this._$)};break;case 31:this.$={type:"HashPair",key:n.id(i[a-2]),value:i[a],loc:n.locInfo(this._$)};break;case 32:this.$=n.id(i[a-1]);break;case 35:this.$={type:"StringLiteral",value:i[a],original:i[a],loc:n.locInfo(this._$)};break;case 36:this.$={type:"NumberLiteral",value:Number(i[a]),original:Number(i[a]),loc:n.locInfo(this._$)};break;case 37:this.$={type:"BooleanLiteral",value:"true"===i[a],original:"true"===i[a],loc:n.locInfo(this._$)};break;case 38:this.$={type:"UndefinedLiteral",original:void 0,value:void 0,loc:n.locInfo(this._$)};break;case 39:this.$={type:"NullLiteral",original:null,value:null,loc:n.locInfo(this._$)};break;case 42:this.$=n.preparePath(!0,i[a],this._$);break;case 43:this.$=n.preparePath(!1,i[a],this._$);break;case 44:i[a-2].push({part:n.id(i[a]),original:i[a],separator:i[a-1]}),this.$=i[a-2];break;case 45:this.$=[{part:n.id(i[a]),original:i[a]}];break;case 46:case 48:case 50:case 58:case 64:case 70:case 78:case 82:case 86:case 90:case 94:this.$=[];break;case 47:case 49:case 51:case 59:case 65:case 71:case 79:case 83:case 87:case 91:case 95:case 99:case 101:i[a-1].push(i[a]);break;case 98:case 100:this.$=[i[a]]}},table:[{3:1,4:2,5:[2,46],6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:10,13:11,14:[1,12],15:[1,20],16:17,19:[1,23],24:15,27:16,29:[1,21],34:[1,22],39:[2,2],44:[2,2],47:[2,2],48:[1,13],51:[1,14],55:[1,18],59:19,60:[1,24]},{1:[2,1]},{5:[2,47],14:[2,47],15:[2,47],19:[2,47],29:[2,47],34:[2,47],39:[2,47],44:[2,47],47:[2,47],48:[2,47],51:[2,47],55:[2,47],60:[2,47]},{5:[2,3],14:[2,3],15:[2,3],19:[2,3],29:[2,3],34:[2,3],39:[2,3],44:[2,3],47:[2,3],48:[2,3],51:[2,3],55:[2,3],60:[2,3]},{5:[2,4],14:[2,4],15:[2,4],19:[2,4],29:[2,4],34:[2,4],39:[2,4],44:[2,4],47:[2,4],48:[2,4],51:[2,4],55:[2,4],60:[2,4]},{5:[2,5],14:[2,5],15:[2,5],19:[2,5],29:[2,5],34:[2,5],39:[2,5],44:[2,5],47:[2,5],48:[2,5],51:[2,5],55:[2,5],60:[2,5]},{5:[2,6],14:[2,6],15:[2,6],19:[2,6],29:[2,6],34:[2,6],39:[2,6],44:[2,6],47:[2,6],48:[2,6],51:[2,6],55:[2,6],60:[2,6]},{5:[2,7],14:[2,7],15:[2,7],19:[2,7],29:[2,7],34:[2,7],39:[2,7],44:[2,7],47:[2,7],48:[2,7],51:[2,7],55:[2,7],60:[2,7]},{5:[2,8],14:[2,8],15:[2,8],19:[2,8],29:[2,8],34:[2,8],39:[2,8],44:[2,8],47:[2,8],48:[2,8],51:[2,8],55:[2,8],60:[2,8]},{5:[2,9],14:[2,9],15:[2,9],19:[2,9],29:[2,9],34:[2,9],39:[2,9],44:[2,9],47:[2,9],48:[2,9],51:[2,9],55:[2,9],60:[2,9]},{20:25,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:36,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:37,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{4:38,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{15:[2,48],17:39,18:[2,48]},{20:41,56:40,64:42,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:44,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{5:[2,10],14:[2,10],15:[2,10],18:[2,10],19:[2,10],29:[2,10],34:[2,10],39:[2,10],44:[2,10],47:[2,10],48:[2,10],51:[2,10],55:[2,10],60:[2,10]},{20:45,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:46,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:47,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:41,56:48,64:42,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[2,78],49:49,65:[2,78],72:[2,78],80:[2,78],81:[2,78],82:[2,78],83:[2,78],84:[2,78],85:[2,78]},{23:[2,33],33:[2,33],54:[2,33],65:[2,33],68:[2,33],72:[2,33],75:[2,33],80:[2,33],81:[2,33],82:[2,33],83:[2,33],84:[2,33],85:[2,33]},{23:[2,34],33:[2,34],54:[2,34],65:[2,34],68:[2,34],72:[2,34],75:[2,34],80:[2,34],81:[2,34],82:[2,34],83:[2,34],84:[2,34],85:[2,34]},{23:[2,35],33:[2,35],54:[2,35],65:[2,35],68:[2,35],72:[2,35],75:[2,35],80:[2,35],81:[2,35],82:[2,35],83:[2,35],84:[2,35],85:[2,35]},{23:[2,36],33:[2,36],54:[2,36],65:[2,36],68:[2,36],72:[2,36],75:[2,36],80:[2,36],81:[2,36],82:[2,36],83:[2,36],84:[2,36],85:[2,36]},{23:[2,37],33:[2,37],54:[2,37],65:[2,37],68:[2,37],72:[2,37],75:[2,37],80:[2,37],81:[2,37],82:[2,37],83:[2,37],84:[2,37],85:[2,37]},{23:[2,38],33:[2,38],54:[2,38],65:[2,38],68:[2,38],72:[2,38],75:[2,38],80:[2,38],81:[2,38],82:[2,38],83:[2,38],84:[2,38],85:[2,38]},{23:[2,39],33:[2,39],54:[2,39],65:[2,39],68:[2,39],72:[2,39],75:[2,39],80:[2,39],81:[2,39],82:[2,39],83:[2,39],84:[2,39],85:[2,39]},{23:[2,43],33:[2,43],54:[2,43],65:[2,43],68:[2,43],72:[2,43],75:[2,43],80:[2,43],81:[2,43],82:[2,43],83:[2,43],84:[2,43],85:[2,43],87:[1,50]},{72:[1,35],86:51},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{52:52,54:[2,82],65:[2,82],72:[2,82],80:[2,82],81:[2,82],82:[2,82],83:[2,82],84:[2,82],85:[2,82]},{25:53,38:55,39:[1,57],43:56,44:[1,58],45:54,47:[2,54]},{28:59,43:60,44:[1,58],47:[2,56]},{13:62,15:[1,20],18:[1,61]},{33:[2,86],57:63,65:[2,86],72:[2,86],80:[2,86],81:[2,86],82:[2,86],83:[2,86],84:[2,86],85:[2,86]},{33:[2,40],65:[2,40],72:[2,40],80:[2,40],81:[2,40],82:[2,40],83:[2,40],84:[2,40],85:[2,40]},{33:[2,41],65:[2,41],72:[2,41],80:[2,41],81:[2,41],82:[2,41],83:[2,41],84:[2,41],85:[2,41]},{20:64,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:65,47:[1,66]},{30:67,33:[2,58],65:[2,58],72:[2,58],75:[2,58],80:[2,58],81:[2,58],82:[2,58],83:[2,58],84:[2,58],85:[2,58]},{33:[2,64],35:68,65:[2,64],72:[2,64],75:[2,64],80:[2,64],81:[2,64],82:[2,64],83:[2,64],84:[2,64],85:[2,64]},{21:69,23:[2,50],65:[2,50],72:[2,50],80:[2,50],81:[2,50],82:[2,50],83:[2,50],84:[2,50],85:[2,50]},{33:[2,90],61:70,65:[2,90],72:[2,90],80:[2,90],81:[2,90],82:[2,90],83:[2,90],84:[2,90],85:[2,90]},{20:74,33:[2,80],50:71,63:72,64:75,65:[1,43],69:73,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{72:[1,79]},{23:[2,42],33:[2,42],54:[2,42],65:[2,42],68:[2,42],72:[2,42],75:[2,42],80:[2,42],81:[2,42],82:[2,42],83:[2,42],84:[2,42],85:[2,42],87:[1,50]},{20:74,53:80,54:[2,84],63:81,64:75,65:[1,43],69:82,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:83,47:[1,66]},{47:[2,55]},{4:84,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{47:[2,20]},{20:85,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:86,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{26:87,47:[1,66]},{47:[2,57]},{5:[2,11],14:[2,11],15:[2,11],19:[2,11],29:[2,11],34:[2,11],39:[2,11],44:[2,11],47:[2,11],48:[2,11],51:[2,11],55:[2,11],60:[2,11]},{15:[2,49],18:[2,49]},{20:74,33:[2,88],58:88,63:89,64:75,65:[1,43],69:90,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{65:[2,94],66:91,68:[2,94],72:[2,94],80:[2,94],81:[2,94],82:[2,94],83:[2,94],84:[2,94],85:[2,94]},{5:[2,25],14:[2,25],15:[2,25],19:[2,25],29:[2,25],34:[2,25],39:[2,25],44:[2,25],47:[2,25],48:[2,25],51:[2,25],55:[2,25],60:[2,25]},{20:92,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,31:93,33:[2,60],63:94,64:75,65:[1,43],69:95,70:76,71:77,72:[1,78],75:[2,60],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,33:[2,66],36:96,63:97,64:75,65:[1,43],69:98,70:76,71:77,72:[1,78],75:[2,66],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,22:99,23:[2,52],63:100,64:75,65:[1,43],69:101,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,33:[2,92],62:102,63:103,64:75,65:[1,43],69:104,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,105]},{33:[2,79],65:[2,79],72:[2,79],80:[2,79],81:[2,79],82:[2,79],83:[2,79],84:[2,79],85:[2,79]},{33:[2,81]},{23:[2,27],33:[2,27],54:[2,27],65:[2,27],68:[2,27],72:[2,27],75:[2,27],80:[2,27],81:[2,27],82:[2,27],83:[2,27],84:[2,27],85:[2,27]},{23:[2,28],33:[2,28],54:[2,28],65:[2,28],68:[2,28],72:[2,28],75:[2,28],80:[2,28],81:[2,28],82:[2,28],83:[2,28],84:[2,28],85:[2,28]},{23:[2,30],33:[2,30],54:[2,30],68:[2,30],71:106,72:[1,107],75:[2,30]},{23:[2,98],33:[2,98],54:[2,98],68:[2,98],72:[2,98],75:[2,98]},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],73:[1,108],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{23:[2,44],33:[2,44],54:[2,44],65:[2,44],68:[2,44],72:[2,44],75:[2,44],80:[2,44],81:[2,44],82:[2,44],83:[2,44],84:[2,44],85:[2,44],87:[2,44]},{54:[1,109]},{54:[2,83],65:[2,83],72:[2,83],80:[2,83],81:[2,83],82:[2,83],83:[2,83],84:[2,83],85:[2,83]},{54:[2,85]},{5:[2,13],14:[2,13],15:[2,13],19:[2,13],29:[2,13],34:[2,13],39:[2,13],44:[2,13],47:[2,13],48:[2,13],51:[2,13],55:[2,13],60:[2,13]},{38:55,39:[1,57],43:56,44:[1,58],45:111,46:110,47:[2,76]},{33:[2,70],40:112,65:[2,70],72:[2,70],75:[2,70],80:[2,70],81:[2,70],82:[2,70],83:[2,70],84:[2,70],85:[2,70]},{47:[2,18]},{5:[2,14],14:[2,14],15:[2,14],19:[2,14],29:[2,14],34:[2,14],39:[2,14],44:[2,14],47:[2,14],48:[2,14],51:[2,14],55:[2,14],60:[2,14]},{33:[1,113]},{33:[2,87],65:[2,87],72:[2,87],80:[2,87],81:[2,87],82:[2,87],83:[2,87],84:[2,87],85:[2,87]},{33:[2,89]},{20:74,63:115,64:75,65:[1,43],67:114,68:[2,96],69:116,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,117]},{32:118,33:[2,62],74:119,75:[1,120]},{33:[2,59],65:[2,59],72:[2,59],75:[2,59],80:[2,59],81:[2,59],82:[2,59],83:[2,59],84:[2,59],85:[2,59]},{33:[2,61],75:[2,61]},{33:[2,68],37:121,74:122,75:[1,120]},{33:[2,65],65:[2,65],72:[2,65],75:[2,65],80:[2,65],81:[2,65],82:[2,65],83:[2,65],84:[2,65],85:[2,65]},{33:[2,67],75:[2,67]},{23:[1,123]},{23:[2,51],65:[2,51],72:[2,51],80:[2,51],81:[2,51],82:[2,51],83:[2,51],84:[2,51],85:[2,51]},{23:[2,53]},{33:[1,124]},{33:[2,91],65:[2,91],72:[2,91],80:[2,91],81:[2,91],82:[2,91],83:[2,91],84:[2,91],85:[2,91]},{33:[2,93]},{5:[2,22],14:[2,22],15:[2,22],19:[2,22],29:[2,22],34:[2,22],39:[2,22],44:[2,22],47:[2,22],48:[2,22],51:[2,22],55:[2,22],60:[2,22]},{23:[2,99],33:[2,99],54:[2,99],68:[2,99],72:[2,99],75:[2,99]},{73:[1,108]},{20:74,63:125,64:75,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,23],14:[2,23],15:[2,23],19:[2,23],29:[2,23],34:[2,23],39:[2,23],44:[2,23],47:[2,23],48:[2,23],51:[2,23],55:[2,23],60:[2,23]},{47:[2,19]},{47:[2,77]},{20:74,33:[2,72],41:126,63:127,64:75,65:[1,43],69:128,70:76,71:77,72:[1,78],75:[2,72],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,24],14:[2,24],15:[2,24],19:[2,24],29:[2,24],34:[2,24],39:[2,24],44:[2,24],47:[2,24],48:[2,24],51:[2,24],55:[2,24],60:[2,24]},{68:[1,129]},{65:[2,95],68:[2,95],72:[2,95],80:[2,95],81:[2,95],82:[2,95],83:[2,95],84:[2,95],85:[2,95]},{68:[2,97]},{5:[2,21],14:[2,21],15:[2,21],19:[2,21],29:[2,21],34:[2,21],39:[2,21],44:[2,21],47:[2,21],48:[2,21],51:[2,21],55:[2,21],60:[2,21]},{33:[1,130]},{33:[2,63]},{72:[1,132],76:131},{33:[1,133]},{33:[2,69]},{15:[2,12],18:[2,12]},{14:[2,26],15:[2,26],19:[2,26],29:[2,26],34:[2,26],47:[2,26],48:[2,26],51:[2,26],55:[2,26],60:[2,26]},{23:[2,31],33:[2,31],54:[2,31],68:[2,31],72:[2,31],75:[2,31]},{33:[2,74],42:134,74:135,75:[1,120]},{33:[2,71],65:[2,71],72:[2,71],75:[2,71],80:[2,71],81:[2,71],82:[2,71],83:[2,71],84:[2,71],85:[2,71]},{33:[2,73],75:[2,73]},{23:[2,29],33:[2,29],54:[2,29],65:[2,29],68:[2,29],72:[2,29],75:[2,29],80:[2,29],81:[2,29],82:[2,29],83:[2,29],84:[2,29],85:[2,29]},{14:[2,15],15:[2,15],19:[2,15],29:[2,15],34:[2,15],39:[2,15],44:[2,15],47:[2,15],48:[2,15],51:[2,15],55:[2,15],60:[2,15]},{72:[1,137],77:[1,136]},{72:[2,100],77:[2,100]},{14:[2,16],15:[2,16],19:[2,16],29:[2,16],34:[2,16],44:[2,16],47:[2,16],48:[2,16],51:[2,16],55:[2,16],60:[2,16]},{33:[1,138]},{33:[2,75]},{33:[2,32]},{72:[2,101],77:[2,101]},{14:[2,17],15:[2,17],19:[2,17],29:[2,17],34:[2,17],39:[2,17],44:[2,17],47:[2,17],48:[2,17],51:[2,17],55:[2,17],60:[2,17]}],defaultActions:{4:[2,1],54:[2,55],56:[2,20],60:[2,57],73:[2,81],82:[2,85],86:[2,18],90:[2,89],101:[2,53],104:[2,93],110:[2,19],111:[2,77],116:[2,97],119:[2,63],122:[2,69],135:[2,75],136:[2,32]},parseError:function(e,t){throw new Error(e)},parse:function(e){var t=[0],r=[null],n=[],s=this.table,i="",o=0,a=0,c=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var l=this.lexer.yylloc;n.push(l);var u=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var d,h,p,f,m,g,y,v,b,S,C={};;){if(p=t[t.length-1],this.defaultActions[p]?f=this.defaultActions[p]:(null==d&&(S=void 0,"number"!=typeof(S=this.lexer.lex()||1)&&(S=this.symbols_[S]||S),d=S),f=s[p]&&s[p][d]),void 0===f||!f.length||!f[0]){var w="";if(!c){for(g in b=[],s[p])this.terminals_[g]&&g>2&&b.push("'"+this.terminals_[g]+"'");w=this.lexer.showPosition?"Parse error on line "+(o+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[d]||d)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==d?"end of input":"'"+(this.terminals_[d]||d)+"'"),this.parseError(w,{text:this.lexer.match,token:this.terminals_[d]||d,line:this.lexer.yylineno,loc:l,expected:b})}}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+d);switch(f[0]){case 1:t.push(d),r.push(this.lexer.yytext),n.push(this.lexer.yylloc),t.push(f[1]),d=null,h?(d=h,h=null):(a=this.lexer.yyleng,i=this.lexer.yytext,o=this.lexer.yylineno,l=this.lexer.yylloc,c>0&&c--);break;case 2:if(y=this.productions_[f[1]][1],C.$=r[r.length-y],C._$={first_line:n[n.length-(y||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(y||1)].first_column,last_column:n[n.length-1].last_column},u&&(C._$.range=[n[n.length-(y||1)].range[0],n[n.length-1].range[1]]),void 0!==(m=this.performAction.call(C,i,a,o,this.yy,f[1],r,n)))return m;y&&(t=t.slice(0,-1*y*2),r=r.slice(0,-1*y),n=n.slice(0,-1*y)),t.push(this.productions_[f[1]][0]),r.push(C.$),n.push(C._$),v=s[t[t.length-2]][t[t.length-1]],t.push(v);break;case 3:return!0}}return!0}},t={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;var e,t,r,n,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;ot[0].length)||(t=r,n=o,this.options.flex));o++);return t?((s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,i[n],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return void 0!==e?e:this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(e){this.begin(e)},options:{},performAction:function(e,t,r,n){function s(e,r){return t.yytext=t.yytext.substring(e,t.yyleng-r+e)}switch(r){case 0:if("\\\\"===t.yytext.slice(-2)?(s(0,1),this.begin("mu")):"\\"===t.yytext.slice(-1)?(s(0,1),this.begin("emu")):this.begin("mu"),t.yytext)return 15;break;case 1:case 5:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(s(5,9),"END_RAW_BLOCK");case 6:case 22:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:case 23:return 48;case 21:this.unput(t.yytext),this.popState(),this.begin("com");break;case 24:return 73;case 25:case 26:case 41:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return t.yytext=s(1,2).replace(/\\"/g,'"'),80;case 32:return t.yytext=s(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 42:return t.yytext=t.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};function r(){this.yy={}}return e.lexer=t,r.prototype=e,e.Parser=r,new r}();t.default=r,e.exports=t.default},1350:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=(n=r(3769))&&n.__esModule?n:{default:n};function i(){this.parents=[]}function o(e){this.acceptRequired(e,"path"),this.acceptArray(e.params),this.acceptKey(e,"hash")}function a(e){o.call(this,e),this.acceptKey(e,"program"),this.acceptKey(e,"inverse")}function c(e){this.acceptRequired(e,"name"),this.acceptArray(e.params),this.acceptKey(e,"hash")}i.prototype={constructor:i,mutating:!1,acceptKey:function(e,t){var r=this.accept(e[t]);if(this.mutating){if(r&&!i.prototype[r.type])throw new s.default('Unexpected node type "'+r.type+'" found when accepting '+t+" on "+e.type);e[t]=r}},acceptRequired:function(e,t){if(this.acceptKey(e,t),!e[t])throw new s.default(e.type+" requires "+t)},acceptArray:function(e){for(var t=0,r=e.length;t{"use strict";t.__esModule=!0;var n,s=(n=r(1350))&&n.__esModule?n:{default:n};function i(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=e}function o(e,t,r){void 0===t&&(t=e.length);var n=e[t-1],s=e[t-2];return n?"ContentStatement"===n.type?(s||!r?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(n.original):void 0:r}function a(e,t,r){void 0===t&&(t=-1);var n=e[t+1],s=e[t+2];return n?"ContentStatement"===n.type?(s||!r?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(n.original):void 0:r}function c(e,t,r){var n=e[null==t?0:t+1];if(n&&"ContentStatement"===n.type&&(r||!n.rightStripped)){var s=n.value;n.value=n.value.replace(r?/^\s+/:/^[ \t]*\r?\n?/,""),n.rightStripped=n.value!==s}}function l(e,t,r){var n=e[null==t?e.length-1:t-1];if(n&&"ContentStatement"===n.type&&(r||!n.leftStripped)){var s=n.value;return n.value=n.value.replace(r?/\s+$/:/[ \t]+$/,""),n.leftStripped=n.value!==s,n.leftStripped}}i.prototype=new s.default,i.prototype.Program=function(e){var t=!this.options.ignoreStandalone,r=!this.isRootSeen;this.isRootSeen=!0;for(var n=e.body,s=0,i=n.length;s{"use strict";t.__esModule=!0,t.registerDefaultDecorators=function(e){s.default(e)};var n,s=(n=r(7430))&&n.__esModule?n:{default:n}},7430:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849);t.default=function(e){e.registerDecorator("inline",(function(e,t,r,s){var i=e;return t.partials||(t.partials={},i=function(s,i){var o=r.partials;r.partials=n.extend({},o,t.partials);var a=e(s,i);return r.partials=o,a}),t.partials[s.args[0]]=s.fn,i}))},e.exports=t.default},3769:(e,t)=>{"use strict";t.__esModule=!0;var r=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function n(e,t){var s=t&&t.loc,i=void 0,o=void 0,a=void 0,c=void 0;s&&(i=s.start.line,o=s.end.line,a=s.start.column,c=s.end.column,e+=" - "+i+":"+a);for(var l=Error.prototype.constructor.call(this,e),u=0;u{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.registerDefaultHelpers=function(e){s.default(e),i.default(e),o.default(e),a.default(e),c.default(e),l.default(e),u.default(e)},t.moveHelperToHooks=function(e,t,r){e.helpers[t]&&(e.hooks[t]=e.helpers[t],r||delete e.helpers[t])};var s=n(r(6097)),i=n(r(6785)),o=n(r(4353)),a=n(r(2355)),c=n(r(5300)),l=n(r(7466)),u=n(r(908))},6097:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849);t.default=function(e){e.registerHelper("blockHelperMissing",(function(t,r){var s=r.inverse,i=r.fn;if(!0===t)return i(this);if(!1===t||null==t)return s(this);if(n.isArray(t))return t.length>0?(r.ids&&(r.ids=[r.name]),e.helpers.each(t,r)):s(this);if(r.data&&r.ids){var o=n.createFrame(r.data);o.contextPath=n.appendContextPath(r.data.contextPath,r.name),r={data:o}}return i(t,r)}))},e.exports=t.default},6785:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("each",(function(e,t){if(!t)throw new i.default("Must pass iterator to #each");var r,n=t.fn,o=t.inverse,a=0,c="",l=void 0,u=void 0;function d(t,r,i){l&&(l.key=t,l.index=r,l.first=0===r,l.last=!!i,u&&(l.contextPath=u+t)),c+=n(e[t],{data:l,blockParams:s.blockParams([e[t],t],[u+t,null])})}if(t.data&&t.ids&&(u=s.appendContextPath(t.data.contextPath,t.ids[0])+"."),s.isFunction(e)&&(e=e.call(this)),t.data&&(l=s.createFrame(t.data)),e&&"object"==typeof e)if(s.isArray(e))for(var h=e.length;a{"use strict";t.__esModule=!0;var n,s=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("helperMissing",(function(){if(1!==arguments.length)throw new s.default('Missing helper: "'+arguments[arguments.length-1].name+'"')}))},e.exports=t.default},2355:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("if",(function(e,t){if(2!=arguments.length)throw new i.default("#if requires exactly one argument");return s.isFunction(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||s.isEmpty(e)?t.inverse(this):t.fn(this)})),e.registerHelper("unless",(function(t,r){if(2!=arguments.length)throw new i.default("#unless requires exactly one argument");return e.helpers.if.call(this,t,{fn:r.inverse,inverse:r.fn,hash:r.hash})}))},e.exports=t.default},5300:(e,t)=>{"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("log",(function(){for(var t=[void 0],r=arguments[arguments.length-1],n=0;n{"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("lookup",(function(e,t,r){return e?r.lookupProperty(e,t):e}))},e.exports=t.default},908:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("with",(function(e,t){if(2!=arguments.length)throw new i.default("#with requires exactly one argument");s.isFunction(e)&&(e=e.call(this));var r=t.fn;if(s.isEmpty(e))return t.inverse(this);var n=t.data;return t.data&&t.ids&&((n=s.createFrame(t.data)).contextPath=s.appendContextPath(t.data.contextPath,t.ids[0])),r(e,{data:n,blockParams:s.blockParams([e],[n&&n.contextPath])})}))},e.exports=t.default},9726:(e,t,r)=>{"use strict";t.__esModule=!0,t.createNewLookupObject=function(){for(var e=arguments.length,t=Array(e),r=0;r{"use strict";t.__esModule=!0,t.createProtoAccessControl=function(e){var t=Object.create(null);t.constructor=!1,t.__defineGetter__=!1,t.__defineSetter__=!1,t.__lookupGetter__=!1;var r=Object.create(null);return r.__proto__=!1,{properties:{whitelist:s.createNewLookupObject(r,e.allowedProtoProperties),defaultValue:e.allowProtoPropertiesByDefault},methods:{whitelist:s.createNewLookupObject(t,e.allowedProtoMethods),defaultValue:e.allowProtoMethodsByDefault}}},t.resultIsAllowed=function(e,t,r){return function(e,t){return void 0!==e.whitelist[t]?!0===e.whitelist[t]:void 0!==e.defaultValue?e.defaultValue:(function(e){!0!==o[e]&&(o[e]=!0,i.default.log("error",'Handlebars: Access has been denied to resolve the property "'+e+'" because it is not an "own property" of its parent.\nYou can add a runtime option to disable the check or this warning:\nSee https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details'))}(t),!1)}("function"==typeof e?t.methods:t.properties,r)},t.resetLoggedProperties=function(){Object.keys(o).forEach((function(e){delete o[e]}))};var n,s=r(9726),i=(n=r(566))&&n.__esModule?n:{default:n},o=Object.create(null)},2614:(e,t)=>{"use strict";t.__esModule=!0,t.wrapHelper=function(e,t){return"function"!=typeof e?e:function(){return arguments[arguments.length-1]=t(arguments[arguments.length-1]),e.apply(this,arguments)}}},566:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849),s={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(e){if("string"==typeof e){var t=n.indexOf(s.methodMap,e.toLowerCase());e=t>=0?t:parseInt(e,10)}return e},log:function(e){if(e=s.lookupLevel(e),"undefined"!=typeof console&&s.lookupLevel(s.level)<=e){var t=s.methodMap[e];console[t]||(t="log");for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i{"use strict";t.__esModule=!0,t.default=function(e){"object"!=typeof globalThis&&(Object.prototype.__defineGetter__("__magic__",(function(){return this})),__magic__.globalThis=__magic__,delete Object.prototype.__magic__);var t=globalThis.Handlebars;e.noConflict=function(){return globalThis.Handlebars===e&&(globalThis.Handlebars=t),e}},e.exports=t.default},7624:(e,t,r)=>{"use strict";t.__esModule=!0,t.checkRevision=function(e){var t=e&&e[0]||1,r=o.COMPILER_REVISION;if(!(t>=o.LAST_COMPATIBLE_COMPILER_REVISION&&t<=o.COMPILER_REVISION)){if(t{"use strict";function r(e){this.string=e}t.__esModule=!0,r.prototype.toString=r.prototype.toHTML=function(){return""+this.string},t.default=r,e.exports=t.default},2849:(e,t)=>{"use strict";t.__esModule=!0,t.extend=o,t.indexOf=function(e,t){for(var r=0,n=e.length;r":">",'"':""","'":"'","`":"`","=":"="},n=/[&<>"'`=]/g,s=/[&<>"'`=]/;function i(e){return r[e]}function o(e){for(var t=1;t{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},8287:e=>{"use strict";e.exports=function(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,r){let n=-1;return function s(i){if(i<=n)return Promise.reject(new Error("next() called multiple times"));n=i;let o=e[i];if(i===e.length&&(o=r),!o)return Promise.resolve();try{return Promise.resolve(o(t,s.bind(null,i+1)))}catch(e){return Promise.reject(e)}}(0)}}},8775:(e,t,r)=>{"use strict";var n=r(8712),s=n.escapeXML,i=n.escapeXMLText,o=r(3255),a=o.equal,c=o.name,l=o.attrs,u=o.children,d=r(3942);function h(e,t){this.name=e,this.parent=null,this.children=[],this.attrs={},this.setAttrs(t)}h.prototype.is=function(e,t){return this.getName()===e&&(!t||this.getNS()===t)},h.prototype.getName=function(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name},h.prototype.getNS=function(){if(this.name.indexOf(":")>=0){var e=this.name.substr(0,this.name.indexOf(":"));return this.findNS(e)}return this.findNS()},h.prototype.findNS=function(e){if(e){var t="xmlns:"+e;if(this.attrs[t])return this.attrs[t];if(this.parent)return this.parent.findNS(e)}else{if(this.attrs.xmlns)return this.attrs.xmlns;if(this.parent)return this.parent.findNS()}},h.prototype.getXmlns=function(){var e={};for(var t in this.parent&&(e=this.parent.getXmlns()),this.attrs){var r=t.match("xmlns:?(.*)");this.attrs.hasOwnProperty(t)&&r&&(e[this.attrs[t]]=r[1])}return e},h.prototype.setAttrs=function(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach((function(t){this.attrs[t]=e[t]}),this)},h.prototype.getAttr=function(e,t){if(!t)return this.attrs[e];var r=this.getXmlns();return r[t]?this.attrs[[r[t],e].join(":")]:null},h.prototype.getChild=function(e,t){return this.getChildren(e,t)[0]},h.prototype.getChildren=function(e,t){for(var r=[],n=0;n");for(var t=0;t")},h.prototype.write=function(e){for(var t in e("<"),e(this.name),this.attrs){var r=this.attrs[t];null!=r&&(e(" "),e(t),e('="'),"string"!=typeof r&&(r=r.toString()),e(s(r)),e('"'))}0===this.children.length?e("/>"):this._addChildren(e)},h.prototype.nameEquals=function(e){return c(this,e)},h.prototype.attrsEquals=function(e){return l(this,e)},h.prototype.childrenEquals=function(e){return u(this,e)},h.prototype.equals=function(e){return a(this,e)},e.exports=h},3942:e=>{"use strict";e.exports=function(e){for(var t=new e.constructor(e.name,e.attrs),r=0;r{"use strict";function t(e,t){return e.name===t.name}function r(e,t){var r=e.attrs,n=Object.keys(r),s=n.length;if(s!==Object.keys(t.attrs).length)return!1;for(var i=0,o=s;i{"use strict";var r={"&":"&","<":"<",">":">",'"':""","'":"'"};function n(e){return r[e]}var s={"&":"&","<":"<",">":">",""":'"',"'":"'"};function i(e){if("#"===e[1]){var t;if(9===(t="x"===e[2]?parseInt(e.slice(3),16):parseInt(e.slice(2),10))||10===t||13===t||t>=32&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111)return String.fromCodePoint(t);throw new Error("Illegal XML character 0x"+t.toString(16))}if(s[e])return s[e]||e;throw new Error("Illegal XML entity "+e)}t.escapeXML=function(e){return e.replace(/&|<|>|"|'/g,n)},t.unescapeXML=function(e){for(var t="",r=-1,n=-1,s=0;-1!==(r=e.indexOf("&",s))&&-1!==(n=e.indexOf(";",r+1));)t=t+e.substring(s,r)+i(e.substring(r,n+1)),s=n+1;return 0===s?e:t+=e.substring(s)},t.escapeXMLText=function(e){return e.replace(/&|<|>/g,n)},t.unescapeXMLText=function(e){return e.replace(/&(amp|#38|lt|#60|gt|#62);/g,i)}},9416:(e,t,r)=>{"use strict";var n=r(6698),s=r(7007).EventEmitter,i=r(8712).unescapeXML,o=e.exports=function(){s.call(this);var e,t,r,n,o,a,c,l,u=0,d=0;this._handleTagOpening=function(e,t,r){e?this.emit("endElement",t):(this.emit("startElement",t,r),o&&this.emit("endElement",t))},this.write=function(s){"string"!=typeof s&&(s=s.toString());var h=0;function p(){if("number"==typeof d){var e=s.substring(d,h);return d=void 0,e}}for(e&&(s=e+s,h+=e.length,e=null);h",h);-1!==y&&(h=y+2)}var v=s.charCodeAt(h);switch(u){case 0:if(60===v){var b=p();b&&this.emit("text",i(b)),u=3,d=h+1,r={}}break;case 9:if(93===v&&"]>"===s.substr(h+1,2)){var S=p();S&&this.emit("text",S),u=0}break;case 3:47===v&&d===h?(d=h+1,n=!0):33===v?"[CDATA["===s.substr(h+1,7)?(d=h+8,u=9):(d=void 0,u=1):63===v?(d=void 0,u=2):(v<=32||47===v||62===v)&&(t=p(),h--,u=4);break;case 1:if(62===v){var C=s.charCodeAt(h-1),w=s.charCodeAt(h-2);(45===C&&45===w||93===C&&93===w)&&(u=0)}break;case 2:62===v&&63===s.charCodeAt(h-1)&&(u=0);break;case 4:62===v?(this._handleTagOpening(n,t,r),t=void 0,r=void 0,n=void 0,o=void 0,u=0,d=h+1):47===v?o=!0:v>32&&(d=h,u=5);break;case 5:(v<=32||61===v)&&(l=p(),h--,u=6);break;case 6:61===v&&(u=7);break;case 7:34!==v&&39!==v||(a=v,c=34===v?'"':"'",u=8,d=h+1);break;case 8:if(v===a){var k=i(p());r[l]=k,l=void 0,u=4}}}"number"==typeof d&&d<=s.length&&(e=s.slice(d),d=0)}};n(o,s),o.prototype.end=function(e){e&&this.write(e),this.write=function(){}}},4011:function(e,t,r){!function(e,t){function r(){}r.prototype.name="ANONYMOUS",r.prototype.clientFirst=!0,r.prototype.response=function(e){return e.trace||""},r.prototype.challenge=function(e){},t.exports=r}(0,e=r.nmd(e))},3481:function(e,t,r){!function(e,t,r){(t.exports=r).Mechanism=r}(0,e=r.nmd(e),r(4011))},7474:function(e,t,r){!function(e,t){function r(){}r.prototype.name="PLAIN",r.prototype.clientFirst=!0,r.prototype.response=function(e){var t="";return t+=e.authzid||"",t+="\0",t+=e.username,(t+="\0")+e.password},r.prototype.challenge=function(e){return this},t.exports=r}(0,e=r.nmd(e))},1978:function(e,t,r){!function(e,t,r){(t.exports=r).Mechanism=r}(0,e=r.nmd(e),r(7474))},2074:function(e,t,r){!function(e,t){function r(){this._mechs=[]}r.prototype.use=function(e,t){return t||(e=(t=e).prototype.name),this._mechs.push({name:e,mech:t}),this},r.prototype.create=function(e){for(var t=0,r=this._mechs.length;t{"use strict";e.exports=t},8849:t=>{"use strict";t.exports=e},2969:()=>{},732:()=>{},477:()=>{},2122:e=>{"use strict";e.exports={rE:"3.32.0"}}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}return s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e=s(639),t=s.n(e),r=s(1605),n=s.n(r),i={appId:5,authKey:"fESpBfG6KS4yhO7",authSecret:"FEcQedvDA36U5nx"},o={debug:{mode:1},videochat:{disconnectTimeInterval:300},endpoints:{api:"apidev.connectycube.com",chat:"chatdev.connectycube.com"},conference:{server:"wss://janusdev.connectycube.com:8989"}},a=[{id:422,name:"Alice",login:"videouser1",password:"videouser1",color:"#34ad86"},{id:424,name:"Bob",login:"videouser2",password:"videouser2",color:"#077988"},{id:425,name:"Ciri",login:"videouser3",password:"videouser3",color:"#13aaae"},{id:426,name:"Dexter",login:"videouser4",password:"videouser4",color:"#056a96"}];function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function l(e,t){for(var r=0;r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return s("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),D(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var s=n.arg;D(r)}return s}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:O(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function v(e,t,r,n,s,i,o){try{var a=e[i](o),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,s)}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function w(e,t){if(e){if("string"==typeof e)return k(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0){var e,t=C(r.needIceRestartForUsersIds);try{for(t.s();!(e=t.n()).done;){var n=e.value;r.maybeDoIceRestart(r._session,n)}}catch(e){t.e(e)}finally{t.f()}}r.isOnline=!0}})),x(this,"$calling",document.getElementById("signal-in")),x(this,"$dialing",document.getElementById("signal-out")),x(this,"$endCall",document.getElementById("signal-end")),x(this,"$modal",document.getElementById("call-modal-incoming")),x(this,"$muteUnmuteButton",document.getElementById("videochat-mute-unmute")),x(this,"$switchCameraButton",document.getElementById("videochat-switch-camera")),x(this,"$switchSharingScreenButton",document.getElementById("videochat-sharing-screen")),x(this,"mediaParams",{audio:!0,video:!0,elementId:"localStream",options:{muted:!0,mirror:!0}}),x(this,"sharingScreenMediaParams",{audio:!0,video:{frameRate:{ideal:10,max:15}},elementId:"localStream",options:{muted:!0,mirror:!1}}),x(this,"_session",null),x(this,"mediaDevicesIds",[]),x(this,"activeDeviceId",null),x(this,"isAudioMuted",!1),x(this,"isSharingScreen",!1),x(this,"startEventSharinScreen",null),x(this,"defaultSettings",(function(){T&&(r.$switchSharingScreenButton.disabled=!0)})),x(this,"addStreamElements",(function(e){var r=document.getElementById("videochat-streams"),n=document.getElementById("videochat-streams-template"),s=t().compile(n.innerHTML);2===e.length?r.classList.value="grid-2-1":3===e.length&&(r.classList.value="grid-2-2"),document.getElementById("call").classList.add("hidden"),document.getElementById("videochat").classList.remove("hidden"),r.innerHTML=s({opponents:e})})),x(this,"onCallListener",(function(e,t){return e.initiatorID!==e.currentUserID&&(r._session?(r.rejectCall(e,{busy:!0}),!1):(r._session=e,void r.showIncomingCallModal()))})),x(this,"onAcceptCallListener",(function(e,t,n){if(t===e.currentUserID)return r.$modal.classList.contains("show")&&(r._session=null,r.hideIncomingCallModal(),r.showSnackbar("You have accepted the call on other side")),!1;var s=r._getUserById(t,"name"),i="".concat(s," has accepted the call");r.showSnackbar(i),r.$dialing.pause()})),x(this,"onRejectCallListener",(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t===e.currentUserID)return r.$modal.classList.contains("show")&&(r._session=null,r.hideIncomingCallModal(),r.showSnackbar("You have rejected the call on other side")),!1;var s=r._getUserById(t,"name"),i=n.busy?"".concat(s," is busy"):"".concat(s," rejected the call request");r.stopCall(t),r.showSnackbar(i)})),x(this,"onStopCallListener",(function(e,t,n){if(!r._session)return!1;var s=e.initiatorID===t,i=r._getUserById(t,"name"),o="".concat(i," has ").concat(s?"stopped":"left"," the call");r.showSnackbar(o),s?(r.$modal.classList.contains("show")&&r.hideIncomingCallModal(),r.stopCall()):r.stopCall(t)})),x(this,"onUserNotAnswerListener",(function(e,t){if(!r._session)return!1;var n=r._getUserById(t,"name"),s="".concat(n," did not answer");r.showSnackbar(s),r.stopCall(t)})),x(this,"onRemoteStreamListener",(function(e,t,n){if(!r._session)return!1;var s="remoteStream-".concat(t);document.getElementById("videochat-stream-loader-".concat(t)).remove(),r._session.attachMediaStream(s,n),r.$muteUnmuteButton.disabled=!1,r.onDevicesChangeListener(),r._prepareVideoElement(s)})),x(this,"acceptCall",(function(){var e={},t=r._session,s=t.opponentsIDs,i=t.initiatorID,o=t.currentUserID,a=t.callType,c=[i].concat(function(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(s)).filter((function(e){return o!==e})).map((function(e){return{id:e,name:r._getUserById(e,"name")}}));r.defaultSettings(),r.addStreamElements(c),r.hideIncomingCallModal();var l=S({},r.mediaParams);a===n().videochat.CallType.AUDIO&&delete l.video,r._session.getUserMedia(l).then((function(t){r._session.getDisplayMedia&&a!==n().videochat.CallType.AUDIO||(r.$switchSharingScreenButton.disabled=!0),r._session.accept(e),r.setActiveDeviceId(t),r._prepareVideoElement("localStream")}))})),x(this,"rejectCall",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e?e.reject(t):(r._session.reject(t),r._session=null,r.hideIncomingCallModal())})),x(this,"startAudioCall",(function(){r.startCall(n().videochat.CallType.AUDIO)})),x(this,"startVideoCall",(function(){r.startCall(n().videochat.CallType.VIDEO)})),x(this,"startCall",(function(e){var t=[],s=[];if(r.defaultSettings(),document.querySelectorAll(".select-user-checkbox").forEach((function(e){if(e.checked){var n=+e.dataset.id,i=r._getUserById(n,"name");t.push({id:n,name:i}),s.push(n),e.checked=!1}})),t.length>0){document.getElementById("call").classList.add("hidden"),document.getElementById("videochat").classList.remove("hidden"),r.$dialing.play(),r.addStreamElements(t),r._session=n().videochat.createNewSession(s,e,{}),console.log("startCall",{callType:e},n().videochat.CallType.AUDIO);var i=S({},r.mediaParams);e===n().videochat.CallType.AUDIO&&delete i.video,r._session.getUserMedia(i).then((function(t){r._session.getDisplayMedia&&e!==n().videochat.CallType.AUDIO||(r.$switchSharingScreenButton.disabled=!0),r._session.call({}),r.setActiveDeviceId(t),r._prepareVideoElement("localStream")}));var o=r._getUserById(r._session.initiatorID,"name"),a={message:"Incoming call from ".concat(o),ios_voip:1,initiatorId:r._session.initiatorID,opponentsIds:s.join(","),handle:o,uuid:r._session.ID,callType:e===n().videochat.CallType.VIDEO?"video":"audio"},c=JSON.stringify(a),l={notification_type:"push",user:{ids:s},message:n().pushnotifications.base64Encode(c)};n().pushnotifications.events.create(l).then((function(e){console.log("[sendPushNotification] Ok")})).catch((function(e){console.warn("[sendPushNotification] Error",e)}))}else r.showSnackbar("Select at less one user to start Videocall")})),x(this,"stopCall",(function(e){var t=document.getElementById("call"),s=document.getElementById("videochat"),i=document.getElementById("videochat-mute-unmute"),o=document.getElementById("videochat-streams");if(e){document.getElementById("videochat-stream-container-".concat(e)).remove();var a=document.querySelectorAll(".videochat-stream-container");a.length<2?r.stopCall():2===a.length?o.classList.value="":3===a.length&&(o.classList.value="grid-2-1")}else if(r._session){var c,l=C(document.getElementById("localStream").srcObject.getTracks());try{for(l.s();!(c=l.n()).done;)c.value.stop()}catch(e){l.e(e)}finally{l.f()}r._session.stop({}),n().videochat.clearSession(r._session.ID),r.$dialing.pause(),r.$calling.pause(),r.$endCall.play(),r.$muteUnmuteButton.disabled=!0,r.$switchCameraButton.disabled=!0,r._session=null,r.mediaDevicesIds=[],r.activeDeviceId=null,r.isAudioMuted=!1,o.innerHTML="",o.classList.value="",t.classList.remove("hidden"),s.classList.add("hidden"),i.classList.remove("muted"),r.isSharingScreen&&(r.isSharingScreen=!1,r.updateSharingScreenBtn()),E&&(s.style.background="#000000")}})),x(this,"onDevicesChangeListener",(function(){E||n().videochat.getMediaDevices("videoinput").then((function(e){var t;r.mediaDevicesIds=null==e?void 0:e.map((function(e){return e.deviceId})),r.mediaDevicesIds.length<2||r._session.callType===n().videochat.CallType.AUDIO?(r.$switchCameraButton.disabled=!0,r.activeDeviceId&&(null===(t=r.mediaDevicesIds)||void 0===t?void 0:t[0])!==r.activeDeviceId&&!r.isSharingScreen&&r.switchCamera()):r.$switchCameraButton.disabled=!1}))})),x(this,"onSessionConnectionStateChangedListener",(function(e,t,s){console.log("[onSessionConnectionStateChangedListener]",t,s);var i=n().videochat.SessionConnectionState,o=i.DISCONNECTED,a=i.FAILED,c=i.CONNECTED,l=i.CLOSED;s===o||s===a?r.iceRestartTimeout=setTimeout((function(){console.log("Connection not restored within 30 seconds, trying ICE restart.."),r.isOnline?r.maybeDoIceRestart(e,t):(console.log("Skip ICE restart, no Internet connection "),r.needIceRestartForUsersIds.push(t))}),3e4):s===c?(clearTimeout(r.iceRestartTimeout),r.iceRestartTimeout=null,r.needIceRestartForUsersIds=[]):s===l&&(r.needIceRestartForUsersIds=[])})),x(this,"setActiveDeviceId",(function(e){if(e&&!E){var t,n=null===(t=e.getVideoTracks()[0])||void 0===t?void 0:t.getSettings();r.activeDeviceId=null==n?void 0:n.deviceId}})),x(this,"setAudioMute",(function(){var e=document.getElementById("videochat-mute-unmute");r.isAudioMuted?(r._session.unmute("audio"),r.isAudioMuted=!1,e.classList.remove("muted")):(r._session.mute("audio"),r.isAudioMuted=!0,e.classList.add("muted"))})),x(this,"switchCamera",(function(){var e=r.mediaDevicesIds.find((function(e){return e!==r.activeDeviceId}));r._session.switchMediaTracks({video:e}).then((function(){r.activeDeviceId=e,r.isAudioMuted&&r._session.mute("audio")}))})),x(this,"sharingScreen",(function(){if(!r.isSharingScreen)return r._session.getDisplayMedia(r.sharingScreenMediaParams,!0).then((function(e){r.updateStream(e),r.isSharingScreen=!0,r.updateSharingScreenBtn(),r.startEventSharinScreen=e.getVideoTracks()[0].addEventListener("ended",(function(){return r.stopSharingScreen()}))}),(function(e){console.warn("[Get display media error]",e,r.mediaParam),r.stopSharingScreen()}));r.stopSharingScreen()})),x(this,"updateSharingScreenBtn",(function(){var e=document.getElementById("videochat-sharing-screen"),t=document.getElementById("videochat-sharing-screen-icon");r.isSharingScreen?(e.classList.add("videochat-sharing-screen-active"),t.classList.add("videochat-sharing-screen-icon-active")):(e.classList.remove("videochat-sharing-screen-active"),t.classList.remove("videochat-sharing-screen-icon-active"))})),x(this,"stopSharingScreen",(function(){return r._session.getUserMedia(r.mediaParams,!0).then((function(e){r.updateStream(e),r.isSharingScreen=!1,r.updateSharingScreenBtn(),r.startEventSharinScreen=null}))})),x(this,"updateStream",(function(e){r.setActiveDeviceId(e),r._prepareVideoElement("localStream")})),x(this,"showSnackbar",(function(e){var t=document.getElementById("snackbar");t.innerHTML=e,t.classList.add("show"),setTimeout((function(){t.innerHTML="",t.classList.remove("show")}),3e3)})),x(this,"showIncomingCallModal",(function(){return r._incomingCallModal("show")})),x(this,"hideIncomingCallModal",(function(){return r._incomingCallModal("hide")})),x(this,"_incomingCallModal",(function(e){var t=document.getElementById("call-modal-initiator");"hide"===e?(t.innerHTML="",r.$modal.classList.remove("show"),r.$calling.pause()):(t.innerHTML=r._getUserById(r._session.initiatorID,"name"),r.$modal.classList.add("show"),r.$calling.play())})),x(this,"_getUserById",(function(e,t){var r=a.find((function(t){return t.id==e}));return"string"==typeof t?r[t]:r})),x(this,"_prepareVideoElement",(function(e){var t=document.getElementById(e);t.style.visibility="visible",E&&(document.getElementById("videochat").style.background="transparent",t.style.backgroundColor="",t.style.zIndex=-1)}))},r=[{key:"maybeDoIceRestart",value:(s=y().mark((function e(t,r){return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("[maybeDoIceRestart] Chat PING"),e.prev=1,e.next=4,n().chat.pingWithTimeout();case 4:console.log("[maybeDoIceRestart] Chat PONG"),console.log("[maybeDoIceRestart] canInitiateIceRestart: ",t.canInitiateIceRestart(r)),t.canInitiateIceRestart(r)&&(console.log("[maybeDoIceRestart] do ICE restart"),t.iceRestart(r)),e.next=20;break;case 9:return e.prev=9,e.t0=e.catch(1),console.error(e.t0.message),console.log("[maybeDoIceRestart] do Chat restart"),e.next=15,n().chat.disconnect();case 15:return e.next=17,n().chat.connect({userId:this.currentUser.id,password:this.currentUser.password});case 17:console.log("[maybeDoIceRestart] Chat restarted"),console.log("[maybeDoIceRestart] canInitiateIceRestart: ",t.canInitiateIceRestart(r)),t.canInitiateIceRestart(r)&&(console.log("[maybeDoIceRestart] do ICE restart"),t.iceRestart(r));case 20:case"end":return e.stop()}}),e,this,[[1,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,n){var i=s.apply(e,t);function o(e){v(i,r,n,o,a,"next",e)}function a(e){v(i,r,n,o,a,"throw",e)}o(void 0)}))},function(e,t){return i.apply(this,arguments)})}],r&&_(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,s,i}());function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function D(e,t){for(var r=0;r(()=>{var r={1862:(e,t,r)=>{"use strict";e.exports.encode=function(e){return r.g.btoa(e)},e.exports.decode=function(e){return r.g.atob(e)}},5734:(e,t,r)=>{"use strict";const n=r(5251),s=r(7930),i=r(1192);e.exports.Client=n,e.exports.xml=s,e.exports.jid=i},5251:(e,t,r)=>{"use strict";const n=r(3073);class s extends n{constructor(e){super(e),this.transports=[]}send(e,...t){return this.Transport.prototype.send.call(this,e,...t)}_findTransport(e){return this.transports.find((t=>{try{return void 0!==t.prototype.socketParameters(e)}catch(e){return!1}}))}connect(e){const t=this._findTransport(e);if(!t)throw new Error("No compatible connection method found.");return this.Transport=t,this.Socket=t.prototype.Socket,this.Parser=t.prototype.Parser,super.connect(e)}socketParameters(...e){return this.Transport.prototype.socketParameters(...e)}header(...e){return this.Transport.prototype.header(...e)}headerElement(...e){return this.Transport.prototype.headerElement(...e)}footer(...e){return this.Transport.prototype.footer(...e)}footerElement(...e){return this.Transport.prototype.footerElement(...e)}}s.prototype.NS="jabber:client",e.exports=s},5150:e=>{"use strict";e.exports=function(e){return(e.split("://")[1]||e).split(":")[0].split("/")[0]}},3113:(e,t,r)=>{"use strict";const{xml:n,jid:s,Client:i}=r(5734),o=r(5150),a=r(6826),c=r(3312),l=r(5013),u=r(3323),d=r(3812),h=r(353),p=r(7127),f=r(7802),m=r(145),g=r(9717),y=r(7718),v=r(4767);e.exports.xml=n,e.exports.jid=s,e.exports.client=function(e={}){const{resource:t,credentials:r,username:n,password:s,...b}=e,{domain:S,service:C}=b;!S&&C&&(b.domain=o(C));const w=new i(b),k=a({entity:w}),_=c({entity:w}),x=l({entity:w}),I=u({middleware:x}),E=d({middleware:x,entity:w}),T=h({middleware:x,entity:w}),P=p({entity:w}),L=f({streamFeatures:I},r||{username:n,password:s}),D=m({iqCaller:E,streamFeatures:I},t),A=g({iqCaller:E,streamFeatures:I}),O=Object.entries({plain:v,anonymous:y}).map((([e,t])=>({[e]:t(L)})));return Object.assign(w,{entity:w,reconnect:k,websocket:_,middleware:x,streamFeatures:I,iqCaller:E,iqCallee:T,resolve:P,sasl:L,resourceBinding:D,sessionEstablishment:A,mechanisms:O})}},3073:(e,t,r)=>{"use strict";const{EventEmitter:n,promise:s}=r(3572),i=r(1192),o=r(7930),a=r(3611),{parseHost:c,parseService:l}=r(1473);class u extends n{constructor(e={}){super(),this.jid=null,this.timeout=2e3,this.options=e,this.socketListeners=Object.create(null),this.parserListeners=Object.create(null),this.status="offline",this.socket=null,this.parser=null,this.root=null}_reset(){this.jid=null,this.status="offline",this._detachSocket(),this._detachParser()}async _streamError(e,t){try{await this.send(o("stream:error",{},[o(e,{xmlns:"urn:ietf:params:xml:ns:xmpp-streams"},t)]))}catch(e){}return this._end()}_onData(e){const t=e.toString("utf8");this.emit("input",t),this.parser.write(t)}_onParserError(e){this._streamError("bad-format"),this._detachParser(),this.emit("error",e)}_attachSocket(e){const t=this.socket=e,r=this.socketListeners;r.data=this._onData.bind(this),r.close=(e,t)=>{this._reset(),this._status("disconnect",{clean:!e,event:t})},r.connect=()=>{this._status("connect")},r.error=e=>{this.emit("error",e)},t.on("close",r.close),t.on("data",r.data),t.on("error",r.error),t.on("connect",r.connect)}_detachSocket(){const{socketListeners:e,socket:t}=this;return Object.getOwnPropertyNames(e).forEach((r=>{t.removeListener(r,e[r]),delete e[r]})),this.socket=null,t}_onElement(e){this.emit("element",e),this.emit(this.isStanza(e)?"stanza":"nonza",e),"stream:error"===e.name&&this._onStreamError(e)}_onStreamError(e){const t=a.fromElement(e);"see-other-host"===t.condition?this._onSeeOtherHost(t):this.emit("error",t),this._end()}async _onSeeOtherHost(e){const{protocol:t}=l(this.options.service),r=e.element.getChildText("see-other-host"),{port:n}=c(r);let i;i=n?`${t||"xmpp:"}//${r}`:(t?`${t}//`:"")+r;try{await s(this,"disconnect");const{domain:e,lang:t}=this.options;await this.connect(i),await this.open({domain:e,lang:t})}catch(e){this.emit("error",e)}}_attachParser(e){const t=this.parser=e,r=this.parserListeners;r.element=this._onElement.bind(this),r.error=this._onParserError.bind(this),r.end=e=>{this._detachParser(),this._status("close",e)},r.start=e=>{this._status("open",e)},t.on("error",r.error),t.on("element",r.element),t.on("end",r.end),t.on("start",r.start)}_detachParser(){const e=this.parserListeners;Object.getOwnPropertyNames(e).forEach((t=>{this.parser.removeListener(t,e[t]),delete e[t]})),this.parser=null}_jid(e){return this.jid=i(e),this.jid}_status(e,...t){this.status=e,this.emit("status",e,...t),this.emit(e,...t)}async _end(){let e;try{e=await this.close()}catch(e){}try{await this.disconnect()}catch(e){}return e}async start(){if("offline"!==this.status)throw new Error("Connection is not offline");const{service:e,domain:t,lang:r}=this.options;await this.connect(e);const n=s(this,"online");return await this.open({domain:t,lang:r}),n}async connect(e){this._status("connecting",e);const t=new this.Socket;return this._attachSocket(t),t.connect(this.socketParameters(e)),s(t,"connect")}async disconnect(e=this.timeout){this.socket&&this._status("disconnecting"),this.socket.end(),await s(this.socket,"close","error",e)}async open(e){this._status("opening"),"string"==typeof e&&(e={domain:e});const{domain:t,lang:r,timeout:n=this.timeout}=e,i=this.headerElement();return i.attrs.to=t,i.attrs["xml:lang"]=r,this.root=i,this._attachParser(new this.Parser),await this.write(this.header(i)),s(this,"open","error",n)}async stop(){const e=await this._end();return"offline"!==this.status&&this._status("offline",e),e}async close(e=this.timeout){const t=Promise.all([s(this.parser,"end","error",e),this.write(this.footer(this.footerElement()))]);this.parser&&this.socket&&this._status("closing");const[r]=await t;return this.root=null,r}async restart(){this._detachParser();const{domain:e,lang:t}=this.options;return this.open({domain:e,lang:t})}async send(e){e.parent=this.root,this.emit("outgoing",e),await this.write(e),this.emit("send",e)}sendReceive(e,t=this.timeout){return Promise.all([this.send(e),s(this,"element","error",t)]).then((([,e])=>e))}write(e){return new Promise(((t,r)=>{if("closing"===this.status)return void r(new Error("Connection is closing"));const n=e.toString("utf8");this.socket.write(n,(e=>{if(e)return r(e);this.emit("output",n),t()}))}))}isStanza(e){const{name:t}=e;return"iq"===t||"message"===t||"presence"===t}isNonza(e){return!this.isStanza(e)}header(e){return e.toString()}headerElement(){return new o.Element("",{version:"1.0",xmlns:this.NS})}footer(e){return e.toString()}footerElement(){}socketParameters(){}}u.prototype.NS="",u.prototype.Socket=null,u.prototype.Parser=null,e.exports=u},3611:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(...e){super(...e),this.name="StreamError"}}},1473:e=>{"use strict";function t(e){let{port:t,hostname:r,protocol:n}=new URL(e);return"[::1]"===r&&(r="::1"),{port:t,hostname:r,protocol:n}}function r(e){const{port:r,hostname:n}=t(`http://${e}`);return{port:r,hostname:n}}Object.assign(e.exports,{parseURI:t,parseHost:r,parseService:function(e){return e.includes("://")?t(e):r(e)}})},2649:e=>{"use strict";class t extends Error{constructor(e,t,r){super(e+(t?` - ${t}`:"")),this.name="XMPPError",this.condition=e,this.text=t,this.application=r}static fromElement(e){const[t,r,n]=e.children;let s,i;r&&(r.is("text")?s=r:r&&(i=r),n&&(i=n));const o=new this(t.name,s?s.text():"",i);return o.element=e,o}}e.exports=t},3572:(e,t,r)=>{"use strict";const n=r(5407),s=r(9639),i=r(6585),o=r(7989),a=r(7007),c=r(4845);t.EventEmitter=a,t.timeout=n,t.delay=s,t.TimeoutError=i,t.promise=o,t.Deferred=c},4845:e=>{"use strict";e.exports=function(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},6585:e=>{"use strict";e.exports=class extends Error{constructor(e){super(e),this.name="TimeoutError"}}},9639:e=>{"use strict";e.exports=function(e){let t;const r=new Promise((r=>{t=setTimeout(r,e)}));return r.timeout=t,r}},7989:(e,t,r)=>{"use strict";const n=r(6585);e.exports=function(e,t,r="error",s){return new Promise(((i,o)=>{let a;const c=()=>{clearTimeout(a),e.removeListener(t,u),e.removeListener(r,l)};function l(e){o(e),c()}function u(e){i(e),c()}e.once(t,u),r&&e.once(r,l),s&&(a=setTimeout((()=>{c(),o(new n)}),s))}))}},5407:(e,t,r)=>{"use strict";const n=r(6585),s=r(9639);e.exports=function(e,t){const r=s(t);return Promise.race([e.finally((function(){clearTimeout(r.timeout)})),r.then((()=>{throw new n}))])}},1208:e=>{"use strict";e.exports=function(){let e;for(;!e;)e=Math.random().toString(36).slice(2,12);return e}},353:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-stanzas";function i({stanza:e}){return n("iq",{to:e.attrs.from,from:e.attrs.to,id:e.attrs.id})}function o(e,t,r){const n=i(e);return n.attrs.type="error",r&&n.append(r),n.append(t),n}function a(e,t){return n("error",{type:e},n(t,s))}function c(e,t,r,n){return function(s,i){return s.type!==e|!s.element||!s.element.is(r,t)?i():n(s,i)}}e.exports=function({middleware:e,entity:t}){return e.use(function(e){return async function(t,r){if(!function({name:e,type:t}){return"iq"===e&&"error"!==t&&"result"!==t}(t))return r();const{stanza:s}=t,c=s.getChildElements(),[l]=c;if(!function({type:e},t,r){return("get"===e||"set"===e)&&1===t.length&&!!r}(t,c,l))return o(t,a("modify","bad-request"),l);let u;t.element=l;try{u=await r()}catch(t){e.emit("error",t),u=a("cancel","internal-server-error")}return u||(u=a("cancel","service-unavailable")),u instanceof n.Element&&u.is("error")?o(t,u,l):function(e,t){const r=i(e);return r.attrs.type="result",t&&r.append(t),r}(t,u instanceof n.Element?u:void 0)}}(t)),{get(t,r,n){e.use(c("get",t,r,n))},set(t,r,n){e.use(c("set",t,r,n))}}}},3812:(e,t,r)=>{"use strict";const n=r(1208),s=r(6808),{Deferred:i}=r(3572),o=r(3572).timeout,a=r(7930);class c{constructor({entity:e,middleware:t}){this.handlers=new Map,this.entity=e,this.middleware=t}start(){this.middleware.use(this._route.bind(this))}_route({type:e,name:t,id:r,stanza:n},i){if(!function({name:e,type:t}){return"iq"===e&&("error"===t||"result"===t)}({name:t,type:e}))return i();const o=this.handlers.get(r);if(!o)return i();"error"===e?o.reject(s.fromElement(n.getChild("error"))):o.resolve(n),this.handlers.delete(r)}async request(e,t=3e4){e.attrs.id||(e.attrs.id=n());const r=new i;this.handlers.set(e.attrs.id,r);try{await this.entity.send(e),await o(r.promise,t)}catch(t){throw this.handlers.delete(e.attrs.id),t}return r.promise}_childRequest(e,t,r,...n){const{name:s}=t,{xmlns:i}=t.attrs;return this.request(a("iq",{type:e,to:r},t),...n).then((e=>e.getChild(s,i)))}async get(...e){return this._childRequest("get",...e)}async set(...e){return this._childRequest("set",...e)}}e.exports=function(...e){const t=new c(...e);return t.start(),t}},1192:(e,t,r)=>{"use strict";const n=r(3435),s=r(5294),i=r(1287);function o(...e){return e[1]||e[2]?new n(...e):i(...e)}(t=e.exports=o.bind()).jid=o,t.JID=n,t.equal=function(e,t){return e.equals(t)},t.detectEscape=s.detect,t.escapeLocal=s.escape,t.unescapeLocal=s.unescape,t.parse=i},3435:(e,t,r)=>{"use strict";const n=r(5294);class s{constructor(e,t,r){if("string"!=typeof t||!t)throw new TypeError("Invalid domain.");this.setDomain(t),this.setLocal("string"==typeof e?e:""),this.setResource("string"==typeof r?r:"")}[Symbol.toPrimitive](e){return"number"===e?NaN:this.toString()}toString(e){let t=this._domain;return this._local&&(t=this.getLocal(e)+"@"+t),this._resource&&(t=t+"/"+this._resource),t}bare(){return this._resource?new s(this._local,this._domain,null):this}equals(e){return this._local===e._local&&this._domain===e._domain&&this._resource===e._resource}setLocal(e,t){return(t=t||n.detect(e))&&(e=n.escape(e)),this._local=e&&e.toLowerCase(),this}getLocal(e){let t=null;return t=(e=e||!1)?n.unescape(this._local):this._local,t}setDomain(e){return this._domain=e.toLowerCase(),this}getDomain(){return this._domain}setResource(e){return this._resource=e,this}getResource(){return this._resource}}Object.defineProperty(s.prototype,"local",{get:s.prototype.getLocal,set:s.prototype.setLocal}),Object.defineProperty(s.prototype,"domain",{get:s.prototype.getDomain,set:s.prototype.setDomain}),Object.defineProperty(s.prototype,"resource",{get:s.prototype.getResource,set:s.prototype.setResource}),e.exports=s},5294:e=>{"use strict";e.exports.detect=function(e){return!!e&&-1!==e.replace(/\\20/g,"").replace(/\\22/g,"").replace(/\\26/g,"").replace(/\\27/g,"").replace(/\\2f/g,"").replace(/\\3a/g,"").replace(/\\3c/g,"").replace(/\\3e/g,"").replace(/\\40/g,"").replace(/\\5c/g,"").search(/\\| |"|&|'|\/|:|<|>|@/g)},e.exports.escape=function(e){return null===e?null:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(//g,"\\3e").replace(/@/g,"\\40").replace(/\3a/g,"c3a")},e.exports.unescape=function(e){return null===e?null:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")}},1287:(e,t,r)=>{"use strict";const n=r(3435);e.exports=function(e){let t,r;const s=e.indexOf("/");-1!==s&&(r=e.slice(s+1),e=e.slice(0,s));const i=e.indexOf("@");return-1!==i&&(t=e.slice(0,i),e=e.slice(i+1)),new n(t,e,r)}},5013:(e,t,r)=>{"use strict";const n=r(8287),s=r(6210),i=r(1600);function o(e,t,r){return function(s){const i=new r(e,s);return n(t)(i)}}function a(e){return function(t,r){r().then((t=>t&&e.send(t))).catch((t=>e.emit("error",t)))}}e.exports=function({entity:e}){const t=[a(e)],r=[],n=o(e,t,s),c=o(e,r,i);return e.on("element",n),e.hookOutgoing=c,{use:e=>(t.push(e),e),filter:e=>(r.push(e),e)}}},1354:e=>{"use strict";e.exports=class{constructor(e,t){this.stanza=t,this.entity=e;const{name:r,attrs:n}=t,{type:s,id:i}=n;this.name=r,this.id=i||"",this.type="message"===r?s||"normal":"presence"===r?s||"available":s||"",this.from=null,this.to=null,this.local="",this.domain="",this.resource=""}}},6210:(e,t,r)=>{"use strict";const n=r(1354),s=r(1192);e.exports=class extends n{constructor(e,t){super(e,t);const{jid:r,domain:n}=e,i=t.attrs.to||r&&r.toString(),o=t.attrs.from||n;i&&(this.to=new s(i)),o&&(this.from=new s(o),this.local=this.from.local,this.domain=this.from.domain,this.resource=this.from.resource)}}},1600:(e,t,r)=>{"use strict";const n=r(1354),s=r(1192);e.exports=class extends n{constructor(e,t){super(e,t);const{jid:r,domain:n}=e,i=t.attrs.from||r&&r.toString(),o=t.attrs.to||n;i&&(this.from=new s(i)),o&&(this.to=new s(o),this.local=this.to.local,this.domain=this.to.domain,this.resource=this.to.resource)}}},6808:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(e,t,r,n){super(e,t,r),this.type=n,this.name="StanzaError"}static fromElement(e){const t=super.fromElement(e);return t.type=e.attrs.type,t}}},6826:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(3572);class s extends n{constructor(e){super(),this.delay=1e3,this.entity=e,this._timeout=null}scheduleReconnect(){const{entity:e,delay:t,_timeout:r}=this;clearTimeout(r),this._timeout=setTimeout((async()=>{if("disconnect"===e.status)try{await this.reconnect()}catch(e){}}),t)}async reconnect(){const{entity:e}=this;this.emit("reconnecting");const{service:t,domain:r,lang:n}=e.options;await e.connect(t),await e.open({domain:r,lang:n}),this.emit("reconnected")}start(){const{entity:e}=this,t={};t.disconnect=()=>{this.scheduleReconnect()},this.listeners=t,e.on("disconnect",t.disconnect)}stop(){const{entity:e,listeners:t,_timeout:r}=this;e.removeListener("disconnect",t.disconnect),clearTimeout(r)}}e.exports=function({entity:e}){const t=new s(e);return t.start(),t}},7127:(e,t,r)=>{"use strict";const n=r(6119),{promise:s}=r(3572);async function i(e,t){if(0===t.length)throw new Error("Couldn't connect");const r=t.shift(),n=e._findTransport(r);if(!n)return i(e,t);e._status("connecting",r);const o=n.prototype.socketParameters(r),a=new n.prototype.Socket;try{a.connect(o),await s(a,"connect")}catch(r){return i(e,t)}e._attachSocket(a),a.emit("connect"),e.Transport=n,e.Socket=n.prototype.Socket,e.Parser=n.prototype.Parser}e.exports=function({entity:e}){const t=e.connect;e.connect=async function(r){if(!r||r.match(/:\/\//))return t.call(this,r);const s=function(e,t){return t.filter((t=>e._findTransport(t)))}(e,await async function(e){return[...new Set((await n(e,{srv:[{service:"xmpps-client",protocol:"tcp"},{service:"xmpp-client",protocol:"tcp"}]})).map((e=>e.uri)))]}(r));if(0===s.length)throw new Error("No compatible transport found.");try{await i(e,s)}catch(t){throw e._reset(),e._status("disconnect"),t}}}},8096:e=>{"use strict";function t(e){return e.startsWith("https")||e.startsWith("wss")}e.exports.U=function(e,r){let n,s;return n=t(e.uri)&&!t(r.uri)?-1:!t(e.uri)&&t(r.uri)?1:0,0!==n?n:(s=e.method===r.method?0:"websocket"===e.method?-1:"websocket"===r.method?1:"xbosh"===e.method?-1:"xbosh"===r.method?1:"httppoll"===e.method?-1:"httppoll"===r.method?1:0,0!==s?s:0)}},163:(e,t,r)=>{"use strict";const n=r.g.fetch||r(8849),s=r(3837),i=r(8096).U;e.exports.resolve=function(e){return n(`https://${e}/.well-known/host-meta`).then((e=>e.text())).then((e=>s(e).getChildren("Link").filter((e=>["urn:xmpp:alt-connections:websocket","urn:xmpp:alt-connections:httppoll","urn:xmpp:alt-connections:xbosh"].includes(e.attrs.rel))).map((({attrs:e})=>({rel:e.rel,href:e.href,method:e.rel.split(":").pop(),uri:e.href}))).sort(i))).catch((()=>[]))}},6119:(e,t,r)=>{"use strict";const n=r(2969),s=r(163);e.exports=function(...e){return Promise.all([n.resolve?n.resolve(...e):Promise.resolve([]),s.resolve(...e)]).then((([e,t])=>e.concat(t)))},n.resolve&&(e.exports.dns=n),e.exports.http=s},145:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-bind";async function i(e,t,r){const i=await t.set(function(e){return n("bind",{xmlns:s},e&&n("resource",{},e))}(r)),o=i.getChildText("jid");return e._jid(o),o}e.exports=function({streamFeatures:e,iqCaller:t},r){e.use("bind",s,function({iqCaller:e},t){return async function({entity:r},n){"function"==typeof t?await t((t=>i(r,e,t))):await i(r,e,t),n()}}({iqCaller:t},r))}},7718:(e,t,r)=>{"use strict";const n=r(3481);e.exports=function(e){e.use(n)}},4767:(e,t,r)=>{"use strict";const n=r(1978);e.exports=function(e){e.use(n)}},7802:(e,t,r)=>{"use strict";const{encode:n,decode:s}=r(1862),i=r(401),o=r(7930),a=r(5591),c="urn:ietf:params:xml:ns:xmpp-sasl";async function l(e,t,r,a){const l=e.create([r]);if(!l)throw new Error("No compatible mechanism");const{domain:u}=t.options,d={username:null,password:null,server:u,host:u,realm:u,serviceType:"xmpp",serviceName:u,...a};return new Promise(((e,r)=>{const a=u=>{if(u.attrs.xmlns===c)if("challenge"!==u.name)"failure"===u.name?r(i.fromElement(u)):"success"===u.name&&e(),t.removeListener("nonza",a);else{l.challenge(s(u.text()));const e=l.response(d);t.send(o("response",{xmlns:c,mechanism:l.name},"string"==typeof e?n(e):""))}};t.on("nonza",a),l.clientFirst&&t.send(o("auth",{xmlns:c,mechanism:l.name},n(l.response(d))))}))}e.exports=function({streamFeatures:e},t){const r=new a;return e.use("mechanisms",c,(async({stanza:e,entity:n})=>{const s=e.getChild("mechanisms",c).children.map((e=>e.text())),i=r._mechs.map((({name:e})=>e)).filter((e=>s.includes(e)));let o=i[0];"function"==typeof t?await t((e=>l(r,n,o,e)),o):(t.username||t.password||(o="ANONYMOUS"),await l(r,n,o,t)),await n.restart()})),{use:(...e)=>r.use(...e)}}},401:(e,t,r)=>{"use strict";const n=r(2649);e.exports=class extends n{constructor(...e){super(...e),this.name="SASLError"}}},9717:(e,t,r)=>{"use strict";const n=r(7930),s="urn:ietf:params:xml:ns:xmpp-session";e.exports=function({iqCaller:e,streamFeatures:t}){t.use("session",s,(async(t,r,i)=>(i.getChild("optional")||await e.set(n("session",s)),r())))}},3323:(e,t,r)=>{"use strict";const n=r(7342);e.exports=function({middleware:e}){return e.use(n()),{use:function(t,r,n){return e.use(((e,s)=>{const{stanza:i}=e;if(!i.is("features","http://etherx.jabber.org/streams"))return s();const o=i.getChild(t,r);return o?n(e,s,o):s()}))}}}},7342:e=>{"use strict";e.exports=function(){return async function({stanza:e,entity:t},r){if(!e.is("features","http://etherx.jabber.org/streams"))return r();await r(),t.jid&&t._status("online",t.jid)}}},3312:(e,t,r)=>{"use strict";const n=r(6174);e.exports=function({entity:e}){e.transports.push(n)}},6174:(e,t,r)=>{"use strict";const n=r(47),s=r(3073),i=r(7930),o=r(9558),a="urn:ietf:params:xml:ns:xmpp-framing";class c extends s{send(e,...t){return!e.attrs.xmlns&&super.isStanza(e)&&(e.attrs.xmlns="jabber:client"),super.send(e,...t)}footerElement(){return new i.Element("close",{xmlns:a})}headerElement(){const e=super.headerElement();return e.name="open",e.attrs.xmlns=a,e}socketParameters(e){return e.match(/^wss?:\/\//)?e:void 0}}c.prototype.Socket=n,c.prototype.NS="jabber:client",c.prototype.Parser=o,e.exports=c},9558:(e,t,r)=>{"use strict";const{Parser:n,Element:s,XMLError:i}=r(7930);e.exports=class extends n{onStartElement(e,t){const r=new s(e,t),{cursor:n}=this;n&&n.append(r),this.cursor=r}onEndElement(e){const{cursor:t}=this;e===t.name?t.parent?this.cursor=t.parent:(t.is("open","urn:ietf:params:xml:ns:xmpp-framing")?this.emit("start",t):t.is("close","urn:ietf:params:xml:ns:xmpp-framing")?this.emit("end",t):this.emit("element",t),this.cursor=null):this.emit("error",new i(`${t.name} must be closed.`))}}},47:(e,t,r)=>{"use strict";const n=r(732),s=r.g.WebSocket||n,i=r(7007),o="ECONNERROR";e.exports=class extends i{constructor(){super(),this.listeners=Object.create(null)}connect(e){this.url=e,this._attachSocket(new s(e,["xmpp"]))}_attachSocket(e){const t=this.socket=e,{listeners:r}=this;r.open=()=>{this.emit("connect")},r.message=({data:e})=>this.emit("data",e),r.error=e=>{let{error:t}=e;t||(t=new Error(`WebSocket ${o} ${this.url}`),t.errno=o,t.code=o),t.event=e,t.url=this.url,this.emit("error",t)},r.close=e=>{this._detachSocket(),this.emit("close",!e.wasClean,e)},t.addEventListener("open",r.open),t.addEventListener("message",r.message),t.addEventListener("error",r.error),t.addEventListener("close",r.close)}_detachSocket(){delete this.url;const{socket:e,listeners:t}=this;Object.getOwnPropertyNames(t).forEach((r=>{e.removeEventListener(r,t[r]),delete t[r]})),delete this.socket}end(){this.socket.close()}write(e,t){s===n?this.socket.send(e,t):(this.socket.send(e),t())}}},7930:(e,t,r)=>{"use strict";const n=r(118),s=r(7858),i=r(4063),{escapeXML:o,unescapeXML:a,escapeXMLText:c,unescapeXMLText:l}=r(8712),u=r(2037);t=e.exports=function(...e){return n(...e)},Object.assign(t,{x:n,Element:s,Parser:i,escapeXML:o,unescapeXML:a,escapeXMLText:c,unescapeXMLText:l,XMLError:u})},7858:(e,t,r)=>{"use strict";const n=r(8775);e.exports=class extends n{setAttrs(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach((function(t){if("__source"===t||"__self"===t)return;const r=e[t];null!=r&&(this.attrs[t.toString()]=r.toString())}),this)}append(e){return(e=Array.isArray(e)?e:[e]).forEach((e=>{this.children.push(e),"object"==typeof e&&(e.parent=this)})),this}prepend(e){return(e=Array.isArray(e)?e:[e]).forEach((e=>{this.children.unshift(e),"object"==typeof e&&(e.parent=this)})),this}}},4063:(e,t,r)=>{"use strict";const n=r(9416),s=r(7858),i=r(7007),o=r(2037);class a extends i{constructor(){super();const e=new n;this.root=null,this.cursor=null,e.on("startElement",this.onStartElement.bind(this)),e.on("endElement",this.onEndElement.bind(this)),e.on("text",this.onText.bind(this)),this.parser=e}onStartElement(e,t){const r=new s(e,t),{root:n,cursor:i}=this;n?i!==n&&i.append(r):(this.root=r,this.emit("start",r)),this.cursor=r}onEndElement(e){const{root:t,cursor:r}=this;if(e===r.name){if(r!==t)return r.parent?void(this.cursor=r.parent):(r.parent=t,this.emit("element",r),void(this.cursor=t));this.emit("end",t)}else this.emit("error",new o(`${r.name} must be closed.`))}onText(e){const{cursor:t}=this;t?t.t(e):this.emit("error",new o(`${e} must be a child.`))}write(e){this.parser.write(e)}end(e){e&&this.parser.write(e)}}a.XMLError=o,e.exports=a},2037:e=>{"use strict";e.exports=class extends Error{constructor(...e){super(...e),this.name="XMLError"}}},3837:(e,t,r)=>{"use strict";const n=r(4063);e.exports=function(e){const t=new n;let r=null,s=null;if(t.on("start",(e=>{r=e})),t.on("element",(e=>{r.append(e)})),t.on("error",(e=>{s=e})),t.write(e),t.end(),s)throw s;return r}},118:(e,t,r)=>{"use strict";const n=r(7858);function s(e,t){!1!==t&&null!=t&&(t instanceof n?e.append(t):Array.isArray(t)?t.forEach((t=>s(e,t))):e.append(String(t)))}e.exports=function(e,t,...r){const i=new n(e,t);for(let e=0;e{const n=r(9028),s=r(330);e.exports=class{constructor(e){this.proxy=e}uploadAddressBook(e,t){if(!n.isArray(e))return void new Error("First parameter must be an Array.");const r={contacts:e};t&&(t.force&&(r.force=t.force),t.udid&&(r.udid=t.udid));const i={type:"POST",url:n.getUrl(s.urls.addressbook),data:r};return this.proxy.ajax(i)}get(e){const t={type:"GET",url:n.getUrl(s.urls.addressbook)};return e&&(t.data={udid:e}),this.proxy.ajax(t)}getRegisteredUsers(e){const t={type:"GET",url:n.getUrl(s.urls.addressbookRegistered)};return e&&(t.data={compact:1}),this.proxy.ajax(t)}}},9694:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e,this.webSessionCheckInterval=null}setSession(e){this.proxy.setSession(e)}getSession(){const e={type:"GET",url:s.getUrl(n.urls.session)};return new Promise(((t,r)=>{this.proxy.ajax(e).then((e=>{t(e.session)})).catch((e=>{r(e)}))}))}createSession(e){if(""===n.creds.appId||""===n.creds.authKey||""===n.creds.authSecret)throw new Error("Cannot create a new session without app credentials (app ID, auth key and auth secret)");const t=e&&e.hasOwnProperty("long")?n.urls.webSession:n.urls.session,r=s.generateCreateSessionParams(e);r.signature=s.signParams(r,n.creds.authSecret);const i={type:"POST",url:s.getUrl(t),data:r};return new Promise(((e,t)=>{this.proxy.ajax(i).then((t=>{const r=t.qr_code?t.qr_code:t.session;this.proxy.setSession(t.session),this.proxy.setCurrentUserId(t.session.user_id),e(r)})).catch((e=>{t(e)}))}))}destroySession(){const e={type:"DELETE",url:s.getUrl(n.urls.session),dataType:"text"};return new Promise(((t,r)=>{this.proxy.ajax(e).then((e=>{this.proxy.setSession(null),this.proxy.setCurrentUserId(null),t()})).catch((e=>{r(e)}))}))}createWebSession(e){return e||(e={long:0}),this.createSession(e)}checkWebSessionUntilUpgrade(e){const t=n.webSession.getSessionTimeInterval,r=new Error("The web session check interval was stopped (timeout)");let s=n.webSession.getSessionTimeout;const i=()=>{this.webSessionCheckInterval&&clearInterval(this.webSessionCheckInterval)};return i(),this.webSessionCheckInterval=setInterval((()=>{this.getSession().then((n=>{0!==n.user_id?(i(),this.proxy.setCurrentUserId(n.user_id),this.proxy.setSession(n),e(null,n)):s>t?s-=t:(i(),e(r,null))})).catch((t=>{i(),e(t,null)}))}),1e3*t),this.webSessionCheckInterval}upgradeWebSession(e){const t={type:"PATCH",url:s.getUrl(n.urls.webSession),dataType:"text",data:{web_token:e}};return this.proxy.ajax(t)}login(e){const t={type:"POST",url:s.getUrl(n.urls.login),data:e};return new Promise(((e,r)=>{this.proxy.ajax(t).then((t=>{this.proxy.setCurrentUserId(t.user.id),e(t.user)})).catch((e=>{r(e)}))}))}logout(){const e={type:"DELETE",url:s.getUrl(n.urls.login),dataType:"text"};return this.proxy.setCurrentUserId(null),this.proxy.ajax(e)}}},330:(e,t,r)=>{const n={version:r(2122).rE,creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.connectycube.com",chat:"chat.connectycube.com",muc:"muc.chat.connectycube.com"},hash:"sha1",chatProtocol:{bosh:"https://chat.connectycube.com:5281",websocket:"wss://chat.connectycube.com:5291",active:2},webSession:{getSessionTimeInterval:3,getSessionTimeout:120},chat:{contactList:{subscriptionMode:{mutual:!0}},streamManagement:{enable:!1},ping:{enable:!1,timeInterval:60},reconnect:{enable:!0,timeInterval:5}},videochat:{alwaysRelayCalls:!1,answerTimeInterval:60,dialingTimeInterval:5,disconnectTimeInterval:30,statsReportTimeInterval:!1,iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:turn.connectycube.com"},{urls:"turn:turn.connectycube.com:5349?transport=udp",username:"connectycube",credential:"4c29501ca9207b7fb9c4b4b6b04faeb1"},{urls:"turn:turn.connectycube.com:5349?transport=tcp",username:"connectycube",credential:"4c29501ca9207b7fb9c4b4b6b04faeb1"}]},conference:{server:"wss://janus.connectycube.com:8989"},whiteboard:{server:"https://whiteboard.connectycube.com"},urls:{session:"session",webSession:"session/web",login:"login",users:"users",chat:"chat",blobs:"blobs",subscriptions:"subscriptions",events:"events",data:"data",addressbook:"address_book",addressbookRegistered:"address_book/registered_users",meetings:"meetings",whiteboards:"whiteboards",calls:"calls",type:".json"},on:{sessionExpired:null,xmppDataWrite:null,xmppDataRead:null},timeout:null,debug:{mode:0},set:function(e){"object"==typeof e.endpoints&&e.endpoints.chat&&(n.endpoints.muc="muc."+e.endpoints.chat,n.chatProtocol.bosh="https://"+e.endpoints.chat+":5281",n.chatProtocol.websocket="wss://"+e.endpoints.chat+":5291"),Object.keys(e).forEach((function(t){"set"!==t&&n.hasOwnProperty(t)&&("object"!=typeof e[t]?n[t]=e[t]:Object.keys(e[t]).forEach((function(r){n[t].hasOwnProperty(r)&&(n[t][r]=e[t][r])})))}))}};e.exports=n},0:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e}create(e,t){const r={type:"POST"};return s.isArray(t)?(r.url=s.getUrl(n.urls.data,`${e}/multi`),r.data={record:{}},t.forEach(((e,t)=>r.data.record[t]=e))):(r.url=s.getUrl(n.urls.data,e),r.data=t),this.proxy.ajax(r)}list(e,t={}){const r={};return"string"==typeof t?r.url=s.getUrl(n.urls.data,`${e}/${t}`):s.isArray(t)?r.url=s.getUrl(n.urls.data,`${e}/${t.toString()}`):s.isObject(t)&&(r.url=s.getUrl(n.urls.data,e),r.data=t),this.proxy.ajax(r)}readPermissions(e,t){const r={url:s.getUrl(n.urls.data,`${e}/${t}`),data:{permissions:1}};return this.proxy.ajax(r)}update(e,t={}){const r={type:"PUT"};return s.isArray(t)?(r.url=s.getUrl(n.urls.data,`${e}/multi`),r.data={record:{}},t.forEach(((e,t)=>{const n=e.id?e:{id:e._id,...e};r.data.record[t+1]=n}))):t.search_criteria?(r.url=s.getUrl(n.urls.data,`${e}/by_criteria`),r.data=t):(r.url=s.getUrl(n.urls.data,`${e}/${t._id||t.id}`),r.data=t),this.proxy.ajax(r)}delete(e,t){const r={type:"DELETE"};let i;return"string"==typeof t?i=1:s.isArray(t)?i=t.length>1?2:1:s.isObject(t)&&(i=3),1===i?(r.url=s.getUrl(n.urls.data,`${e}/${t}`),r.dataType="text"):2===i?r.url=s.getUrl(n.urls.data,`${e}/${t.toString()}`):3===i&&(r.url=s.getUrl(n.urls.data,`${e}/by_criteria`),r.data=t),this.proxy.ajax(r)}}},8009:(e,t,r)=>{const n=r(9028);let s,i,o,a,c,l,u,d,h,p,f,m,g=r(3113);n.getEnv().browser?(s=fetch,i=FormData,o=window.adapter,m=navigator,a=navigator.mediaDevices,c=window.MediaStream,l=window.MediaStreamTrack,h=window.RTCIceCandidate,u=window.RTCPeerConnection,d=window.RTCSessionDescription,p=window.RTCRtpReceiver,f=window.RTCRtpSender):n.getEnv().node&&(s=r(8849),i=r(6245)),e.exports={fetchImpl:s,formDataImpl:i,XMPPClient:g,adapter:o,mediaDevices:a,MediaStream:c,MediaStreamTrack:l,RTCIceCandidate:h,RTCPeerConnection:u,RTCRtpReceiver:p,RTCRtpSender:f,RTCSessionDescription:d,navigator:m}},9028:(e,t,r)=>{const n=r(330),s="undefined"!=typeof document,i="undefined"!=typeof navigator&&"ReactNative"==navigator.product,o="object"==typeof r.g&&(void 0!==r.g.android||void 0!==r.g.NSObject),a={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0};e.exports=class{static getEnv(){return{nativescript:o,reactnative:i,browser:s,node:!s&&!o&&!i}}static isRNWebRTCAvailble(){if(i&&"undefined"==typeof Expo){const{RTCView:e,RTCPeerConnection:t,RTCIceCandidate:n,RTCSessionDescription:s,MediaStream:i,mediaDevices:o}=r(8009);return e&&t&&n&&s&&i&&o}return!1}static isWebRTCAvailble(){return i&&this.isRNWebRTCAvailble()||s&&window.RTCPeerConnection&&window.RTCIceCandidate&&window.RTCSessionDescription}static safeCallbackCall(){const e=arguments[0];if("function"!=typeof e)return;const t=e.toString().split("(")[0].split(" ")[1],r=[];let n;for(let e=0;e16777215&&(a.increment=0),"00000000".substr(0,8-e.length)+e+"000000".substr(0,6-a.machine.length)+a.machine+"0000".substr(0,4-a.pid.length)+a.pid+"000000".substr(0,6-t.length)+t}static DLog(){if(this.loggers){for(let e=0;e{const n=r(330),s=r(9028);class i{constructor(){s.getEnv().reactnative&&s.isWebRTCAvailble()&&(this.RTCView=r(8009).RTCView)}init(e,t){t&&"object"==typeof t&&n.set(t);const i=r(5854),o=r(9694),a=r(8266),c=r(215),l=r(4002),u=r(0),d=r(1563),h=r(7999),p=r(3873),f=r(6462),m=r(611),g=r(8979);if(this.service=new i,this.auth=new o(this.service),this.users=new a(this.service),this.storage=new c(this.service),this.pushnotifications=new l(this.service),this.data=new u(this.service),this.addressbook=new d(this.service),this.chat=new h(this.service),this.chat.dialog=new p(this.service),this.chat.message=new f(this.service),this.meeting=new m(this.service),this.whiteboard=new g(this.service),this.utils=s,s.isWebRTCAvailble()){const e=r(5888),t=r(8852);this.videochat=new e(this.chat.xmppClient,this.service),this.videochatconference=new t(this.service),this.chat.webrtcSignalingProcessor=this.videochat.signalingProcessor}else this.videochat=null,this.videochatconference=null;e.token?(n.creds.appId=e.appId,this.service.setSession({token:e.token})):(n.creds.appId=e.appId,n.creds.authKey=e.authKey,n.creds.authSecret=e.authSecret)}setSession(e){this.auth.setSession(e)}getSession(){return this.auth.getSession()}createSession(e){return this.auth.createSession(e)}destroySession(){return this.auth.destroySession()}createWebSession(e){return this.auth.createWebSession(e)}checkWebSessionUntilUpgrade(e){return this.auth.checkWebSessionUntilUpgrade(e)}upgradeWebSession(e){return this.auth.upgradeWebSession(e)}login(e){return this.auth.login(e)}logout(){return this.auth.logout()}}const o=new i;o.ConnectyCube=i,e.exports=o},611:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.meetings;e.exports=class{constructor(e){this.proxy=e}get(e={}){const t={type:"GET",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e={}){const t=Math.ceil(Date.now()/1e3),r=t+3600,n={name:new Date(t).toLocaleString("en",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}),start_date:t,end_date:r,attendees:[],record:!1,chat:!1},o={type:"POST",url:s.getUrl(i),data:{...n,...e}};return this.proxy.ajax(o)}update(e,t){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e){const t={type:"DELETE",url:s.getUrl(i,e),dataType:"text"};return this.proxy.ajax(t)}getRecordings(e){const t={type:"GET",url:s.getUrl(i,`recordings/${e}`)};return this.proxy.ajax(t)}}},5854:(e,t,r)=>{const n=r(330),s=r(9028),i=r(8009).fetchImpl,o=r(8009).formDataImpl;e.exports=class{constructor(){this.sdkInstance={config:n,session:null},this.currentUserId=null,this.requestsNumber=0,this.fetchImpl=i,this.abortControllersMap={}}setSession(e){this.sdkInstance.session=e,e&&e.user_id&&this.setCurrentUserId(e.user_id)}getSession(){return this.sdkInstance.session}setCurrentUserId(e){this.currentUserId=e}getCurrentUserId(){return this.currentUserId}logRequest(e,t){s.DLog(`[Request][${t}]`,`${e.type||"GET"} ${e.url}`,e)}logResponse(e,t){s.DLog(`[Response][${t}]`,e)}buildRequestAndURL(e){const t=!e.type||"GET"===e.type||"HEAD"===e.type,r=e.type&&("POST"===e.type||"PUT"===e.type),s=this.sdkInstance&&this.sdkInstance.session&&this.sdkInstance.session.token,i=-1===e.url.indexOf("s3.amazonaws.com"),o=!1===e.contentType;let a,c=e.url;const l={};return l.method=e.type||"GET",e.data&&(a=this.buildRequestBody(e,o,r),t?c+="?"+a:l.body=a),o||(l.headers={"Content-Type":r?"application/json;charset=utf-8":"application/x-www-form-urlencoded; charset=UTF-8"}),i&&(l.headers||(l.headers={}),l.headers["CB-SDK"]="JS "+n.version+" - Client",s&&(l.headers["CB-Token"]=s)),n.timeout&&(l.timeout=n.timeout),[l,c]}buildRequestBody(e,t,r){const n=e.data,s=e.useArrayQuery;let i;return t?(i=new o,Object.keys(n).forEach((function(t){e.fileToCustomObject&&"file"===t?i.append(t,n[t].data,n[t].name):i.append(t,e.data[t])}))):i=r?JSON.stringify(n):this.serializeQueryParams(n,null,s,0),i}serializeQueryParams(e,t,r,n){n=n||0;const i=[];let o;for(o in e){let a=this.encodeURIComponent(o);s.isArray(e)&&(a="");const c=t?t+`[${a}]`:a;let l=e[o];const u=s.isArray(l);u&&(r||0===n)||s.isObject(l)?i.push(this.serializeQueryParams(l,c,r,++n)):(l=u?l.sort().join(","):l,i.push(`${c}=${this.encodeURIComponent(l)}`))}return i.sort().join("&")}encodeURIComponent(e){return encodeURIComponent(e).replace(/[#$&+,/:;=?@\[\]]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}abortRequest(e){if(this.abortControllersMap[e]){const t=this.abortControllersMap[e].controllers||{};Object.values(t).forEach((e=>{e.abort()}))}}processSuccessfulOrFailedRequest(e){if(!this.abortControllersMap[e])return;const t=this.abortControllersMap[e].controllers||{},r=Object.keys(t).length;this.abortControllersMap[e].doneRequestsCount?this.abortControllersMap[e].doneRequestsCount+=1:this.abortControllersMap[e].doneRequestsCount=1,this.abortControllersMap[e].doneRequestsCount===r&&delete this.abortControllersMap[e]}ajax(e){const t=++this.requestsNumber;return new Promise(((r,n)=>{this.logRequest(e,t);const s=this.buildRequestAndURL(e);let o=s[0];const a=s[1],c=e.abort_id;if(c){let e;if(this.abortControllersMap[c]){const t=this.abortControllersMap[c].controllers||[],r=Object.keys(t).length;this.abortControllersMap[c].controllers.push(new AbortController),e=r}else this.abortControllersMap[c]={controllers:[new AbortController]},e=0;const t=this.abortControllersMap[c].controllers[e].signal;o={...o,signal:t}}let l;i(a,o).then((t=>(l=t,"text"===(e.dataType||"json")?l.text():l.json()))).then((s=>{this.processSuccessfulOrFailedRequest(c),l.ok?this.processAjaxResponse(s,r,t):this.processAjaxError(l,s,null,n,r,e,t)})).catch((s=>{this.processSuccessfulOrFailedRequest(c),this.processAjaxError(l," ",s,n,r,e,t)}))}))}processAjaxResponse(e,t,r){const n=e&&" "!==e?e:"empty body";this.logResponse(n,r),t(e)}processAjaxError(e,t,r,i,o,a,c){if(!e&&r&&!r.code)return void i(r);const l=e&&(e.status||e.statusCode),u={code:e&&l||r&&r.code,info:(t&&"string"==typeof t&&" "!==t?JSON.parse(t):t)||r&&r.errno},d=t||r||t.errors;this.logResponse(d,c),-1===e.url.indexOf(n.urls.session)&&s.isExpiredSessionError(u)&&"function"==typeof n.on.sessionExpired?this.handleExpiredSessionResponse(u,null,i,o,a):i(u)}handleExpiredSessionResponse(e,t,r,s,i){n.on.sessionExpired((()=>{e?r(e):s(t)}),(e=>{e&&(this.setSession(e),this.ajax(i).then(s).catch(r))}))}}},4002:(e,t,r)=>{const n=r(330),s=r(9028);class i{constructor(e){this.proxy=e}create(e){const t={type:"POST",url:s.getUrl(n.urls.subscriptions),data:e};return this.proxy.ajax(t)}list(){const e={type:"GET",url:s.getUrl(n.urls.subscriptions)};return this.proxy.ajax(e)}delete(e){const t={type:"DELETE",dataType:"text",url:s.getUrl(n.urls.subscriptions,e)};return this.proxy.ajax(t)}}class o{constructor(e){this.proxy=e}create(e){const t={type:"POST",url:s.getUrl(n.urls.events),data:{event:e}};return this.proxy.ajax(t)}}e.exports=class{constructor(e){this.proxy=e,this.subscriptions=new i(e),this.events=new o(e),this.base64Encode=function(e){return s.toBase64(e)}}}},215:(e,t,r)=>{const n=r(330),s=r(9028);function i(e){const t=i.options,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={};let s=14;for(;s--;)n[t.key[s]]=r[s]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,r,s){r&&(n[t.q.name][r]=s)})),n}e.exports=class{constructor(e){this.proxy=e}list(e){const t={type:"GET",url:s.getUrl(n.urls.blobs),data:e};return this.proxy.ajax(t)}create(e){const t={type:"POST",url:s.getUrl(n.urls.blobs),data:{blob:e}};return this.proxy.ajax(t)}delete(e){const t={type:"DELETE",url:s.getUrl(n.urls.blobs,e),dataType:"text"};return this.proxy.ajax(t)}createAndUpload(e){const t=e.file,r=e.public,n=e.name||t.name,s=e.size||t.size,o=e.type||t.type,a=e.abort_id,c={name:n,content_type:o,public:r};let l;return this.create(c).then((({blob:e})=>{l=e;const r=i(l.blob_object_access.params),n={url:`${r.protocol}://${r.authority}${r.path}`,data:{}};return a&&(n.abort_id=a),Object.keys(r.queryKey).forEach((e=>{n.data[e]=decodeURIComponent(r.queryKey[e])})),n.data.file=t,this.upload(n).then((()=>l))})).then((e=>this.markUploaded({id:e.id,size:s}).then((()=>e)))).then((e=>({...e,size:s}))).catch((e=>{if(l)return{...l,size:s}}))}upload(e){const t={...e,type:"POST",dataType:"text",contentType:!1};return this.proxy.ajax(t)}markUploaded(e){const t={type:"PUT",url:s.getUrl(n.urls.blobs,e.id,"complete"),data:{size:e.size},dataType:"text"};return this.proxy.ajax(t)}getInfo(e){const t={url:s.getUrl(n.urls.blobs,e)};return this.proxy.ajax(t)}getFile(e){const t={url:s.getUrl(n.urls.blobs,e)};return this.proxy.ajax(t)}getFileObject(e,t){const r={type:"GET",url:s.getUrl(n.urls.blobs,e,"object"),data:t};return this.proxy.ajax(r)}update(e){const t={blob:{}};void 0!==e.name&&(t.blob.name=e.name);const r={url:s.getUrl(n.urls.blobs,e.id),data:t};return this.proxy.ajax(r)}privateUrl(e){return"https://"+n.endpoints.api+"/blobs/"+e+"?token="+this.proxy.getSession().token}publicUrl(e){return"https://"+n.endpoints.api+"/blobs/"+e}},i.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},8266:(e,t,r)=>{const n=r(330),s=r(9028);e.exports=class{constructor(e){this.proxy=e}getV2(e){const t={type:"GET",url:s.getUrl(`${n.urls.users}/v2`),data:e,useArrayQuery:!0};return this.proxy.ajax(t)}get(e){let t,r,c=s.cloneObject(e);const l=[];c.order&&(c.order=function(e){const t=e.field in i?"date":e.field in o?"number":"string";return[e.sort,t,e.field].join(" ")}(c.order)),c&&c.filter&&(s.isArray(c.filter)?c.filter.forEach((function(e){r=a(e),l.push(r)})):(r=a(c.filter),l.push(r)),c.filter=l),"number"==typeof c?(t=c,c={}):c.login?t="by_login":c.full_name?t="by_full_name":c.facebook_id?t="by_facebook_id":c.twitter_id?t="by_twitter_id":c.phone?t="phone":c.email?t="by_email":c.tags?t="by_tags":c.external&&(t="external/"+c.external,c={});const u={type:"GET",url:s.getUrl(n.urls.users,t),data:c};return this.proxy.ajax(u)}signup(e){const t={type:"POST",url:s.getUrl(n.urls.users),data:{user:e}};return this.proxy.ajax(t)}update(e){const t={type:"PUT",url:s.getUrl(n.urls.users,this.proxy.getCurrentUserId()),data:{user:e}};return this.proxy.ajax(t)}delete(){const e={type:"DELETE",url:s.getUrl(n.urls.users,this.proxy.getCurrentUserId()),dataType:"text"};return this.proxy.ajax(e)}resetPassword(e){const t={type:"GET",url:s.getUrl(n.urls.users+"/password/reset"),data:{email:e},dataType:"text"};return this.proxy.ajax(t)}};const i=["created_at","updated_at","last_request_at"],o=["id","external_user_id"];function a(e){const t=s.cloneObject(e);let r=i.includes(t.field)?"date":typeof t.value;return s.isArray(t.value)&&("object"===r&&(r=typeof t.value[0]),t.value=t.value.toString()),[r,t.field,t.param,t.value].join(" ")}},8979:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.whiteboards,o=n.whiteboard.server;e.exports=class{constructor(e){this.proxy=e}getURL({id:e,title:t,username:r}){return`${o}?whiteboardid=${e}&username=${r}&title=${t}`}get(e){const t={type:"GET",url:s.getUrl(i),data:"string"==typeof e?{chat_dialog_id:e}:e};return this.proxy.ajax(t)}create(e={}){const t={type:"POST",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}update(e,t={}){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e){const t={type:"DELETE",url:s.getUrl(i,e),dataType:"text"};return this.proxy.ajax(t)}}},7999:(e,t,r)=>{const n=r(330),s=r(9028),i=r(3173),o=r(1458),a=r(278),c=r(1341),l=r(9965),u=r(6349),d=r(8009).XMPPClient;e.exports=class{constructor(e){this.proxy=e,this.xmppClient=d.client({service:n.chatProtocol.websocket,credentials:(e,t)=>e({username:this.xmppClient.options.username,password:this.xmppClient.options.password})}),this.webrtcSignalingProcessor=null,this.stanzasCallbacks={},this.earlyIncomingMessagesQueue=[],this.isConnected=!1,this._isConnecting=!1,this._isLogout=!1,this._isReconnect=!1,this._checkPingTimer=void 0,this.helpers=new o,this.xmppClientListeners=[],this.connectPromise=null;var t={xmppClient:this.xmppClient,helpers:this.helpers,stanzasCallbacks:this.stanzasCallbacks};this.contactList=new c(t),this.privacylist=new l(t),this.muc=new u(t),n.chat.streamManagement.enable&&2===n.chatProtocol.active&&(this.streamManagement=new a,this._sentMessageCallback=(e,t)=>{"function"==typeof this.onSentMessageCallback&&(t?this.onSentMessageCallback(null,t):this.onSentMessageCallback(e))}),n.chat.reconnect.enable&&(this.xmppClient.reconnect.delay=1e3*n.chat.reconnect.timeInterval)}get connectionStatus(){return this.xmppClient.status}connect(e){return this.connectPromise=new Promise(((t,r)=>{if(s.DLog("[Chat]","Connect with parameter:",e),this._isConnecting)return s.DLog("[Chat]","Warning! Already in CONNECTING state"),void t();if(this.isConnected)return s.DLog("[Chat]","Warning! Chat is already connected!"),void t();this._isConnecting=!0,this._isLogout=!1,this.xmppClientListeners.forEach((e=>{this.xmppClient.removeListener(e.name,e.callback)}));const o=()=>{s.DLog("[Chat]",this._isReconnect?"RECONNECTING":"CONNECTING")};this.xmppClient.on("connect",o),this.xmppClientListeners.push({name:"connect",callback:o});const a=()=>{s.DLog("[Chat]","ONLINE"),this.startPingTimer(),this._postConnectActions(),t(),this.connectPromise=null};this.xmppClient.on("online",a),this.xmppClientListeners.push({name:"online",callback:a});const c=()=>{s.DLog("[Chat]","OFFLINE")};this.xmppClient.on("offline",c),this.xmppClientListeners.push({name:"offline",callback:c});const l=()=>{s.DLog("[Chat]","DISCONNECTED"),"function"==typeof this.onDisconnectedListener&&s.safeCallbackCall(this.onDisconnectedListener),n.chat.reconnect.enable?(this.isConnected=!1,this._isConnecting=!1):this.disconnect(),this.stopPingTimer()};this.xmppClient.on("disconnect",l),this.xmppClientListeners.push({name:"disconnect",callback:l});const u=(e,t)=>{s.DLog("[Chat]",`status - ${e}`,"object"==typeof t?JSON.stringify(t):""),"function"==typeof this.onChatStatusListener&&s.safeCallbackCall(this.onChatStatusListener,e)};this.xmppClient.on("status",u),this.xmppClientListeners.push({name:"status",callback:u});const d=e=>{if(e.is("message")&&!this.isConnected)return this.earlyIncomingMessagesQueue.push(e),void s.DLog("[Chat]","on 'stanza': enqueue incoming stanza (isConnected=false)");e.is("presence")?this._onPresence(e):e.is("iq")?this._onIQ(e):e.is("message")&&("headline"===e.attrs.type?this._onSystemMessageListener(e):"error"===e.attrs.type?this._onMessageErrorListener(e):this._onMessage(e))};this.xmppClient.on("stanza",d),this.xmppClientListeners.push({name:"stanza",callback:d});const h=e=>{s.DLog("[Chat]","ERROR:",e,{_isReconnect:this._isReconnect,connectPromise:!!this.connectPromise}),this.connectPromise?this._isReconnect||("SASLError"==e.name&&(e=e.condition),r(e),this.connectPromise=null):"function"==typeof this.onConnectionErrorListener&&s.safeCallbackCall(this.onConnectionErrorListener,e)};this.xmppClient.on("error",h),this.xmppClientListeners.push({name:"error",callback:h});const p=e=>{s.callTrafficUsageCallback("xmppDataWrite",{body:e}),s.DLog("[Chat]","SENT:",e)};this.xmppClient.on("output",p),this.xmppClientListeners.push({name:"output",callback:p});const f=e=>{s.callTrafficUsageCallback("xmppDataRead",{body:e}),s.DLog("[Chat]","RECV:",e)};this.xmppClient.on("input",f),this.xmppClientListeners.push({name:"input",callback:f}),this.xmppClient.options.username=i.buildUserJidLocalPart(e.userId),this.xmppClient.options.password=e.password,this.xmppClient.start().catch((e=>{console.error("[Chat] xmppClient.start error",e),this.connectPromise?(r(e),this.connectPromise=null):"function"==typeof this.onConnectionErrorListener&&s.safeCallbackCall(this.onConnectionErrorListener,e)}))})),this.connectPromise}getContacts(){return new Promise(((e,t)=>{this.contactList.get().then((t=>{this.contactList.contacts=t,e(t)})).catch((e=>{t(t)}))}))}ping(){return new Promise(((e,t)=>{const r={id:i.getUniqueId("ping"),to:n.endpoints.chat,type:"get"},s=i.createIqStanza(r);s.c("ping",{xmlns:"urn:xmpp:ping"}),this.stanzasCallbacks[r.id]=r=>{const n=i.getElement(r,"error");n?t(i.buildErrorFromXMPPErrorStanza(n)):e()},this.xmppClient.send(s)}))}pingWithTimeout(e=5e3){return Promise.race([this.ping(),new Promise(((t,r)=>setTimeout((()=>r(new Error("Chat ping() timed out"))),e)))])}startPingTimer(){if(this.stopPingTimer(),n.chat.ping.enable){const e=n.chat.ping.timeInterval<30?30:n.chat.ping.timeInterval;this._checkPingTimer=setInterval((()=>{this.ping()}),1e3*e)}}stopPingTimer(){this._checkPingTimer&&(clearInterval(this._checkPingTimer),this._checkPingTimer=null)}send(e,t){const r={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:t.type?t.type:this.helpers.typeChat(e),id:t.id?t.id:s.getBsonObjectId()};let o=i.createMessageStanza(r);return t.body&&o.c("body").t(t.body).up(),t.markable&&o.c("markable",{xmlns:"urn:xmpp:chat-markers:0"}).up(),t.extension&&(o.c("extraParams",{xmlns:"jabber:client"}),o=i.filledExtraParams(o,t.extension)),n.chat.streamManagement.enable?(t.id=r.id,this.xmppClient.send(o,t)):this.xmppClient.send(o),r.id}sendSystemMessage(e,t){const r={type:"headline",id:t.id?t.id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e)};let n=i.createMessageStanza(r);return t.body&&n.c("body").t(t.body).up(),t.extension&&(n.c("extraParams",{xmlns:"jabber:client"}).c("moduleIdentifier").t("SystemNotifications").up(),n=i.filledExtraParams(n,t.extension)),this.xmppClient.send(n),r.id}sendIsTypingStatus(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},r=i.createMessageStanza(t);r.c("composing",{xmlns:"http://jabber.org/protocol/chatstates"}),this.xmppClient.send(r)}sendIsStopTypingStatus(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},r=i.createMessageStanza(t);r.c("paused",{xmlns:"http://jabber.org/protocol/chatstates"}),this.xmppClient.send(r)}sendDeliveredStatus(e){const t={type:"chat",from:this.helpers.getUserCurrentJid(),id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e.userId)},r=i.createMessageStanza(t);r.c("received",{xmlns:"urn:xmpp:chat-markers:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}sendReadStatus(e){const t={type:"chat",from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.userId),id:s.getBsonObjectId()},r=i.createMessageStanza(t);r.c("displayed",{xmlns:"urn:xmpp:chat-markers:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}editMessage(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.to),type:this.helpers.typeChat(e.to),id:s.getBsonObjectId()};let r=i.createMessageStanza(t);r.c("body").t(e.body).up(),r.c("replace",{xmlns:"urn:xmpp:message-correct:0",id:e.originMessageId,last:e.last?"true":"false"}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),e.extension&&(r=i.filledExtraParams(r,e.extension)),this.xmppClient.send(r)}deleteMessage(e){const t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.to),type:this.helpers.typeChat(e.to),id:s.getBsonObjectId()},r=i.createMessageStanza(t);r.c("remove",{xmlns:"urn:xmpp:message-delete:0",id:e.messageId}).up(),r.c("extraParams",{xmlns:"jabber:client"}).c("dialog_id").t(e.dialogId),this.xmppClient.send(r)}getLastUserActivity(e){return new Promise(((t,r)=>{const n={from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("lastActivity"),to:this.helpers.jidOrUserId(e),type:"get"},s=i.createIqStanza(n);s.c("query",{xmlns:"jabber:iq:last"}),this.stanzasCallbacks[n.id]=e=>{const n=i.getElement(e,"error"),{userId:s,seconds:o}=this._onLastActivityStanza(e);n?r(i.buildErrorFromXMPPErrorStanza(e)):t({userId:s,seconds:o})},this.xmppClient.send(s)}))}_onLastActivityStanza(e){const t=i.getAttr(e,"from"),r=this.helpers.getUserIdFromJID(t),n=i.getElement(e,"query"),o=+i.getAttr(n,"seconds");return s.safeCallbackCall(this.onLastUserActivityListener,r,o),{userId:r,seconds:o}}markActive(){const e={id:this.helpers.getUniqueId("markActive"),type:"set"},t=i.createIqStanza(e);t.c("mobile",{xmlns:"http://tigase.org/protocol/mobile#v2",enable:"false"}),this.xmppClient.send(t)}markInactive(){const e={id:this.helpers.getUniqueId("markActive"),type:"set"},t=i.createIqStanza(e);t.c("mobile",{xmlns:"http://tigase.org/protocol/mobile#v2",enable:"true"}),this.xmppClient.send(t)}disconnect(){if(s.DLog("[Chat]","disconnect"),!this._isLogout)return this.muc.joinedRooms={},this.isConnected=!1,this._isConnecting=!1,this._isLogout=!0,this._isReconnect=!1,this.helpers.setUserCurrentJid(""),n.chat.streamManagement.enable&&this.streamManagement._removeElementHandler(),this.xmppClient.stop();s.DLog("[Chat]","Warning! Chat is already disconnected!")}search(e){let t=Object.assign({},e);t.start_date&&(t.start_date=new Date(t.start_date).toISOString()),t.end_date&&(t.end_date=new Date(t.end_date).toISOString()),s.isArray(t.chat_dialog_ids)&&(t.chat_dialog_ids=t.chat_dialog_ids.join(","));const r={type:"GET",url:s.getUrl(`${n.urls.chat}/search`),data:t};return this.proxy.ajax(r)}_onMessage(e){const t=i.getElementTreePath(e,["sent","forwarded","message"]),r=t||e,n=i.getAttr(r,"from"),o=i.getAttr(r,"type"),a=i.getAttr(r,"id"),c=i.getElement(r,"markable"),l=i.getElement(r,"received"),u=i.getElement(r,"displayed"),d=i.getElement(r,"replace"),h=i.getElement(r,"reactions"),p=i.getElement(r,"remove"),f=i.getElement(r,"composing"),m=i.getElement(r,"paused"),g=i.getElement(r,"invite"),y=i.getElement(r,"delay"),v=i.getElement(r,"extraParams"),b=i.getElementText(r,"body"),S=!!t,C=this.xmppClient.jid&&this.xmppClient.jid._resource||"";if("chat"===o&&-1!==n.indexOf(C))return!0;let w,k,_;_="chat"===o?i.getAttr(r,"to"):null,k=_?this.helpers.getUserIdFromJID(_):null;let x="groupchat"===o?this.helpers.getDialogIdFromJID(n):null,I="groupchat"===o?this.helpers.getIdFromResource(n):this.helpers.getUserIdFromJID(n),E=l||u||null;if(g)return!0;if(v&&(w=i.parseExtraParams(v),w.dialogId&&(x=w.dialogId)),f||m)return"function"!=typeof this.onMessageTypingListener||"chat"!==o&&"groupchat"!==o&&y||s.safeCallbackCall(this.onMessageTypingListener,!!f,I,x),!0;if(d)return"function"==typeof this.onMessageUpdateListener&&s.safeCallbackCall(this.onMessageUpdateListener,i.getAttr(d,"id"),"true"===i.getAttr(d,"last"),b,x,I,w?w.extension:null),!0;if(h){if(S&&"groupchat"===o)return!0;if("function"==typeof this.onMessageReactionsListener){const e=i.getAttr(h,"message_id"),t=+i.getAttr(h,"user_id"),{add:r,remove:n}=i.parseReactions(h),{dialogId:o}=w;s.safeCallbackCall(this.onMessageReactionsListener,e,t,o,r,n)}return!0}if(p)return"function"==typeof this.onMessageDeleteListener&&s.safeCallbackCall(this.onMessageDeleteListener,i.getAttr(p,"id"),x,I),!0;if(E)return void(l?"function"==typeof this.onDeliveredStatusListener&&"chat"===o&&s.safeCallbackCall(this.onDeliveredStatusListener,i.getAttr(l,"id"),x,I):"function"==typeof this.onReadStatusListener&&"chat"===o&&s.safeCallbackCall(this.onReadStatusListener,i.getAttr(u,"id"),x,I));if(c&&I!=this.helpers.getUserIdFromJID(this.helpers.userCurrentJid(this.xmppClient))){const e={messageId:a,userId:I,dialogId:x};this.sendDeliveredStatus(e)}const T={id:a,dialog_id:x,recipient_id:k,is_forwarded:S,type:o,body:b,extension:w?w.extension:null,delay:y};c&&(T.markable=1),"function"!=typeof this.onMessageListener||"chat"!==o&&"groupchat"!==o||s.safeCallbackCall(this.onMessageListener,I,T)}_onPresence(e){const t=i.getAttr(e,"from"),r=i.getAttr(e,"id"),n=i.getAttr(e,"type"),o=this.helpers.getUserIdFromJID(this.helpers.userCurrentJid(this.xmppClient)),a=i.getElement(e,"x");let c,l,u;if(a&&(c=i.getAttr(a,"xmlns"),l=i.getElement(a,"status"),l&&(u=i.getAttr(l,"code"))),c&&c.startsWith("http://jabber.org/protocol/muc")){if("error"===n)return void(r.endsWith(":join")&&"function"==typeof this.stanzasCallbacks[r]&&this.stanzasCallbacks[r](e));const c=this.helpers.getDialogIdFromJID(t),p=this.helpers.getUserIdFromRoomJid(t);if(l){if("301"==u){if("function"==typeof this.onKickOccupant){var d=i.getElement(i.getElement(a,"item"),"actor"),h=i.getAttr(d,"jid");s.safeCallbackCall(this.onKickOccupant,c,this.helpers.getUserIdFromJID(h))}return void delete this.muc.joinedRooms[this.helpers.getRoomJidFromRoomFullJid(t)]}if("unavailable"===n)return void(l&&"110"==u&&"function"==typeof this.stanzasCallbacks["muc:leave"]&&s.safeCallbackCall(this.stanzasCallbacks["muc:leave"],null));if(r.endsWith(":join")&&l&&"110"==u)return void("function"==typeof this.stanzasCallbacks[r]&&this.stanzasCallbacks[r](e))}else if(p!=o)return"unavailable"===n?void("function"==typeof this.onLeaveOccupant&&s.safeCallbackCall(this.onLeaveOccupant,c,parseInt(p))):void("function"==typeof this.onJoinOccupant&&s.safeCallbackCall(this.onJoinOccupant,c,parseInt(p)))}const p=this.helpers.getUserIdFromJID(t);let f=this.contactList.contacts[p];if(n)switch(n){case"subscribe":f&&"to"===f.subscription?(f?f.ask=null:f={ask:null},f.subscription="both",this.contactList._sendSubscriptionPresence({jid:t,type:"subscribed"})):"function"==typeof this.onSubscribeListener&&s.safeCallbackCall(this.onSubscribeListener,p);break;case"subscribed":f&&"from"===f.subscription?(f?f.ask=null:f={ask:null},f.subscription="both"):(f?f.ask=null:f={ask:null},f.subscription="to","function"==typeof this.onConfirmSubscribeListener&&s.safeCallbackCall(this.onConfirmSubscribeListener,p));break;case"unsubscribed":f?f.ask=null:f={ask:null},f.subscription="none","function"==typeof this.onRejectSubscribeListener&&s.safeCallbackCall(this.onRejectSubscribeListener,p);break;case"unsubscribe":f?f.ask=null:f={ask:null},f.subscription="to";break;case"unavailable":"function"==typeof this.onContactListListener&&f&&"none"!==f.subscription&&s.safeCallbackCall(this.onContactListListener,p,n),p===o&&this.xmppClient.send(i.createPresenceStanza())}else"function"==typeof this.onContactListListener&&f&&"none"!==f.subscription&&s.safeCallbackCall(this.onContactListListener,p)}_onIQ(e){const t=i.getAttr(e,"id");if(this.stanzasCallbacks[t])s.safeCallbackCall(this.stanzasCallbacks[t],e),delete this.stanzasCallbacks[t];else{const t=i.getAttr(e,"from"),r=i.getElement(e,"query");if(!t||!r)return;this._onLastActivityStanza(e)}}_onSystemMessageListener(e){const t=i.getElementTreePath(e,["sent","forwarded","message"])||e,r=i.getAttr(t,"from"),n=i.getAttr(t,"id"),o=i.getElement(t,"extraParams"),a=this.helpers.getUserIdFromJID(r),c=i.getElement(t,"delay"),l=i.getElementText(o,"moduleIdentifier"),u=i.getElementText(t,"body"),d=i.parseExtraParams(o);if("SystemNotifications"===l&&"function"==typeof this.onSystemMessageListener){const e={id:n,userId:a,body:u,extension:d.extension};s.safeCallbackCall(this.onSystemMessageListener,e)}else this.webrtcSignalingProcessor&&!c&&"WebRTCVideoChat"===l&&this.webrtcSignalingProcessor._onMessage(a,o)}_onMessageErrorListener(e){const t=i.getAttr(e,"id"),r=i.buildErrorFromXMPPErrorStanza(e);"function"==typeof this.onMessageErrorListener&&s.safeCallbackCall(this.onMessageErrorListener,t,r)}_postConnectActions(){s.DLog("[Chat]",this._isReconnect?"RECONNECTED":"CONNECTED");const e=i.createPresenceStanza();if(n.chat.streamManagement.enable&&2===n.chatProtocol.active&&(this.streamManagement.enable(this.xmppClient),this.streamManagement.sentMessageCallback=this._sentMessageCallback),this.helpers.setUserCurrentJid(this.helpers.userCurrentJid(this.xmppClient)),this.isConnected=!0,this._isConnecting=!1,this._enableCarbons(),this.xmppClient.send(e),this._isReconnect?"function"==typeof this.onReconnectListener&&s.safeCallbackCall(this.onReconnectListener):this._isReconnect=!0,this.earlyIncomingMessagesQueue.length>0){s.DLog("[Chat]",`Flush 'earlyIncomingMessagesQueue' (length=${this.earlyIncomingMessagesQueue.length})`);const e=this.xmppClientListeners.filter((e=>"stanza"===e.name))[0].callback;this.earlyIncomingMessagesQueue.forEach((t=>{e(t)})),this.earlyIncomingMessagesQueue=[]}}_enableCarbons(){const e={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("enableCarbons")},t=i.createIqStanza(e);t.c("enable",{xmlns:"urn:xmpp:carbons:2"}),this.xmppClient.send(t)}_setSubscriptionToUserLastActivity(e,t){var r={id:this.helpers.getUniqueId("statusStreaming"),type:"set"},n=i.createIqStanza(r);n.c("subscribe",{xmlns:"https://connectycube.com/protocol/status_streaming",user_jid:this.helpers.jidOrUserId(e),enable:t}),this.xmppClient.send(n)}subscribeToUserLastActivityStatus(e){this._setSubscriptionToUserLastActivity(e,!0)}unsubscribeFromUserLastActivityStatus(e){this._setSubscriptionToUserLastActivity(e,!1)}}},1458:(e,t,r)=>{const n=r(9028),s=r(330),i=r(3173);e.exports=class{constructor(){this._userCurrentJid=null}getUniqueId(e){return i.getUniqueId(e)}isNumeric(e){return/^-?\d+$/.test(e)||/^\d+\.\d+$/.test(e)}jidOrUserId(e){let t;return t="string"==typeof e?this.isNumeric(e)?this.getUserJid(e):e.includes("@")?e:this.getRoomJidFromDialogId(e):this.getUserJid(e),t}typeChat(e){let t;if("string"==typeof e)t=this.isNumeric(e)?"chat":e.includes("@")?e.includes("muc")?"groupchat":"chat":"groupchat";else{if("number"!=typeof e)throw new Error("Unsupported chat type");t="chat"}return t}getUserJid(e,t){return t?e+"-"+t+"@"+s.endpoints.chat:e+"-"+s.creds.appId+"@"+s.endpoints.chat}getUserNickWithMucDomain(e){return s.endpoints.muc+"/"+e}getUserIdFromJID(e){return e?.includes("@")?parseInt(e.split("@")[0].split("-")[0]):null}getDialogIdFromJID(e){return e?.includes("@")?e.split("@")[0].split("_")[1]:null}getRoomJidFromDialogId(e){return s.creds.appId+"_"+e+"@"+s.endpoints.muc}getRoomJid(e){return e+"/"+this.getUserIdFromJID(this._userCurrentJid)}getIdFromResource(e){let t=e.split("/");return t.length<2?null:(t.splice(0,1),parseInt(t.join("/")))}getRoomJidFromRoomFullJid(e){let t=e.split("/");return t.length<2?null:t[0]}getBsonObjectId(){return n.getBsonObjectId()}getUserIdFromRoomJid(e){let t=e.toString().split("/");return 0===t.length?null:t[t.length-1]}userCurrentJid(e){return e.jid._local+"@"+e.jid._domain+"/"+e.jid._resource}getUserCurrentJid(){return this._userCurrentJid}setUserCurrentJid(e){this._userCurrentJid=e}getDialogJid(e){return e.indexOf("@")>0?e:this.getRoomJidFromDialogId(e)}}},3173:(e,t,r)=>{r(9028);const n=r(330),s=r(8009).XMPPClient;e.exports=class{static buildUserJid(e){let t;return"userId"in e?(t=e.userId+"-"+n.creds.appId+"@"+n.endpoints.chat,"resource"in e&&(t=t+"/"+e.resource)):"jid"in e&&(t=e.jid),t}static buildUserJidLocalPart(e){return e+"-"+n.creds.appId}static createMessageStanza(e){return s.xml("message",e)}static createIqStanza(e){return s.xml("iq",e)}static createPresenceStanza(e){return s.xml("presence",e)}static createNonza(e,t){return s.xml(e,t)}static getAttr(e,t){if(!e)return null;let r;return"function"==typeof e.getAttribute?r=e.getAttribute(t):e.attrs&&(r=e.attrs[t]),r}static getElement(e,t){let r;return"function"==typeof e.querySelector?r=e.querySelector(t):"function"==typeof e.getChild&&(r=e.getChild(t)),r}static isErrorStanza(e){return!!e.getChild("error")}static getAllElements(e,t){let r;return"function"==typeof e.querySelectorAll?r=e.querySelectorAll(t):"function"==typeof e.getChild&&(r=e.getChild(t)),r}static getElementText(e,t){let r,n;return"function"==typeof e.querySelector?(r=e.querySelector(t),n=r?r.textContent:null):"function"==typeof e.getChildText&&(n=e.getChildText(t)),n}static getElementTreePath(e,t){return t.reduce(((e,t)=>e?this.getElement(e,t):e),e)}static _JStoXML(e,t,r){r=r.c(e),Object.keys(t).forEach((e=>{"object"==typeof t[e]?this._JStoXML(e,t[e],r):r=r.c(e).t(t[e]).up()})),r=r.up()}static _XMLtoJS(e,t,r){e[t]={};let n=r.childNodes||r.children;for(let r=0;r=1?e[t]=this._XMLtoJS(e[t],o,s):e[t][o]=a}return e}static filledExtraParams(e,t){return Object.keys(t).forEach((r=>{"attachments"===r?t[r].forEach((t=>{e.getChild("extraParams").c("attachment",t).up()})):"object"==typeof t[r]?this._JStoXML(r,t[r],e.getChild("extraParams")):e.getChild("extraParams").c(r).t(t[r]).up()})),e.up(),e}static parseExtraParams(e){if(!e)return null;let t,r,n,s={},i=[];for(let o=0,a=e.children.length;o0&&(s.attachments=i),s.moduleIdentifier&&delete s.moduleIdentifier,{extension:s,dialogId:t}}static buildErrorFromXMPPErrorStanza(e){const t=this.getElement(e,"error");return{code:parseInt(this.getAttr(t,"code")),info:this.getElementText(t,"text")}}static getUniqueId(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}static parseReactions(e){let t=e.children;return t=t.map((e=>({add:"true"===this.getAttr(e,"add"),remove:"true"===this.getAttr(e,"remove"),reaction:this.getAttr(e,"type")}))),t.reduce(((e,t)=>(t.add&&(e.add=t.reaction),t.remove&&(e.remove=t.reaction),e)),{})}}},1341:(e,t,r)=>{const n=r(3173),s=r(9028),i=r(330);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.contacts={},this.xmlns="jabber:iq:roster"}get(){return new Promise(((e,t)=>{const r=n.getUniqueId("getRoster");let s={},o=n.createIqStanza({type:"get",from:this.helpers.getUserCurrentJid(),id:r});o.c("query",{xmlns:this.xmlns}),this.stanzasCallbacks[r]=t=>{const r=t.getChild("query").children;for(let e=0,t=r.length;e{const s=e.userId||e,i=this.helpers.jidOrUserId(s),o=n.getUniqueId("addContactInRoster");let a=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:o});this.contacts[s]={subscription:"none",ask:"subscribe",name:e.name||null},a.c("query",{xmlns:this.xmlns}).c("item",{jid:i,name:e.name||null}),this.stanzasCallbacks[o]=()=>{this._sendSubscriptionPresence({jid:i,type:"subscribe"}),t()},this.xmppClient.send(a)}))}confirm(e){return new Promise(((t,r)=>{const n=e.userId||e,s=this.helpers.jidOrUserId(n);this._sendSubscriptionPresence({jid:s,type:"subscribed"}),i.chat.contactList.subscriptionMode.mutual?this.add(e,(function(){t()})):t()}))}reject(e){return new Promise(((t,r)=>{const n=this.helpers.jidOrUserId(e);this.contacts[e]={subscription:"none",ask:null},this._sendSubscriptionPresence({jid:n,type:"unsubscribed"}),t()}))}updateName(e){return new Promise(((t,r)=>{const i=this.helpers.jidOrUserId(e.userId),o=n.getUniqueId("updateContactInRoster");let a=this.contacts[e.userId];if(!s.isObject(a))return void r("No contact exists with provided user id");a.name=e.name||null;let c=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:o});c.c("query",{xmlns:this.xmlns}).c("item",{jid:i,name:e.name||null}),this.stanzasCallbacks[o]=e=>{"result"===e.attrs.type?t():r(e)},this.xmppClient.send(c)}))}remove(e){return new Promise(((t,r)=>{const s=this.helpers.jidOrUserId(e),i=n.getUniqueId("removeConactInRoster");let o=n.createIqStanza({type:"set",from:this.helpers.getUserCurrentJid(),id:i});o.c("query",{xmlns:this.xmlns}).c("item",{jid:s,subscription:"remove"}),this.stanzasCallbacks[i]=()=>{delete this.contacts[e],t()},this.xmppClient.send(o)}))}_sendSubscriptionPresence(e){const t={to:e.jid,type:e.type},r=n.createPresenceStanza(t);this.xmppClient.send(r)}}},3873:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.chat+"/Dialog";e.exports=class{constructor(e){this.proxy=e}list(e){const t={type:"GET",url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e){const t=s.cloneObject(e);t&&t.occupants_ids&&s.isArray(t.occupants_ids)&&(t.occupants_ids=t.occupants_ids.join(", "));const r={type:"POST",url:s.getUrl(i),data:t};return this.proxy.ajax(r)}update(e,t){const r={type:"PUT",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e,t){const r={type:"DELETE",url:s.getUrl(i,e)};return("string"==typeof e||s.isArray(e)&&1===e.length)&&(r.dataType="text"),t&&(r.data=t),this.proxy.ajax(r)}addAdmins(e,t){const r={push_all:{admins_ids:t}},n={type:"PUT",url:s.getUrl(i,e,"admins"),data:r};return this.proxy.ajax(n)}removeAdmins(e,t){const r={pull_all:{admins_ids:t}},n={type:"PUT",url:s.getUrl(i,e,"admins"),data:r};return this.proxy.ajax(n)}subscribe(e){const t={type:"POST",url:s.getUrl(i,e,"subscribe")};return this.proxy.ajax(t)}unsubscribe(e){const t={type:"DELETE",url:s.getUrl(i,e,"subscribe"),dataType:"text"};return this.proxy.ajax(t)}subscribeToPublic(e){return this.subscribe(e)}unsubscribeFromPublic(e){return this.unsubscribe(e)}updateNotificationsSettings(e,t){const r={enabled:t?1:0},n={type:"PUT",url:s.getUrl(i,e,"notifications"),data:r};return this.proxy.ajax(n)}getNotificationsSettings(e){const t={type:"GET",url:s.getUrl(i,e,"notifications")};return this.proxy.ajax(t)}getPublicOccupants(e,t){const r={type:"GET",url:s.getUrl(i,e,"occupants"),data:t};return this.proxy.ajax(r)}clearHistory(e){const t={type:"DELETE",url:s.getUrl(i,"clearHistory",e),dataType:"text"};return this.proxy.ajax(t)}}},6462:(e,t,r)=>{const n=r(330),s=r(9028),i=n.urls.chat+"/Message";e.exports=class{constructor(e){this.proxy=e}list(e){const t={url:s.getUrl(i),data:e};return this.proxy.ajax(t)}create(e){const t={url:s.getUrl(i),type:"POST",data:e};return this.proxy.ajax(t)}update(e,t){const r={type:"PUT",dataType:"text",url:s.getUrl(i,e),data:t};return this.proxy.ajax(r)}delete(e,t={}){const r={url:s.getUrl(i,e),type:"DELETE",dataType:"text"};return t&&(r.data=t),this.proxy.ajax(r)}createSystem(e){const t={url:s.getUrl(i+"/system"),type:"POST",data:e};return this.proxy.ajax(t)}unreadCount(e){const t=s.cloneObject(e);t&&t.chat_dialog_ids&&s.isArray(t.chat_dialog_ids)&&(t.chat_dialog_ids=t.chat_dialog_ids.join(", "));const r={url:s.getUrl(i+"/unread"),data:t};return this.proxy.ajax(r)}listReactions(e){const t={type:"GET",dataType:"json",url:s.getUrl(i,e,"reactions"),data:{}};return this.proxy.ajax(t)}addReaction(e,t){return this.updateReaction(e,t)}removeReaction(e,t){return this.updateReaction(e,null,t)}updateReaction(e,t,r){const n={};t&&(n.add=t),r&&(n.remove=r);const o={type:"PUT",dataType:"text",url:s.getUrl(i,e,"reactions"),data:n};return this.proxy.ajax(o)}}},6349:(e,t,r)=>{const n=r(3173);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.joinedRooms={},this.xmlns="http://jabber.org/protocol/muc"}join(e){return new Promise(((t,r)=>{const s=n.getUniqueId("join"),i=this.helpers.getDialogJid(e),o={id:s,from:this.helpers.getUserCurrentJid(),to:this.helpers.getRoomJid(i)};let a=n.createPresenceStanza(o);a.c("x",{xmlns:this.xmlns}).c("history",{maxstanzas:0}),this.stanzasCallbacks[s]=e=>{const o=n.getAttr(e,"from"),a=(this.helpers.getDialogIdFromJID(o),n.getElement(e,"x")),c=n.getAttr(a,"xmlns"),l=n.getElement(a,"status"),u=n.getAttr(l,"code");if(l&&"110"==u)this.joinedRooms[i]=!0,t();else{const t=n.getAttr(e,"type");if(t&&"error"===t&&c===this.xmlns&&s.endsWith(":join")){const t=n.getElement(e,"error"),s=n.getAttr(t,"code"),i=n.getElementText(t,"text");r({code:s||500,message:i||"Unknown issue"})}}},this.xmppClient.send(a)}))}leave(e){return new Promise(((t,r)=>{const s=this.helpers.getDialogJid(e),i={type:"unavailable",from:this.helpers.getUserCurrentJid(),to:this.helpers.getRoomJid(s)},o=n.createPresenceStanza(i);delete this.joinedRooms[s],this.stanzasCallbacks["muc:leave"]=e=>{t()},this.xmppClient.send(o)}))}listOnlineUsers(e){return new Promise(((t,r)=>{const s={type:"get",to:this.helpers.getDialogJid(e),from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("muc_disco_items")};let i=n.createIqStanza(s);i.c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),this.stanzasCallbacks[s.id]=e=>{var r=e.attrs.id;if(this.stanzasCallbacks[r]){const r=e.getChild("query").getChildElements("item");let i=[];for(var n=0,s=r.length;n{const n=r(3173),s=r(9028);e.exports=class{constructor(e){this.helpers=e.helpers,this.xmppClient=e.xmppClient,this.stanzasCallbacks=e.stanzasCallbacks,this.xmlns="jabber:iq:privacy"}create(e){return new Promise(((t,r)=>{let s,i,o,a,c,l={},u=[];for(let t=e.items.length-1;t>=0;t--){const r=e.items[t];l[r.user_id]={action:r.action,mutualBlock:!0===r.mutualBlock}}u=Object.keys(l);const d={type:"set",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("edit")};let h=n.createIqStanza(d);function p(e,t){return e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up(),e}function f(e,t){return e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up(),e}h.c("query",{xmlns:this.xmlns}).c("list",{name:e.name});for(let e=0,t=0,r=u.length;e{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(h)}))}getList(e){return new Promise(((t,r)=>{let s,i,o,a=[],c={};const l={type:"get",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("getlist")};let u=n.createIqStanza(l);u.c("query",{xmlns:this.xmlns}).c("list",{name:e}),this.stanzasCallbacks[l.id]=e=>{const r=e.getChild("query");c=r?r.getChild("list"):null,s=c?c.getChildElements("item"):null;for(let e=0,t=s.length;e{this.getList(e.name).then((n=>{const i={items:s.mergeArrays(n.items,e.items),name:e.name};this.create(i).then((()=>{t()})).catch((e=>{r(e)}))})).catch((e=>{r(e)}))}))}getNames(){return new Promise(((e,t)=>{const r={type:"get",from:this.helpers.getUserCurrentJid(),id:n.getUniqueId("getNames")};let s=n.createIqStanza(r);s.c("query",{xmlns:this.xmlns}),this.stanzasCallbacks[s.attrs.id]=r=>{if(n.isErrorStanza(r))t(n.buildErrorFromXMPPErrorStanza(r));else{const t=r.getChild("query"),n=t.getChild("default"),s=t.getChild("active"),i=t.getChildElements("list");let o=n?n.attrs.name:null,a=s?s.attrs.name:null,c=[];for(let e=0,t=i.length;e{const s={from:this.xmppClient.jid||this.xmppClient.jid.user,type:"set",id:n.getUniqueId("remove")};let i=n.createIqStanza(s);i.c("query",{xmlns:this.xmlns}).c("list",{name:e||""}),this.stanzasCallbacks[i.attrs.id]=e=>{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(i)}))}setAsDefault(e){return new Promise(((t,r)=>{const s={from:this.xmppClient.jid||this.xmppClient.jid.user,type:"set",id:n.getUniqueId("default")};let i=n.createIqStanza(s);i.c("query",{xmlns:this.xmlns}).c("default",e&&e.length>0?{name:e}:{}),this.stanzasCallbacks[i.attrs.id]=e=>{n.isErrorStanza(e)?r(n.buildErrorFromXMPPErrorStanza(e)):t()},this.xmppClient.send(i)}))}}},278:(e,t,r)=>{const n=r(9028),s=r(3173);e.exports=class{constructor(){this._NS="urn:xmpp:sm:3",this._isStreamManagementEnabled=!1,this._clientProcessedStanzasCounter=0,this._clientSentStanzasCounter=0,this.sentMessageCallback=null,this._lastAck=0,this._xmppClient=null,this._originalSend=null,this._unackedQueue=[],this._incomingStanzaHandler=e=>{let t=e.name||e.tagName||e.nodeTree.tagName;if("enabled"!==t)if(s.getAttr(e,"xmlns")!==this._NS&&this._increaseReceivedStanzasCounter(),"r"!==t){if("a"===t){const t=parseInt(s.getAttr(e,"h"));this._checkCounterOnIncomeStanza(t)}}else{let e={xmlns:this._NS,h:this._clientProcessedStanzasCounter},t=s.createNonza("a",e);this._originalSend.call(this._xmppClient,t)}else this._isStreamManagementEnabled=!0}}enable(e){let t={xmlns:this._NS};this._isStreamManagementEnabled||(this._xmppClient=e,this._originalSend=this._xmppClient.send,this._xmppClient.send=this.send.bind(this)),this._clientProcessedStanzasCounter=0,this._clientSentStanzasCounter=0,this._lastAck=0,this._removeElementHandler(),this._addElementHandler();const r=s.createNonza("enable",t);this._xmppClient.send(r)}_removeElementHandler(){this._xmppClient.removeListener("element",this._incomingStanzaHandler)}_addElementHandler(){this._xmppClient.on("element",this._incomingStanzaHandler)}send(e,t){let r=e.name||e.tagName||e.nodeTree.tagName,n=s.getAttr(e,"type"),i=s.getElementText(e,"body")||"",o=s.getAllElements(e,"attachment")||"";this._originalSend.call(this._xmppClient,e),"message"!==r||"chat"!==n&&"groupchat"!==n||!i&&!o.length||this._sendStanzasRequest({message:t,expect:this._clientSentStanzasCounter}),++this._clientSentStanzasCounter}_sendStanzasRequest(e){if(this._isStreamManagementEnabled){this._unackedQueue.push(e);const t=s.createNonza("r",{xmlns:this._NS});this._originalSend.call(this._xmppClient,t)}}getClientSentStanzasCounter(){return this._clientSentStanzasCounter}_checkCounterOnIncomeStanza(e){const t=e-this._lastAck;n.DLog("[Chat][SM][_checkCounterOnIncomeStanza]",t,e,this._lastAck);for(let e=0;e0;e++)this.sentMessageCallback(null,this._unackedQueue.shift().message);this._lastAck=e}_increaseReceivedStanzasCounter(){++this._clientProcessedStanzasCounter}}},2555:(e,t,r)=>{const n=r(330),s=r(1366),i=r(8666).SessionConnectionState,o=r(8009).RTCPeerConnection,a=r(8009).RTCSessionDescription,c=r(8009).RTCIceCandidate,l=r(8009).MediaStream,u=r(8666).PeerConnectionState;o.prototype._init=function(e,t,r,n){s.trace("RTCPeerConnection init. userID: "+t+", sessionID: "+r+", type: "+n),this.delegate=e,this.sessionID=r,this.userID=t,this.type=n,this.remoteSDP=null,this.state=u.NEW,this.remoteStream=new l,this.ontrack=this.onAddRemoteMediaCallback.bind(this),this.onicecandidate=this.onIceCandidateCallback.bind(this),this.onsignalingstatechange=this.onSignalingStateCallback.bind(this),this.oniceconnectionstatechange=this.onIceConnectionStateCallback.bind(this),this.onStatusClosedChecker=void 0,this.dialingTimer=null,this.answerTimeInterval=0,this.statsReportTimer=null,this.iceCandidates=[],this.released=!1},o.prototype.release=function(){this._clearDialingTimer(),this._clearStatsReportTimer(),this.close(),s.getVersionSafari()>=11&&this.onIceConnectionStateCallback(),this.released=!0},o.prototype.updateRemoteSDP=function(e){if(!e)throw new Error("sdp string can't be empty.");this.remoteSDP=e},o.prototype.getRemoteSDP=function(){return this.remoteSDP},o.prototype.setRemoteSessionDescription=function(e,t){const r=new a({sdp:t,type:e});return this.setRemoteDescription(r)},o.prototype.getAndSetLocalSessionDescription=function(e,t={}){return new Promise(((r,n)=>{if(this.state=u.CONNECTING,"offer"===this.type)this.createOffer(t).then((t=>{this.setLocalDescription(t).then((n=>{this.setRTCRtpSenderMaxBandwidth(e),r(t)})).catch(n)})).catch(n);else{if(t.iceRestart)throw new Error("iceRestart is possible only from offer side");this.createAnswer(t).then((t=>{this.setLocalDescription(t).then((n=>{this.setRTCRtpSenderMaxBandwidth(e),r(t)})).catch(n)})).catch(n)}}))},o.prototype.setRTCRtpSenderMaxBandwidth=function(e){(this.getSenders()||[]).forEach((t=>{if("video"===t.track.kind){const r=t.getParameters();r.encodings||(r.encodings=[]),e?r.encodings[0].maxBitrate=1e3*e:delete r.encodings[0]?.maxBitrate,t.setParameters(r).then((()=>{s.trace("Set maxBandwidth success ["+this.userID+"]: "+e+" kbps")})).catch((e=>{s.trace("Set maxBandwidth error ["+this.userID+"]: "+e)}))}}))},o.prototype.addCandidates=function(e){for(let t=0,r=e.length;t{}),(e=>{s.traceError("Error on 'addIceCandidate': "+e)}))}},o.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", type: "+this.type+", state: "+this.state},o.prototype.onSignalingStateCallback=function(){s.trace("onSignalingStateCallback: "+this.signalingState),"stable"===this.signalingState&&this.iceCandidates.length>0&&(this.delegate._processIceCandidates(this,this.iceCandidates),this.iceCandidates.length=0)},o.prototype.onIceCandidateCallback=function(e){const t=e.candidate;if(t){const e={sdpMLineIndex:t.sdpMLineIndex,sdpMid:t.sdpMid,candidate:t.candidate};"stable"===this.signalingState?this.delegate._processIceCandidates(this,[e]):this.iceCandidates.push(e)}},o.prototype.onAddRemoteMediaCallback=function(e){"function"==typeof this.delegate._onRemoteStreamListener&&(this.remoteStream.addTrack(e.track),(1==this.delegate.callType&&this.remoteStream.getVideoTracks().length||2==this.delegate.callType&&this.remoteStream.getAudioTracks().length)&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream),this._getStatsWrap())},o.prototype.onIceConnectionStateCallback=function(){if(s.trace("onIceConnectionStateCallback: "+this.iceConnectionState),"function"==typeof this.delegate._onSessionConnectionStateChangedListener){let e=null;switch(s.getVersionSafari()>=11&&clearTimeout(this.onStatusClosedChecker),this.iceConnectionState){case"checking":this.state=u.CHECKING,e=i.CONNECTING;break;case"connected":this._clearWaitingReconnectTimer(),this.state=u.CONNECTED,e=i.CONNECTED;break;case"completed":this._clearWaitingReconnectTimer(),this.state=u.COMPLETED,e=i.COMPLETED;break;case"failed":this.state=u.FAILED,e=i.FAILED;break;case"disconnected":this._startWaitingReconnectTimer(),this.state=u.DISCONNECTED,e=i.DISCONNECTED,s.getVersionSafari()>=11&&(this.onStatusClosedChecker=setTimeout((()=>{this.onIceConnectionStateCallback()}),500));break;case"closed":this._clearWaitingReconnectTimer(),this.state=u.CLOSED,e=i.CLOSED}e&&this.delegate._onSessionConnectionStateChangedListener(this.userID,e)}},o.prototype._clearStatsReportTimer=function(){this.statsReportTimer&&(clearInterval(this.statsReportTimer),this.statsReportTimer=null)},o.prototype._getStatsWrap=function(){let e,t;if(n.videochat&&n.videochat.statsReportTimeInterval){if(isNaN(+n.videochat.statsReportTimeInterval))return void s.traceError("statsReportTimeInterval ("+n.videochat.statsReportTimeInterval+") must be integer.");e=1e3*n.videochat.statsReportTimeInterval;const r=()=>{!function(e,t,r,n){let i={local:{audio:{},video:{},candidate:{}},remote:{audio:{},video:{},candidate:{}}};if(s.getVersionFirefox()){let t=e.getLocalStreams().length?e.getLocalStreams()[0]:e.delegate.localStream,r=t.getVideoTracks().length?t.getVideoTracks()[0].getSettings():null;i.local.video.frameHeight=r&&r.height,i.local.video.frameWidth=r&&r.width}e.getStats(null).then((e=>{e.forEach((e=>{let r;e.bytesReceived&&"inbound-rtp"===e.type?(r=i.remote[e.mediaType],r.bitrate=o(e,t,!1),r.bytesReceived=e.bytesReceived,r.packetsReceived=e.packetsReceived,r.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(r.framesPerSecond=Math.round(10*e.framerateMean)/10)):e.bytesSent&&"outbound-rtp"===e.type?(r=i.local[e.mediaType],r.bitrate=o(e,t,!0),r.bytesSent=e.bytesSent,r.packetsSent=e.packetsSent,r.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(r.framesPerSecond=Math.round(10*e.framerateMean)/10)):"local-candidate"===e.type?(r=i.local.candidate,"host"===e.candidateType&&"udp"===e.mozLocalTransport&&"udp"===e.transport?(r.protocol=e.transport,r.ip=e.ipAddress,r.port=e.portNumber):s.getVersionFirefox()||(r.protocol=e.protocol,r.ip=e.ip,r.port=e.port)):"remote-candidate"===e.type?(r=i.remote.candidate,r.protocol=e.protocol||e.transport,r.ip=e.ip||e.ipAddress,r.port=e.port||e.portNumber):"track"!==e.type||"video"!==e.kind||s.getVersionFirefox()||(e.remoteSource?(r=i.remote.video,r.frameHeight=e.frameHeight,r.frameWidth=e.frameWidth,r.framesPerSecond=a(e,t,!1)):(r=i.local.video,r.frameHeight=e.frameHeight,r.frameWidth=e.frameWidth,r.framesPerSecond=a(e,t,!0)))})),r(i,e)}),n);const o=(e,t,r)=>{let n,s=t&&t.get(e.id),i=s?(e.timestamp-s.timestamp)/1e3:5;return n=s?r?8*(e.bytesSent-s.bytesSent)/(1024*i):8*(e.bytesReceived-s.bytesReceived)/(1024*i):0,Math.round(n)},a=(e,t,r)=>{let n,s=t&&t.get(e.id),i=s?(e.timestamp-s.timestamp)/1e3:5;return n=s?r?(e.framesSent-s.framesSent)/i:(e.framesReceived-s.framesReceived)/i:0,Math.round(10*n)/10}}(this,t,((e,r)=>{t=r,this.delegate._onCallStatsReport(this.userID,e,null)}),(e=>{s.traceError("_getStats error. "+e.name+": "+e.message),this.delegate._onCallStatsReport(this.userID,null,e)}))};s.trace("Stats tracker has been started."),this.statsReportTimer=setInterval(r,e)}},o.prototype._clearWaitingReconnectTimer=function(){this.waitingReconnectTimeoutCallback&&(s.trace("_clearWaitingReconnectTimer"),clearTimeout(this.waitingReconnectTimeoutCallback),this.waitingReconnectTimeoutCallback=null)},o.prototype._startWaitingReconnectTimer=function(){const e=1e3*n.videochat.disconnectTimeInterval;s.trace("_startWaitingReconnectTimer, timeout: "+e),this.waitingReconnectTimeoutCallback=setTimeout((()=>{s.trace("waitingReconnectTimeoutCallback"),clearTimeout(this.waitingReconnectTimeoutCallback),this.release(),this.delegate._closeSessionIfAllConnectionsClosed()}),e)},o.prototype._clearDialingTimer=function(){this.dialingTimer&&(s.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},o.prototype._startDialingTimer=function(e,t){const r=1e3*n.videochat.dialingTimeInterval;s.trace("_startDialingTimer, dialingTimeInterval: "+r);const i=(e,t,r)=>{r||(this.answerTimeInterval+=1e3*n.videochat.dialingTimeInterval),s.trace("_dialingCallback, answerTimeInterval: "+this.answerTimeInterval),this.answerTimeInterval>=1e3*n.videochat.answerTimeInterval?(this._clearDialingTimer(),t&&this.delegate._processOnNotAnswer(this)):this.delegate._processCall(this,e)};this.dialingTimer=setInterval(i,r,e,t,!1),i(e,t,!0)},e.exports=o},5888:(e,t,r)=>{const n=r(3191),s=r(5395),i=r(2382),o=r(1366),a=r(8666),c=r(8666).SessionState,l=r(9028),u=r(8009).mediaDevices,d=r(330);e.exports=class{constructor(e,t){this.connection=e,this.proxy=t,this.signalingProcessor=new s(this),this.signalingProvider=new i(e),this.SessionConnectionState=a.SessionConnectionState,this.PeerConnectionState=a.PeerConnectionState,this.CallType=a.CallType,this.sessions={},u&&(u.ondevicechange=this._onDevicesChangeListener.bind(this))}getMediaDevices(e){const t=[];return new Promise(((r,n)=>{u&&u.enumerateDevices?u.enumerateDevices().then((n=>{e?(n.forEach(((r,n)=>{r.kind===e&&t.push(r)})),r(t)):r(n)})):n("No 'enumerateDevices' API supported")}))}createNewSession(e,t){const r=o.getUserIdFromJID(o.userCurrentJid(this.connection));if(!e)throw new Error("Can't create a session without opponentsIDs.");return this._createAndStoreSession(null,r,e,t)}_createAndStoreSession(e,t,r,s,i){const a=new n({sessionID:e,initiatorID:t,opIDs:r,callType:s,signalingProvider:this.signalingProvider,currentUserID:o.getUserIdFromJID(o.userCurrentJid(this.connection)),maxBandwidth:i});return a.onUserNotAnswerListener=this.onUserNotAnswerListener,a.onRemoteStreamListener=this.onRemoteStreamListener,a.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,a.onSessionCloseListener=this.onSessionCloseListener,a.onCallStatsReport=this.onCallStatsReport,this.sessions[a.ID]=a,a}clearSession(e){delete this.sessions[e]}callRejectRequest(e){const t={type:"POST",url:l.getUrl(d.urls.calls,"reject"),data:{...e}};return this.proxy.ajax(t)}_onCallListener(e,t,r){const n=r.userInfo||{},s=+n.maxBandwidth||0;let i=this.sessions[t];o.trace("onCall. UserID:"+e+". SessionID: "+t+". extension: ",n),i?i._processOnCall(e,r):(i=this._createAndStoreSession(t,r.callerID,r.opponentsIDs,r.callType,s),i._processOnCall(e,r),l.safeCallbackCall(this.onCallListener,i,n))}_onAcceptListener(e,t,r){const n=this.sessions[t],s=r.userInfo||{};o.trace("onAccept. UserID:"+e+". SessionID: "+t),!n||n.state!==c.ACTIVE&&n.state!==c.NEW?o.traceWarning("Ignore 'onAccept', there is no information about session "+t):(l.safeCallbackCall(this.onAcceptCallListener,n,e,s),n._processOnAccept(e,r))}_onRejectListener(e,t,r){const n=this.sessions[t];if(o.trace("onReject. UserID:"+e+". SessionID: "+t),n){const t=r.userInfo||{};l.safeCallbackCall(this.onRejectCallListener,n,e,t),n._processOnReject(e,r)}else o.traceWarning("Ignore 'onReject', there is no information about session "+t)}_onStopListener(e,t,r){o.trace("onStop. UserID:"+e+". SessionID: "+t);const n=this.sessions[t],s=r.userInfo||{};!n||n.state!==c.ACTIVE&&n.state!==c.NEW?(l.safeCallbackCall(this.onInvalidEventsListener,"onStop",n,e,s),o.traceWarning("Ignore 'onStop', there is no information about session "+t+" by some reason.")):(n._processOnStop(e,r),l.safeCallbackCall(this.onStopCallListener,n,e,s))}_onIceCandidatesListener(e,t,r){const n=this.sessions[t];o.trace("onIceCandidates. UserID:"+e+". SessionID: "+t+". ICE candidates count: "+r.iceCandidates.length),n?n.state===c.ACTIVE?n._processOnIceCandidates(e,r):o.traceWarning("Ignore 'OnIceCandidates', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'OnIceCandidates', there is no information about session "+t)}_onIceRestartListener(e,t,r){const n=this.sessions[t];o.trace("onIceRestart. UserID:"+e+". SessionID: "+t),n?n.state===c.ACTIVE?n._processOnIceRestart(e,r):o.traceWarning("Ignore 'OnIceRestart', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'OnIceRestart', there is no information about session "+t)}_onIceRestartAcceptListener(e,t,r){const n=this.sessions[t];o.trace("onIceRestartAccept. UserID:"+e+". SessionID: "+t),n?n.state===c.ACTIVE?n._processOnIceRestartAccept(e,r):o.traceWarning("Ignore 'onIceRestartAccept', the session ( "+t+" ) has invalid state."):o.traceWarning("Ignore 'onIceRestartAccept', there is no information about session "+t)}_onDevicesChangeListener(){l.safeCallbackCall(this.onDevicesChangeListener)}}},8666:e=>{e.exports={SignalingConstants:{MODULE_ID:"WebRTCVideoChat",SignalingType:{CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",RESTART:"iceRestart",RESTART_ACCEPT:"iceRestartAccept",CANDIDATE:"iceCandidates"}},SessionConnectionState:{UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},SessionState:{NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5},PeerConnectionState:{NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},CallType:{VIDEO:1,AUDIO:2}}},1366:(e,t,r)=>{const n=r(330);e.exports=class{static getUserJid(e,t){return e+"-"+t+"@"+n.endpoints.chat}static getUserIdFromJID(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])}static userCurrentJid(e){return e.jid._local+"@"+e.jid._domain+"/"+e.jid._resource}static trace(e){n.debug&&console.log("[VideoChat]:",e)}static traceWarning(e){n.debug&&console.warn("[VideoChat]:",e)}static traceError(e){n.debug&&console.error("[VideoChat]:",e)}static getVersionFirefox(){const e=!!navigator&&navigator.userAgent;let t;if(e){const r=e.match(/(?:firefox)[ \/](\d+)/i)||[];t=r[1]?+r[1]:null}return t}static getVersionSafari(){const e=!!navigator&&navigator.userAgent;let t;if(e)if((e.match(/(?:safari)[ \/](\d+)/i)||[]).length){const r=e.match(/(?:version)[ \/](\d+)/i)||[];t=r&&r[1]?+r[1]:null}else t=null;return t}}},3191:(e,t,r)=>{const n=r(330),s=r(2555),i=r(9028),o=r(1366),a=r(8666).SignalingConstants,c=r(8666).SessionState,l=r(8666).PeerConnectionState,u=r(8009).mediaDevices;function d(e={}){const t={userInfo:e};try{i.isObject(e)?t.userInfo=i.cloneObject(e,!0):o.traceWarning("Ignore 'extension', must be an object.")}catch(e){o.traceWarning(e.message)}return t}function h(e){const t=i.cloneObject(e);return Object.keys(t).forEach(((e,r,n)=>{t[r].hasOwnProperty("url")?t[r].urls=t[r].url:t[r].url=t[r].urls})),t}e.exports=class{constructor(e){this.ID=e.sessionID?e.sessionID:function(){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}(),this.state=c.NEW,this.initiatorID=parseInt(e.initiatorID),this.opponentsIDs=e.opIDs,this.callType=parseInt(e.callType),this.peerConnections={},this.localStream=null,this.mediaParams=null,this.signalingProvider=e.signalingProvider,this.currentUserID=e.currentUserID,this.maxBandwidth=e.maxBandwidth,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0}getDisplayMedia(e){if(!u.getDisplayMedia)throw new Error("Your environment does not support 'getDisplayMedia' API");const t=e&&e.elementId,r=e&&e.options,n={...e};return this.mediaParams=n,delete n.elementId,delete n.options,u.getDisplayMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}getUserMedia(e){const t=e&&e.elementId,r=e&&e.options,n={...e};return this.mediaParams=n,delete n.elementId,delete n.options,u.getUserMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}_upsertStream(e,t,r){const n=!!this.localStream;n?(this.localStream.getTracks().forEach((t=>{"audio"===t.kind&&0===e.getAudioTracks().length||(t.stop(),this.localStream.removeTrack(t))})),this._replaceTracks(e)):this.localStream=e,t&&(n&&this.detachMediaStream(t,r),this.attachMediaStream(t,this.localStream,r))}_replaceTracks(e){const t=this.peerConnections;e.getTracks().forEach((e=>{"audio"===e.kind?e.enabled=this.localStream.getAudioTracks().every((e=>e.enabled)):e.enabled=this.localStream.getVideoTracks().every((e=>e.enabled))}));for(let r in t)t[r].getSenders().map((t=>{const r=e.getTracks().find((e=>e.kind===t.track.kind));r&&(t.replaceTrack(r),this.localStream.addTrack(r))}))}setMaxBandwidth(e){const t=this.peerConnections||[];if(t.length<1)o.trace("No 'RTCPeerConnection' to set 'maxBandwidth'");else for(let r in t)t[r].setRTCRtpSenderMaxBandwidth(e)}connectionStateForUser(e){const t=this.peerConnections[e];return t?t.state:null}attachMediaStream(e,t,r){const n=document.getElementById(e);if(!n)throw new Error("Unable to attach media stream, element "+e+" is undefined");"object"==typeof n.srcObject?n.srcObject=t:n.src=window.URL.createObjectURL(t),r&&r.muted&&(n.muted=!0),r&&r.mirror&&(n.style.webkitTransform="scaleX(-1)",n.style.transform="scaleX(-1)"),n.onloadedmetadata=function(e){n.play()}}detachMediaStream(e,t){const r=document.getElementById(e);if(!r)throw new Error("Unable to attach media stream, element "+e+" is undefined");r.pause(),"object"==typeof r.srcObject?r.srcObject=null:r.src="",t&&!t.mirror&&(r.style.webkitTransform="",r.style.transform="")}switchMediaTracks(e){return i.DLog("switchMediaTracks(deviceIds)",{deviceIds:e}),e&&e.audio&&("boolean"==typeof this.mediaParams.audio&&(this.mediaParams.audio={}),this.mediaParams.audio.deviceId=e.audio),e&&e.video&&("boolean"==typeof this.mediaParams.video&&(this.mediaParams.video={}),this.mediaParams.video.deviceId=e.video),this.localStream.getTracks().forEach((e=>{e.stop()})),u.getUserMedia({audio:this.mediaParams.audio||!1,video:this.mediaParams.video||!1}).then((e=>this._replaceTracks(e))).catch((e=>{throw new Error(e)}))}call(e){const t=d(e);o.trace("Call, extension: "+JSON.stringify(t)),this.state=c.ACTIVE,this.maxBandwidth=+t.userInfo.maxBandwidth||0,this.opponentsIDs.forEach(((e,r,n)=>{this._callInternal(e,t,!0)}))}_callInternal(e,t,r){const n=this._createPeer(e,"offer");this.localStream.getTracks().forEach((e=>{n.addTrack(e,this.localStream)})),this.peerConnections[e]=n,n.getAndSetLocalSessionDescription(this.maxBandwidth).then((()=>{o.trace("getAndSetLocalSessionDescription success"),n._startDialingTimer(t,r)})).catch((e=>{o.trace("getAndSetLocalSessionDescription error: "+e)}))}accept(e){const t=d(e);if(o.trace("Accept, extension: "+JSON.stringify(t.userInfo)),this.state===c.ACTIVE)return void o.traceError("Can't accept, the session is already active, return.");if(this.state===c.CLOSED)return o.traceError("Can't accept, the session is already closed, return."),void this.stop({});this.state=c.ACTIVE,this.acceptCallTime=new Date,this._clearAnswerTimer(),this._acceptInternal(this.initiatorID,t);const r=this._uniqueOpponentsIDsWithoutInitiator();if(r.length>0){const e=(this.acceptCallTime-this.startCallTime)/1e3;this._startWaitingOfferOrAnswerTimer(e),r.forEach((e=>{this.currentUserID>e&&this._callInternal(e,{},!0)}))}}_acceptInternal(e,t){const r=this.peerConnections[e];r?(this.localStream.getTracks().forEach((e=>{r.addTrack(e,this.localStream)})),r.setRemoteSessionDescription("offer",r.getRemoteSDP()).then((()=>{o.trace("'setRemoteSessionDescription' success"),r.getAndSetLocalSessionDescription(this.maxBandwidth).then((()=>{o.trace("'getAndSetLocalSessionDescription' success"),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,t.sdp=r.localDescription.sdp,this.signalingProvider.sendMessage(e,t,a.SignalingType.ACCEPT)})).catch((e=>{o.trace("'getAndSetLocalSessionDescription' error: "+e)}))})).catch((e=>{o.traceError("'setRemoteSessionDescription' error: "+e)}))):o.traceError("Can't accept the call, there is no information about peer connection by some reason.")}reject(e){const t=d(e);o.trace("Reject, extension: "+JSON.stringify(t.userInfo)),this.state=c.REJECTED,this._clearAnswerTimer(),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,Object.keys(this.peerConnections).forEach((e=>{const r=this.peerConnections[e];this.signalingProvider.sendMessage(r.userID,t,a.SignalingType.REJECT)})),this._close()}stop(e){const t=d(e);o.trace("Stop, extension: "+JSON.stringify(t.userInfo)),this.state=c.HUNGUP,this.answerTimer&&this._clearAnswerTimer(),t.sessionID=this.ID,t.callType=this.callType,t.callerID=this.initiatorID,t.opponentsIDs=this.opponentsIDs,Object.keys(this.peerConnections).forEach((e=>{const r=this.peerConnections[e];this.signalingProvider.sendMessage(r.userID,t,a.SignalingType.STOP)})),this._close()}canInitiateIceRestart(e){return"offer"===this.peerConnections[e].type}iceRestart(e){this.peerConnections[e].getAndSetLocalSessionDescription(this.maxBandwidth,{iceRestart:!0}).then((t=>{o.trace("[iceRestart][getAndSetLocalSessionDescription] Ok");const r={sessionID:this.ID,sdp:t.sdp};this.signalingProvider.sendMessage(e,r,a.SignalingType.RESTART)})).catch((e=>{o.trace("[iceRestart][getAndSetLocalSessionDescription] Error: "+e)}))}mute(e){this._muteStream(0,e)}unmute(e){this._muteStream(1,e)}_processOnCall(e,t){this._uniqueOpponentsIDs().forEach((r=>{const n=this.peerConnections[r];if(n)r==e&&(n.updateRemoteSDP(t.sdp),e!=this.initiatorID&&this.state===c.ACTIVE&&this._acceptInternal(e,{}));else{let n;n=r!=e&&this.currentUserID>r?this._createPeer(r,"offer"):this._createPeer(r,"answer"),this.peerConnections[r]=n,r==e&&(n.updateRemoteSDP(t.sdp),this._startAnswerTimer())}}))}_processOnAccept(e,t){const r=this.peerConnections[e];r?(r._clearDialingTimer(),r.setRemoteSessionDescription("answer",t.sdp).then((()=>{o.trace("'setRemoteSessionDescription' success")})).catch((e=>{o.traceError("'setRemoteSessionDescription' error: "+e)}))):o.traceWarning("Ignore 'OnAccept', there is no information about peer connection by some reason.")}_processOnReject(e,t){const r=this.peerConnections[e];this._clearWaitingOfferOrAnswerTimer(),r?r.release():o.traceWarning("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()}_processOnStop(e,t){if(this._clearAnswerTimer(),e===this.initiatorID){const e=Object.keys(this.peerConnections);e.length>0?e.forEach((e=>{this.peerConnections[e].release()})):o.traceWarning("Ignore 'OnStop', there is no information about peer connections by some reason.")}else{const t=this.peerConnections[e];t?t.release():o.traceWarning("Ignore 'OnStop', there is no information about peer connection by some reason.")}this._closeSessionIfAllConnectionsClosed()}_processOnIceCandidates(e,t){const r=this.peerConnections[e];r?r.addCandidates(t.iceCandidates):o.traceWarning("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")}_processOnIceRestart(e,t){const r=this.peerConnections[e];r?r.setRemoteSessionDescription("offer",t.sdp).then((()=>{o.trace("[_processOnIceRestart]'setRemoteSessionDescription' success"),r.getAndSetLocalSessionDescription(this.maxBandwidth).then((t=>{o.trace("[_processOnIceRestart]'getAndSetLocalSessionDescription' success");const r={sessionID:this.ID,sdp:t.sdp};this.signalingProvider.sendMessage(e,r,a.SignalingType.RESTART_ACCEPT)})).catch((e=>{o.trace("[_processOnIceRestart] 'getAndSetLocalSessionDescription' error: "+e)}))})).catch((e=>{o.traceError("[_processOnIceRestart] 'setRemoteSessionDescription' error: "+e)})):o.traceWarning("[_processOnIceRestart] Ignore 'OnIceRestart', there is no information about peer connection by some reason.")}_processOnIceRestartAccept(e,t){const r=this.peerConnections[e];r?r.setRemoteSessionDescription("answer",t.sdp).then((()=>{o.trace("[_processOnIceRestartAccept] 'setRemoteSessionDescription' success")})).catch((e=>{o.traceError("[_processOnIceRestartAccept] 'setRemoteSessionDescription' error: "+e)})):o.traceWarning("[_processOnIceRestartAccept] Ignore 'OnIceRestartAccept', there is no information about peer connection by some reason.")}_processCall(e,t){const r=t||{};r.sessionID=this.ID,r.callType=this.callType,r.callerID=this.initiatorID,r.opponentsIDs=this.opponentsIDs,r.sdp=e.localDescription.sdp,r.userInfo=t.userInfo||{},this.signalingProvider.sendMessage(e.userID,r,a.SignalingType.CALL)}_processIceCandidates(e,t){const r={};r.sessionID=this.ID,r.callType=this.callType,r.callerID=this.initiatorID,r.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(e.userID,t,r)}_processOnNotAnswer(e){o.trace("Answer timeout callback for session "+this.ID+" for user "+e.userID),this._clearWaitingOfferOrAnswerTimer(),e.release(),i.safeCallbackCall(this.onUserNotAnswerListener,this,e.userID),this._closeSessionIfAllConnectionsClosed()}_onRemoteStreamListener(e,t){i.safeCallbackCall(this.onRemoteStreamListener,this,e,t)}_onCallStatsReport(e,t,r){i.safeCallbackCall(this.onCallStatsReport,this,e,t,r)}_onSessionConnectionStateChangedListener(e,t){i.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e,t)}_createPeer(e,t){this.startCallTime=new Date;const r={iceServers:h(n.videochat.iceServers)};n.videochat.alwaysRelayCalls&&(r.iceTransportPolicy="relay"),o.trace("_createPeer, iceServers: "+JSON.stringify(r));const i=new s(r);return i._init(this,e,this.ID,t),i}_close(){Object.keys(this.peerConnections).forEach((e=>{const t=this.peerConnections[e];try{t.release()}catch(e){i.DLog("Peer close error:",e)}})),this._closeLocalMediaStream(),this.state=c.CLOSED,i.safeCallbackCall(this.onSessionCloseListener,this)}_closeSessionIfAllConnectionsClosed(){let e=!0;Object.keys(this.peerConnections).forEach((t=>{const r=this.peerConnections[t];let n;try{n="closed"===r.iceConnectionState||"closed"===r.signalingState||r.released?"closed":null}catch(e){o.traceError(e),n="closed"}"closed"!==n&&(e=!1)})),o.trace("All peer connections closed: "+e),e&&(this._closeLocalMediaStream(),i.safeCallbackCall(this.onSessionCloseListener,this),this.state=c.CLOSED)}_closeLocalMediaStream(){this.localStream&&(this.localStream.getAudioTracks().forEach((e=>{e.stop()})),this.localStream.getVideoTracks().forEach((e=>{e.stop()})),this.localStream=null)}_muteStream(e,t){"audio"===t&&this.localStream.getAudioTracks().length>0?this.localStream.getAudioTracks().forEach((t=>{t.enabled=!!e})):"video"===t&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach((t=>{t.enabled=!!e}))}_clearAnswerTimer(){this.answerTimer&&(o.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)}_startAnswerTimer(){o.trace("_startAnswerTimer");const e=1e3*n.videochat.answerTimeInterval;this.answerTimer=setTimeout((()=>{o.trace("_answerTimeoutCallback"),"function"==typeof this.onSessionCloseListener&&this._close(),this.answerTimer=null}),e)}_clearWaitingOfferOrAnswerTimer(){this.waitingOfferOrAnswerTimer&&(o.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)}_startWaitingOfferOrAnswerTimer(e){const t=n.videochat.answerTimeInterval-e<0?1:n.videochat.answerTimeInterval-e;o.trace("_startWaitingOfferOrAnswerTimer, timeout: "+t),this.waitingOfferOrAnswerTimer=setTimeout((()=>{o.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(this.peerConnections).forEach((e=>{const t=this.peerConnections[e];t.state!==l.CONNECTING&&t.state!==l.NEW||this._processOnNotAnswer(t)})),this.waitingOfferOrAnswerTimer=null}),1e3*t)}_uniqueOpponentsIDs(){const e=[];return this.initiatorID!==this.currentUserID&&e.push(this.initiatorID),this.opponentsIDs.forEach((t=>{t!=this.currentUserID&&e.push(parseInt(t))})),e}_uniqueOpponentsIDsWithoutInitiator(){const e=[];return this.opponentsIDs.forEach((t=>{t!=this.currentUserID&&e.push(parseInt(t))})),e}toString(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType}}},5395:(e,t,r)=>{const n=r(8666).SignalingConstants,s=r(3173);e.exports=class{constructor(e){this.delegate=e}_onMessage(e,t){const r=this._getExtension(t),s=r.sessionID,i=r.signalType;switch(delete r.moduleIdentifier,delete r.sessionID,delete r.signalType,i){case n.SignalingType.CALL:this.delegate._onCallListener(e,s,r);break;case n.SignalingType.ACCEPT:this.delegate._onAcceptListener(e,s,r);break;case n.SignalingType.REJECT:this.delegate._onRejectListener(e,s,r);break;case n.SignalingType.STOP:this.delegate._onStopListener(e,s,r);break;case n.SignalingType.CANDIDATE:this.delegate._onIceCandidatesListener(e,s,r);break;case n.SignalingType.RESTART:this.delegate._onIceRestartListener(e,s,r);break;case n.SignalingType.RESTART_ACCEPT:this.delegate._onIceRestartAcceptListener(e,s,r)}}_getExtension(e){if(!e)return null;let t,r,n,i={},o=[],a=[],c=e.childNodes||e.children;for(let e=0,l=c.length;e1)if((c[e].textContent||c[e].children[0]).length>4096){let e="";for(let t=0;t0&&(i.iceCandidates=o),a.length>0&&(i.opponentsIDs=a),i}}},2382:(e,t,r)=>{const n=r(1366),s=r(8666).SignalingConstants,i=r(9028),o=r(330),a=r(3173);e.exports=class{constructor(e){this.signalingConnection=e}sendCandidate(e,t,r){const n=r||{};n.iceCandidates=t,this.sendMessage(e,n,s.SignalingType.CANDIDATE)}sendMessage(e,t,r){const c=t||{};c.moduleIdentifier=s.MODULE_ID,c.signalType=r,c.platform="web",c.userInfo&&(Object.keys(c.userInfo).length?0===c.userInfo.maxBandwidth&&delete c.userInfo.maxBandwidth:delete c.userInfo);const l={to:n.getUserJid(e,o.creds.appId),type:"headline",id:i.getBsonObjectId()};let u=a.createMessageStanza(l).c("extraParams",{xmlns:"jabber:client"});Object.keys(c).forEach((e=>{"iceCandidates"===e?(u=u.c("iceCandidates"),c[e].forEach((e=>{u=u.c("iceCandidate"),Object.keys(e).forEach((t=>{u=u.c(t).t(e[t]).up()})),u=u.up()})),u=u.up()):"opponentsIDs"===e?(u=u.c("opponentsIDs"),c[e].forEach((e=>{u=u.c("opponentID").t(e).up()})),u=u.up()):"object"==typeof c[e]?a._JStoXML(e,c[e],u):u=u.c(e).t(c[e]).up()})),u=u.up(),this.signalingConnection.send(u)}}},936:(e,t,r)=>{const{EventEmitter:n}=r(2881),{MediaStream:s}=r(8009),i=r(9171),o=r(9028),a=r(330),{JANUS_EVENTS:c,JANUS_MEDIA_TRACKS_REASONS:l}=r(9454);e.exports={Client:class{constructor(e){if(!o.getEnv().reactnative&&!adapter)throw"Error: in order to use this library please connect adapter.js. More info https://github.com/webrtc/adapter";if(this.token=e.token,delete e.token,this.configs=e,!this.configs.server)throw"'server' parameter is mandatory.";this.configs.server.includes("http")&&(this.configs.server=this.configs.server+"/janus"),this.configs.debug||(this.configs.debug="all"),this.engine=null,this.videoRoomPlugin=null,this.isOnlyAudio=!1,this.currentRoomId=null,this.remoteFeeds={},this.remoteJseps={},this.remoteFeedsAttachingInProgress={},this.bitrateTimers={},this.emitter=new n}createSession(e){i.init({debug:this.configs.debug,callback:()=>{i.isWebrtcSupported()?this.engine=new i({server:this.configs.server,iceServers:a.videochat.iceServers,token:this.token,success:()=>{o.safeCallbackCall(e.success)},error:t=>{o.safeCallbackCall(e.error,t)},destroyed:()=>{o.safeCallbackCall(e.destroyed)},timeoutSessionCallback:()=>{o.safeCallbackCall(e.timeoutSessionCallback)}}):o.safeCallbackCall(e.error,"Your browser does not support WebRTC, so you can't use this functionality.")}})}getSessionId(){return this.engine?this.engine.getSessionId():null}destroySession(e){this.engine.destroy({}),o.safeCallbackCall(e.success)}attachVideoConferencingPlugin(e,t,r,n){let s=null;const i=n.localStream;delete n.localStream;const a=n.displayName;delete n.displayName,this.engine.attach({plugin:"janus.plugin.videoroom",success:r=>{if(e){s=r,s.userId=t,this.remoteFeedsAttachingInProgress[t]=s;const e={request:"join",room:this.currentRoomId,ptype:"listener",feed:t,display:a};s.send({message:e})}else this.videoRoomPlugin=r;o.safeCallbackCall(n.success)},error:e=>{o.safeCallbackCall(n.error,e)},consentDialog:e=>{o.safeCallbackCall(n.consentDialog,e)},mediaState:(e,t)=>{o.safeCallbackCall(n.mediaState,e,t)},webrtcState:e=>{o.safeCallbackCall(n.webrtcState,e)},slowLink:(e,t)=>{o.safeCallbackCall(n.slowLink,e,t)},iceState:e=>{o.safeCallbackCall(n.iceState,e)},onmessage:(t,s)=>{const a=t.videoroom;if(e){if(a)if("attached"===a){const e=t.id;this.remoteFeeds[e]=this.remoteFeedsAttachingInProgress[e],this.remoteFeedsAttachingInProgress[e]=null}else t.error&&o.safeCallbackCall(n.error,t.error);if(s){const e=t.id;this.remoteJseps[e]=s,this.createAnswer({remoteFeed:this.remoteFeeds[e],jsep:s},i,{success:()=>{},error:e=>{o.safeCallbackCall(n.error,e)}})}}else{if(a)if("joined"===a){const e={media:r?{audio:!1,video:!1}:{audio:!0,video:!0},stream:r?null:i};this.createOffer(e,{success:()=>{if(t.publishers){const e=t.publishers;for(const t in e){const r=e[t].id,n=e[t].display;this.emitter.emit(c.PARTICIPANT_JOINED,r,n,!0)}}},error:e=>{o.safeCallbackCall(n.error,e)}})}else if("event"===a)if(t.publishers){const e=t.publishers;for(const t in e){const r=e[t].id,n=e[t].display;this.emitter.emit(c.PARTICIPANT_JOINED,r,n,!1)}}else if(t.leaving){const e=t.leaving;this.detachRemoteFeed(e)&&this.emitter.emit(c.PARTICIPANT_LEFT,e,null)}else if(t.unpublished){const e=t.unpublished;"ok"!=e&&this.detachRemoteFeed(e)&&this.emitter.emit(c.PARTICIPANT_LEFT,e,null)}else t.error&&(o.DLog("[janus error message]",t.error),this.emitter.emit(c.ERROR,t),o.safeCallbackCall(n.error,t.error));s&&this.videoRoomPlugin.handleRemoteJsep({jsep:s})}},onlocaltrack:(e,t)=>{o.DLog("[onlocaltrack]",e,t),this.onLocalTrack(e,t)},onremotetrack:(e,t,r,n)=>{o.DLog("[onremotetrack]",e,t,r,n),this.onRemoteTrack(s,e,t,r,n)},ondataopen:e=>{o.DLog("[ondataopen]",e),this.emitter.emit(c.DATA_CHANNEL_OPEN,e)},ondata:(e,t)=>{o.DLog("[ondata]",t,e),this.emitter.emit(c.DATA_CHANNEL_MESSAGE,t,e)},oncleanup:()=>{o.safeCallbackCall(n.oncleanup)},detached:()=>{}})}onLocalTrack(e,t){}onRemoteTrack(e,t,r,n,i){const o=i&&i.reason;if(o===l.CREATED){const n=!e.stream||!e.tracks;n?(e.tracks={[r]:t},e.stream=new s([t])):(e.tracks[r]=t,e.stream.addTrack(t)),n&&this.emitter.emit(c.REMOTE_STREAM,e.userId,e.stream)}else if(o===l.ENDED){delete e.tracks[r];const n=e.stream.getTracks().find((e=>e.kind===t.kind));e.stream.removeTrack(n)}this.emitter.emit(c.REMOTE_TRACKS_UPDATED,e.userId,t,o)}getPluginId(){return this.videoRoomPlugin?this.videoRoomPlugin.getId():null}detachVideoConferencingPlugin(e){const t=()=>{this.videoRoomPlugin=null,Object.keys(this.remoteFeeds).forEach((e=>{this.detachRemoteFeed(e)})),this.remoteFeeds={},this.remoteJseps={}};this.videoRoomPlugin.detach({success:()=>{t(),o.safeCallbackCall(e.success)},error:r=>{t(),o.safeCallbackCall(e.error,r)}})}join(e,t,r,n){const s=n.displayName;delete n.displayName,this.isOnlyAudio=!!r,o.DLog("isOnlyAudio: "+this.isOnlyAudio);const i={request:"join",room:e,ptype:"publisher",id:t,display:s};this.videoRoomPlugin.send({message:i,success:r=>{this.currentRoomId=e,this.currentUserId=t,o.safeCallbackCall(n.success)},error:e=>{o.safeCallbackCall(n.error,e)}})}leave(e){if(o.DLog("leave"),!this.engine.isConnected())return void o.safeCallbackCall(e.success);const t={request:"leave",room:this.currentRoomId,id:this.currentUserId};this.videoRoomPlugin&&this.videoRoomPlugin.send({message:t}),this.currentRoomId=null,this.currentUserId=null,o.safeCallbackCall(e.success)}listOnlineParticipants(e,t){const r={request:"listparticipants",room:e};this.videoRoomPlugin.send({message:r,success:e=>{const r=[];e&&(r=e.participants),o.safeCallbackCall(t.success,r)},error:e=>{o.safeCallbackCall(t.error,e)}})}toggleAudioMute(){return this.videoRoomPlugin.isAudioMuted()?this.videoRoomPlugin.unmuteAudio():this.videoRoomPlugin.muteAudio(),this.videoRoomPlugin.isAudioMuted()}isAudioMuted(){return this.videoRoomPlugin.isAudioMuted()}toggleRemoteAudioMute(e){const t=this.remoteFeeds[e];if(!t)return!1;const r=t.stream.getAudioTracks();if(r&&r.length>0){for(let e=0;e0)&&!r[0].enabled}toggleVideoMute(){return this.videoRoomPlugin.isVideoMuted()?this.videoRoomPlugin.unmuteVideo():this.videoRoomPlugin.muteVideo(),this.videoRoomPlugin.isVideoMuted()}isVideoMuted(){return this.videoRoomPlugin.isVideoMuted()}toggleRemoteVideoMute(e){const t=this.remoteFeeds[e];if(!t)return!1;const r=t.stream.getVideoTracks();if(r&&r.length>0){for(let e=0;e0)&&!r[0].enabled}switchVideoinput(e,t){console.warn('[ConnectyCube.videochatconference] The method "switchVideoinput(mediaDeviceId, callbacks)" was deprecated. Use "videoConferenceSession.switchMediaTracks(mediaDeviceId): Promise" instead.')}switchAudioinput(e,t){console.warn('[ConnectyCube.videochatconference] The method "switchAudioinput(mediaDeviceId, callbacks)" was deprecated. Use "videoConferenceSession.switchMediaTracks(mediaDeviceId): Promise" instead.')}sendKeyframeRequest(e,t){const r={request:"configure",room:e,keyframe:!0};this.videoRoomPlugin.send({message:r,success:e=>{o.safeCallbackCall(t.success)},error:e=>{o.safeCallbackCall(t.error,e)}})}getTracksFromStream(e){const t=[],r=e.getAudioTracks();if(r.length){const e=r[0];t.push({type:"audio",capture:e,recv:!1})}const n=e.getVideoTracks();if(n.length){const e=n[0];t.push({type:"video",capture:e,recv:!1})}return t}createOffer(e,t){o.DLog("[JanusWrapper][createOffer]",e);const{stream:r,media:n,replace:s}=e,i={tracks:[{type:"data"}]};if(r){const e=this.getTracksFromStream(r);i.tracks=i.tracks.concat(e)}else if(n){const e=[];n.audio&&e.push({type:"audio",capture:n.audio,recv:!1,replace:!!s}),n.video&&e.push({type:"video",capture:n.video,recv:!1,replace:!!s}),i.tracks=i.tracks.concat(e)}else i.tracks=i.tracks.concat([{type:"audio",capture:!0,recv:!1,replace:!!s},{type:"video",capture:!0,recv:!1,replace:!!s}]);o.DLog("[JanusWrapper][createOffer][params]",i),i.customizeSdp=e=>{},i.success=e=>{const r={request:"configure",audio:!!n.audio,video:!!n.video};o.DLog("[JanusWrapper][createOffer][success]",r),this.videoRoomPlugin.send({message:r,jsep:e}),o.safeCallbackCall(t.success)},i.error=e=>{o.DLog("[JanusWrapper][createOffer][error]",e),n.audio?this.createOffer({media:{video:!1,audio:!1}},t):o.safeCallbackCall(t.error,e)},this.videoRoomPlugin.createOffer(i)}getTracksMidsFromStream(e){const t=[],r=e.getAudioTracks();if(r.length){const e=r[0];t.push({type:"audio",mid:e.id,recv:!0})}const n=e.getVideoTracks();if(n.length){const e=n[0];t.push({type:"video",mid:e.id,recv:!0})}return t}createAnswer({remoteFeed:e,jsep:t},r,n){o.DLog("[JanusWrapper][createAnswer]",t,r);let s=[{type:"data"}];if(r){const e=this.getTracksMidsFromStream(r);s=s.concat(e)}o.DLog("[JanusWrapper][createAnswer][tracks]",s),e.createAnswer({jsep:t,tracks:s,success:t=>{const r={request:"start",room:this.currentRoomId};o.DLog("[JanusWrapper][createAnswer][success]",r),e.send({message:r,jsep:t}),o.safeCallbackCall(n.success)},error:e=>{o.DLog("[JanusWrapper][createAnswer][error]",e),o.safeCallbackCall(n.error,e)}})}detachRemoteFeed(e){const t=this.remoteFeeds[e];return!!t&&(t.detach(),this.remoteFeeds[e]=null,this.remoteJseps[e]=null,!0)}getUserBitrate(e){return this.remoteFeeds[e].getBitrate()}getVolume(e){return this.videoRoomPlugin.getLocalVolume(null,e)}getUserVolume(e,t){return this.remoteFeeds[e].getRemoteVolume(null,t)}showBitrate(e,t){const r=this.remoteFeeds[e];o.getEnv().reactnative||"chrome"!==adapter.browserDetails.browser&&"firefox"!==adapter.browserDetails.browser||(this.bitrateTimers[e]=setInterval((()=>{const e=r.getBitrate();t.text(e)}),1e3))}hideBitrate(e,t){this.bitrateTimers[e]&&clearInterval(this.bitrateTimers[e]),this.bitrateTimers[e]=null,t.text=null}on(e,t){return this.emitter.addListener(e,t)}removeAllListeners(e){e?this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}}}},8852:(e,t,r)=>{const n=r(330),s=r(5992),{DEVICE_INPUT_TYPES:i,CALL_TYPES:o}=r(9454),{mediaDevices:a}=r(8009);e.exports=class{constructor(e){this.proxy=e,this.DEVICE_INPUT_TYPES=i,this.CALL_TYPES=o,this.sessionsStore={},this.onParticipantJoinedListener,this.onParticipantLeftListener,this.onSlowLinkListener,this.onRemoteStreamListener,this.onRemoteTracksUpdatedListener,this.onRemoteConnectionStateChangedListener,this.onDataChannelOpenedListener,this.onDataChannelMessageListener,this.onSessionConnectionStateChangedListener,this.onErrorListener}createNewSession(){const e=new s(Object.assign(n.conference,{token:this.getCurrentSessionToken()}));return e.onParticipantJoinedListener=this.onParticipantJoinedListener,e.onParticipantLeftListener=this.onParticipantLeftListener,e.onSlowLinkListener=this.onSlowLinkListener,e.onRemoteStreamListener=this.onRemoteStreamListener,e.onRemoteTracksUpdatedListener=this.onRemoteTracksUpdatedListener,e.onRemoteConnectionStateChangedListener=this.onRemoteConnectionStateChangedListener,e.onDataChannelOpenedListener=this.onDataChannelOpenedListener,e.onDataChannelMessageListener=this.onDataChannelMessageListener,e.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,e.onErrorListener=this.onErrorListener,this.sessionsStore[e.id]=e,e}async getMediaDevices(e){const t=await this._listDevices();return e===i.VIDEO?t.filter((({kind:e})=>e===i.VIDEO)):e===i.AUDIO?t.filter((({kind:e})=>e===i.AUDIO)):t}_listDevices(){return a.enumerateDevices()}clearSession(e){delete this.sessionsStore[e]}getCurrentSessionToken(){if(!this.proxy.getSession())throw new Error("Session does not exist");return this.proxy.getSession().token}}},9454:e=>{e.exports={CALL_TYPES:{VIDEO:"video",AUDIO:"audio"},DEVICE_INPUT_TYPES:{VIDEO:"videoinput",AUDIO:"audioinput"},JANUS_EVENTS:{PARTICIPANT_JOINED:"participant_joined",PARTICIPANT_LEFT:"participant_left",LOCAL_STREAM:"local_stream",REMOTE_STREAM:"remote_stream",REMOTE_TRACKS_UPDATED:"remote_tracks_updated",DATA_CHANNEL_OPEN:"data_channel_open",DATA_CHANNEL_MESSAGE:"data_channel_message",ERROR:"error"},JANUS_MEDIA_TRACKS_REASONS:{CREATED:"created",ENDED:"ended",MUTE:"mute",UNMUTE:"unmute"}}},5992:(e,t,r)=>{const n=r(9028),{mediaDevices:s}=r(8009),{Client:i}=r(936),{CALL_TYPES:o,JANUS_EVENTS:a}=r(9454);e.exports=class{constructor(e){this.id=`${Math.random()}`,this._clientConf=new i(e),this._setOnParticipantJoinListener(),this._setOnParticipantLeftListener(),this._setOnRemoteStreamListener(),this._setOnRemoteTracksUpdatedListener(),this._setOnDataChannelOpenListener(),this._setOnDataChannelMessageListener(),this._setOnErrorListener(),this.currentUserDisplayName,this.localStream,this.onParticipantJoinedListener,this.onParticipantLeftListener,this.onSlowLinkListener,this.onRemoteStreamListener,this.onRemoteTracksUpdatedListener,this.onRemoteConnectionStateChangedListener,this.onDataChannelOpenedListener,this.onDataChannelMessageListener,this.onSessionConnectionStateChangedListener,this.onErrorListener}get currentRoomId(){return this._clientConf.currentRoomId}set currentRoomId(e){return this._clientConf.currentRoomId=e}get currentPublisherPC(){return this._clientConf.videoRoomPlugin.webrtcStuff.pc}_createSession(){let e=!1;return new Promise(((t,r)=>{this._clientConf.createSession({success:()=>{e=!0,t()},error:t=>{e?this._onError(t):r(t)}})}))}async join(e,t,r){this.currentUserDisplayName=r,await this._createSession(),this.currentRoomId=e,await this._createHandler(!1,t),await this._join(this.currentRoomId,t)}async joinAsListener(e,t,r){this.currentUserDisplayName=r,await this._createSession(),this.currentRoomId=e,await this._createHandler(!1,t,!0),await this._join(this.currentRoomId,t)}sendKeyframeRequest(e){return new Promise(((t,r)=>{this._clientConf.sendKeyframeRequest(e,{success:t,error:r})}))}async _createListener(e){await this._createHandler(!0,e)}_createHandler(e,t,r=!1){return new Promise(((n,s)=>{this._clientConf.attachVideoConferencingPlugin(e,t,r,{success:n,error:s,iceState:e?this._onRemoteIceStateChanged.bind(this,t):this._onLocalIceStateChanged.bind(this),slowLink:e?this._onSlowLink.bind(this,t):this._onSlowLink.bind(this,void 0),localStream:this.localStream,displayName:this.currentUserDisplayName})}))}_join(e,t){return new Promise(((r,n)=>{this._clientConf.join(e,t,!1,{success:r,error:n,displayName:this.currentUserDisplayName})}))}_setOnParticipantJoinListener(){this._clientConf.on(a.PARTICIPANT_JOINED,this._onParticipantJoined.bind(this))}_setOnParticipantLeftListener(){this._clientConf.on(a.PARTICIPANT_LEFT,this._onParticipantLeft.bind(this))}_setOnRemoteStreamListener(){this._clientConf.on(a.REMOTE_STREAM,this._onRemoteStream.bind(this))}_setOnRemoteTracksUpdatedListener(){this._clientConf.on(a.REMOTE_TRACKS_UPDATED,this._onRemoteTracksUpdated.bind(this))}_setOnDataChannelOpenListener(){this._clientConf.on(a.DATA_CHANNEL_OPEN,this._onDataChannelOpen.bind(this))}_setOnDataChannelMessageListener(){this._clientConf.on(a.DATA_CHANNEL_MESSAGE,this._onDataChannelMessage.bind(this))}_setOnErrorListener(){this._clientConf.on(a.ERROR,this._onError.bind(this))}_onParticipantJoined(e,t,r){n.DLog("[_onParticipantJoined]",e,t,r),this._createListener(e),n.safeCallbackCall(this.onParticipantJoinedListener,this,e,t,r)}_onParticipantLeft(e,t){n.DLog("[_onParticipantLeft]",e,t),n.safeCallbackCall(this.onParticipantLeftListener,this,e,t)}_onError(e){n.DLog("[_onError]",e),n.safeCallbackCall(this.onErrorListener,this,e)}_onDataChannelOpen(e){n.DLog("[_onDataChannelOpen]",e),n.safeCallbackCall(this.onDataChannelOpenedListener,this,e)}_onDataChannelMessage(e,t){n.DLog("[_onDataChannelMessage]",e,t),n.safeCallbackCall(this.onDataChannelMessageListener,this,e,t)}_onLocalIceStateChanged(e){n.DLog("[_onLocalIceStateChanged]",e),n.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e)}_onRemoteIceStateChanged(e,t){n.DLog("[_onRemoteIceStateChanged]",e,t),n.safeCallbackCall(this.onRemoteConnectionStateChangedListener,this,e,t)}_onRemoteStream(e,t){n.DLog("[_onRemoteStream]",e,t),n.safeCallbackCall(this.onRemoteStreamListener,this,e,t)}_onRemoteTracksUpdated(e,t,r){n.DLog("[_onRemoteTracksUpdated]",e,t,r),n.safeCallbackCall(this.onRemoteTracksUpdatedListener,this,e,t,r)}_onSlowLink(e,t,r){n.DLog("[_onSlowLink]",e,t,r),n.safeCallbackCall(this.onSlowLinkListener,this,e,t,r)}listOfOnlineParticipants(){return new Promise(((e,t)=>{this._clientConf.listOnlineParticipants(this.currentRoomId,{success:e,error:t})}))}async leave(){await this._leaveGroup(),this.currentRoomId=void 0,this.currentUserDisplayName=void 0,await this._detachVideoConferencingPlugin(),await this._destroy(),this.localStream&&(this.localStream.getTracks().forEach((e=>e.stop())),this.localStream=void 0)}_leaveGroup(){return new Promise(((e,t)=>{this._clientConf.leave({success:e,error:t})}))}_destroy(){return new Promise(((e,t)=>{this._clientConf.destroySession({success:e,error:t})}))}_detachVideoConferencingPlugin(){return new Promise(((e,t)=>{this._clientConf.detachVideoConferencingPlugin({success:e,error:t})}))}getDisplayMedia(e){if(!s.getDisplayMedia)throw new Error("Your environment does not support 'getDisplayMedia' API");const t=e&&e.elementId,r=e&&e.options,n={...e};return delete n.elementId,delete n.options,s.getDisplayMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}getUserMedia(e){const t=e&&e.elementId,r=e&&e.options,n={...e};return delete n.elementId,delete n.options,s.getUserMedia(n).then((e=>this._upsertStream(e,t,r))).catch((e=>{throw new Error(e)}))}_upsertStream(e,t,r){const n=!!this.localStream;return n?(this.localStream.getTracks().forEach((t=>{t.kind===o.AUDIO&&0===e.getAudioTracks().length||(t.stop(),this.localStream.removeTrack(t))})),this._replaceTracks(e)):this.localStream=e,t&&(n&&this.detachMediaStream(t,r),this.attachMediaStream(t,this.localStream,r)),this.localStream}_replaceTracks(e){e.getTracks().forEach((e=>{const t=this.currentPublisherPC.getSenders().find((t=>e.kind===t.track.kind));e.kind===o.AUDIO?e.enabled=this.localStream.getAudioTracks().every((e=>e.enabled)):e.enabled=this.localStream.getVideoTracks().every((e=>e.enabled)),t?(t.replaceTrack(e),this.localStream.addTrack(e)):console.warn(`No sender found for track kind: ${e.kind}`)}))}switchMediaTracks(e){return e[o.VIDEO]?this._switchVideo(e[o.VIDEO]):e[o.AUDIO]?this._switchAudio(e[o.AUDIO]):Promise.reject()}_switchVideo(e){return this._switchMediaTracks({audio:!0,video:{deviceId:e}})}_switchAudio(e){return this._switchMediaTracks({audio:{deviceId:e},video:!0})}_switchMediaTracks(e){return this.getUserMedia(e,!0).then((e=>{const t=e.getTracks(),r=this.currentPublisherPC.getSenders();return t.forEach((e=>{r.find((t=>e.kind===t.track.kind)).replaceTrack(e)})),this.localStream}))}muteVideo(){this.isVideoMuted()||this._clientConf.toggleVideoMute()}unmuteVideo(){this.isVideoMuted()&&this._clientConf.toggleVideoMute()}muteAudio(){this.isAudioMuted()||this._clientConf.toggleAudioMute()}unmuteAudio(){this.isAudioMuted()&&this._clientConf.toggleAudioMute()}isVideoMuted(){return this._clientConf.isVideoMuted()}isAudioMuted(){return this._clientConf.isAudioMuted()}getUserVolume(){return new Promise(((e,t)=>this._clientConf.getVolume(e)))}getRemoteUserBitrate(e){return this._clientConf.getUserBitrate(e)}getRemoteUserVolume(e){return new Promise(((t,r)=>this._clientConf.getUserVolume(e,t)))}attachMediaStream(e,t,r){const n=document.getElementById(e);if(!n)throw new Error("Unable to attach media stream, element "+e+" is undefined");"object"==typeof n.srcObject?n.srcObject=t:n.src=window.URL.createObjectURL(t),r&&r.muted&&(n.muted=!0),r&&r.mirror&&(n.style.webkitTransform="scaleX(-1)",n.style.transform="scaleX(-1)"),n.onloadedmetadata=function(e){n.play()}}detachMediaStream(e,t){const r=document.getElementById(e);if(!r)throw new Error("Unable to attach media stream, element "+e+" is undefined");r.pause(),"object"==typeof r.srcObject?r.srcObject=null:r.src="",t&&!t.mirror&&(r.style.webkitTransform="",r.style.transform="")}async sendData(e,t){const r={data:e,label:t};return new Promise(((e,t)=>{const n={success:e,error:t};Object.assign(n,r),this._clientConf.videoRoomPlugin.data(n)}))}}},9171:(e,t,r)=>{const{adapter:n,navigator:s,MediaStream:i,MediaStreamTrack:o,RTCPeerConnection:a,RTCRtpReceiver:c,RTCRtpSender:l}=r(8009),u=r(9028);h.sessions={},h.mobile=u.getEnv().reactnative,h.isExtensionEnabled=function(){if(h.mobile)return!1;if(s.mediaDevices&&s.mediaDevices.getDisplayMedia)return!0;if(window.navigator.userAgent.match("Chrome")){let e=parseInt(window.navigator.userAgent.match(/Chrome\/(.*) /)[1],10),t=33;return window.navigator.userAgent.match("Linux")&&(t=35),e>=26&&e<=t||h.extension.isInstalled()}return!0};var d={extensionId:"hapfgfdkleiggjjpfpenajgdnfckjpaj",isInstalled:function(){return!h.mobile&&null!==document.querySelector("#janus-extension-installed")},getScreen:function(e){if(h.mobile)e();else{let t=window.setTimeout((function(){let t=new Error("NavigatorUserMediaError");return t.name='The required Chrome extension is not installed: click here to install it. (NOTE: this will need you to refresh the page)',e(t)}),1e3);this.cache[t]=e,window.postMessage({type:"janusGetScreen",id:t},"*")}},init:function(){let e={};this.cache=e,h.mobile||window.addEventListener("message",(function(t){if(t.origin==window.location.origin)if("janusGotScreen"==t.data.type&&e[t.data.id]){let r=e[t.data.id];if(delete e[t.data.id],""===t.data.sourceId){let e=new Error("NavigatorUserMediaError");e.name="You cancelled the request for permission, giving up...",r(e)}else r(null,t.data.sourceId)}else"janusGetScreenPending"==t.data.type&&window.clearTimeout(t.data.id)}))}};function h(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.destroyed="function"==typeof e.destroyed?e.destroyed:h.noop,!h.initDone)return e.error("Library not initialized"),{};if(!h.isWebrtcSupported())return e.error("WebRTC not supported by this browser"),{};if(h.log("Library initialized: "+h.initDone),!e.server)return e.error("Invalid server url"),{};let t=!1,r=null,n={},u=null,d=null,p=0,f=e.server;h.isArray(f)?(h.log("Multiple servers provided ("+f.length+"), will use the first that works"),f=null,d=e.server,h.debug(d)):0===f.indexOf("ws")?(t=!0,h.log("Using WebSockets to contact Janus: "+f)):(t=!1,h.log("Using REST API to contact Janus: "+f));let m=e.iceServers||[{urls:"stun:stun.l.google.com:19302"}],g=e.iceTransportPolicy,y=e.bundlePolicy,v=!1;void 0!==e.withCredentials&&null!==e.withCredentials&&(v=!0===e.withCredentials);let b=10;void 0!==e.max_poll_events&&null!==e.max_poll_events&&(b=e.max_poll_events),b<1&&(b=1);let S=null;void 0!==e.token&&null!==e.token&&(S=e.token);let C=null;void 0!==e.apisecret&&null!==e.apisecret&&(C=e.apisecret),this.destroyOnUnload=!0,void 0!==e.destroyOnUnload&&null!==e.destroyOnUnload&&(this.destroyOnUnload=!0===e.destroyOnUnload);let w=25e3;void 0!==e.keepAlivePeriod&&null!==e.keepAlivePeriod&&(w=e.keepAlivePeriod),isNaN(w)&&(w=25e3);let k=6e4;function _(e){let t={high:9e5,medium:3e5,low:1e5};return null!=e&&(e.high&&(t.high=e.high),e.medium&&(t.medium=e.medium),e.low&&(t.low=e.low)),t}void 0!==e.longPollTimeout&&null!==e.longPollTimeout&&(k=e.longPollTimeout),isNaN(k)&&(k=6e4);let x=!1,I=null,E={},T=this,P=0,L={};function D(){if(null==I)return;if(h.debug("Long poll..."),!x)return void h.warn("Is the server down? (connected=false)");let t=f+"/"+I+"?rid="+(new Date).getTime();b&&(t=t+"&maxev="+b),S&&(t=t+"&token="+encodeURIComponent(S)),C&&(t=t+"&apisecret="+encodeURIComponent(C)),h.httpAPICall(t,{verb:"GET",withCredentials:v,success:A,timeout:k,error:function(t,r){if(h.error(t+":",r),P++,P>3)return x=!1,void e.error("Lost connection to the server (is it down?)");D()}})}function A(e,n){if(P=0,t||null==I||!0===n||D(),t||!h.isArray(e))if("keepalive"!==e.janus)if("server_info"!==e.janus)if("ack"!==e.janus)if("success"!==e.janus)if("trickle"===e.janus){const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");let n=e.candidate;h.debug("Got a trickled candidate on session "+I),h.debug(n);let s=r.webrtcStuff;s.pc&&s.remoteSdp?(h.debug("Adding remote candidate:",n),n&&!0!==n.completed?s.pc.addIceCandidate(n):s.pc.addIceCandidate(h.endOfCandidates)):(h.debug("We didn't do setRemoteDescription (trickle got here before the offer?), caching candidate"),s.candidates||(s.candidates=[]),s.candidates.push(n),h.debug(s.candidates))}else{if("webrtcup"===e.janus){h.debug("Got a webrtcup event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];return r?void r.webrtcState(!0):void h.debug("This handle is not attached to this session")}if("hangup"===e.janus){h.debug("Got a hangup event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.webrtcState(!1,e.reason),r.hangup()}else if("detached"===e.janus){h.debug("Got a detached event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return;r.ondetached(),r.detach()}else if("media"===e.janus){h.debug("Got a media event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.mediaState(e.type,e.receiving,e.mid)}else if("slowlink"===e.janus){h.debug("Got a slowlink event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");const r=E[t];if(!r)return void h.debug("This handle is not attached to this session");r.slowLink(e.uplink,e.lost,e.mid)}else{if("error"===e.janus){h.error("Ooops: "+e.error.code+" "+e.error.reason),h.debug(e);let t=e.transaction;if(t){let r=L[t];r&&r(e),delete L[t]}return}if("event"===e.janus){h.debug("Got a plugin event on session "+I),h.debug(e);const t=e.sender;if(!t)return void h.warn("Missing sender...");let r=e.plugindata;if(!r)return void h.warn("Missing plugindata...");h.debug(" -- Event is coming from "+t+" ("+r.plugin+")");let n=r.data;h.debug(n);const s=E[t];if(!s)return void h.warn("This handle is not attached to this session");let i=e.jsep;i&&(h.debug("Handling SDP as well..."),h.debug(i));let o=s.onmessage;o?(h.debug("Notifying application..."),o(n,i)):h.debug("No provided notification callback")}else{if("timeout"===e.janus)return h.error("Timeout on session "+I),h.debug(e),void(t&&r.close(3504,"Gateway timeout"));h.warn("Unknown message/event '"+e.janus+"' on session "+I),h.debug(e)}}}else{h.debug("Got a success on session "+I),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else{h.debug("Got an ack on session "+I),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else{h.debug("Got info on the Janus instance"),h.debug(e);const t=e.transaction;if(t){const r=L[t];r&&r(e),delete L[t]}}else h.vdebug("Got a keepalive on session "+I);else for(let t=0;t data channel: "+n),"open"===n){if(o.dataChannel[t].pending&&o.dataChannel[t].pending.length>0){h.log("Sending pending messages on <"+t+">:",o.dataChannel[t].pending.length);for(let e of o.dataChannel[t].pending)h.log("Sending data on data channel <"+t+">"),h.debug(e),o.dataChannel[t].send(e);o.dataChannel[t].pending=[]}i.ondataopen(t,r)}};if(n)o.dataChannel[t]=n;else{let e=o.dataChannelOptions;r&&(e.protocol=r),o.dataChannel[t]=o.pc.createDataChannel(t,e)}o.dataChannel[t].onmessage=function(e){h.log("Received message on data channel:",e);let t=e.target.label;i.ondata(e.data,t)},o.dataChannel[t].onopen=a,o.dataChannel[t].onclose=a,o.dataChannel[t].onerror=function(e){h.error("Got error on data channel:",e)},o.dataChannel[t].pending=[],s&&o.dataChannel[t].pending.push(s)}function U(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),void t.error("Invalid handle");let n=r.webrtcStuff,s=t.text||t.data;if(!s)return h.warn("Invalid data"),void t.error("Invalid data");let i=t.label?t.label:h.dataChanDefaultLabel;return n.dataChannel[i]?"open"!==n.dataChannel[i].readyState?(n.dataChannel[i].pending.push(s),void t.success()):(h.log("Sending data on data channel <"+i+">"),h.debug(s),n.dataChannel[i].send(s),void t.success()):(N(e,i,t.protocol,!1,s,t.protocol),void t.success())}function B(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),void t.error("Invalid handle");let n=r.webrtcStuff;if(!n.dtmfSender){if(n.pc){let e=n.pc.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(!e)return h.warn("Invalid DTMF configuration (no audio track)"),void t.error("Invalid DTMF configuration (no audio track)");n.dtmfSender=e.dtmf,n.dtmfSender&&(h.log("Created DTMF Sender"),n.dtmfSender.ontonechange=function(e){h.debug("Sent DTMF tone: "+e.tone)})}if(!n.dtmfSender)return h.warn("Invalid DTMF configuration"),void t.error("Invalid DTMF configuration")}let s=t.dtmf;if(!s)return h.warn("Invalid DTMF parameters"),void t.error("Invalid DTMF parameters");let i=s.tones;if(!i)return h.warn("Invalid DTMF string"),void t.error("Invalid DTMF string");let o="number"==typeof s.duration?s.duration:500,a="number"==typeof s.gap?s.gap:50;h.debug("Sending DTMF string "+i+" (duration "+o+"ms, gap "+a+"ms)"),n.dtmfSender.insertDTMF(i,o,a),t.success()}function F(e,n){(n=n||{}).success="function"==typeof n.success?n.success:h.noop,n.error="function"==typeof n.error?n.error:h.noop;let s=!0===n.noRequest;h.log("Destroying handle "+e+" (only-locally="+s+")"),Z(e);let i=E[e];if(!i||i.detached)return delete E[e],void n.success();if(i.detached=!0,s)return delete E[e],void n.success();if(!x)return h.warn("Is the server down? (connected=false)"),void n.error("Is the server down? (connected=false)");let o={janus:"detach",transaction:h.randomString(12)};if(i.token&&(o.token=i.token),C&&(o.apisecret=C),t)return o.session_id=I,o.handle_id=e,r.send(JSON.stringify(o)),delete E[e],void n.success();h.httpAPICall(f+"/"+I+"/"+e,{verb:"POST",withCredentials:v,body:o,success:function(t){h.log("Destroyed handle:"),h.debug(t),"success"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),delete E[e],n.success()},error:function(t,r){h.error(t+":",r),delete E[e],n.success()}})}async function z(e,t,r){(r=r||{}).success="function"==typeof r.success?r.success:h.noop,r.error="function"==typeof r.error?r.error:Q;let n=r.jsep;if(t&&n)return h.error("Provided a JSEP to a createOffer"),void r.error("Provided a JSEP to a createOffer");if(!(t||n&&n.type&&n.sdp))return h.error("A valid JSEP is required for createAnswer"),void r.error("A valid JSEP is required for createAnswer");if(r.media&&!r.tracks){if(r.tracks=h.mediaToTracks(r.media),!0===r.simulcast||!0===r.simulcast2||r.svc)for(let e of r.tracks)if("video"===e.type){!0===r.simulcast||!0===r.simulcast2?e.simulcast=!0:r.svc&&(e.svc=r.svc);break}h.warn("Deprecated media object passed, use tracks instead. Automatically translated to:",r.tracks)}if(r.tracks&&!Array.isArray(r.tracks))return h.error("Tracks must be an array"),void r.error("Tracks must be an array");let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),void r.error("Invalid handle");let i=s.webrtcStuff;var o;i.trickle=(o=r.trickle,h.debug("isTrickleEnabled:",o),!1!==o);try{if(function(e,t){let r=E[e];if(!r||!r.webrtcStuff)throw h.warn("Invalid handle"),"Invalid handle";let n=r.webrtcStuff;if(n.pc)return;let s={iceServers:m,iceTransportPolicy:g,bundlePolicy:y,sdpSemantics:"unified-plan"},i=!1;if(t.tracks)for(let e of t.tracks)if(e.transforms&&(e.transforms.sender||e.transforms.receiver)){i=!0;break}l&&(l.prototype.createEncodedStreams||l.prototype.createEncodedAudioStreams&&l.prototype.createEncodedVideoStreams)&&i&&(n.insertableStreams=!0,s.forceEncodedAudioInsertableStreams=!0,s.forceEncodedVideoInsertableStreams=!0,s.encodedInsertableStreams=!0),h.log("Creating PeerConnection"),n.pc=new a(s),h.debug(n.pc),n.pc.getStats&&(n.volume={},n.bitrate.value="0 kbits/sec"),h.log("Preparing local SDP and gathering candidates (trickle="+n.trickle+")"),n.pc.oniceconnectionstatechange=function(){n.pc&&r.iceState(n.pc.iceConnectionState)},n.pc.onicecandidate=function(r){if(!r.candidate||r.candidate.candidate&&r.candidate.candidate.indexOf("endOfCandidates")>0)h.log("End of candidates."),n.iceDone=!0,!0===n.trickle?M(e,{completed:!0}):function(e,t){(t=t||{}).success="function"==typeof t.success?t.success:h.noop,t.error="function"==typeof t.error?t.error:h.noop;let r=E[e];if(!r||!r.webrtcStuff)return void h.warn("Invalid handle, not sending anything");let n=r.webrtcStuff;h.log("Sending offer/answer SDP..."),n.mySdp?(n.mySdp={type:n.pc.localDescription.type,sdp:n.pc.localDescription.sdp},!1===n.trickle&&(n.mySdp.trickle=!1),h.debug(t),n.sdpSent=!0,t.success(n.mySdp)):h.warn("Local SDP instance is invalid, not sending anything...")}(e,t);else{let t={candidate:r.candidate.candidate,sdpMid:r.candidate.sdpMid,sdpMLineIndex:r.candidate.sdpMLineIndex};!0===n.trickle&&M(e,t)}},n.pc.ontrack=function(e){if(h.log("Handling Remote Track",e),!e.streams)return;if(!e.track)return;let t=e.transceiver?e.transceiver.mid||e.transceiver._mid:e.track.id;try{r.onremotetrack(e.track,t,!0,{reason:"created"})}catch(e){h.error("Error calling onremotetrack",e)}if(e.track.onended)return;let s=null;h.log("Adding onended callback to track:",e.track),e.track.onended=function(e){h.log("Remote track removed:",e),clearTimeout(s);let t=n.pc?n.pc.getTransceivers():null,i=t?t.find((t=>{const r=t.receiver||t._receiver;return(r.track||r._track)===e.target})):null,o=i?i.mid||i._mid:e.target.id;try{r.onremotetrack(e.target,o,!1,{reason:"ended"})}catch(e){h.error("Error calling onremotetrack on removal",e)}},e.track.onmute=function(e){if(h.log("Remote track muted:",e),!s){const t=e.target;s=setTimeout((function(){h.log("Removing remote track");let e=n.pc?n.pc.getTransceivers():null,i=e?e.find((e=>{const r=e.receiver||e._receiver;return(r.track||r._track)===t})):null,o=i?i.mid||i._mid:t.id;try{r.onremotetrack(t,o,!1,{reason:"mute"})}catch(e){h.error("Error calling onremotetrack on mute",e)}s=null}),2520)}},e.track.onunmute=function(e){if(h.log("Remote track flowing again:",e),null!=s)clearTimeout(s),s=null;else try{let t=n.pc?n.pc.getTransceivers():null,s=t?t.find((t=>{const r=t.receiver||t._receiver;return(r.track||r._track)===e.target})):null,i=s?s.mid||s._mid:e.target.id;r.onremotetrack(e.target,i,!0,{reason:"unmute"})}catch(e){h.error("Error calling onremotetrack on unmute",e)}}}}(e,r),t&&await J(e,r),n){if(await i.pc.setRemoteDescription(n),h.log("Remote description accepted!"),i.remoteSdp=n.sdp,i.candidates&&i.candidates.length>0){for(let e=0;e0){for(let e=0;ee.mid===t.mid&&e.receiver.track.kind===a)):n.pc.getTransceivers().find((e=>e.receiver.track.kind===a)),t.replace||t.remove){if(!p){h.warn("Couldn't find a transceiver for track:",t);continue}if(!p.sender){h.warn("No sender in the transceiver for track:",t);continue}m=p.sender}if(f&&!p&&(p=n.pc.getTransceivers().find((e=>e.receiver.track.kind===a)),!p)){h.warn("Couldn't find a transceiver for track:",t);continue}let g=null,y=null;if(t.remove)h.log("Removing track from PeerConnection",t),y=m.track?m.track.id:null,await m.replaceTrack(null);else if(t.capture){if(t.gumGroup&&d[t.gumGroup]&&d[t.gumGroup].stream){let e=d[t.gumGroup].stream;g="audio"===t.type?e.getAudioTracks()[0]:e.getVideoTracks()[0],delete d[t.gumGroup].stream,delete d[t.gumGroup],delete t.gumGroup}else if(t.capture instanceof o)g=t.capture;else{u||(u=!0,r.consentDialog(!0));let e=h.trackConstraints(t),n=null;if("audio"===t.type||"video"===t.type){if(t.gumGroup){let r="audio"===t.type?"video":"audio";if(d[t.gumGroup]&&d[t.gumGroup][r]){let n=d[t.gumGroup][r],s=h.trackConstraints(n);e[r]=s[r]}}n=await s.mediaDevices.getUserMedia(e),t.gumGroup&&e.audio&&e.video&&(d[t.gumGroup].stream=n,delete t.gumGroup)}else n=await s.mediaDevices.getDisplayMedia(e);g="audio"===t.type?n.getAudioTracks()[0]:n.getVideoTracks()[0]}if(t.replace){await m.replaceTrack(g);let e="sendrecv";!1!==t.recv&&"inactive"!==p.direction&&"sendonly"!==p.direction||(e="sendonly"),p.setDirection?p.setDirection(e):p.direction=e}else{if(n.myStream||(n.myStream=new i),"audio"===a||!t.simulcast&&!t.svc)m=n.pc.addTrack(g,n.myStream),p=n.pc.getTransceivers().find((e=>e.sender===m));else if(t.simulcast){if("firefox"!==h.webRTCAdapter.browserDetails.browser){h.log("Enabling rid-based simulcasting:",g);let e=_(t.simulcastMaxBitrates);p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream],sendEncodings:t.sendEncodings||[{rid:"h",active:!0,maxBitrate:e.high},{rid:"m",active:!0,maxBitrate:e.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:e.low,scaleResolutionDownBy:4}]})}else if(h.log("Enabling Simulcasting for Firefox (RID)"),p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream]}),m=p?p.sender:null,m){let e=m.getParameters();e||(e={});let r=_(t.simulcastMaxBitrates);e.encodings=t.sendEncodings||[{rid:"h",active:!0,maxBitrate:r.high},{rid:"m",active:!0,maxBitrate:r.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:r.low,scaleResolutionDownBy:4}],m.setParameters(e)}}else h.log("Enabling SVC ("+t.svc+"):",g),p=n.pc.addTransceiver(g,{direction:"sendrecv",streams:[n.myStream],sendEncodings:[{scalabilityMode:t.svc}]});if(m||(m=p?p.sender:null),t.codec)if("firefox"===h.webRTCAdapter.browserDetails.browser)h.warn("setCodecPreferences not supported in Firefox, ignoring codec for track:",t);else if("string"!=typeof t.codec)h.warn("Invalid codec value, ignoring for track:",t);else{let e=a+"/"+t.codec.toLowerCase(),r=c.getCapabilities(a).codecs.filter((function(t){return t.mimeType.toLowerCase()===e}));if(r&&0!==r.length){if(p)try{p.setCodecPreferences(r)}catch(e){h.warn("Failed enforcing codec for this "+a+" track:",e)}}else h.warn("Codec not supported in this browser for this track, ignoring:",t)}if(t.bitrate)if(t.simulcast||t.svc)h.warn("Ignoring bitrate for simulcast/SVC track, use sendEncodings for that");else if(isNaN(t.bitrate)||t.bitrate<0)h.warn("Ignoring invalid bitrate for track:",t);else if(m){let e=m.getParameters();e&&e.encodings&&0!==e.encodings.length?(e.encodings[0].maxBitrate=t.bitrate,await m.setParameters(e)):h.warn("No encodings in the sender parameters, ignoring bitrate for track:",t)}if("video"===a&&t.framerate)if(t.simulcast||t.svc)h.warn("Ignoring framerate for simulcast/SVC track, use sendEncodings for that");else if(isNaN(t.framerate)||t.framerate<0)h.warn("Ignoring invalid framerate for track:",t);else if(m){let e=m.getParameters();e&&e.encodings&&0!==e.encodings.length?(e.encodings[0].maxFramerate=t.framerate,await m.setParameters(e)):h.warn("No encodings in the sender parameters, ignoring framerate for track:",t)}if(t.transforms){if(m&&t.transforms.sender){let e=null;l.prototype.createEncodedStreams?e=m.createEncodedStreams():(l.prototype.createAudioEncodedStreams||l.prototype.createEncodedVideoStreams)&&("audio"===a?e=m.createEncodedAudioStreams():"video"===a&&(e=m.createEncodedVideoStreams())),e&&(h.log("Insertable Streams sender transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.sender).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.sender).pipeTo(e.writable))}if(p&&p.receiver&&t.transforms.receiver){let e=null;c.prototype.createEncodedStreams?e=p.receiver.createEncodedStreams():(c.prototype.createAudioEncodedStreams||c.prototype.createEncodedVideoStreams)&&("audio"===a?e=p.receiver.createEncodedAudioStreams():"video"===a&&(e=p.receiver.createEncodedVideoStreams())),e&&(h.log("Insertable Streams receiver transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.receiver).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.receiver).pipeTo(e.writable))}}}g&&!0===t.dontStop&&(g.dontStop=!0)}else if(t.recv&&!p&&(p=n.pc.addTransceiver(a),p)){if(t.codec)if("firefox"===h.webRTCAdapter.browserDetails.browser)h.warn("setCodecPreferences not supported in Firefox, ignoring codec for track:",t);else if("string"!=typeof t.codec)h.warn("Invalid codec value, ignoring for track:",t);else{let e=a+"/"+t.codec.toLowerCase(),r=c.getCapabilities(a).codecs.filter((function(t){return t.mimeType.toLowerCase()===e}));if(r&&0!==r.length)try{p.setCodecPreferences(r)}catch(e){h.warn("Failed enforcing codec for this "+a+" track:",e)}else h.warn("Codec not supported in this browser for this track, ignoring:",t)}if(p.receiver&&t.transforms&&t.transforms.receiver){let e=null;c.prototype.createEncodedStreams?e=p.receiver.createEncodedStreams():(c.prototype.createAudioEncodedStreams||c.prototype.createEncodedVideoStreams)&&("audio"===a?e=p.receiver.createEncodedAudioStreams():"video"===a&&(e=p.receiver.createEncodedVideoStreams())),e&&(h.log("Insertable Streams receiver transform:",e),e.readableStream&&e.writableStream?e.readableStream.pipeThrough(t.transforms.receiver).pipeTo(e.writableStream):e.readable&&e.writable&&e.readable.pipeThrough(t.transforms.receiver).pipeTo(e.writable))}}if(y&&n.myStream){let e=null;if("audio"===a&&n.myStream.getAudioTracks()&&n.myStream.getAudioTracks().length)for(let t of n.myStream.getAudioTracks())t.id===y&&(e=t,h.log("Removing audio track:",e));else if("video"===a&&n.myStream.getVideoTracks()&&n.myStream.getVideoTracks().length)for(let t of n.myStream.getVideoTracks())t.id===y&&(e=t,h.log("Removing video track:",e));if(e){try{n.myStream.removeTrack(e),r.onlocaltrack(e,!1)}catch(e){h.error("Error calling onlocaltrack on removal for renegotiation",e)}if(!0!==e.dontStop)try{e.stop()}catch(e){}}}if(g){n.myStream.addTrack(g),g.onended=function(e){h.log("Local track removed:",e);try{r.onlocaltrack(e.target,!1)}catch(e){h.error("Error calling onlocaltrack following end",e)}};try{r.onlocaltrack(g,!0)}catch(e){h.error("Error calling onlocaltrack for track add",e)}}if(p){let e=p.direction,r=null,n=g&&p.sender.track,s=!1!==t.recv&&p.receiver.track;n&&s?r="sendrecv":n&&!s?r="sendonly":!n&&s?r="recvonly":n||s||(r="inactive"),r&&r!==e&&(h.warn("Changing direction of transceiver to "+r+" (was "+e+")",t),p.setDirection?p.setDirection(r):p.direction=r)}}u&&r.consentDialog(!1)}function $(e){let t=E[e];if(!t||!t.webrtcStuff)return h.warn("Invalid handle"),null;let r=t.webrtcStuff;if(!r.pc)return h.warn("Invalid PeerConnection"),null;let n=[],s=r.pc.getTransceivers();for(let e of s){let t=null;e.sender&&e.sender.track&&(t={mid:e.mid},t.type=e.sender.track.kind,t.id=e.sender.track.id,t.label=e.sender.track.label),t&&n.push(t)}return n}function H(e){let t=E[e];if(!t||!t.webrtcStuff)return h.warn("Invalid handle"),null;let r=t.webrtcStuff;if(!r.pc)return h.warn("Invalid PeerConnection"),null;let n=[],s=r.pc.getTransceivers();for(let e of s){let t=null;e.receiver&&e.receiver.track&&(t={mid:e.mid},t.type=e.receiver.track.kind,t.id=e.receiver.track.id,t.label=e.receiver.track.label),t&&n.push(t)}return n}function W(e,t,r,n){n="function"==typeof n?n:h.noop;let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),void n(0);let i=r?"remote":"local",o=s.webrtcStuff;if(o.volume[i]||(o.volume[i]={value:0}),o.pc&&o.pc.getStats&&("chrome"===h.webRTCAdapter.browserDetails.browser||"safari"===h.webRTCAdapter.browserDetails.browser)){let e=o.pc;if(t){let s=o.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));if(!s)return h.warn("No audio transceiver with mid "+t),void n(0);if(r&&!s.receiver)return h.warn("Remote transceiver track unavailable"),void n(0);if(!r&&!s.sender)return h.warn("Local transceiver track unavailable"),void n(0);e=r?s.receiver:s.sender}return e.getStats().then((function(e){e.forEach((function(e){e&&"audio"===e.kind&&(r&&!e.remoteSource||!r&&"media-source"!==e.type||n(e.audioLevel?e.audioLevel:0))}))})),o.volume[i].value}return h.warn("Getting the "+i+" volume unsupported by browser"),void n(0)}function G(e,t,r){let n=E[e];if(!n||!n.webrtcStuff)return h.warn("Invalid handle"),!0;let s=n.webrtcStuff;if(!s.pc)return h.warn("Invalid PeerConnection"),!0;if(!s.myStream)return h.warn("Invalid local MediaStream"),!0;if(r){if(!s.myStream.getVideoTracks()||0===s.myStream.getVideoTracks().length)return h.warn("No video track"),!0;if(t){let e=s.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));return e?e.sender&&e.sender.track?!e.sender.track.enabled:(h.warn("No video sender with mid "+t),!0):(h.warn("No video transceiver with mid "+t),!0)}return!s.myStream.getVideoTracks()[0].enabled}if(!s.myStream.getAudioTracks()||0===s.myStream.getAudioTracks().length)return h.warn("No audio track"),!0;if(t){let e=s.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));return e?e.sender&&e.sender.track?!e.sender.track.enabled:(h.warn("No audio sender with mid "+t),!0):(h.warn("No audio transceiver with mid "+t),!0)}return!s.myStream.getAudioTracks()[0].enabled}function K(e,t,r,n){let s=E[e];if(!s||!s.webrtcStuff)return h.warn("Invalid handle"),!1;let i=s.webrtcStuff;if(!i.pc)return h.warn("Invalid PeerConnection"),!1;if(!i.myStream)return h.warn("Invalid local MediaStream"),!1;if(r){if(!i.myStream.getVideoTracks()||0===i.myStream.getVideoTracks().length)return h.warn("No video track"),!1;if(t){let e=i.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));if(!e)return h.warn("No video transceiver with mid "+t),!1;if(!e.sender||!e.sender.track)return h.warn("No video sender with mid "+t),!1;e.sender.track.enabled=!n}else for(const e of i.myStream.getVideoTracks())e.enabled=!n}else{if(!i.myStream.getAudioTracks()||0===i.myStream.getAudioTracks().length)return h.warn("No audio track"),!1;if(t){let e=i.pc.getTransceivers().find((e=>e.mid===t&&"audio"===e.receiver.track.kind));if(!e)return h.warn("No audio transceiver with mid "+t),!1;if(!e.sender||!e.sender.track)return h.warn("No audio sender with mid "+t),!1;e.sender.track.enabled=!n}else for(const e of i.myStream.getAudioTracks())e.enabled=!n}return!0}function X(e,t){let r=E[e];if(!r||!r.webrtcStuff)return h.warn("Invalid handle"),"Invalid handle";let n=r.webrtcStuff;if(!n.pc)return"Invalid PeerConnection";if(n.pc.getStats){let e=n.pc,r=t||"default";if(t){let r=n.pc.getTransceivers().find((e=>e.mid===t&&"video"===e.receiver.track.kind));if(!r)return h.warn("No video transceiver with mid "+t),"No video transceiver with mid "+t;if(!r.receiver)return h.warn("No video receiver with mid "+t),"No video receiver with mid "+t;e=r.receiver}return n.bitrate[r]||(n.bitrate[r]={timer:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,value:"0 kbits/sec"}),n.bitrate[r].timer?n.bitrate[r].value:(h.log("Starting bitrate timer"+(t?" for mid "+t:"")+" (via getStats)"),n.bitrate[r].timer=setInterval((function(){e.getStats().then((function(e){e.forEach((function(e){if(!e)return;let t=!1;if(("video"===e.mediaType||e.id.toLowerCase().indexOf("video")>-1)&&"inbound-rtp"===e.type&&e.id.indexOf("rtcp")<0?t=!0:"ssrc"!=e.type||!e.bytesReceived||"VP8"!==e.googCodecName&&""!==e.googCodecName||(t=!0),t)if(n.bitrate[r].bsnow=e.bytesReceived,n.bitrate[r].tsnow=e.timestamp,null===n.bitrate[r].bsbefore||null===n.bitrate[r].tsbefore)n.bitrate[r].bsbefore=n.bitrate[r].bsnow,n.bitrate[r].tsbefore=n.bitrate[r].tsnow;else{let e=n.bitrate[r].tsnow-n.bitrate[r].tsbefore;"safari"===h.webRTCAdapter.browserDetails.browser&&(e/=1e3);let t=Math.round(8*(n.bitrate[r].bsnow-n.bitrate[r].bsbefore)/e);"safari"===h.webRTCAdapter.browserDetails.browser&&(t=parseInt(t/1e3)),n.bitrate[r].value=t+" kbits/sec",n.bitrate[r].bsbefore=n.bitrate[r].bsnow,n.bitrate[r].tsbefore=n.bitrate[r].tsnow}}))}))}),1e3),"0 kbits/sec")}return h.warn("Getting the video bitrate unsupported by browser"),"Feature unsupported by browser"}function Y(e,t,r){let n=E[e];if(!n||!n.webrtcStuff)return void h.warn("Invalid handle");let s=n.webrtcStuff;if(!s.pc)return void h.warn("Invalid PeerConnection");let i=s.pc.getTransceivers().find((e=>e.mid===t));if(!i)return void h.warn("No transceiver with mid",t);if(!i.sender)return void h.warn("No sender for transceiver with mid",t);let o=i.sender.getParameters();o&&o.encodings&&0!==o.encodings.length?o.encodings.length>1?h.warn("Ignoring bitrate for simulcast track, use sendEncodings for that"):isNaN(r)||r<0?h.warn("Invalid bitrate (must be a positive integer)"):(o.encodings[0].maxBitrate=r,i.sender.setParameters(o)):h.warn("No parameters encodings")}function Q(e){h.error("WebRTC error:",e)}function Z(e,n){h.log("Cleaning WebRTC stuff");let s=E[e];if(!s)return;let i=s.webrtcStuff;if(i){if(!0===n){let n={janus:"hangup",transaction:h.randomString(12)};s.token&&(n.token=s.token),C&&(n.apisecret=C),h.debug("Sending hangup request (handle="+e+"):"),h.debug(n),t?(n.session_id=I,n.handle_id=e,r.send(JSON.stringify(n))):h.httpAPICall(f+"/"+I+"/"+e,{verb:"POST",withCredentials:v,body:n})}i.volume&&(i.volume.local&&i.volume.local.timer&&clearInterval(i.volume.local.timer),i.volume.remote&&i.volume.remote.timer&&clearInterval(i.volume.remote.timer));for(let e in i.bitrate)i.bitrate[e].timer&&clearInterval(i.bitrate[e].timer);i.bitrate={},!i.streamExternal&&i.myStream&&(h.log("Stopping local stream tracks"),h.stopAllTracks(i.myStream)),i.streamExternal=!1,i.myStream=null;try{i.pc.close()}catch(e){}i.pc=null,i.candidates=null,i.mySdp=null,i.remoteSdp=null,i.iceDone=!1,i.dataChannel={},i.dtmfSender=null,i.insertableStreams=!1}s.oncleanup()}R(e),this.getServer=function(){return f},this.isConnected=function(){return x},this.reconnect=function(e){(e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.reconnect=!0,R(e)},this.getSessionId=function(){return I},this.getInfo=function(e){!function(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,h.log("Getting info on Janus instance"),!x)return h.warn("Is the server down? (connected=false)"),void e.error("Is the server down? (connected=false)");let n=h.randomString(12),s={janus:"info",transaction:n};if(S&&(s.token=S),C&&(s.apisecret=C),t)return L[n]=function(t){h.log("Server info:"),h.debug(t),"server_info"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),e.success(t)},void r.send(JSON.stringify(s));h.httpAPICall(f,{verb:"POST",withCredentials:v,body:s,success:function(t){h.log("Server info:"),h.debug(t),"server_info"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),e.success(t)},error:function(t,r){h.error(t+":",r),""===r?e.error(t+": Is the server down?"):e.error(t+": "+r)}})}(e)},this.destroy=function(i){!function(i){(i=i||{}).success="function"==typeof i.success?i.success:h.noop,i.error="function"==typeof i.error?i.error:h.noop;let o=!0===i.unload,a=!0;void 0!==i.notifyDestroyed&&null!==i.notifyDestroyed&&(a=!0===i.notifyDestroyed);let c=!0===i.cleanupHandles;if(h.log("Destroying session "+I+" (unload="+o+")"),!I)return h.warn("No session to destroy"),i.success(),void(a&&e.destroyed());if(c)for(let e in E)F(e,{noRequest:!0});if(!x)return h.warn("Is the server down? (connected=false)"),I=null,void i.success();let l={janus:"destroy",transaction:h.randomString(12)};if(S&&(l.token=S),C&&(l.apisecret=C),o)return t?(r.onclose=null,r.close(),r=null):s.sendBeacon(f+"/"+I,JSON.stringify(l)),h.log("Destroyed session:"),I=null,x=!1,i.success(),void(a&&e.destroyed());if(t){l.session_id=I;let t=function(){for(let e in n)r.removeEventListener(e,n[e]);r.removeEventListener("message",s),r.removeEventListener("error",o),u&&clearTimeout(u),r.close()},s=function(r){let n=JSON.parse(r.data);n.session_id==l.session_id&&n.transaction==l.transaction&&(t(),i.success(),a&&e.destroyed())},o=function(){t(),i.error("Failed to destroy the server: Is the server down?"),a&&e.destroyed()};return r.addEventListener("message",s),r.addEventListener("error",o),void(1===r.readyState?r.send(JSON.stringify(l)):o())}h.httpAPICall(f+"/"+I,{verb:"POST",withCredentials:v,body:l,success:function(t){h.log("Destroyed session:"),h.debug(t),I=null,x=!1,"success"!==t.janus&&h.error("Ooops: "+t.error.code+" "+t.error.reason),i.success(),a&&e.destroyed()},error:function(t,r){h.error(t+":",r),I=null,x=!1,i.success(),a&&e.destroyed()}})}(i)},this.attach=function(e){!function(e){if((e=e||{}).success="function"==typeof e.success?e.success:h.noop,e.error="function"==typeof e.error?e.error:h.noop,e.dataChannelOptions=e.dataChannelOptions||{ordered:!0},e.consentDialog="function"==typeof e.consentDialog?e.consentDialog:h.noop,e.iceState="function"==typeof e.iceState?e.iceState:h.noop,e.mediaState="function"==typeof e.mediaState?e.mediaState:h.noop,e.webrtcState="function"==typeof e.webrtcState?e.webrtcState:h.noop,e.slowLink="function"==typeof e.slowLink?e.slowLink:h.noop,e.onmessage="function"==typeof e.onmessage?e.onmessage:h.noop,e.onlocaltrack="function"==typeof e.onlocaltrack?e.onlocaltrack:h.noop,e.onremotetrack="function"==typeof e.onremotetrack?e.onremotetrack:h.noop,e.ondata="function"==typeof e.ondata?e.ondata:h.noop,e.ondataopen="function"==typeof e.ondataopen?e.ondataopen:h.noop,e.oncleanup="function"==typeof e.oncleanup?e.oncleanup:h.noop,e.ondetached="function"==typeof e.ondetached?e.ondetached:h.noop,!x)return h.warn("Is the server down? (connected=false)"),void e.error("Is the server down? (connected=false)");let n=e.plugin;if(!n)return h.error("Invalid plugin"),void e.error("Invalid plugin");let s=e.opaqueId,i=e.loopIndex,o=e.token?e.token:S,a=h.randomString(12),c={janus:"attach",plugin:n,opaque_id:s,loop_index:i,transaction:a};if(o&&(c.token=o),C&&(c.apisecret=C),t)return L[a]=function(t){if(h.debug(t),"success"!==t.janus)return h.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);let r=t.data.id;h.log("Created handle: "+r);let s={session:T,plugin:n,id:r,token:o,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,mySdp:null,mediaConstraints:null,pc:null,dataChannelOptions:e.dataChannelOptions,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,bitrate:{}},getId:function(){return r},getPlugin:function(){return n},getVolume:function(e,t){return W(r,e,!0,t)},getRemoteVolume:function(e,t){return W(r,e,!0,t)},getLocalVolume:function(e,t){return W(r,e,!1,t)},isAudioMuted:function(e){return G(r,e,!1)},muteAudio:function(e){return K(r,e,!1,!0)},unmuteAudio:function(e){return K(r,e,!1,!1)},isVideoMuted:function(e){return G(r,e,!0)},muteVideo:function(e){return K(r,e,!0,!0)},unmuteVideo:function(e){return K(r,e,!0,!1)},getBitrate:function(e){return X(r,e)},setMaxBitrate:function(e,t){return Y(r,e,t)},send:function(e){j(r,e)},data:function(e){U(r,e)},dtmf:function(e){B(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){z(r,!0,e)},createAnswer:function(e){z(r,!1,e)},handleRemoteJsep:function(e){V(r,e)},replaceTracks:function(e){q(r,e)},getLocalTracks:function(){return $(r)},getRemoteTracks:function(){return H(r)},onlocaltrack:e.onlocaltrack,onremotetrack:e.onremotetrack,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){Z(r,!0===e)},detach:function(e){F(r,e)}};E[r]=s,e.success(s)},c.session_id=I,void r.send(JSON.stringify(c));h.httpAPICall(f+"/"+I,{verb:"POST",withCredentials:v,body:c,success:function(t){if(h.debug(t),"success"!==t.janus)return h.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);let r=t.data.id;h.log("Created handle: "+r);let s={session:T,plugin:n,id:r,token:o,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,mySdp:null,mediaConstraints:null,pc:null,dataChannelOptions:e.dataChannelOptions,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,bitrate:{}},getId:function(){return r},getPlugin:function(){return n},getVolume:function(e,t){return W(r,e,!0,t)},getRemoteVolume:function(e,t){return W(r,e,!0,t)},getLocalVolume:function(e,t){return W(r,e,!1,t)},isAudioMuted:function(e){return G(r,e,!1)},muteAudio:function(e){return K(r,e,!1,!0)},unmuteAudio:function(e){return K(r,e,!1,!1)},isVideoMuted:function(e){return G(r,e,!0)},muteVideo:function(e){return K(r,e,!0,!0)},unmuteVideo:function(e){return K(r,e,!0,!1)},getBitrate:function(e){return X(r,e)},setMaxBitrate:function(e,t){return Y(r,e,t)},send:function(e){j(r,e)},data:function(e){U(r,e)},dtmf:function(e){B(r,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){z(r,!0,e)},createAnswer:function(e){z(r,!1,e)},handleRemoteJsep:function(e){V(r,e)},replaceTracks:function(e){q(r,e)},getLocalTracks:function(){return $(r)},getRemoteTracks:function(){return H(r)},onlocaltrack:e.onlocaltrack,onremotetrack:e.onremotetrack,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){Z(r,!0===e)},detach:function(e){F(r,e)}};E[r]=s,e.success(s)},error:function(t,r){h.error(t+":",r),""===r?e.error(t+": Is the server down?"):e.error(t+": "+r)}})}(e)}}h.useDefaultDependencies=function(e){let t=e&&e.fetch||fetch,r=e&&e.Promise||Promise,s=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new s(e,t)},extension:e&&e.extension||d,isArray:function(e){return Array.isArray(e)},webRTCAdapter:e&&e.adapter||n,httpAPICall:function(e,n){let s={method:n.verb,headers:{Accept:"application/json, text/plain, */*"},cache:"no-cache"};"POST"===n.verb&&(s.headers["Content-Type"]="application/json"),void 0!==n.withCredentials&&(s.credentials=!0===n.withCredentials?"include":n.withCredentials?n.withCredentials:"omit"),n.body&&(s.body=JSON.stringify(n.body));let i=t(e,s).catch((function(e){return r.reject({message:"Probably a network error, is the server down?",error:e})}));if(n.timeout){let e=new r((function(e,t){let r=setTimeout((function(){return clearTimeout(r),t({message:"Request timed out",timeout:n.timeout})}),n.timeout)}));i=r.race([i,e])}return i.then((function(e){return e.ok?typeof n.success==typeof h.noop?e.json().then((function(e){try{n.success(e)}catch(e){h.error("Unhandled httpAPICall success callback error",e)}}),(function(t){return r.reject({message:"Failed to parse response body",error:t,response:e})})):void 0:r.reject({message:"API call failed",response:e})})).catch((function(e){typeof n.error==typeof h.noop&&n.error(e.message||"<< internal error >>",e)})),i}}},h.useOldDependencies=function(e){let t=e&&e.jQuery||jQuery,r=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new r(e,t)},isArray:function(e){return t.isArray(e)},extension:e&&e.extension||d,webRTCAdapter:e&&e.adapter||n,httpAPICall:function(e,r){let n=void 0!==r.body?{contentType:"application/json",data:JSON.stringify(r.body)}:{},s=void 0!==r.withCredentials?{xhrFields:{withCredentials:r.withCredentials}}:{};return t.ajax(t.extend(n,s,{url:e,type:r.verb,cache:!1,dataType:"json",async:r.async,timeout:r.timeout,success:function(e){typeof r.success==typeof h.noop&&r.success(e)},error:function(e,t,n){typeof r.error==typeof h.noop&&r.error(t,n)}}))}}},h.mediaToTracks=function(e){let t=[];if(e){if(!e.keepAudio&&!1!==e.audio&&(void 0===e.audio||e.audio||e.audioSend||e.audioRecv||e.addAudio||e.replaceAudio||e.removeAudio)){let r={type:"audio"};e.removeAudio?r.remove=!0:(e.addAudio?r.add=!0:e.replaceAudio&&(r.replace=!0),!1!==e.audioSend&&(r.capture=e.audio||!0),!1!==e.audioRecv&&(r.recv=!0)),(r.remove||r.capture||r.recv)&&t.push(r)}if(!e.keepVideo&&!1!==e.video&&(void 0===e.video||e.video||e.videoSend||e.videoRecv||e.addVideo||e.replaceVideo||e.removeVideo)){let r={type:"video"};e.removeVideo?r.remove=!0:(e.addVideo?r.add=!0:e.replaceVideo&&(r.replace=!0),!1!==e.videoSend&&(r.capture=e.video||!0,["screen","window","desktop"].includes(r.capture)&&(r.type="screen",r.capture={video:{}},e.screenshareFrameRate&&(r.capture.frameRate=e.screenshareFrameRate),e.screenshareHeight&&(r.capture.height=e.screenshareHeight),e.screenshareWidth&&(r.capture.width=e.screenshareWidth))),!1!==e.videoRecv&&(r.recv=!0)),(r.remove||r.capture||r.recv)&&t.push(r)}e.data&&t.push({type:"data"})}else t.push({type:"audio",capture:!0,recv:!0}),t.push({type:"video",capture:!0,recv:!0});return t},h.trackConstraints=function(e){let t={};if(!e||!e.capture)return t;if("audio"===e.type)t.audio=e.capture;else if("video"===e.type)if((e.simulcast||e.svc)&&!0===e.capture&&(e.capture="hires"),!0===e.capture||"object"==typeof e.capture)t.video=e.capture;else{let r=0,n=0;"lowres"===e.capture?(r=320,n=240):"lowres-16:9"===e.capture?(r=320,n=180):"hires"===e.capture||"hires-16:9"===e.capture||"hdres"===e.capture?(r=1280,n=720):"fhdres"===e.capture?(r=1920,n=1080):"4kres"===e.capture?(r=3840,n=2160):"stdres"===e.capture?(r=640,n=480):"stdres-16:9"===e.capture?(r=640,n=360):(h.log("Default video setting is stdres 4:3"),r=640,n=480),t.video={width:{ideal:r},height:{ideal:n}}}else"screen"===e.type&&(t.video=e.capture);return t},h.noop=function(){},h.dataChanDefaultLabel="JanusDataChannel",h.endOfCandidates=null,h.stopAllTracks=function(e){try{let t=e.getTracks();for(let e of t)h.log(e),e&&!0!==e.dontStop&&e.stop()}catch(e){}},h.init=function(e){if((e=e||{}).callback="function"==typeof e.callback?e.callback:h.noop,h.initDone)e.callback();else{if(void 0===console.log&&(console.log=function(){}),h.trace=h.noop,h.debug=h.noop,h.vdebug=h.noop,h.log=h.noop,h.warn=h.noop,h.error=h.noop,!0===e.debug||"all"===e.debug)h.trace=console.trace.bind(console),h.debug=console.debug.bind(console),h.vdebug=console.debug.bind(console),h.log=console.log.bind(console),h.warn=console.warn.bind(console),h.error=console.error.bind(console);else if(Array.isArray(e.debug))for(let t of e.debug)switch(t){case"trace":h.trace=console.trace.bind(console);break;case"debug":h.debug=console.debug.bind(console);break;case"vdebug":h.vdebug=console.debug.bind(console);break;case"log":h.log=console.log.bind(console);break;case"warn":h.warn=console.warn.bind(console);break;case"error":h.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+t+"' (supported: 'trace', 'debug', 'vdebug', 'log', warn', 'error')")}h.log("Initializing library");let t=e.dependencies||h.useDefaultDependencies();if(h.isArray=t.isArray,h.webRTCAdapter=t.webRTCAdapter,h.httpAPICall=t.httpAPICall,h.newWebSocket=t.newWebSocket,h.extension=t.extension,h.extension.init(),h.listDevices=function(e,t){e="function"==typeof e?e:h.noop,t||(t={audio:!0,video:!0}),h.isGetUserMediaAvailable()?s.mediaDevices.getUserMedia(t).then((function(t){s.mediaDevices.enumerateDevices().then((function(r){h.debug(r),e(r),h.stopAllTracks(t)}))})).catch((function(t){h.error(t),e([])})):(h.warn("navigator.mediaDevices unavailable"),e([]))},h.safariVp8=!1,"safari"===h.webRTCAdapter.browserDetails.browser&&h.webRTCAdapter.browserDetails.version>=605)if(l&&l.getCapabilities&&l.getCapabilities("video")&&l.getCapabilities("video").codecs&&l.getCapabilities("video").codecs.length){for(let e of l.getCapabilities("video").codecs)if(e&&e.mimeType&&"video/vp8"===e.mimeType.toLowerCase()){h.safariVp8=!0;break}h.safariVp8?h.log("This version of Safari supports VP8"):h.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu")}else{let e=new a({});e.createOffer({offerToReceiveVideo:!0}).then((function(t){h.safariVp8=-1!==t.sdp.indexOf("VP8"),h.safariVp8?h.log("This version of Safari supports VP8"):h.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu"),e.close(),e=null}))}h.initDone=!0,e.callback()}},h.isWebrtcSupported=function(){return!!a},h.isGetUserMediaAvailable=function(){return s.mediaDevices&&s.mediaDevices.getUserMedia},h.randomString=function(e){let t="";for(let r=0;r>>2]>>>24-i%4*8&255;t[n+i>>>2]|=o<<24-(n+i)%4*8}else for(var a=0;a>>2]=r[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r>>2]>>>24-s%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],s=0;s>>2]>>>24-s%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},h=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,s=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*l,i);if(l){for(var d=0;dn&&(t=e.finalize(t)),t.clamp();for(var s=this._oKey=t.clone(),o=this._iKey=t.clone(),a=s.words,c=o.words,l=0;l>>31}var d=(n<<5|n>>>27)+a+c[l];d+=l<20?1518500249+(s&i|~s&o):l<40?1859775393+(s^i^o):l<60?(s&i|s&o|i&o)-1894007588:(s^i^o)-899497514,a=o,o=i,i=s<<30|s>>>2,s=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=o._createHelper(l),n.HmacSHA1=o._createHmacHelper(l),u.SHA1)},3009:function(e,t,r){var n;e.exports=(n=r(9021),function(e){var t=n,r=t.lib,s=r.WordArray,i=r.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,s=0;s<64;)t(n)&&(s<8&&(a[s]=r(e.pow(n,.5))),c[s]=r(e.pow(n,1/3)),s++),n++}();var l=[],u=o.SHA256=i.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],s=r[1],i=r[2],o=r[3],a=r[4],u=r[5],d=r[6],h=r[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var f=l[p-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=l[p-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=m+l[p-7]+y+l[p-16]}var v=n&s^n&i^s&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&d)+c[p]+l[p];h=d,d=u,u=a,a=o+S|0,o=i,i=s,s=n,n=S+(b+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+i|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+u|0,r[6]=r[6]+d|0,r[7]=r[7]+h|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=e.floor(n/4294967296),r[15+(s+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(u),t.HmacSHA256=i._createHmacHelper(u)}(Math),n.SHA256)},7007:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var s,i,o,l;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(n);return s.listener=r,n.wrapFn=s,s}function h(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=f(c,l);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},2881:(e,t,r)=>{var n={EventEmitter:r(4566),EmitterSubscription:r(7274)};e.exports=n},4566:(e,t,r)=>{"use strict";var n=r(7274),s=r(9402),i=r(646),o=r(9395),a=function(){function e(){this._subscriber=new s,this._currentSubscription=null}var t=e.prototype;return t.addListener=function(e,t,r){return this._subscriber.addSubscription(e,new n(this._subscriber,t,r))},t.once=function(e,t,r){var n=this;return this.addListener(e,(function(){n.removeCurrentListener(),t.apply(r,arguments)}))},t.removeAllListeners=function(e){this._subscriber.removeAllSubscriptions(e)},t.removeCurrentListener=function(){this._currentSubscription||i(!1),this._subscriber.removeSubscription(this._currentSubscription)},t.listeners=function(e){var t=this._subscriber.getSubscriptionsForType(e);return t?t.filter(o.thatReturnsTrue).map((function(e){return e.listener})):[]},t.emit=function(e){var t=this._subscriber.getSubscriptionsForType(e);if(t){for(var r=Object.keys(t),n=0;n{"use strict";var n=function(e){var t,r;function n(t,r,n){var s;return(s=e.call(this,t)||this).listener=r,s.context=n,s}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n}(r(5856));e.exports=n},5856:e=>{"use strict";var t=function(){function e(e){this.subscriber=e}return e.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},e}();e.exports=t},9402:(e,t,r)=>{"use strict";var n=r(646),s=function(){function e(){this._subscriptionsForType={},this._currentSubscription=null}var t=e.prototype;return t.addSubscription=function(e,t){t.subscriber!==this&&n(!1),this._subscriptionsForType[e]||(this._subscriptionsForType[e]=[]);var r=this._subscriptionsForType[e].length;return this._subscriptionsForType[e].push(t),t.eventType=e,t.key=r,t},t.removeAllSubscriptions=function(e){void 0===e?this._subscriptionsForType={}:delete this._subscriptionsForType[e]},t.removeSubscription=function(e){var t=e.eventType,r=e.key,n=this._subscriptionsForType[t];n&&delete n[r]},t.getSubscriptionsForType=function(e){return this._subscriptionsForType[e]},e}();e.exports=s},9395:e=>{"use strict";function t(e){return function(){return e}}var r=function(){};r.thatReturns=t,r.thatReturnsFalse=t(!1),r.thatReturnsTrue=t(!0),r.thatReturnsNull=t(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},646:e=>{"use strict";e.exports=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=n(r(261)),i=n(r(2300)),o=r(9027),a=r(1127),c=n(r(6727)),l=n(r(1350)),u=n(r(1148)),d=s.default.create;function h(){var e=d();return e.compile=function(t,r){return a.compile(t,r,e)},e.precompile=function(t,r){return a.precompile(t,r,e)},e.AST=i.default,e.Compiler=a.Compiler,e.JavaScriptCompiler=c.default,e.Parser=o.parser,e.parse=o.parse,e.parseWithoutProcessing=o.parseWithoutProcessing,e}var p=h();p.create=h,u.default(p),p.Visitor=l.default,p.default=p,t.default=p,e.exports=t.default},261:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}t.__esModule=!0;var i=s(r(2871)),o=n(r(9613)),a=n(r(3769)),c=s(r(2849)),l=s(r(7624)),u=n(r(1148));function d(){var e=new i.HandlebarsEnvironment;return c.extend(e,i),e.SafeString=o.default,e.Exception=a.default,e.Utils=c,e.escapeExpression=c.escapeExpression,e.VM=l,e.template=function(t){return l.template(t,e)},e}var h=d();h.create=d,u.default(h),h.default=h,t.default=h,e.exports=t.default},2871:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.HandlebarsEnvironment=d;var s=r(2849),i=n(r(3769)),o=r(2277),a=r(5940),c=n(r(566)),l=r(3865);t.VERSION="4.7.8",t.COMPILER_REVISION=8,t.LAST_COMPATIBLE_COMPILER_REVISION=7,t.REVISION_CHANGES={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};var u="[object Object]";function d(e,t,r){this.helpers=e||{},this.partials=t||{},this.decorators=r||{},o.registerDefaultHelpers(this),a.registerDefaultDecorators(this)}d.prototype={constructor:d,logger:c.default,log:c.default.log,registerHelper:function(e,t){if(s.toString.call(e)===u){if(t)throw new i.default("Arg not supported with multiple helpers");s.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if(s.toString.call(e)===u)s.extend(this.partials,e);else{if(void 0===t)throw new i.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if(s.toString.call(e)===u){if(t)throw new i.default("Arg not supported with multiple decorators");s.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]},resetLoggedPropertyAccesses:function(){l.resetLoggedProperties()}};var h=c.default.log;t.log=h,t.createFrame=s.createFrame,t.logger=c.default},2300:(e,t)=>{"use strict";t.__esModule=!0;var r={helpers:{helperExpression:function(e){return"SubExpression"===e.type||("MustacheStatement"===e.type||"BlockStatement"===e.type)&&!!(e.params&&e.params.length||e.hash)},scopedId:function(e){return/^\.|this\b/.test(e.original)},simpleId:function(e){return 1===e.parts.length&&!r.helpers.scopedId(e)&&!e.depth}}};t.default=r,e.exports=t.default},9027:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.parseWithoutProcessing=l,t.parse=function(e,t){var r=l(e,t);return new i.default(t).accept(r)};var s=n(r(6201)),i=n(r(915)),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8425)),a=r(2849);t.parser=s.default;var c={};function l(e,t){return"Program"===e.type?e:(s.default.yy=c,c.locInfo=function(e){return new c.SourceLocation(t&&t.srcName,e)},s.default.parse(e))}a.extend(c,o)},9632:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849),s=void 0;function i(e,t,r){if(n.isArray(e)){for(var s=[],i=0,o=e.length;i{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.Compiler=c,t.precompile=function(e,t,r){if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new s.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+e);"data"in(t=t||{})||(t.data=!0),t.compat&&(t.useDepths=!0);var n=r.parse(e,t),i=(new r.Compiler).compile(n,t);return(new r.JavaScriptCompiler).compile(i,t)},t.compile=function(e,t,r){if(void 0===t&&(t={}),null==e||"string"!=typeof e&&"Program"!==e.type)throw new s.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+e);"data"in(t=i.extend({},t))||(t.data=!0),t.compat&&(t.useDepths=!0);var n=void 0;function o(){var n=r.parse(e,t),s=(new r.Compiler).compile(n,t),i=(new r.JavaScriptCompiler).compile(s,t,void 0,!0);return r.template(i)}function a(e,t){return n||(n=o()),n.call(this,e,t)}return a._setup=function(e){return n||(n=o()),n._setup(e)},a._child=function(e,t,r,s){return n||(n=o()),n._child(e,t,r,s)},a};var s=n(r(3769)),i=r(2849),o=n(r(2300)),a=[].slice;function c(){}function l(e,t){if(e===t)return!0;if(i.isArray(e)&&i.isArray(t)&&e.length===t.length){for(var r=0;r1)throw new s.default("Unsupported number of partial arguments: "+r.length,e);r.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):r.push({type:"PathExpression",parts:[],depth:0}));var n=e.name.original,i="SubExpression"===e.name.type;i&&this.accept(e.name),this.setupFullMustacheParams(e,t,void 0,!0);var o=e.indent||"";this.options.preventIndent&&o&&(this.opcode("appendContent",o),o=""),this.opcode("invokePartial",i,n,o),this.opcode("append")},PartialBlockStatement:function(e){this.PartialStatement(e)},MustacheStatement:function(e){this.SubExpression(e),e.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(e){this.DecoratorBlock(e)},ContentStatement:function(e){e.value&&this.opcode("appendContent",e.value)},CommentStatement:function(){},SubExpression:function(e){u(e);var t=this.classifySexpr(e);"simple"===t?this.simpleSexpr(e):"helper"===t?this.helperSexpr(e):this.ambiguousSexpr(e)},ambiguousSexpr:function(e,t,r){var n=e.path,s=n.parts[0],i=null!=t||null!=r;this.opcode("getContext",n.depth),this.opcode("pushProgram",t),this.opcode("pushProgram",r),n.strict=!0,this.accept(n),this.opcode("invokeAmbiguous",s,i)},simpleSexpr:function(e){var t=e.path;t.strict=!0,this.accept(t),this.opcode("resolvePossibleLambda")},helperSexpr:function(e,t,r){var n=this.setupFullMustacheParams(e,t,r),i=e.path,a=i.parts[0];if(this.options.knownHelpers[a])this.opcode("invokeKnownHelper",n.length,a);else{if(this.options.knownHelpersOnly)throw new s.default("You specified knownHelpersOnly, but used the unknown helper "+a,e);i.strict=!0,i.falsy=!0,this.accept(i),this.opcode("invokeHelper",n.length,i.original,o.default.helpers.simpleId(i))}},PathExpression:function(e){this.addDepth(e.depth),this.opcode("getContext",e.depth);var t=e.parts[0],r=o.default.helpers.scopedId(e),n=!e.depth&&!r&&this.blockParamIndex(t);n?this.opcode("lookupBlockParam",n,e.parts):t?e.data?(this.options.data=!0,this.opcode("lookupData",e.depth,e.parts,e.strict)):this.opcode("lookupOnContext",e.parts,e.falsy,e.strict,r):this.opcode("pushContext")},StringLiteral:function(e){this.opcode("pushString",e.value)},NumberLiteral:function(e){this.opcode("pushLiteral",e.value)},BooleanLiteral:function(e){this.opcode("pushLiteral",e.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(e){var t=e.pairs,r=0,n=t.length;for(this.opcode("pushHash");r=0)return[t,s]}}}},8425:(e,t,r)=>{"use strict";t.__esModule=!0,t.SourceLocation=function(e,t){this.source=e,this.start={line:t.first_line,column:t.first_column},this.end={line:t.last_line,column:t.last_column}},t.id=function(e){return/^\[.*\]$/.test(e)?e.substring(1,e.length-1):e},t.stripFlags=function(e,t){return{open:"~"===e.charAt(2),close:"~"===t.charAt(t.length-3)}},t.stripComment=function(e){return e.replace(/^\{\{~?!-?-?/,"").replace(/-?-?~?\}\}$/,"")},t.preparePath=function(e,t,r){r=this.locInfo(r);for(var n=e?"@":"",i=[],o=0,a=0,c=t.length;a0)throw new s.default("Invalid path: "+n,{loc:r});".."===l&&o++}}return{type:"PathExpression",data:e,depth:o,parts:i,original:n,loc:r}},t.prepareMustache=function(e,t,r,n,s,i){var o=n.charAt(3)||n.charAt(2),a="{"!==o&&"&"!==o;return{type:/\*/.test(n)?"Decorator":"MustacheStatement",path:e,params:t,hash:r,escaped:a,strip:s,loc:this.locInfo(i)}},t.prepareRawBlock=function(e,t,r,n){i(e,r);var s={type:"Program",body:t,strip:{},loc:n=this.locInfo(n)};return{type:"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:s,openStrip:{},inverseStrip:{},closeStrip:{},loc:n}},t.prepareBlock=function(e,t,r,n,o,a){n&&n.path&&i(e,n);var c=/\*/.test(e.open);t.blockParams=e.blockParams;var l=void 0,u=void 0;if(r){if(c)throw new s.default("Unexpected inverse block on decorator",r);r.chain&&(r.program.body[0].closeStrip=n.strip),u=r.strip,l=r.program}return o&&(o=l,l=t,t=o),{type:c?"DecoratorBlock":"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:t,inverse:l,openStrip:e.strip,inverseStrip:u,closeStrip:n&&n.strip,loc:this.locInfo(a)}},t.prepareProgram=function(e,t){if(!t&&e.length){var r=e[0].loc,n=e[e.length-1].loc;r&&n&&(t={source:r.source,start:{line:r.start.line,column:r.start.column},end:{line:n.end.line,column:n.end.column}})}return{type:"Program",body:e,strip:{},loc:t}},t.preparePartialBlock=function(e,t,r,n){return i(e,r),{type:"PartialBlockStatement",name:e.path,params:e.params,hash:e.hash,program:t,openStrip:e.strip,closeStrip:r&&r.strip,loc:this.locInfo(n)}};var n,s=(n=r(3769))&&n.__esModule?n:{default:n};function i(e,t){if(t=t.path?t.path.original:t,e.path.original!==t){var r={loc:e.path.loc};throw new s.default(e.path.original+" doesn't match "+t,r)}}},6727:(e,t,r)=>{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=r(2871),i=n(r(3769)),o=r(2849),a=n(r(9632));function c(e){this.value=e}function l(){}l.prototype={nameLookup:function(e,t){return this.internalNameLookup(e,t)},depthedLookup:function(e){return[this.aliasable("container.lookup"),"(depths, ",JSON.stringify(e),")"]},compilerInfo:function(){var e=s.COMPILER_REVISION;return[e,s.REVISION_CHANGES[e]]},appendToBuffer:function(e,t,r){return o.isArray(e)||(e=[e]),e=this.source.wrap(e,t),this.environment.isSimple?["return ",e,";"]:r?["buffer += ",e,";"]:(e.appendToBuffer=!0,e)},initializeBuffer:function(){return this.quotedString("")},internalNameLookup:function(e,t){return this.lookupPropertyFunctionIsUsed=!0,["lookupProperty(",e,",",JSON.stringify(t),")"]},lookupPropertyFunctionIsUsed:!1,compile:function(e,t,r,n){this.environment=e,this.options=t,this.stringParams=this.options.stringParams,this.trackIds=this.options.trackIds,this.precompile=!n,this.name=this.environment.name,this.isChild=!!r,this.context=r||{decorators:[],programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(e,t),this.useDepths=this.useDepths||e.useDepths||e.useDecorators||this.options.compat,this.useBlockParams=this.useBlockParams||e.useBlockParams;var s=e.opcodes,o=void 0,a=void 0,c=void 0,l=void 0;for(c=0,l=s.length;c0&&(r+=", "+n.join(", "));var s=0;Object.keys(this.aliases).forEach((function(e){var n=t.aliases[e];n.children&&n.referenceCount>1&&(r+=", alias"+ ++s+"="+e,n.children[0]="alias"+s)})),this.lookupPropertyFunctionIsUsed&&(r+=", "+this.lookupPropertyFunctionVarDeclaration());var i=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&i.push("blockParams"),this.useDepths&&i.push("depths");var o=this.mergeSource(r);return e?(i.push(o),Function.apply(this,i)):this.source.wrap(["function(",i.join(","),") {\n ",o,"}"])},mergeSource:function(e){var t=this.environment.isSimple,r=!this.forceBuffer,n=void 0,s=void 0,i=void 0,o=void 0;return this.source.each((function(e){e.appendToBuffer?(i?e.prepend(" + "):i=e,o=e):(i&&(s?i.prepend("buffer += "):n=!0,o.add(";"),i=o=void 0),s=!0,t||(r=!1))})),r?i?(i.prepend("return "),o.add(";")):s||this.source.push('return "";'):(e+=", buffer = "+(n?"":this.initializeBuffer()),i?(i.prepend("return buffer + "),o.add(";")):this.source.push("return buffer;")),e&&this.source.prepend("var "+e.substring(2)+(n?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(e){var t=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs(e,0,r);var n=this.popStack();r.splice(1,0,n),this.push(this.source.functionCall(t,"call",r))},ambiguousBlockValue:function(){var e=this.aliasable("container.hooks.blockHelperMissing"),t=[this.contextName(0)];this.setupHelperArgs("",0,t,!0),this.flushInline();var r=this.topStack();t.splice(1,0,r),this.pushSource(["if (!",this.lastHelper,") { ",r," = ",this.source.functionCall(e,"call",t),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack((function(e){return[" != null ? ",e,' : ""']})),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,t,r,n){var s=0;n||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(e[s++])),this.resolvePath("context",e,s,t,r)},lookupBlockParam:function(e,t){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",t,1)},lookupData:function(e,t,r){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",t,0,!0,r)},resolvePath:function(e,t,r,n,s){var i=this;if(this.options.strict||this.options.assumeObjects)this.push(function(e,t,r,n,s){var i=t.popStack(),o=r.length;for(e&&o--;nthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var t=0,r=e.length;t{"use strict";t.__esModule=!0;var r=function(){var e={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,program_repetition0:6,statement:7,mustache:8,block:9,rawBlock:10,partial:11,partialBlock:12,content:13,COMMENT:14,CONTENT:15,openRawBlock:16,rawBlock_repetition0:17,END_RAW_BLOCK:18,OPEN_RAW_BLOCK:19,helperName:20,openRawBlock_repetition0:21,openRawBlock_option0:22,CLOSE_RAW_BLOCK:23,openBlock:24,block_option0:25,closeBlock:26,openInverse:27,block_option1:28,OPEN_BLOCK:29,openBlock_repetition0:30,openBlock_option0:31,openBlock_option1:32,CLOSE:33,OPEN_INVERSE:34,openInverse_repetition0:35,openInverse_option0:36,openInverse_option1:37,openInverseChain:38,OPEN_INVERSE_CHAIN:39,openInverseChain_repetition0:40,openInverseChain_option0:41,openInverseChain_option1:42,inverseAndProgram:43,INVERSE:44,inverseChain:45,inverseChain_option0:46,OPEN_ENDBLOCK:47,OPEN:48,mustache_repetition0:49,mustache_option0:50,OPEN_UNESCAPED:51,mustache_repetition1:52,mustache_option1:53,CLOSE_UNESCAPED:54,OPEN_PARTIAL:55,partialName:56,partial_repetition0:57,partial_option0:58,openPartialBlock:59,OPEN_PARTIAL_BLOCK:60,openPartialBlock_repetition0:61,openPartialBlock_option0:62,param:63,sexpr:64,OPEN_SEXPR:65,sexpr_repetition0:66,sexpr_option0:67,CLOSE_SEXPR:68,hash:69,hash_repetition_plus0:70,hashSegment:71,ID:72,EQUALS:73,blockParams:74,OPEN_BLOCK_PARAMS:75,blockParams_repetition_plus0:76,CLOSE_BLOCK_PARAMS:77,path:78,dataName:79,STRING:80,NUMBER:81,BOOLEAN:82,UNDEFINED:83,NULL:84,DATA:85,pathSegments:86,SEP:87,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"COMMENT",15:"CONTENT",18:"END_RAW_BLOCK",19:"OPEN_RAW_BLOCK",23:"CLOSE_RAW_BLOCK",29:"OPEN_BLOCK",33:"CLOSE",34:"OPEN_INVERSE",39:"OPEN_INVERSE_CHAIN",44:"INVERSE",47:"OPEN_ENDBLOCK",48:"OPEN",51:"OPEN_UNESCAPED",54:"CLOSE_UNESCAPED",55:"OPEN_PARTIAL",60:"OPEN_PARTIAL_BLOCK",65:"OPEN_SEXPR",68:"CLOSE_SEXPR",72:"ID",73:"EQUALS",75:"OPEN_BLOCK_PARAMS",77:"CLOSE_BLOCK_PARAMS",80:"STRING",81:"NUMBER",82:"BOOLEAN",83:"UNDEFINED",84:"NULL",85:"DATA",87:"SEP"},productions_:[0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[13,1],[10,3],[16,5],[9,4],[9,4],[24,6],[27,6],[38,6],[43,2],[45,3],[45,1],[26,3],[8,5],[8,5],[11,5],[12,3],[59,5],[63,1],[63,1],[64,5],[69,1],[71,3],[74,3],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[56,1],[56,1],[79,2],[78,1],[86,3],[86,1],[6,0],[6,2],[17,0],[17,2],[21,0],[21,2],[22,0],[22,1],[25,0],[25,1],[28,0],[28,1],[30,0],[30,2],[31,0],[31,1],[32,0],[32,1],[35,0],[35,2],[36,0],[36,1],[37,0],[37,1],[40,0],[40,2],[41,0],[41,1],[42,0],[42,1],[46,0],[46,1],[49,0],[49,2],[50,0],[50,1],[52,0],[52,2],[53,0],[53,1],[57,0],[57,2],[58,0],[58,1],[61,0],[61,2],[62,0],[62,1],[66,0],[66,2],[67,0],[67,1],[70,1],[70,2],[76,1],[76,2]],performAction:function(e,t,r,n,s,i,o){var a=i.length-1;switch(s){case 1:return i[a-1];case 2:this.$=n.prepareProgram(i[a]);break;case 3:case 4:case 5:case 6:case 7:case 8:case 20:case 27:case 28:case 33:case 34:case 40:case 41:this.$=i[a];break;case 9:this.$={type:"CommentStatement",value:n.stripComment(i[a]),strip:n.stripFlags(i[a],i[a]),loc:n.locInfo(this._$)};break;case 10:this.$={type:"ContentStatement",original:i[a],value:i[a],loc:n.locInfo(this._$)};break;case 11:this.$=n.prepareRawBlock(i[a-2],i[a-1],i[a],this._$);break;case 12:this.$={path:i[a-3],params:i[a-2],hash:i[a-1]};break;case 13:this.$=n.prepareBlock(i[a-3],i[a-2],i[a-1],i[a],!1,this._$);break;case 14:this.$=n.prepareBlock(i[a-3],i[a-2],i[a-1],i[a],!0,this._$);break;case 15:this.$={open:i[a-5],path:i[a-4],params:i[a-3],hash:i[a-2],blockParams:i[a-1],strip:n.stripFlags(i[a-5],i[a])};break;case 16:case 17:this.$={path:i[a-4],params:i[a-3],hash:i[a-2],blockParams:i[a-1],strip:n.stripFlags(i[a-5],i[a])};break;case 18:this.$={strip:n.stripFlags(i[a-1],i[a-1]),program:i[a]};break;case 19:var c=n.prepareBlock(i[a-2],i[a-1],i[a],i[a],!1,this._$),l=n.prepareProgram([c],i[a-1].loc);l.chained=!0,this.$={strip:i[a-2].strip,program:l,chain:!0};break;case 21:this.$={path:i[a-1],strip:n.stripFlags(i[a-2],i[a])};break;case 22:case 23:this.$=n.prepareMustache(i[a-3],i[a-2],i[a-1],i[a-4],n.stripFlags(i[a-4],i[a]),this._$);break;case 24:this.$={type:"PartialStatement",name:i[a-3],params:i[a-2],hash:i[a-1],indent:"",strip:n.stripFlags(i[a-4],i[a]),loc:n.locInfo(this._$)};break;case 25:this.$=n.preparePartialBlock(i[a-2],i[a-1],i[a],this._$);break;case 26:this.$={path:i[a-3],params:i[a-2],hash:i[a-1],strip:n.stripFlags(i[a-4],i[a])};break;case 29:this.$={type:"SubExpression",path:i[a-3],params:i[a-2],hash:i[a-1],loc:n.locInfo(this._$)};break;case 30:this.$={type:"Hash",pairs:i[a],loc:n.locInfo(this._$)};break;case 31:this.$={type:"HashPair",key:n.id(i[a-2]),value:i[a],loc:n.locInfo(this._$)};break;case 32:this.$=n.id(i[a-1]);break;case 35:this.$={type:"StringLiteral",value:i[a],original:i[a],loc:n.locInfo(this._$)};break;case 36:this.$={type:"NumberLiteral",value:Number(i[a]),original:Number(i[a]),loc:n.locInfo(this._$)};break;case 37:this.$={type:"BooleanLiteral",value:"true"===i[a],original:"true"===i[a],loc:n.locInfo(this._$)};break;case 38:this.$={type:"UndefinedLiteral",original:void 0,value:void 0,loc:n.locInfo(this._$)};break;case 39:this.$={type:"NullLiteral",original:null,value:null,loc:n.locInfo(this._$)};break;case 42:this.$=n.preparePath(!0,i[a],this._$);break;case 43:this.$=n.preparePath(!1,i[a],this._$);break;case 44:i[a-2].push({part:n.id(i[a]),original:i[a],separator:i[a-1]}),this.$=i[a-2];break;case 45:this.$=[{part:n.id(i[a]),original:i[a]}];break;case 46:case 48:case 50:case 58:case 64:case 70:case 78:case 82:case 86:case 90:case 94:this.$=[];break;case 47:case 49:case 51:case 59:case 65:case 71:case 79:case 83:case 87:case 91:case 95:case 99:case 101:i[a-1].push(i[a]);break;case 98:case 100:this.$=[i[a]]}},table:[{3:1,4:2,5:[2,46],6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:10,13:11,14:[1,12],15:[1,20],16:17,19:[1,23],24:15,27:16,29:[1,21],34:[1,22],39:[2,2],44:[2,2],47:[2,2],48:[1,13],51:[1,14],55:[1,18],59:19,60:[1,24]},{1:[2,1]},{5:[2,47],14:[2,47],15:[2,47],19:[2,47],29:[2,47],34:[2,47],39:[2,47],44:[2,47],47:[2,47],48:[2,47],51:[2,47],55:[2,47],60:[2,47]},{5:[2,3],14:[2,3],15:[2,3],19:[2,3],29:[2,3],34:[2,3],39:[2,3],44:[2,3],47:[2,3],48:[2,3],51:[2,3],55:[2,3],60:[2,3]},{5:[2,4],14:[2,4],15:[2,4],19:[2,4],29:[2,4],34:[2,4],39:[2,4],44:[2,4],47:[2,4],48:[2,4],51:[2,4],55:[2,4],60:[2,4]},{5:[2,5],14:[2,5],15:[2,5],19:[2,5],29:[2,5],34:[2,5],39:[2,5],44:[2,5],47:[2,5],48:[2,5],51:[2,5],55:[2,5],60:[2,5]},{5:[2,6],14:[2,6],15:[2,6],19:[2,6],29:[2,6],34:[2,6],39:[2,6],44:[2,6],47:[2,6],48:[2,6],51:[2,6],55:[2,6],60:[2,6]},{5:[2,7],14:[2,7],15:[2,7],19:[2,7],29:[2,7],34:[2,7],39:[2,7],44:[2,7],47:[2,7],48:[2,7],51:[2,7],55:[2,7],60:[2,7]},{5:[2,8],14:[2,8],15:[2,8],19:[2,8],29:[2,8],34:[2,8],39:[2,8],44:[2,8],47:[2,8],48:[2,8],51:[2,8],55:[2,8],60:[2,8]},{5:[2,9],14:[2,9],15:[2,9],19:[2,9],29:[2,9],34:[2,9],39:[2,9],44:[2,9],47:[2,9],48:[2,9],51:[2,9],55:[2,9],60:[2,9]},{20:25,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:36,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:37,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{4:38,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{15:[2,48],17:39,18:[2,48]},{20:41,56:40,64:42,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:44,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{5:[2,10],14:[2,10],15:[2,10],18:[2,10],19:[2,10],29:[2,10],34:[2,10],39:[2,10],44:[2,10],47:[2,10],48:[2,10],51:[2,10],55:[2,10],60:[2,10]},{20:45,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:46,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:47,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:41,56:48,64:42,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[2,78],49:49,65:[2,78],72:[2,78],80:[2,78],81:[2,78],82:[2,78],83:[2,78],84:[2,78],85:[2,78]},{23:[2,33],33:[2,33],54:[2,33],65:[2,33],68:[2,33],72:[2,33],75:[2,33],80:[2,33],81:[2,33],82:[2,33],83:[2,33],84:[2,33],85:[2,33]},{23:[2,34],33:[2,34],54:[2,34],65:[2,34],68:[2,34],72:[2,34],75:[2,34],80:[2,34],81:[2,34],82:[2,34],83:[2,34],84:[2,34],85:[2,34]},{23:[2,35],33:[2,35],54:[2,35],65:[2,35],68:[2,35],72:[2,35],75:[2,35],80:[2,35],81:[2,35],82:[2,35],83:[2,35],84:[2,35],85:[2,35]},{23:[2,36],33:[2,36],54:[2,36],65:[2,36],68:[2,36],72:[2,36],75:[2,36],80:[2,36],81:[2,36],82:[2,36],83:[2,36],84:[2,36],85:[2,36]},{23:[2,37],33:[2,37],54:[2,37],65:[2,37],68:[2,37],72:[2,37],75:[2,37],80:[2,37],81:[2,37],82:[2,37],83:[2,37],84:[2,37],85:[2,37]},{23:[2,38],33:[2,38],54:[2,38],65:[2,38],68:[2,38],72:[2,38],75:[2,38],80:[2,38],81:[2,38],82:[2,38],83:[2,38],84:[2,38],85:[2,38]},{23:[2,39],33:[2,39],54:[2,39],65:[2,39],68:[2,39],72:[2,39],75:[2,39],80:[2,39],81:[2,39],82:[2,39],83:[2,39],84:[2,39],85:[2,39]},{23:[2,43],33:[2,43],54:[2,43],65:[2,43],68:[2,43],72:[2,43],75:[2,43],80:[2,43],81:[2,43],82:[2,43],83:[2,43],84:[2,43],85:[2,43],87:[1,50]},{72:[1,35],86:51},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{52:52,54:[2,82],65:[2,82],72:[2,82],80:[2,82],81:[2,82],82:[2,82],83:[2,82],84:[2,82],85:[2,82]},{25:53,38:55,39:[1,57],43:56,44:[1,58],45:54,47:[2,54]},{28:59,43:60,44:[1,58],47:[2,56]},{13:62,15:[1,20],18:[1,61]},{33:[2,86],57:63,65:[2,86],72:[2,86],80:[2,86],81:[2,86],82:[2,86],83:[2,86],84:[2,86],85:[2,86]},{33:[2,40],65:[2,40],72:[2,40],80:[2,40],81:[2,40],82:[2,40],83:[2,40],84:[2,40],85:[2,40]},{33:[2,41],65:[2,41],72:[2,41],80:[2,41],81:[2,41],82:[2,41],83:[2,41],84:[2,41],85:[2,41]},{20:64,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:65,47:[1,66]},{30:67,33:[2,58],65:[2,58],72:[2,58],75:[2,58],80:[2,58],81:[2,58],82:[2,58],83:[2,58],84:[2,58],85:[2,58]},{33:[2,64],35:68,65:[2,64],72:[2,64],75:[2,64],80:[2,64],81:[2,64],82:[2,64],83:[2,64],84:[2,64],85:[2,64]},{21:69,23:[2,50],65:[2,50],72:[2,50],80:[2,50],81:[2,50],82:[2,50],83:[2,50],84:[2,50],85:[2,50]},{33:[2,90],61:70,65:[2,90],72:[2,90],80:[2,90],81:[2,90],82:[2,90],83:[2,90],84:[2,90],85:[2,90]},{20:74,33:[2,80],50:71,63:72,64:75,65:[1,43],69:73,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{72:[1,79]},{23:[2,42],33:[2,42],54:[2,42],65:[2,42],68:[2,42],72:[2,42],75:[2,42],80:[2,42],81:[2,42],82:[2,42],83:[2,42],84:[2,42],85:[2,42],87:[1,50]},{20:74,53:80,54:[2,84],63:81,64:75,65:[1,43],69:82,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:83,47:[1,66]},{47:[2,55]},{4:84,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{47:[2,20]},{20:85,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:86,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{26:87,47:[1,66]},{47:[2,57]},{5:[2,11],14:[2,11],15:[2,11],19:[2,11],29:[2,11],34:[2,11],39:[2,11],44:[2,11],47:[2,11],48:[2,11],51:[2,11],55:[2,11],60:[2,11]},{15:[2,49],18:[2,49]},{20:74,33:[2,88],58:88,63:89,64:75,65:[1,43],69:90,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{65:[2,94],66:91,68:[2,94],72:[2,94],80:[2,94],81:[2,94],82:[2,94],83:[2,94],84:[2,94],85:[2,94]},{5:[2,25],14:[2,25],15:[2,25],19:[2,25],29:[2,25],34:[2,25],39:[2,25],44:[2,25],47:[2,25],48:[2,25],51:[2,25],55:[2,25],60:[2,25]},{20:92,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,31:93,33:[2,60],63:94,64:75,65:[1,43],69:95,70:76,71:77,72:[1,78],75:[2,60],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,33:[2,66],36:96,63:97,64:75,65:[1,43],69:98,70:76,71:77,72:[1,78],75:[2,66],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,22:99,23:[2,52],63:100,64:75,65:[1,43],69:101,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:74,33:[2,92],62:102,63:103,64:75,65:[1,43],69:104,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,105]},{33:[2,79],65:[2,79],72:[2,79],80:[2,79],81:[2,79],82:[2,79],83:[2,79],84:[2,79],85:[2,79]},{33:[2,81]},{23:[2,27],33:[2,27],54:[2,27],65:[2,27],68:[2,27],72:[2,27],75:[2,27],80:[2,27],81:[2,27],82:[2,27],83:[2,27],84:[2,27],85:[2,27]},{23:[2,28],33:[2,28],54:[2,28],65:[2,28],68:[2,28],72:[2,28],75:[2,28],80:[2,28],81:[2,28],82:[2,28],83:[2,28],84:[2,28],85:[2,28]},{23:[2,30],33:[2,30],54:[2,30],68:[2,30],71:106,72:[1,107],75:[2,30]},{23:[2,98],33:[2,98],54:[2,98],68:[2,98],72:[2,98],75:[2,98]},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],73:[1,108],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{23:[2,44],33:[2,44],54:[2,44],65:[2,44],68:[2,44],72:[2,44],75:[2,44],80:[2,44],81:[2,44],82:[2,44],83:[2,44],84:[2,44],85:[2,44],87:[2,44]},{54:[1,109]},{54:[2,83],65:[2,83],72:[2,83],80:[2,83],81:[2,83],82:[2,83],83:[2,83],84:[2,83],85:[2,83]},{54:[2,85]},{5:[2,13],14:[2,13],15:[2,13],19:[2,13],29:[2,13],34:[2,13],39:[2,13],44:[2,13],47:[2,13],48:[2,13],51:[2,13],55:[2,13],60:[2,13]},{38:55,39:[1,57],43:56,44:[1,58],45:111,46:110,47:[2,76]},{33:[2,70],40:112,65:[2,70],72:[2,70],75:[2,70],80:[2,70],81:[2,70],82:[2,70],83:[2,70],84:[2,70],85:[2,70]},{47:[2,18]},{5:[2,14],14:[2,14],15:[2,14],19:[2,14],29:[2,14],34:[2,14],39:[2,14],44:[2,14],47:[2,14],48:[2,14],51:[2,14],55:[2,14],60:[2,14]},{33:[1,113]},{33:[2,87],65:[2,87],72:[2,87],80:[2,87],81:[2,87],82:[2,87],83:[2,87],84:[2,87],85:[2,87]},{33:[2,89]},{20:74,63:115,64:75,65:[1,43],67:114,68:[2,96],69:116,70:76,71:77,72:[1,78],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,117]},{32:118,33:[2,62],74:119,75:[1,120]},{33:[2,59],65:[2,59],72:[2,59],75:[2,59],80:[2,59],81:[2,59],82:[2,59],83:[2,59],84:[2,59],85:[2,59]},{33:[2,61],75:[2,61]},{33:[2,68],37:121,74:122,75:[1,120]},{33:[2,65],65:[2,65],72:[2,65],75:[2,65],80:[2,65],81:[2,65],82:[2,65],83:[2,65],84:[2,65],85:[2,65]},{33:[2,67],75:[2,67]},{23:[1,123]},{23:[2,51],65:[2,51],72:[2,51],80:[2,51],81:[2,51],82:[2,51],83:[2,51],84:[2,51],85:[2,51]},{23:[2,53]},{33:[1,124]},{33:[2,91],65:[2,91],72:[2,91],80:[2,91],81:[2,91],82:[2,91],83:[2,91],84:[2,91],85:[2,91]},{33:[2,93]},{5:[2,22],14:[2,22],15:[2,22],19:[2,22],29:[2,22],34:[2,22],39:[2,22],44:[2,22],47:[2,22],48:[2,22],51:[2,22],55:[2,22],60:[2,22]},{23:[2,99],33:[2,99],54:[2,99],68:[2,99],72:[2,99],75:[2,99]},{73:[1,108]},{20:74,63:125,64:75,65:[1,43],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,23],14:[2,23],15:[2,23],19:[2,23],29:[2,23],34:[2,23],39:[2,23],44:[2,23],47:[2,23],48:[2,23],51:[2,23],55:[2,23],60:[2,23]},{47:[2,19]},{47:[2,77]},{20:74,33:[2,72],41:126,63:127,64:75,65:[1,43],69:128,70:76,71:77,72:[1,78],75:[2,72],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,24],14:[2,24],15:[2,24],19:[2,24],29:[2,24],34:[2,24],39:[2,24],44:[2,24],47:[2,24],48:[2,24],51:[2,24],55:[2,24],60:[2,24]},{68:[1,129]},{65:[2,95],68:[2,95],72:[2,95],80:[2,95],81:[2,95],82:[2,95],83:[2,95],84:[2,95],85:[2,95]},{68:[2,97]},{5:[2,21],14:[2,21],15:[2,21],19:[2,21],29:[2,21],34:[2,21],39:[2,21],44:[2,21],47:[2,21],48:[2,21],51:[2,21],55:[2,21],60:[2,21]},{33:[1,130]},{33:[2,63]},{72:[1,132],76:131},{33:[1,133]},{33:[2,69]},{15:[2,12],18:[2,12]},{14:[2,26],15:[2,26],19:[2,26],29:[2,26],34:[2,26],47:[2,26],48:[2,26],51:[2,26],55:[2,26],60:[2,26]},{23:[2,31],33:[2,31],54:[2,31],68:[2,31],72:[2,31],75:[2,31]},{33:[2,74],42:134,74:135,75:[1,120]},{33:[2,71],65:[2,71],72:[2,71],75:[2,71],80:[2,71],81:[2,71],82:[2,71],83:[2,71],84:[2,71],85:[2,71]},{33:[2,73],75:[2,73]},{23:[2,29],33:[2,29],54:[2,29],65:[2,29],68:[2,29],72:[2,29],75:[2,29],80:[2,29],81:[2,29],82:[2,29],83:[2,29],84:[2,29],85:[2,29]},{14:[2,15],15:[2,15],19:[2,15],29:[2,15],34:[2,15],39:[2,15],44:[2,15],47:[2,15],48:[2,15],51:[2,15],55:[2,15],60:[2,15]},{72:[1,137],77:[1,136]},{72:[2,100],77:[2,100]},{14:[2,16],15:[2,16],19:[2,16],29:[2,16],34:[2,16],44:[2,16],47:[2,16],48:[2,16],51:[2,16],55:[2,16],60:[2,16]},{33:[1,138]},{33:[2,75]},{33:[2,32]},{72:[2,101],77:[2,101]},{14:[2,17],15:[2,17],19:[2,17],29:[2,17],34:[2,17],39:[2,17],44:[2,17],47:[2,17],48:[2,17],51:[2,17],55:[2,17],60:[2,17]}],defaultActions:{4:[2,1],54:[2,55],56:[2,20],60:[2,57],73:[2,81],82:[2,85],86:[2,18],90:[2,89],101:[2,53],104:[2,93],110:[2,19],111:[2,77],116:[2,97],119:[2,63],122:[2,69],135:[2,75],136:[2,32]},parseError:function(e,t){throw new Error(e)},parse:function(e){var t=[0],r=[null],n=[],s=this.table,i="",o=0,a=0,c=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var l=this.lexer.yylloc;n.push(l);var u=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var d,h,p,f,m,g,y,v,b,S,C={};;){if(p=t[t.length-1],this.defaultActions[p]?f=this.defaultActions[p]:(null==d&&(S=void 0,"number"!=typeof(S=this.lexer.lex()||1)&&(S=this.symbols_[S]||S),d=S),f=s[p]&&s[p][d]),void 0===f||!f.length||!f[0]){var w="";if(!c){for(g in b=[],s[p])this.terminals_[g]&&g>2&&b.push("'"+this.terminals_[g]+"'");w=this.lexer.showPosition?"Parse error on line "+(o+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[d]||d)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==d?"end of input":"'"+(this.terminals_[d]||d)+"'"),this.parseError(w,{text:this.lexer.match,token:this.terminals_[d]||d,line:this.lexer.yylineno,loc:l,expected:b})}}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+d);switch(f[0]){case 1:t.push(d),r.push(this.lexer.yytext),n.push(this.lexer.yylloc),t.push(f[1]),d=null,h?(d=h,h=null):(a=this.lexer.yyleng,i=this.lexer.yytext,o=this.lexer.yylineno,l=this.lexer.yylloc,c>0&&c--);break;case 2:if(y=this.productions_[f[1]][1],C.$=r[r.length-y],C._$={first_line:n[n.length-(y||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(y||1)].first_column,last_column:n[n.length-1].last_column},u&&(C._$.range=[n[n.length-(y||1)].range[0],n[n.length-1].range[1]]),void 0!==(m=this.performAction.call(C,i,a,o,this.yy,f[1],r,n)))return m;y&&(t=t.slice(0,-1*y*2),r=r.slice(0,-1*y),n=n.slice(0,-1*y)),t.push(this.productions_[f[1]][0]),r.push(C.$),n.push(C._$),v=s[t[t.length-2]][t[t.length-1]],t.push(v);break;case 3:return!0}}return!0}},t={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;var e,t,r,n,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;ot[0].length)||(t=r,n=o,this.options.flex));o++);return t?((s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,i[n],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return void 0!==e?e:this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(e){this.begin(e)},options:{},performAction:function(e,t,r,n){function s(e,r){return t.yytext=t.yytext.substring(e,t.yyleng-r+e)}switch(r){case 0:if("\\\\"===t.yytext.slice(-2)?(s(0,1),this.begin("mu")):"\\"===t.yytext.slice(-1)?(s(0,1),this.begin("emu")):this.begin("mu"),t.yytext)return 15;break;case 1:case 5:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(s(5,9),"END_RAW_BLOCK");case 6:case 22:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:case 23:return 48;case 21:this.unput(t.yytext),this.popState(),this.begin("com");break;case 24:return 73;case 25:case 26:case 41:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return t.yytext=s(1,2).replace(/\\"/g,'"'),80;case 32:return t.yytext=s(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 42:return t.yytext=t.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};function r(){this.yy={}}return e.lexer=t,r.prototype=e,e.Parser=r,new r}();t.default=r,e.exports=t.default},1350:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=(n=r(3769))&&n.__esModule?n:{default:n};function i(){this.parents=[]}function o(e){this.acceptRequired(e,"path"),this.acceptArray(e.params),this.acceptKey(e,"hash")}function a(e){o.call(this,e),this.acceptKey(e,"program"),this.acceptKey(e,"inverse")}function c(e){this.acceptRequired(e,"name"),this.acceptArray(e.params),this.acceptKey(e,"hash")}i.prototype={constructor:i,mutating:!1,acceptKey:function(e,t){var r=this.accept(e[t]);if(this.mutating){if(r&&!i.prototype[r.type])throw new s.default('Unexpected node type "'+r.type+'" found when accepting '+t+" on "+e.type);e[t]=r}},acceptRequired:function(e,t){if(this.acceptKey(e,t),!e[t])throw new s.default(e.type+" requires "+t)},acceptArray:function(e){for(var t=0,r=e.length;t{"use strict";t.__esModule=!0;var n,s=(n=r(1350))&&n.__esModule?n:{default:n};function i(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=e}function o(e,t,r){void 0===t&&(t=e.length);var n=e[t-1],s=e[t-2];return n?"ContentStatement"===n.type?(s||!r?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(n.original):void 0:r}function a(e,t,r){void 0===t&&(t=-1);var n=e[t+1],s=e[t+2];return n?"ContentStatement"===n.type?(s||!r?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(n.original):void 0:r}function c(e,t,r){var n=e[null==t?0:t+1];if(n&&"ContentStatement"===n.type&&(r||!n.rightStripped)){var s=n.value;n.value=n.value.replace(r?/^\s+/:/^[ \t]*\r?\n?/,""),n.rightStripped=n.value!==s}}function l(e,t,r){var n=e[null==t?e.length-1:t-1];if(n&&"ContentStatement"===n.type&&(r||!n.leftStripped)){var s=n.value;return n.value=n.value.replace(r?/\s+$/:/[ \t]+$/,""),n.leftStripped=n.value!==s,n.leftStripped}}i.prototype=new s.default,i.prototype.Program=function(e){var t=!this.options.ignoreStandalone,r=!this.isRootSeen;this.isRootSeen=!0;for(var n=e.body,s=0,i=n.length;s{"use strict";t.__esModule=!0,t.registerDefaultDecorators=function(e){s.default(e)};var n,s=(n=r(7430))&&n.__esModule?n:{default:n}},7430:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849);t.default=function(e){e.registerDecorator("inline",(function(e,t,r,s){var i=e;return t.partials||(t.partials={},i=function(s,i){var o=r.partials;r.partials=n.extend({},o,t.partials);var a=e(s,i);return r.partials=o,a}),t.partials[s.args[0]]=s.fn,i}))},e.exports=t.default},3769:(e,t)=>{"use strict";t.__esModule=!0;var r=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function n(e,t){var s=t&&t.loc,i=void 0,o=void 0,a=void 0,c=void 0;s&&(i=s.start.line,o=s.end.line,a=s.start.column,c=s.end.column,e+=" - "+i+":"+a);for(var l=Error.prototype.constructor.call(this,e),u=0;u{"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.registerDefaultHelpers=function(e){s.default(e),i.default(e),o.default(e),a.default(e),c.default(e),l.default(e),u.default(e)},t.moveHelperToHooks=function(e,t,r){e.helpers[t]&&(e.hooks[t]=e.helpers[t],r||delete e.helpers[t])};var s=n(r(6097)),i=n(r(6785)),o=n(r(4353)),a=n(r(2355)),c=n(r(5300)),l=n(r(7466)),u=n(r(908))},6097:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849);t.default=function(e){e.registerHelper("blockHelperMissing",(function(t,r){var s=r.inverse,i=r.fn;if(!0===t)return i(this);if(!1===t||null==t)return s(this);if(n.isArray(t))return t.length>0?(r.ids&&(r.ids=[r.name]),e.helpers.each(t,r)):s(this);if(r.data&&r.ids){var o=n.createFrame(r.data);o.contextPath=n.appendContextPath(r.data.contextPath,r.name),r={data:o}}return i(t,r)}))},e.exports=t.default},6785:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("each",(function(e,t){if(!t)throw new i.default("Must pass iterator to #each");var r,n=t.fn,o=t.inverse,a=0,c="",l=void 0,u=void 0;function d(t,r,i){l&&(l.key=t,l.index=r,l.first=0===r,l.last=!!i,u&&(l.contextPath=u+t)),c+=n(e[t],{data:l,blockParams:s.blockParams([e[t],t],[u+t,null])})}if(t.data&&t.ids&&(u=s.appendContextPath(t.data.contextPath,t.ids[0])+"."),s.isFunction(e)&&(e=e.call(this)),t.data&&(l=s.createFrame(t.data)),e&&"object"==typeof e)if(s.isArray(e))for(var h=e.length;a{"use strict";t.__esModule=!0;var n,s=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("helperMissing",(function(){if(1!==arguments.length)throw new s.default('Missing helper: "'+arguments[arguments.length-1].name+'"')}))},e.exports=t.default},2355:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("if",(function(e,t){if(2!=arguments.length)throw new i.default("#if requires exactly one argument");return s.isFunction(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||s.isEmpty(e)?t.inverse(this):t.fn(this)})),e.registerHelper("unless",(function(t,r){if(2!=arguments.length)throw new i.default("#unless requires exactly one argument");return e.helpers.if.call(this,t,{fn:r.inverse,inverse:r.fn,hash:r.hash})}))},e.exports=t.default},5300:(e,t)=>{"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("log",(function(){for(var t=[void 0],r=arguments[arguments.length-1],n=0;n{"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("lookup",(function(e,t,r){return e?r.lookupProperty(e,t):e}))},e.exports=t.default},908:(e,t,r)=>{"use strict";t.__esModule=!0;var n,s=r(2849),i=(n=r(3769))&&n.__esModule?n:{default:n};t.default=function(e){e.registerHelper("with",(function(e,t){if(2!=arguments.length)throw new i.default("#with requires exactly one argument");s.isFunction(e)&&(e=e.call(this));var r=t.fn;if(s.isEmpty(e))return t.inverse(this);var n=t.data;return t.data&&t.ids&&((n=s.createFrame(t.data)).contextPath=s.appendContextPath(t.data.contextPath,t.ids[0])),r(e,{data:n,blockParams:s.blockParams([e],[n&&n.contextPath])})}))},e.exports=t.default},9726:(e,t,r)=>{"use strict";t.__esModule=!0,t.createNewLookupObject=function(){for(var e=arguments.length,t=Array(e),r=0;r{"use strict";t.__esModule=!0,t.createProtoAccessControl=function(e){var t=Object.create(null);t.constructor=!1,t.__defineGetter__=!1,t.__defineSetter__=!1,t.__lookupGetter__=!1;var r=Object.create(null);return r.__proto__=!1,{properties:{whitelist:s.createNewLookupObject(r,e.allowedProtoProperties),defaultValue:e.allowProtoPropertiesByDefault},methods:{whitelist:s.createNewLookupObject(t,e.allowedProtoMethods),defaultValue:e.allowProtoMethodsByDefault}}},t.resultIsAllowed=function(e,t,r){return function(e,t){return void 0!==e.whitelist[t]?!0===e.whitelist[t]:void 0!==e.defaultValue?e.defaultValue:(function(e){!0!==o[e]&&(o[e]=!0,i.default.log("error",'Handlebars: Access has been denied to resolve the property "'+e+'" because it is not an "own property" of its parent.\nYou can add a runtime option to disable the check or this warning:\nSee https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details'))}(t),!1)}("function"==typeof e?t.methods:t.properties,r)},t.resetLoggedProperties=function(){Object.keys(o).forEach((function(e){delete o[e]}))};var n,s=r(9726),i=(n=r(566))&&n.__esModule?n:{default:n},o=Object.create(null)},2614:(e,t)=>{"use strict";t.__esModule=!0,t.wrapHelper=function(e,t){return"function"!=typeof e?e:function(){return arguments[arguments.length-1]=t(arguments[arguments.length-1]),e.apply(this,arguments)}}},566:(e,t,r)=>{"use strict";t.__esModule=!0;var n=r(2849),s={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(e){if("string"==typeof e){var t=n.indexOf(s.methodMap,e.toLowerCase());e=t>=0?t:parseInt(e,10)}return e},log:function(e){if(e=s.lookupLevel(e),"undefined"!=typeof console&&s.lookupLevel(s.level)<=e){var t=s.methodMap[e];console[t]||(t="log");for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i{"use strict";t.__esModule=!0,t.default=function(e){"object"!=typeof globalThis&&(Object.prototype.__defineGetter__("__magic__",(function(){return this})),__magic__.globalThis=__magic__,delete Object.prototype.__magic__);var t=globalThis.Handlebars;e.noConflict=function(){return globalThis.Handlebars===e&&(globalThis.Handlebars=t),e}},e.exports=t.default},7624:(e,t,r)=>{"use strict";t.__esModule=!0,t.checkRevision=function(e){var t=e&&e[0]||1,r=o.COMPILER_REVISION;if(!(t>=o.LAST_COMPATIBLE_COMPILER_REVISION&&t<=o.COMPILER_REVISION)){if(t{"use strict";function r(e){this.string=e}t.__esModule=!0,r.prototype.toString=r.prototype.toHTML=function(){return""+this.string},t.default=r,e.exports=t.default},2849:(e,t)=>{"use strict";t.__esModule=!0,t.extend=o,t.indexOf=function(e,t){for(var r=0,n=e.length;r":">",'"':""","'":"'","`":"`","=":"="},n=/[&<>"'`=]/g,s=/[&<>"'`=]/;function i(e){return r[e]}function o(e){for(var t=1;t{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},8287:e=>{"use strict";e.exports=function(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,r){let n=-1;return function s(i){if(i<=n)return Promise.reject(new Error("next() called multiple times"));n=i;let o=e[i];if(i===e.length&&(o=r),!o)return Promise.resolve();try{return Promise.resolve(o(t,s.bind(null,i+1)))}catch(e){return Promise.reject(e)}}(0)}}},8775:(e,t,r)=>{"use strict";var n=r(8712),s=n.escapeXML,i=n.escapeXMLText,o=r(3255),a=o.equal,c=o.name,l=o.attrs,u=o.children,d=r(3942);function h(e,t){this.name=e,this.parent=null,this.children=[],this.attrs={},this.setAttrs(t)}h.prototype.is=function(e,t){return this.getName()===e&&(!t||this.getNS()===t)},h.prototype.getName=function(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name},h.prototype.getNS=function(){if(this.name.indexOf(":")>=0){var e=this.name.substr(0,this.name.indexOf(":"));return this.findNS(e)}return this.findNS()},h.prototype.findNS=function(e){if(e){var t="xmlns:"+e;if(this.attrs[t])return this.attrs[t];if(this.parent)return this.parent.findNS(e)}else{if(this.attrs.xmlns)return this.attrs.xmlns;if(this.parent)return this.parent.findNS()}},h.prototype.getXmlns=function(){var e={};for(var t in this.parent&&(e=this.parent.getXmlns()),this.attrs){var r=t.match("xmlns:?(.*)");this.attrs.hasOwnProperty(t)&&r&&(e[this.attrs[t]]=r[1])}return e},h.prototype.setAttrs=function(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach((function(t){this.attrs[t]=e[t]}),this)},h.prototype.getAttr=function(e,t){if(!t)return this.attrs[e];var r=this.getXmlns();return r[t]?this.attrs[[r[t],e].join(":")]:null},h.prototype.getChild=function(e,t){return this.getChildren(e,t)[0]},h.prototype.getChildren=function(e,t){for(var r=[],n=0;n");for(var t=0;t")},h.prototype.write=function(e){for(var t in e("<"),e(this.name),this.attrs){var r=this.attrs[t];null!=r&&(e(" "),e(t),e('="'),"string"!=typeof r&&(r=r.toString()),e(s(r)),e('"'))}0===this.children.length?e("/>"):this._addChildren(e)},h.prototype.nameEquals=function(e){return c(this,e)},h.prototype.attrsEquals=function(e){return l(this,e)},h.prototype.childrenEquals=function(e){return u(this,e)},h.prototype.equals=function(e){return a(this,e)},e.exports=h},3942:e=>{"use strict";e.exports=function(e){for(var t=new e.constructor(e.name,e.attrs),r=0;r{"use strict";function t(e,t){return e.name===t.name}function r(e,t){var r=e.attrs,n=Object.keys(r),s=n.length;if(s!==Object.keys(t.attrs).length)return!1;for(var i=0,o=s;i{"use strict";var r={"&":"&","<":"<",">":">",'"':""","'":"'"};function n(e){return r[e]}var s={"&":"&","<":"<",">":">",""":'"',"'":"'"};function i(e){if("#"===e[1]){var t;if(9===(t="x"===e[2]?parseInt(e.slice(3),16):parseInt(e.slice(2),10))||10===t||13===t||t>=32&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111)return String.fromCodePoint(t);throw new Error("Illegal XML character 0x"+t.toString(16))}if(s[e])return s[e]||e;throw new Error("Illegal XML entity "+e)}t.escapeXML=function(e){return e.replace(/&|<|>|"|'/g,n)},t.unescapeXML=function(e){for(var t="",r=-1,n=-1,s=0;-1!==(r=e.indexOf("&",s))&&-1!==(n=e.indexOf(";",r+1));)t=t+e.substring(s,r)+i(e.substring(r,n+1)),s=n+1;return 0===s?e:t+=e.substring(s)},t.escapeXMLText=function(e){return e.replace(/&|<|>/g,n)},t.unescapeXMLText=function(e){return e.replace(/&(amp|#38|lt|#60|gt|#62);/g,i)}},9416:(e,t,r)=>{"use strict";var n=r(6698),s=r(7007).EventEmitter,i=r(8712).unescapeXML,o=e.exports=function(){s.call(this);var e,t,r,n,o,a,c,l,u=0,d=0;this._handleTagOpening=function(e,t,r){e?this.emit("endElement",t):(this.emit("startElement",t,r),o&&this.emit("endElement",t))},this.write=function(s){"string"!=typeof s&&(s=s.toString());var h=0;function p(){if("number"==typeof d){var e=s.substring(d,h);return d=void 0,e}}for(e&&(s=e+s,h+=e.length,e=null);h",h);-1!==y&&(h=y+2)}var v=s.charCodeAt(h);switch(u){case 0:if(60===v){var b=p();b&&this.emit("text",i(b)),u=3,d=h+1,r={}}break;case 9:if(93===v&&"]>"===s.substr(h+1,2)){var S=p();S&&this.emit("text",S),u=0}break;case 3:47===v&&d===h?(d=h+1,n=!0):33===v?"[CDATA["===s.substr(h+1,7)?(d=h+8,u=9):(d=void 0,u=1):63===v?(d=void 0,u=2):(v<=32||47===v||62===v)&&(t=p(),h--,u=4);break;case 1:if(62===v){var C=s.charCodeAt(h-1),w=s.charCodeAt(h-2);(45===C&&45===w||93===C&&93===w)&&(u=0)}break;case 2:62===v&&63===s.charCodeAt(h-1)&&(u=0);break;case 4:62===v?(this._handleTagOpening(n,t,r),t=void 0,r=void 0,n=void 0,o=void 0,u=0,d=h+1):47===v?o=!0:v>32&&(d=h,u=5);break;case 5:(v<=32||61===v)&&(l=p(),h--,u=6);break;case 6:61===v&&(u=7);break;case 7:34!==v&&39!==v||(a=v,c=34===v?'"':"'",u=8,d=h+1);break;case 8:if(v===a){var k=i(p());r[l]=k,l=void 0,u=4}}}"number"==typeof d&&d<=s.length&&(e=s.slice(d),d=0)}};n(o,s),o.prototype.end=function(e){e&&this.write(e),this.write=function(){}}},4011:function(e,t,r){!function(e,t){function r(){}r.prototype.name="ANONYMOUS",r.prototype.clientFirst=!0,r.prototype.response=function(e){return e.trace||""},r.prototype.challenge=function(e){},t.exports=r}(0,e=r.nmd(e))},3481:function(e,t,r){!function(e,t,r){(t.exports=r).Mechanism=r}(0,e=r.nmd(e),r(4011))},7474:function(e,t,r){!function(e,t){function r(){}r.prototype.name="PLAIN",r.prototype.clientFirst=!0,r.prototype.response=function(e){var t="";return t+=e.authzid||"",t+="\0",t+=e.username,(t+="\0")+e.password},r.prototype.challenge=function(e){return this},t.exports=r}(0,e=r.nmd(e))},1978:function(e,t,r){!function(e,t,r){(t.exports=r).Mechanism=r}(0,e=r.nmd(e),r(7474))},2074:function(e,t,r){!function(e,t){function r(){this._mechs=[]}r.prototype.use=function(e,t){return t||(e=(t=e).prototype.name),this._mechs.push({name:e,mech:t}),this},r.prototype.create=function(e){for(var t=0,r=this._mechs.length;t{"use strict";e.exports=t},8849:t=>{"use strict";t.exports=e},2969:()=>{},732:()=>{},477:()=>{},2122:e=>{"use strict";e.exports={rE:"3.32.0"}}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}return s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e=s(639),t=s.n(e),r=s(1605),n=s.n(r),i={appId:385,authKey:"DFBMs5-dKBBCXcd",authSecret:"SkCW-ThdnmRg9Za"},o={debug:{mode:1},videochat:{disconnectTimeInterval:300},endpoints:{api:"api.connectycube.com",chat:"chat.connectycube.com"},conference:{server:"wss://janus.connectycube.com:8989"}},a=[{id:72780,name:"Alice",login:"videouser1",password:"videouser1",color:"#34ad86"},{id:72781,name:"Bob",login:"videouser2",password:"videouser2",color:"#077988"},{id:590565,name:"Ciri",login:"videouser3",password:"videouser3",color:"#13aaae"},{id:590583,name:"Dexter",login:"videouser4",password:"videouser4",color:"#056a96"}];function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function l(e,t){for(var r=0;r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return s("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),D(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var s=n.arg;D(r)}return s}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:O(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function v(e,t,r,n,s,i,o){try{var a=e[i](o),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,s)}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function w(e,t){if(e){if("string"==typeof e)return k(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0){var e,t=C(r.needIceRestartForUsersIds);try{for(t.s();!(e=t.n()).done;){var n=e.value;r.maybeDoIceRestart(r._session,n)}}catch(e){t.e(e)}finally{t.f()}}r.isOnline=!0}})),x(this,"$calling",document.getElementById("signal-in")),x(this,"$dialing",document.getElementById("signal-out")),x(this,"$endCall",document.getElementById("signal-end")),x(this,"$modal",document.getElementById("call-modal-incoming")),x(this,"$muteUnmuteButton",document.getElementById("videochat-mute-unmute")),x(this,"$switchCameraButton",document.getElementById("videochat-switch-camera")),x(this,"$switchSharingScreenButton",document.getElementById("videochat-sharing-screen")),x(this,"mediaParams",{audio:!0,video:!0,elementId:"localStream",options:{muted:!0,mirror:!0}}),x(this,"sharingScreenMediaParams",{audio:!0,video:{frameRate:{ideal:10,max:15}},elementId:"localStream",options:{muted:!0,mirror:!1}}),x(this,"_session",null),x(this,"mediaDevicesIds",[]),x(this,"activeDeviceId",null),x(this,"isAudioMuted",!1),x(this,"isSharingScreen",!1),x(this,"startEventSharinScreen",null),x(this,"defaultSettings",(function(){T&&(r.$switchSharingScreenButton.disabled=!0)})),x(this,"addStreamElements",(function(e){var r=document.getElementById("videochat-streams"),n=document.getElementById("videochat-streams-template"),s=t().compile(n.innerHTML);2===e.length?r.classList.value="grid-2-1":3===e.length&&(r.classList.value="grid-2-2"),document.getElementById("call").classList.add("hidden"),document.getElementById("videochat").classList.remove("hidden"),r.innerHTML=s({opponents:e})})),x(this,"onCallListener",(function(e,t){return e.initiatorID!==e.currentUserID&&(r._session?(r.rejectCall(e,{busy:!0}),!1):(r._session=e,void r.showIncomingCallModal()))})),x(this,"onAcceptCallListener",(function(e,t,n){if(t===e.currentUserID)return r.$modal.classList.contains("show")&&(r._session=null,r.hideIncomingCallModal(),r.showSnackbar("You have accepted the call on other side")),!1;var s=r._getUserById(t,"name"),i="".concat(s," has accepted the call");r.showSnackbar(i),r.$dialing.pause()})),x(this,"onRejectCallListener",(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t===e.currentUserID)return r.$modal.classList.contains("show")&&(r._session=null,r.hideIncomingCallModal(),r.showSnackbar("You have rejected the call on other side")),!1;var s=r._getUserById(t,"name"),i=n.busy?"".concat(s," is busy"):"".concat(s," rejected the call request");r.stopCall(t),r.showSnackbar(i)})),x(this,"onStopCallListener",(function(e,t,n){if(!r._session)return!1;var s=e.initiatorID===t,i=r._getUserById(t,"name"),o="".concat(i," has ").concat(s?"stopped":"left"," the call");r.showSnackbar(o),s?(r.$modal.classList.contains("show")&&r.hideIncomingCallModal(),r.stopCall()):r.stopCall(t)})),x(this,"onUserNotAnswerListener",(function(e,t){if(!r._session)return!1;var n=r._getUserById(t,"name"),s="".concat(n," did not answer");r.showSnackbar(s),r.stopCall(t)})),x(this,"onRemoteStreamListener",(function(e,t,n){if(!r._session)return!1;var s="remoteStream-".concat(t);document.getElementById("videochat-stream-loader-".concat(t)).remove(),r._session.attachMediaStream(s,n),r.$muteUnmuteButton.disabled=!1,r.onDevicesChangeListener(),r._prepareVideoElement(s)})),x(this,"acceptCall",(function(){var e={},t=r._session,s=t.opponentsIDs,i=t.initiatorID,o=t.currentUserID,a=t.callType,c=[i].concat(function(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(s)).filter((function(e){return o!==e})).map((function(e){return{id:e,name:r._getUserById(e,"name")}}));r.defaultSettings(),r.addStreamElements(c),r.hideIncomingCallModal();var l=S({},r.mediaParams);a===n().videochat.CallType.AUDIO&&delete l.video,r._session.getUserMedia(l).then((function(t){r._session.getDisplayMedia&&a!==n().videochat.CallType.AUDIO||(r.$switchSharingScreenButton.disabled=!0),r._session.accept(e),r.setActiveDeviceId(t),r._prepareVideoElement("localStream")}))})),x(this,"rejectCall",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e?e.reject(t):(r._session.reject(t),r._session=null,r.hideIncomingCallModal())})),x(this,"startAudioCall",(function(){r.startCall(n().videochat.CallType.AUDIO)})),x(this,"startVideoCall",(function(){r.startCall(n().videochat.CallType.VIDEO)})),x(this,"startCall",(function(e){var t=[],s=[];if(r.defaultSettings(),document.querySelectorAll(".select-user-checkbox").forEach((function(e){if(e.checked){var n=+e.dataset.id,i=r._getUserById(n,"name");t.push({id:n,name:i}),s.push(n),e.checked=!1}})),t.length>0){document.getElementById("call").classList.add("hidden"),document.getElementById("videochat").classList.remove("hidden"),r.$dialing.play(),r.addStreamElements(t),r._session=n().videochat.createNewSession(s,e,{}),console.log("startCall",{callType:e},n().videochat.CallType.AUDIO);var i=S({},r.mediaParams);e===n().videochat.CallType.AUDIO&&delete i.video,r._session.getUserMedia(i).then((function(t){r._session.getDisplayMedia&&e!==n().videochat.CallType.AUDIO||(r.$switchSharingScreenButton.disabled=!0),r._session.call({}),r.setActiveDeviceId(t),r._prepareVideoElement("localStream")}));var o=r._getUserById(r._session.initiatorID,"name"),a={message:"Incoming call from ".concat(o),ios_voip:1,initiatorId:r._session.initiatorID,opponentsIds:s.join(","),handle:o,uuid:r._session.ID,callType:e===n().videochat.CallType.VIDEO?"video":"audio"},c=JSON.stringify(a),l={notification_type:"push",user:{ids:s},message:n().pushnotifications.base64Encode(c)};n().pushnotifications.events.create(l).then((function(e){console.log("[sendPushNotification] Ok")})).catch((function(e){console.warn("[sendPushNotification] Error",e)}))}else r.showSnackbar("Select at less one user to start Videocall")})),x(this,"stopCall",(function(e){var t=document.getElementById("call"),s=document.getElementById("videochat"),i=document.getElementById("videochat-mute-unmute"),o=document.getElementById("videochat-streams");if(e){document.getElementById("videochat-stream-container-".concat(e)).remove();var a=document.querySelectorAll(".videochat-stream-container");a.length<2?r.stopCall():2===a.length?o.classList.value="":3===a.length&&(o.classList.value="grid-2-1")}else if(r._session){var c,l=C(document.getElementById("localStream").srcObject.getTracks());try{for(l.s();!(c=l.n()).done;)c.value.stop()}catch(e){l.e(e)}finally{l.f()}r._session.stop({}),n().videochat.clearSession(r._session.ID),r.$dialing.pause(),r.$calling.pause(),r.$endCall.play(),r.$muteUnmuteButton.disabled=!0,r.$switchCameraButton.disabled=!0,r._session=null,r.mediaDevicesIds=[],r.activeDeviceId=null,r.isAudioMuted=!1,o.innerHTML="",o.classList.value="",t.classList.remove("hidden"),s.classList.add("hidden"),i.classList.remove("muted"),r.isSharingScreen&&(r.isSharingScreen=!1,r.updateSharingScreenBtn()),E&&(s.style.background="#000000")}})),x(this,"onDevicesChangeListener",(function(){E||n().videochat.getMediaDevices("videoinput").then((function(e){var t;r.mediaDevicesIds=null==e?void 0:e.map((function(e){return e.deviceId})),r.mediaDevicesIds.length<2||r._session.callType===n().videochat.CallType.AUDIO?(r.$switchCameraButton.disabled=!0,r.activeDeviceId&&(null===(t=r.mediaDevicesIds)||void 0===t?void 0:t[0])!==r.activeDeviceId&&!r.isSharingScreen&&r.switchCamera()):r.$switchCameraButton.disabled=!1}))})),x(this,"onSessionConnectionStateChangedListener",(function(e,t,s){console.log("[onSessionConnectionStateChangedListener]",t,s);var i=n().videochat.SessionConnectionState,o=i.DISCONNECTED,a=i.FAILED,c=i.CONNECTED,l=i.CLOSED;s===o||s===a?r.iceRestartTimeout=setTimeout((function(){console.log("Connection not restored within 30 seconds, trying ICE restart.."),r.isOnline?r.maybeDoIceRestart(e,t):(console.log("Skip ICE restart, no Internet connection "),r.needIceRestartForUsersIds.push(t))}),3e4):s===c?(clearTimeout(r.iceRestartTimeout),r.iceRestartTimeout=null,r.needIceRestartForUsersIds=[]):s===l&&(r.needIceRestartForUsersIds=[])})),x(this,"setActiveDeviceId",(function(e){if(e&&!E){var t,n=null===(t=e.getVideoTracks()[0])||void 0===t?void 0:t.getSettings();r.activeDeviceId=null==n?void 0:n.deviceId}})),x(this,"setAudioMute",(function(){var e=document.getElementById("videochat-mute-unmute");r.isAudioMuted?(r._session.unmute("audio"),r.isAudioMuted=!1,e.classList.remove("muted")):(r._session.mute("audio"),r.isAudioMuted=!0,e.classList.add("muted"))})),x(this,"switchCamera",(function(){var e=r.mediaDevicesIds.find((function(e){return e!==r.activeDeviceId}));r._session.switchMediaTracks({video:e}).then((function(){r.activeDeviceId=e,r.isAudioMuted&&r._session.mute("audio")}))})),x(this,"sharingScreen",(function(){if(!r.isSharingScreen)return r._session.getDisplayMedia(r.sharingScreenMediaParams,!0).then((function(e){r.updateStream(e),r.isSharingScreen=!0,r.updateSharingScreenBtn(),r.startEventSharinScreen=e.getVideoTracks()[0].addEventListener("ended",(function(){return r.stopSharingScreen()}))}),(function(e){console.warn("[Get display media error]",e,r.mediaParam),r.stopSharingScreen()}));r.stopSharingScreen()})),x(this,"updateSharingScreenBtn",(function(){var e=document.getElementById("videochat-sharing-screen"),t=document.getElementById("videochat-sharing-screen-icon");r.isSharingScreen?(e.classList.add("videochat-sharing-screen-active"),t.classList.add("videochat-sharing-screen-icon-active")):(e.classList.remove("videochat-sharing-screen-active"),t.classList.remove("videochat-sharing-screen-icon-active"))})),x(this,"stopSharingScreen",(function(){return r._session.getUserMedia(r.mediaParams,!0).then((function(e){r.updateStream(e),r.isSharingScreen=!1,r.updateSharingScreenBtn(),r.startEventSharinScreen=null}))})),x(this,"updateStream",(function(e){r.setActiveDeviceId(e),r._prepareVideoElement("localStream")})),x(this,"showSnackbar",(function(e){var t=document.getElementById("snackbar");t.innerHTML=e,t.classList.add("show"),setTimeout((function(){t.innerHTML="",t.classList.remove("show")}),3e3)})),x(this,"showIncomingCallModal",(function(){return r._incomingCallModal("show")})),x(this,"hideIncomingCallModal",(function(){return r._incomingCallModal("hide")})),x(this,"_incomingCallModal",(function(e){var t=document.getElementById("call-modal-initiator");"hide"===e?(t.innerHTML="",r.$modal.classList.remove("show"),r.$calling.pause()):(t.innerHTML=r._getUserById(r._session.initiatorID,"name"),r.$modal.classList.add("show"),r.$calling.play())})),x(this,"_getUserById",(function(e,t){var r=a.find((function(t){return t.id==e}));return"string"==typeof t?r[t]:r})),x(this,"_prepareVideoElement",(function(e){var t=document.getElementById(e);t.style.visibility="visible",E&&(document.getElementById("videochat").style.background="transparent",t.style.backgroundColor="",t.style.zIndex=-1)}))},r=[{key:"maybeDoIceRestart",value:(s=y().mark((function e(t,r){return y().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("[maybeDoIceRestart] Chat PING"),e.prev=1,e.next=4,n().chat.pingWithTimeout();case 4:console.log("[maybeDoIceRestart] Chat PONG"),console.log("[maybeDoIceRestart] canInitiateIceRestart: ",t.canInitiateIceRestart(r)),t.canInitiateIceRestart(r)&&(console.log("[maybeDoIceRestart] do ICE restart"),t.iceRestart(r)),e.next=20;break;case 9:return e.prev=9,e.t0=e.catch(1),console.error(e.t0.message),console.log("[maybeDoIceRestart] do Chat restart"),e.next=15,n().chat.disconnect();case 15:return e.next=17,n().chat.connect({userId:this.currentUser.id,password:this.currentUser.password});case 17:console.log("[maybeDoIceRestart] Chat restarted"),console.log("[maybeDoIceRestart] canInitiateIceRestart: ",t.canInitiateIceRestart(r)),t.canInitiateIceRestart(r)&&(console.log("[maybeDoIceRestart] do ICE restart"),t.iceRestart(r));case 20:case"end":return e.stop()}}),e,this,[[1,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,n){var i=s.apply(e,t);function o(e){v(i,r,n,o,a,"next",e)}function a(e){v(i,r,n,o,a,"throw",e)}o(void 0)}))},function(e,t){return i.apply(this,arguments)})}],r&&_(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,s,i}());function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function D(e,t){for(var r=0;r