genesys-cloud-streaming-client 14.2.1-develop.21 → 14.2.1-develop.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client.js +1 -0
- package/dist/deploy-info.json +2 -2
- package/dist/es/client.js +1 -0
- package/dist/es/index.bundle.js +1 -0
- package/dist/npm/CHANGELOG.md +1 -0
- package/dist/npm/client.js +1 -0
- package/dist/streaming-client.browser.ie.js +1 -1
- package/dist/streaming-client.browser.js +1 -1
- package/dist/v14/streaming-client.browser.ie.js +1 -1
- package/dist/v14/streaming-client.browser.js +1 -1
- package/dist/v14.2.1/streaming-client.browser.ie.js +1 -1
- package/dist/v14.2.1/streaming-client.browser.js +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
35
35
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
36
36
|
and limitations under the License.
|
|
37
37
|
***************************************************************************** */
|
|
38
|
-
var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function r(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return(s=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function o(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function a(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function c(e,t){return function(n,i){t(n,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function p(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function d(e,t){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function f(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}function g(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i}function v(e){return this instanceof v?(this.v=e,this):new v(e)}function b(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof v?Promise.resolve(n.value.v).then(c,l):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function y(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:v(e[i](t)),done:"return"===i}:r?r(t):t}:r}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=h(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function w(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function x(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(24);class r{constructor(e,t={},n=[]){this.name=e,this.attributes=t,this.children=[],this.optionalNamespaces={};for(const e of n)if("string"!=typeof e){const t=new r(e.name,e.attributes,e.children);t.parent=this,this.children.push(t)}else this.children.push(e)}getName(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name}getNamespace(){if(this.name.indexOf(":")>=0){const e=this.name.substr(0,this.name.indexOf(":"));return this.findNamespaceForPrefix(e)}return this.findNamespaceForPrefix()}getNamespaceContext(){let e={};this.parent&&(e=this.parent.getNamespaceContext());for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")){const i=t.substr(6);e[n]=i}return e}getDefaultNamespace(){return this.attributes.xmlns?this.attributes.xmlns:this.parent?this.parent.getDefaultNamespace():""}getNamespaceRoot(e){if(this.parent){const t=this.parent.getNamespaceRoot(e);if(t)return t}for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")&&n===e)return this;if(this.optionalNamespaces[e])return this}getAttribute(e,t){if(!t)return this.attributes[e];const n=this.getNamespaceContext();return n[t]?this.attributes[[n[t],e].join(":")]:void 0}getChild(e,t){return this.getChildren(e,t)[0]}getChildren(e,t){const n=[];for(const i of this.children)"string"==typeof i||i.getName()!==e||t&&i.getNamespace()!==t||n.push(i);return n}getText(){let e="";for(const t of this.children)"string"==typeof t&&(e+=t);return e}appendChild(e){return this.children.push(e),"string"!=typeof e&&(e.parent=this),e}setAttribute(e,t,n=!1){this.attributes[e]=t||void 0,""===t&&n&&(this.attributes[e]=t)}addOptionalNamespace(e,t){this.optionalNamespaces[t]=e}useNamespace(e,t){return this.optionalNamespaces[t]&&(e=this.optionalNamespaces[t]),this.setAttribute("xmlns:"+e,t),e}toJSON(){const e=this.children.map(e=>"string"==typeof e?e:e?e.toJSON():void 0).filter(e=>!!e),t={};for(const[e,n]of Object.entries(this.attributes))null!=n&&(t[e]=n);return{attributes:t,children:e,name:this.name}}toString(){let e=this.openTag(!0);if(this.children.length){for(const t of this.children)"string"==typeof t?e+=i.escapeXMLText(t):t&&(e+=t.toString());e+=this.closeTag()}return e}openTag(e=!1){let t="";t+="<"+this.name;for(const[e,n]of Object.entries(this.attributes))void 0!==n&&(t+=` ${e}="${i.escapeXML(n.toString())}"`);return e&&0===this.children.length?t+="/>":t+=">",t}closeTag(){return`</${this.name}>`}findNamespaceForPrefix(e){if(e){const t="xmlns:"+e;if(this.attributes[t])return this.attributes[t];if(this.parent)return this.parent.findNamespaceForPrefix(e)}else{if(this.attributes.xmlns)return this.attributes.xmlns;if(this.parent)return this.parent.findNamespaceForPrefix()}return""}}t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.basicLanguageResolver=t.escapeXMLText=t.unescapeXML=t.escapeXML=void 0;const i=n(0).__importDefault(n(30)),r={'"':""","&":"&","'":"'","<":"<",">":">"},s={"&":"&","'":"'",">":">","<":"<",""":'"'},o=/&([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);/g,a=/&|<|>|"|'/g,c=/&|<|>/g;function l(e){return r[e]}t.escapeXML=function(e){return e.replace(a,l)},t.unescapeXML=function(e){return e.replace(o,e=>function(e){if(s[e])return s[e];const t=e.startsWith("&#x"),n=parseInt(e.substring(t?3:2,e.length-1),t?16:10);if(9===n||10===n||13===n||32<=n&&n<=55295||57344<=n&&n<=65533||65536<=n&&n<=1114111)return String.fromCodePoint(n);throw i.default.restrictedXML("Prohibited entity: "+e)}(e))},t.escapeXMLText=function(e){return e.replace(c,l)},t.basicLanguageResolver=function(e,t=[],n=""){const i=new Set(e.map(e=>e.toLowerCase()));for(let e of t.map(e=>e.toLowerCase()))if("*"!==e)for(;e.length>0;){if(i.has(e))return e;e=e.substring(0,e.lastIndexOf("-")).toLowerCase(),e.lastIndexOf("-")===e.length-2&&(e=e.substring(0,e.lastIndexOf("-")))}return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GenesysCloudMediaSession=void 0;const i=n(22),r=n(130),s=n(9),o=i.__importDefault(n(132)),a=n(3),c=n(17),l={"Discovered new ICE candidate":{skipMessage:!0}};class u extends r.MediaSession{constructor(e){super(e.options),this.iceCandidatesDiscovered=0,this.iceCandidatesReceivedFromPeer=0,this.conversationId=e.conversationId,this.fromUserId=e.fromUserId,this.originalRoomJid=e.originalRoomJid,this.sessionType=c.SessionTypes[e.sessionType],this.ignoreHostCandidatesFromRemote=!!e.ignoreHostCandidatesFromRemote,this.allowIPv6=!!e.allowIPv6,this.allowTCP=!!e.allowTCP;const t=new a.EventEmitter;Object.keys(t.__proto__).forEach(e=>{this[e]=t[e]}),e.optOutOfWebrtcStatsTelemetry||this.setupStatsGatherer(),this.pc.addEventListener("connectionstatechange",this.onConnectionStateChange.bind(this)),this.pc.addEventListener("icecandidateerror",this.onIceCandidateError.bind(this))}getLogDetails(){return{conversationId:this.conversationId,sessionId:this.sid,sessionType:this.sessionType}}async onTransportInfo(e,t){var n,i;const r=null===(n=e.contents)||void 0===n?void 0:n[0].transport,s=null==r?void 0:r.candidates;if(this.ignoreHostCandidatesFromRemote){const e=null==s?void 0:s.filter(e=>"host"!==e.type);(null==e?void 0:e.length)!==(null===(i=null==r?void 0:r.candidates)||void 0===i?void 0:i.length)&&(this._log("info","Ignoring remote host ice candidates"),r.candidates=e)}if(s)for(const e of s)this._log("info","Received candidate from peer",{candidateType:e.type}),this.iceCandidatesReceivedFromPeer++;return super.onTransportInfo(e,t)}_log(e,t,...n){if(this.parent){const i=l[t];if(null==i?void 0:i.skipMessage)return;if(n.length){const e=n[0];"object"!=typeof e||Array.isArray(e)||null===e?n[0]={...this.getLogDetails(),data:e}:Object.assign(n[0],this.getLogDetails())}else n.push(this.getLogDetails());this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n)}}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),setTimeout(()=>{"connected"!==this.pc.connectionState&&"connecting"!==this.pc.connectionState||this.pc.close()},2e3),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}setupStatsGatherer(){this.statsGatherer=new o.default(this.pc),this.statsGatherer.on("stats",this.emit.bind(this,"stats"))}onIceStateChange(){const e=this.pc.iceConnectionState,t=this.id,n=this.conversationId;this._log("info","ICE state changed: ",{iceState:e,sessionId:t,conversationId:n}),"connected"===e?(this._log("info","sending session-info: active"),this.send(s.JingleAction.SessionInfo,{info:{infoType:s.JINGLE_INFO_ACTIVE}}),this._setupDataChannel()):"failed"===e&&this._log("info","ICE connection failed",{candidatesDiscovered:this.iceCandidatesDiscovered,candidatesReceivedFromPeer:this.iceCandidatesReceivedFromPeer}),super.onIceStateChange()}onConnectionStateChange(){this._log("info","Connection state changed: ",{connectionState:this.pc.connectionState})}onIceCandidateError(e){this._log("error","IceCandidateError",{errorCode:e.errorCode,errorText:e.errorText,url:e.url}),console.error("IceCandidateError",e)}onIceCandidate(e){if(e.candidate){if(!this.allowTCP&&"tcp"===e.candidate.protocol)return;if(!this.allowIPv6){const t=/.+udp [^ ]+ ([^ ]+).*typ host/.exec(e.candidate.candidate),n=/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/;if(t&&!t[1].match(n))return void this._log("debug","Filtering out IPv6 candidate",e.candidate.candidate)}this._log("debug","Processing ice candidate",e.candidate.candidate),this._log("info","Discovered ice candidate to send to peer",{type:e.candidate.type}),this.iceCandidatesDiscovered++}return super.onIceCandidate(e)}onIceEndOfCandidates(){super.onIceEndOfCandidates(),this.emit("endOfCandidates")}addTrack(e,t){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",async()=>{const n=this.pc.getTransceivers().find(t=>{var n;return!t.sender.track&&(null===(n=t.receiver.track)||void 0===n?void 0:n.kind)===e.kind});if(n)return n.sender.replaceTrack(e);this.pc.addTrack(e,t)})}_setupDataChannel(){var e;this.dataChannel||(null===(e=this.pc.localDescription)||void 0===e?void 0:e.sdp.includes("webrtc-datachannel"))&&(this._log("info","creating data channel"),this.dataChannel=this.pc.createDataChannel("videoConferenceControl"),this.dataChannel.addEventListener("open",()=>{this._log("info","data channel opened")}),this.dataChannel.addEventListener("message",this._handleDataChannelMessage.bind(this)),this.dataChannel.addEventListener("close",()=>{this._log("info","closing data channel")}),this.dataChannel.addEventListener("error",e=>{this._log("error","Error occurred with the data channel",e)}))}_handleDataChannelMessage(e){this._log("debug","data channel message received",e);try{const t=JSON.parse(e.data);this.emit("dataChannelMessage",t)}catch(e){this._log("error","Failed to parse data channel message",{error:e})}}}t.GenesysCloudMediaSession=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exportToSDP=t.importFromSDP=void 0;const i=n(0).__importStar(n(1));t.importFromSDP=function(e){const t=i.getMediaSections(e),n=i.getDescription(e),r={groups:[],media:[]};i.matchPrefix(n,"a=ice-lite").length>0&&(r.iceLite=!0);for(const e of i.matchPrefix(n,"a=group:")){const t=e.split(" "),n=t.shift().substr(8);r.groups.push({mids:t,semantics:n})}for(const e of t){const t=i.getKind(e),s=i.isRejected(e),o=i.parseMLine(e),a={direction:i.getDirection(e,n),kind:t,mid:i.getMid(e),protocol:o.protocol};if(s||(a.iceParameters=i.getIceParameters(e,n),a.dtlsParameters=i.getDtlsParameters(e,n),a.setup=i.matchPrefix(e,"a=setup:")[0].substr(8),r.iceLite&&(a.iceParameters.iceLite=!0)),"audio"===t||"video"===t){a.rtpParameters=i.parseRtpParameters(e),a.rtpEncodingParameters=i.parseRtpEncodingParameters(e),a.rtcpParameters=i.parseRtcpParameters(e);const t=i.parseMsid(e);a.streams=t?[t]:[]}else"application"===t&&(a.sctp=i.parseSctpDescription(e));a.candidates=i.matchPrefix(e,"a=candidate:").map(i.parseCandidate),r.media.push(a)}return r},t.exportToSDP=function(e){const t=[];t.push(i.writeSessionBoilerplate(e.sessionId,e.sessionVersion),"a=msid-semantic:WMS *\r\n"),(e.iceLite||e.media.filter(e=>e.iceParameters&&e.iceParameters.iceLite).length>0)&&t.push("a=ice-lite\r\n");for(const n of e.groups||[])t.push(`a=group:${n.semantics} ${n.mids.join(" ")}\r\n`);for(const n of e.media||[]){const e=!(n.iceParameters&&n.dtlsParameters);if("application"===n.kind&&n.sctp)t.push(i.writeSctpDescription(n,n.sctp));else if(n.rtpParameters){let r=i.writeRtpDescription(n.kind,n.rtpParameters);e&&(r=r.replace(`m=${n.kind} 9 `,`m=${n.kind} 0 `)),t.push(r),t.push(`a=${n.direction||"sendrecv"}\r\n`);for(const e of n.streams||[])t.push(`a=msid:${e.stream} ${e.track}\r\n`);if(n.rtcpParameters&&(t.push(i.writeRtcpParameters(n.rtcpParameters)),n.rtcpParameters.cname&&n.rtpEncodingParameters&&n.rtpEncodingParameters[0].rtx)){const e=n.rtpEncodingParameters[0];t.push(`a=ssrc-group:FID ${e.ssrc} ${e.rtx.ssrc}\r\n`),t.push(`a=ssrc:${e.rtx.ssrc} cname:${n.rtcpParameters.cname}\r\n`)}}if(void 0!==n.mid&&t.push(`a=mid:${n.mid}\r\n`),n.iceParameters&&t.push(i.writeIceParameters({usernameFragment:n.iceParameters.usernameFragment,password:n.iceParameters.password})),n.dtlsParameters&&n.setup&&t.push(i.writeDtlsParameters(n.dtlsParameters,n.setup)),n.candidates&&n.candidates.length)for(const e of n.candidates)t.push(`a=${i.writeCandidate(e)}\r\n`)}return t.join("")}},function(e,t,n){e.exports=n(88)},function(e,t){var n=Object.prototype.hasOwnProperty;function i(e){return"[Throws: "+(e?e.message:"?")+"]"}function r(e){var t=[];return function e(r){if(null===r||"object"!=typeof r)return r;if(-1!==t.indexOf(r))return"[Circular]";if(t.push(r),"function"==typeof r.toJSON)try{var s=e(r.toJSON());return t.pop(),s}catch(e){return i(e)}if(Array.isArray(r)){var o=r.map(e);return t.pop(),o}var a=Object.keys(r).reduce((function(t,s){return t[s]=e(function(e,t){if(n.call(e,t))try{return e[t]}catch(e){return i(e)}return e[t]}(r,s)),t}),{});return t.pop(),a}(e)}e.exports=function(e,t,n){return JSON.stringify(r(e),t,n)},e.exports.ensureProperties=r},function(e,t,n){"use strict";(function(t){var i=n(2),r=n(93),s=n(13),o=n(49),a=n(50),c={"Content-Type":"application/x-www-form-urlencoded"};function l(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,p={transitional:o,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(u=n(51)),u),transformRequest:[function(e,t){if(r(t,"Accept"),r(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e))return e;if(i.isArrayBufferView(e))return e.buffer;if(i.isURLSearchParams(e))return l(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,s=i.isObject(e),o=t&&t["Content-Type"];if((n=i.isFileList(e))||s&&"multipart/form-data"===o){var c=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,c&&new c)}return s||"application/json"===o?(l(t,"application/json"),function(e,t,n){if(i.isString(e))try{return(t||JSON.parse)(e),i.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||p.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||r&&i.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw s.from(e,s.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:n(101)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};i.forEach(["delete","get","head"],(function(e){p.headers[e]={}})),i.forEach(["post","put","patch"],(function(e){p.headers[e]=i.merge(c)})),e.exports=p}).call(this,n(7))},function(e,t,n){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.JXTErrorCondition=void 0,function(e){e.NotWellFormed="not-well-formed",e.RestrictedXML="restricted-xml",e.AlreadyClosed="already-closed",e.UnknownRoot="unknown-stream-root"}(i=t.JXTErrorCondition||(t.JXTErrorCondition={}));class r extends Error{constructor(e){super(e.text),this.isJXTError=!0,this.condition=e.condition,this.text=e.text}static notWellFormed(e){return new r({condition:i.NotWellFormed,text:e})}static restrictedXML(e){return new r({condition:i.RestrictedXML,text:e})}static alreadyClosed(e){return new r({condition:i.AlreadyClosed,text:e})}static unknownRoot(e){return new r({condition:i.UnknownRoot,text:e})}}t.default=r},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.childAlternateLanguageRawElement=t.childLanguageRawElement=t.childRawElement=t.staticValue=t.splicePath=t.multipleChildEnum=t.multipleChildAlternateLanguageText=t.childAlternateLanguageText=t.multipleChildIntegerAttribute=t.multipleChildAttribute=t.multipleChildText=t.childDoubleEnum=t.childEnum=t.deepMultipleChildText=t.deepChildBoolean=t.deepChildInteger=t.deepChildText=t.childBoolean=t.childTimezoneOffset=t.childJSON=t.childFloat=t.childInteger=t.childDate=t.childTextBuffer=t.childText=t.childLanguageAttribute=t.languageAttribute=t.textBuffer=t.textJSON=t.text=t.childDateAttribute=t.childFloatAttribute=t.childIntegerAttribute=t.childBooleanAttribute=t.childAttribute=t.namespacedDateAttribute=t.namespacedFloatAttribute=t.namespacedIntegerAttribute=t.namespacedBooleanAttribute=t.namespacedAttribute=t.dateAttribute=t.floatAttribute=t.integerAttribute=t.booleanAttribute=t.attribute=t.findOrCreate=t.findAll=t.getTargetLang=t.getLang=t.createElement=void 0,t.parameterMap=void 0;const i=n(0).__importDefault(n(23)),r=n(32);function s(e,t,n,r){if(r){e=e||r.getNamespace();const n=r.getNamespaceRoot(e);if(n){t=`${n.useNamespace("",e)}:${t}`}}const s=new i.default(t);return t.indexOf(":")<0&&(!n||e!==n)&&s.setAttribute("xmlns",e),s}function o(e,t){return(e.getAttribute("xml:lang")||t||"").toLowerCase()}function a(e,t){const n=[];for(const i of e)n.push(o(i,t.lang));let i;return i=t.resolveLanguage?t.resolveLanguage(n,t.acceptLanguages||[],t.lang):t.lang,i||""}function c(e,t,n,i){const r=e.getChildren(n,t),s=o(e);return r.length?i?r.filter(e=>{if(o(e,s)===i)return!0}):r:[]}function l(e,t,n,i){t=t||e.getNamespace();const r=c(e,t,n,i);if(r.length)return r[0];const a=s(t,n,e.getDefaultNamespace(),e),l=o(e,i);return i&&l!==i&&a.setAttribute("xml:lang",i),e.appendChild(a),a}function u(e){return{importer(t){const n=t.getAttribute(e.name,e.namespace);return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);if(i||e.emitEmpty)if(e.namespace&&e.prefix){let n;const r=t.getNamespaceRoot(e.namespace);if(r)n=r.useNamespace(e.prefix,e.namespace);else{const i=t.getNamespaceContext();i[e.namespace]||(n=t.useNamespace(e.prefix,e.namespace),i[e.namespace]=n)}t.setAttribute(`${n}:${e.name}`,i,e.emitEmpty)}else t.setAttribute(e.name,i,e.emitEmpty)}}}function p(e,t){return(n,i,r={})=>(r={staticDefault:i,...r},u({name:n,...e,...t?t(r):r}))}function d(e,t){return(n,i,r,s,o={})=>(o={staticDefault:s,...o},u({name:r,namespace:i,prefix:n,...e,...t?t(o):o}))}function h(e){const t=e.converter||u({...e,namespace:e.attributeNamespace});return{importer(n,i){const r=n.getChild(e.element,e.namespace||n.getNamespace());return r?t.importer(r,i):e.dynamicDefault?e.dynamicDefault():e.staticDefault},exporter(n,i,r){if(void 0!==i&&i!==e.staticDefault){const s=l(n,e.namespace||n.getNamespace(),e.element);t.exporter(s,i,r)}}}}function f(e,t){return(n,i,r,s,o={})=>(o={staticDefault:s,...o},h({element:i,name:r,namespace:n,...e,...t?t(o):o}))}function m(e){return{importer(t){const n=t.getText();return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(!n&&e.emitEmpty)return void t.children.push("");if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);i&&t.children.push(i)}}}function g(e){const t=m(e);return{importer(n,i){const r=c(n,e.namespace||n.getNamespace(),e.element),s=a(r,i);if(!r.length)return e.dynamicDefault?e.dynamicDefault():e.staticDefault;if(e.matchLanguage)for(const e of r)if(o(e,i.lang)===s)return t.importer(e,i);return t.importer(r[0],i)},exporter(n,i,r){if(i||!e.emitEmpty){if(void 0!==i&&i!==e.staticDefault){const s=l(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0);t.exporter(s,i,r)}}else l(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0)}}}t.createElement=s,t.getLang=o,t.getTargetLang=a,t.findAll=c,t.findOrCreate=l;const v={parseValue:e=>e,writeValue:e=>e},b={parseValue:e=>parseInt(e,10),writeValue:e=>e.toString()},y={parseValue:e=>parseFloat(e),writeValue:e=>e.toString()},_={parseValue:e=>"true"===e||"1"===e||"false"!==e&&"0"!==e&&void 0,writeValue:e=>e?"1":"0"},S={parseValue:e=>new Date(e),writeValue:e=>"string"==typeof e?e:e.toISOString()},w={parseValue:e=>JSON.parse(e),writeValue:e=>JSON.stringify(e)},x=(t="utf8")=>({parseValue:n=>("base64"===t&&"="===n&&(n=""),e.from(n.trim(),t)),writeValue:n=>{let i;return i="string"==typeof n?e.from(n).toString(t):n?n.toString(t):"","base64"===t&&(i=i||"="),i}}),T={parseValue:e=>{let t=-1;"-"===e.charAt(0)&&(t=1,e=e.slice(1));const n=e.split(":");return(60*parseInt(n[0],10)+parseInt(n[1],10))*t},writeValue:e=>{if("string"==typeof e)return e;{let t="-";e<0&&(e=-e,t="+");const n=e/60,i=e%60;return t+=(n<10?"0":"")+n+":"+(i<10?"0":"")+i,t}}};t.attribute=p(v,e=>({dynamicDefault:e.emitEmpty?t=>""===t?"":e.staticDefault:void 0,...e})),t.booleanAttribute=p(_),t.integerAttribute=p(b),t.floatAttribute=p(y),t.dateAttribute=p(S),t.namespacedAttribute=d(v),t.namespacedBooleanAttribute=d(_),t.namespacedIntegerAttribute=d(b),t.namespacedFloatAttribute=d(y),t.namespacedDateAttribute=d(S),t.childAttribute=f(v),t.childBooleanAttribute=f(_),t.childIntegerAttribute=f(b),t.childFloatAttribute=f(y),t.childDateAttribute=f(S);t.text=e=>m({staticDefault:e,...v});t.textJSON=()=>m({...w});function k(){return{importer:(e,t)=>o(e,t.lang),exporter(e,t,n){t&&t.toLowerCase()!==n.lang?e.setAttribute("xml:lang",t):e.setAttribute("xml:lang",void 0)}}}t.textBuffer=(e="utf8")=>m({...x(e)}),t.languageAttribute=k;t.childLanguageAttribute=(e,t)=>h({converter:k(),element:t,name:"xml:lang",namespace:e,...v});t.childText=(e,t,n,i=!1)=>g({element:t,emitEmpty:i,matchLanguage:!0,namespace:e,staticDefault:n,...v});t.childTextBuffer=(e,t,n="utf8")=>g({element:t,matchLanguage:!0,namespace:e,...x(n)});t.childDate=(e,t)=>g({element:t,namespace:e,...S});t.childInteger=(e,t,n)=>g({element:t,namespace:e,staticDefault:n,...b});t.childFloat=(e,t,n)=>g({element:t,namespace:e,staticDefault:n,...y});t.childJSON=(e,t)=>g({element:t,namespace:e,...w}),t.childTimezoneOffset=function(e,t){return g({element:t,namespace:e,staticDefault:0,...T})},t.childBoolean=function(e,t){return{importer(n){if(n.getChild(t,e||n.getNamespace()))return!0},exporter(n,i){i&&l(n,e||n.getNamespace(),t)}}};const I=(e,t,n)=>{if(!n)return;let i=t;for(const t of e)i=l(i,t.namespace||i.getNamespace(),t.element);i.children.push(n.toString())};t.deepChildText=function(e,t){return{importer(n){let i=n;for(const n of e)if(i=i.getChild(n.element,n.namespace||i.getNamespace()),!i)return t;return i.getText()||t},exporter(t,n){I(e,t,n)}}},t.deepChildInteger=function(e,t){return{importer(n){let i=n;for(const t of e)if(i=i.getChild(t.element,t.namespace||i.getNamespace()),!i)return;const r=i.getText();return r?parseInt(r,10):t||void 0},exporter(t,n){I(e,t,n)}}},t.deepChildBoolean=function(e){return{importer(t){let n=t;for(const t of e)if(n=n.getChild(t.element,t.namespace||n.getNamespace()),!n)return!1;return!0},exporter(t,n){if(!n)return;let i=t;for(const t of e)i=l(i,t.namespace||i.getNamespace(),t.element)}}},t.deepMultipleChildText=function(e){const t=e.pop();return{importer(n,i){let r=n;for(const t of e)if(r=r.getChild(t.element,t.namespace||r.getNamespace()),!r)return[];const s=[],l=c(r,t.namespace||r.getNamespace(),t.element),u=a(l,i);for(const e of l)o(e,i.lang)===u&&s.push(e.getText());return s},exporter(n,i,r){if(!i.length)return;let o=n;for(const t of e)o=l(o,t.namespace||o.getNamespace(),t.element);const{namespace:a,element:c}=t;for(const e of i){const t=s(a||o.getNamespace(),c,r.namespace,o);t.children.push(e),o.appendChild(t)}}}},t.childEnum=function(e,t,n){const i=new Map,r=new Map;for(const e of t)"string"==typeof e?(i.set(e,e),r.set(e,e)):(i.set(e[1],e[0]),r.set(e[0],e[1]));return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&i.has(n.getName()))return i.get(n.getName());return n},exporter(t,n){r.has(n)&&l(t,e,r.get(n))}}},t.childDoubleEnum=function(e,t,n,i){const r=new Set(t),s=new Set(n);return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&r.has(n.getName())){for(const i of n.children)if("string"!=typeof i&&i.getNamespace()===(e||t.getNamespace())&&s.has(i.getName()))return[n.getName(),i.getName()];return[n.getName()]}return i},exporter(t,n){const i=l(t,e,n[0]);n[1]&&l(i,e,n[1])}}},t.multipleChildText=function(e,t){return{importer(n,i){const r=[],s=c(n,e||n.getNamespace(),t),l=a(s,i);for(const e of s)o(e,i.lang)===l&&r.push(e.getText());return r},exporter(n,i,r){for(const o of i){const i=s(e||n.getNamespace(),t,r.namespace,n);i.children.push(o),n.appendChild(i)}}}},t.multipleChildAttribute=function(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(t)}return r},exporter(i,r,o){for(const a of r){const r=s(e||i.getNamespace(),t,o.namespace,i);r.setAttribute(n,a),i.appendChild(r)}}}},t.multipleChildIntegerAttribute=function(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(parseInt(t,10))}return r},exporter(i,r,o){for(const a of r){const r=s(e||i.getNamespace(),t,o.namespace,i);r.setAttribute(n,a.toString()),i.appendChild(r)}}}},t.childAlternateLanguageText=function(e,t){return{importer(n,i){const r=[],s=c(n,e||n.getNamespace(),t),a=new Set;for(const e of s){const t=e.getText();if(t){const n=o(e,i.lang);if(a.has(n))continue;r.push({lang:n,value:t}),a.add(n)}}return a.size>0?r:void 0},exporter(n,i,r){for(const o of i){const i=o.value;if(i){const a=s(e||n.getNamespace(),t,r.namespace,n);o.lang!==r.lang&&a.setAttribute("xml:lang",o.lang),a.children.push(i),n.appendChild(a)}}}}},t.multipleChildAlternateLanguageText=function(e,t){return{importer(n,i){const r=[],s=new Map;let a=!1;const l=c(n,e||n.getNamespace(),t);for(const e of l){const t=e.getText();if(t){const n=o(e,i.lang);let c=s.get(n);c||(c=[],s.set(n,c),r.push({lang:n,value:c})),c.push(t),a=!0}}return a?r:void 0},exporter(n,i,r){for(const o of i)for(const i of o.value){const a=s(e||n.getNamespace(),t,r.namespace,n);o.lang!==r.lang&&a.setAttribute("xml:lang",o.lang),a.children.push(i),n.appendChild(a)}}}},t.multipleChildEnum=function(e,t){const n=new Map,i=new Map;for(const e of t)"string"==typeof e?(n.set(e,e),i.set(e,e)):(n.set(e[1],e[0]),i.set(e[0],e[1]));return{importer(t){const i=[];for(const r of t.children)"string"!=typeof r&&r.getNamespace()===(e||t.getNamespace())&&n.has(r.getName())&&i.push(n.get(r.getName()));return i},exporter(t,n){for(const r of n)l(t,e,i.get(r))}}},t.splicePath=function(e,t,n,i=!1){return{importer(r,s){const o=r.getChild(t,e||r.getNamespace());if(!o)return;const a=[];for(const e of o.children)if("string"!=typeof e&&s.registry.getImportKey(e)===n){const t=s.registry.import(e);t&&a.push(t)}return i?a:a[0]},exporter(i,r,s){let o=[];o=Array.isArray(r)?r:[r];const a=[];for(const t of o){const r=s.registry.export(n,t,{...s,namespace:e||i.getNamespace()||void 0});r&&a.push(r)}if(a.length){const n=l(i,e||i.getNamespace(),t);for(const e of a)n.appendChild(e)}}}},t.staticValue=function(e){return{exporter:()=>{},importer:()=>e}},t.childRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=i.getChild(t,e||i.getNamespace());return s?n?r.sanitizers[n](s.toJSON()):s.toJSON():void 0},exporter(s,o,a){if("string"==typeof o){o=r.parse(`<${t} xmlns="${e||s.getNamespace()}">${o}</${t}>`).toJSON()}if(n){if(!a.sanitizers||!a.sanitizers[n])return;o=a.sanitizers[n](o)}o&&s.appendChild(new i.default(o.name,o.attributes,o.children))}}},t.childLanguageRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=c(i,e||i.getNamespace(),t),l=a(s,r);for(const e of s)if(o(e,r.lang)===l)return n?r.sanitizers[n](e.toJSON()):e.toJSON();return s[0]?n?r.sanitizers[n](s[0].toJSON()):s[0].toJSON():void 0},exporter(s,o,a){if("string"==typeof o){o=r.parse(`<${t} xmlns="${e||s.getNamespace()}">${o}</${t}>`).toJSON()}if(o&&n){if(!a.sanitizers||!a.sanitizers[n])return;o=a.sanitizers[n](o)}if(!o)return;const c=l(s,e||s.getNamespace(),t,a.lang);for(const e of o.children)"string"==typeof e?c.appendChild(e):e&&c.appendChild(new i.default(e.name,e.attributes,e.children))}}},t.childAlternateLanguageRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=[],a=new Set,l=c(i,e||i.getNamespace(),t);for(const e of l){let t=e.toJSON();if(n&&(t=r.sanitizers[n](t)),t){const n=o(e,r.lang);if(a.has(n))continue;s.push({lang:n,value:t}),a.add(n)}}return a.size>0?s:void 0},exporter(o,a,c){for(const l of a){let a=l.value;if("string"==typeof a){a=r.parse(`<${t} xmlns="${e||o.getNamespace()}">${a}</${t}>`).toJSON()}if(a&&n){if(!c.sanitizers||!c.sanitizers[n])continue;a=c.sanitizers[n](a)}if(a){const n=s(e||o.getNamespace(),t,c.namespace,o);o.appendChild(n),l.lang!==c.lang&&n.setAttribute("xml:lang",l.lang);for(const e of a.children)"string"==typeof e?n.appendChild(e):n.appendChild(new i.default(e.name,e.attributes,e.children))}}}}},t.parameterMap=function(e,n,i,r){return{importer(s,o){const a={},l=c(s,e,n),u=t.attribute(i).importer,p=t.attribute(r).importer;for(const e of l)a[u(e,o)]=p(e,o);return a},exporter(o,a,c){const l=t.attribute(i).exporter,u=t.attribute(r).exporter,p=e||o.getNamespace();for(const[e,t]of Object.entries(a)){const i=s(p,n,c.namespace,o);l(i,e,c),a[e]&&u(i,t,c),o.appendChild(i)}}}}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;const i=n(0),r=n(3),s=n(24),o=i.__importDefault(n(23)),a=i.__importDefault(n(30));function c(e){return 97<=e&&e<=122||65<=e&&e<=90||58===e||95===e}function l(e){return 192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=767||880<=e&&e<=893||895<=e&&e<=8191||8204<=e&&e<=8205||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||65008<=e&&e<=65533||65536<=e&&e<=983039}function u(e){return c(e)||l(e)}function p(e){return c(e)||45===e||46===e||48<=e&&e<=57||183===e||768<=e&&e<=879||8255<=e&&e<=8256||l(e)}function d(e){return 32===e||10===e||13===e||9===e}class h extends r.EventEmitter{constructor(e={}){super(),this.allowComments=!0,this.attributes={},this.state=34,this.tagName="",this.haveDeclaration=!1,this.recordBuffer=[],void 0!==e.allowComments&&(this.allowComments=e.allowComments)}write(e){for(const t of e){const e=t.codePointAt(0);switch(this.state){case 34:if(60===e){let e;try{e=s.unescapeXML(this.endRecord())}catch(e){return void this.emit("error",e)}e&&this.emit("text",e),this.transition(31);continue}this.record(t);continue;case 31:if(47===e){this.transition(7);continue}if(33===e){this.transition(24);continue}if(63===e){this.haveDeclaration&&this.restrictedXML(),this.transition(25);continue}if(u(e)){this.transition(30),this.startRecord(t);continue}return this.notWellFormed();case 30:if(p(e)){this.record(t);continue}if(d(e)){this.startTag(),this.transition(32);continue}if(47===e){this.startTag(),this.transition(29);continue}if(62===e){this.startTag(),this.transition(34),this.emit("startElement",this.tagName,this.attributes);continue}return this.notWellFormed();case 29:if(62===e){this.emit("startElement",this.tagName,this.attributes),this.emit("endElement",this.tagName),this.transition(34);continue}return this.notWellFormed();case 33:if(d(e)){this.transition(32);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 32:if(d(e))continue;if(u(e)){this.startRecord(t),this.transition(0);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 7:if(u(e)){this.startRecord(t),this.transition(6);continue}return this.notWellFormed();case 6:if(p(e)){this.record(t);continue}if(d(e)){this.transition(8);continue}if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 8:if(d(e))continue;if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 0:if(p(e)){this.record(t);continue}if(61===e){this.addAttribute(),this.transition(4);continue}if(d(e)){this.addAttribute(),this.transition(3);continue}return this.notWellFormed();case 3:if(61===e){this.transition(4);continue}if(d(e))continue;return this.notWellFormed();case 4:if(34===e){this.startRecord(),this.transition(1);continue}if(39===e){this.startRecord(),this.transition(2);continue}if(d(e))continue;return this.notWellFormed();case 1:case 2:if(34===e&&1===this.state||39===e&&2===this.state){const e=this.endRecord();this.attributes[this.attributeName]=s.unescapeXML(e),this.transition(33);continue}if(60===e)return this.notWellFormed();this.record(t);continue;case 24:if(45===e){this.allowComments||this.restrictedXML(),this.transition(23);continue}if(91===e){this.transition(21);continue}return this.notWellFormed();case 23:if(45===e){this.transition(14);continue}return this.notWellFormed();case 14:45===e&&this.transition(12);continue;case 12:45===e?this.transition(11):this.transition(14);continue;case 11:62===e?this.transition(34):this.transition(14);continue;case 25:if(88===e||120===e){this.transition(28);continue}return this.notWellFormed();case 28:if(77===e||109===e){this.transition(27);continue}return this.notWellFormed();case 27:if(76===e||108===e){this.transition(26);continue}return this.notWellFormed();case 26:if(d(e)){this.haveDeclaration=!0,this.transition(15);continue}return this.notWellFormed();case 13:if(62===e){this.transition(34);continue}return this.notWellFormed();case 15:63===e&&this.transition(13);continue;case 21:this.wait(e,67,20);continue;case 20:this.wait(e,68,19);continue;case 19:this.wait(e,65,18);continue;case 18:this.wait(e,84,17);continue;case 17:this.wait(e,65,16);continue;case 16:this.wait(e,91,5);continue;case 5:if(93===e){this.transition(10);continue}this.record(t);continue;case 10:93===e?this.transition(9):(this.record(String.fromCodePoint(93)),this.record(t),this.transition(5));continue;case 9:if(62===e){const e=this.endRecord();e&&this.emit("text",e),this.transition(34)}else this.record(String.fromCodePoint(93)),this.record(String.fromCodePoint(93)),this.record(t),this.transition(5);continue}}}end(e){e&&this.write(e),this.write=()=>{}}record(e){this.recordBuffer.push(e)}startRecord(e){this.recordBuffer=[],e&&this.recordBuffer.push(e)}endRecord(){const e=this.recordBuffer;return this.recordBuffer=[],e.join("")}startTag(){this.tagName=this.endRecord(),this.attributes={}}addAttribute(){const e=this.endRecord();if(void 0!==this.attributes[e])return this.notWellFormed();this.attributeName=e,this.attributes[e]=""}wait(e,t,n){if(e!==t)return this.notWellFormed();this.transition(n)}transition(e){this.state=e,34===e&&this.startRecord()}notWellFormed(e){this.emit("error",a.default.notWellFormed(e))}restrictedXML(e){this.emit("error",a.default.restrictedXML(e))}}t.parse=function(e,t={}){const n=new h(t);let i,r,s=null;if(n.on("text",e=>{r&&r.children.push(e)}),n.on("startElement",(e,t)=>{const n=new o.default(e,t);i||(i=n),r=r?r.appendChild(n):n}),n.on("endElement",e=>{r?e===r.name?r.parent&&(r=r.parent):n.emit("error",a.default.notWellFormed("b")):n.emit("error",a.default.notWellFormed("a"))}),n.on("error",e=>{s=e}),n.write(e),n.end(),s)throw s;return i},t.default=h},function(e,t,n){"use strict";n.r(t),function(e,i){n.d(t,"Hash",(function(){return s})),n.d(t,"Hmac",(function(){return F})),n.d(t,"RTCPeerConnection",(function(){return G})),n.d(t,"WebSocket",(function(){return J})),n.d(t,"createHash",(function(){return q})),n.d(t,"createHmac",(function(){return U})),n.d(t,"fetch",(function(){return z})),n.d(t,"getHashes",(function(){return B})),n.d(t,"randomBytes",(function(){return D}));var r=n(6);class s extends r.Transform{constructor(t,n,i="be"){super(),this._block=e.alloc(t),this._finalSize=n,this._blockSize=t,this._bigEndian="be"===i,this._len=0}_transform(e,t,n){let i=null;try{this.update(e,t)}catch(e){i=e}n(i)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(t,n){"string"==typeof t&&(n=n||"utf8",t=e.from(t,n));const i=this._block,r=this._blockSize,s=t.length;let o=this._len;for(let e=0;e<s;){const n=o%r,a=Math.min(s-e,r-n);for(let r=0;r<a;r++)i[n+r]=t[e+r];o+=a,e+=a,o%r==0&&this._update(i)}return this._len+=s,this}digest(e){const t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));const n=8*this._len;if(n<=4294967295)this._bigEndian?(this._block.writeUInt32BE(0,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)):(this._block.writeUInt32LE(n,this._blockSize-8),this._block.writeUInt32LE(0,this._blockSize-4));else{const e=(4294967295&n)>>>0,t=(n-e)/4294967296;this._bigEndian?(this._block.writeUInt32BE(t,this._blockSize-8),this._block.writeUInt32BE(e,this._blockSize-4)):(this._block.writeUInt32LE(e,this._blockSize-8),this._block.writeUInt32LE(t,this._blockSize-4))}this._update(this._block);const i=this._hash();return e?i.toString(e):i}_update(e){throw new Error("_update must be implemented by subclass")}_hash(){throw new Error("_update must be implemented by subclass")}}function o(e,t){return e<<t|e>>>32-t}function a(e,t,n,i,r,s,a){return o(e+(t&n|~t&i)+r+s|0,a)+t|0}function c(e,t,n,i,r,s,a){return o(e+(t&i|n&~i)+r+s|0,a)+t|0}function l(e,t,n,i,r,s,a){return o(e+(t^n^i)+r+s|0,a)+t|0}function u(e,t,n,i,r,s,a){return o(e+(n^(t|~i))+r+s|0,a)+t|0}const p=[1518500249,1859775393,-1894007588,-899497514];function d(e){return e<<5|e>>>27}function h(e){return e<<30|e>>>2}function f(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}class m extends s{constructor(){super(64,56),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this._w=new Array(80)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<80;++n)t[n]=(c=t[n-3]^t[n-8]^t[n-14]^t[n-16])<<1|c>>>31;var c;for(let e=0;e<80;++e){const n=~~(e/20),c=d(i)+f(n,r,s,o)+a+t[e]+p[n]|0;a=o,o=s,s=h(r),r=i,i=c}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0}_hash(){const t=e.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t}}const g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(e,t,n){return n^e&(t^n)}function b(e,t,n){return e&t|n&(e|t)}function y(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function _(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function S(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}class w extends s{constructor(){super(64,56),this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this._w=new Array(64)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,c=0|this._f,l=0|this._g,u=0|this._h;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<64;++n)t[n]=0|(((p=t[n-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10)+t[n-7]+S(t[n-15])+t[n-16];var p;for(let e=0;e<64;++e){const n=u+_(a)+v(a,c,l)+g[e]+t[e]|0,p=y(i)+b(i,r,s)|0;u=l,l=c,c=a,a=o+n|0,o=s,s=r,r=i,i=n+p|0}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=c+this._f|0,this._g=l+this._g|0,this._h=u+this._h|0}_hash(){const t=e.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t}}const x=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function T(e,t,n){return n^e&(t^n)}function k(e,t,n){return e&t|n&(e|t)}function I(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function j(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function E(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function N(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function C(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function R(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function O(e,t){return e>>>0<t>>>0?1:0}class A extends s{constructor(){super(128,112),this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this._w=new Array(160)}_update(e){const t=this._w;let n,i,r=0|this._ah,s=0|this._bh,o=0|this._ch,a=0|this._dh,c=0|this._eh,l=0|this._fh,u=0|this._gh,p=0|this._hh,d=0|this._al,h=0|this._bl,f=0|this._cl,m=0|this._dl,g=0|this._el,v=0|this._fl,b=0|this._gl,y=0|this._hl,_=0;for(_=0;_<32;_+=2)t[_]=e.readInt32BE(4*_),t[_+1]=e.readInt32BE(4*_+4);for(;_<160;_+=2){let e=t[_-30],r=t[_-30+1];const s=E(e,r),o=N(r,e);e=t[_-4],r=t[_-4+1];const a=C(e,r),c=R(r,e),l=t[_-14],u=t[_-14+1],p=t[_-32],d=t[_-32+1];i=o+u|0,n=s+l+O(i,o)|0,i=i+c|0,n=n+a+O(i,c)|0,i=i+d|0,n=n+p+O(i,d)|0,t[_]=n,t[_+1]=i}for(let e=0;e<160;e+=2){n=t[e],i=t[e+1];const _=k(r,s,o),S=k(d,h,f),w=I(r,d),E=I(d,r),N=j(c,g),C=j(g,c),R=x[e],A=x[e+1],P=T(c,l,u),q=T(g,v,b);let L=y+C|0,F=p+N+O(L,y)|0;L=L+q|0,F=F+P+O(L,q)|0,L=L+A|0,F=F+R+O(L,A)|0,L=L+i|0,F=F+n+O(L,i)|0;const M=E+S|0,D=w+_+O(M,E)|0;p=u,y=b,u=l,b=v,l=c,v=g,g=m+L|0,c=a+F+O(g,m)|0,a=o,m=f,o=s,f=h,s=r,h=d,d=L+M|0,r=F+D+O(d,L)|0}this._al=this._al+d|0,this._bl=this._bl+h|0,this._cl=this._cl+f|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+b|0,this._hl=this._hl+y|0,this._ah=this._ah+r+O(this._al,d)|0,this._bh=this._bh+s+O(this._bl,h)|0,this._ch=this._ch+o+O(this._cl,f)|0,this._dh=this._dh+a+O(this._dl,m)|0,this._eh=this._eh+c+O(this._el,g)|0,this._fh=this._fh+l+O(this._fl,v)|0,this._gh=this._gh+u+O(this._gl,b)|0,this._hh=this._hh+p+O(this._hl,y)|0}_hash(){const t=e.allocUnsafe(64);function n(e,n,i){t.writeInt32BE(e,i),t.writeInt32BE(n,i+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),n(this._gh,this._gl,48),n(this._hh,this._hl,56),t}}const P=new Map([["md5",class extends s{constructor(){super(64,56,"le"),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._m=new Array(16)}_update(e){const t=this._m;for(let n=0;n<16;++n)t[n]=e.readInt32LE(4*n);let n=this._a,i=this._b,r=this._c,s=this._d;n=a(n,i,r,s,t[0],3614090360,7),s=a(s,n,i,r,t[1],3905402710,12),r=a(r,s,n,i,t[2],606105819,17),i=a(i,r,s,n,t[3],3250441966,22),n=a(n,i,r,s,t[4],4118548399,7),s=a(s,n,i,r,t[5],1200080426,12),r=a(r,s,n,i,t[6],2821735955,17),i=a(i,r,s,n,t[7],4249261313,22),n=a(n,i,r,s,t[8],1770035416,7),s=a(s,n,i,r,t[9],2336552879,12),r=a(r,s,n,i,t[10],4294925233,17),i=a(i,r,s,n,t[11],2304563134,22),n=a(n,i,r,s,t[12],1804603682,7),s=a(s,n,i,r,t[13],4254626195,12),r=a(r,s,n,i,t[14],2792965006,17),i=a(i,r,s,n,t[15],1236535329,22),n=c(n,i,r,s,t[1],4129170786,5),s=c(s,n,i,r,t[6],3225465664,9),r=c(r,s,n,i,t[11],643717713,14),i=c(i,r,s,n,t[0],3921069994,20),n=c(n,i,r,s,t[5],3593408605,5),s=c(s,n,i,r,t[10],38016083,9),r=c(r,s,n,i,t[15],3634488961,14),i=c(i,r,s,n,t[4],3889429448,20),n=c(n,i,r,s,t[9],568446438,5),s=c(s,n,i,r,t[14],3275163606,9),r=c(r,s,n,i,t[3],4107603335,14),i=c(i,r,s,n,t[8],1163531501,20),n=c(n,i,r,s,t[13],2850285829,5),s=c(s,n,i,r,t[2],4243563512,9),r=c(r,s,n,i,t[7],1735328473,14),i=c(i,r,s,n,t[12],2368359562,20),n=l(n,i,r,s,t[5],4294588738,4),s=l(s,n,i,r,t[8],2272392833,11),r=l(r,s,n,i,t[11],1839030562,16),i=l(i,r,s,n,t[14],4259657740,23),n=l(n,i,r,s,t[1],2763975236,4),s=l(s,n,i,r,t[4],1272893353,11),r=l(r,s,n,i,t[7],4139469664,16),i=l(i,r,s,n,t[10],3200236656,23),n=l(n,i,r,s,t[13],681279174,4),s=l(s,n,i,r,t[0],3936430074,11),r=l(r,s,n,i,t[3],3572445317,16),i=l(i,r,s,n,t[6],76029189,23),n=l(n,i,r,s,t[9],3654602809,4),s=l(s,n,i,r,t[12],3873151461,11),r=l(r,s,n,i,t[15],530742520,16),i=l(i,r,s,n,t[2],3299628645,23),n=u(n,i,r,s,t[0],4096336452,6),s=u(s,n,i,r,t[7],1126891415,10),r=u(r,s,n,i,t[14],2878612391,15),i=u(i,r,s,n,t[5],4237533241,21),n=u(n,i,r,s,t[12],1700485571,6),s=u(s,n,i,r,t[3],2399980690,10),r=u(r,s,n,i,t[10],4293915773,15),i=u(i,r,s,n,t[1],2240044497,21),n=u(n,i,r,s,t[8],1873313359,6),s=u(s,n,i,r,t[15],4264355552,10),r=u(r,s,n,i,t[6],2734768916,15),i=u(i,r,s,n,t[13],1309151649,21),n=u(n,i,r,s,t[4],4149444226,6),s=u(s,n,i,r,t[11],3174756917,10),r=u(r,s,n,i,t[2],718787259,15),i=u(i,r,s,n,t[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+i|0,this._c=this._c+r|0,this._d=this._d+s|0}_hash(){const t=e.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t}}],["sha-1",m],["sha-256",w],["sha-512",A],["sha1",m],["sha256",w],["sha512",A]]);function q(e){e=e.toLowerCase();const t=P.get(e);if(t)return new t;throw new Error("Unsupported hash algorithm: "+e)}const L=e.alloc(128);class F extends r.Transform{constructor(t,n){super(),"string"==typeof n&&(n=e.from(n));const i="sha512"===t?128:64;this._alg=t,n.length>i?n=q(t).update(n).digest():n.length<i&&(n=e.concat([n,L],i)),this._ipad=e.alloc(i),this._opad=e.alloc(i);for(let e=0;e<i;e++)this._ipad[e]=54^n[e],this._opad[e]=92^n[e];this._hash=q(t).update(this._ipad)}_transform(e,t,n){let i;try{this.update(e,t)}catch(e){i=e}finally{n(i)}}_flush(e){let t;try{this.push(this._final())}catch(e){t=e}e(t)}_final(){const e=this._hash.digest();return q(this._alg).update(this._opad).update(e).digest()}update(e,t){return this._hash.update(e,t),this}digest(t){const n=this._final()||e.alloc(0);return t?n.toString(t):n}}let M;function D(t){const n=new Uint8Array(t);return t>0&&(M.crypto||M.msCrypto).getRandomValues(n),e.from(n.buffer)}function B(){return["sha-1","sha-256","sha-512","md5"]}function U(e,t){return new F(e.toLowerCase(),t)}"undefined"!=typeof window?M=window:void 0!==i&&(M=i);const z=fetch,J=WebSocket,G=M.RTCPeerConnection}.call(this,n(10).Buffer,n(5))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=i.__importStar(n(1)),s=n(9),o=n(11),a=n(26),c=n(35),l=i.__importDefault(n(36));class u extends l.default{constructor(e){super(e),this.bitrateLimit=0,this.candidateBuffer=[],this.transportType=o.NS_JINGLE_ICE_UDP_1,this.restartingIce=!1,this.usingRelay=!1,this.maxRelayBandwidth=e.maxRelayBandwidth,this.pc=this.parent.createPeerConnection(this,{...e.config,iceServers:e.iceServers}),this.pc.oniceconnectionstatechange=()=>{this.onIceStateChange()},this.pc.onicecandidate=e=>{e.candidate?this.onIceCandidate(e):this.onIceEndOfCandidates()},this.restrictRelayBandwidth()}end(e="success",t=!1){this.pc.close(),super.end(e,t)}async restartIce(){if(this.isInitiator){void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this.restartingIce=!0;try{await this.processLocal("restart-ice",async()=>{const e=await this.pc.createOffer({iceRestart:!0}),t=a.importFromSDP(e.sdp);this.send(s.JingleAction.TransportInfo,{contents:t.media.map(e=>({creator:s.JingleSessionRole.Initiator,name:e.mid,transport:c.convertIntermediateToTransport(e,this.transportType)})),sid:this.sid}),await this.pc.setLocalDescription(e)})}catch(e){this._log("error","Could not create WebRTC offer",e),this.end(s.JingleReasonCondition.FailedTransport,!0)}}}async setMaximumBitrate(e){this.maximumBitrate&&(e=Math.min(e,this.maximumBitrate)),this.currentBitrate=e;const t=this.pc.getSenders().find(e=>!!e.track&&"video"===e.track.kind);if(t&&t.getParameters)try{await this.processLocal("set-bitrate",async()=>{const n=t.getParameters();n.encodings&&n.encodings.length||(n.encodings=[{}]),0===e?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=e,await t.setParameters(n)})}catch(e){this._log("error","Set maximumBitrate failed",e)}}async onTransportInfo(e,t){if(e.contents&&e.contents[0]&&e.contents[0].transport.gatheringComplete){const n={sdpMid:e.contents[0].name,candidate:""};try{"stable"===this.pc.signalingState?await this.pc.addIceCandidate(n):this.candidateBuffer.push(n)}catch(e){this._log("debug","Could not add null end-of-candidate")}finally{t()}return}if(this.pc.remoteDescription){const n=this.pc.remoteDescription,i=a.importFromSDP(n.sdp),r=i.media.find(t=>t.mid===e.contents[0].name).iceParameters.usernameFragment,o=e.contents[0].transport.usernameFragment;if(o&&r!==o){for(const[t,n]of e.contents.entries()){const e=n.transport;i.media[t].iceParameters={password:e.password,usernameFragment:e.usernameFragment},i.media[t].candidates=[]}try{if(await this.pc.setRemoteDescription({type:n.type,sdp:a.exportToSDP(i)}),await this.processBufferedCandidates(),"offer"===n.type){const e=await this.pc.createAnswer();await this.pc.setLocalDescription(e);const t=a.importFromSDP(e.sdp);this.send(s.JingleAction.TransportInfo,{contents:t.media.map(e=>({creator:s.JingleSessionRole.Initiator,name:e.mid,transport:c.convertIntermediateToTransport(e,this.transportType)})),sid:this.sid})}else this.restartingIce=!1}catch(e){return this._log("error","Could not do remote ICE restart",e),t(e),void this.end(s.JingleReasonCondition.FailedTransport)}}}const n=(e.contents||[]).map(e=>{const t=e.name,n=(e.transport.candidates||[]).map(async e=>{const n=r.writeCandidate(c.convertCandidateToIntermediate(e));if(this.pc.remoteDescription&&"stable"===this.pc.signalingState)try{await this.pc.addIceCandidate({sdpMid:t,candidate:n})}catch(e){this._log("error","Could not add ICE candidate",e)}else this.candidateBuffer.push({sdpMid:t,candidate:n})});return Promise.all(n)});try{await Promise.all(n),t()}catch(e){this._log("error","Could not process transport-info: "+e),t(e)}}async onSessionAccept(e,t){this.state="active";const n=c.convertRequestToIntermediate(e,this.peerRole),i=a.exportToSDP(n);try{await this.pc.setRemoteDescription({type:"answer",sdp:i}),await this.processBufferedCandidates(),this.parent.emit("accepted",this,void 0),t()}catch(e){this._log("error","Could not process WebRTC answer: "+e),t({condition:"general-error"})}}onSessionTerminate(e,t){this._log("info","Terminating session"),this.pc.close(),super.end(e.reason,!0),t()}onIceCandidate(e){if(!e.candidate||!e.candidate.candidate)return;const t=r.parseCandidate(e.candidate.candidate),n={contents:[{creator:s.JingleSessionRole.Initiator,name:e.candidate.sdpMid,transport:{candidates:[c.convertIntermediateToCandidate(t)],transportType:this.transportType,usernameFragment:t.usernameFragment}}]};this._log("info","Discovered new ICE candidate",n),this.send(s.JingleAction.TransportInfo,n)}onIceEndOfCandidates(){this._log("info","ICE end of candidates");const e=a.importFromSDP(this.pc.localDescription.sdp).media[0];this.send(s.JingleAction.TransportInfo,{contents:[{creator:s.JingleSessionRole.Initiator,name:e.mid,transport:{gatheringComplete:!0,transportType:this.transportType,usernameFragment:e.iceParameters.usernameFragment}}]})}onIceStateChange(){switch(this.pc.iceConnectionState){case"checking":this.connectionState="connecting";break;case"completed":case"connected":this.connectionState="connected";break;case"disconnected":if("stable"===this.pc.signalingState?this.connectionState="interrupted":this.connectionState="disconnected",this.restartingIce)return void this.end(s.JingleReasonCondition.FailedTransport);this.maybeRestartIce();break;case"failed":if("failed"===this.connectionState||this.restartingIce)return void this.end(s.JingleReasonCondition.FailedTransport);this.connectionState="failed",this.restartIce();break;case"closed":this.connectionState="disconnected",this.restartingIce?this.end(s.JingleReasonCondition.FailedTransport):this.end()}}async processBufferedCandidates(){for(const e of this.candidateBuffer)try{await this.pc.addIceCandidate(e)}catch(e){this._log("error","Could not add ICE candidate",e)}this.candidateBuffer=[]}restrictRelayBandwidth(){this.pc.addEventListener("iceconnectionstatechange",async()=>{if("completed"!==this.pc.iceConnectionState&&"connected"!==this.pc.iceConnectionState)return;const e=await this.pc.getStats();let t;if(e.forEach(n=>{"transport"===n.type&&(t=e.get(n.selectedCandidatePairId))}),t||e.forEach(e=>{"candidate-pair"===e.type&&e.selected&&(t=e)}),!t)return;let n=!1,i="",r="";if(t.remoteCandidateId){const n=e.get(t.remoteCandidateId);n&&(r=n.candidateType)}if(t.localCandidateId){const n=e.get(t.localCandidateId);n&&(i=n.candidateType)}"relay"!==i&&"relay"!==r||(n=!0),this.usingRelay=n,this.parent.emit("iceConnectionType",this,{localCandidateType:i,relayed:n,remoteCandidateType:r}),n&&void 0!==this.maxRelayBandwidth&&(this.maximumBitrate=this.maxRelayBandwidth,this.currentBitrate?this.setMaximumBitrate(Math.min(this.currentBitrate,this.maximumBitrate)):this.setMaximumBitrate(this.maximumBitrate))})}maybeRestartIce(){this.isInitiator&&(void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this._maybeRestartingIce=setTimeout(()=>{this._maybeRestartingIce=void 0,"disconnected"===this.pc.iceConnectionState&&this.restartIce()},2e3))}}t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertRequestToIntermediate=t.convertContentToIntermediate=t.convertIntermediateToRequest=t.convertIntermediateToTransport=t.convertCandidateToIntermediate=t.convertIntermediateToCandidate=t.convertIntermediateToApplication=void 0;const i=n(9),r=n(11);function s(e,t){const n=e.rtpParameters,s=e.rtcpParameters||{},o=e.rtpEncodingParameters||[];let a=!1;o&&o.length&&(a=!!o[0].ssrc);const c={applicationType:r.NS_JINGLE_RTP_1,codecs:[],headerExtensions:[],media:e.kind,rtcpMux:s.mux,rtcpReducedSize:s.reducedSize,sourceGroups:[],sources:[],ssrc:a?o[0].ssrc.toString():void 0,streams:[]};for(const e of n.headerExtensions||[]){const n={id:e.id,uri:e.uri};e.direction&&"sendrecv"!==e.direction&&(n.senders=i.directionToSenders(t,e.direction)),c.headerExtensions.push(n)}s.ssrc&&s.cname&&(c.sources=[{parameters:{cname:s.cname},ssrc:s.ssrc.toString()}]),a&&o[0]&&o[0].rtx&&(c.sourceGroups=[{semantics:"FID",sources:[o[0].ssrc.toString(),o[0].rtx.ssrc.toString()]}]);for(const t of e.streams||[])c.streams.push({id:t.stream,track:t.track});for(const e of n.codecs||[]){const t={channels:e.channels,clockRate:e.clockRate,id:e.payloadType.toString(),name:e.name,parameters:e.parameters,rtcpFeedback:e.rtcpFeedback};e.maxptime&&(t.maxptime=e.maxptime),e.parameters&&e.parameters.ptime&&(t.ptime=parseInt(e.parameters.ptime,10)),c.codecs.push(t)}return c}function o(e){let t;return t="rtp"===e.component?1:"rtcp"===e.component?2:e.component,{component:t,foundation:e.foundation,generation:void 0,id:void 0,ip:e.ip,network:void 0,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function a(e){return{address:e.ip,component:1===e.component?"rtp":2===e.component?"rtcp":e.component,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function c(e,t){const n=e.iceParameters,i=e.dtlsParameters,r={candidates:[],transportType:t};n&&(r.usernameFragment=n.usernameFragment,r.password=n.password,n.iceLite&&(r.iceLite=!0)),i&&(r.fingerprints=i.fingerprints.map(t=>({algorithm:t.algorithm,setup:e.setup,value:t.value}))),e.sctp&&(r.sctp=e.sctp);for(const t of e.candidates||[])r.candidates.push(o(t));return r}function l(e,t){const n=e.application||{},s=e.transport,o=n&&n.applicationType===r.NS_JINGLE_RTP_1,c={direction:i.sendersToDirection(t,e.senders),kind:n.media||"application",mid:e.name,protocol:o?"UDP/TLS/RTP/SAVPF":"UDP/DTLS/SCTP"};if(o){if(c.rtcpParameters={compound:!n.rtcpReducedSize,mux:n.rtcpMux,reducedSize:n.rtcpReducedSize},n.sources&&n.sources.length){const e=n.sources[0];c.rtcpParameters.ssrc=parseInt(e.ssrc,10),e.parameters&&(c.rtcpParameters.cname=e.parameters.cname)}if(c.rtpParameters={codecs:[],fecMechanisms:[],headerExtensions:[],rtcp:[]},n.streams){c.streams=[];for(const e of n.streams)c.streams.push({stream:e.id,track:e.track})}if(n.ssrc&&(c.rtpEncodingParameters=[{ssrc:parseInt(n.ssrc,10)}],n.sourceGroups&&n.sourceGroups.length)){const e=n.sourceGroups[0];c.rtpEncodingParameters[0].rtx={ssrc:parseInt(e.sources[1],10)}}let e=!1,r=!1;for(const t of n.codecs||[]){const n=t.parameters||{},i=[];for(const e of t.rtcpFeedback||[])i.push({parameter:e.parameter,type:e.type});if("red"===t.name||"ulpfec"===t.name){e=e||"red"===t.name,r=r||"ulpfec"===t.name;const n=t.name.toUpperCase();c.rtpParameters.fecMechanisms.includes(n)||c.rtpParameters.fecMechanisms.push(n)}c.rtpParameters.codecs.push({channels:t.channels,clockRate:t.clockRate,name:t.name,numChannels:t.channels,parameters:n,payloadType:parseInt(t.id,10),rtcpFeedback:i})}for(const e of n.headerExtensions||[])c.rtpParameters.headerExtensions.push({direction:i.sendersToDirection(t,e.senders||"both"),id:e.id,uri:e.uri})}if(s){if(s.usernameFragment&&s.password&&(c.iceParameters={password:s.password,usernameFragment:s.usernameFragment},s.iceLite&&(c.iceParameters.iceLite=!0)),s.fingerprints&&s.fingerprints.length){c.dtlsParameters={fingerprints:[],role:"auto"};for(const e of s.fingerprints)c.dtlsParameters.fingerprints.push({algorithm:e.algorithm,value:e.value});s.sctp&&(c.sctp=s.sctp),c.setup=s.fingerprints[0].setup}c.candidates=(s.candidates||[]).map(a)}return c}t.convertIntermediateToApplication=s,t.convertIntermediateToCandidate=o,t.convertCandidateToIntermediate=a,t.convertIntermediateToTransport=c,t.convertIntermediateToRequest=function(e,t,n){return{contents:e.media.map(e=>({application:"audio"===e.kind||"video"===e.kind?s(e,t):{applicationType:"datachannel",protocol:e.protocol},creator:i.JingleSessionRole.Initiator,name:e.mid,senders:i.directionToSenders(t,e.direction),transport:c(e,n)})),groups:e.groups?e.groups.map(e=>({contents:e.mids,semantics:e.semantics})):[]}},t.convertContentToIntermediate=l,t.convertRequestToIntermediate=function(e,t){const n={groups:[],media:[]};for(const t of e.groups||[])n.groups.push({mids:t.contents,semantics:t.semantics});for(const i of e.contents||[])n.media.push(l(i,t));return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(14),r=n(9),s=n(60),o={condition:r.StanzaErrorCondition.BadRequest},a={condition:r.StanzaErrorCondition.FeatureNotImplemented,jingleError:r.JingleErrorCondition.UnsupportedInfo,type:"modify"};t.default=class{constructor(e){this.parent=e.parent,this.sid=e.sid||s.uuid(),this.peerID=e.peerID,this.role=e.initiator?r.JingleSessionRole.Initiator:r.JingleSessionRole.Responder,this._sessionState="starting",this._connectionState="starting",this.pendingApplicationTypes=e.applicationTypes||[],this.pendingAction=void 0,this.processingQueue=i.priorityQueue(async(e,t)=>{if("ended"===this.state)return"local"===e.type&&e.reject&&e.reject(new Error("Session ended")),void(t&&t());if("local"===e.type){this._log("debug","Processing local action:",e.name);try{const t=await e.handler();e.resolve(t)}catch(t){e.reject(t)}return void(t&&t())}const{action:n,changes:i,cb:s}=e;return this._log("debug","Processing remote action:",n),new Promise(e=>{const o=(n,i)=>{s(n,i),t&&t(),e()};switch(n){case r.JingleAction.ContentAccept:return this.onContentAccept(i,o);case r.JingleAction.ContentAdd:return this.onContentAdd(i,o);case r.JingleAction.ContentModify:return this.onContentModify(i,o);case r.JingleAction.ContentReject:return this.onContentReject(i,o);case r.JingleAction.ContentRemove:return this.onContentRemove(i,o);case r.JingleAction.DescriptionInfo:return this.onDescriptionInfo(i,o);case r.JingleAction.SecurityInfo:return this.onSecurityInfo(i,o);case r.JingleAction.SessionAccept:return this.onSessionAccept(i,o);case r.JingleAction.SessionInfo:return this.onSessionInfo(i,o);case r.JingleAction.SessionInitiate:return this.onSessionInitiate(i,o);case r.JingleAction.SessionTerminate:return this.onSessionTerminate(i,o);case r.JingleAction.TransportAccept:return this.onTransportAccept(i,o);case r.JingleAction.TransportInfo:return this.onTransportInfo(i,o);case r.JingleAction.TransportReject:return this.onTransportReject(i,o);case r.JingleAction.TransportReplace:return this.onTransportReplace(i,o);default:this._log("error","Invalid or unsupported action: "+n),o({condition:r.StanzaErrorCondition.BadRequest})}})},1)}get isInitiator(){return this.role===r.JingleSessionRole.Initiator}get peerRole(){return this.isInitiator?r.JingleSessionRole.Responder:r.JingleSessionRole.Initiator}get state(){return this._sessionState}set state(e){e!==this._sessionState&&(this._log("info","Changing session state to: "+e),this._sessionState=e,this.parent&&this.parent.emit("sessionState",this,e))}get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._log("info","Changing connection state to: "+e),this._connectionState=e,this.parent&&this.parent.emit("connectionState",this,e))}send(e,t){(t=t||{}).sid=this.sid,t.action=e;new Set([r.JingleAction.ContentAccept,r.JingleAction.ContentAdd,r.JingleAction.ContentModify,r.JingleAction.ContentReject,r.JingleAction.ContentRemove,r.JingleAction.SessionAccept,r.JingleAction.SessionInitiate,r.JingleAction.TransportAccept,r.JingleAction.TransportReject,r.JingleAction.TransportReplace]).has(e)?this.pendingAction=e:this.pendingAction=void 0,this.parent.signal(this,{id:s.uuid(),jingle:t,to:this.peerID,type:"set"})}processLocal(e,t){return new Promise((n,i)=>{this.processingQueue.push({handler:t,name:e,reject:i,resolve:n,type:"local"},1)})}process(e,t,n){this.processingQueue.push({action:e,cb:n,changes:t,type:"remote"},2)}start(e,t){this._log("error","Can not start base sessions"),this.end("unsupported-applications",!0)}accept(e,t){this._log("error","Can not accept base sessions"),this.end("unsupported-applications")}cancel(){this.end("cancel")}decline(){this.end("decline")}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}_log(e,t,...n){this.parent&&(t=this.sid+": "+t,this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n))}onSessionInitiate(e,t){t()}onSessionAccept(e,t){t()}onSessionTerminate(e,t){this.end(e.reason,!0),t()}onSessionInfo(e,t){e.info?t(a):t()}onSecurityInfo(e,t){t(a)}onDescriptionInfo(e,t){t(a)}onTransportInfo(e,t){t(a)}onContentAdd(e,t){t(),this.send(r.JingleAction.ContentReject,{reason:{condition:r.JingleReasonCondition.FailedApplication,text:"content-add is not supported"}})}onContentAccept(e,t){t(o)}onContentReject(e,t){t(o)}onContentModify(e,t){t(o)}onContentRemove(e,t){t(o)}onTransportReplace(e,t){t(),this.send(r.JingleAction.TransportReject,{reason:{condition:r.JingleReasonCondition.FailedTransport,text:"transport-replace is not supported"}})}onTransportAccept(e,t){t(o)}onTransportReject(e,t){t(o)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const i=n(70),r=n(73),s=n(141);n(113);const o=n(114),a=n(116),c=n(136),l=n(140),u=n(8),p=n(18),d=n(27);let h={ping:l.Ping,reconnector:c.Reconnector,notifications:o.Notifications,webrtcSessions:a.WebrtcExtension};const f={connected:"session:started",_connected:"connected"};class m{constructor(e){this.connected=!1,this.connecting=!1,this.autoReconnect=!0,this.hardReconnectCount=0,this.reconnectLeakTime=6e5,this.deadChannels=[],this.backgroundAssistantMode=!1,this.isGuest=!1,this.http=new p.HttpClient;const t=r.createClient({});t.sasl.mechanisms.find(e=>"ANONYMOUS"===e.name).priority=0,t.sasl.mechanisms=t.sasl.mechanisms.sort((e,t)=>t.priority-e.priority),this._stanzaio=t,this.reconnectOnNoLongerSubscribed=!1!==e.reconnectOnNoLongerSubscribed,this.config={host:e.host,apiHost:e.apiHost||e.host.replace("wss://streaming.",""),authToken:e.authToken,jwt:e.jwt,jid:e.jid,jidResource:e.jidResource,channelId:null,appName:e.appName,appVersion:e.appVersion},this.backgroundAssistantMode=this.checkIsBackgroundAssistant(),this.isGuest=!this.backgroundAssistantMode&&!e.authToken;let n=e.authToken||"",o=`https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;this.backgroundAssistantMode&&(n=e.jwt,o+="/backgroundassistant"),this.logger=new s.Logger({accessToken:n,url:o,uploadDebounceTime:1e3,initializeServerLogging:!this.isGuest&&!e.optOutOfWebrtcStatsTelemetry,appVersion:m.version,appName:"streaming-client",logLevel:this.config.logLevel||"info",logger:e.logger||console,formatters:e.logFormatters,originAppName:e.appName,originAppVersion:e.appVersion,originAppId:e.appId}),this.on("disconnected",()=>{if(this._stanzaio.transport||this.connecting)return void this.logger.info("disconnected event received, but reconnection is in progress");this.connected=!1,this._ping.stop(),this.logger.info("Streaming client disconnected.");const e=this.config.channelId;this.autoReconnect&&!this.deadChannels.includes(e)&&(this.logger.info("Streaming client disconnected unexpectedly. Attempting to auto reconnect",{channelId:e}),this._reconnector.start())}),this.on("connected",async e=>{this.streamId=e.resource,this._ping.start(),this.connected=!0,this._reconnector.stop(),this.connecting=!1}),this.on("session:end",()=>{this._ping.stop()}),this._stanzaio.on("sasl",e=>{if("failure"===e.type){if(this.logger.error("Authentication failed connecting to streaming service",{...e,channelId:this.config.channelId}),"temporary-auth-failure"!==e.condition)return this._ping.stop(),this.autoReconnect=!1,this.disconnect();this.logger.info("Temporary auth failure, continuing reconnect attempts")}}),this.on("notify:no_longer_subscribed",e=>{this._ping.stop();const t=e.eventBody.channelId;if(this.deadChannels.push(t),t===this.config.channelId){if(this.hardReconnectCount>=2)return this.logger.error(`no_longer_subscribed has been called ${this.hardReconnectCount} times and the threshold is 2, not attempting to reconnect\n channelId: ${this.config.channelId}`),void this.cleanupLeakTimer();if(this.logger.info("no_longer_subscribed received"),this.reconnectOnNoLongerSubscribed)return this.logger.info("streaming client attempting to reconnect on a new channel"),this.hardReconnectCount++,this.leakyReconnectTimer||(this.leakyReconnectTimer=setInterval(()=>{this.hardReconnectCount>0?this.hardReconnectCount--:this.cleanupLeakTimer()},this.reconnectLeakTime)),this._reconnector.hardReconnect();this.logger.info("`reconnectOnNoLongerSubscribed` is false, not attempting to reconnect streaming client")}else this.logger.warn("received no_longer_subscribed event for a non active channelId")}),Object.keys(h).forEach(n=>{const r=new h[n](this,e);"function"==typeof r.handleIq&&t.on("iq",r.handleIq.bind(r)),"function"==typeof r.handleMessage&&t.on("message",r.handleMessage.bind(r)),r.tokenBucket||(r.tokenBucket=new i.TokenBucket(20,25,1e3),r.tokenBucket.content=25),"function"==typeof r.on&&r.on("send",(function(e,n=!1){return r.tokenBucket.removeTokens(1,()=>!0===n?t.sendMessage(e):t.sendIQ(e))})),this[n]=r.expose,this["_"+n]=r})}checkIsBackgroundAssistant(){if(this.config.jwt){const e=u.parseJwt(this.config.jwt);return e&&"urn:purecloud:screenrecording"===e.iss}return!1}cleanupLeakTimer(){clearInterval(this.leakyReconnectTimer),this.leakyReconnectTimer=null}on(e,...t){return f[e]?this._stanzaio.on(f[e],...t):this._stanzaio.on(e,...t),this}once(e,...t){return f[e]?this._stanzaio.once(f[e],...t):this._stanzaio.once(e,...t),this}off(e,...t){return f[e]?this._stanzaio.off(f[e],...t):this._stanzaio.off(e,...t),this}disconnect(){return this.logger.info("streamingClient.disconnect was called"),this.stopServerLogging(),u.timeoutPromise(e=>{this._stanzaio.once("disconnected",e),this.autoReconnect=!1,this._reconnector.stop(new Error("Cancelling reconnect")),this.http.stopAllRetries(),this._stanzaio.disconnect()},1e3,"disconnecting streaming service")}reconnect(){return this.logger.info("streamingClient.reconnect was called"),u.timeoutPromise(e=>{this._stanzaio.once("session:started",e),this.autoReconnect=!0,this._stanzaio.disconnect()},1e4,"reconnecting streaming service")}async connect(e={keepTryingOnFailure:!1,retryDelay:5e3}){var t;try{this.logger.info("streamingClient.connect was called"),await this._tryToConnect()}catch(n){let i=!0;if(n instanceof d.AxiosError&&[401,403].includes((null===(t=n.response)||void 0===t?void 0:t.status)||0)&&(i=!1),e.keepTryingOnFailure&&this.autoReconnect){if(i)return await u.wait(e.retryDelay),this.connect(e);this.logger.error("Streaming client received and error that it can't recover from and will not attempt to reconnect",{error:n})}throw n}}_tryToConnect(){if(this.startServerLogging(),this.connecting=!0,this.config.jwt)return u.timeoutPromise(e=>{this.once("connected",e);const t=function(e){const t=u.parseJwt(e.jwt);let n;try{n=t.data.jid.split("@")[1].replace("conference.","")}catch(e){throw new Error("failed to parse jid")}return{transports:{websocket:`${e.host.replace(/\/$/,"")}/stream/jwt/${e.jwt}`},server:n,sasl:["anonymous"]}}(this.config);this._stanzaio.updateConfig(t),this._stanzaio.connect()},1e4,"connecting to streaming service with jwt").catch(e=>(this.connecting=!1,Promise.reject(e)));let e;if(this.config.jid)e=Promise.resolve(this.config.jid);else{const t={method:"get",host:this.config.apiHost,authToken:this.config.authToken,logger:this.logger};e=this.http.requestApiWithRetry("users/me",t).promise.then(e=>e.data.chat.jabberId)}const t={method:"post",host:this.config.apiHost,authToken:this.config.authToken,logger:this.logger},n=this.http.requestApiWithRetry("notifications/channels?connectionType=streaming",t).promise.then(e=>e.data.id);return Promise.all([e,n]).then(([e,t])=>(this.config.jid=e,this.config.channelId=t,this.autoReconnect=!0,u.timeoutPromise(e=>{this.once("connected",e);const t=function(e){let t=e.host.replace(/\/$/,"");return{jid:e.jid,resource:e.jidResource,credentials:{username:e.jid,password:"authKey:"+e.authToken},transports:{websocket:`${t}/stream/channels/${e.channelId}`}}}(this.config);this._stanzaio.updateConfig(t),this._stanzaio.connect()},1e4,"connecting to streaming service",{jid:e,channelId:t}))).catch(e=>(this.connecting=!1,Promise.reject(e)))}stopServerLogging(){this.logger.sendAllLogsInstantly(),this.logger.stopServerLogging(),this._webrtcSessions.flushStats()}startServerLogging(){this.logger.startServerLogging()}setAccessToken(e){this.config.authToken=e,this.logger.setAccessToken(e)}static extend(e,t){if(h[e])throw new Error("Cannot register already existing namespace "+e);h[e]=t}get version(){return m.version}static get version(){return"14.2.1"}}t.Client=m},function(e,t,n){(function(t){var n=function(e,t,n,i){if(this.bucketSize=e,this.tokensPerInterval=t,"string"==typeof n)switch(n){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=6e4;break;case"hr":case"hour":this.interval=36e5;break;case"day":this.interval=864e5;break;default:throw new Error("Invaid interval "+n)}else this.interval=n;this.parentBucket=i,this.content=0,this.lastDrip=+new Date};n.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(e,n){var i=this;return this.bucketSize?e>this.bucketSize?(t.nextTick(n.bind(null,"Requested tokens "+e+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),e>this.content?r():this.parentBucket?this.parentBucket.removeTokens(e,(function(t,s){return t?n(t,null):e>i.content?r():(i.content-=e,void n(null,Math.min(s,i.content)))})):(this.content-=e,t.nextTick(n.bind(null,null,this.content)),!0)):(t.nextTick(n.bind(null,null,e,Number.POSITIVE_INFINITY)),!0);function r(){var t=Math.ceil((e-i.content)*(i.interval/i.tokensPerInterval));return setTimeout((function(){i.removeTokens(e,n)}),t),!1}},tryRemoveTokens:function(e){return!this.bucketSize||!(e>this.bucketSize)&&(this.drip(),!(e>this.content)&&(!(this.parentBucket&&!this.parentBucket.tryRemoveTokens(e))&&(this.content-=e,!0)))},drip:function(){if(this.tokensPerInterval){var e=+new Date,t=Math.max(e-this.lastDrip,0);this.lastDrip=e;var n=t*(this.tokensPerInterval/this.interval);this.content=Math.min(this.content+n,this.bucketSize)}else this.content=this.bucketSize}},e.exports=n}).call(this,n(7))},function(e,t,n){"use strict";(function(t,i){var r=n(19);e.exports=y;var s,o=n(78);y.ReadableState=b;n(3).EventEmitter;var a=function(e,t){return e.listeners(t).length},c=n(40),l=n(20).Buffer,u=t.Uint8Array||function(){};var p=Object.create(n(15));p.inherits=n(16);var d=n(79),h=void 0;h=d&&d.debuglog?d.debuglog("stream"):function(){};var f,m=n(80),g=n(41);p.inherits(y,c);var v=["error","close","destroy","pause","resume"];function b(e,t){e=e||{};var i=t instanceof(s=s||n(12));this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,o=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=n(43).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function y(e){if(s=s||n(12),!(this instanceof y))return new y(e);this._readableState=new b(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function _(e,t,n,i,r){var s,o=e._readableState;null===t?(o.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,x(e)}(e,o)):(r||(s=function(e,t){var n;i=t,l.isBuffer(i)||i instanceof u||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var i;return n}(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),i?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):S(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?S(e,o,t,!1):k(e,o)):S(e,o,t,!1))):i||(o.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(o)}function S(e,t,n,i){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),k(e,t)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.push(null),t(e)},y.prototype.push=function(e,t){var n,i=this._readableState;return i.objectMode?n=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=l.from(e,t),t=""),n=!0),_(this,e,t,!1,n)},y.prototype.unshift=function(e){return _(this,e,null,!0,!1)},y.prototype.isPaused=function(){return!1===this._readableState.flowing},y.prototype.setEncoding=function(e){return f||(f=n(43).StringDecoder),this._readableState.decoder=new f(e),this._readableState.encoding=e,this};function w(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?r.nextTick(T,e):T(e))}function T(e){h("emit readable"),e.emit("readable"),N(e)}function k(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(I,e,t))}function I(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(h("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function j(e){h("readable nexttick read 0"),e.read(0)}function E(e,t){t.reading||(h("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),N(e),t.flowing&&!t.reading&&e.read(0)}function N(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function C(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var i;e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):i=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,i=1,r=n.data;e-=r.length;for(;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(o===s.length?r+=s:r+=s.slice(0,e),0===(e-=o)){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}(e,t):function(e,t){var n=l.allocUnsafe(e),i=t.head,r=1;i.data.copy(n),e-=i.data.length;for(;i=i.next;){var s=i.data,o=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,o),0===(e-=o)){o===s.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=s.slice(o));break}++r}return t.length-=r,n}(e,t);return i}(e,t.buffer,t.decoder),n);var n}function R(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,r.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1}y.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):x(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&R(this),null;var i,r=t.needReadable;return h("need readable",r),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",r=!0),t.ended||t.reading?h("reading or ended",r=!1):r&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=w(n,t))),null===(i=e>0?C(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&R(this)),null!==i&&this.emit("data",i),i},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var n=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,h("pipe count=%d opts=%j",s.pipesCount,t);var c=(!t||!1!==t.end)&&e!==i.stdout&&e!==i.stderr?u:y;function l(t,i){h("onunpipe"),t===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,h("cleanup"),e.removeListener("close",v),e.removeListener("finish",b),e.removeListener("drain",p),e.removeListener("error",g),e.removeListener("unpipe",l),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",m),d=!0,!s.awaitDrain||e._writableState&&!e._writableState.needDrain||p())}function u(){h("onend"),e.end()}s.endEmitted?r.nextTick(c):n.once("end",c),e.on("unpipe",l);var p=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,N(e))}}(n);e.on("drain",p);var d=!1;var f=!1;function m(t){h("ondata"),f=!1,!1!==e.write(t)||f||((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==A(s.pipes,e))&&!d&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,f=!0),n.pause())}function g(t){h("onerror",t),y(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",b),y()}function b(){h("onfinish"),e.removeListener("close",v),y()}function y(){h("unpipe"),n.unpipe(e)}return n.on("data",m),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?o(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",g),e.once("close",v),e.once("finish",b),e.emit("pipe",n),s.flowing||(h("pipe resume"),n.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<r;s++)i[s].emit("unpipe",this,n);return this}var o=A(t.pipes,e);return-1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},y.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&x(this):r.nextTick(j,this))}return n},y.prototype.addListener=y.prototype.on,y.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(E,e,t))}(this,e)),this},y.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this},y.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;for(var r in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(r){(h("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r)||(n.objectMode||r&&r.length)&&(t.push(r)||(i=!0,e.pause()))})),e)void 0===this[r]&&"function"==typeof e[r]&&(this[r]=function(t){return function(){return e[t].apply(e,arguments)}}(r));for(var s=0;s<v.length;s++)e.on(v[s],this.emit.bind(this,v[s]));return this._read=function(t){h("wrapped _read",t),i&&(i=!1,e.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=C}).call(this,n(5),n(7))},function(e,t,n){e.exports=n(3).EventEmitter},function(e,t,n){"use strict";var i=n(19);function r(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||i.nextTick(r,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?(i.nextTick(r,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";(function(t,i,r){var s=n(19);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var i=e.entry;e.entry=null;for(;i;){var r=i.callback;t.pendingcb--,r(n),i=i.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=b;var a,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?i:s.nextTick;b.WritableState=v;var l=Object.create(n(15));l.inherits=n(16);var u={deprecate:n(84)},p=n(40),d=n(20).Buffer,h=r.Uint8Array||function(){};var f,m=n(41);function g(){}function v(e,t){a=a||n(12),e=e||{};var i=t instanceof a;this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,l=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i&&(l||0===l)?l:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var p=!1===e.decodeStrings;this.decodeStrings=!p,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,i=n.sync,r=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,i,r){--t.pendingcb,n?(s.nextTick(r,i),s.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(r(i),e._writableState.errorEmitted=!0,e.emit("error",i),T(e,t))}(e,n,i,t,r);else{var o=w(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),i?c(_,e,n,o,r):_(e,n,o,r)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(e){if(a=a||n(12),!(f.call(b,this)||this instanceof a))return new b(e);this._writableState=new v(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),p.call(this)}function y(e,t,n,i,r,s,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,n?e._writev(r,t.onwrite):e._write(r,s,t.onwrite),t.sync=!1}function _(e,t,n,i){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),T(e,t)}function S(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,r=new Array(i),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)r[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;r.allBuffers=c,y(e,t,!0,t.length,r,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,p=n.callback;if(y(e,t,!1,t.objectMode?1:l.length,l,u,p),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function w(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),T(e,t)}))}function T(e,t){var n=w(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,s.nextTick(x,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}l.inherits(b,p),v.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(v.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===b&&(e&&e._writableState instanceof v)}})):f=function(e){return e instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(e,t,n){var i,r=this._writableState,o=!1,a=!r.objectMode&&(i=e,d.isBuffer(i)||i instanceof h);return a&&!d.isBuffer(e)&&(e=function(e){return d.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=g),r.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),s.nextTick(t,n)}(this,n):(a||function(e,t,n,i){var r=!0,o=!1;return null===n?o=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),s.nextTick(i,o),r=!1),r}(this,r,e,n))&&(r.pendingcb++,o=function(e,t,n,i,r,s){if(!n){var o=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=d.from(t,n));return t}(t,i,r);i!==o&&(n=!0,r="buffer",i=o)}var a=t.objectMode?1:i.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:r,isBuf:n,callback:s,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else y(e,t,!1,a,i,r,s);return c}(this,r,a,e,t,n)),o},b.prototype.cork=function(){this._writableState.corked++},b.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||S(this,e))},b.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(e,t,n){var i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||function(e,t,n){t.ending=!0,T(e,t),n&&(t.finished?s.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,i,n)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),b.prototype.destroy=m.destroy,b.prototype._undestroy=m.undestroy,b.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(7),n(82).setImmediate,n(5))},function(e,t,n){"use strict";var i=n(20).Buffer,r=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===r||!r(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=p,t=3;break;default:return this.write=d,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},s.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},s.prototype.text=function(e,t){var n=function(e,t,n){var i=t.length-1;if(i<n)return 0;var r=o(t[i]);if(r>=0)return r>0&&(e.lastNeed=r-1),r;if(--i<n||-2===r)return 0;if((r=o(t[i]))>=0)return r>0&&(e.lastNeed=r-2),r;if(--i<n||-2===r)return 0;if((r=o(t[i]))>=0)return r>0&&(2===r?r=0:e.lastNeed=r-3),r;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";e.exports=o;var i=n(12),r=Object.create(n(15));function s(e,t){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),i(e);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",a)}function a(){var e=this;"function"==typeof this._flush?this._flush((function(t,n){c(e,t,n)})):c(this,null,null)}function c(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}r.inherits=n(16),r.inherits(o,i),o.prototype.push=function(e,t){return this._transformState.needTransform=!1,i.prototype.push.call(this,e,t)},o.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(e,t,n){var i=this._transformState;if(i.writecb=n,i.writechunk=e,i.writeencoding=t,!i.transforming){var r=this._readableState;(i.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}},o.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},o.prototype._destroy=function(e,t){var n=this;i.prototype._destroy.call(this,e,(function(e){t(e),n.emit("close")}))}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var i=new Uint8Array(16);e.exports=function(){return n(i),i}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,r=n;return[r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]]].join("")}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return e.apply(t,n)}}},function(e,t,n){"use strict";var i=n(2);function r(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(i.isURLSearchParams(t))s=t.toString();else{var o=[];i.forEach(t,(function(e,t){null!=e&&(i.isArray(e)?t+="[]":e=[e],i.forEach(e,(function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),o.push(r(t)+"="+r(e))})))})),s=o.join("&")}if(s){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},function(e,t,n){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";(function(t){var i=n(2);e.exports=function(e,n){n=n||new FormData;var r=[];function s(e){return null===e?"":i.isDate(e)?e.toISOString():i.isArrayBuffer(e)||i.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):t.from(e):e}return function e(t,o){if(i.isPlainObject(t)||i.isArray(t)){if(-1!==r.indexOf(t))throw Error("Circular reference detected in "+o);r.push(t),i.forEach(t,(function(t,r){if(!i.isUndefined(t)){var a,c=o?o+"."+r:r;if(t&&!o&&"object"==typeof t)if(i.endsWith(r,"{}"))t=JSON.stringify(t);else if(i.endsWith(r,"[]")&&(a=i.toArray(t)))return void a.forEach((function(e){!i.isUndefined(e)&&n.append(c,s(e))}));e(t,c)}})),r.pop()}else n.append(o,s(t))}(e),n}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";var i=n(2),r=n(94),s=n(95),o=n(48),a=n(52),c=n(98),l=n(99),u=n(49),p=n(13),d=n(21),h=n(100);e.exports=function(e){return new Promise((function(t,n){var f,m=e.data,g=e.headers,v=e.responseType;function b(){e.cancelToken&&e.cancelToken.unsubscribe(f),e.signal&&e.signal.removeEventListener("abort",f)}i.isFormData(m)&&i.isStandardBrowserEnv()&&delete g["Content-Type"];var y=new XMLHttpRequest;if(e.auth){var _=e.auth.username||"",S=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";g.Authorization="Basic "+btoa(_+":"+S)}var w=a(e.baseURL,e.url);function x(){if(y){var i="getAllResponseHeaders"in y?c(y.getAllResponseHeaders()):null,s={data:v&&"text"!==v&&"json"!==v?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:i,config:e,request:y};r((function(e){t(e),b()}),(function(e){n(e),b()}),s),y=null}}if(y.open(e.method.toUpperCase(),o(w,e.params,e.paramsSerializer),!0),y.timeout=e.timeout,"onloadend"in y?y.onloadend=x:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(x)},y.onabort=function(){y&&(n(new p("Request aborted",p.ECONNABORTED,e,y)),y=null)},y.onerror=function(){n(new p("Network Error",p.ERR_NETWORK,e,y,y)),y=null},y.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",i=e.transitional||u;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new p(t,i.clarifyTimeoutError?p.ETIMEDOUT:p.ECONNABORTED,e,y)),y=null},i.isStandardBrowserEnv()){var T=(e.withCredentials||l(w))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;T&&(g[e.xsrfHeaderName]=T)}"setRequestHeader"in y&&i.forEach(g,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete g[t]:y.setRequestHeader(t,e)})),i.isUndefined(e.withCredentials)||(y.withCredentials=!!e.withCredentials),v&&"json"!==v&&(y.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&y.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&y.upload&&y.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(f=function(e){y&&(n(!e||e&&e.type?new d:e),y.abort(),y=null)},e.cancelToken&&e.cancelToken.subscribe(f),e.signal&&(e.signal.aborted?f():e.signal.addEventListener("abort",f))),m||(m=null);var k=h(w);k&&-1===["http","https","file"].indexOf(k)?n(new p("Unsupported protocol "+k+":",p.ERR_BAD_REQUEST,e)):y.send(m)}))}},function(e,t,n){"use strict";var i=n(96),r=n(97);e.exports=function(e,t){return e&&!i(t)?r(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var i=n(2);e.exports=function(e,t){t=t||{};var n={};function r(e,t){return i.isPlainObject(e)&&i.isPlainObject(t)?i.merge(e,t):i.isPlainObject(t)?i.merge({},t):i.isArray(t)?t.slice():t}function s(n){return i.isUndefined(t[n])?i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function o(e){if(!i.isUndefined(t[e]))return r(void 0,t[e])}function a(n){return i.isUndefined(t[n])?i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function c(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var l={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return i.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||s,r=t(e);i.isUndefined(r)&&t!==c||(n[e]=r)})),n}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(109),r=function(){function e(e){this.options=e,this.attempt=0}return e.prototype.apply=function(){var e=this;return new Promise((function(t){return setTimeout(t,e.jitteredDelay)}))},e.prototype.setAttemptNumber=function(e){this.attempt=e},Object.defineProperty(e.prototype,"jitteredDelay",{get:function(){return i.JitterFactory(this.options)(this.delay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"delay",{get:function(){var e=this.options.startingDelay,t=this.options.timeMultiple,n=this.numOfDelayedAttempts,i=e*Math.pow(t,n);return Math.min(i,this.options.maxDelay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt},enumerable:!0,configurable:!0}),e}();t.Delay=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.define=t.XMLElement=t.Translator=t.Registry=t.StreamParser=t.parse=t.Parser=void 0;const i=n(0),r=i.__importDefault(n(23));t.XMLElement=r.default;const s=i.__importDefault(n(126));t.Registry=s.default;const o=i.__importDefault(n(58));t.Translator=o.default,i.__exportStar(n(24),t),i.__exportStar(n(31),t),i.__exportStar(n(128),t);var a=n(32);Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return i.__importDefault(a).default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return a.parse}});var c=n(129);Object.defineProperty(t,"StreamParser",{enumerable:!0,get:function(){return i.__importDefault(c).default}}),t.define=function(e){return t=>{t.define(e)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(31);t.default=class{constructor(){this.parents=new Set,this.placeholder=!1,this.typeField="",this.versionField="",this.defaultType="",this.defaultVersion="",this.languageField="lang",this.typeValues=new Map,this.typeOrders=new Map,this.importers=new Map,this.exporters=new Map,this.children=new Map,this.childrenIndex=new Map,this.implicitChildren=new Set,this.contexts=new Map}addChild(e,t,n=!1,i,r){const s={multiple:n||!1,name:e,selector:i,translator:t},o=this.children.get(e);if(!o){s.translator.parents.add(this),this.children.set(e,s);for(const[n]of t.importers)this.implicitChildren.has(n)||this.childrenIndex.set(n,e);return void(r&&this.implicitChildren.add(r))}const a=o.translator;o.multiple=n,i&&o.selector&&i!==o.selector&&(o.selector=void 0);for(const[n,i]of t.importers){const[r,s]=(a.typeValues.get(n)||"").split("__v__");a.updateDefinition({contexts:t.contexts,element:i.element,exporterOrdering:new Map,exporters:new Map,importerOrdering:i.fieldOrders,importers:i.fields,namespace:i.namespace,optionalNamespaces:new Map,type:r,version:s}),this.implicitChildren.has(n)||this.childrenIndex.set(n,e)}for(const[e,n]of t.exporters){const[i,r]=e.split("__v__");a.updateDefinition({contexts:t.contexts,element:n.element,exporterOrdering:n.fieldOrders,exporters:n.fields,importerOrdering:new Map,importers:new Map,namespace:n.namespace,optionalNamespaces:n.optionalNamespaces,type:i,version:r})}}addContext(e,t,n,i,r,s){t&&(e=`${e}[${t}]`);let o=this.contexts.get(e);o||(o={typeField:"",versionField:"",typeValues:new Map}),s&&(o.impliedType=r),o.typeField=n||"",o.typeValues.set(i,r),this.contexts.set(e,o)}getChild(e){const t=this.children.get(e);if(t)return t.translator}getImportKey(e){return this.childrenIndex.get(`{${e.getNamespace()}}${e.getName()}`)}updateDefinition(e){const t=`{${e.namespace}}${e.element}`,n=e.type||this.defaultType,i=e.version||this.defaultVersion,r=i?`${n}__v__${i}`:n,s=this.importers.get(t)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace};for(const[t,n]of e.importers)s.fields.set(t,n);for(const[t,n]of e.importerOrdering)s.fieldOrders.set(t,n);this.importers.set(t,s);const o=this.exporters.get(r)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace,optionalNamespaces:e.optionalNamespaces};for(const[t,n]of e.exporters)o.fields.set(t,n);for(const[t,n]of e.exporterOrdering)o.fieldOrders.set(t,n);for(const[t,n]of e.optionalNamespaces)o.optionalNamespaces.set(t,n);this.exporters.set(r,o);for(const[t,n]of e.contexts){const e=this.contexts.get(t)||{impliedType:void 0,typeField:n.typeField,versionField:n.versionField,typeValues:new Map};e.typeField||(e.typeField=n.typeField),e.versionField||(e.versionField=n.versionField),e.impliedType||(e.impliedType=n.impliedType);for(const[t,i]of n.typeValues)e.typeValues.set(t,i);this.contexts.set(t,e)}if(e.type)this.typeValues.set(t,r),e.typeOrder&&e.type&&this.typeOrders.set(e.type,e.typeOrder);else if(this.typeField&&!e.type){for(const[,t]of this.importers){for(const[n,i]of e.importers)t.fields.set(n,i);for(const[n,i]of e.importerOrdering)t.fieldOrders.set(n,i)}for(const[,t]of this.exporters){for(const[n,i]of e.exporters)t.fields.set(n,i);for(const[n,i]of e.exporterOrdering)t.fieldOrders.set(n,i)}}}replaceWith(e){for(const[t,n]of this.children)e.children.set(t,n);for(const[t,n]of this.childrenIndex)e.childrenIndex.set(t,n);for(const[t,n]of this.contexts)e.contexts.set(t,n);for(const t of this.implicitChildren)e.implicitChildren.add(t);for(const t of this.parents)for(const n of t.children.values())n.translator===this&&(n.translator=e);this.parents=new Set}import(e,t){const n=`{${e.getNamespace()}}${e.getName()}`,i={},r=this.importers.get(n);if(!r)return;const s=this.typeValues.get(n)||"",[o,a]=s.split("__v__"),c=t.path||"";let l;if(t.pathSelector&&(l=this.contexts.get(`${c}[${t.pathSelector}]`)),l||(l=this.contexts.get(c)),l){if(!l.impliedType){const e=l.typeValues.get(n)||"";e&&(i[l.typeField]=e)}}else this.typeField&&o&&o!==this.defaultType&&(i[this.typeField]=o);this.versionField&&a&&a!==this.defaultVersion&&(i[this.versionField]=a);const u={...t,data:i,importer:r,lang:(e.getAttribute("xml:lang")||t.lang||"").toLowerCase(),pathSelector:o,translator:this},p=[...r.fieldOrders.entries()].sort((e,t)=>e[1]>t[1]?-1:e[1]<t[1]?1:0),d=p.filter(e=>e[1]>=0),h=p.filter(e=>e[1]<0);for(const[n]of d){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}for(const n of e.children){if("string"==typeof n)continue;const e=`{${n.getNamespace()}}${n.getName()}`,r=this.childrenIndex.get(e);if(!r)continue;u.path=`${t.path}.${r}`;const{translator:s,multiple:a,selector:c}=this.children.get(r);if(!c||c===o){const e=s.import(n,u);void 0!==e&&(a?(i[r]||(i[r]=[]),i[r].push(e)):i[r]?i[r]=s.resolveCollision(i[r],e):i[r]=e)}}for(const[n]of h){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}return i}export(e,t){if(!e)return;let n=this.defaultType,r=this.defaultVersion;const s=t.path||"";let o;t.pathSelector&&(o=this.contexts.get(`${s}[${t.pathSelector}]`)),o||(o=this.contexts.get(s)),o?n=o.impliedType||e[o.typeField]||this.defaultType:this.typeField&&(n=e[this.typeField]||this.defaultType),this.versionField&&(r=e[this.versionField]||this.defaultVersion);const a=r?`${n}__v__${r}`:n,c=this.exporters.get(a);if(!c)return;const l=i.createElement(c.namespace,c.element,t.namespace,t.element);t.element&&(l.parent=t.element);for(const[e,t]of c.optionalNamespaces)l.addOptionalNamespace(e,t);const u={...t,data:e,element:l,exporter:c,lang:(e[this.languageField]||t.lang||"").toLowerCase(),namespace:l.getDefaultNamespace(),pathSelector:n,translator:this},p=c.fields.get(this.languageField);p&&p(l,e[this.languageField],t);const d=Object.keys(e);d.sort((e,t)=>(c.fieldOrders.get(e)||1e5)-(c.fieldOrders.get(t)||1e5));for(const i of d){if(i===this.languageField)continue;const r=e[i],s=c.fields.get(i);if(s){s(l,r,u);continue}const o=this.children.get(i);if(!o)continue;u.path=`${t.path?t.path+".":""}${i}`;const{translator:a,multiple:p,selector:d}=o;if(!d||d===n){let e;e=p?null!=r?r:[]:[r];for(const t of e){const e=a.export(t,u);e&&l.appendChild(e)}}}return l}resolveCollision(e,t){return(this.typeOrders.get(e[this.typeField]||this.defaultType)||0)<=(this.typeOrders.get(t[this.typeField]||this.defaultType)||0)?e:t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Receiver=t.Sender=void 0;const i=n(0),r=n(3),s=i.__importStar(n(33)),o=n(9),a=n(11),c=i.__importDefault(n(34)),l=n(26),u=n(35);class p extends r.EventEmitter{constructor(e={}){super(),this.config={chunkSize:16384,hash:"sha-1",...e},this.file=void 0,this.channel=void 0,this.hash=s.createHash(this.config.hash)}send(e,t){if(this.file&&this.channel)return;this.file=e,this.channel=t,this.channel.binaryType="arraybuffer";const n=new FileReader;let i=0,r=!1;const s=()=>{if(r||i>=e.size)return;r=!0;const t=e.slice(i,i+this.config.chunkSize);n.readAsArrayBuffer(t)};t.bufferedAmountLowThreshold=8*this.config.chunkSize,t.onbufferedamountlow=()=>{s()},n.addEventListener("load",t=>{const n=t.target.result;r=!1,i+=n.byteLength,this.channel.send(n),this.hash.update(new Uint8Array(n)),this.emit("progress",i,e.size,n),i<e.size?this.channel.bufferedAmount<=this.channel.bufferedAmountLowThreshold&&s():(this.emit("progress",e.size,e.size,null),this.emit("sentFile",{algorithm:this.config.hash,name:e.name,size:e.size,value:this.hash.digest()}))}),s()}}t.Sender=p;class d extends r.EventEmitter{constructor(e={}){super(),this.config={hash:"sha-1",...e},this.receiveBuffer=[],this.received=0,this.channel=void 0,this.hash=s.createHash(this.config.hash)}receive(e,t){this.metadata=e,this.channel=t,this.channel.binaryType="arraybuffer",this.channel.onmessage=e=>{const t=e.data.byteLength;this.received+=t,this.receiveBuffer.push(e.data),e.data&&this.hash.update(new Uint8Array(e.data)),this.emit("progress",this.received,this.metadata.size,e.data),this.received===this.metadata.size?(this.metadata.actualhash=this.hash.digest("hex"),this.emit("receivedFile",new Blob(this.receiveBuffer),this.metadata),this.receiveBuffer=[]):this.received>this.metadata.size&&(console.error("received more than expected, discarding..."),this.receiveBuffer=[])}}}t.Receiver=d;class h extends c.default{constructor(e){super(e),this.sender=void 0,this.receiver=void 0,this.file=void 0}async start(e,t){if(t=t||(()=>{}),!e||"function"==typeof e)throw new Error("File object required");this.state="pending",this.role="initiator",this.file=e,this.sender=new p,this.sender.on("progress",(e,t)=>{this._log("info","Send progress "+e+"/"+t)}),this.sender.on("sentFile",e=>{this._log("info","Sent file",e.name),this.send(o.JingleAction.SessionInfo,{info:{creator:o.JingleSessionRole.Initiator,file:{hashes:[{algorithm:e.algorithm,value:e.value}]},infoType:o.JINGLE_INFO_CHECKSUM_5,name:this.contentName}}),this.parent.emit("sentFile",this,e)}),this.channel=this.pc.createDataChannel("filetransfer",{ordered:!0}),this.channel.onopen=()=>{this.sender.send(this.file,this.channel)};try{await this.processLocal(o.JingleAction.SessionInitiate,async()=>{const t=await this.pc.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1}),n=l.importFromSDP(t.sdp),i=u.convertIntermediateToRequest(n,this.role,this.transportType);this.contentName=i.contents[0].name,i.sid=this.sid,i.action=o.JingleAction.SessionInitiate,i.contents[0].application={applicationType:a.NS_JINGLE_FILE_TRANSFER_5,file:{date:e.lastModified?new Date(e.lastModified):void 0,hashesUsed:[{algorithm:"sha-1"}],name:e.name,size:e.size}},this.send("session-initiate",i),await this.pc.setLocalDescription(t)}),t()}catch(e){return this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}async accept(e){this._log("info","Accepted incoming session"),this.role="responder",this.state="active",e=e||(()=>{});try{await this.processLocal(o.JingleAction.SessionAccept,async()=>{const e=await this.pc.createAnswer(),t=l.importFromSDP(e.sdp),n=u.convertIntermediateToRequest(t,this.role,this.transportType);n.sid=this.sid,n.action="session-accept";for(const e of n.contents)e.creator="initiator";this.contentName=n.contents[0].name,this.send("session-accept",n),await this.pc.setLocalDescription(e),await this.processBufferedCandidates()}),e()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}async onSessionInitiate(e,t){this._log("info","Initiating incoming session"),this.role="responder",this.state="pending",this.transportType=e.contents[0].transport.transportType;const n=u.convertRequestToIntermediate(e,this.peerRole),i=l.exportToSDP(n),r=e.contents[0].application,s=r.file.hashesUsed?r.file.hashesUsed:r.file.hashes||[];this.receiver=new d({hash:s[0]&&s[0].algorithm}),this.receiver.on("progress",(e,t)=>{this._log("info","Receive progress "+e+"/"+t)}),this.receiver.on("receivedFile",e=>{this.receivedFile=e,this._maybeReceivedFile()}),this.receiver.metadata=r.file,this.pc.addEventListener("datachannel",e=>{this.channel=e.channel,this.receiver.receive(this.receiver.metadata,e.channel)});try{await this.pc.setRemoteDescription({type:"offer",sdp:i}),await this.processBufferedCandidates(),t()}catch(e){this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}onSessionInfo(e,t){const n=e.info;n&&n.file&&n.file.hashes&&(this.receiver.metadata.hashes=n.file.hashes,this.receiver.metadata.actualhash&&this._maybeReceivedFile(),t())}_maybeReceivedFile(){if(this.receiver.metadata.hashes&&this.receiver.metadata.hashes.length){for(const e of this.receiver.metadata.hashes||[])if(e.value&&e.value.toString("hex")===this.receiver.metadata.actualhash)return this._log("info","File hash matches"),this.parent.emit("receivedFile",this,this.receivedFile,this.receiver.metadata),void this.end("success");this._log("error","File hash does not match"),this.end("media-error")}}}t.default=h},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.reviveData=t.uuid=t.octetCompare=t.sleep=t.timeoutPromise=void 0;const i=n(33),r=[];for(let e=0;e<256;++e)r[e]=(e+256).toString(16).substr(1);t.timeoutPromise=async function(e,t,n=(()=>{})){let i;const r=await Promise.race([e,new Promise((e,r)=>{i=setTimeout(()=>r(n()),t)})]);return clearTimeout(i),r},t.sleep=async function(e){return new Promise(t=>{setTimeout(()=>t(),e)})},t.octetCompare=function(t,n){const i="string"==typeof t?e.from(t,"utf8"):t,r="string"==typeof n?e.from(n,"utf8"):n;return i.compare(r)},t.uuid=function(){const e=i.randomBytes(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=0;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[15]]].join("")};const s=new Set(["date","expires","httpUploadRetry","idleSince","published","since","stamp","timestamp","updated","utc"]),o=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)(?:Z|((\+|-)([\d|:]*)))?$/;t.reviveData=function(t,n){return s.has(t)&&n&&"string"==typeof n&&o.test(n)?new Date(n):n&&"object"==typeof n&&"Buffer"===n.type&&Array.isArray(n.data)?e.from(n):n}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(9),s=i.__importDefault(n(34)),o=n(26),a=n(35);function c(e){const t=e.application;if(t.streams&&t.streams.length&&t.sources&&t.sources.length){const e=t.streams[0];t.sources[0].parameters.msid=`${e.id} ${e.track}`,t.sourceGroups&&t.sourceGroups.length>0&&t.sources.push({parameters:{cname:t.sources[0].parameters.cname,msid:`${e.id} ${e.track}`},ssrc:t.sourceGroups[0].sources[1]})}}class l extends s.default{constructor(e){if(super(e),this.includesAudio=!1,this.includesVideo=!1,this._ringing=!1,this.pc.addEventListener("track",e=>{this.onAddTrack(e.track,e.streams[0])}),e.stream)for(const t of e.stream.getTracks())this.addTrack(t,e.stream)}get ringing(){return this._ringing}set ringing(e){e!==this._ringing&&(this._ringing=e)}get streams(){return"closed"!==this.pc.signalingState?this.pc.getRemoteStreams():[]}async start(e,t){this.state="pending",1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this.role="initiator",this.offerOptions=e;try{await this.processLocal(r.JingleAction.SessionInitiate,async()=>{const t=await this.pc.createOffer(e),n=o.importFromSDP(t.sdp),i=a.convertIntermediateToRequest(n,this.role,this.transportType);i.sid=this.sid,i.action=r.JingleAction.SessionInitiate;for(const e of i.contents||[])e.creator="initiator",c(e);await this.pc.setLocalDescription(t),this.send("session-initiate",i)}),t()}catch(e){this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}async accept(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this._log("info","Accepted incoming session"),this.state="active",this.role="responder";try{await this.processLocal(r.JingleAction.SessionAccept,async()=>{const t=await this.pc.createAnswer(e),n=o.importFromSDP(t.sdp),i=a.convertIntermediateToRequest(n,this.role,this.transportType);i.sid=this.sid,i.action=r.JingleAction.SessionAccept;for(const e of i.contents||[])e.creator="initiator";await this.pc.setLocalDescription(t),await this.processBufferedCandidates(),this.send("session-accept",i)}),t()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}end(e="success",t=!1){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.end(e,t)}ring(){return this.processLocal("ring",async()=>{this._log("info","Ringing on incoming session"),this.ringing=!0,this.send(r.JingleAction.SessionInfo,{info:{infoType:r.JINGLE_INFO_RINGING}})})}mute(e,t){return this.processLocal("mute",async()=>{this._log("info","Muting",t),this.send(r.JingleAction.SessionInfo,{info:{creator:e,infoType:r.JINGLE_INFO_MUTE,name:t}})})}unmute(e,t){return this.processLocal("unmute",async()=>{this._log("info","Unmuting",t),this.send(r.JingleAction.SessionInfo,{info:{creator:e,infoType:r.JINGLE_INFO_UNMUTE,name:t}})})}hold(){return this.processLocal("hold",async()=>{this._log("info","Placing on hold"),this.send("session-info",{info:{infoType:r.JINGLE_INFO_HOLD}})})}resume(){return this.processLocal("resume",async()=>{this._log("info","Resuming from hold"),this.send("session-info",{info:{infoType:r.JINGLE_INFO_ACTIVE}})})}addTrack(e,t,n){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",async()=>{this.pc.addTrack?this.pc.addTrack(e,t):this.pc.addStream(t),n&&n()})}async removeTrack(e,t){return this.processLocal("removetrack",async()=>{if(this.pc.removeTrack(e),t)return t()})}onAddTrack(e,t){this._log("info","Track added"),this.parent.emit("peerTrackAdded",this,e,t)}onRemoveTrack(e){this._log("info","Track removed"),this.parent.emit("peerTrackRemoved",this,e)}async onSessionInitiate(e,t){this._log("info","Initiating incoming session"),this.state="pending",this.role="responder",this.transportType=e.contents[0].transport.transportType;const n=a.convertRequestToIntermediate(e,this.peerRole);for(const e of n.media)"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),e.streams||(e.streams=[{stream:"legacy",track:e.kind}]);const i=o.exportToSDP(n);try{return await this.pc.setRemoteDescription({type:"offer",sdp:i}),await this.processBufferedCandidates(),t()}catch(e){return this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}onSessionTerminate(e,t){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.onSessionTerminate(e,t)}onSessionInfo(e,t){const n=e.info||{infoType:""};switch(n.infoType){case r.JINGLE_INFO_RINGING:return this._log("info","Outgoing session is ringing"),this.ringing=!0,this.parent.emit("ringing",this),t();case r.JINGLE_INFO_HOLD:return this._log("info","On hold"),this.parent.emit("hold",this),t();case r.JINGLE_INFO_UNHOLD:case r.JINGLE_INFO_ACTIVE:return this._log("info","Resuming from hold"),this.parent.emit("resumed",this),t();case r.JINGLE_INFO_MUTE:return this._log("info","Muting",n),this.parent.emit("mute",this,n),t();case r.JINGLE_INFO_UNMUTE:return this._log("info","Unmuting",n),this.parent.emit("unmute",this,n),t()}return t()}}t.default=l},function(e,t,n){const i=n(63);e.exports=class extends i{constructor(e){super(),this.backoffStrategy_=e,this.maxNumberOfRetry_=-1,this.backoffNumber_=0,this.backoffDelay_=0,this.timeoutID_=-1,this.handlers={backoff:this.onBackoff_.bind(this)}}failAfter(e){if(void 0!==e&&e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got "+e);this.maxNumberOfRetry_=e}backoff(e){if(-1!==this.timeoutID_)throw new Error("Backoff in progress");this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))}onBackoff_(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++}reset(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1}}},function(e,t){function n(){}e.exports=n,n.mixin=function(e){var t=e.prototype||e;t.isWildEmitter=!0,t.on=function(e,t,n){this.callbacks=this.callbacks||{};var i=3===arguments.length,r=i?arguments[1]:void 0,s=i?arguments[2]:arguments[1];return s._groupName=r,(this.callbacks[e]=this.callbacks[e]||[]).push(s),this},t.once=function(e,t,n){var i=this,r=3===arguments.length,s=r?arguments[1]:void 0,o=r?arguments[2]:arguments[1];function a(){i.off(e,a),o.apply(this,arguments)}return this.on(e,s,a),this},t.releaseGroup=function(e){var t,n,i,r;for(t in this.callbacks=this.callbacks||{},this.callbacks)for(n=0,i=(r=this.callbacks[t]).length;n<i;n++)r[n]._groupName===e&&(r.splice(n,1),n--,i--);return this},t.off=function(e,t){this.callbacks=this.callbacks||{};var n,i=this.callbacks[e];return i?1===arguments.length?(delete this.callbacks[e],this):(-1!==(n=i.indexOf(t))&&(i.splice(n,1),0===i.length&&delete this.callbacks[e]),this):this},t.emit=function(e){this.callbacks=this.callbacks||{};var t,n,i,r=[].slice.call(arguments,1),s=this.callbacks[e],o=this.getWildcardCallbacks(e);if(s)for(t=0,n=(i=s.slice()).length;t<n&&i[t];++t)i[t].apply(this,r);if(o)for(n=o.length,t=0,n=(i=o.slice()).length;t<n&&i[t];++t)i[t].apply(this,[e].concat(r));return this},t.getWildcardCallbacks=function(e){this.callbacks=this.callbacks||{};var t,n,i=[];for(t in this.callbacks)n=t.split("*"),("*"===t||2===n.length&&e.slice(0,n[0].length)===n[0])&&(i=i.concat(this.callbacks[t]));return i}},n.mixin(n)},function(e,t){function n(e){return null!=e}e.exports=class{constructor(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}getMaxDelay(){return this.maxDelay_}getInitialDelay(){return this.initialDelay_}next(){const e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)}next_(){throw new Error("Not implemented")}reset(){this.reset_()}reset_(){throw new Error("Not implemented")}}},function(e,t,n){const i=n(64);e.exports=class extends i{constructor(e){super(e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}next_(){const e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e}reset_(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0}}},function(e,t,n){"use strict";var i;n.r(t);var r=new Uint8Array(16);function s(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(r)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var a=function(e){return"string"==typeof e&&o.test(e)},c=[],l=0;l<256;++l)c.push((l+256).toString(16).substr(1));var u,p,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n},h=0,f=0;var m=function(e,t,n){var i=t&&n||0,r=t||new Array(16),o=(e=e||{}).node||u,a=void 0!==e.clockseq?e.clockseq:p;if(null==o||null==a){var c=e.random||(e.rng||s)();null==o&&(o=u=[1|c[0],c[1],c[2],c[3],c[4],c[5]]),null==a&&(a=p=16383&(c[6]<<8|c[7]))}var l=void 0!==e.msecs?e.msecs:Date.now(),m=void 0!==e.nsecs?e.nsecs:f+1,g=l-h+(m-f)/1e4;if(g<0&&void 0===e.clockseq&&(a=a+1&16383),(g<0||l>h)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=l,f=m,p=a;var v=(1e4*(268435455&(l+=122192928e5))+m)%4294967296;r[i++]=v>>>24&255,r[i++]=v>>>16&255,r[i++]=v>>>8&255,r[i++]=255&v;var b=l/4294967296*1e4&268435455;r[i++]=b>>>8&255,r[i++]=255&b,r[i++]=b>>>24&15|16,r[i++]=b>>>16&255,r[i++]=a>>>8|128,r[i++]=255&a;for(var y=0;y<6;++y)r[i+y]=o[y];return t||d(r)};var g=function(e){if(!a(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};var v=function(e,t,n){function i(e,i,r,s){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=g(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+e.length);if(o.set(i),o.set(e,i.length),(o=n(o))[6]=15&o[6]|t,o[8]=63&o[8]|128,r){s=s||0;for(var a=0;a<16;++a)r[s+a]=o[a];return r}return d(o)}try{i.name=e}catch(e){}return i.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",i.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",i};function b(e){return 14+(e+64>>>9<<4)+1}function y(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function _(e,t,n,i,r,s){return y((o=y(y(t,e),y(i,s)))<<(a=r)|o>>>32-a,n);var o,a}function S(e,t,n,i,r,s,o){return _(t&n|~t&i,e,t,r,s,o)}function w(e,t,n,i,r,s,o){return _(t&i|n&~i,e,t,r,s,o)}function x(e,t,n,i,r,s,o){return _(t^n^i,e,t,r,s,o)}function T(e,t,n,i,r,s,o){return _(n^(t|~i),e,t,r,s,o)}var k=v("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,i=0;i<n;i+=8){var r=e[i>>5]>>>i%32&255,s=parseInt("0123456789abcdef".charAt(r>>>4&15)+"0123456789abcdef".charAt(15&r),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[b(t)-1]=t;for(var n=1732584193,i=-271733879,r=-1732584194,s=271733878,o=0;o<e.length;o+=16){var a=n,c=i,l=r,u=s;n=S(n,i,r,s,e[o],7,-680876936),s=S(s,n,i,r,e[o+1],12,-389564586),r=S(r,s,n,i,e[o+2],17,606105819),i=S(i,r,s,n,e[o+3],22,-1044525330),n=S(n,i,r,s,e[o+4],7,-176418897),s=S(s,n,i,r,e[o+5],12,1200080426),r=S(r,s,n,i,e[o+6],17,-1473231341),i=S(i,r,s,n,e[o+7],22,-45705983),n=S(n,i,r,s,e[o+8],7,1770035416),s=S(s,n,i,r,e[o+9],12,-1958414417),r=S(r,s,n,i,e[o+10],17,-42063),i=S(i,r,s,n,e[o+11],22,-1990404162),n=S(n,i,r,s,e[o+12],7,1804603682),s=S(s,n,i,r,e[o+13],12,-40341101),r=S(r,s,n,i,e[o+14],17,-1502002290),i=S(i,r,s,n,e[o+15],22,1236535329),n=w(n,i,r,s,e[o+1],5,-165796510),s=w(s,n,i,r,e[o+6],9,-1069501632),r=w(r,s,n,i,e[o+11],14,643717713),i=w(i,r,s,n,e[o],20,-373897302),n=w(n,i,r,s,e[o+5],5,-701558691),s=w(s,n,i,r,e[o+10],9,38016083),r=w(r,s,n,i,e[o+15],14,-660478335),i=w(i,r,s,n,e[o+4],20,-405537848),n=w(n,i,r,s,e[o+9],5,568446438),s=w(s,n,i,r,e[o+14],9,-1019803690),r=w(r,s,n,i,e[o+3],14,-187363961),i=w(i,r,s,n,e[o+8],20,1163531501),n=w(n,i,r,s,e[o+13],5,-1444681467),s=w(s,n,i,r,e[o+2],9,-51403784),r=w(r,s,n,i,e[o+7],14,1735328473),i=w(i,r,s,n,e[o+12],20,-1926607734),n=x(n,i,r,s,e[o+5],4,-378558),s=x(s,n,i,r,e[o+8],11,-2022574463),r=x(r,s,n,i,e[o+11],16,1839030562),i=x(i,r,s,n,e[o+14],23,-35309556),n=x(n,i,r,s,e[o+1],4,-1530992060),s=x(s,n,i,r,e[o+4],11,1272893353),r=x(r,s,n,i,e[o+7],16,-155497632),i=x(i,r,s,n,e[o+10],23,-1094730640),n=x(n,i,r,s,e[o+13],4,681279174),s=x(s,n,i,r,e[o],11,-358537222),r=x(r,s,n,i,e[o+3],16,-722521979),i=x(i,r,s,n,e[o+6],23,76029189),n=x(n,i,r,s,e[o+9],4,-640364487),s=x(s,n,i,r,e[o+12],11,-421815835),r=x(r,s,n,i,e[o+15],16,530742520),i=x(i,r,s,n,e[o+2],23,-995338651),n=T(n,i,r,s,e[o],6,-198630844),s=T(s,n,i,r,e[o+7],10,1126891415),r=T(r,s,n,i,e[o+14],15,-1416354905),i=T(i,r,s,n,e[o+5],21,-57434055),n=T(n,i,r,s,e[o+12],6,1700485571),s=T(s,n,i,r,e[o+3],10,-1894986606),r=T(r,s,n,i,e[o+10],15,-1051523),i=T(i,r,s,n,e[o+1],21,-2054922799),n=T(n,i,r,s,e[o+8],6,1873313359),s=T(s,n,i,r,e[o+15],10,-30611744),r=T(r,s,n,i,e[o+6],15,-1560198380),i=T(i,r,s,n,e[o+13],21,1309151649),n=T(n,i,r,s,e[o+4],6,-145523070),s=T(s,n,i,r,e[o+11],10,-1120210379),r=T(r,s,n,i,e[o+2],15,718787259),i=T(i,r,s,n,e[o+9],21,-343485551),n=y(n,a),i=y(i,c),r=y(r,l),s=y(s,u)}return[n,i,r,s]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(b(t)),i=0;i<t;i+=8)n[i>>5]|=(255&e[i/8])<<i%32;return n}(e),8*e.length))}));var I=function(e,t,n){var i=(e=e||{}).random||(e.rng||s)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return d(i)};function j(e,t,n,i){switch(e){case 0:return t&n^~t&i;case 1:return t^n^i;case 2:return t&n^t&i^n&i;case 3:return t^n^i}}function E(e,t){return e<<t|e>>>32-t}var N=v("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=[];for(var r=0;r<i.length;++r)e.push(i.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var s=e.length/4+2,o=Math.ceil(s/16),a=new Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[64*c+4*u]<<24|e[64*c+4*u+1]<<16|e[64*c+4*u+2]<<8|e[64*c+4*u+3];a[c]=l}a[o-1][14]=8*(e.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(e.length-1)&4294967295;for(var p=0;p<o;++p){for(var d=new Uint32Array(80),h=0;h<16;++h)d[h]=a[p][h];for(var f=16;f<80;++f)d[f]=E(d[f-3]^d[f-8]^d[f-14]^d[f-16],1);for(var m=n[0],g=n[1],v=n[2],b=n[3],y=n[4],_=0;_<80;++_){var S=Math.floor(_/20),w=E(m,5)+j(S,g,v,b)+y+t[S]+d[_]>>>0;y=b,b=v,v=E(g,30)>>>0,g=m,m=w}n[0]=n[0]+m>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+v>>>0,n[3]=n[3]+b>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));var C=function(e){if(!a(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};n.d(t,"v1",(function(){return m})),n.d(t,"v3",(function(){return k})),n.d(t,"v4",(function(){return I})),n.d(t,"v5",(function(){return N})),n.d(t,"NIL",(function(){return"00000000-0000-0000-0000-000000000000"})),n.d(t,"version",(function(){return C})),n.d(t,"validate",(function(){return a})),n.d(t,"stringify",(function(){return d})),n.d(t,"parse",(function(){return g}))},function(e,t,n){var i=n(86),r=n(87),s=r;s.v1=i,s.v4=r,e.exports=s},function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(106),o=n(107);t.backOff=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return r(this,(function(i){switch(i.label){case 0:return n=s.getSanitizedOptions(t),[4,new a(e,n).execute()];case 1:return[2,i.sent()]}}))}))};var a=function(){function e(e,t){this.request=e,this.options=t,this.attemptNumber=0}return e.prototype.execute=function(){return i(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:if(this.attemptLimitReached)return[3,7];t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.applyDelay()];case 2:return t.sent(),[4,this.request()];case 3:return[2,t.sent()];case 4:return e=t.sent(),this.attemptNumber++,[4,this.options.retry(e,this.attemptNumber)];case 5:if(!t.sent()||this.attemptLimitReached)throw e;return[3,6];case 6:return[3,0];case 7:throw new Error("Something went wrong.")}}))}))},Object.defineProperty(e.prototype,"attemptLimitReached",{get:function(){return this.attemptNumber>=this.options.numOfAttempts},enumerable:!0,configurable:!0}),e.prototype.applyDelay=function(){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,o.DelayFactory(this.options,this.attemptNumber).apply()];case 1:return e.sent(),[2]}}))}))},e}()},function(e,t,n){"use strict";n.r(t);var i=n(37),r=n(25);for(var s in r)["HttpClient","parseJwt","default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(s);var o=n(17);for(var s in o)["HttpClient","parseJwt","default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(18);n.d(t,"HttpClient",(function(){return a.HttpClient}));var c=n(8);n.d(t,"parseJwt",(function(){return c.parseJwt})),t.default=i.Client},function(e,t,n){t.RateLimiter=n(71),t.TokenBucket=n(38)},function(e,t,n){(function(t){var i=n(38),r=n(72),s=function(e,t,n){this.tokenBucket=new i(e,e,t,null),this.tokenBucket.content=e,this.curIntervalStart=r(),this.tokensThisInterval=0,this.fireImmediately=n};s.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(e,n){if(e>this.tokenBucket.bucketSize)return t.nextTick(n.bind(null,"Requested tokens "+e+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var i=this,s=r();if((s<this.curIntervalStart||s-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=s,this.tokensThisInterval=0),e>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)t.nextTick(n.bind(null,null,-1));else{var o=Math.ceil(this.curIntervalStart+this.tokenBucket.interval-s);setTimeout((function(){i.tokenBucket.removeTokens(e,a)}),o)}return!1}return this.tokenBucket.removeTokens(e,a);function a(t,r){if(t)return n(t,null);i.tokensThisInterval+=e,n(null,r)}},tryRemoveTokens:function(e){if(e>this.tokenBucket.bucketSize)return!1;var t=r();if((t<this.curIntervalStart||t-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=t,this.tokensThisInterval=0),e>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var n=this.tokenBucket.tryRemoveTokens(e);return n&&(this.tokensThisInterval+=e),n},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},e.exports=s}).call(this,n(7))},function(e,t,n){(function(t){e.exports=function(){if(void 0!==t&&t.hrtime){var e=t.hrtime(),n=e[0],i=e[1];return 1e3*n+Math.floor(i/1e6)}return(new Date).getTime()}}).call(this,n(7))},function(e,t,n){"use strict";n.r(t),function(e,i){n.d(t,"Client",(function(){return Ba})),n.d(t,"Constants",(function(){return ds})),n.d(t,"DataForms",(function(){return Ds})),n.d(t,"JID",(function(){return Y})),n.d(t,"JXT",(function(){return vi})),n.d(t,"Jingle",(function(){return Ls})),n.d(t,"Namespaces",(function(){return si})),n.d(t,"RSM",(function(){return Ga})),n.d(t,"RTT",(function(){return za})),n.d(t,"SASL",(function(){return vr})),n.d(t,"Stanzas",(function(){return La})),n.d(t,"Utils",(function(){return Nr})),n.d(t,"VERSION",(function(){return Va})),n.d(t,"core",(function(){return Zs})),n.d(t,"createClient",(function(){return $a})),n.d(t,"getHostMeta",(function(){return ms}));var r=n(0),s=n(14),o=n(3),a=n(4),c=n.n(a),l=n(6),u=n(1);const p=Math.pow(2,32),d=(e,t)=>(e%t+t)%t;class h extends o.EventEmitter{constructor(){super(),this.allowResume=!0,this.lastAck=0,this.handled=0,this.unacked=[],this.inboundStarted=!1,this.outboundStarted=!1,this.id=void 0,this.jid=void 0,this.allowResume=!0,this.started=!1,this.cacheHandler=()=>{},this._reset()}get started(){return this.outboundStarted&&this.inboundStarted}set started(e){e||(this.outboundStarted=!1,this.inboundStarted=!1)}get resumable(){return this.started&&this.allowResume}load(e){var t;this.id=e.id,this.allowResume=null===(t=e.allowResume)||void 0===t||t,this.handled=e.handled,this.lastAck=e.lastAck,this.unacked=e.unacked,this.emit("prebound",e.jid)}cache(e){this.cacheHandler=e}bind(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.jid=e,yield this._cache()}))}enable(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.emit("send",{allowResumption:this.allowResume,type:"enable"})}))}resume(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.emit("send",{handled:this.handled,previousSession:this.id,type:"resume"})}))}enabled(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.id=e.id,this.handled=0,this.inboundStarted=!0,yield this._cache()}))}resumed(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.id=e.previousSession,this.inboundStarted=!0,yield this.process(e,!0),yield this._cache()}))}failed(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield this.process(e);for(const[e,t]of this.unacked)this.emit("failed",{kind:e,stanza:t});this._reset(),yield this._cache()}))}ack(){this.emit("send",{handled:this.handled,type:"ack"})}request(){this.emit("send",{type:"request"})}process(e,t=!1){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(void 0===e.handled)return;const n=d(e.handled-this.lastAck,p);for(let e=0;e<n&&this.unacked.length>0;e++){const[e,t]=this.unacked.shift();this.emit("acked",{kind:e,stanza:t})}if(this.lastAck=e.handled,t){const e=this.unacked;if(this.unacked=[],e.length){this.emit("begin-resend");for(const[t,n]of e)this.emit("resend",{kind:t,stanza:n});this.emit("end-resend")}}yield this._cache()}))}track(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return"sm"!==e||"enable"!==t.type&&"resume"!==t.type?!!this.outboundStarted&&(("message"===e||"presence"===e||"iq"===e)&&(this.unacked.push([e,t]),yield this._cache(),!0)):(this.handled=0,this.outboundStarted=!0,yield this._cache(),!1)}))}handle(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.inboundStarted&&(this.handled=d(this.handled+1,p),yield this._cache())}))}hibernate(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!this.resumable)return this.shutdown();for(const[e,t]of this.unacked)this.emit("hibernated",{kind:e,stanza:t})}))}shutdown(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this.failed({type:"failed"})}))}_cache(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){try{yield this.cacheHandler({allowResume:this.allowResume,handled:this.handled,id:this.id,jid:this.jid,lastAck:this.lastAck,unacked:this.unacked})}catch(e){console.error("Failed to cache stream state",e)}}))}_reset(){this.id="",this.inboundStarted=!1,this.outboundStarted=!1,this.lastAck=0,this.handled=0,this.unacked=[]}}const f={"A.1":{r:"hk:if|le:lf|nf:nv|qg:qv|rg:rj|rm:rp|rr:rt|rv:s3|vn:vv|17m:17n|17q:17v|18g:19g|1an:1ao|1cb:1cg|1e5:1ef|1fb:1ff|1fl:1gb|1gd:1gq|1gs:1gu|1hr:1hv|1im:1iv|1ne:1nf|1pd:1pf|1qb:1rv|1ti:280|29q:29r|2ae:2af|2al:2an|2bh:2c0|2cd:2ce|2ch:2ci|2dj:2dl|2dq:2dr|2e5:2e6|2e9:2ea|2ee:2em|2eo:2er|2f4:2f5|2fr:2g1|2g3:2g4|2gb:2ge|2gh:2gi|2hq:2hr|2i3:2i6|2i9:2ia|2ie:2io|2iv:2j5|2jl:2k0|2lq:2lr|2me:2mf|2mh:2mv|2n1:2n5|2ng:2o0|2od:2oe|2oh:2oi|2pk:2pl|2pq:2pr|2q4:2q6|2q9:2qa|2qe:2ql|2qo:2qr|2r2:2r5|2rh:2s1|2sb:2sd|2sm:2so|2t0:2t2|2t5:2t7|2tb:2td|2tq:2tt|2u3:2u5|2ue:2um|2uo:2v6|2vj:300|31q:31t|32e:32k|32n:32v|332:335|33g:341|35q:35t|36e:36k|36n:36t|372:375|37g:381|39q:39t|3a4:3a5|3ae:3am|3ao:3av|3b2:3b5|3bg:3c1|3cn:3cp|3du:3dv|3e7:3e9|3eb:3ee|3f0:3fh|3fl:3g0|3hr:3hu|3is:3k0|3k5:3k6|3kb:3kc|3ke:3kj|3l8:3l9|3lu:3lv|3me:3mf|3mq:3mr|3mu:3nv|3rb:3rg|3sc:3sf|3ud:3ue|3ug:3vv|41j:41l|41q:41v|42q:44v|466:46f|47p:47q|47s:47v|4aq:4au|4d3:4d7|4fq:4fv|4ie:4if|4iu:4iv|4ke:4kf|4lm:4ln|4m6:4m7|4om:4on|4qr:4r0|4rt:4sv|4vl:500|5jn:5jv|5kt:5kv|5nh:5nv|5ol:5ov|5pn:5pv|5qk:5qv|5rk:5rv|5ut:5uv|5va:5vv|60q:60v|63o:63v|65a:7fv|7ks:7kv|7nq:7nv|7om:7on|7ou:7ov|7q6:7q7|7qe:7qf|7ru:7rv|7uk:7ul|7vg:7vh|82j:82m|82o:82u|834:839|83i:83j|84f:84v|85i:86f|87b:87v|89r:89s|8ac:8ai|8c4:8cf|8uf:8vv|917:91v|92b:92v|9gk:9gl|9ju:9jv|9ka:9o0|9oa:9ob|9qj:9ql|9qv:9r0|9sl:9sn|9tv:9uf|9vc:9vf|ao0:bjv|bnk:bnv|bum:bvf|bvs:bvv|c4n:c4o|c80:c84|c9d:c9g|cdo:cff|cgt:cgv|ci4:cig|cjs:cju|cmc:cmf|crn:crq|cuu:cuv|jdm:jfv|17t6:17vv|194d:194f|1967:1avv|1lt4:1lvv|1uhe:1uhf|1ujb:1unv|1uo7:1uoi|1uoo:1uos|1uti:1uui|1va0:1vaf|1vcg:1vch|1ve8:1vef|1vft:1vfv|1vgg:1vgv|1vh4:1vhf|1vi7:1vi8|1vjc:1vjf|1vnt:1vnu|1vtv:1vu1|1vu8:1vu9|1vug:1vuh|1vuo:1vup|1vut:1vuv|1vvf:1vvo|2000:20nv|20p4:20pf|20qb:20vv|2116:2117|212e:3jvv|3k7m:3k7v|3k97:3k99|3keu:3kvv|3l50:3l51|3l53:3l54|3l57:3l58|3l8b:3l8c|3la7:3la9|3ll4:3ll7|3lua:3lud|3m00:3vvt|59mn:5tvv|5ugu:5vvt|6000:7vvt|8000:9vvt|a000:bvvt|c000:dvvt|e000:fvvt|g000:hvvt|i000:jvvt|k000:lvvt|m000:nvvt|o000:pvvt|q000:rvvt|s002:s00v|s040:tvvt",s:"9p8|9qc|9qe|9qn|9tg|147|bkq|3l2l|3l4t|3l5d|3l5q|3l5s|3l61|3l64|3l86|3l8l|3l8t|3l9q|3l9v|3la5|3lah|16f|c20|ccf|cnv|cvv|1b0|1c8|1d2|1dq|1h0|1nv|1oe|284|2c4|2d9|2dh|2dt|2eu|2h9|2hh|2hk|2hn|2ht|2it|2k4|2kc|2ke|2ki|2l9|2lh|2lk|2m6|2ma|2o4|2p9|2ph|2qu|2s4|2sh|2sr|2st|2tm|2u9|304|30d|30h|319|31k|325|329|344|34d|34h|359|35k|365|369|36v|384|38d|38h|399|3a9|3c4|3di|3ds|3el|3en|3k3|3k9|3ko|3l0|3l4|3l6|3lc|3lq|3m5|3m7|3q8|3so|3tt|412|418|41b|4g7|4i7|4i9|4in|4ip|4k7|4k9|4lf|4lh|4lv|4m1|4mf|4mn|4nf|4of|4oh|4ov|4q7|h1|5od|5rd|5rh|60f|1upn|1upt|1upv|1uq2|1uq5|1vij|1vj7|1vjl|1vo0|1vv7|20ov|7qo|7qq|7qs|7qu|7tl|7u5|7us|7vl|7vv|sb|sd|s000|t2|97v|uf|9go|9o5"},"B.1":{r:"60b:60d|80b:80d|1vg0:1vgf",s:"5d|606|1vnv|830|qf"},"B.2":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|rq:10;tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ui:u5|uj:ud|uk:ub|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|858:3i;3j|882:33|883:5g;33|887:ir|889:5g;36|88b:38|88c:38|88d:38|88g:39|88h:39|88i:3c|88l:3e|88m:3e;3f|88p:3g|88q:3h|88r:3i|88s:3i|88t:3i|890:3j;3d|891:3k;35;3c|892:3k;3d|894:3q|898:3q|89c:32|89d:33|89g:35|89h:36|89j:3d|89u:tj|89v:u0|8a5:34|crh:38;3g;31|crj:31;3l|crl:3f;3m|cs0:3g;31|cs1:3e;31|cs2:ts;31|cs3:3d;31|cs4:3b;31|cs5:3b;32|cs6:3d;32|cs7:37;32|csa:3g;36|csb:3e;36|csc:ts;36|csg:38;3q|csh:3b;38;3q|csi:3d;38;3q|csj:37;38;3q|csk:3k;38;3q|ct9:3g;31|cta:3b;3g;31|ctb:3d;3g;31|ctc:37;3g;31|ctk:3g;3m|ctl:3e;3m|ctm:ts;3m|ctn:3d;3m|cto:3b;3m|ctp:3d;3m|ctq:3g;3n|ctr:3e;3n|cts:ts;3n|ctt:3d;3n|ctu:3b;3n|ctv:3d;3n|cu0:3b;u9|cu1:3d;u9|cu3:32;3h|cu6:33;8gl;3b;37|cu7:33;3f;1e|cu8:34;32|cu9:37;3p|cub:38;3g|cud:3b;3b|cue:3b;3d|cun:3g;38|cup:3g;3g;3d|cuq:3g;3i|cus:3j;3m|cut:3n;32|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd|3l00:31|3l01:32|3l02:33|3l03:34|3l04:35|3l05:36|3l06:37|3l07:38|3l08:39|3l09:3a|3l0a:3b|3l0b:3c|3l0c:3d|3l0d:3e|3l0e:3f|3l0f:3g|3l0g:3h|3l0h:3i|3l0i:3j|3l0j:3k|3l0k:3l|3l0l:3m|3l0m:3n|3l0n:3o|3l0o:3p|3l0p:3q|3l1k:31|3l1l:32|3l1m:33|3l1n:34|3l1o:35|3l1p:36|3l1q:37|3l1r:38|3l1s:39|3l1t:3a|3l1u:3b|3l1v:3c|3l20:3d|3l21:3e|3l22:3f|3l23:3g|3l24:3h|3l25:3i|3l26:3j|3l27:3k|3l28:3l|3l29:3m|3l2a:3n|3l2b:3o|3l2c:3p|3l2d:3q|3l38:31|3l39:32|3l3a:33|3l3b:34|3l3c:35|3l3d:36|3l3e:37|3l3f:38|3l3g:39|3l3h:3a|3l3i:3b|3l3j:3c|3l3k:3d|3l3l:3e|3l3m:3f|3l3n:3g|3l3o:3h|3l3p:3i|3l3q:3j|3l3r:3k|3l3s:3l|3l3t:3m|3l3u:3n|3l3v:3o|3l40:3p|3l41:3q|3l4s:31|3l4u:33|3l4v:34|3l52:37|3l55:3a|3l56:3b|3l59:3e|3l5a:3f|3l5b:3g|3l5c:3h|3l5e:3j|3l5f:3k|3l5g:3l|3l5h:3m|3l5i:3n|3l5j:3o|3l5k:3p|3l5l:3q|3l6g:31|3l6h:32|3l6i:33|3l6j:34|3l6k:35|3l6l:36|3l6m:37|3l6n:38|3l6o:39|3l6p:3a|3l6q:3b|3l6r:3c|3l6s:3d|3l6t:3e|3l6u:3f|3l6v:3g|3l70:3h|3l71:3i|3l72:3j|3l73:3k|3l74:3l|3l75:3m|3l76:3n|3l77:3o|3l78:3p|3l79:3q|3l84:31|3l85:32|3l87:34|3l88:35|3l89:36|3l8a:37|3l8d:3a|3l8e:3b|3l8f:3c|3l8g:3d|3l8h:3e|3l8i:3f|3l8j:3g|3l8k:3h|3l8m:3j|3l8n:3k|3l8o:3l|3l8p:3m|3l8q:3n|3l8r:3o|3l8s:3p|3l9o:31|3l9p:32|3l9r:34|3l9s:35|3l9t:36|3l9u:37|3la0:39|3la1:3a|3la2:3b|3la3:3c|3la4:3d|3la6:3f|3laa:3j|3lab:3k|3lac:3l|3lad:3m|3lae:3n|3laf:3o|3lag:3p|3lbc:31|3lbd:32|3lbe:33|3lbf:34|3lbg:35|3lbh:36|3lbi:37|3lbj:38|3lbk:39|3lbl:3a|3lbm:3b|3lbn:3c|3lbo:3d|3lbp:3e|3lbq:3f|3lbr:3g|3lbs:3h|3lbt:3i|3lbu:3j|3lbv:3k|3lc0:3l|3lc1:3m|3lc2:3n|3lc3:3o|3lc4:3p|3lc5:3q|3ld0:31|3ld1:32|3ld2:33|3ld3:34|3ld4:35|3ld5:36|3ld6:37|3ld7:38|3ld8:39|3ld9:3a|3lda:3b|3ldb:3c|3ldc:3d|3ldd:3e|3lde:3f|3ldf:3g|3ldg:3h|3ldh:3i|3ldi:3j|3ldj:3k|3ldk:3l|3ldl:3m|3ldm:3n|3ldn:3o|3ldo:3p|3ldp:3q|3lek:31|3lel:32|3lem:33|3len:34|3leo:35|3lep:36|3leq:37|3ler:38|3les:39|3let:3a|3leu:3b|3lev:3c|3lf0:3d|3lf1:3e|3lf2:3f|3lf3:3g|3lf4:3h|3lf5:3i|3lf6:3j|3lf7:3k|3lf8:3l|3lf9:3m|3lfa:3n|3lfb:3o|3lfc:3p|3lfd:3q|3lg8:31|3lg9:32|3lga:33|3lgb:34|3lgc:35|3lgd:36|3lge:37|3lgf:38|3lgg:39|3lgh:3a|3lgi:3b|3lgj:3c|3lgk:3d|3lgl:3e|3lgm:3f|3lgn:3g|3lgo:3h|3lgp:3i|3lgq:3j|3lgr:3k|3lgs:3l|3lgt:3m|3lgu:3n|3lgv:3o|3lh0:3p|3lh1:3q|3lhs:31|3lht:32|3lhu:33|3lhv:34|3li0:35|3li1:36|3li2:37|3li3:38|3li4:39|3li5:3a|3li6:3b|3li7:3c|3li8:3d|3li9:3e|3lia:3f|3lib:3g|3lic:3h|3lid:3i|3lie:3j|3lif:3k|3lig:3l|3lih:3m|3lii:3n|3lij:3o|3lik:3p|3lil:3q|3ljg:31|3ljh:32|3lji:33|3ljj:34|3ljk:35|3ljl:36|3ljm:37|3ljn:38|3ljo:39|3ljp:3a|3ljq:3b|3ljr:3c|3ljs:3d|3ljt:3e|3lju:3f|3ljv:3g|3lk0:3h|3lk1:3i|3lk2:3j|3lk3:3k|3lk4:3l|3lk5:3m|3lk6:3n|3lk7:3o|3lk8:3p|3lk9:3q|3ll8:th|3ll9:ti|3lla:tj|3llb:tk|3llc:tl|3lld:tm|3lle:tn|3llf:to|3llg:tp|3llh:tq|3lli:tr|3llj:ts|3llk:tt|3lll:tu|3llm:tv|3lln:u0|3llo:u1|3llp:to|3llq:u3|3llr:u4|3lls:u5|3llt:u6|3llu:u7|3llv:u8|3lm0:u9|3lmj:u3|3ln2:th|3ln3:ti|3ln4:tj|3ln5:tk|3ln6:tl|3ln7:tm|3ln8:tn|3ln9:to|3lna:tp|3lnb:tq|3lnc:tr|3lnd:ts|3lne:tt|3lnf:tu|3lng:tv|3lnh:u0|3lni:u1|3lnj:to|3lnk:u3|3lnl:u4|3lnm:u5|3lnn:u6|3lno:u7|3lnp:u8|3lnq:u9|3lod:u3|3los:th|3lot:ti|3lou:tj|3lov:tk|3lp0:tl|3lp1:tm|3lp2:tn|3lp3:to|3lp4:tp|3lp5:tq|3lp6:tr|3lp7:ts|3lp8:tt|3lp9:tu|3lpa:tv|3lpb:u0|3lpc:u1|3lpd:to|3lpe:u3|3lpf:u4|3lpg:u5|3lph:u6|3lpi:u7|3lpj:u8|3lpk:u9|3lq7:u3|3lqm:th|3lqn:ti|3lqo:tj|3lqp:tk|3lqq:tl|3lqr:tm|3lqs:tn|3lqt:to|3lqu:tp|3lqv:tq|3lr0:tr|3lr1:ts|3lr2:tt|3lr3:tu|3lr4:tv|3lr5:u0|3lr6:u1|3lr7:to|3lr8:u3|3lr9:u4|3lra:u5|3lrb:u6|3lrc:u7|3lrd:u8|3lre:u9|3ls1:u3|3lsg:th|3lsh:ti|3lsi:tj|3lsj:tk|3lsk:tl|3lsl:tm|3lsm:tn|3lsn:to|3lso:tp|3lsp:tq|3lsq:tr|3lsr:ts|3lss:tt|3lst:tu|3lsu:tv|3lsv:u0|3lt0:u1|3lt1:to|3lt2:u3|3lt3:u4|3lt4:u5|3lt5:u6|3lt6:u7|3lt7:u8|3lt8:u9|3ltr:u3",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"B.3":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"C.1.1":{s:"10"},"C.1.2":{r:"800:80b",s:"c00|50|5k0|81f|82v"},"C.2.1":{r:"0:v",s:"3v"},"C.2.2":{r:"40:4v|80c:80d|818:819|830:833|83a:83f|1vvp:1vvs|3kbj:3kbq",s:"1mt|1of|60e|1vnv"},"C.3":{r:"1o00:1u7v|u000:vvvt|10000:11vvt"},"C.4":{r:"1veg:1vff|1vvu:1vvv|3vvu:3vvv|5vvu:5vvv|7vvu:7vvv|9vvu:9vvv|bvvu:bvvv|dvvu:dvvv|fvvu:fvvv|hvvu:hvvv|jvvu:jvvv|lvvu:lvvv|nvvu:nvvv|pvvu:pvvv|rvvu:rvvv|tvvu:tvvv|vvvu:vvvv|11vvu:11vvv"},"C.5":{r:"1m00:1nvv"},"C.6":{r:"1vvp:1vvt"},"C.7":{r:"bvg:bvr"},"C.8":{r:"q0:q1|80e:80f|81a:81e|83a:83f"},"C.9":{r:"s010:s03v",s:"s001"},"D.1":{r:"1eg:1fa|1fg:1fk|1h1:1hq|1i0:1ia|1jd:1jf|1jh:1ml|1n5:1n6|1nq:1nu|1o0:1od|1oi:1pc|1s0:1t5|1uov:1up8|1upa:1upm|1upo:1ups|1uq0:1uq1|1uq3:1uq4|1uq6:1uth|1uuj:1v9t|1vag:1vcf|1vci:1ve7|1vfg:1vfs|1vjg:1vjk|1vjm:1vns",s:"1du|1e0|1e3|1gr|1gv|1mt|1og|1th|1uot|1upu|80f"},"D.2":{r:"21:2q|31:3q|60:6m|6o:7m|7o:h0|h2:hj|ig:ld|lg:lo|lr:m1|mg:mh|n0:n4|s8:sa|se:t1|t3:ue|ug:vl|100:142|14a:16e|16g:17l|17o:17p|180:18f|19h:1am|1ap:1av|1b1:1c7|285:29p|29t:2a0|2a9:2ac|2ao:2b1|2b4:2bg|2c2:2c3|2c5:2cc|2cf:2cg|2cj:2d8|2da:2dg|2dm:2dp|2du:2e0|2e7:2e8|2eb:2ec|2es:2et|2ev:2f1|2f6:2fh|2fk:2fq|2g5:2ga|2gf:2gg|2gj:2h8|2ha:2hg|2hi:2hj|2hl:2hm|2ho:2hp|2hu:2i0|2ip:2is|2j6:2jf|2ji:2jk|2k5:2kb|2kf:2kh|2kj:2l8|2la:2lg|2li:2lj|2ll:2lp|2lt:2m0|2mb:2mc|2n6:2nf|2o2:2o3|2o5:2oc|2of:2og|2oj:2p8|2pa:2pg|2pi:2pj|2pm:2pp|2pt:2pu|2q7:2q8|2qb:2qc|2qs:2qt|2qv:2r1|2r6:2rg|2s5:2sa|2se:2sg|2si:2sl|2sp:2sq|2su:2sv|2t3:2t4|2t8:2ta|2te:2tl|2tn:2tp|2tu:2tv|2u1:2u2|2u6:2u8|2ua:2uc|2v7:2vi|301:303|305:30c|30e:30g|30i:318|31a:31j|31l:31p|321:324|330:331|336:33f|342:343|345:34c|34e:34g|34i:358|35a:35j|35l:35p|360:364|367:368|36a:36b|36l:36m|370:371|376:37f|382:383|385:38c|38e:38g|38i:398|39a:39p|39u:3a0|3a6:3a8|3aa:3ac|3b0:3b1|3b6:3bf|3c2:3c3|3c5:3cm|3cq:3dh|3dj:3dr|3e0:3e6|3ef:3eh|3eo:3ev|3fi:3fk|3g1:3hg|3hi:3hj|3i0:3i6|3if:3ir|3k1:3k2|3k7:3k8|3kk:3kn|3kp:3kv|3l1:3l3|3la:3lb|3ld:3lg|3li:3lj|3m0:3m4|3mg:3mp|3ms:3mt|3o0:3on|3oq:3pk|3pu:3q7|3q9:3ra|3s8:3sb|3tu:3u5|3u7:3uc|400:411|413:417|419:41a|420:42n|450:465|46g:47o|480:4ap|4av:4d2|4d8:4fp|4g0:4g6|4g8:4i6|4ia:4id|4ig:4im|4iq:4it|4j0:4k6|4ka:4kd|4kg:4le|4li:4ll|4lo:4lu|4m2:4m5|4m8:4me|4mg:4mm|4mo:4ne|4ng:4oe|4oi:4ol|4oo:4ou|4p0:4q6|4q8:4qq|4r1:4rs|4t0:4vk|501:5jm|5k1:5kq|5l0:5ng|5o0:5oc|5oe:5oh|5p0:5ph|5pl:5pm|5q0:5qh|5r0:5rc|5re:5rg|5s0:5tm|5tu:5u5|5u7:5u8|5uk:5uq|5v0:5v9|60g:60p|610:63n|640:658|7g0:7kr|7l0:7np|7o0:7ol|7oo:7ot|7p0:7q5|7q8:7qd|7qg:7qn|7qv:7rt|7s0:7tk|7tm:7ts|7u2:7u4|7u6:7uc|7ug:7uj|7um:7ur|7v0:7vc|7vi:7vk|7vm:7vs|88a:88j|88p:88t|89a:89d|89f:89h|89j:89p|89t:89v|8a5:8a9|8b0:8c3|8pm:8rq|94s:979|c05:c07|c11:c19|c1h:c1l|c1o:c1s|c21:c4m|c4t:c4v|c51:c7q|c7s:c7v|c85:c9c|c9h:cce|ccg:cdn|cfg:cgs|ch0:ci3|cj0:cjr|cjv:clg|cm0:cmb|cmg:cnu|co0:crm|crr:cut|cv0:cvu|d00:jdl|jg0:17t5|1800:194c|1b00:1lt3|1m00:1uhd|1uhg:1uja|1uo0:1uo6|1uoj:1uon|1vp1:1vpq|1vq1:1vqq|1vr6:1vtu|1vu2:1vu7|1vua:1vuf|1vui:1vun|1vuq:1vus|20o0:20ou|20p0:20p3|20pg:20qa|2100:2115|2118:212d|3k00:3k7l|3k80:3k96|3k9a:3kb6|3kba:3kbi|3kc3:3kc4|3kcc:3kd9|3kde:3ket|3l00:3l2k|3l2m:3l4s|3l4u:3l4v|3l55:3l56|3l59:3l5c|3l5e:3l5p|3l5t:3l60|3l62:3l63|3l65:3l85|3l87:3l8a|3l8d:3l8k|3l8m:3l8s|3l8u:3l9p|3l9r:3l9u|3la0:3la4|3laa:3lag|3lai:3ll3|3ll8:3lu9|4000:59mm|5u00:5ugt|u000:vvvt|10000:11vvt",s:"3l52|3l5r|3la6|1c9|5a|5l|5q|283|2ag|2di|2en|2iu|2k3|2kd|2m9|2mg|2n0|2q0|2qn|2s3|2ss|2un|35u|36u|3an|3dt|3k4|3ka|3kd|3l5|3l7|3lt|3m6|3pm|3po|3rv|3s5|3uf|41c|41h|41o|47r|4i8|4io|4k8|4lg|4m0|4og|5us|ne|7qp|7qr|7qt|7tu|80e|83h|83v|882|887|88l|894|896|898|rq|s6|sc|8sl"}};class m{constructor(e,t){this.singles=new Set,this.ranges=[],this.mappings=new Map;const n=f[e];this.name=e,n?(n.s&&(this.singles=new Set(n.s.split("|").map(e=>parseInt(e,32)))),n.r&&(this.ranges=n.r.split("|").map(e=>{const[t,n]=e.split(":");return[parseInt(t,32),parseInt(n,32)]})),n.m&&(this.mappings=new Map(n.m.split("|").map(e=>{const[t,n]=e.split(":"),i=n.split(";").map(e=>parseInt(e,32));return[parseInt(t,32),i]})))):t&&(this.singles=new Set(t))}contains(e){if(this.singles.has(e))return!0;let t=0,n=this.ranges.length-1;for(;t<=n;){const i=Math.floor((t+n)/2),r=this.ranges[i];if(e<r[0])n=i-1;else{if(!(e>r[1]))return!0;t=i+1}}return!1}hasMapping(e){return this.mappings.has(e)||this.contains(e)}map(e){return this.contains(e)&&!this.mappings.has(e)?String.fromCodePoint(e).toLowerCase().codePointAt(0):this.mappings.get(e)||null}}const g=new m("A.1"),v=new m("B.1"),b=new m("B.2");new m("B.3");const y=new m("C.1.1"),_=new m("C.1.2"),S=new m("C.2.1"),w=new m("C.2.2"),x=new m("C.3"),T=new m("C.4"),k=new m("C.5"),I=new m("C.6"),j=new m("C.7"),E=new m("C.8"),N=new m("C.9"),C=new m("D.1"),R=new m("D.2");function O(e,t,n=""){const i=c.a.ucs2.decode(n);let r=[];for(const n of i){if(!t&&e.unassigned.contains(n))throw new Error("Unassigned code point: x"+n.toString(16));let i=!1;for(const t of e.mappings){if(!t.hasMapping(n))continue;i=!0;const e=t.map(n);e&&(Array.isArray(e)?r=r.concat(e):r.push(e))}i||r.push(n)}let s=r;if(e.normalize){const e=c.a.ucs2.encode(r).normalize("NFKC");s=c.a.ucs2.decode(e)}let o=!1,a=!1;for(const n of s){for(const t of e.prohibited)if(t.contains(n))throw new Error("Prohibited code point: x"+n.toString(16));if(!t&&e.unassigned.contains(n))throw new Error("Prohibited code point: x"+n.toString(16));e.bidirectional&&(o=o||C.contains(n),a=a||R.contains(n))}if(e.bidirectional){if(o&&a)throw new Error("String contained both LCat and RandALCat code points");if(o&&(!C.contains(s[0])||!C.contains(s[s.length-1])))throw new Error("String containing RandALCat code points must start and end with RandALCat code points")}return c.a.ucs2.encode(s)}v.map=()=>null,y.contains=e=>32===e,_.map=e=>_.contains(e)?32:null;const A={bidirectional:!0,mappings:[v,b],normalize:!0,prohibited:[_,w,x,T,k,I,j,E,N],unassigned:g};const P=new m("NodePrepProhibited",[34,38,39,47,58,60,62,64]),q={bidirectional:!0,mappings:[v,b],normalize:!0,prohibited:[y,_,S,w,x,T,k,I,j,E,N,P],unassigned:g};const L={bidirectional:!0,mappings:[v],normalize:!0,prohibited:[_,S,w,x,T,k,I,j,E,N],unassigned:g};const F={bidirectional:!0,mappings:[_,v],normalize:!0,prohibited:[_,S,w,x,T,k,I,j,E,N],unassigned:g};function M(e,t=!1){return O(F,t,e)}function D(e=""){return e.replace(/^\s+|\s+$/g,"").replace(/\\5c/g,"\\5c5c").replace(/\\20/g,"\\5c20").replace(/\\22/g,"\\5c22").replace(/\\26/g,"\\5c26").replace(/\\27/g,"\\5c27").replace(/\\2f/g,"\\5c2f").replace(/\\3a/g,"\\5c3a").replace(/\\3c/g,"\\5c3c").replace(/\\3e/g,"\\5c3e").replace(/\\40/g,"\\5c40").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")}function B(e){return 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,"\\")}function U(e){let t=e.local||"",n=e.domain,i=e.resource||"";return t&&(t=function(e,t=!0){return O(q,t,e)}(t)),i&&(i=function(e,t=!0){return O(L,t,e)}(i)),"."===n[n.length-1]&&(n=n.slice(0,n.length-1)),n=function(e,t=!0){return O(A,t,e)}(n.split(".").map(c.a.toUnicode).join(".")),{domain:n,local:t,resource:i}}function z(e,t={}){let n=e.local;t.escaped||(n=D(e.local));const i=t.prepared?e:U({local:n,domain:e.domain,resource:e.resource}),r=n?`${n}@${i.domain}`:i.domain;return i.resource?`${r}/${i.resource}`:r}function J(e,t){return t?`${K(e)}/${t}`:K(e)}function G(e=""){let t="",n="",i="";const r=e.indexOf("/");r>0&&(i=e.slice(r+1),e=e.slice(0,r));const s=e.indexOf("@");s>0&&(t=e.slice(0,s),e=e.slice(s+1)),n=e;const o=U({domain:n,local:t,resource:i});return{bare:z({local:o.local,domain:o.domain},{escaped:!0,prepared:!0}),domain:o.domain,full:z(o,{escaped:!0,prepared:!0}),local:B(o.local),resource:o.resource}}function V(e,t){const n=new Set;if(n.add(void 0),n.add(""),e){const t=G(e);n.add(t.full),n.add(t.bare),n.add(t.domain)}if(t){const e=G(t);n.add(e.domain),n.add(e.bare),n.add(e.full)}return n}function $(e,t){if(!e||!t)return!1;const n=G(e),i=G(t);return n.local===i.local&&n.domain===i.domain}function H(e){return!!G(e).resource}function W(e=""){return G(e).domain}function Q(e=""){return G(e).resource}function K(e=""){return G(e).bare}var X,Y=Object.freeze({__proto__:null,escapeLocal:D,unescapeLocal:B,prepare:U,create:z,createFull:J,parse:G,allowedResponders:V,equal:function(e,t){if(!e||!t)return!1;const n=G(e),i=G(t);return n.local===i.local&&n.domain===i.domain&&n.resource===i.resource},equalBare:$,isFull:H,isBare:function(e){return!H(e)},getLocal:function(e=""){return G(e).local},getDomain:W,getResource:Q,toBare:K,parseURI:function(e){const t=new URL(e);if("xmpp:"!==t.protocol)throw new Error("Invalid XMPP URI, wrong protocol: "+t.protocol);const n=t.hostname?t.username?z({domain:decodeURIComponent(t.hostname),local:decodeURIComponent(t.username)},{escaped:!0}):decodeURIComponent(t.hostname):void 0,i=G(decodeURIComponent(n?t.pathname.substr(1):t.pathname)).full,r=t.search&&t.search.indexOf(";")>=1,s=r?t.search.substr(t.search.indexOf(";")+1):"",o=t.search?decodeURIComponent(t.search.substr(1,r?t.search.indexOf(";")-1:void 0)):void 0,a={};for(const e of s.split(";")){const[t,n]=e.split("=").map(decodeURIComponent);if(a[t]){const e=a[t];Array.isArray(e)?e.push(n):a[t]=[e,n]}else a[t]=n}return{action:o,identity:n,jid:i,parameters:a}},toURI:function(e){const t=["xmpp:"],n=(e,n)=>{const i=G(e);i.local&&(t.push(encodeURIComponent(D(i.local))),t.push("@")),t.push(encodeURIComponent(i.domain)),n&&i.resource&&(t.push("/"),t.push(encodeURIComponent(i.resource)))};e.identity&&(t.push("//"),n(e.identity,!1),e.jid&&t.push("/")),e.jid&&n(e.jid,!0),e.action&&(t.push("?"),t.push(encodeURIComponent(e.action)));for(const[n,i]of Object.entries(e.parameters||{}))for(const e of Array.isArray(i)?i:[i])t.push(";"),t.push(encodeURIComponent(n)),void 0!==e&&(t.push("="),t.push(encodeURIComponent(e)));return t.join("")}});!function(e){e.NotWellFormed="not-well-formed",e.RestrictedXML="restricted-xml",e.AlreadyClosed="already-closed",e.UnknownRoot="unknown-stream-root"}(X||(X={}));class Z extends Error{constructor(e){super(e.text),this.isJXTError=!0,this.condition=e.condition,this.text=e.text}static notWellFormed(e){return new Z({condition:X.NotWellFormed,text:e})}static restrictedXML(e){return new Z({condition:X.RestrictedXML,text:e})}static alreadyClosed(e){return new Z({condition:X.AlreadyClosed,text:e})}static unknownRoot(e){return new Z({condition:X.UnknownRoot,text:e})}}const ee={'"':""","&":"&","'":"'","<":"<",">":">"},te={"&":"&","'":"'",">":">","<":"<",""":'"'},ne=/&([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);/g,ie=/&|<|>|"|'/g,re=/&|<|>/g;function se(e){return ee[e]}function oe(e){return e.replace(ie,se)}function ae(e){return e.replace(ne,e=>function(e){if(te[e])return te[e];const t=e.startsWith("&#x"),n=parseInt(e.substring(t?3:2,e.length-1),t?16:10);if(9===n||10===n||13===n||32<=n&&n<=55295||57344<=n&&n<=65533||65536<=n&&n<=1114111)return String.fromCodePoint(n);throw Z.restrictedXML("Prohibited entity: "+e)}(e))}function ce(e){return e.replace(re,se)}function le(e,t=[],n=""){const i=new Set(e.map(e=>e.toLowerCase()));for(let e of t.map(e=>e.toLowerCase()))if("*"!==e)for(;e.length>0;){if(i.has(e))return e;e=e.substring(0,e.lastIndexOf("-")).toLowerCase(),e.lastIndexOf("-")===e.length-2&&(e=e.substring(0,e.lastIndexOf("-")))}return n}class ue{constructor(e,t={},n=[]){this.name=e,this.attributes=t,this.children=[],this.optionalNamespaces={};for(const e of n)if("string"!=typeof e){const t=new ue(e.name,e.attributes,e.children);t.parent=this,this.children.push(t)}else this.children.push(e)}getName(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name}getNamespace(){if(this.name.indexOf(":")>=0){const e=this.name.substr(0,this.name.indexOf(":"));return this.findNamespaceForPrefix(e)}return this.findNamespaceForPrefix()}getNamespaceContext(){let e={};this.parent&&(e=this.parent.getNamespaceContext());for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")){const i=t.substr(6);e[n]=i}return e}getDefaultNamespace(){return this.attributes.xmlns?this.attributes.xmlns:this.parent?this.parent.getDefaultNamespace():""}getNamespaceRoot(e){if(this.parent){const t=this.parent.getNamespaceRoot(e);if(t)return t}for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")&&n===e)return this;if(this.optionalNamespaces[e])return this}getAttribute(e,t){if(!t)return this.attributes[e];const n=this.getNamespaceContext();return n[t]?this.attributes[[n[t],e].join(":")]:void 0}getChild(e,t){return this.getChildren(e,t)[0]}getChildren(e,t){const n=[];for(const i of this.children)"string"==typeof i||i.getName()!==e||t&&i.getNamespace()!==t||n.push(i);return n}getText(){let e="";for(const t of this.children)"string"==typeof t&&(e+=t);return e}appendChild(e){return this.children.push(e),"string"!=typeof e&&(e.parent=this),e}setAttribute(e,t,n=!1){this.attributes[e]=t||void 0,""===t&&n&&(this.attributes[e]=t)}addOptionalNamespace(e,t){this.optionalNamespaces[t]=e}useNamespace(e,t){return this.optionalNamespaces[t]&&(e=this.optionalNamespaces[t]),this.setAttribute("xmlns:"+e,t),e}toJSON(){const e=this.children.map(e=>"string"==typeof e?e:e?e.toJSON():void 0).filter(e=>!!e),t={};for(const[e,n]of Object.entries(this.attributes))null!=n&&(t[e]=n);return{attributes:t,children:e,name:this.name}}toString(){let e=this.openTag(!0);if(this.children.length){for(const t of this.children)"string"==typeof t?e+=ce(t):t&&(e+=t.toString());e+=this.closeTag()}return e}openTag(e=!1){let t="";t+="<"+this.name;for(const[e,n]of Object.entries(this.attributes))void 0!==n&&(t+=` ${e}="${oe(n.toString())}"`);return e&&0===this.children.length?t+="/>":t+=">",t}closeTag(){return`</${this.name}>`}findNamespaceForPrefix(e){if(e){const t="xmlns:"+e;if(this.attributes[t])return this.attributes[t];if(this.parent)return this.parent.findNamespaceForPrefix(e)}else{if(this.attributes.xmlns)return this.attributes.xmlns;if(this.parent)return this.parent.findNamespaceForPrefix()}return""}}const pe=new Set(["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul"]),de=new Set(["style"]),he=new Map([["a",new Set(["href","style"])],["body",new Set(["style","xml:lang"])],["blockquote",de],["br",de],["cite",de],["em",de],["img",new Set(["alt","height","src","style","width"])],["li",de],["ol",de],["p",de],["span",de],["strong",de],["ul",de]]),fe=new Map([["font-style",/normal|italic|oblique|inherit/i],["font-weight",/normal|bold|bolder|lighter|inherit|\d\d\d/i],["text-decoration",/none|underline|overline|line-through|blink|inherit/i]]),me=e=>!!e.match(/^(https?|xmpp|cid|mailto|ftps?|im|ircs?|sips?|tel|geo|bitcoin|magnet):/i)&&e,ge=e=>!!e.match(/^[0-9]*$/)&&e,ve={alt:e=>e,height:ge,href:me,src:me,style:e=>{const t=(";"+e).replace(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,"").replace(/\/\*.*/,"").replace(/\\([a-fA-F0-9]{1,6})\s?/,(e,t)=>String.fromCharCode(parseInt(t,16))).match(/;\s*([a-z-]+)\s*:\s*([^;]*[^\s;])\s*/g),n=[];if(!t)return!1;for(const e of t){const t=e.match(/^;\s*([a-z-]+)\s*:\s*([^;]*[^\s])\s*$/);if(!t)continue;const i=fe.get(t[1]);if(i){const e=t[2].match(i);e&&n.push(`${t[1]}:${e[0]}`)}}return!!n.length&&n.join("")},width:ge};function be(e){if("string"==typeof e)return e;if(!pe.has(e.name)){if("script"===e.name)return;return function(e){let t=[];for(const n of e.children)if("string"==typeof n)t.push(n);else{const e=be(n);e&&(Array.isArray(e)?t=t.concat(e):t.push(e))}return t}(e)}const t=e.children.map(be).filter(e=>void 0!==e),n={};for(const[t,i]of Object.entries(e.attributes)){const r=he.get(e.name);if(!r||!r.has(t))continue;if(!i)continue;const s=ve[t](i);s&&(n[t]=s)}return{attributes:n,children:t,name:e.name}}function ye(e){if("string"==typeof e)return;let t=[];for(const n of e.children){if(!n)continue;if("string"==typeof n){t.push(n);continue}const e=be(n);Array.isArray(e)?t=t.concat(e):e&&t.push(e)}const n={};return"body"===e.name?(void 0!==e.attributes.xmlns&&(n.xmlns=e.attributes.xmlns),e.attributes.style&&(n.style=e.attributes.style),void 0!==e.attributes["xml:lang"]&&(n["xml:lang"]=e.attributes["xml:lang"]),{attributes:n,children:t,name:"body"}):void 0}function _e(e){return 97<=e&&e<=122||65<=e&&e<=90||58===e||95===e}function Se(e){return 192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=767||880<=e&&e<=893||895<=e&&e<=8191||8204<=e&&e<=8205||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||65008<=e&&e<=65533||65536<=e&&e<=983039}function we(e){return _e(e)||Se(e)}function xe(e){return _e(e)||45===e||46===e||48<=e&&e<=57||183===e||768<=e&&e<=879||8255<=e&&e<=8256||Se(e)}function Te(e){return 32===e||10===e||13===e||9===e}class ke extends o.EventEmitter{constructor(e={}){super(),this.allowComments=!0,this.attributes={},this.state=34,this.tagName="",this.haveDeclaration=!1,this.recordBuffer=[],void 0!==e.allowComments&&(this.allowComments=e.allowComments)}write(e){for(const t of e){const e=t.codePointAt(0);switch(this.state){case 34:if(60===e){let e;try{e=ae(this.endRecord())}catch(e){return void this.emit("error",e)}e&&this.emit("text",e),this.transition(31);continue}this.record(t);continue;case 31:if(47===e){this.transition(7);continue}if(33===e){this.transition(24);continue}if(63===e){this.haveDeclaration&&this.restrictedXML(),this.transition(25);continue}if(we(e)){this.transition(30),this.startRecord(t);continue}return this.notWellFormed();case 30:if(xe(e)){this.record(t);continue}if(Te(e)){this.startTag(),this.transition(32);continue}if(47===e){this.startTag(),this.transition(29);continue}if(62===e){this.startTag(),this.transition(34),this.emit("startElement",this.tagName,this.attributes);continue}return this.notWellFormed();case 29:if(62===e){this.emit("startElement",this.tagName,this.attributes),this.emit("endElement",this.tagName),this.transition(34);continue}return this.notWellFormed();case 33:if(Te(e)){this.transition(32);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 32:if(Te(e))continue;if(we(e)){this.startRecord(t),this.transition(0);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 7:if(we(e)){this.startRecord(t),this.transition(6);continue}return this.notWellFormed();case 6:if(xe(e)){this.record(t);continue}if(Te(e)){this.transition(8);continue}if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 8:if(Te(e))continue;if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 0:if(xe(e)){this.record(t);continue}if(61===e){this.addAttribute(),this.transition(4);continue}if(Te(e)){this.addAttribute(),this.transition(3);continue}return this.notWellFormed();case 3:if(61===e){this.transition(4);continue}if(Te(e))continue;return this.notWellFormed();case 4:if(34===e){this.startRecord(),this.transition(1);continue}if(39===e){this.startRecord(),this.transition(2);continue}if(Te(e))continue;return this.notWellFormed();case 1:case 2:if(34===e&&1===this.state||39===e&&2===this.state){const e=this.endRecord();this.attributes[this.attributeName]=ae(e),this.transition(33);continue}if(60===e)return this.notWellFormed();this.record(t);continue;case 24:if(45===e){this.allowComments||this.restrictedXML(),this.transition(23);continue}if(91===e){this.transition(21);continue}return this.notWellFormed();case 23:if(45===e){this.transition(14);continue}return this.notWellFormed();case 14:45===e&&this.transition(12);continue;case 12:45===e?this.transition(11):this.transition(14);continue;case 11:62===e?this.transition(34):this.transition(14);continue;case 25:if(88===e||120===e){this.transition(28);continue}return this.notWellFormed();case 28:if(77===e||109===e){this.transition(27);continue}return this.notWellFormed();case 27:if(76===e||108===e){this.transition(26);continue}return this.notWellFormed();case 26:if(Te(e)){this.haveDeclaration=!0,this.transition(15);continue}return this.notWellFormed();case 13:if(62===e){this.transition(34);continue}return this.notWellFormed();case 15:63===e&&this.transition(13);continue;case 21:this.wait(e,67,20);continue;case 20:this.wait(e,68,19);continue;case 19:this.wait(e,65,18);continue;case 18:this.wait(e,84,17);continue;case 17:this.wait(e,65,16);continue;case 16:this.wait(e,91,5);continue;case 5:if(93===e){this.transition(10);continue}this.record(t);continue;case 10:93===e?this.transition(9):(this.record(String.fromCodePoint(93)),this.record(t),this.transition(5));continue;case 9:if(62===e){const e=this.endRecord();e&&this.emit("text",e),this.transition(34)}else this.record(String.fromCodePoint(93)),this.record(String.fromCodePoint(93)),this.record(t),this.transition(5);continue}}}end(e){e&&this.write(e),this.write=()=>{}}record(e){this.recordBuffer.push(e)}startRecord(e){this.recordBuffer=[],e&&this.recordBuffer.push(e)}endRecord(){const e=this.recordBuffer;return this.recordBuffer=[],e.join("")}startTag(){this.tagName=this.endRecord(),this.attributes={}}addAttribute(){const e=this.endRecord();if(void 0!==this.attributes[e])return this.notWellFormed();this.attributeName=e,this.attributes[e]=""}wait(e,t,n){if(e!==t)return this.notWellFormed();this.transition(n)}transition(e){this.state=e,34===e&&this.startRecord()}notWellFormed(e){this.emit("error",Z.notWellFormed(e))}restrictedXML(e){this.emit("error",Z.restrictedXML(e))}}function Ie(e,t={}){const n=new ke(t);let i,r,s=null;if(n.on("text",e=>{r&&r.children.push(e)}),n.on("startElement",(e,t)=>{const n=new ue(e,t);i||(i=n),r=r?r.appendChild(n):n}),n.on("endElement",e=>{r?e===r.name?r.parent&&(r=r.parent):n.emit("error",Z.notWellFormed("b")):n.emit("error",Z.notWellFormed("a"))}),n.on("error",e=>{s=e}),n.write(e),n.end(),s)throw s;return i}function je(e,t,n,i){if(i){e=e||i.getNamespace();const n=i.getNamespaceRoot(e);if(n){t=`${n.useNamespace("",e)}:${t}`}}const r=new ue(t);return t.indexOf(":")<0&&(!n||e!==n)&&r.setAttribute("xmlns",e),r}function Ee(e,t){return(e.getAttribute("xml:lang")||t||"").toLowerCase()}function Ne(e,t){const n=[];for(const i of e)n.push(Ee(i,t.lang));let i;return i=t.resolveLanguage?t.resolveLanguage(n,t.acceptLanguages||[],t.lang):t.lang,i||""}function Ce(e,t,n,i){const r=e.getChildren(n,t),s=Ee(e);return r.length?i?r.filter(e=>{if(Ee(e,s)===i)return!0}):r:[]}function Re(e,t,n,i){t=t||e.getNamespace();const r=Ce(e,t,n,i);if(r.length)return r[0];const s=je(t,n,e.getDefaultNamespace(),e),o=Ee(e,i);return i&&o!==i&&s.setAttribute("xml:lang",i),e.appendChild(s),s}function Oe(e){return{importer(t){const n=t.getAttribute(e.name,e.namespace);return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);if(i||e.emitEmpty)if(e.namespace&&e.prefix){let n;const r=t.getNamespaceRoot(e.namespace);if(r)n=r.useNamespace(e.prefix,e.namespace);else{const i=t.getNamespaceContext();i[e.namespace]||(n=t.useNamespace(e.prefix,e.namespace),i[e.namespace]=n)}t.setAttribute(`${n}:${e.name}`,i,e.emitEmpty)}else t.setAttribute(e.name,i,e.emitEmpty)}}}function Ae(e,t){return(n,i,r={})=>(r=Object.assign({staticDefault:i},r),Oe(Object.assign(Object.assign({name:n},e),t?t(r):r)))}function Pe(e,t){return(n,i,r,s,o={})=>(o=Object.assign({staticDefault:s},o),Oe(Object.assign(Object.assign({name:r,namespace:i,prefix:n},e),t?t(o):o)))}function qe(e){const t=e.converter||Oe(Object.assign(Object.assign({},e),{namespace:e.attributeNamespace}));return{importer(n,i){const r=n.getChild(e.element,e.namespace||n.getNamespace());return r?t.importer(r,i):e.dynamicDefault?e.dynamicDefault():e.staticDefault},exporter(n,i,r){if(void 0!==i&&i!==e.staticDefault){const s=Re(n,e.namespace||n.getNamespace(),e.element);t.exporter(s,i,r)}}}}function Le(e,t){return(n,i,r,s,o={})=>(o=Object.assign({staticDefault:s},o),qe(Object.assign(Object.assign({element:i,name:r,namespace:n},e),t?t(o):o)))}function Fe(e){return{importer(t){const n=t.getText();return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(!n&&e.emitEmpty)return void t.children.push("");if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);i&&t.children.push(i)}}}function Me(e){const t=Fe(e);return{importer(n,i){const r=Ce(n,e.namespace||n.getNamespace(),e.element),s=Ne(r,i);if(!r.length)return e.dynamicDefault?e.dynamicDefault():e.staticDefault;if(e.matchLanguage)for(const e of r)if(Ee(e,i.lang)===s)return t.importer(e,i);return t.importer(r[0],i)},exporter(n,i,r){if(i||!e.emitEmpty){if(void 0!==i&&i!==e.staticDefault){const s=Re(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0);t.exporter(s,i,r)}}else Re(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0)}}}const De={parseValue:e=>e,writeValue:e=>e},Be={parseValue:e=>parseInt(e,10),writeValue:e=>e.toString()},Ue={parseValue:e=>parseFloat(e),writeValue:e=>e.toString()},ze={parseValue:e=>"true"===e||"1"===e||"false"!==e&&"0"!==e&&void 0,writeValue:e=>e?"1":"0"},Je={parseValue:e=>new Date(e),writeValue:e=>"string"==typeof e?e:e.toISOString()},Ge={parseValue:e=>JSON.parse(e),writeValue:e=>JSON.stringify(e)},Ve=(t="utf8")=>({parseValue:n=>("base64"===t&&"="===n&&(n=""),e.from(n.trim(),t)),writeValue:n=>{let i;return i="string"==typeof n?e.from(n).toString(t):n?n.toString(t):"","base64"===t&&(i=i||"="),i}}),$e={parseValue:e=>{let t=-1;"-"===e.charAt(0)&&(t=1,e=e.slice(1));const n=e.split(":");return(60*parseInt(n[0],10)+parseInt(n[1],10))*t},writeValue:e=>{if("string"==typeof e)return e;{let t="-";e<0&&(e=-e,t="+");const n=e/60,i=e%60;return t+=(n<10?"0":"")+n+":"+(i<10?"0":"")+i,t}}},He=Ae(De,e=>Object.assign({dynamicDefault:e.emitEmpty?t=>""===t?"":e.staticDefault:void 0},e)),We=Ae(ze),Qe=Ae(Be),Ke=Ae(Ue),Xe=Ae(Je),Ye=Pe(De),Ze=Pe(ze),et=Pe(Be),tt=Pe(Ue),nt=Pe(Je),it=Le(De),rt=Le(ze),st=Le(Be),ot=Le(Ue),at=Le(Je),ct=e=>Fe(Object.assign({staticDefault:e},De)),lt=()=>Fe(Object.assign({},Ge)),ut=(e="utf8")=>Fe(Object.assign({},Ve(e)));function pt(){return{importer:(e,t)=>Ee(e,t.lang),exporter(e,t,n){t&&t.toLowerCase()!==n.lang?e.setAttribute("xml:lang",t):e.setAttribute("xml:lang",void 0)}}}const dt=(e,t,n,i=!1)=>Me(Object.assign({element:t,emitEmpty:i,matchLanguage:!0,namespace:e,staticDefault:n},De)),ht=(e,t,n="utf8")=>Me(Object.assign({element:t,matchLanguage:!0,namespace:e},Ve(n))),ft=(e,t)=>Me(Object.assign({element:t,namespace:e},Je)),mt=(e,t,n)=>Me(Object.assign({element:t,namespace:e,staticDefault:n},Be)),gt=(e,t,n)=>Me(Object.assign({element:t,namespace:e,staticDefault:n},Ue)),vt=(e,t)=>Me(Object.assign({element:t,namespace:e},Ge));function bt(e,t){return Me(Object.assign({element:t,namespace:e,staticDefault:0},$e))}function yt(e,t){return{importer(n){if(n.getChild(t,e||n.getNamespace()))return!0},exporter(n,i){i&&Re(n,e||n.getNamespace(),t)}}}const _t=(e,t,n)=>{if(!n)return;let i=t;for(const t of e)i=Re(i,t.namespace||i.getNamespace(),t.element);i.children.push(n.toString())};function St(e,t){return{importer(n){let i=n;for(const n of e)if(i=i.getChild(n.element,n.namespace||i.getNamespace()),!i)return t;return i.getText()||t},exporter(t,n){_t(e,t,n)}}}function wt(e,t){return{importer(n){let i=n;for(const t of e)if(i=i.getChild(t.element,t.namespace||i.getNamespace()),!i)return;const r=i.getText();return r?parseInt(r,10):t||void 0},exporter(t,n){_t(e,t,n)}}}function xt(e){return{importer(t){let n=t;for(const t of e)if(n=n.getChild(t.element,t.namespace||n.getNamespace()),!n)return!1;return!0},exporter(t,n){if(!n)return;let i=t;for(const t of e)i=Re(i,t.namespace||i.getNamespace(),t.element)}}}function Tt(e){const t=e.pop();return{importer(n,i){let r=n;for(const t of e)if(r=r.getChild(t.element,t.namespace||r.getNamespace()),!r)return[];const s=[],o=Ce(r,t.namespace||r.getNamespace(),t.element),a=Ne(o,i);for(const e of o)Ee(e,i.lang)===a&&s.push(e.getText());return s},exporter(n,i,r){if(!i.length)return;let s=n;for(const t of e)s=Re(s,t.namespace||s.getNamespace(),t.element);const{namespace:o,element:a}=t;for(const e of i){const t=je(o||s.getNamespace(),a,r.namespace,s);t.children.push(e),s.appendChild(t)}}}}function kt(e,t,n){const i=new Map,r=new Map;for(const e of t)"string"==typeof e?(i.set(e,e),r.set(e,e)):(i.set(e[1],e[0]),r.set(e[0],e[1]));return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&i.has(n.getName()))return i.get(n.getName());return n},exporter(t,n){r.has(n)&&Re(t,e,r.get(n))}}}function It(e,t,n,i){const r=new Set(t),s=new Set(n);return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&r.has(n.getName())){for(const i of n.children)if("string"!=typeof i&&i.getNamespace()===(e||t.getNamespace())&&s.has(i.getName()))return[n.getName(),i.getName()];return[n.getName()]}return i},exporter(t,n){const i=Re(t,e,n[0]);n[1]&&Re(i,e,n[1])}}}function jt(e,t){return{importer(n,i){const r=[],s=Ce(n,e||n.getNamespace(),t),o=Ne(s,i);for(const e of s)Ee(e,i.lang)===o&&r.push(e.getText());return r},exporter(n,i,r){for(const s of i){const i=je(e||n.getNamespace(),t,r.namespace,n);i.children.push(s),n.appendChild(i)}}}}function Et(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(t)}return r},exporter(i,r,s){for(const o of r){const r=je(e||i.getNamespace(),t,s.namespace,i);r.setAttribute(n,o),i.appendChild(r)}}}}function Nt(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(parseInt(t,10))}return r},exporter(i,r,s){for(const o of r){const r=je(e||i.getNamespace(),t,s.namespace,i);r.setAttribute(n,o.toString()),i.appendChild(r)}}}}function Ct(e,t){return{importer(n,i){const r=[],s=Ce(n,e||n.getNamespace(),t),o=new Set;for(const e of s){const t=e.getText();if(t){const n=Ee(e,i.lang);if(o.has(n))continue;r.push({lang:n,value:t}),o.add(n)}}return o.size>0?r:void 0},exporter(n,i,r){for(const s of i){const i=s.value;if(i){const o=je(e||n.getNamespace(),t,r.namespace,n);s.lang!==r.lang&&o.setAttribute("xml:lang",s.lang),o.children.push(i),n.appendChild(o)}}}}}function Rt(e,t){const n=new Map,i=new Map;for(const e of t)"string"==typeof e?(n.set(e,e),i.set(e,e)):(n.set(e[1],e[0]),i.set(e[0],e[1]));return{importer(t){const i=[];for(const r of t.children)"string"!=typeof r&&r.getNamespace()===(e||t.getNamespace())&&n.has(r.getName())&&i.push(n.get(r.getName()));return i},exporter(t,n){for(const r of n)Re(t,e,i.get(r))}}}function Ot(e,t,n,i=!1){return{importer(r,s){const o=r.getChild(t,e||r.getNamespace());if(!o)return;const a=[];for(const e of o.children)if("string"!=typeof e&&s.registry.getImportKey(e)===n){const t=s.registry.import(e);t&&a.push(t)}return i?a:a[0]},exporter(i,r,s){let o=[];o=Array.isArray(r)?r:[r];const a=[];for(const t of o){const r=s.registry.export(n,t,Object.assign(Object.assign({},s),{namespace:e||i.getNamespace()||void 0}));r&&a.push(r)}if(a.length){const n=Re(i,e||i.getNamespace(),t);for(const e of a)n.appendChild(e)}}}}function At(e){return{exporter:()=>{},importer:()=>e}}function Pt(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=Ce(i,e||i.getNamespace(),t),o=Ne(s,r);for(const e of s)if(Ee(e,r.lang)===o)return n?r.sanitizers[n](e.toJSON()):e.toJSON();return s[0]?n?r.sanitizers[n](s[0].toJSON()):s[0].toJSON():void 0},exporter(i,r,s){if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(r&&n){if(!s.sanitizers||!s.sanitizers[n])return;r=s.sanitizers[n](r)}if(!r)return;const o=Re(i,e||i.getNamespace(),t,s.lang);for(const e of r.children)"string"==typeof e?o.appendChild(e):e&&o.appendChild(new ue(e.name,e.attributes,e.children))}}}function qt(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=[],o=new Set,a=Ce(i,e||i.getNamespace(),t);for(const e of a){let t=e.toJSON();if(n&&(t=r.sanitizers[n](t)),t){const n=Ee(e,r.lang);if(o.has(n))continue;s.push({lang:n,value:t}),o.add(n)}}return o.size>0?s:void 0},exporter(i,r,s){for(const o of r){let r=o.value;if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(r&&n){if(!s.sanitizers||!s.sanitizers[n])continue;r=s.sanitizers[n](r)}if(r){const n=je(e||i.getNamespace(),t,s.namespace,i);i.appendChild(n),o.lang!==s.lang&&n.setAttribute("xml:lang",o.lang);for(const e of r.children)"string"==typeof e?n.appendChild(e):n.appendChild(new ue(e.name,e.attributes,e.children))}}}}}function Lt(e,t,n,i){return{importer(r,s){const o={},a=Ce(r,e,t),c=He(n).importer,l=He(i).importer;for(const e of a)o[c(e,s)]=l(e,s);return o},exporter(r,s,o){const a=He(n).exporter,c=He(i).exporter,l=e||r.getNamespace();for(const[e,n]of Object.entries(s)){const i=je(l,t,o.namespace,r);a(i,e,o),s[e]&&c(i,n,o),r.appendChild(i)}}}}class Ft{constructor(){this.parents=new Set,this.placeholder=!1,this.typeField="",this.versionField="",this.defaultType="",this.defaultVersion="",this.languageField="lang",this.typeValues=new Map,this.typeOrders=new Map,this.importers=new Map,this.exporters=new Map,this.children=new Map,this.childrenIndex=new Map,this.implicitChildren=new Set,this.contexts=new Map}addChild(e,t,n=!1,i,r){const s={multiple:n||!1,name:e,selector:i,translator:t},o=this.children.get(e);if(!o){s.translator.parents.add(this),this.children.set(e,s);for(const[n]of t.importers)this.implicitChildren.has(n)||this.childrenIndex.set(n,e);return void(r&&this.implicitChildren.add(r))}const a=o.translator;o.multiple=n,i&&o.selector&&i!==o.selector&&(o.selector=void 0);for(const[n,i]of t.importers){const[r,s]=(a.typeValues.get(n)||"").split("__v__");a.updateDefinition({contexts:t.contexts,element:i.element,exporterOrdering:new Map,exporters:new Map,importerOrdering:i.fieldOrders,importers:i.fields,namespace:i.namespace,optionalNamespaces:new Map,type:r,version:s}),this.implicitChildren.has(n)||this.childrenIndex.set(n,e)}for(const[e,n]of t.exporters){const[i,r]=e.split("__v__");a.updateDefinition({contexts:t.contexts,element:n.element,exporterOrdering:n.fieldOrders,exporters:n.fields,importerOrdering:new Map,importers:new Map,namespace:n.namespace,optionalNamespaces:n.optionalNamespaces,type:i,version:r})}}addContext(e,t,n,i,r,s){t&&(e=`${e}[${t}]`);let o=this.contexts.get(e);o||(o={typeField:"",versionField:"",typeValues:new Map}),s&&(o.impliedType=r),o.typeField=n||"",o.typeValues.set(i,r),this.contexts.set(e,o)}getChild(e){const t=this.children.get(e);if(t)return t.translator}getImportKey(e){return this.childrenIndex.get(`{${e.getNamespace()}}${e.getName()}`)}updateDefinition(e){const t=`{${e.namespace}}${e.element}`,n=e.type||this.defaultType,i=e.version||this.defaultVersion,r=i?`${n}__v__${i}`:n,s=this.importers.get(t)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace};for(const[t,n]of e.importers)s.fields.set(t,n);for(const[t,n]of e.importerOrdering)s.fieldOrders.set(t,n);this.importers.set(t,s);const o=this.exporters.get(r)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace,optionalNamespaces:e.optionalNamespaces};for(const[t,n]of e.exporters)o.fields.set(t,n);for(const[t,n]of e.exporterOrdering)o.fieldOrders.set(t,n);for(const[t,n]of e.optionalNamespaces)o.optionalNamespaces.set(t,n);this.exporters.set(r,o);for(const[t,n]of e.contexts){const e=this.contexts.get(t)||{impliedType:void 0,typeField:n.typeField,versionField:n.versionField,typeValues:new Map};e.typeField||(e.typeField=n.typeField),e.versionField||(e.versionField=n.versionField),e.impliedType||(e.impliedType=n.impliedType);for(const[t,i]of n.typeValues)e.typeValues.set(t,i);this.contexts.set(t,e)}if(e.type)this.typeValues.set(t,r),e.typeOrder&&e.type&&this.typeOrders.set(e.type,e.typeOrder);else if(this.typeField&&!e.type){for(const[,t]of this.importers){for(const[n,i]of e.importers)t.fields.set(n,i);for(const[n,i]of e.importerOrdering)t.fieldOrders.set(n,i)}for(const[,t]of this.exporters){for(const[n,i]of e.exporters)t.fields.set(n,i);for(const[n,i]of e.exporterOrdering)t.fieldOrders.set(n,i)}}}replaceWith(e){for(const[t,n]of this.children)e.children.set(t,n);for(const[t,n]of this.childrenIndex)e.childrenIndex.set(t,n);for(const[t,n]of this.contexts)e.contexts.set(t,n);for(const t of this.implicitChildren)e.implicitChildren.add(t);for(const t of this.parents)for(const n of t.children.values())n.translator===this&&(n.translator=e);this.parents=new Set}import(e,t){const n=`{${e.getNamespace()}}${e.getName()}`,i={},r=this.importers.get(n);if(!r)return;const s=this.typeValues.get(n)||"",[o,a]=s.split("__v__"),c=t.path||"";let l;if(t.pathSelector&&(l=this.contexts.get(`${c}[${t.pathSelector}]`)),l||(l=this.contexts.get(c)),l){if(!l.impliedType){const e=l.typeValues.get(n)||"";e&&(i[l.typeField]=e)}}else this.typeField&&o&&o!==this.defaultType&&(i[this.typeField]=o);this.versionField&&a&&a!==this.defaultVersion&&(i[this.versionField]=a);const u=Object.assign(Object.assign({},t),{data:i,importer:r,lang:(e.getAttribute("xml:lang")||t.lang||"").toLowerCase(),pathSelector:o,translator:this}),p=[...r.fieldOrders.entries()].sort((e,t)=>e[1]>t[1]?-1:e[1]<t[1]?1:0),d=p.filter(e=>e[1]>=0),h=p.filter(e=>e[1]<0);for(const[n]of d){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}for(const n of e.children){if("string"==typeof n)continue;const e=`{${n.getNamespace()}}${n.getName()}`,r=this.childrenIndex.get(e);if(!r)continue;u.path=`${t.path}.${r}`;const{translator:s,multiple:a,selector:c}=this.children.get(r);if(!c||c===o){const e=s.import(n,u);void 0!==e&&(a?(i[r]||(i[r]=[]),i[r].push(e)):i[r]?i[r]=s.resolveCollision(i[r],e):i[r]=e)}}for(const[n]of h){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}return i}export(e,t){if(!e)return;let n=this.defaultType,i=this.defaultVersion;const r=t.path||"";let s;t.pathSelector&&(s=this.contexts.get(`${r}[${t.pathSelector}]`)),s||(s=this.contexts.get(r)),s?n=s.impliedType||e[s.typeField]||this.defaultType:this.typeField&&(n=e[this.typeField]||this.defaultType),this.versionField&&(i=e[this.versionField]||this.defaultVersion);const o=i?`${n}__v__${i}`:n,a=this.exporters.get(o);if(!a)return;const c=je(a.namespace,a.element,t.namespace,t.element);t.element&&(c.parent=t.element);for(const[e,t]of a.optionalNamespaces)c.addOptionalNamespace(e,t);const l=Object.assign(Object.assign({},t),{data:e,element:c,exporter:a,lang:(e[this.languageField]||t.lang||"").toLowerCase(),namespace:c.getDefaultNamespace(),pathSelector:n,translator:this}),u=a.fields.get(this.languageField);u&&u(c,e[this.languageField],t);const p=Object.keys(e);p.sort((e,t)=>(a.fieldOrders.get(e)||1e5)-(a.fieldOrders.get(t)||1e5));for(const i of p){if(i===this.languageField)continue;const r=e[i],s=a.fields.get(i);if(s){s(c,r,l);continue}const o=this.children.get(i);if(!o)continue;l.path=`${t.path?t.path+".":""}${i}`;const{translator:u,multiple:p,selector:d}=o;if(!d||d===n){let e;e=p?null!=r?r:[]:[r];for(const t of e){const e=u.export(t,l);e&&c.appendChild(e)}}}return c}resolveCollision(e,t){return(this.typeOrders.get(e[this.typeField]||this.defaultType)||0)<=(this.typeOrders.get(t[this.typeField]||this.defaultType)||0)?e:t}}class Mt{constructor(){this.translators=new Map,this.root=new Ft,this.setLanguageResolver(le)}setLanguageResolver(e){this.languageResolver=e}import(e,t={registry:this}){if(!this.hasTranslator(e.getNamespace(),e.getName()))return;t.acceptLanguages||(t.acceptLanguages=[]),t.acceptLanguages=t.acceptLanguages.map(e=>e.toLowerCase()),t.lang&&(t.lang=t.lang.toLowerCase()),t.resolveLanguage||(t.resolveLanguage=this.languageResolver),t.path=this.getImportKey(e),t.sanitizers||(t.sanitizers={xhtmlim:ye});return this.getOrCreateTranslator(e.getNamespace(),e.getName()).import(e,Object.assign(Object.assign({},t),{registry:this}))}export(e,t,n={registry:this}){n.acceptLanguages||(n.acceptLanguages=[]),n.acceptLanguages=n.acceptLanguages.map(e=>e.toLowerCase()),n.lang&&(n.lang=n.lang.toLowerCase()),n.sanitizers||(n.sanitizers={xhtmlim:ye}),n.path=e;const i=e.split(".").filter(e=>""!==e);let r=this.root;for(const e of i){const t=r.getChild(e);if(!t)return;r=t}return r.export(t,Object.assign(Object.assign({},n),{registry:this}))}getImportKey(e,t=""){const n=t?this.walkToTranslator(t.split(".")):this.root;if(n)return n.getImportKey(e)}define(e){if(Array.isArray(e)){for(const t of e)"object"==typeof t?this.define(t):t(this);return}if("object"!=typeof e)return void e(this);const t=e;t.aliases=t.aliases||[],t.path&&!t.aliases.includes(t.path)&&t.aliases.push(t.path);const n=t.aliases.map(e=>"string"==typeof e?{path:e}:e).sort((e,t)=>{const n=e.path.split(".").length;return t.path.split(".").length-n});let i;if(this.hasTranslator(t.namespace,t.element)&&(i=this.getOrCreateTranslator(t.namespace,t.element)),!i){let e;for(const t of n){const n=this.walkToTranslator(t.path.split("."));if(n&&!n.placeholder){i=n;break}n&&(e=n)}e&&!i&&(i=e,i.placeholder=!1)}i||(i=this.getOrCreateTranslator(t.namespace,t.element)),this.indexTranslator(t.namespace,t.element,i);const r=t.fields||{},s=new Map,o=new Map,a=new Map,c=new Map;t.typeField&&(i.typeField=t.typeField),t.defaultType&&(i.defaultType=t.defaultType),t.versionField&&(i.versionField=t.versionField),t.defaultVersion&&(i.defaultVersion=t.defaultVersion),t.languageField&&(i.languageField=t.languageField);for(const[e,t]of Object.entries(r))s.set(e,t.importer),a.set(e,t.importOrder||t.order||0),o.set(e,t.exporter),c.set(e,t.exportOrder||t.order||0);if(t.childrenExportOrder)for(const[e,n]of Object.entries(t.childrenExportOrder))c.set(e,n||0);const l=new Map;for(const[e,n]of Object.entries(t.optionalNamespaces||{}))l.set(e,n);i.updateDefinition({contexts:new Map,element:t.element,exporterOrdering:c,exporters:o,importerOrdering:a,importers:s,namespace:t.namespace,optionalNamespaces:l,type:t.type,version:t.version,typeOrder:t.typeOrder});for(const e of n)this.alias(t.namespace,t.element,e.path,e.multiple,e.selector,e.contextField,t.type,e.impliedType);for(const e of n){const t=this.walkToTranslator(e.path.split("."));t&&t!==i&&t.replaceWith(i)}}alias(e,t,n,i=!1,r,s,o,a=!1){const c=this.getOrCreateTranslator(e,t);c.placeholder=!1;const l=n.split(".").filter(e=>""!==e),u=l.pop(),p=this.walkToTranslator(l,!0),d=`{${e}}${t}`;o&&(s||a)&&c.addContext(n,r,s,d,o,a),p.addChild(u,c,i,r,d)}walkToTranslator(e,t=!1){let n=this.root;for(const i of e){let e=n.getChild(i);if(!e){if(!t)return;e=new Ft,e.placeholder=!0,n.addChild(i,e)}n=e}return n}hasTranslator(e,t){return this.translators.has(`{${e}}${t}`)}getOrCreateTranslator(e,t){let n=this.translators.get(`{${e}}${t}`);return n||(n=new Ft,this.indexTranslator(e,t,n)),n}indexTranslator(e,t,n){this.translators.set(`{${e}}${t}`,n)}}const Dt="http://www.w3.org/2005/Atom",Bt="urn:ietf:params:xml:ns:xmpp-bind",Ut="jabber:client",zt="urn:ietf:params:xml:ns:xmpp-sasl",Jt="urn:ietf:params:xml:ns:xmpp-session",Gt="urn:ietf:params:xml:ns:xmpp-stanzas",Vt="http://etherx.jabber.org/streams",$t="urn:ietf:params:xml:ns:xmpp-streams",Ht="urn:ietf:params:xml:ns:xmpp-tls",Wt="urn:ietf:params:xml:ns:xmpp-framing",Qt="jabber:x:data",Kt="jabber:iq:privacy",Xt="http://jabber.org/protocol/disco#info",Yt="http://jabber.org/protocol/disco#items",Zt="http://jabber.org/protocol/address",en="http://jabber.org/protocol/muc",tn="http://jabber.org/protocol/muc#admin",nn="http://jabber.org/protocol/muc#owner",rn="http://jabber.org/protocol/muc#user",sn="http://jabber.org/protocol/ibb",on="http://jabber.org/protocol/commands",an="http://jabber.org/protocol/rsm",cn="http://jabber.org/protocol/pubsub",ln="http://jabber.org/protocol/pubsub#errors",un="http://jabber.org/protocol/pubsub#event",pn="http://jabber.org/protocol/pubsub#owner",dn="http://jabber.org/protocol/bytestreams",hn="jabber:x:oob",fn="http://www.w3.org/1999/xhtml",mn="http://jabber.org/protocol/xhtml-im",gn="http://jabber.org/protocol/geoloc",vn="urn:xmpp:avatar:data",bn="urn:xmpp:avatar:metadata",yn="http://jabber.org/protocol/chatstates",_n="http://jabber.org/protocol/mood",Sn="http://jabber.org/protocol/activity",wn="http://jabber.org/protocol/tune",xn="http://jabber.org/protocol/xdata-validate",Tn="http://jabber.org/protocol/httpbind",kn="http://jabber.org/protocol/shim",In="http://jabber.org/protocol/compress",jn="http://jabber.org/protocol/xdata-layout",En="http://jabber.org/protocol/rosterx",Nn=e=>e+"+notify",Cn="urn:xmpp:jingle:1",Rn="urn:xmpp:jingle:apps:rtp:1",On="urn:xmpp:jingle:apps:rtp:info:1",An="http://jabber.org/protocol/nick",Pn="urn:xmpp:jingle:transports:ice-udp:1",qn="urn:xmpp:jingle:transports:raw-udp:1",Ln="urn:xmpp:sm:3",Fn="urn:xmpp:delay",Mn="urn:xmpp:bob",Dn="urn:xmpp:jingle:apps:file-transfer:5",Bn="urn:xmpp:jingle:apps:xmlstream:0",Un="urn:xmpp:jingle:transports:s5b:1",zn="urn:xmpp:jingle:transports:ibb:1",Jn="urn:xmpp:carbons:2",Gn="urn:xmpp:jingle:apps:rtp:rtcp-fb:0",Vn="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0",$n="urn:xmpp:forward:0",Hn="urn:xmpp:hashes:2",Wn=e=>"urn:xmpp:hash-function-text-names:"+e,Qn="urn:xmpp:rtt:0",Kn="urn:xmpp:hats:0",Xn="urn:xmpp:chat-markers:0",Yn="urn:xmpp:hints",Zn="urn:xmpp:json:0",ei="urn:xmpp:push:0",ti="urn:xmpp:http:upload:0",ni="urn:xmpp:jingle:transports:ice:0",ii="eu.siacs.conversations.axolotl",ri="http://docs.oasis-open.org/ns/xri/xrd-1.0";var si=Object.freeze({__proto__:null,NS_ATOM:Dt,NS_BIND:Bt,NS_CLIENT:Ut,NS_SASL:zt,NS_SERVER:"jabber:server",NS_SESSION:Jt,NS_STANZAS:Gt,NS_STREAM:Vt,NS_STREAMS:$t,NS_STARTTLS:Ht,NS_ROSTER:"jabber:iq:roster",NS_ROSTER_VERSIONING:"urn:xmpp:features:rosterver",NS_SUBSCRIPTION_PREAPPROVAL:"urn:xmpp:features:pre-approval",NS_FRAMING:Wt,NS_DATAFORM:Qt,NS_RPC:"jabber:iq:rpc",NS_LAST_ACTIVITY:"jabber:iq:last",NS_PRIVACY:Kt,NS_LEGACY_CHAT_EVENTS:"jabber:x:event",NS_DISCO_INFO:Xt,NS_DISCO_ITEMS:Yt,NS_ADDRESS:Zt,NS_MUC:en,NS_MUC_ADMIN:tn,NS_MUC_OWNER:nn,NS_MUC_USER:rn,NS_IBB:sn,NS_BOOKMARKS:"storage:bookmarks",NS_PRIVATE:"jabber:iq:private",NS_ADHOC_COMMANDS:on,NS_VCARD_TEMP:"vcard-temp",NS_SEARCH:"jabber:iq:search",NS_RSM:an,NS_PUBSUB:cn,NS_PUBSUB_ERRORS:ln,NS_PUBSUB_EVENT:un,NS_PUBSUB_OWNER:pn,NS_SOCKS5:dn,NS_OOB:hn,NS_OOB_TRANSFER:"jabber:iq:oob",NS_HTTP_AUTH:"http://jabber.org/protocol/http-auth",NS_XHTML:fn,NS_XHTML_IM:mn,NS_REGISTER:"jabber:iq:register",NS_INBAND_REGISTRATION:"http://jabber.org/features/iq-register",NS_AMP:"http://jabber.org/protocol/amp",NS_GEOLOC:gn,NS_ROSTER_DELIMITER:"roster:delimiter",NS_AVATAR_DATA:vn,NS_AVATAR_METADATA:bn,NS_CHAT_STATES:yn,NS_VERSION:"jabber:iq:version",NS_MOOD:_n,NS_ACTIVITY:Sn,NS_COMPONENT:"jabber:component:accept",NS_DISCO_LEGACY_CAPS:"http://jabber.org/protocol/caps",NS_TUNE:wn,NS_DATAFORM_VALIDATION:xn,NS_BOSH:Tn,NS_SHIM:kn,NS_COMPRESSION_FEATURE:"http://jabber.org/features/compress",NS_COMPRESSION:In,NS_DATAFORM_LAYOUT:jn,NS_ROSTER_EXCHANGE:En,NS_ROSTER_NOTES:"storage:rosternotes",NS_REACH_0:"urn:xmpp:reach:0",NS_VCARD_TEMP_UPDATE:"vcard-temp:x:update",NS_ALT_CONNECTIONS_WEBSOCKET:"urn:xmpp:alt-connections:websocket",NS_ALT_CONNECTIONS_XBOSH:"urn:xmpp:alt-connections:xbosh",NS_CAPTCHA:"urn:xmpp:captcha",NS_PEP_NOTIFY:Nn,NS_JINGLE_1:Cn,NS_JINGLE_ERRORS_1:"urn:xmpp:jingle:errors:1",NS_JINGLE_RTP_1:Rn,NS_JINGLE_RTP_ERRORS_1:"urn:xmpp:jingle:apps:rtp:errors:1",NS_JINGLE_RTP_INFO_1:On,NS_JINGLE_RTP_AUDIO:"urn:xmpp:jingle:apps:rtp:audio",NS_JINGLE_RTP_VIDEO:"urn:xmpp:jingle:apps:rtp:video",NS_LANG_TRANS:"urn:xmpp:langtrans",NS_LANG_TRANS_ITEMS:"urn:xmpp:langtrans:items",NS_NICK:An,NS_JINGLE_ICE_UDP_1:Pn,NS_JINGLE_RAW_UDP_1:qn,NS_RECEIPTS:"urn:xmpp:receipts",NS_INVISIBLE_0:"urn:xmpp:invisible:0",NS_BLOCKING:"urn:xmpp:blocking",NS_BLOCKING_ERRORS:"urn:xmpp:blocking:errors",NS_SMACKS_3:Ln,NS_PING:"urn:xmpp:ping",NS_TIME:"urn:xmpp:time",NS_DELAY:Fn,NS_BOSH_XMPP:"urn:xmpp:xbosh",NS_DISCO_EXTERNAL_1:"urn:xmpp:extdisco:1",NS_DISCO_EXTERNAL_2:"urn:xmpp:extdisco:2",NS_DATAFORM_MEDIA:"urn:xmpp:media-element",NS_ATTENTION_0:"urn:xmpp:attention:0",NS_BOB:Mn,NS_SOFTWARE_INFO:"urn:xmpp:dataforms:softwareinfo",NS_JINGLE_FILE_TRANSFER_3:"urn:xmpp:jingle:apps:file-transfer:3",NS_JINGLE_FILE_TRANSFER_4:"urn:xmpp:jingle:apps:file-transfer:4",NS_JINGLE_FILE_TRANSFER_5:Dn,NS_JINGLE_XML_0:Bn,NS_MUC_DIRECT_INVITE:"jabber:x:conference",NS_SEC_LABEL_0:"urn:xmpp:sec-label:0",NS_SEC_LABEL_CATALOG_2:"urn:xmpp:sec-label:catalog:2",NS_SEC_LABEL_ESS_0:"urn:xmpp:sec-label:ess:0",NS_JINGLE_SOCKS5_1:Un,NS_JINGLE_IBB_1:zn,NS_JINGLE_RTP_ZRTP_1:"urn:xmpp:jingle:apps:rtp:zrtp:1",NS_THUMBS_0:"urn:xmpp:thumbs:0",NS_THUMBS_1:"urn:xmpp:thumbs:1",NS_DECLOAKING_0:"urn:xmpp:decloaking:0",NS_CARBONS_2:Jn,NS_JINGLE_RTP_RTCP_FB_0:Gn,NS_JINGLE_RTP_HDREXT_0:Vn,NS_FORWARD_0:$n,NS_HASHES_1:"urn:xmpp:hashes:1",NS_HASHES_2:Hn,NS_HASH_NAME:Wn,NS_RTT_0:Qn,NS_MUC_UNIQUE:"http://jabber.org/protocol/muc#unique",NS_CORRECTION_0:"urn:xmpp:message-correct:0",NS_PSA:"urn:xmpp:psa",NS_MAM_TMP:"urn:xmpp:mam:tmp",NS_MAM_0:"urn:xmpp:mam:0",NS_MAM_1:"urn:xmpp:mam:1",NS_MAM_2:"urn:xmpp:mam:2",NS_HATS_0:Kn,NS_IDLE_1:"urn:xmpp:idle:1",NS_JINGLE_DTLS_0:"urn:xmpp:jingle:apps:dtls:0",NS_CHAT_MARKERS_0:Xn,NS_HINTS:Yn,NS_JSON_0:Zn,NS_JINGLE_GROUPING_0:"urn:xmpp:jingle:apps:grouping:0",NS_JINGLE_RTP_SSMA_0:"urn:xmpp:jingle:apps:rtp:ssma:0",NS_JINGLE_DTLS_SCTP_1:"urn:xmpp:jingle:transports:dtls-sctp:1",NS_CSI_0:"urn:xmpp:csi:0",NS_JINGLE_MSG_INITIATE_0:"urn:xmpp:jingle:jingle-message:0",NS_DELEGATION_1:"urn:xmpp:delegation:1",NS_PUSH_0:ei,NS_JINGLE_PUB_1:"urn:xmpp:jinglepub:1",NS_SID_0:"urn:xmpp:sid:0",NS_HTTP_UPLOAD_0:ti,NS_JINGLE_HTTP_0:"urn:xmpp:jingle:transports:http:0",NS_JINGLE_HTTP_UPLOAD_0:"urn:xmpp:jingle:transports:http:upload:0",NS_JINGLE_ICE_0:ni,NS_REFERENCE_0:"urn:xmpp:reference:0",NS_EME_0:"urn:xmpp:eme:0",NS_SPOILER_0:"urn:xmpp:spoiler:0",NS_OMEMO_AXOLOTL:ii,NS_OMEMO_AXOLOTL_DEVICELIST:"eu.siacs.conversations.axolotl.devicelist",NS_OMEMO_AXOLOTL_BUNDLES:"eu.siacs.conversations.axolotl.bundles",NS_OMEMO_AXOLOTL_BUNDLE:e=>"eu.siacs.conversations.axolotl.bundles:"+e,NS_JSON_MESSAGE_0:"urn:xmpp:json-msg:0",NS_XRD:ri,NS_JINGLE_RTP_MSID_0:"urn:xmpp:jingle:apps:rtp:msid:0"});const oi=He,ai=it,ci=dt;function li(e,t,n){return{aliases:Array.isArray(n)?n:[n],element:t,fields:{},namespace:e}}function ui(e){return{element:"message",fields:e,namespace:Ut}}function pi(e){return{element:"presence",fields:e,namespace:Ut}}function di(e){return{element:"iq",fields:e,namespace:Ut}}function hi(e){return{element:"features",fields:e,namespace:Vt}}function fi(e){return{element:"error",fields:e,namespace:Gt,path:"stanzaError"}}function mi(){return[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}]}class gi extends l.Transform{constructor(e){super({objectMode:!0}),this.closedStream=!1,this.wrappedStream=!1,this.registry=e.registry,this.acceptLanguages=e.acceptLanguages||[],e.wrappedStream&&(this.wrappedStream=!0,this.rootImportKey=e.rootKey),this.parser=new ke({allowComments:e.allowComments}),this.parser.on("error",e=>{this.destroy(e)}),this.parser.on("startElement",(e,t)=>{if(this.destroyed)return;if(this.closedStream)return this.destroy(Z.alreadyClosed());const n=new ue(e,t),i=this.registry.getImportKey(n);if(this.wrappedStream&&!this.rootElement){if(this.rootImportKey&&i!==this.rootImportKey)return this.destroy(Z.unknownRoot());const e=this.registry.import(n,{acceptLanguages:this.acceptLanguages,lang:this.lang});return e?(this.rootElement=n,void this.push({event:"stream-start",kind:i,stanza:e,xml:n})):this.destroy(Z.notWellFormed())}this.currentElement?this.currentElement=this.currentElement.appendChild(n):this.currentElement=n}),this.parser.on("endElement",e=>{if(!this.destroyed){if(this.wrappedStream&&!this.currentElement)return this.rootElement&&e===this.rootElement.name?(this.closedStream=!0,this.push({event:"stream-end",kind:this.rootImportKey,stanza:{},xml:this.rootElement}),this.end()):(this.closedStream=!0,this.destroy(Z.notWellFormed()));if(!this.currentElement||e!==this.currentElement.name)return this.closedStream=!0,this.destroy(Z.notWellFormed());if(this.currentElement.parent)this.currentElement=this.currentElement.parent;else{this.wrappedStream&&(this.currentElement.parent=this.rootElement);const e=this.registry.getImportKey(this.currentElement),t=this.registry.import(this.currentElement,{acceptLanguages:this.acceptLanguages,lang:this.lang});t&&this.push({kind:e,stanza:t,xml:this.currentElement}),this.currentElement=void 0}}}),this.parser.on("text",e=>{this.currentElement&&this.currentElement.children.push(e)})}_transform(e,t,n){this.parser.write(e.toString()),n()}}var vi=Object.freeze({__proto__:null,Registry:Mt,Translator:Ft,XMLElement:ue,define:function(e){return t=>{t.define(e)}},Parser:ke,parse:Ie,StreamParser:gi,escapeXML:oe,unescapeXML:ae,escapeXMLText:ce,basicLanguageResolver:le,createElement:je,getLang:Ee,getTargetLang:Ne,findAll:Ce,findOrCreate:Re,attribute:He,booleanAttribute:We,integerAttribute:Qe,floatAttribute:Ke,dateAttribute:Xe,namespacedAttribute:Ye,namespacedBooleanAttribute:Ze,namespacedIntegerAttribute:et,namespacedFloatAttribute:tt,namespacedDateAttribute:nt,childAttribute:it,childBooleanAttribute:rt,childIntegerAttribute:st,childFloatAttribute:ot,childDateAttribute:at,text:ct,textJSON:lt,textBuffer:ut,languageAttribute:pt,childLanguageAttribute:(e,t)=>qe(Object.assign({converter:pt(),element:t,name:"xml:lang",namespace:e},De)),childText:dt,childTextBuffer:ht,childDate:ft,childInteger:mt,childFloat:gt,childJSON:vt,childTimezoneOffset:bt,childBoolean:yt,deepChildText:St,deepChildInteger:wt,deepChildBoolean:xt,deepMultipleChildText:Tt,childEnum:kt,childDoubleEnum:It,multipleChildText:jt,multipleChildAttribute:Et,multipleChildIntegerAttribute:Nt,childAlternateLanguageText:Ct,multipleChildAlternateLanguageText:function(e,t){return{importer(n,i){const r=[],s=new Map;let o=!1;const a=Ce(n,e||n.getNamespace(),t);for(const e of a){const t=e.getText();if(t){const n=Ee(e,i.lang);let a=s.get(n);a||(a=[],s.set(n,a),r.push({lang:n,value:a})),a.push(t),o=!0}}return o?r:void 0},exporter(n,i,r){for(const s of i)for(const i of s.value){const o=je(e||n.getNamespace(),t,r.namespace,n);s.lang!==r.lang&&o.setAttribute("xml:lang",s.lang),o.children.push(i),n.appendChild(o)}}}},multipleChildEnum:Rt,splicePath:Ot,staticValue:At,childRawElement:function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=i.getChild(t,e||i.getNamespace());return s?n?r.sanitizers[n](s.toJSON()):s.toJSON():void 0},exporter(i,r,s){if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(n){if(!s.sanitizers||!s.sanitizers[n])return;r=s.sanitizers[n](r)}r&&i.appendChild(new ue(r.name,r.attributes,r.children))}}},childLanguageRawElement:Pt,childAlternateLanguageRawElement:qt,parameterMap:Lt,JIDAttribute:oi,childJIDAttribute:ai,childJID:ci,addAlias:li,extendMessage:ui,extendPresence:pi,extendIQ:di,extendStreamFeatures:hi,extendStanzaError:fi,pubsubItemContentAliases:mi});class bi extends l.Transform{constructor(t,n,i="be"){super(),this._block=e.alloc(t),this._finalSize=n,this._blockSize=t,this._bigEndian="be"===i,this._len=0}_transform(e,t,n){let i=null;try{this.update(e,t)}catch(e){i=e}n(i)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(t,n){"string"==typeof t&&(n=n||"utf8",t=e.from(t,n));const i=this._block,r=this._blockSize,s=t.length;let o=this._len;for(let e=0;e<s;){const n=o%r,a=Math.min(s-e,r-n);for(let r=0;r<a;r++)i[n+r]=t[e+r];o+=a,e+=a,o%r==0&&this._update(i)}return this._len+=s,this}digest(e){const t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));const n=8*this._len;if(n<=4294967295)this._bigEndian?(this._block.writeUInt32BE(0,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)):(this._block.writeUInt32LE(n,this._blockSize-8),this._block.writeUInt32LE(0,this._blockSize-4));else{const e=(4294967295&n)>>>0,t=(n-e)/4294967296;this._bigEndian?(this._block.writeUInt32BE(t,this._blockSize-8),this._block.writeUInt32BE(e,this._blockSize-4)):(this._block.writeUInt32LE(e,this._blockSize-8),this._block.writeUInt32LE(t,this._blockSize-4))}this._update(this._block);const i=this._hash();return e?i.toString(e):i}_update(e){throw new Error("_update must be implemented by subclass")}_hash(){throw new Error("_update must be implemented by subclass")}}function yi(e,t){return e<<t|e>>>32-t}function _i(e,t,n,i,r,s,o){return yi(e+(t&n|~t&i)+r+s|0,o)+t|0}function Si(e,t,n,i,r,s,o){return yi(e+(t&i|n&~i)+r+s|0,o)+t|0}function wi(e,t,n,i,r,s,o){return yi(e+(t^n^i)+r+s|0,o)+t|0}function xi(e,t,n,i,r,s,o){return yi(e+(n^(t|~i))+r+s|0,o)+t|0}const Ti=[1518500249,1859775393,-1894007588,-899497514];function ki(e){return e<<5|e>>>27}function Ii(e){return e<<30|e>>>2}function ji(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}class Ei extends bi{constructor(){super(64,56),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this._w=new Array(80)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<80;++n)t[n]=(c=t[n-3]^t[n-8]^t[n-14]^t[n-16])<<1|c>>>31;var c;for(let e=0;e<80;++e){const n=~~(e/20),c=ki(i)+ji(n,r,s,o)+a+t[e]+Ti[n]|0;a=o,o=s,s=Ii(r),r=i,i=c}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0}_hash(){const t=e.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t}}const Ni=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Ci(e,t,n){return n^e&(t^n)}function Ri(e,t,n){return e&t|n&(e|t)}function Oi(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Ai(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Pi(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}class qi extends bi{constructor(){super(64,56),this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this._w=new Array(64)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,c=0|this._f,l=0|this._g,u=0|this._h;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<64;++n)t[n]=0|(((p=t[n-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10)+t[n-7]+Pi(t[n-15])+t[n-16];var p;for(let e=0;e<64;++e){const n=u+Ai(a)+Ci(a,c,l)+Ni[e]+t[e]|0,p=Oi(i)+Ri(i,r,s)|0;u=l,l=c,c=a,a=o+n|0,o=s,s=r,r=i,i=n+p|0}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=c+this._f|0,this._g=l+this._g|0,this._h=u+this._h|0}_hash(){const t=e.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t}}const Li=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Fi(e,t,n){return n^e&(t^n)}function Mi(e,t,n){return e&t|n&(e|t)}function Di(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Bi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Ui(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function zi(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Ji(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Gi(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Vi(e,t){return e>>>0<t>>>0?1:0}class $i extends bi{constructor(){super(128,112),this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this._w=new Array(160)}_update(e){const t=this._w;let n,i,r=0|this._ah,s=0|this._bh,o=0|this._ch,a=0|this._dh,c=0|this._eh,l=0|this._fh,u=0|this._gh,p=0|this._hh,d=0|this._al,h=0|this._bl,f=0|this._cl,m=0|this._dl,g=0|this._el,v=0|this._fl,b=0|this._gl,y=0|this._hl,_=0;for(_=0;_<32;_+=2)t[_]=e.readInt32BE(4*_),t[_+1]=e.readInt32BE(4*_+4);for(;_<160;_+=2){let e=t[_-30],r=t[_-30+1];const s=Ui(e,r),o=zi(r,e);e=t[_-4],r=t[_-4+1];const a=Ji(e,r),c=Gi(r,e),l=t[_-14],u=t[_-14+1],p=t[_-32],d=t[_-32+1];i=o+u|0,n=s+l+Vi(i,o)|0,i=i+c|0,n=n+a+Vi(i,c)|0,i=i+d|0,n=n+p+Vi(i,d)|0,t[_]=n,t[_+1]=i}for(let e=0;e<160;e+=2){n=t[e],i=t[e+1];const _=Mi(r,s,o),S=Mi(d,h,f),w=Di(r,d),x=Di(d,r),T=Bi(c,g),k=Bi(g,c),I=Li[e],j=Li[e+1],E=Fi(c,l,u),N=Fi(g,v,b);let C=y+k|0,R=p+T+Vi(C,y)|0;C=C+N|0,R=R+E+Vi(C,N)|0,C=C+j|0,R=R+I+Vi(C,j)|0,C=C+i|0,R=R+n+Vi(C,i)|0;const O=x+S|0,A=w+_+Vi(O,x)|0;p=u,y=b,u=l,b=v,l=c,v=g,g=m+C|0,c=a+R+Vi(g,m)|0,a=o,m=f,o=s,f=h,s=r,h=d,d=C+O|0,r=R+A+Vi(d,C)|0}this._al=this._al+d|0,this._bl=this._bl+h|0,this._cl=this._cl+f|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+b|0,this._hl=this._hl+y|0,this._ah=this._ah+r+Vi(this._al,d)|0,this._bh=this._bh+s+Vi(this._bl,h)|0,this._ch=this._ch+o+Vi(this._cl,f)|0,this._dh=this._dh+a+Vi(this._dl,m)|0,this._eh=this._eh+c+Vi(this._el,g)|0,this._fh=this._fh+l+Vi(this._fl,v)|0,this._gh=this._gh+u+Vi(this._gl,b)|0,this._hh=this._hh+p+Vi(this._hl,y)|0}_hash(){const t=e.allocUnsafe(64);function n(e,n,i){t.writeInt32BE(e,i),t.writeInt32BE(n,i+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),n(this._gh,this._gl,48),n(this._hh,this._hl,56),t}}const Hi=new Map([["md5",class extends bi{constructor(){super(64,56,"le"),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._m=new Array(16)}_update(e){const t=this._m;for(let n=0;n<16;++n)t[n]=e.readInt32LE(4*n);let n=this._a,i=this._b,r=this._c,s=this._d;n=_i(n,i,r,s,t[0],3614090360,7),s=_i(s,n,i,r,t[1],3905402710,12),r=_i(r,s,n,i,t[2],606105819,17),i=_i(i,r,s,n,t[3],3250441966,22),n=_i(n,i,r,s,t[4],4118548399,7),s=_i(s,n,i,r,t[5],1200080426,12),r=_i(r,s,n,i,t[6],2821735955,17),i=_i(i,r,s,n,t[7],4249261313,22),n=_i(n,i,r,s,t[8],1770035416,7),s=_i(s,n,i,r,t[9],2336552879,12),r=_i(r,s,n,i,t[10],4294925233,17),i=_i(i,r,s,n,t[11],2304563134,22),n=_i(n,i,r,s,t[12],1804603682,7),s=_i(s,n,i,r,t[13],4254626195,12),r=_i(r,s,n,i,t[14],2792965006,17),i=_i(i,r,s,n,t[15],1236535329,22),n=Si(n,i,r,s,t[1],4129170786,5),s=Si(s,n,i,r,t[6],3225465664,9),r=Si(r,s,n,i,t[11],643717713,14),i=Si(i,r,s,n,t[0],3921069994,20),n=Si(n,i,r,s,t[5],3593408605,5),s=Si(s,n,i,r,t[10],38016083,9),r=Si(r,s,n,i,t[15],3634488961,14),i=Si(i,r,s,n,t[4],3889429448,20),n=Si(n,i,r,s,t[9],568446438,5),s=Si(s,n,i,r,t[14],3275163606,9),r=Si(r,s,n,i,t[3],4107603335,14),i=Si(i,r,s,n,t[8],1163531501,20),n=Si(n,i,r,s,t[13],2850285829,5),s=Si(s,n,i,r,t[2],4243563512,9),r=Si(r,s,n,i,t[7],1735328473,14),i=Si(i,r,s,n,t[12],2368359562,20),n=wi(n,i,r,s,t[5],4294588738,4),s=wi(s,n,i,r,t[8],2272392833,11),r=wi(r,s,n,i,t[11],1839030562,16),i=wi(i,r,s,n,t[14],4259657740,23),n=wi(n,i,r,s,t[1],2763975236,4),s=wi(s,n,i,r,t[4],1272893353,11),r=wi(r,s,n,i,t[7],4139469664,16),i=wi(i,r,s,n,t[10],3200236656,23),n=wi(n,i,r,s,t[13],681279174,4),s=wi(s,n,i,r,t[0],3936430074,11),r=wi(r,s,n,i,t[3],3572445317,16),i=wi(i,r,s,n,t[6],76029189,23),n=wi(n,i,r,s,t[9],3654602809,4),s=wi(s,n,i,r,t[12],3873151461,11),r=wi(r,s,n,i,t[15],530742520,16),i=wi(i,r,s,n,t[2],3299628645,23),n=xi(n,i,r,s,t[0],4096336452,6),s=xi(s,n,i,r,t[7],1126891415,10),r=xi(r,s,n,i,t[14],2878612391,15),i=xi(i,r,s,n,t[5],4237533241,21),n=xi(n,i,r,s,t[12],1700485571,6),s=xi(s,n,i,r,t[3],2399980690,10),r=xi(r,s,n,i,t[10],4293915773,15),i=xi(i,r,s,n,t[1],2240044497,21),n=xi(n,i,r,s,t[8],1873313359,6),s=xi(s,n,i,r,t[15],4264355552,10),r=xi(r,s,n,i,t[6],2734768916,15),i=xi(i,r,s,n,t[13],1309151649,21),n=xi(n,i,r,s,t[4],4149444226,6),s=xi(s,n,i,r,t[11],3174756917,10),r=xi(r,s,n,i,t[2],718787259,15),i=xi(i,r,s,n,t[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+i|0,this._c=this._c+r|0,this._d=this._d+s|0}_hash(){const t=e.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t}}],["sha-1",Ei],["sha-256",qi],["sha-512",$i],["sha1",Ei],["sha256",qi],["sha512",$i]]);function Wi(e){e=e.toLowerCase();const t=Hi.get(e);if(t)return new t;throw new Error("Unsupported hash algorithm: "+e)}const Qi=e.alloc(128);class Ki extends l.Transform{constructor(t,n){super(),"string"==typeof n&&(n=e.from(n));const i="sha512"===t?128:64;this._alg=t,n.length>i?n=Wi(t).update(n).digest():n.length<i&&(n=e.concat([n,Qi],i)),this._ipad=e.alloc(i),this._opad=e.alloc(i);for(let e=0;e<i;e++)this._ipad[e]=54^n[e],this._opad[e]=92^n[e];this._hash=Wi(t).update(this._ipad)}_transform(e,t,n){let i;try{this.update(e,t)}catch(e){i=e}finally{n(i)}}_flush(e){let t;try{this.push(this._final())}catch(e){t=e}e(t)}_final(){const e=this._hash.digest();return Wi(this._alg).update(this._opad).update(e).digest()}update(e,t){return this._hash.update(e,t),this}digest(t){const n=this._final()||e.alloc(0);return t?n.toString(t):n}}let Xi;function Yi(t){const n=new Uint8Array(t);return t>0&&(Xi.crypto||Xi.msCrypto).getRandomValues(n),e.from(n.buffer)}"undefined"!=typeof window?Xi=window:void 0!==i&&(Xi=i);const Zi=fetch,er=WebSocket,tr=Xi.RTCPeerConnection;class nr{constructor(e){this.authenticated=!1,this.mutuallyAuthenticated=!1,this.name=e}getCacheableCredentials(){return null}processChallenge(e){}processSuccess(e){this.authenticated=!0}finalize(){const e={authenticated:this.authenticated,mutuallyAuthenticated:this.mutuallyAuthenticated};return this.errorData&&(e.errorData=this.errorData),e}}class ir{constructor(){this.mechanisms=[]}register(e,t,n){this.mechanisms.push({constructor:t,name:e.toUpperCase(),priority:n}),this.mechanisms.sort((e,t)=>t.priority-e.priority)}disable(e){const t=e.toUpperCase();this.mechanisms=this.mechanisms.filter(e=>e.name!==t)}createMechanism(e){const t=e.map(e=>e.toUpperCase());for(const e of this.mechanisms)for(const n of t)if(n===e.name)return new e.constructor(e.name);return null}}function rr(e=32){return Yi(e).toString("hex")}function sr(t,n){const i=[];for(let e=0;e<t.length;e++)i.push(t[e]^n[e]);return e.from(i)}function or(e,t){return Wi(t).update(e).digest()}function ar(e,t,n){return function(e,t){return new Ki(e.toLowerCase(),t)}(n,e).update(t).digest()}function cr(t,n,i,r){let s=ar(t,e.concat([n,e.from("00000001","hex")]),r),o=s;for(let e=0;e<i-1;e++)s=ar(t,s,r),o=sr(o,s);return o}function lr(e){const t={},n=e.toString().split(/,(?=(?:[^"]|"[^"]*")*$)/);for(let e=0,i=n.length;e<i;e++){const i=/(\w+)=["]?([^"]+)["]?$/.exec(n[e]);i&&(t[i[1]]=i[2])}return t}function ur(e){const t=[];for(const n of e)","===n?t.push("=2C"):"="===n?t.push("=3D"):t.push(n);return t.join("")}class pr extends nr{getExpectedCredentials(){return{optional:["trace"],required:[]}}createResponse(t){return e.from(t.trace||"")}}class dr extends nr{getExpectedCredentials(){return{optional:["authzid"],required:[]}}createResponse(t){return e.from(t.authzid||"")}}class hr extends nr{getExpectedCredentials(){return{optional:["authzid"],required:["username","password"]}}createResponse(t){return e.from((t.authzid||"")+"\0"+t.username+"\0"+(t.password||t.token))}}class fr extends nr{constructor(e){super(e),this.failed=!1,this.name=e}getExpectedCredentials(){return{optional:["authzid"],required:["token"]}}createResponse(t){if(this.failed)return e.from("");const n=`n,${ur(M(t.authzid))},`,i=`auth=Bearer ${t.token}`;return e.from(n+""+i+"","utf8")}processChallenge(e){this.failed=!0,this.errorData=JSON.parse(e.toString("utf8"))}}class mr extends nr{constructor(e){super(e),this.providesMutualAuthentication=!1,this.state="INITIAL",this.name=e}processChallenge(e){this.state="CHALLENGE";const t=lr(e);this.authenticated=!!t.rspauth,this.realm=t.realm,this.nonce=t.nonce,this.charset=t.charset}getExpectedCredentials(){return{optional:["authzid","clientNonce","realm"],required:["host","password","serviceName","serviceType","username"]}}createResponse(t){if("INITIAL"===this.state||this.authenticated)return null;let n=t.serviceType+"/"+t.host;t.serviceName&&t.host!==t.serviceName&&(n+="/"+t.serviceName);const i=t.realm||this.realm||"",r=t.clientNonce||rr(16),s="00000001";let o="";o+='username="'+t.username+'"',i&&(o+=',realm="'+i+'"'),o+=',nonce="'+this.nonce+'"',o+=',cnonce="'+r+'"',o+=",nc="+s,o+=",qop=auth",o+=',digest-uri="'+n+'"';const a=Wi("md5").update(t.username).update(":").update(i).update(":").update(t.password).digest(),c=Wi("md5").update(a).update(":").update(this.nonce).update(":").update(r);t.authzid&&c.update(":").update(t.authzid);const l=c.digest("hex"),u=Wi("md5").update("AUTHENTICATE:").update(n).digest("hex");return o+=",response="+Wi("md5").update(l).update(":").update(this.nonce).update(":").update(s).update(":").update(r).update(":").update("auth").update(":").update(u).digest("hex"),"utf-8"===this.charset&&(o+=",charset=utf-8"),t.authzid&&(o+=',authzid="'+t.authzid+'"'),e.from(o)}}class gr{constructor(e){this.providesMutualAuthentication=!0,this.name=e,this.state="INITIAL",this.useChannelBinding=this.name.toLowerCase().endsWith("-plus"),this.algorithm=this.name.toLowerCase().split("scram-")[1].split("-plus")[0]}getExpectedCredentials(){const e=["username","password"];return this.useChannelBinding&&e.push("tlsUnique"),{optional:["authzid","clientNonce"],required:e}}getCacheableCredentials(){return this.cache}createResponse(e){return"INITIAL"===this.state?this.initialResponse(e):this.challengeResponse(e)}processChallenge(t){const n=lr(t);this.salt=e.from(n.s||"","base64"),this.iterationCount=parseInt(n.i,10),this.nonce=n.r,this.verifier=n.v,this.error=n.e,this.challenge=t}processSuccess(e){this.processChallenge(e)}finalize(){return this.verifier?this.serverSignature.toString("base64")!==this.verifier?{authenticated:!1,error:"Mutual authentication failed",mutuallyAuthenticated:!1}:{authenticated:!0,mutuallyAuthenticated:!0}:{authenticated:!1,error:this.error,mutuallyAuthenticated:!1}}initialResponse(t){const n=ur(M(t.authzid)),i=ur(M(t.username));this.clientNonce=t.clientNonce||rr();let r="n";t.tlsUnique&&(r=this.useChannelBinding?"p=tls-unique":"y"),this.gs2Header=e.from(n?`${r},a=${n},`:r+",,"),this.clientFirstMessageBare=e.from(`n=${i},r=${this.clientNonce}`);const s=e.concat([this.gs2Header,this.clientFirstMessageBare]);return this.state="CHALLENGE",s}challengeResponse(t){const n=e.from("Client Key"),i=e.from("Server Key"),r=e.concat([this.gs2Header,t.tlsUnique||e.from("")]).toString("base64"),s=e.from(`c=${r},r=${this.nonce}`);let o,a,c;const l=t.salt&&0===e.compare(t.salt,this.salt);l&&t.clientKey&&t.serverKey?(a=e.from(t.clientKey),c=e.from(t.serverKey)):l&&t.saltedPassword?(o=e.from(t.saltedPassword),a=ar(o,n,this.algorithm),c=ar(o,i,this.algorithm)):(o=cr(e.from(M(t.password)),this.salt,this.iterationCount,this.algorithm),a=ar(o,n,this.algorithm),c=ar(o,i,this.algorithm));const u=or(a,this.algorithm),p=e.from(","),d=e.concat([this.clientFirstMessageBare,p,this.challenge,p,s]),h=sr(a,ar(u,d,this.algorithm)).toString("base64");this.serverSignature=ar(c,d,this.algorithm);const f=e.concat([s,e.from(",p="+h)]);return this.state="FINAL",this.cache={clientKey:a,salt:this.salt,saltedPassword:o,serverKey:c},f}}var vr=Object.freeze({__proto__:null,SimpleMech:nr,Factory:ir,createClientNonce:rr,XOR:sr,H:or,HMAC:ar,Hi:cr,ANONYMOUS:pr,EXTERNAL:dr,PLAIN:hr,OAUTH:fr,DIGEST:mr,SCRAM:gr});function br(e){e.getAccountInfo=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({account:{},to:t,type:"get"})).account})),e.updateAccount=(t,n)=>e.sendIQ({account:n,to:t,type:"set"}),e.deleteAccount=t=>e.sendIQ({account:{remove:!0},to:t,type:"set"}),e.getPrivateData=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({privateStorage:{[t]:{}},type:"get"})).privateStorage[t]})),e.setPrivateData=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return e.sendIQ({privateStorage:{[t]:n},type:"set"})})),e.getVCard=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({to:t,type:"get",vcard:{format:"vcard-temp"}})).vcard})),e.publishVCard=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",vcard:t})})),e.enableNotifications=(t,n,i=[])=>e.sendIQ({push:{action:"enable",form:{fields:[{name:"FORM_TYPE",type:"hidden",value:"http://jabber.org/protocol/pubsub#publish-options"},...i],type:"submit"},jid:t,node:n},type:"set"}),e.disableNotifications=(t,n)=>e.sendIQ({push:{action:"disable",jid:t,node:n},type:"set"})}function yr(e){e.disco.addFeature(Nn(bn)),e.on("pubsub:published",t=>{if(t.pubsub.items.node!==bn)return;const n=t.pubsub.items.published[0].content;e.emit("avatar",{avatars:n.versions||[],jid:t.from,source:"pubsub"})}),e.on("presence",t=>{t.vcardAvatar&&"string"==typeof t.vcardAvatar&&e.emit("avatar",{avatars:[{id:t.vcardAvatar}],jid:t.from,source:"vcard"})}),e.publishAvatar=(t,n)=>e.publish("",vn,{data:n,itemType:vn},t),e.useAvatars=(t,n=[])=>e.publish("",bn,{itemType:bn,pointers:n,versions:t},"current"),e.getAvatar=(t,n)=>e.getItem(t,vn,n)}function _r(e){e.registerFeature("bind",300,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const i=yield e.sendIQ({bind:{resource:e.config.resource},type:"set"});e.features.negotiated.bind=!0,e.emit("session:prebind",i.bind.jid);const r=!t.legacySession||t.legacySession&&t.legacySession.optional;return!e.sessionStarted&&r&&e.emit("session:started",e.jid),n()}catch(e){return console.error(e),n("disconnect","JID binding failed")}}))),e.registerFeature("legacySession",1e3,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sessionStarted||t.legacySession&&t.legacySession.optional)return e.features.negotiated.session=!0,n();try{return yield e.sendIQ({legacySession:!0,type:"set"}),e.features.negotiated.session=!0,e.sessionStarted||(e.sessionStarted=!0,e.emit("session:started",e.jid)),n()}catch(e){return n("disconnect","Session requeset failed")}}))),e.on("session:started",()=>{e.sessionStarted=!0}),e.on("session:prebind",t=>{e.jid=t,e.emit("session:bound",e.jid)}),e.on("--reset-stream-features",()=>{e.sessionStarted=!1,e.features.negotiated.bind=!1,e.features.negotiated.session=!1})}function Sr(e){e.disco.addFeature(on),e.disco.addItem({name:"Ad-Hoc Commands",node:on}),e.getCommands=t=>e.getDiscoItems(t,on)}const wr=[];for(let e=0;e<256;++e)wr[e]=(e+256).toString(16).substr(1);function xr(e,t,n=(()=>{})){return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;const r=yield Promise.race([e,new Promise((e,r)=>{i=setTimeout(()=>r(n()),t)})]);return clearTimeout(i),r}))}function Tr(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return new Promise(t=>{setTimeout(()=>t(),e)})}))}function kr(t,n){const i="string"==typeof t?e.from(t,"utf8"):t,r="string"==typeof n?e.from(n,"utf8"):n;return i.compare(r)}function Ir(){const e=Yi(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=0;return[wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[15]]].join("")}const jr=new Set(["date","expires","httpUploadRetry","idleSince","published","since","stamp","timestamp","updated","utc"]),Er=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)(?:Z|((\+|-)([\d|:]*)))?$/;var Nr=Object.freeze({__proto__:null,timeoutPromise:xr,sleep:Tr,octetCompare:kr,uuid:Ir,reviveData:function(t,n){return jr.has(t)&&n&&"string"==typeof n&&Er.test(n)?new Date(n):n&&"object"==typeof n&&"Buffer"===n.type&&Array.isArray(n.data)?e.from(n):n}});function Cr(e,t){e.features.negotiated.clientStateIndication&&e.send("csi",{type:t})}function Rr(e){e.disco.addFeature("urn:xmpp:ping"),e.on("iq:get:ping",t=>{e.sendIQResult(t)}),e.on("--reset-stream-features",()=>{e._stopKeepAliveInterval(),e.features.negotiated.streamManagement=!1,e.features.negotiated.clientStateIndication=!1}),e.markActive=()=>Cr(e,"active"),e.markInactive=()=>Cr(e,"inactive"),e.ping=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({ping:!0,to:t,type:"get"})})),e.enableKeepAlive=(t={})=>{e._keepAliveOptions=t;const n=t.interval||300,i=t.timeout||e.config.timeout||15;clearInterval(e._keepAliveInterval),e._keepAliveInterval=setInterval((function(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sessionStarted)try{yield xr(function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sm.started)return new Promise(t=>{e.once("stream:management:ack",()=>t()),e.sm.request()});try{yield e.ping()}catch(e){if(e.error&&"timeout"!==e.error.condition)return;throw e}}))}(e),1e3*i)}catch(t){e.emit("stream:error",{condition:"connection-timeout",text:"Server did not respond in "+i+" seconds"}),e.transport&&(e.transport.hasStream=!1,e.transport.disconnect(!1))}}))}),1e3*n)},e._stopKeepAliveInterval=()=>{e._keepAliveInterval&&(clearInterval(e._keepAliveInterval),delete e._keepAliveInterval)},e.disableKeepAlive=()=>{delete e._keepAliveOptions,e._stopKeepAliveInterval()},e.on("stream:management:resumed",()=>{e._keepAliveOptions&&e.enableKeepAlive(e._keepAliveOptions)}),e.on("stream:start",()=>{e._keepAliveOptions&&e.enableKeepAlive(e._keepAliveOptions)});const t=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!e.config.useStreamManagement)return n();const t=i=>Object(r.__awaiter)(this,void 0,void 0,(function*(){switch(i.type){case"enabled":return yield e.sm.enabled(i),e.features.negotiated.streamManagement=!0,e.off("sm",t),n();case"resumed":return yield e.sm.resumed(i),e.features.negotiated.streamManagement=!0,e.features.negotiated.bind=!0,e.sessionStarted=!0,e.sessionStarting=!1,e.off("sm",t),e.emit("stream:management:resumed",i),n("break");case"failed":yield e.sm.failed(i),e.off("sm",t),e.emit("session:end"),n()}}));e.on("sm",t),e.sm.id?e.sm.id&&e.sm.allowResume?yield e.sm.resume():(e.off("sm",t),n()):e.features.negotiated.bind?yield e.sm.enable():(e.off("sm",t),n())}));e.registerFeature("streamManagement",200,t),e.registerFeature("streamManagement",500,t),e.registerFeature("clientStateIndication",400,(t,n)=>{e.features.negotiated.clientStateIndication=!0,n()})}function Or(t){return e.from(t.replace(/</g,"<"),"utf-8")}function Ar(e=[]){const t=[];for(const n of e)"FORM_TYPE"!==n.name&&(n.rawValues?t.push({name:Or(n.name),values:n.rawValues.map(e=>Or(e)).sort(kr)}):Array.isArray(n.value)?t.push({name:Or(n.name),values:n.value.map(e=>Or(e)).sort(kr)}):!0===n.value||!1===n.value?t.push({name:Or(n.name),values:[Or(n.value?"1":"0")]}):t.push({name:Or(n.name),values:[Or(n.value||"")]}));t.sort((e,t)=>kr(e.name,t.name));const n=[];for(const e of t){n.push(e.name);for(const t of e.values)n.push(t)}return n}function Pr(t,n){const i=[],r=e.from("<","utf8"),s=e=>{i.push(e),i.push(r)},o=function(e=[]){const t=[],n=new Set;for(const{category:i,type:r,lang:s,name:o}of e){const e=`${i}/${r}/${s||""}/${o||""}`;if(n.has(e))return null;n.add(e),t.push(Or(e))}return t.sort(kr),t}(t.identities),a=function(e=[]){const t=[],n=new Set;for(const i of e){if(n.has(i))return null;n.add(i),t.push(Or(i))}return t.sort(kr),t}(t.features),c=function(e=[]){const t=[],n=new Set;for(const i of e){let e;for(const t of i.fields||[])if("FORM_TYPE"===t.name&&"hidden"===t.type){if(t.rawValues&&1===t.rawValues.length){e=Or(t.rawValues[0]);break}if(t.value&&"string"==typeof t.value){e=Or(t.value);break}}if(e){if(n.has(e.toString()))return null;n.add(e.toString()),t.push({type:e,form:i})}}t.sort((e,t)=>kr(e.type,t.type));const i=[];for(const e of t){i.push(e.type);const t=Ar(e.form.fields);for(const e of t)i.push(e)}return i}(t.extensions);if(!o||!a||!c)return null;for(const e of o)s(e);for(const e of a)s(e);for(const e of c)s(e);return Wi(n).update(e.concat(i)).digest("base64")}class qr{constructor(){this.capsAlgorithms=["sha-1"],this.features=new Map,this.identities=new Map,this.extensions=new Map,this.items=new Map,this.caps=new Map,this.features.set("",new Set),this.identities.set("",[]),this.extensions.set("",[])}getNodeInfo(e){return{extensions:[...this.extensions.get(e)||[]],features:[...this.features.get(e)||[]],identities:[...this.identities.get(e)||[]]}}addFeature(e,t=""){this.features.has(t)||this.features.set(t,new Set),this.features.get(t).add(e)}addIdentity(e,t=""){this.identities.has(t)||this.identities.set(t,[]),this.identities.get(t).push(e)}addItem(e,t=""){this.items.has(t)||this.items.set(t,[]),this.items.get(t).push(e)}addExtension(e,t=""){this.extensions.has(t)||this.extensions.set(t,[]),this.extensions.get(t).push(e)}updateCaps(e,t=this.capsAlgorithms){const n={extensions:[...this.extensions.get("")],features:[...this.features.get("")],identities:[...this.identities.get("")],type:"info"};for(const i of t){const t=Pr(n,i);if(!t){this.caps.delete(i);continue}this.caps.set(i,{algorithm:i,node:e,value:t});const r=`${e}#${t}`;for(const e of n.features)this.addFeature(e,r);for(const e of n.identities)this.addIdentity(e,r);for(const e of n.extensions)this.addExtension(e,r);this.identities.set(r,n.identities),this.features.set(r,new Set(n.features)),this.extensions.set(r,n.extensions)}return[...this.caps.values()]}getCaps(){return[...this.caps.values()]}}function Lr(e){e.disco=new qr,e.disco.addFeature(Xt),e.disco.addFeature(Yt),e.disco.addIdentity({category:"client",type:"web"}),e.registerFeature("caps",100,(t,n)=>{const i=W(e.jid)||e.config.server;e.emit("disco:caps",{caps:t.legacyCapabilities||[],jid:i}),e.features.negotiated.caps=!0,n()}),e.getDiscoInfo=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield e.sendIQ({disco:{node:n,type:"info"},to:t,type:"get"});return Object.assign({extensions:[],features:[],identities:[]},i.disco)})),e.getDiscoItems=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield e.sendIQ({disco:{node:n,type:"items"},to:t,type:"get"});return Object.assign({items:[]},i.disco)})),e.updateCaps=()=>{const t=e.config.capsNode||"https://stanzajs.org";return e.disco.updateCaps(t)},e.getCurrentCaps=()=>{const t=e.disco.getCaps();if(!t)return;const n=`${t[0].node}#${t[0].value}`;return{info:e.disco.getNodeInfo(n),legacyCapabilities:t}},e.on("presence",t=>{t.legacyCapabilities&&e.emit("disco:caps",{caps:t.legacyCapabilities,jid:t.from})}),e.on("iq:get:disco",t=>{const{type:n,node:i}=t.disco;"info"===n&&e.sendIQResult(t,{disco:Object.assign(Object.assign({},e.disco.getNodeInfo(i||"")),{node:i,type:"info"})}),"items"===n&&e.sendIQResult(t,{disco:{items:e.disco.items.get(i||"")||[],type:"items"}})})}const Fr={Bosh:Tn,Client:Ut,Component:"jabber:component:accept",Server:"jabber:server"},Mr={AccountDisabled:"account-disabled",CredentialsExpired:"credentials-expired",EncryptionRequired:"encryption-required",IncorrectEncoding:"incorrect-encoding",InvalidAuthzid:"invalid-authzid",InvalidMechanism:"invalid-mechanism",MalformedRequest:"malformed-request",MechanismTooWeak:"mechanism-too-weak",NotAuthorized:"not-authorized",TemporaryAuthFailure:"temporary-auth-failure"},Dr={BadFormat:"bad-format",BadNamespacePrefix:"bad-namespace-prefix",Conflict:"conflict",ConnectionTimeout:"connection-timeout",HostGone:"host-gone",HostUnknown:"host-unknown",ImproperAddressing:"improper-addressing",InternalServerError:"internal-server-error",InvalidFrom:"invalid-from",InvalidId:"invalid-id",InvalidNamespace:"invalid-namespace",InvalidXML:"invalid-xml",NotAuthorized:"not-authorized",NotWellFormed:"not-well-formed",PolicyViolation:"policy-violation",RemoteConnectionFailed:"remote-connection-failed",Reset:"reset",ResourceConstraint:"resource-constraint",RestrictedXML:"restricted-xml",SeeOtherHost:"see-other-host",SystemShutdown:"system-shutdown",UndefinedCondition:"undefined-condition",UnsupportedEncoding:"unsupported-encoding",UnsupportedStanzaType:"unsupported-stanza-type",UnsupportedVersion:"unsupported-version"},Br={BadRequest:"bad-request",Conflict:"conflict",FeatureNotImplemented:"feature-not-implemented",Forbidden:"forbidden",Gone:"gone",InternalServerError:"internal-server-error",ItemNotFound:"item-not-found",JIDMalformed:"jid-malformed",NotAcceptable:"not-acceptable",NotAllowed:"not-allowed",NotAuthorized:"not-authorized",PolicyViolation:"policy-violation",RecipientUnavailable:"recipient-unavailable",Redirect:"redirect",RegistrationRequired:"registration-required",RemoteServerNotFound:"remote-server-not-found",RemoteServerTimeout:"remote-server-timeout",ResourceConstraint:"resource-constraint",ServiceUnavailable:"service-unavailable",SubscriptionRequired:"subscription-required",UndefinedCondition:"undefined-condition",UnexpectedRequest:"unexpected-request"},Ur={Available:void 0,Error:"error",Probe:"probe",Subscribe:"subscribe",Subscribed:"subscribed",Unavailable:"unavailable",Unsubscribe:"unsubscribe",Unsubscribed:"unsubscribed"},zr={Boolean:"boolean",Fixed:"fixed",Hidden:"hidden",JID:"jid-single",JIDMultiple:"jid-multi",List:"list-single",ListMultiple:"list-multi",Password:"text-private",Text:"text-single",TextMultiple:"text-multi",TextPrivate:"text-private"},Jr={AffiliationChanged:"101",AffiliationLost:"321",Banned:"301",Error:"333",Kicked:"307",LoggingDisabled:"171",LoggingEnabled:"170",MembershipLost:"322",NickChanged:"303",NickChangedByService:"210",NonAnonymous:"172",NonAnonymousRoom:"100",NonPrivacyConfigurationChange:"104",RoomCreated:"201",SelfPresence:"110",SemiAnonymous:"173",Shutdown:"332",UnavailableMembersListed:"102",UnavailableMembersNotListed:"103"},Gr={ClosedNode:"closed-node",ConfigurationRequired:"configuration-required",InvalidJID:"invalid-jid",InvalidOptions:"invalid-options",InvalidPayload:"invalid-payload",InvalidSubscriptionId:"invalid-subid",ItemForbidden:"item-forbidden",ItemRequired:"item-required",JIDRequired:"jid-required",MaxItemsExceeded:"max-items-exceeded",MaxNodesExceeded:"max-nodes-exceeded",NodeIdRequired:"nodeid-required",NotInRosterGroup:"not-in-roster-group",NotSubscribed:"not-subscribed",PayloadRequired:"payload-required",PayloadTooBig:"payload-too-big",PendingSubscription:"pending-subscription",PresenceSubscriptionRequired:"presence-subscription-required",SubscriptionIdRequired:"subid-required",TooManySubscriptions:"too-many-subscriptions",Unsupported:"unsupported",UnsupportedAccessModel:"unsupported-access-model"},Vr={Active:"active",Composing:"composing",Gone:"gone",Inactive:"inactive",Paused:"paused"},$r={Initiator:"initiator",Responder:"responder"},Hr={Inactive:"inactive",Receive:"recvonly",Send:"sendonly",SendReceive:"sendrecv"},Wr={Both:"both",Initiator:"initiator",None:"none",Responder:"responder"},Qr={ContentAccept:"content-accept",ContentAdd:"content-add",ContentModify:"content-modify",ContentReject:"content-reject",ContentRemove:"content-remove",DescriptionInfo:"description-info",SecurityInfo:"security-info",SessionAccept:"session-accept",SessionInfo:"session-info",SessionInitiate:"session-initiate",SessionTerminate:"session-terminate",TransportAccept:"transport-accept",TransportInfo:"transport-info",TransportReject:"transport-reject",TransportReplace:"transport-replace"},Kr={OutOfOrder:"out-of-order",TieBreak:"tie-break",UnknownContent:"unknown-content",UnknownSession:"unknown-session",UnsupportedInfo:"unsupported-info"},Xr={AlternativeSession:"alternative-session",Busy:"busy",Cancel:"cancel",ConnectivityError:"connectivity-error",Decline:"decline",Expired:"expired",FailedApplication:"failed-application",FailedTransport:"failed-transport",GeneralError:"general-error",Gone:"gone",IncompatibleParameters:"incompatible-parameters",MediaError:"media-error",SecurityError:"security-error",Success:"success",Timeout:"timeout",UnsupportedApplications:"unsupported-applications",UnsupportedTransports:"unsupported-transports"},Yr=["afraid","amazed","amorous","angry","annoyed","anxious","aroused","ashamed","bored","brave","calm","cautious","cold","confident","confused","contemplative","contented","cranky","crazy","creative","curious","dejected","depressed","disappointed","disgusted","dismayed","distracted","embarrassed","envious","excited","flirtatious","frustrated","grateful","grieving","grumpy","guilty","happy","hopeful","hot","humbled","humiliated","hungry","hurt","impressed","in_awe","in_love","indignant","interested","intoxicated","invincible","jealous","lonely","lost","lucky","mean","moody","nervous","neutral","offended","outraged","playful","proud","relaxed","relieved","remorseful","restless","sad","sarcastic","satisfied","serious","shocked","shy","sick","sleepy","spontaneous","stressed","strong","surprised","thankful","thirsty","tired","undefined","weak","worried"],Zr=["doing_chores","drinking","eating","exercising","grooming","having_appointment","inactive","relaxing","talking","traveling","undefined","working"],es=["at_the_spa","brushing_teeth","buying_groceries","cleaning","coding","commuting","cooking","cycling","cycling","dancing","day_off","doing_maintenance","doing_the_dishes","doing_the_laundry","driving","fishing","gaming","gardening","getting_a_haircut","going_out","hanging_out","having_a_beer","having_a_snack","having_breakfast","having_coffee","having_dinner","having_lunch","having_tea","hiding","hiking","in_a_car","in_a_meeting","in_real_life","jogging","on_a_bus","on_a_plane","on_a_train","on_a_trip","on_the_phone","on_vacation","on_video_phone","other","partying","playing_sports","praying","reading","rehearsing","running","running_an_errand","scheduled_holiday","shaving","shopping","skiing","sleeping","smoking","socializing","studying","sunbathing","swimming","taking_a_bath","taking_a_shower","thinking","walking","walking_the_dog","watching_a_movie","watching_tv","working_out","writing"],ts=(e,t)=>`{${e}}${t}`,ns=ts(On,"mute"),is=ts(On,"unmute"),rs=ts(On,"hold"),ss=ts(On,"unhold"),os=ts(On,"active"),as=ts(On,"ringing"),cs=ts(Dn,"checksum"),ls=ts(Dn,"received");function us(e,t=Wr.Both){const n=e===$r.Initiator;switch(t){case Wr.Initiator:return n?Hr.Send:Hr.Receive;case Wr.Responder:return n?Hr.Receive:Hr.Send;case Wr.Both:return Hr.SendReceive}return Hr.Inactive}function ps(e,t=Hr.SendReceive){const n=e===$r.Initiator;switch(t){case Hr.Send:return n?Wr.Initiator:Wr.Responder;case Hr.Receive:return n?Wr.Responder:Wr.Initiator;case Hr.SendReceive:return Wr.Both}return Wr.None}var ds=Object.freeze({__proto__:null,VERSION:"12.17.2",StreamType:Fr,SASLFailureCondition:Mr,StreamErrorCondition:Dr,StanzaErrorCondition:Br,MessageType:{Chat:"chat",Error:"error",GroupChat:"groupchat",Headline:"headline",Normal:"normal"},PresenceType:Ur,IQType:{Error:"error",Get:"get",Result:"result",Set:"set"},PresenceShow:{Away:"away",Chat:"chat",DoNotDisturb:"dnd",ExtendedAway:"xa"},RosterSubscription:{Both:"both",From:"from",None:"none",ReceivePresenceOnly:"to",Remove:"remove",SendAndReceivePresence:"both",SendPresenceOnly:"from",To:"to"},DataFormType:{Cancel:"cancel",Form:"form",Result:"result",Submit:"submit"},DataFormFieldType:zr,MUCAffiliation:{Admin:"admin",Banned:"outcast",Member:"member",None:"none",Outcast:"outcast",Owner:"owner"},MUCRole:{Moderator:"moderator",None:"none",Participant:"participant",Visitor:"visitor"},MUCStatusCode:Jr,PubsubErrorCondition:Gr,ChatState:Vr,JingleSessionRole:$r,JingleApplicationDirection:Hr,JingleContentSenders:Wr,JingleAction:Qr,JingleErrorCondition:Kr,JingleReasonCondition:Xr,USER_MOODS:Yr,USER_ACTIVITY_GENERAL:Zr,USER_ACTIVITY_SPECIFIC:es,JINGLE_INFO:ts,JINGLE_INFO_MUTE:ns,JINGLE_INFO_UNMUTE:is,JINGLE_INFO_HOLD:rs,JINGLE_INFO_UNHOLD:ss,JINGLE_INFO_ACTIVE:os,JINGLE_INFO_RINGING:as,JINGLE_INFO_CHECKSUM_5:cs,JINGLE_INFO_RECEIVED_5:ls,sendersToDirection:us,directionToSenders:ps});function hs(e){e.disco.addFeature("jid\\20escaping"),e.disco.addFeature(Fn),e.disco.addFeature("urn:xmpp:eme:0"),e.disco.addFeature($n),e.disco.addFeature(Hn),e.disco.addFeature("urn:xmpp:hashes:1"),e.disco.addFeature("urn:xmpp:idle:1"),e.disco.addFeature(Zn),e.disco.addFeature(hn),e.disco.addFeature("urn:xmpp:psa"),e.disco.addFeature("urn:xmpp:reference:0"),e.disco.addFeature(kn),e.disco.addFeature(Qt),e.disco.addFeature("urn:xmpp:media-element"),e.disco.addFeature(xn),e.disco.addFeature(jn);const t=["sha-1","sha-256","sha-512","md5"];for(const n of t)e.disco.addFeature(Wn(n));e.disco.addFeature("urn:xmpp:time"),e.disco.addFeature("jabber:iq:version"),e.on("iq:get:softwareVersion",t=>e.sendIQResult(t,{softwareVersion:e.config.softwareVersion||{name:"stanzajs.org",version:"12.17.2"}})),e.on("iq:get:time",t=>{const n=new Date;e.sendIQResult(t,{time:{tzo:n.getTimezoneOffset(),utc:n}})}),e.getSoftwareVersion=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({softwareVersion:{},to:t,type:"get"})).softwareVersion})),e.getTime=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({time:{},to:t,type:"get"})).time})),e.getLastActivity=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({lastActivity:{},to:t,type:"get"})).lastActivity}))}function fs(e){e.features={handlers:Object.create(null),negotiated:Object.create(null),order:[]},e.registerFeature=function(t,n,i){this.features.order.push({name:t,priority:n}),this.features.order.sort((e,t)=>e.priority-t.priority),this.features.handlers[t]=i.bind(e)},e.on("features",t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=e.features.negotiated,i=e.features.handlers,r=[];for(const{name:s}of e.features.order)t[s]&&i[s]&&!n[s]&&r.push(s);function s(e){return new Promise(n=>{i[e](t,(e,t)=>{n(e?{command:e,message:t}:null)})})}for(const t of r){if(n[t])continue;let i="",r="";try{const e=yield s(t);e&&(i=e.command,r=e.message||"")}catch(e){i="disconnect",r=e.message,console.error(e)}if(i)return"restart"===i&&e.transport&&e.transport.restart(),void("disconnect"===i&&(e.emit("stream:error",{condition:"policy-violation",text:"Failed to negotiate stream features: "+r}),e.disconnect()))}})))}function ms(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){"string"==typeof t&&(t={host:t});const n=Object.assign({json:!0,ssl:!0,xrd:!0},t),i=n.ssl?"https://":"http://";return function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const t=yield Promise.all(e.map(e=>e.then(e=>Promise.reject(e),e=>Promise.resolve(e))));return Promise.reject(t)}catch(e){return Promise.resolve(e)}}))}([Zi(`${i}${n.host}/.well-known/host-meta.json`).then(e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!e.ok)throw new Error("could-not-fetch-json");return e.json()}))),Zi(`${i}${n.host}/.well-known/host-meta`).then(t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!t.ok)throw new Error("could-not-fetch-xml");const n=Ie(yield t.text());if(n)return e.import(n)})))])}))}function gs(e,t){e.discoverBindings=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=yield ms(t,e),i={bosh:[],websocket:[]},r=n.links||[];for(const e of r)e.href&&"urn:xmpp:alt-connections:websocket"===e.rel&&i.websocket.push(e.href),e.href&&"urn:xmpp:alt-connections:xbosh"===e.rel&&i.bosh.push(e.href);return i}catch(e){return{}}}))}function vs(e){const t=u.getMediaSections(e),n=u.getDescription(e),i={groups:[],media:[]};u.matchPrefix(n,"a=ice-lite").length>0&&(i.iceLite=!0);for(const e of u.matchPrefix(n,"a=group:")){const t=e.split(" "),n=t.shift().substr(8);i.groups.push({mids:t,semantics:n})}for(const e of t){const t=u.getKind(e),r=u.isRejected(e),s=u.parseMLine(e),o={direction:u.getDirection(e,n),kind:t,mid:u.getMid(e),protocol:s.protocol};if(r||(o.iceParameters=u.getIceParameters(e,n),o.dtlsParameters=u.getDtlsParameters(e,n),o.setup=u.matchPrefix(e,"a=setup:")[0].substr(8),i.iceLite&&(o.iceParameters.iceLite=!0)),"audio"===t||"video"===t){o.rtpParameters=u.parseRtpParameters(e),o.rtpEncodingParameters=u.parseRtpEncodingParameters(e),o.rtcpParameters=u.parseRtcpParameters(e);const t=u.parseMsid(e);o.streams=t?[t]:[]}else"application"===t&&(o.sctp=u.parseSctpDescription(e));o.candidates=u.matchPrefix(e,"a=candidate:").map(u.parseCandidate),i.media.push(o)}return i}function bs(e){const t=[];t.push(u.writeSessionBoilerplate(e.sessionId,e.sessionVersion),"a=msid-semantic:WMS *\r\n"),(e.iceLite||e.media.filter(e=>e.iceParameters&&e.iceParameters.iceLite).length>0)&&t.push("a=ice-lite\r\n");for(const n of e.groups||[])t.push(`a=group:${n.semantics} ${n.mids.join(" ")}\r\n`);for(const n of e.media||[]){const e=!(n.iceParameters&&n.dtlsParameters);if("application"===n.kind&&n.sctp)t.push(u.writeSctpDescription(n,n.sctp));else if(n.rtpParameters){let i=u.writeRtpDescription(n.kind,n.rtpParameters);e&&(i=i.replace(`m=${n.kind} 9 `,`m=${n.kind} 0 `)),t.push(i),t.push(`a=${n.direction||"sendrecv"}\r\n`);for(const e of n.streams||[])t.push(`a=msid:${e.stream} ${e.track}\r\n`);if(n.rtcpParameters&&(t.push(u.writeRtcpParameters(n.rtcpParameters)),n.rtcpParameters.cname&&n.rtpEncodingParameters&&n.rtpEncodingParameters[0].rtx)){const e=n.rtpEncodingParameters[0];t.push(`a=ssrc-group:FID ${e.ssrc} ${e.rtx.ssrc}\r\n`),t.push(`a=ssrc:${e.rtx.ssrc} cname:${n.rtcpParameters.cname}\r\n`)}}if(void 0!==n.mid&&t.push(`a=mid:${n.mid}\r\n`),n.iceParameters&&t.push(u.writeIceParameters({usernameFragment:n.iceParameters.usernameFragment,password:n.iceParameters.password})),n.dtlsParameters&&n.setup&&t.push(u.writeDtlsParameters(n.dtlsParameters,n.setup)),n.candidates&&n.candidates.length)for(const e of n.candidates)t.push(`a=${u.writeCandidate(e)}\r\n`)}return t.join("")}function ys(e,t){const n=e.rtpParameters,i=e.rtcpParameters||{},r=e.rtpEncodingParameters||[];let s=!1;r&&r.length&&(s=!!r[0].ssrc);const o={applicationType:Rn,codecs:[],headerExtensions:[],media:e.kind,rtcpMux:i.mux,rtcpReducedSize:i.reducedSize,sourceGroups:[],sources:[],ssrc:s?r[0].ssrc.toString():void 0,streams:[]};for(const e of n.headerExtensions||[]){const n={id:e.id,uri:e.uri};e.direction&&"sendrecv"!==e.direction&&(n.senders=ps(t,e.direction)),o.headerExtensions.push(n)}i.ssrc&&i.cname&&(o.sources=[{parameters:{cname:i.cname},ssrc:i.ssrc.toString()}]),s&&r[0]&&r[0].rtx&&(o.sourceGroups=[{semantics:"FID",sources:[r[0].ssrc.toString(),r[0].rtx.ssrc.toString()]}]);for(const t of e.streams||[])o.streams.push({id:t.stream,track:t.track});for(const e of n.codecs||[]){const t={channels:e.channels,clockRate:e.clockRate,id:e.payloadType.toString(),name:e.name,parameters:e.parameters,rtcpFeedback:e.rtcpFeedback};e.maxptime&&(t.maxptime=e.maxptime),e.parameters&&e.parameters.ptime&&(t.ptime=parseInt(e.parameters.ptime,10)),o.codecs.push(t)}return o}function _s(e){let t;return t="rtp"===e.component?1:"rtcp"===e.component?2:e.component,{component:t,foundation:e.foundation,generation:void 0,id:void 0,ip:e.ip,network:void 0,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function Ss(e){return{address:e.ip,component:1===e.component?"rtp":2===e.component?"rtcp":e.component,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function ws(e,t){const n=e.iceParameters,i=e.dtlsParameters,r={candidates:[],transportType:t};n&&(r.usernameFragment=n.usernameFragment,r.password=n.password,n.iceLite&&(r.iceLite=!0)),i&&(r.fingerprints=i.fingerprints.map(t=>({algorithm:t.algorithm,setup:e.setup,value:t.value}))),e.sctp&&(r.sctp=e.sctp);for(const t of e.candidates||[])r.candidates.push(_s(t));return r}function xs(e,t,n){return{contents:e.media.map(e=>({application:"audio"===e.kind||"video"===e.kind?ys(e,t):{applicationType:"datachannel",protocol:e.protocol},creator:$r.Initiator,name:e.mid,senders:ps(t,e.direction),transport:ws(e,n)})),groups:e.groups?e.groups.map(e=>({contents:e.mids,semantics:e.semantics})):[]}}function Ts(e,t){const n=e.application||{},i=e.transport,r=n&&n.applicationType===Rn,s={direction:us(t,e.senders),kind:n.media||"application",mid:e.name,protocol:r?"UDP/TLS/RTP/SAVPF":"UDP/DTLS/SCTP"};if(r){if(s.rtcpParameters={compound:!n.rtcpReducedSize,mux:n.rtcpMux,reducedSize:n.rtcpReducedSize},n.sources&&n.sources.length){const e=n.sources[0];s.rtcpParameters.ssrc=parseInt(e.ssrc,10),e.parameters&&(s.rtcpParameters.cname=e.parameters.cname)}if(s.rtpParameters={codecs:[],fecMechanisms:[],headerExtensions:[],rtcp:[]},n.streams){s.streams=[];for(const e of n.streams)s.streams.push({stream:e.id,track:e.track})}if(n.ssrc&&(s.rtpEncodingParameters=[{ssrc:parseInt(n.ssrc,10)}],n.sourceGroups&&n.sourceGroups.length)){const e=n.sourceGroups[0];s.rtpEncodingParameters[0].rtx={ssrc:parseInt(e.sources[1],10)}}let e=!1,i=!1;for(const t of n.codecs||[]){const n=t.parameters||{},r=[];for(const e of t.rtcpFeedback||[])r.push({parameter:e.parameter,type:e.type});if("red"===t.name||"ulpfec"===t.name){e=e||"red"===t.name,i=i||"ulpfec"===t.name;const n=t.name.toUpperCase();s.rtpParameters.fecMechanisms.includes(n)||s.rtpParameters.fecMechanisms.push(n)}s.rtpParameters.codecs.push({channels:t.channels,clockRate:t.clockRate,name:t.name,numChannels:t.channels,parameters:n,payloadType:parseInt(t.id,10),rtcpFeedback:r})}for(const e of n.headerExtensions||[])s.rtpParameters.headerExtensions.push({direction:us(t,e.senders||"both"),id:e.id,uri:e.uri})}if(i){if(i.usernameFragment&&i.password&&(s.iceParameters={password:i.password,usernameFragment:i.usernameFragment},i.iceLite&&(s.iceParameters.iceLite=!0)),i.fingerprints&&i.fingerprints.length){s.dtlsParameters={fingerprints:[],role:"auto"};for(const e of i.fingerprints)s.dtlsParameters.fingerprints.push({algorithm:e.algorithm,value:e.value});i.sctp&&(s.sctp=i.sctp),s.setup=i.fingerprints[0].setup}s.candidates=(i.candidates||[]).map(Ss)}return s}function ks(e,t){const n={groups:[],media:[]};for(const t of e.groups||[])n.groups.push({mids:t.contents,semantics:t.semantics});for(const i of e.contents||[])n.media.push(Ts(i,t));return n}const Is={condition:Br.BadRequest},js={condition:Br.FeatureNotImplemented,jingleError:Kr.UnsupportedInfo,type:"modify"};class Es{constructor(e){this.parent=e.parent,this.sid=e.sid||Ir(),this.peerID=e.peerID,this.role=e.initiator?$r.Initiator:$r.Responder,this._sessionState="starting",this._connectionState="starting",this.pendingApplicationTypes=e.applicationTypes||[],this.pendingAction=void 0,this.processingQueue=Object(s.priorityQueue)((e,t)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if("ended"===this.state)return"local"===e.type&&e.reject&&e.reject(new Error("Session ended")),void(t&&t());if("local"===e.type){this._log("debug","Processing local action:",e.name);try{const t=yield e.handler();e.resolve(t)}catch(t){e.reject(t)}return void(t&&t())}const{action:n,changes:i,cb:r}=e;return this._log("debug","Processing remote action:",n),new Promise(e=>{const s=(n,i)=>{r(n,i),t&&t(),e()};switch(n){case Qr.ContentAccept:return this.onContentAccept(i,s);case Qr.ContentAdd:return this.onContentAdd(i,s);case Qr.ContentModify:return this.onContentModify(i,s);case Qr.ContentReject:return this.onContentReject(i,s);case Qr.ContentRemove:return this.onContentRemove(i,s);case Qr.DescriptionInfo:return this.onDescriptionInfo(i,s);case Qr.SecurityInfo:return this.onSecurityInfo(i,s);case Qr.SessionAccept:return this.onSessionAccept(i,s);case Qr.SessionInfo:return this.onSessionInfo(i,s);case Qr.SessionInitiate:return this.onSessionInitiate(i,s);case Qr.SessionTerminate:return this.onSessionTerminate(i,s);case Qr.TransportAccept:return this.onTransportAccept(i,s);case Qr.TransportInfo:return this.onTransportInfo(i,s);case Qr.TransportReject:return this.onTransportReject(i,s);case Qr.TransportReplace:return this.onTransportReplace(i,s);default:this._log("error","Invalid or unsupported action: "+n),s({condition:Br.BadRequest})}})})),1)}get isInitiator(){return this.role===$r.Initiator}get peerRole(){return this.isInitiator?$r.Responder:$r.Initiator}get state(){return this._sessionState}set state(e){e!==this._sessionState&&(this._log("info","Changing session state to: "+e),this._sessionState=e,this.parent&&this.parent.emit("sessionState",this,e))}get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._log("info","Changing connection state to: "+e),this._connectionState=e,this.parent&&this.parent.emit("connectionState",this,e))}send(e,t){(t=t||{}).sid=this.sid,t.action=e;new Set([Qr.ContentAccept,Qr.ContentAdd,Qr.ContentModify,Qr.ContentReject,Qr.ContentRemove,Qr.SessionAccept,Qr.SessionInitiate,Qr.TransportAccept,Qr.TransportReject,Qr.TransportReplace]).has(e)?this.pendingAction=e:this.pendingAction=void 0,this.parent.signal(this,{id:Ir(),jingle:t,to:this.peerID,type:"set"})}processLocal(e,t){return new Promise((n,i)=>{this.processingQueue.push({handler:t,name:e,reject:i,resolve:n,type:"local"},1)})}process(e,t,n){this.processingQueue.push({action:e,cb:n,changes:t,type:"remote"},2)}start(e,t){this._log("error","Can not start base sessions"),this.end("unsupported-applications",!0)}accept(e,t){this._log("error","Can not accept base sessions"),this.end("unsupported-applications")}cancel(){this.end("cancel")}decline(){this.end("decline")}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}_log(e,t,...n){this.parent&&(t=this.sid+": "+t,this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n))}onSessionInitiate(e,t){t()}onSessionAccept(e,t){t()}onSessionTerminate(e,t){this.end(e.reason,!0),t()}onSessionInfo(e,t){e.info?t(js):t()}onSecurityInfo(e,t){t(js)}onDescriptionInfo(e,t){t(js)}onTransportInfo(e,t){t(js)}onContentAdd(e,t){t(),this.send(Qr.ContentReject,{reason:{condition:Xr.FailedApplication,text:"content-add is not supported"}})}onContentAccept(e,t){t(Is)}onContentReject(e,t){t(Is)}onContentModify(e,t){t(Is)}onContentRemove(e,t){t(Is)}onTransportReplace(e,t){t(),this.send(Qr.TransportReject,{reason:{condition:Xr.FailedTransport,text:"transport-replace is not supported"}})}onTransportAccept(e,t){t(Is)}onTransportReject(e,t){t(Is)}}class Ns extends Es{constructor(e){super(e),this.bitrateLimit=0,this.candidateBuffer=[],this.transportType=Pn,this.restartingIce=!1,this.usingRelay=!1,this.maxRelayBandwidth=e.maxRelayBandwidth,this.pc=this.parent.createPeerConnection(this,Object.assign(Object.assign({},e.config),{iceServers:e.iceServers})),this.pc.oniceconnectionstatechange=()=>{this.onIceStateChange()},this.pc.onicecandidate=e=>{e.candidate?this.onIceCandidate(e):this.onIceEndOfCandidates()},this.restrictRelayBandwidth()}end(e="success",t=!1){this.pc.close(),super.end(e,t)}restartIce(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isInitiator){void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this.restartingIce=!0;try{yield this.processLocal("restart-ice",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=yield this.pc.createOffer({iceRestart:!0}),t=vs(e.sdp);this.send(Qr.TransportInfo,{contents:t.media.map(e=>({creator:$r.Initiator,name:e.mid,transport:ws(e,this.transportType)})),sid:this.sid}),yield this.pc.setLocalDescription(e)})))}catch(e){this._log("error","Could not create WebRTC offer",e),this.end(Xr.FailedTransport,!0)}}}))}setMaximumBitrate(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.maximumBitrate&&(e=Math.min(e,this.maximumBitrate)),this.currentBitrate=e;const t=this.pc.getSenders().find(e=>!!e.track&&"video"===e.track.kind);if(t&&t.getParameters)try{yield this.processLocal("set-bitrate",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=t.getParameters();n.encodings&&n.encodings.length||(n.encodings=[{}]),0===e?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=e,yield t.setParameters(n)})))}catch(e){this._log("error","Set maximumBitrate failed",e)}}))}onTransportInfo(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.contents&&e.contents[0]&&e.contents[0].transport.gatheringComplete){const n={sdpMid:e.contents[0].name,candidate:""};try{"stable"===this.pc.signalingState?yield this.pc.addIceCandidate(n):this.candidateBuffer.push(n)}catch(e){this._log("debug","Could not add null end-of-candidate")}finally{t()}return}if(this.pc.remoteDescription){const n=this.pc.remoteDescription,i=vs(n.sdp),r=i.media.find(t=>t.mid===e.contents[0].name).iceParameters.usernameFragment,s=e.contents[0].transport.usernameFragment;if(s&&r!==s){for(const[t,n]of e.contents.entries()){const e=n.transport;i.media[t].iceParameters={password:e.password,usernameFragment:e.usernameFragment},i.media[t].candidates=[]}try{if(yield this.pc.setRemoteDescription({type:n.type,sdp:bs(i)}),yield this.processBufferedCandidates(),"offer"===n.type){const e=yield this.pc.createAnswer();yield this.pc.setLocalDescription(e);const t=vs(e.sdp);this.send(Qr.TransportInfo,{contents:t.media.map(e=>({creator:$r.Initiator,name:e.mid,transport:ws(e,this.transportType)})),sid:this.sid})}else this.restartingIce=!1}catch(e){return this._log("error","Could not do remote ICE restart",e),t(e),void this.end(Xr.FailedTransport)}}}const n=(e.contents||[]).map(e=>{const t=e.name,n=(e.transport.candidates||[]).map(e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=u.writeCandidate(Ss(e));if(this.pc.remoteDescription&&"stable"===this.pc.signalingState)try{yield this.pc.addIceCandidate({sdpMid:t,candidate:n})}catch(e){this._log("error","Could not add ICE candidate",e)}else this.candidateBuffer.push({sdpMid:t,candidate:n})})));return Promise.all(n)});try{yield Promise.all(n),t()}catch(e){this._log("error","Could not process transport-info: "+e),t(e)}}))}onSessionAccept(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.state="active";const n=bs(ks(e,this.peerRole));try{yield this.pc.setRemoteDescription({type:"answer",sdp:n}),yield this.processBufferedCandidates(),this.parent.emit("accepted",this,void 0),t()}catch(e){this._log("error","Could not process WebRTC answer: "+e),t({condition:"general-error"})}}))}onSessionTerminate(e,t){this._log("info","Terminating session"),this.pc.close(),super.end(e.reason,!0),t()}onIceCandidate(e){if(!e.candidate||!e.candidate.candidate)return;const t=u.parseCandidate(e.candidate.candidate),n={contents:[{creator:$r.Initiator,name:e.candidate.sdpMid,transport:{candidates:[_s(t)],transportType:this.transportType,usernameFragment:t.usernameFragment}}]};this._log("info","Discovered new ICE candidate",n),this.send(Qr.TransportInfo,n)}onIceEndOfCandidates(){this._log("info","ICE end of candidates");const e=vs(this.pc.localDescription.sdp).media[0];this.send(Qr.TransportInfo,{contents:[{creator:$r.Initiator,name:e.mid,transport:{gatheringComplete:!0,transportType:this.transportType,usernameFragment:e.iceParameters.usernameFragment}}]})}onIceStateChange(){switch(this.pc.iceConnectionState){case"checking":this.connectionState="connecting";break;case"completed":case"connected":this.connectionState="connected";break;case"disconnected":if("stable"===this.pc.signalingState?this.connectionState="interrupted":this.connectionState="disconnected",this.restartingIce)return void this.end(Xr.FailedTransport);this.maybeRestartIce();break;case"failed":if("failed"===this.connectionState||this.restartingIce)return void this.end(Xr.FailedTransport);this.connectionState="failed",this.restartIce();break;case"closed":this.connectionState="disconnected",this.restartingIce?this.end(Xr.FailedTransport):this.end()}}processBufferedCandidates(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){for(const e of this.candidateBuffer)try{yield this.pc.addIceCandidate(e)}catch(e){this._log("error","Could not add ICE candidate",e)}this.candidateBuffer=[]}))}restrictRelayBandwidth(){this.pc.addEventListener("iceconnectionstatechange",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if("completed"!==this.pc.iceConnectionState&&"connected"!==this.pc.iceConnectionState)return;const e=yield this.pc.getStats();let t;if(e.forEach(n=>{"transport"===n.type&&(t=e.get(n.selectedCandidatePairId))}),t||e.forEach(e=>{"candidate-pair"===e.type&&e.selected&&(t=e)}),!t)return;let n=!1,i="",r="";if(t.remoteCandidateId){const n=e.get(t.remoteCandidateId);n&&(r=n.candidateType)}if(t.localCandidateId){const n=e.get(t.localCandidateId);n&&(i=n.candidateType)}"relay"!==i&&"relay"!==r||(n=!0),this.usingRelay=n,this.parent.emit("iceConnectionType",this,{localCandidateType:i,relayed:n,remoteCandidateType:r}),n&&void 0!==this.maxRelayBandwidth&&(this.maximumBitrate=this.maxRelayBandwidth,this.currentBitrate?this.setMaximumBitrate(Math.min(this.currentBitrate,this.maximumBitrate)):this.setMaximumBitrate(this.maximumBitrate))})))}maybeRestartIce(){this.isInitiator&&(void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this._maybeRestartingIce=setTimeout(()=>{this._maybeRestartingIce=void 0,"disconnected"===this.pc.iceConnectionState&&this.restartIce()},2e3))}}class Cs extends o.EventEmitter{constructor(e={}){super(),this.config=Object.assign({chunkSize:16384,hash:"sha-1"},e),this.file=void 0,this.channel=void 0,this.hash=Wi(this.config.hash)}send(e,t){if(this.file&&this.channel)return;this.file=e,this.channel=t,this.channel.binaryType="arraybuffer";const n=new FileReader;let i=0,r=!1;const s=()=>{if(r||i>=e.size)return;r=!0;const t=e.slice(i,i+this.config.chunkSize);n.readAsArrayBuffer(t)};t.bufferedAmountLowThreshold=8*this.config.chunkSize,t.onbufferedamountlow=()=>{s()},n.addEventListener("load",t=>{const n=t.target.result;r=!1,i+=n.byteLength,this.channel.send(n),this.hash.update(new Uint8Array(n)),this.emit("progress",i,e.size,n),i<e.size?this.channel.bufferedAmount<=this.channel.bufferedAmountLowThreshold&&s():(this.emit("progress",e.size,e.size,null),this.emit("sentFile",{algorithm:this.config.hash,name:e.name,size:e.size,value:this.hash.digest()}))}),s()}}class Rs extends o.EventEmitter{constructor(e={}){super(),this.config=Object.assign({hash:"sha-1"},e),this.receiveBuffer=[],this.received=0,this.channel=void 0,this.hash=Wi(this.config.hash)}receive(e,t){this.metadata=e,this.channel=t,this.channel.binaryType="arraybuffer",this.channel.onmessage=e=>{const t=e.data.byteLength;this.received+=t,this.receiveBuffer.push(e.data),e.data&&this.hash.update(new Uint8Array(e.data)),this.emit("progress",this.received,this.metadata.size,e.data),this.received===this.metadata.size?(this.metadata.actualhash=this.hash.digest("hex"),this.emit("receivedFile",new Blob(this.receiveBuffer),this.metadata),this.receiveBuffer=[]):this.received>this.metadata.size&&(console.error("received more than expected, discarding..."),this.receiveBuffer=[])}}}class Os extends Ns{constructor(e){super(e),this.sender=void 0,this.receiver=void 0,this.file=void 0}start(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(t=t||(()=>{}),!e||"function"==typeof e)throw new Error("File object required");this.state="pending",this.role="initiator",this.file=e,this.sender=new Cs,this.sender.on("progress",(e,t)=>{this._log("info","Send progress "+e+"/"+t)}),this.sender.on("sentFile",e=>{this._log("info","Sent file",e.name),this.send(Qr.SessionInfo,{info:{creator:$r.Initiator,file:{hashes:[{algorithm:e.algorithm,value:e.value}]},infoType:cs,name:this.contentName}}),this.parent.emit("sentFile",this,e)}),this.channel=this.pc.createDataChannel("filetransfer",{ordered:!0}),this.channel.onopen=()=>{this.sender.send(this.file,this.channel)};try{yield this.processLocal(Qr.SessionInitiate,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1}),n=xs(vs(t.sdp),this.role,this.transportType);this.contentName=n.contents[0].name,n.sid=this.sid,n.action=Qr.SessionInitiate,n.contents[0].application={applicationType:Dn,file:{date:e.lastModified?new Date(e.lastModified):void 0,hashesUsed:[{algorithm:"sha-1"}],name:e.name,size:e.size}},this.send("session-initiate",n),yield this.pc.setLocalDescription(t)}))),t()}catch(e){return this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}))}accept(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Accepted incoming session"),this.role="responder",this.state="active",e=e||(()=>{});try{yield this.processLocal(Qr.SessionAccept,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=yield this.pc.createAnswer(),t=xs(vs(e.sdp),this.role,this.transportType);t.sid=this.sid,t.action="session-accept";for(const e of t.contents)e.creator="initiator";this.contentName=t.contents[0].name,this.send("session-accept",t),yield this.pc.setLocalDescription(e),yield this.processBufferedCandidates()}))),e()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}))}onSessionInitiate(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Initiating incoming session"),this.role="responder",this.state="pending",this.transportType=e.contents[0].transport.transportType;const n=bs(ks(e,this.peerRole)),i=e.contents[0].application,r=i.file.hashesUsed?i.file.hashesUsed:i.file.hashes||[];this.receiver=new Rs({hash:r[0]&&r[0].algorithm}),this.receiver.on("progress",(e,t)=>{this._log("info","Receive progress "+e+"/"+t)}),this.receiver.on("receivedFile",e=>{this.receivedFile=e,this._maybeReceivedFile()}),this.receiver.metadata=i.file,this.pc.addEventListener("datachannel",e=>{this.channel=e.channel,this.receiver.receive(this.receiver.metadata,e.channel)});try{yield this.pc.setRemoteDescription({type:"offer",sdp:n}),yield this.processBufferedCandidates(),t()}catch(e){this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}))}onSessionInfo(e,t){const n=e.info;n&&n.file&&n.file.hashes&&(this.receiver.metadata.hashes=n.file.hashes,this.receiver.metadata.actualhash&&this._maybeReceivedFile(),t())}_maybeReceivedFile(){if(this.receiver.metadata.hashes&&this.receiver.metadata.hashes.length){for(const e of this.receiver.metadata.hashes||[])if(e.value&&e.value.toString("hex")===this.receiver.metadata.actualhash)return this._log("info","File hash matches"),this.parent.emit("receivedFile",this,this.receivedFile,this.receiver.metadata),void this.end("success");this._log("error","File hash does not match"),this.end("media-error")}}}function As(e){const t=e.application;if(t.streams&&t.streams.length&&t.sources&&t.sources.length){const e=t.streams[0];t.sources[0].parameters.msid=`${e.id} ${e.track}`,t.sourceGroups&&t.sourceGroups.length>0&&t.sources.push({parameters:{cname:t.sources[0].parameters.cname,msid:`${e.id} ${e.track}`},ssrc:t.sourceGroups[0].sources[1]})}}class Ps extends Ns{constructor(e){if(super(e),this.includesAudio=!1,this.includesVideo=!1,this._ringing=!1,this.pc.addEventListener("track",e=>{this.onAddTrack(e.track,e.streams[0])}),e.stream)for(const t of e.stream.getTracks())this.addTrack(t,e.stream)}get ringing(){return this._ringing}set ringing(e){e!==this._ringing&&(this._ringing=e)}get streams(){return"closed"!==this.pc.signalingState?this.pc.getRemoteStreams():[]}start(e,t){return Object(r.__awaiter)(this,arguments,void 0,(function*(){this.state="pending",1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this.role="initiator",this.offerOptions=e;try{yield this.processLocal(Qr.SessionInitiate,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createOffer(e),n=xs(vs(t.sdp),this.role,this.transportType);n.sid=this.sid,n.action=Qr.SessionInitiate;for(const e of n.contents||[])e.creator="initiator",As(e);yield this.pc.setLocalDescription(t),this.send("session-initiate",n)}))),t()}catch(e){this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}))}accept(e,t){return Object(r.__awaiter)(this,arguments,void 0,(function*(){1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this._log("info","Accepted incoming session"),this.state="active",this.role="responder";try{yield this.processLocal(Qr.SessionAccept,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createAnswer(e),n=xs(vs(t.sdp),this.role,this.transportType);n.sid=this.sid,n.action=Qr.SessionAccept;for(const e of n.contents||[])e.creator="initiator";yield this.pc.setLocalDescription(t),yield this.processBufferedCandidates(),this.send("session-accept",n)}))),t()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}))}end(e="success",t=!1){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.end(e,t)}ring(){return this.processLocal("ring",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Ringing on incoming session"),this.ringing=!0,this.send(Qr.SessionInfo,{info:{infoType:as}})})))}mute(e,t){return this.processLocal("mute",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Muting",t),this.send(Qr.SessionInfo,{info:{creator:e,infoType:ns,name:t}})})))}unmute(e,t){return this.processLocal("unmute",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Unmuting",t),this.send(Qr.SessionInfo,{info:{creator:e,infoType:is,name:t}})})))}hold(){return this.processLocal("hold",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Placing on hold"),this.send("session-info",{info:{infoType:rs}})})))}resume(){return this.processLocal("resume",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Resuming from hold"),this.send("session-info",{info:{infoType:os}})})))}addTrack(e,t,n){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this.pc.addTrack?this.pc.addTrack(e,t):this.pc.addStream(t),n&&n()})))}removeTrack(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this.processLocal("removetrack",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.pc.removeTrack(e),t)return t()})))}))}onAddTrack(e,t){this._log("info","Track added"),this.parent.emit("peerTrackAdded",this,e,t)}onRemoveTrack(e){this._log("info","Track removed"),this.parent.emit("peerTrackRemoved",this,e)}onSessionInitiate(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Initiating incoming session"),this.state="pending",this.role="responder",this.transportType=e.contents[0].transport.transportType;const n=ks(e,this.peerRole);for(const e of n.media)"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),e.streams||(e.streams=[{stream:"legacy",track:e.kind}]);const i=bs(n);try{return yield this.pc.setRemoteDescription({type:"offer",sdp:i}),yield this.processBufferedCandidates(),t()}catch(e){return this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}))}onSessionTerminate(e,t){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.onSessionTerminate(e,t)}onSessionInfo(e,t){const n=e.info||{infoType:""};switch(n.infoType){case as:return this._log("info","Outgoing session is ringing"),this.ringing=!0,this.parent.emit("ringing",this),t();case rs:return this._log("info","On hold"),this.parent.emit("hold",this),t();case ss:case os:return this._log("info","Resuming from hold"),this.parent.emit("resumed",this),t();case ns:return this._log("info","Muting",n),this.parent.emit("mute",this,n),t();case is:return this._log("info","Unmuting",n),this.parent.emit("unmute",this,n),t()}return t()}}class qs extends o.EventEmitter{constructor(e={}){super(),e=e||{},this.selfID=e.selfID,this.sessions={},this.peers={},this.iceServers=e.iceServers||[],this.prepareSession=e.prepareSession||(e=>{if(this.config.hasRTCPeerConnection)return e.applicationTypes.indexOf(Rn)>=0?new Ps(e):e.applicationTypes.indexOf(Dn)>=0?new Os(e):void 0}),this.performTieBreak=e.performTieBreak||((e,t)=>{const n=(t.jingle.contents||[]).map(e=>{if(e.application)return e.application.applicationType});return(e.pendingApplicationTypes||[]).filter(e=>n.includes(e)).length>0}),this.createPeerConnection=e.createPeerConnection||((e,t)=>{if(tr)return new tr(t)}),this.config=Object.assign({debug:!1,hasRTCPeerConnection:!!tr,peerConnectionConfig:{bundlePolicy:e.bundlePolicy||"balanced",iceTransportPolicy:e.iceTransportPolicy||"all",rtcpMuxPolicy:e.rtcpMuxPolicy||"require",sdpSemantics:e.sdpSemantics},peerConnectionConstraints:{optional:[{DtlsSrtpKeyAgreement:!0},{RtpDataChannels:!1}]}},e)}addICEServer(e){if("string"==typeof e)return void this.iceServers.push({urls:e});if(!(t=e).type&&(t.urls||t.url))return void this.iceServers.push(e);var t;let n=e.host||"";n.indexOf(":")>=0&&(n=`[${n}]`);let i=`${e.type}:${n}`;e.port&&(i+=":"+e.port),e.transport&&(i+="?transport="+e.transport),"turn"===e.type||"turns"===e.type?this.iceServers.push({credential:e.password,urls:[i],username:e.username}):"stun"!==e.type&&"stuns"!==e.type||this.iceServers.push({urls:[i]})}resetICEServers(){this.iceServers=[]}addSession(e){e.parent=this;const t=e.sid,n=e.peerID;return this.sessions[t]=e,this.peers[n]||(this.peers[n]=[]),this.peers[n].push(e),this.emit("createdSession",e),e}forgetSession(e){const t=this.peers[e.peerID]||[];t.length&&t.splice(t.indexOf(e),1),delete this.sessions[e.sid]}createMediaSession(e,t,n){const i=new Ps({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t,stream:n});return this.addSession(i),i}createFileTransferSession(e,t){const n=new Os({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t});return this.addSession(n),n}endPeerSessions(e,t,n=!1){const i=this.peers[e]||[];delete this.peers[e];for(const e of i)e.end(t||"gone",n)}endAllSessions(e,t=!1){for(const n of Object.keys(this.peers))this.endPeerSessions(n,e,t)}process(e){const t=e.jingle?e.jingle.sid:void 0;let n=t?this.sessions[t]:void 0;const i=e.id,r=e.from;if(!r)return;if("error"===e.type){if(this._log("error","Received error response",e),n&&e.error&&"unknown-session"===e.error.jingleError)return n.end("gone",!0);const t=e.error&&"tie-break"===e.error.jingleError;return n&&"pending"===n.state&&t?n.end("alternative-session",!0):void(n&&(n.pendingAction=void 0))}if("result"===e.type)return void(n&&(n.pendingAction=void 0));const s=e.jingle.action,o=e.jingle.contents||[],a=o.map(e=>e.application?e.application.applicationType:void 0),c=o.map(e=>e.transport?e.transport.transportType:void 0);if(s!==Qr.SessionInitiate){if(!n)return"session-terminate"===s?void this.emit("send",{id:i,to:r,type:"result"}):(this._log("error","Unknown session",t),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"}));if(n.peerID!==r||"ended"===n.state)return this._log("error","Session has ended, or action has wrong sender"),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"});if("session-accept"===s&&"pending"!==n.state)return this._log("error","Tried to accept session twice",t),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if("session-terminate"!==s&&s===n.pendingAction&&(this._log("error","Tie break during pending request"),n.isInitiator))return this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(n){if(n.peerID!==r)return this._log("error","Duplicate sid from new sender"),this._sendError(r,i,{condition:"service-unavailable"});if("pending"!==n.state)return this._log("error","Someone is doing this wrong"),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if(this.selfID&&this.selfID>n.peerID&&this.performTieBreak(n,e))return this._log("error","Tie break new session because of duplicate sids"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(this.peers[r]&&this.peers[r].length)for(let n=0,s=this.peers[r].length;n<s;n++){const s=this.peers[r][n];if(s&&"pending"===s.state&&t&&kr(s.sid,t)>0&&this.performTieBreak(s,e))return this._log("info","Tie break session-initiate"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}if("session-initiate"===s){if(!o.length)return this._sendError(r,i,{condition:"bad-request"});n=this._createIncomingSession({applicationTypes:a,config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!1,parent:this,peerID:r,sid:t,transportTypes:c},e)}n.process(s,e.jingle,t=>{t?(this._log("error","Could not process request",e,t),this._sendError(r,i,t)):(this.emit("send",{id:i,to:r,type:"result"}),"session-initiate"===s&&this.emit("incoming",n))})}signal(e,t){const n=t.jingle&&t.jingle.action;e.isInitiator&&n===Qr.SessionInitiate&&this.emit("outgoing",e),this.emit("send",t)}_createIncomingSession(e,t){let n;return this.prepareSession&&(n=this.prepareSession(e,t)),n||(n=new Es(e)),this.addSession(n),n}_sendError(e,t,n){n.type||(n.type="cancel"),this.emit("send",{error:n,id:t,to:e,type:"error"})}_log(e,t,...n){this.emit("log",e,t,...n),this.emit("log:"+e,t,...n)}}var Ls=Object.freeze({__proto__:null,Session:Es,ICESession:Ns,MediaSession:Ps,FileSession:Os,SessionManager:qs,importFromSDP:vs,exportToSDP:bs});function Fs(e){const t=!!tr,n={advertiseAudio:t,advertiseFileTransfer:t,advertiseVideo:t,bundlePolicy:"balanced",hasRTCPeerConnection:t,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",rtcpMuxPolicy:"require",trickleIce:!0},i=e.config.jingle,s=Object.assign(Object.assign({},n),i),o=e.jingle=new qs(s),a=[Cn];s.hasRTCPeerConnection&&(a.push(ni,Pn,"urn:xmpp:jingle:transports:dtls-sctp:1","urn:xmpp:jingle:apps:dtls:0","urn:ietf:rfc:5888"),!1===s.trickleIce&&a.push("urn:ietf:rfc:3264"),(s.advertiseAudio||s.advertiseVideo)&&a.push(Rn,Gn,Vn,"urn:ietf:rfc:5576"),s.advertiseAudio&&a.push("urn:xmpp:jingle:apps:rtp:audio"),s.advertiseVideo&&a.push("urn:xmpp:jingle:apps:rtp:video"),s.advertiseFileTransfer&&a.push("urn:xmpp:jingle:apps:file-transfer:4",Dn));for(const t of a)e.disco.addFeature(t);const c=["outgoing","incoming","accepted","terminated","ringing","mute","unmute","hold","resumed"];for(const t of c)o.on(t,(n,i)=>{e.emit("jingle:"+t,n,i)});o.on("createdSession",t=>{e.emit("jingle:created",t)}),o.on("send",t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{if("set"===t.type){const n=yield e.sendIQ(t);n.jingle||(n.jingle={}),n.jingle.sid=t.jingle.sid,o.process(n)}"result"===t.type&&e.sendIQResult({type:"set",id:t.id,from:t.to},t),"error"===t.type&&e.sendIQError({type:"set",id:t.id,from:t.to},t)}catch(e){e.jingle||(e.jingle=t.jingle),e.jingle.sid=t.jingle.sid,o.process(e)}}))),e.on("session:bound",e=>{o.selfID=e}),e.on("iq:set:jingle",e=>{o.process(e)}),e.on("unavailable",e=>{o.endPeerSessions(e.from,void 0,!0)}),e.getServices=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=(yield e.sendIQ({externalServices:{type:n,version:i},to:t,type:"get"})).externalServices;return r.services=r.services||[],r})),e.getServiceCredentials=(t,n,i,s,o)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({externalServiceCredentials:{host:n,port:s,type:i,version:o},to:t,type:"get"})).externalServiceCredentials})),e.discoverICEServers=(t={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=(yield e.getServices(e.config.server,void 0,t.version)).services||[],i=[];for(const t of n)e.jingle.addICEServer(t);return i}catch(e){return[]}}))}function Ms(e,t){const n=[],i=new Map;for(const e of t)e.name&&i.set(e.name,e);const r=new Set;for(const t of e)t.name&&i.has(t.name)?(n.push(Object.assign(Object.assign({},t),i.get(t.name))),r.add(t.name)):n.push(Object.assign({},t));for(const e of t)(!e.name||e.name&&!r.has(e.name))&&n.push(Object.assign({},e));return n}var Ds=Object.freeze({__proto__:null,mergeFields:Ms});function Bs(e){e.getHistorySearchForm=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({archive:{type:"query",version:n.version},to:t,type:"get"})).archive.form})),e.searchHistory=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=e.nextId();let r="";"string"==typeof t?r=t:(r=t.to||"",n=t),n.queryId=i;const s=n.form||{};s.type="submit";const o=s.fields||[],a=[{name:"FORM_TYPE",type:"hidden",value:"urn:xmpp:mam:2"}];n.with&&a.push({name:"with",type:"text-single",value:n.with}),n.start&&a.push({name:"start",type:"text-single",value:n.start.toISOString()}),n.end&&a.push({name:"end",type:"text-single",value:n.end.toISOString()}),s.fields=Ms(a,o),n.form=s;const c=V(e.jid,r),l=[],u=e=>{c.has(e.from)&&e.archive&&e.archive.queryId===i&&l.push(e.archive)};e.on("mam:item",u);try{const t=yield e.sendIQ({archive:n,id:i,to:r,type:"set"});return Object.assign(Object.assign({},t.archive),{results:l})}finally{e.off("mam:item",u)}})),e.getHistoryPreferences=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({archive:{type:"preferences"},type:"get"})).archive})),e.setHistoryPreferences=t=>e.sendIQ({archive:Object.assign({type:"preferences"},t),type:"set"}),e.on("message",t=>{t.archive&&e.emit("mam:item",t)})}const Us=new Set(["chat","groupchat","headline","normal"]),zs=new Set(["chat","groupchat","normal"]),Js=new Map([["markable",0],["received",1],["displayed",2],["acknowledged",3]]),Gs=(e,t)=>{var n;return e.marker&&(Js.get(e.marker.type)<Js.get(t)||"markable"===(null===(n=e.marker)||void 0===n?void 0:n.type))};function Vs(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({carbons:{action:t},type:"set"})}))}function $s(e){e.disco.addFeature("urn:xmpp:attention:0"),e.disco.addFeature(Xn),e.disco.addFeature(yn),e.disco.addFeature("urn:xmpp:message-correct:0"),e.disco.addFeature("urn:xmpp:receipts"),e.disco.addFeature(Qn),e.enableCarbons=()=>Vs(e,"enable"),e.disableCarbons=()=>Vs(e,"disable"),e.markReceived=t=>e.sendMarker(t,"received"),e.markDisplayed=t=>e.sendMarker(t,"displayed"),e.markAcknowledged=t=>e.sendMarker(t,"acknowledged"),e.getAttention=(t,n={})=>e.sendMessage(Object.assign(Object.assign({},n),{requestingAttention:!0,to:t,type:"headline"})),e.sendMarker=(t,n,i)=>{if(!Gs(t,n)&&!i)return;const r=!1!==e.config.groupchatMarkersUseStanzaID;let s=t.id;if("groupchat"===t.type&&t.stanzaIds&&r){const e=t.stanzaIds.find(e=>$(e.by,t.from));e&&(s=e.id)}e.sendMessage({marker:{id:s,type:n},to:"groupchat"===t.type?K(t.from):t.from,type:t.type})},e.on("message",t=>{if(t.carbon&&$(t.from,e.jid)){const n=t.carbon.forward.message;n.delay||(n.delay=t.carbon.forward.delay||{timestamp:new Date(Date.now())}),(e=>!!e.carbon&&"received"===e.carbon.type)(t)&&(e.emit("carbon:received",t),e.emit("message",n)),(e=>!!e.carbon&&"sent"===e.carbon.type)(t)&&(e.emit("carbon:sent",t),e.emit("message:sent",n,!0))}(e=>!!e.forms&&e.forms.length>0)(t)&&e.emit("dataform",t),t.requestingAttention&&e.emit("attention",t),(e=>!!e.rtt)(t)&&e.emit("rtt",t),(e=>!!e.replace)(t)&&e.emit("replace",t),(e=>!!e.chatState)(t)&&zs.has(t.type||"normal")&&e.emit("chat:state",t);const n=!1!==e.config.sendReceipts,i=!1!==e.config.sendMUCReceipts,r=!1!==e.config.chatMarkers,s=!1!==e.config.groupchatMarkersUseStanzaID,o=(e=>{var t;return!!e.receipt&&"request"===e.receipt.type&&Us.has(null!==(t=e.type)&&void 0!==t?t:"normal")})(t),a=Gs(t,"received"),c=o&&n&&("groupchat"!==t.type||i);if(c||r&&a){const n="groupchat"===t.type?K(t.from):t.from;let i=t.id;if("groupchat"===t.type&&t.stanzaIds&&s){const e=t.stanzaIds.find(e=>$(e.by,t.from));e&&(i=e.id)}e.sendMessage({receipt:c?{id:t.id,type:"received"}:void 0,marker:r&&a?{id:i,type:"received"}:void 0,to:n,type:t.type})}t.receipt&&"received"===t.receipt.type&&e.emit("receipt",t),t.marker&&"markable"!==t.marker.type&&e.emit("marker:"+t.marker.type,t)})}function Hs(e){e.disco.addFeature(en),e.disco.addFeature("jabber:x:conference"),e.disco.addFeature(Kn),e.joinedRooms=new Map,e.joiningRooms=new Map,e.leavingRooms=new Map,e.on("session:started",(function(){const t=e.joiningRooms;e.joiningRooms=new Map;for(const[n,i]of t)e.joinRoom(n,i);const n=e.joinedRooms;e.joinedRooms=new Map;for(const[t,i]of n)e.joinRoom(t,i)})),e.on("message",t=>{if("groupchat"===t.type&&t.hasSubject)e.emit("muc:topic",{from:t.from,room:K(t.from),topic:t.subject||""});else if(t.muc)if("direct-invite"===t.muc.type||!t.muc.invite&&t.legacyMUC){const n="direct-invite"===t.muc.type?t.muc:t.legacyMUC;e.emit("muc:invite",{from:t.from,password:n.password,reason:n.reason,room:n.jid,thread:n.thread,type:"direct"})}else t.muc.invite?e.emit("muc:invite",{from:t.muc.invite[0].from,password:t.muc.password,reason:t.muc.invite[0].reason,room:t.from,thread:t.muc.invite[0].thread,type:"mediated"}):t.muc.decline?e.emit("muc:declined",{from:t.muc.decline.from,reason:t.muc.decline.reason,room:t.from}):e.emit("muc:other",t)}),e.on("presence",t=>{const n=K(t.from);if(e.joiningRooms.has(n)&&"error"===t.type)return e.joiningRooms.delete(n),e.emit("muc:failed",t),void e.emit("muc:error",t);if(!function(e){return!!e.muc}(t))return;const i=t.muc.statusCodes&&t.muc.statusCodes.indexOf(Jr.SelfPresence)>=0,r=t.muc.statusCodes&&t.muc.statusCodes.indexOf(Jr.NickChanged)>=0;if("error"===t.type)return void e.emit("muc:error",t);if("unavailable"===t.type)return e.emit("muc:unavailable",t),i&&(r?e.joinedRooms.set(n,t.muc.nick):(e.emit("muc:leave",t),e.joinedRooms.delete(n),e.leavingRooms.delete(n))),void(t.muc.destroy&&e.emit("muc:destroyed",{newRoom:t.muc.destroy.jid,password:t.muc.destroy.password,reason:t.muc.destroy.reason,room:n}));e.emit("muc:available",t);const s=e.joiningRooms.has(n)||!e.joinedRooms.has(n);i&&(e.joinedRooms.set(n,Q(t.from)),s&&(e.joiningRooms.delete(n),e.emit("muc:join",t)))}),e.joinRoom=(t,n,i={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(t=K(t),e.joiningRooms.set(t,n||""),!n)try{n=yield e.getReservedNick(t),e.joiningRooms.set(t,n)}catch(e){throw new Error("Room nick required")}return new Promise((r,s)=>{function o(n){$(n.from,t)&&(e.off("muc:join",o),e.off("muc:failed",a),r(n))}function a(n){$(n.from,t)&&(e.off("muc:join",o),e.off("muc:failed",a),s(n))}e.on("muc:join",o),e.on("muc:failed",a),e.sendPresence(Object.assign(Object.assign({},i),{muc:Object.assign(Object.assign({},i.muc),{type:"join"}),to:J(t,n)}))})})),e.leaveRoom=(t,n,i={})=>(t=K(t),n=n||e.joinedRooms.get(t),e.leavingRooms.set(t,n),new Promise((r,s)=>{const o=i.id||Ir(),a=V(t);function c(n){$(n.from,t)&&(e.off("muc:leave",c),e.off("presence:error",l),r(n))}function l(n){n.id===o&&a.has(n.from)&&(e.joinedRooms.has(t)||e.leavingRooms.delete(t),e.off("muc:leave",c),e.off("presence:error",l),s(n))}e.on("muc:leave",c),e.on("presence:error",l),e.sendPresence(Object.assign(Object.assign({},i),{id:o,to:J(t,n),type:"unavailable"}))})),e.ban=(t,n,i)=>e.setRoomAffiliation(t,n,"outcast",i),e.kick=(t,n,i)=>e.setRoomRole(t,n,"none",i),e.invite=(t,n=[])=>{Array.isArray(n)||(n=[n]),e.sendMessage({muc:{invite:n,type:"info"},to:t})},e.directInvite=(t,n,i={})=>{e.sendMessage({muc:Object.assign(Object.assign({},i),{jid:t,type:"direct-invite"}),to:n})},e.declineInvite=(t,n,i)=>{e.sendMessage({muc:{decline:{reason:i,to:n},type:"info"},to:t})},e.changeNick=(t,n)=>{const i=Ir(),r=J(t,n),s=V(t);return new Promise((t,n)=>{function o(n){s.has(K(n.from))&&n.muc.statusCodes&&n.muc.statusCodes.includes(Jr.SelfPresence)&&(e.off("muc:available",o),e.off("presence:id:"+i,a),t(n))}function a(r){s.has(K(r.from))&&r.id===i&&(e.off("muc:available",o),e.off("presence:id:"+i,a),"error"===r.type?n(r):t(r))}e.on("muc:available",o),e.on("presence:id:"+i,a),e.sendPresence({id:i,to:r})})},e.setSubject=(t,n)=>{e.sendMessage({subject:n,to:t,type:"groupchat"})},e.getReservedNick=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=(yield e.getDiscoInfo(t,"x-roomuser-item")).identities[0];if(n.name)return n.name;throw new Error("No nickname reserved")}catch(e){throw new Error("No nickname reserved")}})),e.requestRoomVoice=t=>{e.sendMessage({forms:[{fields:[{name:"FORM_TYPE",type:"hidden",value:"http://jabber.org/protocol/muc#request"},{name:"muc#role",type:"text-single",value:"participant"}],type:"submit"}],to:t})},e.setRoomAffiliation=(t,n,i,r)=>e.sendIQ({muc:{type:"user-list",users:[{affiliation:i,jid:n,reason:r}]},to:t,type:"set"}),e.setRoomRole=(t,n,i,r)=>e.sendIQ({muc:{type:"user-list",users:[{nick:n,reason:r,role:i}]},to:t,type:"set"}),e.getRoomMembers=(t,n={affiliation:"member"})=>e.sendIQ({muc:{type:"user-list",users:[n]},to:t,type:"get"}),e.getRoomConfig=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.sendIQ({muc:{type:"configure"},to:t,type:"get"});if(!n.muc.form)throw new Error("No configuration form returned");return n.muc.form})),e.configureRoom=(t,n={})=>e.sendIQ({muc:{form:Object.assign(Object.assign({},n),{type:"submit"}),type:"configure"},to:t,type:"set"}),e.destroyRoom=(t,n={})=>e.sendIQ({muc:{destroy:n,type:"configure"},to:t,type:"set"}),e.getUniqueRoomName=function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.sendIQ({muc:{type:"unique"},to:e,type:"get"});if(!t.muc.name)throw new Error("No unique name returned");return t.muc.name}))},e.getBookmarks=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.getPrivateData("bookmarks");return t&&t.rooms?t.rooms:[]})),e.setBookmarks=t=>e.setPrivateData("bookmarks",{rooms:t}),e.addBookmark=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.getBookmarks(),i=[];let r=!1;for(const e of n)$(e.jid,t.jid)?(i.push(Object.assign(Object.assign({},e),t)),r=!0):i.push(e);return r||i.push(t),e.setBookmarks(i)})),e.removeBookmark=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=(yield e.getBookmarks()).filter(e=>!$(e.jid,t));return e.setBookmarks(n)}))}function Ws(e){e.disco.addFeature(Sn),e.disco.addFeature(gn),e.disco.addFeature(_n),e.disco.addFeature(An),e.disco.addFeature(wn),e.disco.addFeature(Nn(Sn)),e.disco.addFeature(Nn(gn)),e.disco.addFeature(Nn(_n)),e.disco.addFeature(Nn(An)),e.disco.addFeature(Nn(wn)),e.publishActivity=t=>e.publish("",Sn,Object.assign({itemType:Sn},t)),e.publishGeoLoc=t=>e.publish("",gn,Object.assign({itemType:gn},t)),e.publishMood=t=>e.publish("",_n,Object.assign({itemType:_n},t)),e.publishNick=t=>e.publish("",An,{itemType:An,nick:t}),e.publishTune=t=>e.publish("",wn,Object.assign({itemType:wn},t)),e.on("pubsub:published",t=>{const n=t.pubsub.items.published[0].content;switch(t.pubsub.items.node){case Sn:return e.emit("activity",{activity:n,jid:t.from});case gn:return e.emit("geoloc",{geoloc:n,jid:t.from});case _n:return e.emit("mood",{jid:t.from,mood:n});case An:return e.emit("nick",{jid:t.from,nick:n.nick});case wn:return e.emit("tune",{jid:t.from,tune:t.pubsub.items.published[0].content})}})}function Qs(e){e.disco.addFeature(kn+"#SubID",kn),e.on("message",t=>{!function(e){return!!e.pubsub&&!(e.pubsub.context&&"user"!==e.pubsub.context||!e.pubsub.affiliations)}(t)?function(e){return!!e.pubsub}(t)&&(e.emit("pubsub:event",t),!function(e){return!!e.pubsub.items&&!!e.pubsub.items.published}(t)?!function(e){return!!e.pubsub.items&&!!e.pubsub.items.retracted}(t)?!function(e){return"purge"===e.pubsub.eventType}(t)?!function(e){return"delete"===e.pubsub.eventType}(t)?!function(e){return"subscription"===e.pubsub.eventType}(t)?function(e){return"configuration"===e.pubsub.eventType}(t)&&e.emit("pubsub:config",t):e.emit("pubsub:subscription",t):e.emit("pubsub:deleted",t):e.emit("pubsub:purged",t):e.emit("pubsub:retracted",t):e.emit("pubsub:published",t)):e.emit("pubsub:affiliations",t)}),e.subscribeToNode=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i={};let r;"string"==typeof n?(i.node=n,i.jid=K(e.jid)):(i.node=n.node,i.jid=n.jid||(n.useBareJID?K(e.jid):e.jid),r=n.options);const s=yield e.sendIQ({pubsub:{context:"user",subscribe:i,subscriptionOptions:r?{form:r}:void 0},to:t,type:"set"}),o=s.pubsub.subscription||{};return s.pubsub.subscriptionOptions&&(o.options=s.pubsub.subscriptionOptions.form),o})),e.unsubscribeFromNode=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i={};"string"==typeof n?(i.node=n,i.jid=K(e.jid)):(i.node=n.node,i.subid=n.subid,i.jid=n.jid||(n.useBareJID?K(e.jid):e.jid));const r=yield e.sendIQ({pubsub:{context:"user",unsubscribe:i},to:t,type:"set"});return r.pubsub&&r.pubsub.subscription?r.pubsub.subscription:Object.assign(Object.assign({},i),{state:"none"})})),e.publish=(t,n,i,r)=>e.sendIQ({pubsub:{context:"user",publish:{item:{content:i,id:r},node:n}},to:t,type:"set"}),e.getItem=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"user",fetch:{items:[{id:i}],node:n}},to:t,type:"get"})).pubsub.fetch.items[0]})),e.getItems=(t,n,i={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=yield e.sendIQ({pubsub:{context:"user",fetch:{max:i.max,node:n},paging:i},to:t,type:"get"}),s=r.pubsub.fetch;return s.paging=r.pubsub.paging,s})),e.retract=(t,n,i,r)=>e.sendIQ({pubsub:{context:"user",retract:{id:i,node:n,notify:r}},to:t,type:"set"}),e.purgeNode=(t,n)=>e.sendIQ({pubsub:{context:"owner",purge:n},to:t,type:"set"}),e.deleteNode=(t,n,i)=>e.sendIQ({pubsub:{context:"owner",destroy:{node:n,redirect:i}},to:t,type:"set"}),e.createNode=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=yield e.sendIQ({pubsub:{configure:i?{form:i}:void 0,context:"user",create:{node:n}},to:t,type:"set"});return r.pubsub&&r.pubsub.create?r.pubsub.create:{node:n}})),e.getSubscriptions=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"user",subscriptions:n},to:t,type:"get"})).pubsub.subscriptions})),e.getAffiliations=(t,n)=>e.sendIQ({pubsub:{affiliations:{node:n}},to:t,type:"get"}),e.getNodeSubscribers=(t,n,i={})=>("string"==typeof n?i.node=n:i=Object.assign(Object.assign({},i),n),e.sendIQ({pubsub:{context:"owner",subscriptions:i},to:t,type:"get"})),e.updateNodeSubscriptions=(t,n,i)=>e.sendIQ({pubsub:{context:"owner",subscriptions:{items:i,node:n}},to:t,type:"set"}),e.getNodeAffiliations=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{affiliations:{node:n},context:"owner"},to:t,type:"get"})).pubsub.affiliations})),e.updateNodeAffiliations=(t,n,i)=>e.sendIQ({pubsub:{affiliations:{items:i,node:n},context:"owner"},to:t,type:"set"}),e.getNodeConfig=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{configure:{node:n},context:"owner"},to:t,type:"get"})).pubsub.configure.form||{}})),e.getDefaultNodeConfig=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"owner",defaultConfiguration:{}},to:t,type:"get"})).pubsub.defaultConfiguration.form||{}})),e.configureNode=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return e.sendIQ({pubsub:{configure:{form:i,node:n},context:"owner"},to:t,type:"set"})})),e.getDefaultSubscriptionOptions=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{defaultSubscriptionOptions:{}},to:t,type:"get"})).pubsub.defaultSubscriptionOptions.form||{}}))}function Ks(e){function t(t,n){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({blockList:{action:t,jids:[n]},type:"set"})}))}e.on("iq:set:roster",t=>{if(!V(e.jid).has(t.from))return e.sendIQError(t,{error:{condition:"service-unavailable",type:"cancel"}});e.emit("roster:update",t),e.sendIQResult(t)}),e.on("iq:set:blockList",t=>{if(!V(e.jid).has(t.from))return e.sendIQError(t,{error:{condition:"service-unavailable",type:"cancel"}});const n=t.blockList;e.emit(n.action,{jids:n.jids||[]}),e.sendIQResult(t)}),e.getRoster=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.sendIQ({roster:{version:e.config.rosterVer},type:"get"});if(t.roster){const n=t.roster.version;return n&&(e.config.rosterVer=n,e.emit("roster:ver",n)),t.roster.items=t.roster.items||[],t.roster}return{items:[]}})),e.updateRosterItem=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({roster:{items:[t]},type:"set"})})),e.removeRosterItem=t=>e.updateRosterItem({jid:t,subscription:"remove"}),e.subscribe=t=>{e.sendPresence({type:"subscribe",to:t})},e.unsubscribe=t=>{e.sendPresence({type:"unsubscribe",to:t})},e.acceptSubscription=t=>{e.sendPresence({type:"subscribed",to:t})},e.denySubscription=t=>{e.sendPresence({type:"unsubscribed",to:t})},e.getBlocked=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.sendIQ({blockList:{action:"list"},type:"get"});return Object.assign({jids:[]},t.blockList)})),e.block=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return t("block",e)})),e.unblock=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return t("unblock",e)})),e.goInvisible=(t=!1)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",visiblity:{probe:t,type:"invisible"}})})),e.goVisible=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",visiblity:{type:"visible"}})}))}function Xs(e){e.registerFeature("sasl",100,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=e.sasl.createMechanism(t.sasl.mechanisms),s=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(i)switch(t.type){case"success":return e.features.negotiated.sasl=!0,e.off("sasl",s),e.emit("auth:success",e.config.credentials),e.transport&&(e.transport.authenticated=!0),void n("restart");case"challenge":i.processChallenge(t.value);try{const t=yield e.getCredentials(),n=i.createResponse(t);n||""===n?e.send("sasl",{type:"response",value:n}):e.send("sasl",{type:"response"});const r=i.getCacheableCredentials();r&&(e.config.credentials||(e.config.credentials={}),e.config.credentials=Object.assign(Object.assign({},e.config.credentials),r),e.emit("credentials:update",e.config.credentials))}catch(t){console.error(t),e.send("sasl",{type:"abort"})}return;case"failure":case"abort":return e.off("sasl",s),e.emit("auth:failed"),void n("disconnect","authentication failed")}}));if(!i)return e.off("sasl",s),e.emit("auth:failed"),n("disconnect","authentication failed");e.on("sasl",s),e.once("--reset-stream-features",()=>{e.features.negotiated.sasl=!1,e.off("sasl",s)});try{const t=yield e.getCredentials();e.send("sasl",{mechanism:i.name,type:"auth",value:i.createResponse(t)})}catch(t){console.error(t),e.send("sasl",{type:"abort"})}})))}function Ys(e){function t(t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.getDiscoInfo(t);if(!n.features||!n.features.includes(ti))return;let i;for(const e of n.extensions||[]){const n=e.fields||[];if(n.some(e=>"FORM_TYPE"===e.name&&e.value===ti)){const e=n.find(e=>"max-file-size"===e.name);return e&&(i=parseInt(e.value,10)),{jid:t,maxSize:i}}}}))}e.disco.addFeature(Mn),e.getBits=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({bits:{cid:n},to:t,type:"get"})).bits})),e.getUploadService=(n=W(e.jid))=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield t(n);if(i)return i;const r=yield e.getDiscoItems(n);for(const e of r.items||[]){if(!e.jid)continue;const n=yield t(e.jid);if(n)return n}throw new Error("No upload service discovered on: "+n)})),e.getUploadSlot=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({httpUpload:Object.assign({type:"request"},n),to:t,type:"get"})).httpUpload}))}function Zs(e){e.use(fs),e.use(Lr),e.use(_r),e.use(Rr),e.use(gs),e.use(Xs)}function eo(e){e.use(br),e.use($s),e.use(yr),e.use(Sr),e.use(hs),e.use(Fs),e.use(Bs),e.use(Hs),e.use(Ws),e.use(Qs),e.use(Ks),e.use(Ys)}const to={aliases:["features.legacySession","iq.legacySession"],element:"session",fields:{optional:yt(null,"optional")},namespace:Jt},no=[{aliases:["atomentry",{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"entry",fields:{id:dt(null,"id"),published:ft(null,"published"),updated:ft(null,"updated")},namespace:Dt,type:Dt,typeField:"itemType"},{element:"summary",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.summary"},{element:"title",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.title"},{aliases:[{path:"atomentry.links",multiple:!0}],element:"link",fields:{href:He("href"),mediaType:He("type"),rel:He("rel")},namespace:Dt},{aliases:[{path:"atomentry.authors",multiple:!0}],element:"author",fields:{name:dt(null,"name"),uri:dt(null,"uri"),email:dt(null,"email")},namespace:Dt},{aliases:[{path:"atomentry.contributors",multiple:!0}],element:"contributor",fields:{name:dt(null,"name"),uri:dt(null,"uri"),email:dt(null,"email")},namespace:Dt},{aliases:[{path:"atomentry.categories",multiple:!0}],element:"category",fields:{term:He("term"),scheme:He("scheme"),label:He("label")},namespace:Dt},{element:"content",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.content"},{element:"rights",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.rights"}],io={defaultType:"stream",element:"stream",fields:{from:He("from"),id:He("id"),lang:pt(),to:He("to"),version:He("version")},namespace:Vt,path:"stream",type:"stream",typeField:"action"},ro={element:"features",namespace:Vt,path:"features"},so={element:"error",fields:{alternateLanguageText:Ct($t,"text"),condition:kt($t,Object.values(Dr),Dr.UndefinedCondition),seeOtherHost:dt($t,Dr.SeeOtherHost),text:dt($t,"text")},namespace:Vt,path:"streamError"},oo=Object.values(Fr).map(e=>({aliases:["stanzaError","message.error","presence.error","iq.error"],defaultType:Ut,element:"error",fields:{alternateLanguageText:Ct(Gt,"text"),by:oi("by"),condition:kt(Gt,Object.values(Br),Br.UndefinedCondition),gone:dt(Gt,Br.Gone),redirect:dt(Gt,Br.Redirect),text:dt(Gt,"text"),type:He("type")},namespace:e,type:e,typeField:"streamType"})),ao=new Set(["from","id","lang","to","type","payloadType","error","streamType"]),co=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"iq",fields:{from:oi("from"),id:He("id"),lang:pt(),payloadType:{order:-1e4,importer(e,t){if("get"!==t.data.type&&"set"!==t.data.type)return;if(1!==e.children.filter(e=>"string"!=typeof e).length)return"invalid-payload-count";const n=Object.keys(t.data).filter(e=>!ao.has(e));return 1!==n.length?"unknown-payload":n[0]}},to:oi("to"),type:He("type")},namespace:e,path:"iq",type:e,typeField:"streamType"})),lo=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"message",fields:{from:oi("from"),id:He("id"),lang:pt(),to:oi("to")},namespace:e,path:"message",type:e,typeField:"streamType"})),uo=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"presence",fields:{from:oi("from"),id:He("id"),lang:pt(),to:oi("to")},namespace:e,path:"presence",type:e,typeField:"streamType"})),po=[io,ro,so,...oo,...[{element:"mechanisms",fields:{mechanisms:jt(null,"mechanism")},namespace:zt,path:"features.sasl"},{element:"abort",namespace:zt,path:"sasl",type:"abort",typeField:"type"},{element:"auth",fields:{mechanism:He("mechanism"),value:ut("base64")},namespace:zt,path:"sasl",type:"auth",typeField:"type"},{element:"challenge",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"challenge",typeField:"type"},{element:"response",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"response",typeField:"type"},{element:"success",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"success",typeField:"type"},{element:"failure",fields:{alternateLanguageText:Ct(zt,"text"),condition:kt(zt,Object.values(Mr)),text:dt(zt,"text")},namespace:zt,path:"sasl",type:"failure",typeField:"type"}],...[{aliases:["features.tls"],defaultType:"start",element:"starttls",fields:{required:yt(null,"required")},namespace:Ht,path:"tls",type:"start",typeField:"type"},{element:"proceed",namespace:Ht,path:"tls",type:"proceed",typeField:"type"},{element:"failure",namespace:Ht,path:"tls",type:"failure",typeField:"type"}],...co,...lo,...uo,{aliases:["features.bind","iq.bind"],element:"bind",fields:{jid:dt(null,"jid"),resource:dt(null,"resource")},namespace:Bt}],ho=[hi({rosterPreApproval:yt("urn:xmpp:features:pre-approval","sub"),rosterVersioning:yt("urn:xmpp:features:rosterver","ver")}),ui({alternateLanguageBodies:Ct(null,"body"),alternateLanguageSubjects:Ct(null,"subject"),body:dt(null,"body"),hasSubject:yt(null,"subject"),parentThread:it(null,"thread","parent"),subject:dt(null,"subject"),thread:dt(null,"thread"),type:He("type")}),pi({alternateLanguageStatuses:Ct(null,"status"),priority:mt(null,"priority",0),show:dt(null,"show"),status:dt(null,"status"),type:He("type")}),{element:"query",fields:{version:He("ver",void 0,{emitEmpty:!0})},namespace:"jabber:iq:roster",path:"iq.roster"},{aliases:[{path:"iq.roster.items",multiple:!0}],element:"item",fields:{groups:jt(null,"group"),jid:oi("jid"),name:He("name"),pending:He("ask"),preApproved:We("approved"),subscription:He("subscription")},namespace:"jabber:iq:roster"}],fo=[{element:"open",fields:{from:He("from"),id:He("id"),lang:pt(),to:He("to"),version:He("version")},namespace:Wt,path:"stream",type:"open"},{element:"close",fields:{seeOtherURI:He("see-other-uri")},namespace:Wt,path:"stream",type:"close"}],mo=[{aliases:[{path:"message.forms",multiple:!0}],element:"x",fields:{instructions:Object.assign(Object.assign({},jt(null,"instructions")),{exportOrder:2}),reported:Object.assign(Object.assign({},Ot(null,"reported","dataformField",!0)),{exportOrder:3}),title:Object.assign(Object.assign({},dt(null,"title")),{exportOrder:1}),type:He("type")},namespace:Qt,optionalNamespaces:{xdv:xn},path:"dataform"},{aliases:[{path:"dataform.fields",multiple:!0},{path:"dataform.items.fields",multiple:!0}],element:"field",fields:{description:dt(null,"desc"),label:He("label"),name:He("var"),rawValues:Object.assign(Object.assign({},jt(null,"value")),{exporter:()=>null}),required:yt(null,"required"),type:He("type"),value:{importer(e,t){const n=e.getAttribute("type"),i=jt(Qt,"value").importer(e,t),r=i[0];switch(n){case zr.TextMultiple:case zr.ListMultiple:case zr.JIDMultiple:return i;case zr.Hidden:case zr.Fixed:return 1===i.length?r:i;case zr.Boolean:if(r)return"1"===r||"true"===r;break;default:return r}},exporter(e,t,n){const i=jt(null,"value");let r=[];const s=n.data&&n.data.rawValues?n.data.rawValues[0]:void 0;if("boolean"==typeof t)r="true"===s||"false"===s?[s]:[t?"1":"0"];else if(Array.isArray(t))for(const e of t)r.push(e.toString());else r=[t.toString()];i.exporter(e,r,Object.assign({},n,{namespace:Qt}))}}},namespace:Qt,path:"dataformField"},{aliases:[{path:"dataform.fields.options",multiple:!0}],element:"option",fields:{label:He("label"),value:dt(null,"value")},namespace:Qt},{aliases:[{path:"dataform.items",multiple:!0}],element:"item",namespace:Qt},{element:"validate",fields:{listMax:st(null,"list-range","max"),listMin:st(null,"list-range","min"),method:kt(null,["basic","open","range","regex"],"basic"),rangeMax:it(null,"range","max"),rangeMin:it(null,"range","min"),regex:dt(null,"regex"),type:He("datatype","xs:string")},namespace:xn,path:"dataform.fields.validation"}],go=[{aliases:["presence.legacyLastActivity","iq.lastActivity"],element:"query",fields:{seconds:Qe("seconds"),status:ct()},namespace:"jabber:iq:last"}],vo=[{element:"query",fields:{activeList:it(null,"active","name"),defaultList:it(null,"default","name")},namespace:Kt,path:"iq.privacy"},{aliases:[{path:"iq.privacy.lists",multiple:!0}],element:"list",fields:{name:He("name")},namespace:Kt},{aliases:[{path:"iq.privacy.lists.items",multiple:!0}],element:"item",fields:{action:He("action"),incomingPresence:yt(null,"presence-in"),iq:yt(null,"iq"),messages:yt(null,"message"),order:Qe("order"),outgoingPresence:yt(null,"presence-out"),type:He("type"),value:He("value")},namespace:Kt}],bo=[{aliases:["iq.disco","message.disco","features.disco"],childrenExportOrder:{identities:1,features:2,extensions:3},element:"query",fields:{features:Et(null,"feature","var"),node:He("node")},namespace:Xt,path:"disco",type:"info",typeField:"type"},{aliases:[{path:"disco.identities",selector:"info",multiple:!0}],element:"identity",fields:{category:He("category"),lang:pt(),name:He("name"),type:He("type")},namespace:Xt},{aliases:[{path:"disco.items",multiple:!0,selector:"items"}],element:"item",fields:{jid:oi("jid"),name:He("name"),node:He("node")},namespace:Yt},{aliases:[{path:"disco.items",multiple:!0,selector:"info"}],element:"item",fields:{category:oi("category"),lang:pt(),name:He("name"),type:He("type")},namespace:Xt},li(Qt,"x",[{path:"disco.extensions",multiple:!0,selector:"info"}]),li(an,"set",[{path:"disco.paging",selector:"items"}]),{aliases:["iq.disco","message.disco","features.disco"],element:"query",fields:{node:He("node")},namespace:Yt,path:"disco",type:"items",typeField:"type"}],yo=[ui({addresses:Ot(Zt,"addresses","extendedAddress",!0)}),pi({addresses:Ot(Zt,"addresses","extendedAddress",!0)}),{element:"address",fields:{alternateLanguageDescriptions:Ct(null,"desc"),delivered:We("delivered"),description:He("desc"),jid:oi("jid"),node:He("node"),type:He("type"),uri:He("uri")},namespace:Zt,path:"extendedAddress"}],_o=[li(Qt,"x",[{path:"iq.muc.form",selector:"configure"}]),{defaultType:"info",element:"x",fields:{password:dt(null,"password")},namespace:en,path:"presence.muc",type:"join",typeField:"type"},{aliases:[{path:"presence.muc.history",selector:"join"}],element:"history",fields:{maxCharacters:Qe("maxchars"),maxStanzas:Qe("maxstanzas"),seconds:Qe("seconds"),since:Xe("since")},namespace:en},{aliases:["presence.muc","message.muc"],defaultType:"info",element:"x",fields:{action:kt(null,["invite","decline","destroy"]),actor:Ot(null,"item","mucactor"),affiliation:it(null,"item","affiliation"),jid:ai(null,"item","jid"),nick:it(null,"item","nick"),password:dt(null,"password"),reason:St([{namespace:null,element:"item"},{namespace:null,element:"reason"}]),role:it(null,"item","role"),statusCodes:Et(null,"status","code")},namespace:rn,type:"info",typeField:"type",typeOrder:1},{element:"actor",fields:{jid:oi("jid"),nick:He("nick")},namespace:rn,path:"mucactor"},{element:"destroy",fields:{jid:oi("jid"),password:dt(null,"password"),reason:dt(null,"reason")},namespace:rn,path:"presence.muc.destroy"},{aliases:[{path:"message.muc.invite",multiple:!0}],element:"invite",fields:{continue:yt(null,"continue"),from:oi("from"),reason:dt(null,"reason"),thread:it(null,"continue","thread"),to:oi("to")},namespace:rn},{element:"decline",fields:{from:oi("from"),reason:dt(null,"reason"),to:oi("to")},namespace:rn,path:"message.muc",type:"decline"},{element:"query",namespace:tn,path:"iq.muc",type:"user-list",typeField:"type"},{aliases:[{path:"iq.muc.users",multiple:!0,selector:"user-list"}],element:"item",fields:{affiliation:He("affiliation"),jid:oi("jid"),nick:He("nick"),reason:dt(null,"reason"),role:He("role")},namespace:tn},{aliases:["iq.muc.users.actor"],element:"actor",fields:{jid:oi("jid"),nick:He("nick")},namespace:tn},{element:"query",namespace:nn,path:"iq.muc",type:"configure",typeField:"type"},{aliases:[{path:"iq.muc.destroy",selector:"configure"}],element:"destroy",fields:{jid:oi("jid"),password:dt(null,"password"),reason:dt(null,"reason")},namespace:nn},{element:"x",fields:{action:At("invite"),continue:We("continue"),jid:oi("jid"),legacyReason:ct(),password:He("password"),reason:He("reason"),thread:He("thread")},namespace:"jabber:x:conference",path:"message.muc",type:"direct-invite",typeOrder:2},{element:"unique",fields:{name:ct()},namespace:"http://jabber.org/protocol/muc#unique",path:"iq.muc",type:"unique"},ui({legacyMUC:{exporter(e,t,n){const i=n.registry?n.registry.export("message.muc",Object.assign(Object.assign({},t),{type:"direct-invite"})):void 0;i&&e.appendChild(i)},exportOrder:100001,importer(e,t){if(!Ce(e,rn,"x")[0])return;const n=Ce(e,"jabber:x:conference","x")[0];return n&&t.registry?t.registry.import(n,Object.assign(Object.assign({},t),{path:"message"})):void 0},importOrder:-1}})],So=[{aliases:["iq.ibb","message.ibb"],element:"open",fields:{ack:{importer:(e,t)=>"message"!==He("stanza","iq").importer(e,t),exporter(e,t,n){He("stanza").exporter(e,t?"iq":"message",n)}},blockSize:Qe("block-size"),sid:He("sid")},namespace:sn,type:"open",typeField:"action"},{aliases:["iq.ibb","message.ibb"],element:"close",fields:{sid:He("sid")},namespace:sn,type:"close",typeField:"action"},{aliases:["iq.ibb","message.ibb"],element:"data",fields:{data:ut("base64"),seq:Qe("seq"),sid:He("sid")},namespace:sn,type:"data",typeField:"action"}],wo=[{aliases:[{path:"bookmarkStorage",impliedType:!0},{path:"iq.privateStorage.bookmarks",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"storage",namespace:"storage:bookmarks",type:"storage:bookmarks",typeField:"itemType"},{aliases:[{path:"bookmarkStorage.rooms",multiple:!0}],element:"conference",fields:{autoJoin:We("autojoin"),jid:oi("jid"),name:He("name"),nick:dt(null,"nick"),password:dt(null,"password")},namespace:"storage:bookmarks"}],xo={element:"query",namespace:"jabber:iq:private",path:"iq.privateStorage"},To=[li(Qt,"x",["iq.command.form"]),fi({commandError:kt(on,["bad-action","bad-locale","bad-payload","bad-sessionid","malformed-action","session-expired"])}),{element:"command",fields:{action:He("action"),node:He("node"),sid:He("sessionid"),status:He("status")},namespace:on,path:"iq.command"},{element:"actions",fields:{complete:yt(null,"complete"),execute:He("execute"),next:yt(null,"next"),prev:yt(null,"prev")},namespace:on,path:"iq.command.availableActions"},{aliases:[{path:"iq.command.notes",multiple:!0}],element:"note",fields:{type:He("type"),value:ct()},namespace:on}],ko="vcardTemp.records";function Io(e,t){return{aliases:[{multiple:!0,path:ko}],element:e,fields:{value:ct()},namespace:"vcard-temp",type:t,typeField:"type"}}const jo=[{aliases:[{path:"iq.vcard"}],defaultType:"vcard-temp",element:"vCard",fields:{fullName:dt(null,"FN")},namespace:"vcard-temp",path:"vcardTemp",type:"vcard-temp",typeField:"format"},{element:"N",fields:{additional:Object.assign(Object.assign({},dt(null,"MIDDLE")),{order:3}),family:Object.assign(Object.assign({},dt(null,"FAMILY")),{order:1}),given:Object.assign(Object.assign({},dt(null,"GIVEN")),{order:2}),prefix:Object.assign(Object.assign({},dt(null,"PREFIX")),{order:4}),suffix:Object.assign(Object.assign({},dt(null,"SUFFIX")),{order:5})},namespace:"vcard-temp",path:"vcardTemp.name"},Io("NICKNAME","nickname"),Io("BDAY","birthday"),Io("JABBERID","jid"),Io("TZ","timezone"),Io("TITLE","title"),Io("ROLE","role"),Io("URL","url"),Io("NOTE","note"),Io("SORT-STRING","sort"),Io("UID","uid"),Io("REV","revision"),Io("PRODID","productId"),Io("DESC","description"),{aliases:[{multiple:!0,path:ko}],element:"EMAIL",fields:{preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"],["internet","INTERNET"]]),value:dt(null,"USERID")},namespace:"vcard-temp",type:"email"},{aliases:[{path:ko,multiple:!0}],element:"ORG",fields:{units:Object.assign(Object.assign({},jt(null,"ORGUNIT")),{order:2}),value:Object.assign(Object.assign({},dt(null,"ORGNAME")),{order:1})},namespace:"vcard-temp",type:"organization",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"ADR",fields:{city:dt(null,"LOCALITY"),code:dt(null,"PCODE"),country:dt(null,"CTRY"),pobox:dt(null,"POBOX"),preferred:yt(null,"PREF"),region:dt(null,"REGION"),street:dt(null,"STREET"),street2:dt(null,"EXTADD"),types:Rt(null,[["home","HOME"],["work","WORK"],["domestic","DOM"],["international","INTL"],["postal","POSTAL"],["parcel","PARCEL"]])},namespace:"vcard-temp",type:"address",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"LABEL",fields:{lines:jt(null,"LINE"),preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"]])},namespace:"vcard-temp",type:"addressLabel",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"TEL",fields:{preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"],["cell","CELL"],["fax","FAX"],["voice","VOICE"],["msg","MSG"]]),value:dt(null,"NUMBER","",!0)},namespace:"vcard-temp",type:"tel",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"PHOTO",fields:{data:dt(null,"BINVAL"),mediaType:dt(null,"TYPE"),url:dt(null,"EXTVAL")},namespace:"vcard-temp",type:"photo",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"LOGO",fields:{data:dt(null,"BINVAL"),mediaType:dt(null,"TYPE"),url:dt(null,"EXTVAL")},namespace:"vcard-temp",type:"logo",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"CATEGORIES",fields:{value:jt(null,"KEYWORD")},namespace:"vcard-temp",type:"categories",typeField:"type"}],Eo=[li(Qt,"x",["iq.search.form"]),li(an,"set",["iq.search.paging"]),{element:"query",fields:{email:dt(null,"email"),familyName:dt(null,"last"),givenName:dt(null,"first"),instructions:dt(null,"instructions"),nick:dt(null,"nick")},namespace:"jabber:iq:search",path:"iq.search"},{aliases:[{path:"iq.search.items",multiple:!0}],element:"item",fields:{email:dt(null,"email"),familyName:dt(null,"last"),givenName:dt(null,"first"),jid:oi("jid"),nick:dt(null,"nick")},namespace:"jabber:iq:search"}],No={aliases:["iq.pubsub.paging"],element:"set",fields:{after:dt(null,"after"),before:dt(null,"before"),count:mt(null,"count"),first:dt(null,"first"),firstIndex:st(null,"first","index"),index:mt(null,"index"),last:dt(null,"last"),max:mt(null,"max")},namespace:an,path:"paging"},Co={configurable:yt(null,"subscribe-options"),configurationRequired:xt([{namespace:null,element:"subscribe-options"},{namespace:null,element:"required"}]),jid:oi("jid"),node:He("node"),state:He("subscription"),subid:He("subid")},Ro={node:He("node")},Oo=[{aliases:["pubsub","iq.pubsub","message.pubsub"],childrenExportOrder:{configure:0,create:100,publish:100,subscribe:100,subscriptionOptions:0},defaultType:"user",element:"pubsub",fields:{publishOptions:Ot(null,"publish-options","dataform")},namespace:cn,type:"user",typeField:"context"},{aliases:["pubsub","iq.pubsub","message.pubsub"],defaultType:"user",element:"pubsub",fields:{purge:it(null,"purge","node")},namespace:pn,type:"owner",typeField:"context"},li(Qt,"x",["iq.pubsub.configure.form","iq.pubsub.defaultConfiguration.form","iq.pubsub.defaultSubscriptionOptions.form","iq.pubsub.subscriptionOptions.form","message.pubsub.configuration.form"]),li(an,"set",["iq.pubsub.fetch.paging"]),fi({pubsubError:kt(ln,Object.values(Gr)),pubsubUnsupportedFeature:it(ln,"unsupported","feature")}),{element:"subscribe",fields:{jid:oi("jid"),node:He("node")},namespace:cn,path:"iq.pubsub.subscribe"},{element:"unsubscribe",fields:{jid:oi("jid"),node:He("node"),subid:He("subid")},namespace:cn,path:"iq.pubsub.unsubscribe"},{element:"options",fields:{jid:oi("jid"),node:He("node"),subid:He("subid")},namespace:cn,path:"iq.pubsub.subscriptionOptions"},{aliases:[{path:"iq.pubsub.subscriptions",selector:"user",impliedType:!0}],element:"subscriptions",fields:{jid:oi("jid"),node:He("node")},namespace:cn,type:"user"},{aliases:[{path:"iq.pubsub.subscriptions",selector:"owner",impliedType:!0}],element:"subscriptions",fields:{jid:oi("jid"),node:He("node")},namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.subscription",selector:"owner"},{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"owner"}],element:"subscription",fields:Co,namespace:cn},{aliases:[{path:"iq.pubsub.subscription",selector:"user"},{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"user"}],element:"subscription",fields:Co,namespace:cn,type:"user"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"owner"}],element:"subscription",fields:Co,namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.affiliations",selector:"user",impliedType:!0},{path:"message.pubsub.affiliations",selector:"user",impliedType:!0}],element:"affiliations",fields:Ro,namespace:cn,type:"user"},{aliases:[{path:"iq.pubsub.affiliations",selector:"owner",impliedType:!0}],element:"affiliations",fields:Ro,namespace:pn,type:"owner"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.affiliations.items",selector:"user"},{impliedType:!0,multiple:!0,path:"message.pubsub.affiliations.items",selector:"user"}],element:"affiliation",fields:{affiliation:He("affiliation"),jid:oi("jid"),node:He("node")},namespace:cn,type:"user"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.affiliations.items",selector:"owner"}],element:"affiliation",fields:{affiliation:He("affiliation"),jid:oi("jid"),node:He("node")},namespace:pn,type:"owner"},{element:"create",fields:Ro,namespace:cn,path:"iq.pubsub.create"},{aliases:[{path:"iq.pubsub.destroy",selector:"owner"}],element:"delete",fields:{node:He("node"),redirect:it(null,"redirect","uri")},namespace:pn},{aliases:[{path:"iq.pubsub.configure",selector:"owner",impliedType:!0}],element:"configure",fields:Ro,namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.configure",selector:"user",impliedType:!0}],element:"configure",fields:Ro,namespace:cn,type:"user"},{element:"default",fields:{node:He("node")},namespace:cn,path:"iq.pubsub.defaultSubscriptionOptions"},{element:"default",fields:{},namespace:pn,path:"iq.pubsub.defaultConfiguration"},{element:"publish",fields:Ro,namespace:cn,path:"iq.pubsub.publish"},{element:"retract",fields:{id:it(null,"item","id"),node:He("node"),notify:We("notify")},namespace:cn,path:"iq.pubsub.retract"},{element:"items",fields:{max:Qe("max_items"),node:He("node")},namespace:cn,path:"iq.pubsub.fetch"},{aliases:["pubsubitem","iq.pubsub.publish.item",{multiple:!0,path:"iq.pubsub.fetch.items"}],element:"item",fields:{id:He("id"),publisher:oi("publisher")},namespace:cn},{element:"event",fields:{eventType:kt(null,["purge","delete","subscription","configuration","items"])},namespace:un,path:"message.pubsub",type:"event",typeField:"context"},{aliases:[{path:"message.pubsub.items.published",multiple:!0}],element:"item",fields:{id:He("id"),publisher:oi("publisher")},namespace:un,path:"pubsubeventitem"},{element:"purge",fields:Ro,namespace:un,path:"message.pubsub.purge"},{element:"delete",fields:{node:He("node"),redirect:it(null,"redirect","uri")},namespace:un,path:"message.pubsub.delete"},{aliases:[{path:"message.pubsub.subscription",selector:"event",impliedType:!0}],element:"subscription",fields:{expires:(Ao="expiry",{importer(e){const t=e.getAttribute(Ao);return"presence"===t?t:t?new Date(t):void 0},exporter(e,t){let n;n="string"==typeof t?t:t.toISOString(),e.setAttribute(Ao,n)}}),jid:oi("jid"),node:He("node"),subid:He("subid"),type:He("subscription")},namespace:un,type:"event"},{element:"configuration",fields:Ro,namespace:un,path:"message.pubsub.configuration"},{element:"items",fields:{node:He("node"),retracted:Et(null,"retract","id")},namespace:un,path:"message.pubsub.items"}];var Ao;const Po=[{element:"query",fields:{activate:dt(null,"activate"),address:He("dstaddr"),candidateUsed:ai(null,"streamhost-used","jid"),mode:He("mode","tcp"),sid:He("sid"),udpSuccess:it(null,"udpsuccess","dstaddr")},namespace:dn,path:"iq.socks5"},{aliases:[{multiple:!0,path:"iq.socks5.candidates"}],element:"streamhost",fields:{host:He("host"),jid:oi("jid"),port:Qe("port"),uri:He("uri")},namespace:dn}],qo=[{aliases:[{multiple:!0,path:"message.links"}],element:"x",fields:{description:dt(null,"desc"),url:dt(null,"url")},namespace:hn},{element:"query",fields:{description:dt(null,"desc"),url:dt(null,"url")},namespace:"jabber:iq:oob",path:"iq.transferLink"}],Lo={element:"html",fields:{alternateLanguageBodies:qt(fn,"body","xhtmlim"),body:Pt(fn,"body","xhtmlim")},namespace:mn,path:"message.html"},Fo=[hi({inbandRegistration:yt("http://jabber.org/features/iq-register","register")}),li(Qt,"x",["iq.account.form"]),li(hn,"x",["iq.account.registrationLink"]),{element:"query",fields:{address:dt(null,"address"),date:ft(null,"date"),email:dt(null,"email"),familyName:dt(null,"last"),fullName:dt(null,"name"),givenName:dt(null,"first"),instructions:dt(null,"instructions"),key:dt(null,"key"),locality:dt(null,"city"),misc:dt(null,"misc"),nick:dt(null,"nick"),password:dt(null,"password"),phone:dt(null,"phone"),postalCode:dt(null,"zip"),region:dt(null,"state"),registered:yt(null,"registered"),remove:yt(null,"remove"),text:dt(null,"text"),uri:dt(null,"uri"),username:dt(null,"username")},namespace:"jabber:iq:register",path:"iq.account"}],Mo={aliases:[{path:"message.geoloc",impliedType:!0},{path:"dataform.fields.geoloc",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"geoloc",fields:{accuracy:gt(null,"accuracy"),altitude:gt(null,"alt"),altitudeAccuracy:gt(null,"altaccuracy"),area:dt(null,"area"),building:dt(null,"building"),country:dt(null,"country"),countryCode:dt(null,"countrycode"),datum:dt(null,"datum"),description:dt(null,"description"),error:gt(null,"error"),floor:dt(null,"floor"),heading:gt(null,"bearing"),lang:pt(),latitude:gt(null,"lat"),locality:dt(null,"locality"),longitude:gt(null,"lon"),postalCode:dt(null,"postalcode"),region:dt(null,"region"),room:dt(null,"room"),speed:gt(null,"speed"),street:dt(null,"street"),text:dt(null,"text"),timestamp:ft(null,"timestamp"),tzo:bt(null,"tzo"),uri:dt(null,"uri")},namespace:gn,type:gn},Do=[{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"data",fields:{data:ut("base64")},namespace:vn,path:"avatar",type:vn,typeField:"itemType"},{aliases:[{path:"avatar",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"metadata",namespace:bn,type:bn,typeField:"itemType",childrenExportOrder:{versions:1,pointers:2}},{aliases:[{multiple:!0,path:"avatar.versions",selector:bn}],element:"info",fields:{bytes:Qe("bytes"),height:Qe("height"),id:He("id"),mediaType:He("type"),uri:He("url"),width:Qe("width")},namespace:bn},{aliases:[{multiple:!0,path:"avatar.pointers",selector:bn}],element:"pointer",fields:{bytes:Qe("bytes"),height:Qe("height"),id:He("id"),mediaType:He("type"),width:Qe("width")},namespace:bn}];var Bo=ui({chatState:kt(yn,Object.values(Vr))});const Uo={element:"query",fields:{name:dt(null,"name"),os:dt(null,"os"),version:dt(null,"version")},namespace:"jabber:iq:version",path:"iq.softwareVersion"},zo={aliases:[{path:"message.mood",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"mood",fields:{alternateLanguageText:Ct(null,"text"),text:dt(null,"text"),value:kt(null,Yr)},namespace:_n,type:_n},Jo={aliases:[{path:"activity",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"activity",fields:{activity:It(null,Zr,es),alternateLanguageText:Ct(null,"text"),text:dt(null,"text")},namespace:Sn,type:Sn},Go={element:"handshake",fields:{value:ut("hex")},namespace:"jabber:component:accept",path:"handshake"},Vo={aliases:[{path:"presence.legacyCapabilities",multiple:!0},{path:"features.legacyCapabilities",multiple:!0}],element:"c",fields:{algorithm:He("hash"),legacy:At(!0),node:He("node"),value:He("ver")},namespace:"http://jabber.org/protocol/caps"},$o={aliases:[{impliedType:!0,path:"tune"},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"tune",fields:{artist:dt(null,"artist"),length:mt(null,"length"),rating:mt(null,"rating"),source:dt(null,"source"),title:dt(null,"title"),track:dt(null,"track"),uri:dt(null,"uri")},namespace:wn,type:wn},Ho=["dataformLayout",{multiple:!0,path:"dataformLayout.contents"},{multiple:!0,path:"dataform.layout.contents"}],Wo=[{aliases:[{multiple:!0,path:"dataform.layout"}],element:"page",fields:{label:He("label")},namespace:jn},{aliases:Ho,element:"section",fields:{label:He("label")},namespace:jn,type:"section",typeField:"type"},{aliases:Ho,element:"text",fields:{value:ct()},namespace:jn,type:"text",typeField:"type"},{aliases:Ho,element:"fieldref",fields:{field:He("var")},namespace:jn,type:"fieldref",typeField:"type"},{aliases:Ho,element:"reportedref",namespace:jn,type:"reportedref",typeField:"type"}],Qo={element:"body",fields:{acceptMediaTypes:He("accept"),ack:Qe("ack"),authId:He("authid"),characterSets:He("charsets"),condition:He("condition"),from:oi("from"),key:He("key"),lang:pt(),maxClientRequests:Qe("requests"),maxHoldOpen:Qe("hold"),maxInactivityTime:Qe("inactivity"),maxSessionPause:Qe("maxpause"),maxWaitTime:Qe("wait"),mediaType:He("content"),minPollingInterval:Qe("polling"),newKey:He("newkey"),pauseSession:Qe("pause"),report:Qe("report"),rid:Qe("rid"),route:He("string"),seeOtherURI:dt(null,"uri"),sid:He("sid"),stream:He("stream"),time:Qe("time"),to:oi("to"),type:He("type"),version:He("ver"),xmppRestart:Ze("xmpp","urn:xmpp:xbosh","restart",void 0,{writeValue:e=>e?"true":"false"}),xmppRestartLogic:Ze("xmpp","urn:xmpp:xbosh","restartlogic",void 0,{writeValue:e=>e?"true":"false"}),xmppVersion:Ye("xmpp","urn:xmpp:xbosh","version")},namespace:Tn,path:"bosh"},Ko=[ui({headers:Ot(kn,"headers","header",!0)}),pi({headers:Ot(kn,"headers","header",!0)}),{element:"header",fields:{name:He("name"),value:ct()},namespace:kn,path:"header"}],Xo=[{element:"compression",fields:{methods:jt(null,"method")},namespace:"http://jabber.org/features/compress",path:"features.compression"},{element:"compress",fields:{method:dt(null,"method")},namespace:In,path:"compression",type:"start",typeField:"type"},{aliases:["error.compressionError"],element:"failure",fields:{condition:kt(null,["unsupported-method","setup-failed","processing-failed"])},namespace:In,path:"compression",type:"failure",typeField:"type"},{element:"compressed",namespace:In,path:"compression",type:"success",typeField:"type"}],Yo=[ui({rosterExchange:Ot(En,"x","rosterExchange",!0)}),di({rosterExchange:Ot(En,"x","rosterExchange",!0)}),{element:"item",fields:{action:He("action"),groups:jt(null,"group"),jid:oi("jid"),name:He("name")},namespace:En,path:"rosterExchange"}];var Zo=pi({vcardAvatar:{importer(e){const t=Ce(e,"vcard-temp:x:update","x");if(!t.length)return;const n=Ce(t[0],"vcard-temp:x:update","photo");return!n.length||n[0].getText()},exporter(e,t){const n=Re(e,"vcard-temp:x:update","x");if(""===t)Re(n,"vcard-temp:x:update","photo");else{if(!0===t)return;if(t){Re(n,"vcard-temp:x:update","photo").children.push(t)}}}}});const ea=[ui({captcha:Ot("urn:xmpp:captcha","captcha","dataform")}),di({captcha:Ot("urn:xmpp:captcha","captcha","dataform")})],ta=[fi({jingleError:kt("urn:xmpp:jingle:errors:1",Object.values(Kr))}),{element:"jingle",fields:{action:He("action"),initiator:oi("initiator"),responder:oi("responder"),sid:He("sid")},namespace:Cn,path:"iq.jingle"},{aliases:[{multiple:!0,path:"iq.jingle.contents"}],element:"content",fields:{creator:He("creator"),disposition:He("disposition","session"),name:He("name"),senders:He("senders","both")},namespace:Cn},{element:"reason",fields:{alternativeSession:dt(null,"alternative-session"),condition:kt(null,Object.values(Xr)),text:dt(null,"text")},namespace:Cn,path:"iq.jingle.reason"}];function na(){return{importer(e,t){let n=Ce(e,Gn,"rtcp-fb");const i=He("type").importer,r=He("subtype").importer,s=He("value").importer,o=[];for(const e of n){const n=i(e,t),s=r(e,t);o.push(s?{type:n,parameter:s}:{type:n})}n=Ce(e,Gn,"rtcp-fb-trr-int");for(const e of n){const n=s(e,t);o.push(n?{type:"trr-int",parameter:n}:{type:"trr-int"})}return o},exporter(e,t,n){const i=He("type").exporter,r=He("subtype").exporter,s=He("value").exporter;for(const o of t){let t;"trr-int"===o.type?(t=je(Gn,"rtcp-fb-trr-int",n.namespace,e),o.parameter&&s(t,o.parameter,n)):(t=je(Gn,"rtcp-fb",n.namespace,e),i(t,o.type,n),o.parameter&&r(t,o.parameter,n)),e.appendChild(t)}}}}const ia="iq.jingle.info",ra=[{aliases:["iq.jingle.contents.application"],childrenExportOrder:{codecs:4,encryption:5,headerExtensions:6,sourceGroups:8,sources:7,streams:9},element:"description",fields:{media:He("media"),rtcpFeedback:Object.assign(Object.assign({},na()),{exportOrder:3}),rtcpMux:Object.assign(Object.assign({},yt(null,"rtcp-mux")),{exportOrder:1}),rtcpReducedSize:Object.assign(Object.assign({},yt(null,"rtcp-reduced-size")),{exportOrder:2}),ssrc:He("ssrc")},namespace:Rn,optionalNamespaces:{rtcpf:Gn,rtph:Vn},type:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.headerExtensions",selector:Rn}],element:"rtp-hdrext",fields:{id:Qe("id"),senders:He("senders"),uri:He("uri")},namespace:Vn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.codecs",selector:Rn},"rtpcodec"],element:"payload-type",fields:{channels:Qe("channels"),clockRate:Qe("clockrate"),id:He("id"),maxptime:Qe("maxptime"),name:He("name"),parameters:Lt(Rn,"parameter","name","value"),ptime:Qe("ptime"),rtcpFeedback:na()},namespace:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.sources",selector:Rn}],element:"source",fields:{parameters:Lt("urn:xmpp:jingle:apps:rtp:ssma:0","parameter","name","value"),ssrc:He("ssrc")},namespace:"urn:xmpp:jingle:apps:rtp:ssma:0"},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.sourceGroups",selector:Rn}],element:"ssrc-group",fields:{semantics:He("semantics"),sources:Et(null,"source","ssrc")},namespace:"urn:xmpp:jingle:apps:rtp:ssma:0"},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.streams",selector:Rn}],element:"stream",fields:{id:He("id"),track:He("track")},namespace:"urn:xmpp:jingle:apps:rtp:msid:0"},{aliases:[{path:"iq.jingle.contents.application.encryption",selector:Rn}],element:"encryption",fields:{required:We("required")},namespace:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.encryption.sdes",selector:Rn}],element:"crypto",fields:{cryptoSuite:He("crypto-suite"),keyParameters:He("key-params"),sessionParameters:He("session-params"),tag:Qe("tag")},namespace:Rn},{aliases:[{path:"iq.jingle.contents.application.encryption.zrtp",selector:Rn}],element:"zrtp-hash",fields:{value:ut("hex"),version:He("version")},namespace:Rn},{element:"mute",fields:{creator:He("creator"),name:He("name")},namespace:On,path:ia,type:ns},{element:"unmute",fields:{creator:He("creator"),name:He("name")},namespace:On,path:ia,type:is},{element:"hold",namespace:On,path:ia,type:rs},{element:"unhold",namespace:On,path:ia,type:ss},{element:"active",namespace:On,path:ia,type:os},{element:"ringing",namespace:On,path:ia,type:as}],sa=[ui({nick:dt(An,"nick")}),pi({nick:dt(An,"nick")}),{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"nick",fields:{nick:ct()},namespace:An,type:An}],oa=e=>[{element:"transport",fields:{gatheringComplete:yt(null,"gathering-complete"),password:He("pwd"),usernameFragment:He("ufrag")},namespace:e,path:"iq.jingle.contents.transport",type:e,typeField:"transportType"},{aliases:[{impliedType:!0,path:"iq.jingle.contents.transport.remoteCandidate",selector:e}],element:"remote-candidate",fields:{component:Qe("component"),ip:He("ip"),port:Qe("port")},namespace:e,type:e,typeField:"transportType"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:e}],element:"candidate",fields:{component:Qe("component"),foundation:He("foundation"),generation:Qe("generation"),id:He("id"),ip:He("ip"),network:Qe("network"),port:Qe("port"),priority:Qe("priority"),protocol:He("protocol"),relatedAddress:He("rel-addr"),relatedPort:He("rel-port"),tcpType:He("tcptype"),type:He("type")},namespace:e,type:e,typeField:"transportType"}],aa=[...oa(ni),...oa(Pn)],ca=[{element:"transport",fields:{gatheringComplete:yt(null,"gathering-complete"),password:He("pwd"),usernameFragment:He("ufrag")},namespace:qn,path:"iq.jingle.contents.transport",type:qn,typeField:"transportType"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:qn}],element:"candidate",fields:{component:Qe("component"),foundation:He("foundation"),generation:Qe("generation"),id:He("id"),ip:He("ip"),port:Qe("port"),type:He("type")},namespace:qn,type:qn,typeField:"transportType"}],la=[{element:"request",namespace:"urn:xmpp:receipts",path:"message.receipt",type:"request",typeField:"type"},{element:"received",fields:{id:He("id")},namespace:"urn:xmpp:receipts",path:"message.receipt",type:"received",typeField:"type"}],ua=[{element:"invisible",fields:{probe:We("probe")},namespace:"urn:xmpp:invisible:0",path:"iq.visibility",type:"invisible",typeField:"type"},{element:"visible",namespace:"urn:xmpp:invisible:0",path:"iq.visibility",type:"visible"}],pa=[fi({blocked:yt("urn:xmpp:blocking:errors","blocked")}),{element:"blocklist",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"list",typeField:"action"},{element:"block",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"block",typeField:"action"},{element:"unblock",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"unblock",typeField:"action"}],da=[hi({streamManagement:yt(Ln,"sm")}),{element:"a",fields:{handled:Qe("h")},namespace:Ln,path:"sm",type:"ack",typeField:"type"},{element:"r",namespace:Ln,path:"sm",type:"request",typeField:"type"},{element:"enable",fields:{allowResumption:We("resume")},namespace:Ln,path:"sm",type:"enable",typeField:"type"},{element:"enabled",fields:{id:He("id"),resume:We("resume")},namespace:Ln,path:"sm",type:"enabled",typeField:"type"},{element:"resume",fields:{handled:Qe("h"),previousSession:He("previd")},namespace:Ln,path:"sm",type:"resume",typeField:"type"},{element:"resumed",fields:{handled:Qe("h"),previousSession:He("previd")},namespace:Ln,path:"sm",type:"resumed",typeField:"type"},{element:"failed",fields:{handled:Qe("h")},namespace:Ln,path:"sm",type:"failed",typeField:"type"}];var ha=di({ping:yt("urn:xmpp:ping","ping")});const fa={element:"time",fields:{tzo:bt(null,"tzo"),utc:ft(null,"utc")},namespace:"urn:xmpp:time",path:"iq.time"},ma={aliases:["message.delay","presence.delay"],element:"delay",fields:{from:oi("from"),reason:ct(),timestamp:Xe("stamp")},namespace:Fn},ga={2:"urn:xmpp:extdisco:2",1:"urn:xmpp:extdisco:1"},va=[];for(const[e,t]of Object.entries(ga))va.push({aliases:["iq.externalServiceCredentials"],defaultType:"2",element:"credentials",fields:{expires:at(null,"service","expires"),host:it(null,"service","host"),name:it(null,"service","name"),password:it(null,"service","password"),port:st(null,"service","port"),restricted:rt(null,"service","restricted"),transport:it(null,"service","transport"),type:it(null,"service","type"),username:it(null,"service","username")},namespace:t,type:e,typeField:"version"},{aliases:["iq.externalServices"],defaultType:"2",element:"services",fields:{type:He("type")},namespace:t,type:e,typeField:"version"},{aliases:[{path:"iq.externalServices.services",multiple:!0}],defaultType:"2",element:"service",fields:{expires:Xe("expires"),host:He("host"),name:He("name"),password:He("password"),port:Qe("port"),restricted:We("restricted"),transport:He("transport"),type:He("type"),username:He("username")},namespace:t,type:e,typeField:"version"});const ba=[{element:"media",fields:{height:Qe("height"),width:Qe("width")},namespace:"urn:xmpp:media-element",path:"dataform.fields.media"},{aliases:[{multiple:!0,path:"dataform.fields.media.sources"}],element:"uri",fields:{mediaType:He("type"),uri:ct()},namespace:"urn:xmpp:media-element"}];var ya=ui({requestingAttention:yt("urn:xmpp:attention:0","attention")});const _a={aliases:["iq.bits",{path:"message.bits",multiple:!0},{path:"presence.bits",multiple:!0},{path:"iq.jingle.bits",multiple:!0}],element:"data",fields:{cid:He("cid"),data:ut("base64"),maxAge:Qe("max-age"),mediaType:He("type")},namespace:Mn};let Sa=[li(Hn,"hash",[{path:"file.hashes",multiple:!0},{path:"file.range.hashes",multiple:!0}]),li("urn:xmpp:hashes:1","hash",[{path:"file.hashes",multiple:!0},{path:"file.range.hashes",multiple:!0}]),li(Hn,"hash-used",[{path:"file.hashesUsed",multiple:!0}]),li("urn:xmpp:thumbs:1","thumbnail",[{path:"file.thumbnails",multiple:!0}])];for(const e of["urn:xmpp:jingle:apps:file-transfer:4",Dn])Sa=Sa.concat([{aliases:["file",{impliedType:!0,path:"iq.jingle.contents.application.file",selector:e},{impliedType:!0,path:"iq.jingle.info.file",selector:`{${e}}checksum`}],defaultType:Dn,element:"file",fields:{date:ft(null,"date"),description:dt(null,"desc"),mediaType:dt(null,"media-type"),name:dt(null,"name"),size:mt(null,"size")},namespace:e,type:e,typeField:"version"},{aliases:[{impliedType:!0,path:"file.range",selector:e}],defaultType:Dn,element:"range",fields:{length:Qe("length"),offset:Qe("offset",0)},namespace:e,type:e,typeField:"version"},{element:"description",namespace:e,path:"iq.jingle.contents.application",type:e,typeField:"applicationType"},{element:"received",fields:{creator:He("creator"),name:He("name")},namespace:e,path:"iq.jingle.info",type:`{${e}}received`,typeField:"infoType"},{element:"checksum",fields:{creator:He("creator"),name:He("name")},namespace:e,path:"iq.jingle.info",type:`{${e}}checksum`,typeField:"infoType"}]);var wa=Sa;const xa={element:"description",namespace:Bn,path:"iq.jingle.contents.application",type:Bn,typeField:"applicationType"},Ta=[{element:"transport",fields:{activated:it(null,"activated","cid"),address:He("dstaddr"),candidateError:yt(null,"candidate-error"),candidateUsed:it(null,"candidate-used","cid"),mode:He("mode","tcp"),proxyError:yt(null,"proxy-error"),sid:He("sid")},namespace:Un,path:"iq.jingle.contents.transport",type:Un,typeField:"transportType"},{aliases:[{multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:Un}],element:"candidate",fields:{cid:He("cid"),host:He("host"),jid:oi("jid"),port:Qe("port"),priority:Qe("priority"),type:He("type"),uri:He("uri")},namespace:Un}],ka={element:"transport",fields:{ack:{importer:(e,t)=>"message"!==He("stanza","iq").importer(e,t),exporter(e,t,n){!1===t&&He("stanza").exporter(e,"message",n)}},blockSize:Qe("block-size"),sid:He("sid")},namespace:zn,path:"iq.jingle.contents.transport",type:zn,typeField:"transportType"},Ia=[li(Mn,"data",[{path:"iq.jingle.bits",multiple:!0}]),{element:"thumbnail",fields:{height:Qe("height"),mediaType:He("media-type"),uri:He("uri"),width:Qe("width")},namespace:"urn:xmpp:thumbs:1",path:"thumbnail"}],ja=[li($n,"forwarded",["message.carbon.forward"]),{element:"enable",namespace:Jn,path:"iq.carbons",type:"enable",typeField:"action"},{element:"disable",namespace:Jn,path:"iq.carbons",type:"disable",typeField:"action"},{element:"sent",namespace:Jn,path:"message.carbon",type:"sent",typeField:"type"},{element:"received",namespace:Jn,path:"message.carbon",type:"received",typeField:"type"}],Ea=[...Object.values(Fr).map(e=>li(e,"message",["forward.message"])),...Object.values(Fr).map(e=>li(e,"presence",["forward.presence"])),...Object.values(Fr).map(e=>li(e,"iq",["forward.iq"])),li(Fn,"delay",["forward.delay"]),{aliases:["message.forward"],element:"forwarded",namespace:$n,path:"forward"}],Na=[{defaultType:"2",element:"hash",fields:{algorithm:He("algo"),value:ut("base64"),version:At("2")},namespace:Hn,path:"hash",type:"2",typeField:"version"},{element:"hash-used",fields:{algorithm:He("algo"),version:At("2")},namespace:Hn,path:"hashUsed"},{element:"hash",fields:{algorithm:He("algo"),value:ut("hex"),version:At("1")},namespace:"urn:xmpp:hashes:1",path:"hash",type:"1",typeField:"version"}],Ca=[{element:"rtt",fields:{event:He("event","edit"),id:He("id"),seq:Qe("seq")},namespace:Qn,path:"message.rtt"},{aliases:[{path:"message.rtt.actions",multiple:!0}],element:"t",fields:{position:Qe("p"),text:ct()},namespace:Qn,type:"insert",typeField:"type"},{aliases:[{path:"message.rtt.actions",multiple:!0}],element:"e",fields:{length:Qe("n",1),position:Qe("p")},namespace:Qn,type:"erase",typeField:"type"},{aliases:[{multiple:!0,path:"message.rtt.actions"}],element:"w",fields:{duration:Qe("n",0)},namespace:Qn,type:"wait",typeField:"type"}];var Ra=ui({replace:it("urn:xmpp:message-correct:0","replace","id")});const Oa={2:"urn:xmpp:mam:2",1:"urn:xmpp:mam:1"},Aa=[li(Qt,"x",["iq.archive.form"]),li($n,"forwarded",["message.archive.item"]),li(an,"set",["iq.archive.paging"])];for(const[e,t]of Object.entries(Oa))Aa.push({defaultType:"query",defaultVersion:"2",element:"query",fields:{node:He("node"),queryId:He("queryid")},namespace:t,path:"iq.archive",type:"query",typeField:"type",version:e,versionField:"version"},{element:"fin",fields:{complete:We("complete"),stable:We("stable")},namespace:t,path:"iq.archive",type:"result",version:e},{element:"prefs",fields:{default:He("default"),always:Tt([{namespace:null,element:"always"},{namespace:null,element:"jid"}]),never:Tt([{namespace:null,element:"never"},{namespace:null,element:"jid"}])},namespace:t,path:"iq.archive",type:"preferences",version:e},{element:"result",defaultType:"2",fields:{id:He("id"),queryId:He("queryid")},namespace:t,path:"message.archive",type:e,typeField:"version"});const Pa="message.marker";const qa=[to,no,po,ho,fo,mo,go,vo,bo,yo,_o,So,wo,xo,To,jo,Eo,No,Oo,Po,qo,Lo,Fo,Mo,Do,Bo,Uo,zo,Jo,Go,Vo,$o,Qo,Ko,Xo,Wo,Yo,Zo,ea,ta,ra,sa,aa,ca,la,ua,pa,da,ha,fa,ma,va,ba,ya,_a,wa,xa,Ta,ka,Ia,ja,Ea,Na,Ca,Ra,Aa,[pi({hats:Ot(Kn,"hats","hat",!0)}),{element:"hat",fields:{id:He("name"),name:He("displayName")},namespace:Kn,path:"hat"}],pi({idleSince:ft("urn:xmpp:idle:1","since")}),{aliases:[{multiple:!0,path:"iq.jingle.contents.transport.fingerprints",selector:Pn},{multiple:!0,path:"iq.jingle.contents.transport.fingerprints",selector:ni},{multiple:!0,path:"iq.jingle.contents.application.encryption.dtls",selector:Rn}],element:"fingerprint",fields:{algorithm:He("hash"),setup:He("setup"),value:ct()},namespace:"urn:xmpp:jingle:apps:dtls:0"},[{element:"markable",namespace:Xn,path:Pa,type:"markable",typeField:"type"},{element:"received",fields:{id:He("id")},namespace:Xn,path:Pa,type:"received"},{element:"displayed",fields:{id:He("id")},namespace:Xn,path:Pa,type:"displayed"},{element:"acknowledged",fields:{id:He("id")},namespace:Xn,path:Pa,type:"acknowledged"}],ui({processingHints:{importer(e){const t={};let n=!1;for(const i of e.children)if("string"!=typeof i&&i.getNamespace()===Yn)switch(i.getName()){case"no-copy":t.noCopy=!0,n=!0;break;case"no-permanent-store":t.noPermanentStore=!0,n=!0;break;case"no-store":t.noStore=!0,n=!0;break;case"store":t.store=!0,n=!0}return n?t:void 0},exporter(e,t,n){t.noCopy&&e.appendChild(je(Yn,"no-copy",n.namespace,e)),t.noPermanentStore&&e.appendChild(je(Yn,"no-permanent-store",n.namespace,e)),t.noStore&&e.appendChild(je(Yn,"no-store",n.namespace,e)),t.store&&e.appendChild(je(Yn,"store",n.namespace,e))}}}),[ui({json:vt(Zn,"json")}),{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"json",fields:{json:lt()},namespace:Zn,type:Zn},{aliases:[{path:"message.jsonPayloads",multiple:!0}],element:"payload",fields:{type:He("datatype"),data:vt(Zn,"json")},namespace:"urn:xmpp:json-msg:0"}],[{aliases:[{path:"iq.jingle.groups",multiple:!0}],element:"group",fields:{contents:Et(null,"content","name"),semantics:He("semantics")},namespace:"urn:xmpp:jingle:apps:grouping:0"}],{aliases:[{path:"iq.jingle.contents.transport.sctp",selector:Pn},{path:"iq.jingle.contents.transport.sctp",selector:ni}],element:"sctpmap",fields:{port:Qe("number"),protocol:He("protocol"),streams:He("streams")},namespace:"urn:xmpp:jingle:transports:dtls-sctp:1"},[{element:"active",namespace:"urn:xmpp:csi:0",path:"csi",type:"active",typeField:"state"},{element:"inactive",namespace:"urn:xmpp:csi:0",path:"csi",type:"inactive",typeField:"state"}],[li(Qt,"x",["iq.push.form","pushNotification.form"]),{element:"enable",fields:{jid:oi("jid"),node:He("node")},namespace:ei,path:"iq.push",type:"enable",typeField:"action"},{element:"disable",fields:{jid:oi("jid"),node:He("node")},namespace:ei,path:"iq.push",type:"disable",typeField:"action"},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"notification",namespace:ei,path:"pushNotification",type:ei,typeField:"itemType"}],[ui({originId:it("urn:xmpp:sid:0","origin-id","id")}),{aliases:[{path:"message.stanzaIds",multiple:!0}],element:"stanza-id",fields:{by:oi("by"),id:He("id")},namespace:"urn:xmpp:sid:0"}],[fi({httpUploadError:kt(ti,["file-too-large","retry"]),httpUploadMaxFileSize:wt([{namespace:ti,element:"file-too-large"},{namespace:ti,element:"max-file-size"}]),httpUploadRetry:at(ti,"retry","stamp")}),{element:"request",fields:{mediaType:He("content-type"),name:He("filename"),size:Qe("size")},namespace:ti,path:"iq.httpUpload",type:"request",typeField:"type"},{element:"slot",fields:{download:it(null,"get","url")},namespace:ti,path:"iq.httpUpload",type:"slot"},{aliases:[{path:"iq.httpUpload.upload",selector:"slot"}],element:"put",fields:{url:He("url")},namespace:ti},{aliases:[{path:"iq.httpUpload.upload.headers",multiple:!0}],element:"header",fields:{name:He("name"),value:ct()},namespace:ti}],{element:"encryption",fields:{id:He("namespace"),name:He("name")},namespace:"urn:xmpp:eme:0",path:"message.encryptionMethod"},[{aliases:["message.omemo"],element:"encrypted",fields:{payload:ht(null,"payload","base64")},namespace:ii,path:"omemo"},{element:"header",fields:{iv:ht(null,"iv","base64"),sid:Qe("sid")},namespace:ii,path:"omemo.header"},{aliases:[{path:"omemo.header.keys",multiple:!0}],element:"key",fields:{preKey:We("prekey"),rid:Qe("rid"),value:ut("base64")},namespace:ii},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"list",fields:{devices:Nt(null,"device","id")},namespace:ii,type:"eu.siacs.conversations.axolotl.devicelist",typeField:"itemType"},{element:"preKeyPublic",fields:{id:Qe("preKeyId"),value:ut("base64")},namespace:ii,path:"omemoPreKey"},{element:"signedPreKeyPublic",fields:{id:Qe("signedPreKeyId"),value:ut("base64")},namespace:ii,path:"omemoDevice.signedPreKeyPublic"},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"bundle",fields:{identityKey:ht(null,"identityKey","base64"),preKeys:Ot(null,"prekeys","omemoPreKey",!0),signedPreKeySignature:ht(null,"signedPreKeySignature","base64")},namespace:ii,path:"omemoDevice",type:"eu.siacs.conversations.axolotl.bundles",typeField:"itemType"}],[{element:"XRD",fields:{subject:dt(null,"Subject")},namespace:ri,path:"xrd"},{aliases:[{path:"xrd.links",multiple:!0}],element:"Link",fields:{href:He("href"),rel:He("rel"),type:He("type")},namespace:ri}]];var La=Object.freeze({__proto__:null,default:qa});class Fa{constructor(e){this.active=!1,this.maxRetries=5,this.stream=e,this.maxTimeout=1100*this.stream.maxWaitTime}send(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.rid=e,this.active=!0;let n=0;for(;n<=this.maxRetries;){n+=1;try{const e=yield xr(Zi(this.stream.url,{body:t,headers:{"Content-Type":this.stream.contentType},method:"POST"}),this.maxTimeout,()=>new Error("Request timed out"));if(!e.ok)throw new Error("HTTP Status Error: "+e.status);const n=yield e.text();return this.active=!1,n}catch(e){if(1===n)continue;if(n<this.maxRetries){const e=Math.min(this.maxTimeout,1e3*Math.pow(n,2));yield Tr(e+1e3*Math.random());continue}throw this.active=!1,e}}throw new Error("Request failed")}))}}class Ma extends l.Duplex{constructor(e,t,n){super({objectMode:!0}),this.rid=Math.floor(4294967295*Math.random()),this.sid="",this.maxHoldOpen=2,this.maxWaitTime=30,this.contentType="text/xml; charset=utf-8",this.channels=[new Fa(this),new Fa(this)],this.activeChannelID=0,this.queue=[],this.isEnded=!1,this.client=e,this.sm=t,this.stanzas=n,this.on("data",e=>{this.client.emit("stream:data",e.stanza,e.kind)}),this.on("end",()=>{this.isEnded=!0,clearTimeout(this.idleTimeout),this.client.transport===this&&this.client.emit("--transport-disconnected")})}_write(e,t,n){this.queue.push([e,n]),this.scheduleRequests()}_writev(e,t){this.queue.push([e.map(e=>e.chunk).join(""),t]),this.scheduleRequests()}_read(){}process(e){const t=new gi({acceptLanguages:this.config.acceptLanguages,allowComments:!1,lang:this.config.lang,registry:this.stanzas,rootKey:"bosh",wrappedStream:!0});t.on("error",e=>{const t={condition:Dr.InvalidXML};return this.client.emit("stream:error",t,e),this.send("error",t),this.disconnect()}),t.on("data",e=>{if("stream-start"===e.event)return this.stream=e.stanza,void("terminate"===e.stanza.type?(this.hasStream=!1,this.rid=void 0,this.sid=void 0,this.isEnded||(this.isEnded=!0,this.client.emit("bosh:terminate",e.stanza),this.client.emit("stream:end"),this.push(null))):this.hasStream||(this.hasStream=!0,this.stream=e.stanza,this.sid=e.stanza.sid||this.sid,this.maxWaitTime=e.stanza.maxWaitTime||this.maxWaitTime,this.client.emit("stream:start",e.stanza)));e.event||this.push({kind:e.kind,stanza:e.stanza})}),this.client.emit("raw","incoming",e),t.write(e),this.scheduleRequests()}connect(e){if(this.config=e,this.url=e.url,e.rid&&(this.rid=e.rid),e.sid&&(this.sid=e.sid),e.wait&&(this.maxWaitTime=e.wait),e.maxHoldOpen&&(this.maxHoldOpen=e.maxHoldOpen),this.sid)return this.hasStream=!0,this.stream={},this.client.emit("connected"),this.client.emit("session:prebind",this.config.jid),void this.client.emit("session:started");this._send({lang:e.lang,maxHoldOpen:this.maxHoldOpen,maxWaitTime:this.maxWaitTime,to:e.server,version:"1.6",xmppVersion:"1.0"})}restart(){this.hasStream=!1,this._send({to:this.config.server,xmppRestart:!0})}disconnect(e=!0){this.hasStream&&e?this._send({type:"terminate"}):(this.stream=void 0,this.sid=void 0,this.rid=void 0,this.client.emit("--transport-disconnected"))}send(e,t){var n;return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;if(t&&(i=null===(n=this.stanzas.export(e,t))||void 0===n?void 0:n.toString()),i)return new Promise((e,t)=>{this.write(i,"utf8",n=>n?t(n):e())})}))}get sendingChannel(){return this.channels[this.activeChannelID]}get pollingChannel(){return this.channels[0===this.activeChannelID?1:0]}toggleChannel(){this.activeChannelID=0===this.activeChannelID?1:0}_send(e,t=""){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isEnded)return;const n=this.rid++,i=this.stanzas.export("bosh",Object.assign(Object.assign({},e),{rid:n,sid:this.sid}));let r;r=t?[i.openTag(),t,i.closeTag()].join(""):i.toString(),this.client.emit("raw","outgoing",r),this.sendingChannel.send(n,r).then(e=>{this.process(e)}).catch(e=>{this.end(e)}),this.toggleChannel()}))}_poll(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isEnded)return;const e=this.rid++,t=this.stanzas.export("bosh",{rid:e,sid:this.sid}).toString();this.client.emit("raw","outgoing",t),this.pollingChannel.send(e,t).then(e=>{this.process(e)}).catch(e=>{this.end(e)})}))}scheduleRequests(){clearTimeout(this.idleTimeout),this.idleTimeout=setTimeout(()=>{this.fireRequests()},10)}fireRequests(){if(!this.isEnded)if(this.queue.length)if(this.sendingChannel.active)this.scheduleRequests();else{const[e,t]=this.queue.shift();this._send({},e),t()}else!this.authenticated||this.channels[0].active||this.channels[1].active||this._poll()}}class Da extends l.Duplex{constructor(e,t,n){super({objectMode:!0}),this.sm=t,this.stanzas=n,this.closing=!1,this.client=e,this.on("data",e=>{this.client.emit("stream:data",e.stanza,e.kind)}),this.on("error",()=>{this.end()}),this.on("end",()=>{this.client.transport===this&&this.client.emit("--transport-disconnected")})}_read(){}_write(t,n,i){if(!this.socket||1!==this.socket.readyState)return i(new Error("Socket closed"));const r=e.from(t,"utf8").toString();this.client.emit("raw","outgoing",r),this.socket.send(r),i()}connect(t){this.config=t,this.hasStream=!1,this.closing=!1,this.parser=new gi({acceptLanguages:this.config.acceptLanguages,allowComments:!1,lang:this.config.lang,registry:this.stanzas,wrappedStream:!1}),this.parser.on("data",e=>{const t=e.kind,n=e.stanza;if("stream"===t){if("open"===n.action)return this.hasStream=!0,this.stream=n,this.client.emit("stream:start",n);if("close"===n.action)return this.client.emit("stream:end"),this.disconnect()}this.push({kind:e.kind,stanza:e.stanza})}),this.parser.on("error",e=>{const t={condition:Dr.InvalidXML};return this.client.emit("stream:error",t,e),this.write(this.stanzas.export("error",t).toString()),this.disconnect()}),this.socket=new er(t.url,"xmpp"),this.socket.onopen=()=>{this.emit("connect"),this.sm.started=!1,this.client.emit("connected"),this.write(this.startHeader())},this.socket.onmessage=t=>{const n=e.from(t.data,"utf8").toString();this.client.emit("raw","incoming",n),this.parser&&this.parser.write(n)},this.socket.onclose=()=>{this.push(null)}}disconnect(e=!0){this.socket&&!this.closing&&this.hasStream&&e?(this.closing=!0,this.write(this.closeHeader())):(this.hasStream=!1,this.stream=void 0,this.socket&&(this.end(),this.socket.close(),this.client.transport===this&&this.client.emit("--transport-disconnected")),this.socket=void 0)}send(e,t){var n;return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;if(t&&(i=null===(n=this.stanzas.export(e,t))||void 0===n?void 0:n.toString()),i)return new Promise((e,t)=>{this.write(i,"utf8",n=>n?t(n):e())})}))}restart(){this.hasStream=!1,this.write(this.startHeader())}startHeader(){return this.stanzas.export("stream",{action:"open",lang:this.config.lang,to:this.config.server,version:"1.0"}).toString()}closeHeader(){return this.stanzas.export("stream",{action:"close"}).toString()}}class Ba extends o.EventEmitter{constructor(e={}){super(),this.reconnectAttempts=0,this.setMaxListeners(100),this.off=this.removeListener,this.updateConfig(e),this.jid="",this.sasl=new ir,this.sasl.register("EXTERNAL",dr,1e3),this.sasl.register("SCRAM-SHA-256-PLUS",gr,350),this.sasl.register("SCRAM-SHA-256",gr,300),this.sasl.register("SCRAM-SHA-1-PLUS",gr,250),this.sasl.register("SCRAM-SHA-1",gr,200),this.sasl.register("DIGEST-MD5",mr,100),this.sasl.register("OAUTHBEARER",fr,100),this.sasl.register("X-OAUTH2",hr,50),this.sasl.register("PLAIN",hr,1),this.sasl.register("ANONYMOUS",pr,0),this.stanzas=new Mt,this.stanzas.define(qa),this.use(Zs),this.sm=new h,void 0!==this.config.allowResumption&&(this.sm.allowResume=this.config.allowResumption),this.sm.on("prebound",e=>{this.jid=e,this.emit("session:bound",e)}),this.on("session:bound",e=>this.sm.bind(e)),this.sm.on("send",e=>this.send("sm",e)),this.sm.on("acked",e=>this.emit("stanza:acked",e)),this.sm.on("failed",e=>this.emit("stanza:failed",e)),this.sm.on("hibernated",e=>this.emit("stanza:hibernated",e)),this.sm.on("begin-resend",()=>this.outgoingDataQueue.pause()),this.sm.on("resend",({kind:e,stanza:t})=>this.send(e,t,!0)),this.sm.on("end-resend",()=>this.outgoingDataQueue.resume());for(const e of["acked","hibernated","failed"])this.on("stanza:"+e,t=>{"message"===t.kind&&this.emit("message:"+e,t.stanza)});this.transports={bosh:Ma,websocket:Da},this.incomingDataQueue=Object(s.priorityQueue)((e,t)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const{kind:n,stanza:i}=e;this.emit(n,i),i.id&&this.emit(n+":id:"+i.id,i),"message"===n||"presence"===n||"iq"===n?(this.emit("stanza",i),yield this.sm.handle()):"sm"===n&&("ack"===i.type&&(yield this.sm.process(i),this.emit("stream:management:ack",i)),"request"===i.type&&this.sm.ack()),t&&t()})),1);const t=(e,t)=>{["message","presence","iq"].includes(e)&&(this.sm.started&&this.sm.resumable?this.sm.resumable&&!this.transport&&this.emit("stanza:hibernated",{kind:e,stanza:t}):this.emit("stanza:failed",{kind:e,stanza:t}))};this.outgoingDataQueue=Object(s.priorityQueue)((e,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){var i;const{kind:r,stanza:s,replay:o}=e,a=o||(yield this.sm.track(r,s));if("message"===r&&(o?this.emit("message:retry",s):this.emit("message:sent",s,!1)),this.transport)try{yield this.transport.send(r,s),a&&(null===(i=this.transport)||void 0===i||i.send("sm",{type:"request"}))}catch(e){console.error(e),t(r,s)}else t(r,s);n&&n()})),1),this.on("stream:data",(e,t)=>{this.incomingDataQueue.push({kind:t,stanza:e},0)}),this.on("--transport-disconnected",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=[];this.incomingDataQueue.idle()||e.push(this.incomingDataQueue.drain()),this.outgoingDataQueue.idle()||e.push(this.outgoingDataQueue.drain()),yield Promise.all(e),yield this.sm.hibernate(),this.transport&&delete this.transport,this.emit("--reset-stream-features"),!this.sessionTerminating&&this.config.autoReconnect&&(this.reconnectAttempts+=1,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.connect()},1e3*Math.min(Math.pow(2,this.reconnectAttempts)+Math.random(),this.config.maxReconnectBackoff||32))),this.emit("disconnected")}))),this.on("iq",e=>{const t=e.type,n=e.payloadType,i="iq:"+t+":"+n;if("get"===t||"set"===t){if("invalid-payload-count"===n)return this.sendIQError(e,{error:{condition:"bad-request",type:"modify"}});if("unknown-payload"===n||0===this.listenerCount(i))return this.sendIQError(e,{error:{condition:"service-unavailable",type:"cancel"}});this.emit(i,e)}}),this.on("message",e=>{const t=e.alternateLanguageBodies&&e.alternateLanguageBodies.length||e.links&&e.links.length,n=e.marker&&"markable"!==e.marker.type;t&&!n&&("chat"===e.type||"normal"===e.type?this.emit("chat",e):"groupchat"===e.type&&this.emit("groupchat",e)),"error"===e.type&&this.emit("message:error",e)}),this.on("presence",e=>{let t=e.type||"available";"error"===t&&(t="presence:error"),this.emit(t,e)}),this.on("session:started",()=>{this.sessionStarting=!1,this.reconnectAttempts=0,this.reconnectTimer&&clearTimeout(this.reconnectTimer)})}updateConfig(e={}){const t=this.config||{};this.config=Object.assign(Object.assign({allowResumption:!0,jid:"",transports:{bosh:!0,websocket:!0},useStreamManagement:!0},t),e),this.config.server||(this.config.server=W(this.config.jid)),this.config.password&&(this.config.credentials=this.config.credentials||{},this.config.credentials.password=this.config.password,delete this.config.password)}get stream(){return this.transport?this.transport.stream:void 0}emit(e,...t){const n=super.emit(e,...t);return"raw"===e?(super.emit("raw:"+t[0],t[1]),super.emit("raw:*","raw:"+t[0],t[1]),super.emit("*","raw:"+t[0],t[1])):super.emit("*",e,...t),n}use(e){"function"==typeof e&&e(this,this.stanzas,this.config)}nextId(){return Ir()}getCredentials(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this._getConfiguredCredentials()}))}connect(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.sessionTerminating=!1,this.sessionStarting=!0,this.emit("--reset-stream-features"),this.transport&&this.transport.disconnect(!1);const e=["websocket","bosh"];let t;for(const n of e){let e=this.config.transports[n];if(e){if("string"==typeof e)e={url:e};else if(!0===e){if(!t)try{t=yield this.discoverBindings(this.config.server)}catch(e){console.error(e);continue}if(t[n]=(t[n]||[]).filter(e=>e.startsWith("wss:")||e.startsWith("https:")),!t[n]||!t[n].length)continue;e={url:t[n][0]}}return this.transport=new this.transports[n](this,this.sm,this.stanzas),void this.transport.connect(Object.assign({acceptLanguages:this.config.acceptLanguages||["en"],jid:this.config.jid,lang:this.config.lang||"en",server:this.config.server,url:e.url},e))}}console.error("No endpoints found for the requested transports."),this.emit("--transport-disconnected")}))}disconnect(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.sessionTerminating=!0,clearTimeout(this.reconnectTimer),this.outgoingDataQueue.pause(),this.sessionStarted&&!this.sm.started&&this.emit("session:end"),this.emit("--reset-stream-features"),this.sessionStarted=!1,this.transport?this.transport.disconnect():this.emit("--transport-disconnected"),this.outgoingDataQueue.resume(),this.outgoingDataQueue.idle()||(yield this.outgoingDataQueue.drain()),yield this.sm.shutdown()}))}send(e,t,n=!1){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return new Promise((i,r)=>{this.outgoingDataQueue.push({kind:e,stanza:t,replay:n},n?0:1,e=>e?r(e):i())})}))}sendMessage(e){const t=e.id||this.nextId(),n=Object.assign({id:t,originId:t},e);return this.send("message",n),n.id}sendPresence(e={}){const t=Object.assign({id:this.nextId()},e);return this.send("presence",t),t.id}sendIQ(e){const t=Object.assign({id:this.nextId()},e),n=V(this.jid,e.to),i="iq:id:"+t.id,r=new Promise((e,t)=>{const r=s=>{n.has(s.from)&&("result"!==s.type&&"error"!==s.type||(this.off(i,r),"result"===s.type?e(s):t(s)))};this.on(i,r)});this.send("iq",t);const s=this.config.timeout||15;return xr(r,1e3*s,()=>Object.assign(Object.assign({},t),{to:void 0,from:void 0,error:{condition:"timeout",text:`Request timed out after ${s} seconds.`},id:t.id,type:"error"}))}sendIQResult(e,t){this.send("iq",Object.assign(Object.assign({},t),{id:e.id,to:e.from,type:"result"}))}sendIQError(e,t){this.send("iq",Object.assign(Object.assign({},t),{id:e.id,to:e.from,type:"error"}))}sendStreamError(e){this.emit("stream:error",e),this.send("error",e),this.disconnect()}_getConfiguredCredentials(){const e=this.config.credentials||{},t=G(this.config.jid||""),n=e.username||t.local,i=e.host||t.domain;return Object.assign({host:i,password:this.config.password,realm:i,serviceName:i,serviceType:"xmpp",username:n},e)}}function Ua(e,t){const n=e.length,i=t.length,r=Math.min(n,i);let s=0;for(s=0;s<r&&e[s]===t[s];s++);let o=0;for(o=0;o<r-s&&e[n-o-1]===t[i-o-1];o++);const a=s+o,l=[];if(a<n&&l.push({length:n-a,position:n-o,type:"erase"}),a<i){const e=t.slice(s,s+i-a);l.push({position:s,text:c.a.ucs2.encode(e),type:"insert"})}return l}var za=Object.freeze({__proto__:null,diff:Ua,DisplayBuffer:class{constructor(e,t=!1){this.synced=!1,this.cursorPosition=0,this.ignoreWaits=!1,this.timeDeficit=0,this.sequenceNumber=0,this.onStateChange=e||function(){},this.ignoreWaits=t,this.buffer=[],this.resetActionQueue()}get text(){return c.a.ucs2.encode(this.buffer.slice())}commit(){this.resetActionQueue()}process(e){if("cancel"!==e.event&&"init"!==e.event){if("reset"===e.event||"new"===e.event?(this.resetActionQueue(),void 0!==e.seq&&(this.sequenceNumber=e.seq)):e.seq!==this.sequenceNumber&&(this.synced=!1),e.actions){const t=Date.now();let n=0;for(const i of e.actions)i.baseTime=t+n,"wait"===i.type&&(n+=i.duration),this.actionQueue.push(i,0)}this.sequenceNumber=this.sequenceNumber+1}else this.resetActionQueue()}insert(e="",t=this.buffer.length){e=e.normalize("NFC");const n=c.a.ucs2.decode(e);this.buffer.splice(t,0,...n),this.cursorPosition=t+n.length,this.emitState()}erase(e=1,t=this.buffer.length){t=Math.max(Math.min(t,this.buffer.length),0),e=Math.max(Math.min(e,this.text.length),0),this.buffer.splice(Math.max(t-e,0),e),this.cursorPosition=Math.max(t-e,0),this.emitState()}emitState(e={}){this.onStateChange(Object.assign({cursorPosition:this.cursorPosition,synced:this.synced,text:this.text},e))}resetActionQueue(){this.actionQueue&&this.actionQueue.kill(),this.sequenceNumber=0,this.synced=!0,this.buffer=[],this.timeDeficit=0,this.actionQueue=Object(s.priorityQueue)((e,t)=>{const n=Date.now();if("insert"===e.type)return this.insert(e.text,e.position),t();if("erase"===e.type)return this.erase(e.length,e.position),t();if("wait"!==e.type)return t();{if(this.ignoreWaits)return t();e.duration>700&&(e.duration=700);const i=e.duration-(n-e.baseTime)+this.timeDeficit;if(i<=0)return this.timeDeficit=i,t();this.timeDeficit=0,setTimeout(()=>t(),i)}},1),this.emitState()}},InputBuffer:class{constructor(e,t=!1){this.resetInterval=1e4,this.ignoreWaits=!1,this.isStarting=!1,this.isReset=!1,this.changedBetweenResets=!1,this.onStateChange=e||function(){},this.ignoreWaits=t,this.buffer=[],this.actionQueue=[],this.sequenceNumber=0}get text(){return c.a.ucs2.encode(this.buffer.slice())}update(e){let t=[];if(void 0!==e){e=e.normalize("NFC");const n=c.a.ucs2.decode(e);t=Ua(this.buffer,n.slice()),this.buffer=n,this.emitState()}const n=Date.now();if(this.changedBetweenResets&&n-this.lastResetTime>this.resetInterval)this.actionQueue=[],this.actionQueue.push({position:0,text:this.text,type:"insert"}),this.isReset=!0,this.lastActionTime=n,this.lastResetTime=n,this.changedBetweenResets=!1;else if(t.length){const e=n-(this.lastActionTime||n);e>0&&!this.ignoreWaits&&this.actionQueue.push({duration:e,type:"wait"});for(const e of t)this.actionQueue.push(e);this.lastActionTime=n,this.changedBetweenResets=!0}else this.lastActionTime=n}start(e=this.resetInterval){return this.commit(),this.isStarting=!0,this.resetInterval=e,this.sequenceNumber=Math.floor(1e4*Math.random()+1),{event:"init"}}stop(){return this.commit(),{event:"cancel"}}diff(){if(this.update(),!this.actionQueue.length)return null;const e={actions:this.actionQueue,seq:this.sequenceNumber++};return this.isStarting?(e.event="new",this.isStarting=!1,this.lastResetTime=Date.now()):this.isReset&&(e.event="reset",this.isReset=!1),this.actionQueue=[],e}commit(){this.sequenceNumber=0,this.lastActionTime=0,this.actionQueue=[],this.buffer=[]}emitState(){this.onStateChange({text:this.text})}}});class Ja{constructor(e){var t,n,i;this.resultComplete=!1,this.fetchedCount=0,this.yieldedCount=0,this.cursor={first:e.before,last:e.after},this.query=e.query,this.direction=null!==(t=e.direction)&&void 0!==t?t:"forward",this.reverse=null!==(n=e.reverse)&&void 0!==n?n:"backward"===this.direction,this.pageSize=null!==(i=e.pageSize)&&void 0!==i?i:20}[Symbol.asyncIterator](){return Object(r.__asyncGenerator)(this,arguments,(function*(){let e=[];do{e=yield Object(r.__await)(this.fetchPage());for(const t of e)this.yieldedCount+=1,yield yield Object(r.__await)(t)}while(e.length>0)}))}size(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(void 0!==this.resultCount)return this.resultCount;const{paging:e}=yield this.query({max:0});return this.resultCount=e.count,e.count}))}queryCompleted(){return this.resultComplete}finished(){return this.resultComplete&&this.yieldedCount===this.fetchedCount}fetchPage(){var e;return Object(r.__awaiter)(this,void 0,void 0,(function*(){const{results:t,paging:n}=yield this.query({before:"backward"===this.direction?null!==(e=this.cursor.first)&&void 0!==e?e:"":void 0,after:"forward"===this.direction?this.cursor.last:void 0,max:this.pageSize});return this.cursor=n,this.resultCount=n.count,this.fetchedCount+=t.length,(this.pageSize&&t.length<this.pageSize||this.resultCount&&this.fetchedCount===this.resultCount)&&(this.resultComplete=!0),this.reverse&&t.reverse(),t}))}}var Ga=Object.freeze({__proto__:null,ResultSetPager:Ja,createPager:function(e){return new Ja(e)}});const Va="12.17.2";function $a(e){const t=new Ba(e);return t.use(eo),t}}.call(this,n(10).Buffer,n(5))},function(e,t,n){"use strict";t.byteLength=function(e){var t=l(e),n=t[0],i=t[1];return 3*(n+i)/4-i},t.toByteArray=function(e){var t,n,i=l(e),o=i[0],a=i[1],c=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),u=0,p=a>0?o-4:o;for(n=0;n<p;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[u++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=0,a=n-r;o<a;o+=16383)s.push(u(e,o,o+16383>a?a:o+16383));1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)i[a]=o[a],r[o.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,n){for(var r,s,o=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(i[(s=r)>>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(e,t){
|
|
38
|
+
var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function r(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return(s=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function o(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function a(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function c(e,t){return function(n,i){t(n,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function p(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function d(e,t){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function f(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}function g(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i}function v(e){return this instanceof v?(this.v=e,this):new v(e)}function b(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof v?Promise.resolve(n.value.v).then(c,l):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function y(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:v(e[i](t)),done:"return"===i}:r?r(t):t}:r}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=h(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function w(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function x(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(24);class r{constructor(e,t={},n=[]){this.name=e,this.attributes=t,this.children=[],this.optionalNamespaces={};for(const e of n)if("string"!=typeof e){const t=new r(e.name,e.attributes,e.children);t.parent=this,this.children.push(t)}else this.children.push(e)}getName(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name}getNamespace(){if(this.name.indexOf(":")>=0){const e=this.name.substr(0,this.name.indexOf(":"));return this.findNamespaceForPrefix(e)}return this.findNamespaceForPrefix()}getNamespaceContext(){let e={};this.parent&&(e=this.parent.getNamespaceContext());for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")){const i=t.substr(6);e[n]=i}return e}getDefaultNamespace(){return this.attributes.xmlns?this.attributes.xmlns:this.parent?this.parent.getDefaultNamespace():""}getNamespaceRoot(e){if(this.parent){const t=this.parent.getNamespaceRoot(e);if(t)return t}for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")&&n===e)return this;if(this.optionalNamespaces[e])return this}getAttribute(e,t){if(!t)return this.attributes[e];const n=this.getNamespaceContext();return n[t]?this.attributes[[n[t],e].join(":")]:void 0}getChild(e,t){return this.getChildren(e,t)[0]}getChildren(e,t){const n=[];for(const i of this.children)"string"==typeof i||i.getName()!==e||t&&i.getNamespace()!==t||n.push(i);return n}getText(){let e="";for(const t of this.children)"string"==typeof t&&(e+=t);return e}appendChild(e){return this.children.push(e),"string"!=typeof e&&(e.parent=this),e}setAttribute(e,t,n=!1){this.attributes[e]=t||void 0,""===t&&n&&(this.attributes[e]=t)}addOptionalNamespace(e,t){this.optionalNamespaces[t]=e}useNamespace(e,t){return this.optionalNamespaces[t]&&(e=this.optionalNamespaces[t]),this.setAttribute("xmlns:"+e,t),e}toJSON(){const e=this.children.map(e=>"string"==typeof e?e:e?e.toJSON():void 0).filter(e=>!!e),t={};for(const[e,n]of Object.entries(this.attributes))null!=n&&(t[e]=n);return{attributes:t,children:e,name:this.name}}toString(){let e=this.openTag(!0);if(this.children.length){for(const t of this.children)"string"==typeof t?e+=i.escapeXMLText(t):t&&(e+=t.toString());e+=this.closeTag()}return e}openTag(e=!1){let t="";t+="<"+this.name;for(const[e,n]of Object.entries(this.attributes))void 0!==n&&(t+=` ${e}="${i.escapeXML(n.toString())}"`);return e&&0===this.children.length?t+="/>":t+=">",t}closeTag(){return`</${this.name}>`}findNamespaceForPrefix(e){if(e){const t="xmlns:"+e;if(this.attributes[t])return this.attributes[t];if(this.parent)return this.parent.findNamespaceForPrefix(e)}else{if(this.attributes.xmlns)return this.attributes.xmlns;if(this.parent)return this.parent.findNamespaceForPrefix()}return""}}t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.basicLanguageResolver=t.escapeXMLText=t.unescapeXML=t.escapeXML=void 0;const i=n(0).__importDefault(n(30)),r={'"':""","&":"&","'":"'","<":"<",">":">"},s={"&":"&","'":"'",">":">","<":"<",""":'"'},o=/&([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);/g,a=/&|<|>|"|'/g,c=/&|<|>/g;function l(e){return r[e]}t.escapeXML=function(e){return e.replace(a,l)},t.unescapeXML=function(e){return e.replace(o,e=>function(e){if(s[e])return s[e];const t=e.startsWith("&#x"),n=parseInt(e.substring(t?3:2,e.length-1),t?16:10);if(9===n||10===n||13===n||32<=n&&n<=55295||57344<=n&&n<=65533||65536<=n&&n<=1114111)return String.fromCodePoint(n);throw i.default.restrictedXML("Prohibited entity: "+e)}(e))},t.escapeXMLText=function(e){return e.replace(c,l)},t.basicLanguageResolver=function(e,t=[],n=""){const i=new Set(e.map(e=>e.toLowerCase()));for(let e of t.map(e=>e.toLowerCase()))if("*"!==e)for(;e.length>0;){if(i.has(e))return e;e=e.substring(0,e.lastIndexOf("-")).toLowerCase(),e.lastIndexOf("-")===e.length-2&&(e=e.substring(0,e.lastIndexOf("-")))}return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GenesysCloudMediaSession=void 0;const i=n(22),r=n(130),s=n(9),o=i.__importDefault(n(132)),a=n(3),c=n(17),l={"Discovered new ICE candidate":{skipMessage:!0}};class u extends r.MediaSession{constructor(e){super(e.options),this.iceCandidatesDiscovered=0,this.iceCandidatesReceivedFromPeer=0,this.conversationId=e.conversationId,this.fromUserId=e.fromUserId,this.originalRoomJid=e.originalRoomJid,this.sessionType=c.SessionTypes[e.sessionType],this.ignoreHostCandidatesFromRemote=!!e.ignoreHostCandidatesFromRemote,this.allowIPv6=!!e.allowIPv6,this.allowTCP=!!e.allowTCP;const t=new a.EventEmitter;Object.keys(t.__proto__).forEach(e=>{this[e]=t[e]}),e.optOutOfWebrtcStatsTelemetry||this.setupStatsGatherer(),this.pc.addEventListener("connectionstatechange",this.onConnectionStateChange.bind(this)),this.pc.addEventListener("icecandidateerror",this.onIceCandidateError.bind(this))}getLogDetails(){return{conversationId:this.conversationId,sessionId:this.sid,sessionType:this.sessionType}}async onTransportInfo(e,t){var n,i;const r=null===(n=e.contents)||void 0===n?void 0:n[0].transport,s=null==r?void 0:r.candidates;if(this.ignoreHostCandidatesFromRemote){const e=null==s?void 0:s.filter(e=>"host"!==e.type);(null==e?void 0:e.length)!==(null===(i=null==r?void 0:r.candidates)||void 0===i?void 0:i.length)&&(this._log("info","Ignoring remote host ice candidates"),r.candidates=e)}if(s)for(const e of s)this._log("info","Received candidate from peer",{candidateType:e.type}),this.iceCandidatesReceivedFromPeer++;return super.onTransportInfo(e,t)}_log(e,t,...n){if(this.parent){const i=l[t];if(null==i?void 0:i.skipMessage)return;if(n.length){const e=n[0];"object"!=typeof e||Array.isArray(e)||null===e?n[0]={...this.getLogDetails(),data:e}:Object.assign(n[0],this.getLogDetails())}else n.push(this.getLogDetails());this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n)}}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),setTimeout(()=>{"connected"!==this.pc.connectionState&&"connecting"!==this.pc.connectionState||this.pc.close()},2e3),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}setupStatsGatherer(){this.statsGatherer=new o.default(this.pc),this.statsGatherer.on("stats",this.emit.bind(this,"stats"))}onIceStateChange(){const e=this.pc.iceConnectionState,t=this.id,n=this.conversationId;this._log("info","ICE state changed: ",{iceState:e,sessionId:t,conversationId:n}),"connected"===e?(this._log("info","sending session-info: active"),this.send(s.JingleAction.SessionInfo,{info:{infoType:s.JINGLE_INFO_ACTIVE}}),this._setupDataChannel()):"failed"===e&&this._log("info","ICE connection failed",{candidatesDiscovered:this.iceCandidatesDiscovered,candidatesReceivedFromPeer:this.iceCandidatesReceivedFromPeer}),super.onIceStateChange()}onConnectionStateChange(){this._log("info","Connection state changed: ",{connectionState:this.pc.connectionState})}onIceCandidateError(e){this._log("error","IceCandidateError",{errorCode:e.errorCode,errorText:e.errorText,url:e.url}),console.error("IceCandidateError",e)}onIceCandidate(e){if(e.candidate){if(!this.allowTCP&&"tcp"===e.candidate.protocol)return;if(!this.allowIPv6){const t=/.+udp [^ ]+ ([^ ]+).*typ host/.exec(e.candidate.candidate),n=/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/;if(t&&!t[1].match(n))return void this._log("debug","Filtering out IPv6 candidate",e.candidate.candidate)}this._log("debug","Processing ice candidate",e.candidate.candidate),this._log("info","Discovered ice candidate to send to peer",{type:e.candidate.type}),this.iceCandidatesDiscovered++}return super.onIceCandidate(e)}onIceEndOfCandidates(){super.onIceEndOfCandidates(),this.emit("endOfCandidates")}addTrack(e,t){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",async()=>{const n=this.pc.getTransceivers().find(t=>{var n;return!t.sender.track&&(null===(n=t.receiver.track)||void 0===n?void 0:n.kind)===e.kind});if(n)return n.sender.replaceTrack(e);this.pc.addTrack(e,t)})}_setupDataChannel(){var e;this.dataChannel||(null===(e=this.pc.localDescription)||void 0===e?void 0:e.sdp.includes("webrtc-datachannel"))&&(this._log("info","creating data channel"),this.dataChannel=this.pc.createDataChannel("videoConferenceControl"),this.dataChannel.addEventListener("open",()=>{this._log("info","data channel opened")}),this.dataChannel.addEventListener("message",this._handleDataChannelMessage.bind(this)),this.dataChannel.addEventListener("close",()=>{this._log("info","closing data channel")}),this.dataChannel.addEventListener("error",e=>{this._log("error","Error occurred with the data channel",e)}))}_handleDataChannelMessage(e){this._log("debug","data channel message received",e);try{const t=JSON.parse(e.data);this.emit("dataChannelMessage",t)}catch(e){this._log("error","Failed to parse data channel message",{error:e})}}}t.GenesysCloudMediaSession=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exportToSDP=t.importFromSDP=void 0;const i=n(0).__importStar(n(1));t.importFromSDP=function(e){const t=i.getMediaSections(e),n=i.getDescription(e),r={groups:[],media:[]};i.matchPrefix(n,"a=ice-lite").length>0&&(r.iceLite=!0);for(const e of i.matchPrefix(n,"a=group:")){const t=e.split(" "),n=t.shift().substr(8);r.groups.push({mids:t,semantics:n})}for(const e of t){const t=i.getKind(e),s=i.isRejected(e),o=i.parseMLine(e),a={direction:i.getDirection(e,n),kind:t,mid:i.getMid(e),protocol:o.protocol};if(s||(a.iceParameters=i.getIceParameters(e,n),a.dtlsParameters=i.getDtlsParameters(e,n),a.setup=i.matchPrefix(e,"a=setup:")[0].substr(8),r.iceLite&&(a.iceParameters.iceLite=!0)),"audio"===t||"video"===t){a.rtpParameters=i.parseRtpParameters(e),a.rtpEncodingParameters=i.parseRtpEncodingParameters(e),a.rtcpParameters=i.parseRtcpParameters(e);const t=i.parseMsid(e);a.streams=t?[t]:[]}else"application"===t&&(a.sctp=i.parseSctpDescription(e));a.candidates=i.matchPrefix(e,"a=candidate:").map(i.parseCandidate),r.media.push(a)}return r},t.exportToSDP=function(e){const t=[];t.push(i.writeSessionBoilerplate(e.sessionId,e.sessionVersion),"a=msid-semantic:WMS *\r\n"),(e.iceLite||e.media.filter(e=>e.iceParameters&&e.iceParameters.iceLite).length>0)&&t.push("a=ice-lite\r\n");for(const n of e.groups||[])t.push(`a=group:${n.semantics} ${n.mids.join(" ")}\r\n`);for(const n of e.media||[]){const e=!(n.iceParameters&&n.dtlsParameters);if("application"===n.kind&&n.sctp)t.push(i.writeSctpDescription(n,n.sctp));else if(n.rtpParameters){let r=i.writeRtpDescription(n.kind,n.rtpParameters);e&&(r=r.replace(`m=${n.kind} 9 `,`m=${n.kind} 0 `)),t.push(r),t.push(`a=${n.direction||"sendrecv"}\r\n`);for(const e of n.streams||[])t.push(`a=msid:${e.stream} ${e.track}\r\n`);if(n.rtcpParameters&&(t.push(i.writeRtcpParameters(n.rtcpParameters)),n.rtcpParameters.cname&&n.rtpEncodingParameters&&n.rtpEncodingParameters[0].rtx)){const e=n.rtpEncodingParameters[0];t.push(`a=ssrc-group:FID ${e.ssrc} ${e.rtx.ssrc}\r\n`),t.push(`a=ssrc:${e.rtx.ssrc} cname:${n.rtcpParameters.cname}\r\n`)}}if(void 0!==n.mid&&t.push(`a=mid:${n.mid}\r\n`),n.iceParameters&&t.push(i.writeIceParameters({usernameFragment:n.iceParameters.usernameFragment,password:n.iceParameters.password})),n.dtlsParameters&&n.setup&&t.push(i.writeDtlsParameters(n.dtlsParameters,n.setup)),n.candidates&&n.candidates.length)for(const e of n.candidates)t.push(`a=${i.writeCandidate(e)}\r\n`)}return t.join("")}},function(e,t,n){e.exports=n(88)},function(e,t){var n=Object.prototype.hasOwnProperty;function i(e){return"[Throws: "+(e?e.message:"?")+"]"}function r(e){var t=[];return function e(r){if(null===r||"object"!=typeof r)return r;if(-1!==t.indexOf(r))return"[Circular]";if(t.push(r),"function"==typeof r.toJSON)try{var s=e(r.toJSON());return t.pop(),s}catch(e){return i(e)}if(Array.isArray(r)){var o=r.map(e);return t.pop(),o}var a=Object.keys(r).reduce((function(t,s){return t[s]=e(function(e,t){if(n.call(e,t))try{return e[t]}catch(e){return i(e)}return e[t]}(r,s)),t}),{});return t.pop(),a}(e)}e.exports=function(e,t,n){return JSON.stringify(r(e),t,n)},e.exports.ensureProperties=r},function(e,t,n){"use strict";(function(t){var i=n(2),r=n(93),s=n(13),o=n(49),a=n(50),c={"Content-Type":"application/x-www-form-urlencoded"};function l(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,p={transitional:o,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(u=n(51)),u),transformRequest:[function(e,t){if(r(t,"Accept"),r(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e))return e;if(i.isArrayBufferView(e))return e.buffer;if(i.isURLSearchParams(e))return l(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,s=i.isObject(e),o=t&&t["Content-Type"];if((n=i.isFileList(e))||s&&"multipart/form-data"===o){var c=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,c&&new c)}return s||"application/json"===o?(l(t,"application/json"),function(e,t,n){if(i.isString(e))try{return(t||JSON.parse)(e),i.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||p.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||r&&i.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw s.from(e,s.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:n(101)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};i.forEach(["delete","get","head"],(function(e){p.headers[e]={}})),i.forEach(["post","put","patch"],(function(e){p.headers[e]=i.merge(c)})),e.exports=p}).call(this,n(7))},function(e,t,n){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.JXTErrorCondition=void 0,function(e){e.NotWellFormed="not-well-formed",e.RestrictedXML="restricted-xml",e.AlreadyClosed="already-closed",e.UnknownRoot="unknown-stream-root"}(i=t.JXTErrorCondition||(t.JXTErrorCondition={}));class r extends Error{constructor(e){super(e.text),this.isJXTError=!0,this.condition=e.condition,this.text=e.text}static notWellFormed(e){return new r({condition:i.NotWellFormed,text:e})}static restrictedXML(e){return new r({condition:i.RestrictedXML,text:e})}static alreadyClosed(e){return new r({condition:i.AlreadyClosed,text:e})}static unknownRoot(e){return new r({condition:i.UnknownRoot,text:e})}}t.default=r},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.childAlternateLanguageRawElement=t.childLanguageRawElement=t.childRawElement=t.staticValue=t.splicePath=t.multipleChildEnum=t.multipleChildAlternateLanguageText=t.childAlternateLanguageText=t.multipleChildIntegerAttribute=t.multipleChildAttribute=t.multipleChildText=t.childDoubleEnum=t.childEnum=t.deepMultipleChildText=t.deepChildBoolean=t.deepChildInteger=t.deepChildText=t.childBoolean=t.childTimezoneOffset=t.childJSON=t.childFloat=t.childInteger=t.childDate=t.childTextBuffer=t.childText=t.childLanguageAttribute=t.languageAttribute=t.textBuffer=t.textJSON=t.text=t.childDateAttribute=t.childFloatAttribute=t.childIntegerAttribute=t.childBooleanAttribute=t.childAttribute=t.namespacedDateAttribute=t.namespacedFloatAttribute=t.namespacedIntegerAttribute=t.namespacedBooleanAttribute=t.namespacedAttribute=t.dateAttribute=t.floatAttribute=t.integerAttribute=t.booleanAttribute=t.attribute=t.findOrCreate=t.findAll=t.getTargetLang=t.getLang=t.createElement=void 0,t.parameterMap=void 0;const i=n(0).__importDefault(n(23)),r=n(32);function s(e,t,n,r){if(r){e=e||r.getNamespace();const n=r.getNamespaceRoot(e);if(n){t=`${n.useNamespace("",e)}:${t}`}}const s=new i.default(t);return t.indexOf(":")<0&&(!n||e!==n)&&s.setAttribute("xmlns",e),s}function o(e,t){return(e.getAttribute("xml:lang")||t||"").toLowerCase()}function a(e,t){const n=[];for(const i of e)n.push(o(i,t.lang));let i;return i=t.resolveLanguage?t.resolveLanguage(n,t.acceptLanguages||[],t.lang):t.lang,i||""}function c(e,t,n,i){const r=e.getChildren(n,t),s=o(e);return r.length?i?r.filter(e=>{if(o(e,s)===i)return!0}):r:[]}function l(e,t,n,i){t=t||e.getNamespace();const r=c(e,t,n,i);if(r.length)return r[0];const a=s(t,n,e.getDefaultNamespace(),e),l=o(e,i);return i&&l!==i&&a.setAttribute("xml:lang",i),e.appendChild(a),a}function u(e){return{importer(t){const n=t.getAttribute(e.name,e.namespace);return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);if(i||e.emitEmpty)if(e.namespace&&e.prefix){let n;const r=t.getNamespaceRoot(e.namespace);if(r)n=r.useNamespace(e.prefix,e.namespace);else{const i=t.getNamespaceContext();i[e.namespace]||(n=t.useNamespace(e.prefix,e.namespace),i[e.namespace]=n)}t.setAttribute(`${n}:${e.name}`,i,e.emitEmpty)}else t.setAttribute(e.name,i,e.emitEmpty)}}}function p(e,t){return(n,i,r={})=>(r={staticDefault:i,...r},u({name:n,...e,...t?t(r):r}))}function d(e,t){return(n,i,r,s,o={})=>(o={staticDefault:s,...o},u({name:r,namespace:i,prefix:n,...e,...t?t(o):o}))}function h(e){const t=e.converter||u({...e,namespace:e.attributeNamespace});return{importer(n,i){const r=n.getChild(e.element,e.namespace||n.getNamespace());return r?t.importer(r,i):e.dynamicDefault?e.dynamicDefault():e.staticDefault},exporter(n,i,r){if(void 0!==i&&i!==e.staticDefault){const s=l(n,e.namespace||n.getNamespace(),e.element);t.exporter(s,i,r)}}}}function f(e,t){return(n,i,r,s,o={})=>(o={staticDefault:s,...o},h({element:i,name:r,namespace:n,...e,...t?t(o):o}))}function m(e){return{importer(t){const n=t.getText();return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(!n&&e.emitEmpty)return void t.children.push("");if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);i&&t.children.push(i)}}}function g(e){const t=m(e);return{importer(n,i){const r=c(n,e.namespace||n.getNamespace(),e.element),s=a(r,i);if(!r.length)return e.dynamicDefault?e.dynamicDefault():e.staticDefault;if(e.matchLanguage)for(const e of r)if(o(e,i.lang)===s)return t.importer(e,i);return t.importer(r[0],i)},exporter(n,i,r){if(i||!e.emitEmpty){if(void 0!==i&&i!==e.staticDefault){const s=l(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0);t.exporter(s,i,r)}}else l(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0)}}}t.createElement=s,t.getLang=o,t.getTargetLang=a,t.findAll=c,t.findOrCreate=l;const v={parseValue:e=>e,writeValue:e=>e},b={parseValue:e=>parseInt(e,10),writeValue:e=>e.toString()},y={parseValue:e=>parseFloat(e),writeValue:e=>e.toString()},_={parseValue:e=>"true"===e||"1"===e||"false"!==e&&"0"!==e&&void 0,writeValue:e=>e?"1":"0"},S={parseValue:e=>new Date(e),writeValue:e=>"string"==typeof e?e:e.toISOString()},w={parseValue:e=>JSON.parse(e),writeValue:e=>JSON.stringify(e)},x=(t="utf8")=>({parseValue:n=>("base64"===t&&"="===n&&(n=""),e.from(n.trim(),t)),writeValue:n=>{let i;return i="string"==typeof n?e.from(n).toString(t):n?n.toString(t):"","base64"===t&&(i=i||"="),i}}),T={parseValue:e=>{let t=-1;"-"===e.charAt(0)&&(t=1,e=e.slice(1));const n=e.split(":");return(60*parseInt(n[0],10)+parseInt(n[1],10))*t},writeValue:e=>{if("string"==typeof e)return e;{let t="-";e<0&&(e=-e,t="+");const n=e/60,i=e%60;return t+=(n<10?"0":"")+n+":"+(i<10?"0":"")+i,t}}};t.attribute=p(v,e=>({dynamicDefault:e.emitEmpty?t=>""===t?"":e.staticDefault:void 0,...e})),t.booleanAttribute=p(_),t.integerAttribute=p(b),t.floatAttribute=p(y),t.dateAttribute=p(S),t.namespacedAttribute=d(v),t.namespacedBooleanAttribute=d(_),t.namespacedIntegerAttribute=d(b),t.namespacedFloatAttribute=d(y),t.namespacedDateAttribute=d(S),t.childAttribute=f(v),t.childBooleanAttribute=f(_),t.childIntegerAttribute=f(b),t.childFloatAttribute=f(y),t.childDateAttribute=f(S);t.text=e=>m({staticDefault:e,...v});t.textJSON=()=>m({...w});function k(){return{importer:(e,t)=>o(e,t.lang),exporter(e,t,n){t&&t.toLowerCase()!==n.lang?e.setAttribute("xml:lang",t):e.setAttribute("xml:lang",void 0)}}}t.textBuffer=(e="utf8")=>m({...x(e)}),t.languageAttribute=k;t.childLanguageAttribute=(e,t)=>h({converter:k(),element:t,name:"xml:lang",namespace:e,...v});t.childText=(e,t,n,i=!1)=>g({element:t,emitEmpty:i,matchLanguage:!0,namespace:e,staticDefault:n,...v});t.childTextBuffer=(e,t,n="utf8")=>g({element:t,matchLanguage:!0,namespace:e,...x(n)});t.childDate=(e,t)=>g({element:t,namespace:e,...S});t.childInteger=(e,t,n)=>g({element:t,namespace:e,staticDefault:n,...b});t.childFloat=(e,t,n)=>g({element:t,namespace:e,staticDefault:n,...y});t.childJSON=(e,t)=>g({element:t,namespace:e,...w}),t.childTimezoneOffset=function(e,t){return g({element:t,namespace:e,staticDefault:0,...T})},t.childBoolean=function(e,t){return{importer(n){if(n.getChild(t,e||n.getNamespace()))return!0},exporter(n,i){i&&l(n,e||n.getNamespace(),t)}}};const I=(e,t,n)=>{if(!n)return;let i=t;for(const t of e)i=l(i,t.namespace||i.getNamespace(),t.element);i.children.push(n.toString())};t.deepChildText=function(e,t){return{importer(n){let i=n;for(const n of e)if(i=i.getChild(n.element,n.namespace||i.getNamespace()),!i)return t;return i.getText()||t},exporter(t,n){I(e,t,n)}}},t.deepChildInteger=function(e,t){return{importer(n){let i=n;for(const t of e)if(i=i.getChild(t.element,t.namespace||i.getNamespace()),!i)return;const r=i.getText();return r?parseInt(r,10):t||void 0},exporter(t,n){I(e,t,n)}}},t.deepChildBoolean=function(e){return{importer(t){let n=t;for(const t of e)if(n=n.getChild(t.element,t.namespace||n.getNamespace()),!n)return!1;return!0},exporter(t,n){if(!n)return;let i=t;for(const t of e)i=l(i,t.namespace||i.getNamespace(),t.element)}}},t.deepMultipleChildText=function(e){const t=e.pop();return{importer(n,i){let r=n;for(const t of e)if(r=r.getChild(t.element,t.namespace||r.getNamespace()),!r)return[];const s=[],l=c(r,t.namespace||r.getNamespace(),t.element),u=a(l,i);for(const e of l)o(e,i.lang)===u&&s.push(e.getText());return s},exporter(n,i,r){if(!i.length)return;let o=n;for(const t of e)o=l(o,t.namespace||o.getNamespace(),t.element);const{namespace:a,element:c}=t;for(const e of i){const t=s(a||o.getNamespace(),c,r.namespace,o);t.children.push(e),o.appendChild(t)}}}},t.childEnum=function(e,t,n){const i=new Map,r=new Map;for(const e of t)"string"==typeof e?(i.set(e,e),r.set(e,e)):(i.set(e[1],e[0]),r.set(e[0],e[1]));return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&i.has(n.getName()))return i.get(n.getName());return n},exporter(t,n){r.has(n)&&l(t,e,r.get(n))}}},t.childDoubleEnum=function(e,t,n,i){const r=new Set(t),s=new Set(n);return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&r.has(n.getName())){for(const i of n.children)if("string"!=typeof i&&i.getNamespace()===(e||t.getNamespace())&&s.has(i.getName()))return[n.getName(),i.getName()];return[n.getName()]}return i},exporter(t,n){const i=l(t,e,n[0]);n[1]&&l(i,e,n[1])}}},t.multipleChildText=function(e,t){return{importer(n,i){const r=[],s=c(n,e||n.getNamespace(),t),l=a(s,i);for(const e of s)o(e,i.lang)===l&&r.push(e.getText());return r},exporter(n,i,r){for(const o of i){const i=s(e||n.getNamespace(),t,r.namespace,n);i.children.push(o),n.appendChild(i)}}}},t.multipleChildAttribute=function(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(t)}return r},exporter(i,r,o){for(const a of r){const r=s(e||i.getNamespace(),t,o.namespace,i);r.setAttribute(n,a),i.appendChild(r)}}}},t.multipleChildIntegerAttribute=function(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(parseInt(t,10))}return r},exporter(i,r,o){for(const a of r){const r=s(e||i.getNamespace(),t,o.namespace,i);r.setAttribute(n,a.toString()),i.appendChild(r)}}}},t.childAlternateLanguageText=function(e,t){return{importer(n,i){const r=[],s=c(n,e||n.getNamespace(),t),a=new Set;for(const e of s){const t=e.getText();if(t){const n=o(e,i.lang);if(a.has(n))continue;r.push({lang:n,value:t}),a.add(n)}}return a.size>0?r:void 0},exporter(n,i,r){for(const o of i){const i=o.value;if(i){const a=s(e||n.getNamespace(),t,r.namespace,n);o.lang!==r.lang&&a.setAttribute("xml:lang",o.lang),a.children.push(i),n.appendChild(a)}}}}},t.multipleChildAlternateLanguageText=function(e,t){return{importer(n,i){const r=[],s=new Map;let a=!1;const l=c(n,e||n.getNamespace(),t);for(const e of l){const t=e.getText();if(t){const n=o(e,i.lang);let c=s.get(n);c||(c=[],s.set(n,c),r.push({lang:n,value:c})),c.push(t),a=!0}}return a?r:void 0},exporter(n,i,r){for(const o of i)for(const i of o.value){const a=s(e||n.getNamespace(),t,r.namespace,n);o.lang!==r.lang&&a.setAttribute("xml:lang",o.lang),a.children.push(i),n.appendChild(a)}}}},t.multipleChildEnum=function(e,t){const n=new Map,i=new Map;for(const e of t)"string"==typeof e?(n.set(e,e),i.set(e,e)):(n.set(e[1],e[0]),i.set(e[0],e[1]));return{importer(t){const i=[];for(const r of t.children)"string"!=typeof r&&r.getNamespace()===(e||t.getNamespace())&&n.has(r.getName())&&i.push(n.get(r.getName()));return i},exporter(t,n){for(const r of n)l(t,e,i.get(r))}}},t.splicePath=function(e,t,n,i=!1){return{importer(r,s){const o=r.getChild(t,e||r.getNamespace());if(!o)return;const a=[];for(const e of o.children)if("string"!=typeof e&&s.registry.getImportKey(e)===n){const t=s.registry.import(e);t&&a.push(t)}return i?a:a[0]},exporter(i,r,s){let o=[];o=Array.isArray(r)?r:[r];const a=[];for(const t of o){const r=s.registry.export(n,t,{...s,namespace:e||i.getNamespace()||void 0});r&&a.push(r)}if(a.length){const n=l(i,e||i.getNamespace(),t);for(const e of a)n.appendChild(e)}}}},t.staticValue=function(e){return{exporter:()=>{},importer:()=>e}},t.childRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=i.getChild(t,e||i.getNamespace());return s?n?r.sanitizers[n](s.toJSON()):s.toJSON():void 0},exporter(s,o,a){if("string"==typeof o){o=r.parse(`<${t} xmlns="${e||s.getNamespace()}">${o}</${t}>`).toJSON()}if(n){if(!a.sanitizers||!a.sanitizers[n])return;o=a.sanitizers[n](o)}o&&s.appendChild(new i.default(o.name,o.attributes,o.children))}}},t.childLanguageRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=c(i,e||i.getNamespace(),t),l=a(s,r);for(const e of s)if(o(e,r.lang)===l)return n?r.sanitizers[n](e.toJSON()):e.toJSON();return s[0]?n?r.sanitizers[n](s[0].toJSON()):s[0].toJSON():void 0},exporter(s,o,a){if("string"==typeof o){o=r.parse(`<${t} xmlns="${e||s.getNamespace()}">${o}</${t}>`).toJSON()}if(o&&n){if(!a.sanitizers||!a.sanitizers[n])return;o=a.sanitizers[n](o)}if(!o)return;const c=l(s,e||s.getNamespace(),t,a.lang);for(const e of o.children)"string"==typeof e?c.appendChild(e):e&&c.appendChild(new i.default(e.name,e.attributes,e.children))}}},t.childAlternateLanguageRawElement=function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=[],a=new Set,l=c(i,e||i.getNamespace(),t);for(const e of l){let t=e.toJSON();if(n&&(t=r.sanitizers[n](t)),t){const n=o(e,r.lang);if(a.has(n))continue;s.push({lang:n,value:t}),a.add(n)}}return a.size>0?s:void 0},exporter(o,a,c){for(const l of a){let a=l.value;if("string"==typeof a){a=r.parse(`<${t} xmlns="${e||o.getNamespace()}">${a}</${t}>`).toJSON()}if(a&&n){if(!c.sanitizers||!c.sanitizers[n])continue;a=c.sanitizers[n](a)}if(a){const n=s(e||o.getNamespace(),t,c.namespace,o);o.appendChild(n),l.lang!==c.lang&&n.setAttribute("xml:lang",l.lang);for(const e of a.children)"string"==typeof e?n.appendChild(e):n.appendChild(new i.default(e.name,e.attributes,e.children))}}}}},t.parameterMap=function(e,n,i,r){return{importer(s,o){const a={},l=c(s,e,n),u=t.attribute(i).importer,p=t.attribute(r).importer;for(const e of l)a[u(e,o)]=p(e,o);return a},exporter(o,a,c){const l=t.attribute(i).exporter,u=t.attribute(r).exporter,p=e||o.getNamespace();for(const[e,t]of Object.entries(a)){const i=s(p,n,c.namespace,o);l(i,e,c),a[e]&&u(i,t,c),o.appendChild(i)}}}}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;const i=n(0),r=n(3),s=n(24),o=i.__importDefault(n(23)),a=i.__importDefault(n(30));function c(e){return 97<=e&&e<=122||65<=e&&e<=90||58===e||95===e}function l(e){return 192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=767||880<=e&&e<=893||895<=e&&e<=8191||8204<=e&&e<=8205||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||65008<=e&&e<=65533||65536<=e&&e<=983039}function u(e){return c(e)||l(e)}function p(e){return c(e)||45===e||46===e||48<=e&&e<=57||183===e||768<=e&&e<=879||8255<=e&&e<=8256||l(e)}function d(e){return 32===e||10===e||13===e||9===e}class h extends r.EventEmitter{constructor(e={}){super(),this.allowComments=!0,this.attributes={},this.state=34,this.tagName="",this.haveDeclaration=!1,this.recordBuffer=[],void 0!==e.allowComments&&(this.allowComments=e.allowComments)}write(e){for(const t of e){const e=t.codePointAt(0);switch(this.state){case 34:if(60===e){let e;try{e=s.unescapeXML(this.endRecord())}catch(e){return void this.emit("error",e)}e&&this.emit("text",e),this.transition(31);continue}this.record(t);continue;case 31:if(47===e){this.transition(7);continue}if(33===e){this.transition(24);continue}if(63===e){this.haveDeclaration&&this.restrictedXML(),this.transition(25);continue}if(u(e)){this.transition(30),this.startRecord(t);continue}return this.notWellFormed();case 30:if(p(e)){this.record(t);continue}if(d(e)){this.startTag(),this.transition(32);continue}if(47===e){this.startTag(),this.transition(29);continue}if(62===e){this.startTag(),this.transition(34),this.emit("startElement",this.tagName,this.attributes);continue}return this.notWellFormed();case 29:if(62===e){this.emit("startElement",this.tagName,this.attributes),this.emit("endElement",this.tagName),this.transition(34);continue}return this.notWellFormed();case 33:if(d(e)){this.transition(32);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 32:if(d(e))continue;if(u(e)){this.startRecord(t),this.transition(0);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 7:if(u(e)){this.startRecord(t),this.transition(6);continue}return this.notWellFormed();case 6:if(p(e)){this.record(t);continue}if(d(e)){this.transition(8);continue}if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 8:if(d(e))continue;if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 0:if(p(e)){this.record(t);continue}if(61===e){this.addAttribute(),this.transition(4);continue}if(d(e)){this.addAttribute(),this.transition(3);continue}return this.notWellFormed();case 3:if(61===e){this.transition(4);continue}if(d(e))continue;return this.notWellFormed();case 4:if(34===e){this.startRecord(),this.transition(1);continue}if(39===e){this.startRecord(),this.transition(2);continue}if(d(e))continue;return this.notWellFormed();case 1:case 2:if(34===e&&1===this.state||39===e&&2===this.state){const e=this.endRecord();this.attributes[this.attributeName]=s.unescapeXML(e),this.transition(33);continue}if(60===e)return this.notWellFormed();this.record(t);continue;case 24:if(45===e){this.allowComments||this.restrictedXML(),this.transition(23);continue}if(91===e){this.transition(21);continue}return this.notWellFormed();case 23:if(45===e){this.transition(14);continue}return this.notWellFormed();case 14:45===e&&this.transition(12);continue;case 12:45===e?this.transition(11):this.transition(14);continue;case 11:62===e?this.transition(34):this.transition(14);continue;case 25:if(88===e||120===e){this.transition(28);continue}return this.notWellFormed();case 28:if(77===e||109===e){this.transition(27);continue}return this.notWellFormed();case 27:if(76===e||108===e){this.transition(26);continue}return this.notWellFormed();case 26:if(d(e)){this.haveDeclaration=!0,this.transition(15);continue}return this.notWellFormed();case 13:if(62===e){this.transition(34);continue}return this.notWellFormed();case 15:63===e&&this.transition(13);continue;case 21:this.wait(e,67,20);continue;case 20:this.wait(e,68,19);continue;case 19:this.wait(e,65,18);continue;case 18:this.wait(e,84,17);continue;case 17:this.wait(e,65,16);continue;case 16:this.wait(e,91,5);continue;case 5:if(93===e){this.transition(10);continue}this.record(t);continue;case 10:93===e?this.transition(9):(this.record(String.fromCodePoint(93)),this.record(t),this.transition(5));continue;case 9:if(62===e){const e=this.endRecord();e&&this.emit("text",e),this.transition(34)}else this.record(String.fromCodePoint(93)),this.record(String.fromCodePoint(93)),this.record(t),this.transition(5);continue}}}end(e){e&&this.write(e),this.write=()=>{}}record(e){this.recordBuffer.push(e)}startRecord(e){this.recordBuffer=[],e&&this.recordBuffer.push(e)}endRecord(){const e=this.recordBuffer;return this.recordBuffer=[],e.join("")}startTag(){this.tagName=this.endRecord(),this.attributes={}}addAttribute(){const e=this.endRecord();if(void 0!==this.attributes[e])return this.notWellFormed();this.attributeName=e,this.attributes[e]=""}wait(e,t,n){if(e!==t)return this.notWellFormed();this.transition(n)}transition(e){this.state=e,34===e&&this.startRecord()}notWellFormed(e){this.emit("error",a.default.notWellFormed(e))}restrictedXML(e){this.emit("error",a.default.restrictedXML(e))}}t.parse=function(e,t={}){const n=new h(t);let i,r,s=null;if(n.on("text",e=>{r&&r.children.push(e)}),n.on("startElement",(e,t)=>{const n=new o.default(e,t);i||(i=n),r=r?r.appendChild(n):n}),n.on("endElement",e=>{r?e===r.name?r.parent&&(r=r.parent):n.emit("error",a.default.notWellFormed("b")):n.emit("error",a.default.notWellFormed("a"))}),n.on("error",e=>{s=e}),n.write(e),n.end(),s)throw s;return i},t.default=h},function(e,t,n){"use strict";n.r(t),function(e,i){n.d(t,"Hash",(function(){return s})),n.d(t,"Hmac",(function(){return F})),n.d(t,"RTCPeerConnection",(function(){return G})),n.d(t,"WebSocket",(function(){return J})),n.d(t,"createHash",(function(){return q})),n.d(t,"createHmac",(function(){return U})),n.d(t,"fetch",(function(){return z})),n.d(t,"getHashes",(function(){return B})),n.d(t,"randomBytes",(function(){return D}));var r=n(6);class s extends r.Transform{constructor(t,n,i="be"){super(),this._block=e.alloc(t),this._finalSize=n,this._blockSize=t,this._bigEndian="be"===i,this._len=0}_transform(e,t,n){let i=null;try{this.update(e,t)}catch(e){i=e}n(i)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(t,n){"string"==typeof t&&(n=n||"utf8",t=e.from(t,n));const i=this._block,r=this._blockSize,s=t.length;let o=this._len;for(let e=0;e<s;){const n=o%r,a=Math.min(s-e,r-n);for(let r=0;r<a;r++)i[n+r]=t[e+r];o+=a,e+=a,o%r==0&&this._update(i)}return this._len+=s,this}digest(e){const t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));const n=8*this._len;if(n<=4294967295)this._bigEndian?(this._block.writeUInt32BE(0,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)):(this._block.writeUInt32LE(n,this._blockSize-8),this._block.writeUInt32LE(0,this._blockSize-4));else{const e=(4294967295&n)>>>0,t=(n-e)/4294967296;this._bigEndian?(this._block.writeUInt32BE(t,this._blockSize-8),this._block.writeUInt32BE(e,this._blockSize-4)):(this._block.writeUInt32LE(e,this._blockSize-8),this._block.writeUInt32LE(t,this._blockSize-4))}this._update(this._block);const i=this._hash();return e?i.toString(e):i}_update(e){throw new Error("_update must be implemented by subclass")}_hash(){throw new Error("_update must be implemented by subclass")}}function o(e,t){return e<<t|e>>>32-t}function a(e,t,n,i,r,s,a){return o(e+(t&n|~t&i)+r+s|0,a)+t|0}function c(e,t,n,i,r,s,a){return o(e+(t&i|n&~i)+r+s|0,a)+t|0}function l(e,t,n,i,r,s,a){return o(e+(t^n^i)+r+s|0,a)+t|0}function u(e,t,n,i,r,s,a){return o(e+(n^(t|~i))+r+s|0,a)+t|0}const p=[1518500249,1859775393,-1894007588,-899497514];function d(e){return e<<5|e>>>27}function h(e){return e<<30|e>>>2}function f(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}class m extends s{constructor(){super(64,56),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this._w=new Array(80)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<80;++n)t[n]=(c=t[n-3]^t[n-8]^t[n-14]^t[n-16])<<1|c>>>31;var c;for(let e=0;e<80;++e){const n=~~(e/20),c=d(i)+f(n,r,s,o)+a+t[e]+p[n]|0;a=o,o=s,s=h(r),r=i,i=c}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0}_hash(){const t=e.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t}}const g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(e,t,n){return n^e&(t^n)}function b(e,t,n){return e&t|n&(e|t)}function y(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function _(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function S(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}class w extends s{constructor(){super(64,56),this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this._w=new Array(64)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,c=0|this._f,l=0|this._g,u=0|this._h;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<64;++n)t[n]=0|(((p=t[n-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10)+t[n-7]+S(t[n-15])+t[n-16];var p;for(let e=0;e<64;++e){const n=u+_(a)+v(a,c,l)+g[e]+t[e]|0,p=y(i)+b(i,r,s)|0;u=l,l=c,c=a,a=o+n|0,o=s,s=r,r=i,i=n+p|0}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=c+this._f|0,this._g=l+this._g|0,this._h=u+this._h|0}_hash(){const t=e.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t}}const x=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function T(e,t,n){return n^e&(t^n)}function k(e,t,n){return e&t|n&(e|t)}function I(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function j(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function E(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function N(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function C(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function R(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function O(e,t){return e>>>0<t>>>0?1:0}class A extends s{constructor(){super(128,112),this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this._w=new Array(160)}_update(e){const t=this._w;let n,i,r=0|this._ah,s=0|this._bh,o=0|this._ch,a=0|this._dh,c=0|this._eh,l=0|this._fh,u=0|this._gh,p=0|this._hh,d=0|this._al,h=0|this._bl,f=0|this._cl,m=0|this._dl,g=0|this._el,v=0|this._fl,b=0|this._gl,y=0|this._hl,_=0;for(_=0;_<32;_+=2)t[_]=e.readInt32BE(4*_),t[_+1]=e.readInt32BE(4*_+4);for(;_<160;_+=2){let e=t[_-30],r=t[_-30+1];const s=E(e,r),o=N(r,e);e=t[_-4],r=t[_-4+1];const a=C(e,r),c=R(r,e),l=t[_-14],u=t[_-14+1],p=t[_-32],d=t[_-32+1];i=o+u|0,n=s+l+O(i,o)|0,i=i+c|0,n=n+a+O(i,c)|0,i=i+d|0,n=n+p+O(i,d)|0,t[_]=n,t[_+1]=i}for(let e=0;e<160;e+=2){n=t[e],i=t[e+1];const _=k(r,s,o),S=k(d,h,f),w=I(r,d),E=I(d,r),N=j(c,g),C=j(g,c),R=x[e],A=x[e+1],P=T(c,l,u),q=T(g,v,b);let L=y+C|0,F=p+N+O(L,y)|0;L=L+q|0,F=F+P+O(L,q)|0,L=L+A|0,F=F+R+O(L,A)|0,L=L+i|0,F=F+n+O(L,i)|0;const M=E+S|0,D=w+_+O(M,E)|0;p=u,y=b,u=l,b=v,l=c,v=g,g=m+L|0,c=a+F+O(g,m)|0,a=o,m=f,o=s,f=h,s=r,h=d,d=L+M|0,r=F+D+O(d,L)|0}this._al=this._al+d|0,this._bl=this._bl+h|0,this._cl=this._cl+f|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+b|0,this._hl=this._hl+y|0,this._ah=this._ah+r+O(this._al,d)|0,this._bh=this._bh+s+O(this._bl,h)|0,this._ch=this._ch+o+O(this._cl,f)|0,this._dh=this._dh+a+O(this._dl,m)|0,this._eh=this._eh+c+O(this._el,g)|0,this._fh=this._fh+l+O(this._fl,v)|0,this._gh=this._gh+u+O(this._gl,b)|0,this._hh=this._hh+p+O(this._hl,y)|0}_hash(){const t=e.allocUnsafe(64);function n(e,n,i){t.writeInt32BE(e,i),t.writeInt32BE(n,i+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),n(this._gh,this._gl,48),n(this._hh,this._hl,56),t}}const P=new Map([["md5",class extends s{constructor(){super(64,56,"le"),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._m=new Array(16)}_update(e){const t=this._m;for(let n=0;n<16;++n)t[n]=e.readInt32LE(4*n);let n=this._a,i=this._b,r=this._c,s=this._d;n=a(n,i,r,s,t[0],3614090360,7),s=a(s,n,i,r,t[1],3905402710,12),r=a(r,s,n,i,t[2],606105819,17),i=a(i,r,s,n,t[3],3250441966,22),n=a(n,i,r,s,t[4],4118548399,7),s=a(s,n,i,r,t[5],1200080426,12),r=a(r,s,n,i,t[6],2821735955,17),i=a(i,r,s,n,t[7],4249261313,22),n=a(n,i,r,s,t[8],1770035416,7),s=a(s,n,i,r,t[9],2336552879,12),r=a(r,s,n,i,t[10],4294925233,17),i=a(i,r,s,n,t[11],2304563134,22),n=a(n,i,r,s,t[12],1804603682,7),s=a(s,n,i,r,t[13],4254626195,12),r=a(r,s,n,i,t[14],2792965006,17),i=a(i,r,s,n,t[15],1236535329,22),n=c(n,i,r,s,t[1],4129170786,5),s=c(s,n,i,r,t[6],3225465664,9),r=c(r,s,n,i,t[11],643717713,14),i=c(i,r,s,n,t[0],3921069994,20),n=c(n,i,r,s,t[5],3593408605,5),s=c(s,n,i,r,t[10],38016083,9),r=c(r,s,n,i,t[15],3634488961,14),i=c(i,r,s,n,t[4],3889429448,20),n=c(n,i,r,s,t[9],568446438,5),s=c(s,n,i,r,t[14],3275163606,9),r=c(r,s,n,i,t[3],4107603335,14),i=c(i,r,s,n,t[8],1163531501,20),n=c(n,i,r,s,t[13],2850285829,5),s=c(s,n,i,r,t[2],4243563512,9),r=c(r,s,n,i,t[7],1735328473,14),i=c(i,r,s,n,t[12],2368359562,20),n=l(n,i,r,s,t[5],4294588738,4),s=l(s,n,i,r,t[8],2272392833,11),r=l(r,s,n,i,t[11],1839030562,16),i=l(i,r,s,n,t[14],4259657740,23),n=l(n,i,r,s,t[1],2763975236,4),s=l(s,n,i,r,t[4],1272893353,11),r=l(r,s,n,i,t[7],4139469664,16),i=l(i,r,s,n,t[10],3200236656,23),n=l(n,i,r,s,t[13],681279174,4),s=l(s,n,i,r,t[0],3936430074,11),r=l(r,s,n,i,t[3],3572445317,16),i=l(i,r,s,n,t[6],76029189,23),n=l(n,i,r,s,t[9],3654602809,4),s=l(s,n,i,r,t[12],3873151461,11),r=l(r,s,n,i,t[15],530742520,16),i=l(i,r,s,n,t[2],3299628645,23),n=u(n,i,r,s,t[0],4096336452,6),s=u(s,n,i,r,t[7],1126891415,10),r=u(r,s,n,i,t[14],2878612391,15),i=u(i,r,s,n,t[5],4237533241,21),n=u(n,i,r,s,t[12],1700485571,6),s=u(s,n,i,r,t[3],2399980690,10),r=u(r,s,n,i,t[10],4293915773,15),i=u(i,r,s,n,t[1],2240044497,21),n=u(n,i,r,s,t[8],1873313359,6),s=u(s,n,i,r,t[15],4264355552,10),r=u(r,s,n,i,t[6],2734768916,15),i=u(i,r,s,n,t[13],1309151649,21),n=u(n,i,r,s,t[4],4149444226,6),s=u(s,n,i,r,t[11],3174756917,10),r=u(r,s,n,i,t[2],718787259,15),i=u(i,r,s,n,t[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+i|0,this._c=this._c+r|0,this._d=this._d+s|0}_hash(){const t=e.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t}}],["sha-1",m],["sha-256",w],["sha-512",A],["sha1",m],["sha256",w],["sha512",A]]);function q(e){e=e.toLowerCase();const t=P.get(e);if(t)return new t;throw new Error("Unsupported hash algorithm: "+e)}const L=e.alloc(128);class F extends r.Transform{constructor(t,n){super(),"string"==typeof n&&(n=e.from(n));const i="sha512"===t?128:64;this._alg=t,n.length>i?n=q(t).update(n).digest():n.length<i&&(n=e.concat([n,L],i)),this._ipad=e.alloc(i),this._opad=e.alloc(i);for(let e=0;e<i;e++)this._ipad[e]=54^n[e],this._opad[e]=92^n[e];this._hash=q(t).update(this._ipad)}_transform(e,t,n){let i;try{this.update(e,t)}catch(e){i=e}finally{n(i)}}_flush(e){let t;try{this.push(this._final())}catch(e){t=e}e(t)}_final(){const e=this._hash.digest();return q(this._alg).update(this._opad).update(e).digest()}update(e,t){return this._hash.update(e,t),this}digest(t){const n=this._final()||e.alloc(0);return t?n.toString(t):n}}let M;function D(t){const n=new Uint8Array(t);return t>0&&(M.crypto||M.msCrypto).getRandomValues(n),e.from(n.buffer)}function B(){return["sha-1","sha-256","sha-512","md5"]}function U(e,t){return new F(e.toLowerCase(),t)}"undefined"!=typeof window?M=window:void 0!==i&&(M=i);const z=fetch,J=WebSocket,G=M.RTCPeerConnection}.call(this,n(10).Buffer,n(5))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=i.__importStar(n(1)),s=n(9),o=n(11),a=n(26),c=n(35),l=i.__importDefault(n(36));class u extends l.default{constructor(e){super(e),this.bitrateLimit=0,this.candidateBuffer=[],this.transportType=o.NS_JINGLE_ICE_UDP_1,this.restartingIce=!1,this.usingRelay=!1,this.maxRelayBandwidth=e.maxRelayBandwidth,this.pc=this.parent.createPeerConnection(this,{...e.config,iceServers:e.iceServers}),this.pc.oniceconnectionstatechange=()=>{this.onIceStateChange()},this.pc.onicecandidate=e=>{e.candidate?this.onIceCandidate(e):this.onIceEndOfCandidates()},this.restrictRelayBandwidth()}end(e="success",t=!1){this.pc.close(),super.end(e,t)}async restartIce(){if(this.isInitiator){void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this.restartingIce=!0;try{await this.processLocal("restart-ice",async()=>{const e=await this.pc.createOffer({iceRestart:!0}),t=a.importFromSDP(e.sdp);this.send(s.JingleAction.TransportInfo,{contents:t.media.map(e=>({creator:s.JingleSessionRole.Initiator,name:e.mid,transport:c.convertIntermediateToTransport(e,this.transportType)})),sid:this.sid}),await this.pc.setLocalDescription(e)})}catch(e){this._log("error","Could not create WebRTC offer",e),this.end(s.JingleReasonCondition.FailedTransport,!0)}}}async setMaximumBitrate(e){this.maximumBitrate&&(e=Math.min(e,this.maximumBitrate)),this.currentBitrate=e;const t=this.pc.getSenders().find(e=>!!e.track&&"video"===e.track.kind);if(t&&t.getParameters)try{await this.processLocal("set-bitrate",async()=>{const n=t.getParameters();n.encodings&&n.encodings.length||(n.encodings=[{}]),0===e?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=e,await t.setParameters(n)})}catch(e){this._log("error","Set maximumBitrate failed",e)}}async onTransportInfo(e,t){if(e.contents&&e.contents[0]&&e.contents[0].transport.gatheringComplete){const n={sdpMid:e.contents[0].name,candidate:""};try{"stable"===this.pc.signalingState?await this.pc.addIceCandidate(n):this.candidateBuffer.push(n)}catch(e){this._log("debug","Could not add null end-of-candidate")}finally{t()}return}if(this.pc.remoteDescription){const n=this.pc.remoteDescription,i=a.importFromSDP(n.sdp),r=i.media.find(t=>t.mid===e.contents[0].name).iceParameters.usernameFragment,o=e.contents[0].transport.usernameFragment;if(o&&r!==o){for(const[t,n]of e.contents.entries()){const e=n.transport;i.media[t].iceParameters={password:e.password,usernameFragment:e.usernameFragment},i.media[t].candidates=[]}try{if(await this.pc.setRemoteDescription({type:n.type,sdp:a.exportToSDP(i)}),await this.processBufferedCandidates(),"offer"===n.type){const e=await this.pc.createAnswer();await this.pc.setLocalDescription(e);const t=a.importFromSDP(e.sdp);this.send(s.JingleAction.TransportInfo,{contents:t.media.map(e=>({creator:s.JingleSessionRole.Initiator,name:e.mid,transport:c.convertIntermediateToTransport(e,this.transportType)})),sid:this.sid})}else this.restartingIce=!1}catch(e){return this._log("error","Could not do remote ICE restart",e),t(e),void this.end(s.JingleReasonCondition.FailedTransport)}}}const n=(e.contents||[]).map(e=>{const t=e.name,n=(e.transport.candidates||[]).map(async e=>{const n=r.writeCandidate(c.convertCandidateToIntermediate(e));if(this.pc.remoteDescription&&"stable"===this.pc.signalingState)try{await this.pc.addIceCandidate({sdpMid:t,candidate:n})}catch(e){this._log("error","Could not add ICE candidate",e)}else this.candidateBuffer.push({sdpMid:t,candidate:n})});return Promise.all(n)});try{await Promise.all(n),t()}catch(e){this._log("error","Could not process transport-info: "+e),t(e)}}async onSessionAccept(e,t){this.state="active";const n=c.convertRequestToIntermediate(e,this.peerRole),i=a.exportToSDP(n);try{await this.pc.setRemoteDescription({type:"answer",sdp:i}),await this.processBufferedCandidates(),this.parent.emit("accepted",this,void 0),t()}catch(e){this._log("error","Could not process WebRTC answer: "+e),t({condition:"general-error"})}}onSessionTerminate(e,t){this._log("info","Terminating session"),this.pc.close(),super.end(e.reason,!0),t()}onIceCandidate(e){if(!e.candidate||!e.candidate.candidate)return;const t=r.parseCandidate(e.candidate.candidate),n={contents:[{creator:s.JingleSessionRole.Initiator,name:e.candidate.sdpMid,transport:{candidates:[c.convertIntermediateToCandidate(t)],transportType:this.transportType,usernameFragment:t.usernameFragment}}]};this._log("info","Discovered new ICE candidate",n),this.send(s.JingleAction.TransportInfo,n)}onIceEndOfCandidates(){this._log("info","ICE end of candidates");const e=a.importFromSDP(this.pc.localDescription.sdp).media[0];this.send(s.JingleAction.TransportInfo,{contents:[{creator:s.JingleSessionRole.Initiator,name:e.mid,transport:{gatheringComplete:!0,transportType:this.transportType,usernameFragment:e.iceParameters.usernameFragment}}]})}onIceStateChange(){switch(this.pc.iceConnectionState){case"checking":this.connectionState="connecting";break;case"completed":case"connected":this.connectionState="connected";break;case"disconnected":if("stable"===this.pc.signalingState?this.connectionState="interrupted":this.connectionState="disconnected",this.restartingIce)return void this.end(s.JingleReasonCondition.FailedTransport);this.maybeRestartIce();break;case"failed":if("failed"===this.connectionState||this.restartingIce)return void this.end(s.JingleReasonCondition.FailedTransport);this.connectionState="failed",this.restartIce();break;case"closed":this.connectionState="disconnected",this.restartingIce?this.end(s.JingleReasonCondition.FailedTransport):this.end()}}async processBufferedCandidates(){for(const e of this.candidateBuffer)try{await this.pc.addIceCandidate(e)}catch(e){this._log("error","Could not add ICE candidate",e)}this.candidateBuffer=[]}restrictRelayBandwidth(){this.pc.addEventListener("iceconnectionstatechange",async()=>{if("completed"!==this.pc.iceConnectionState&&"connected"!==this.pc.iceConnectionState)return;const e=await this.pc.getStats();let t;if(e.forEach(n=>{"transport"===n.type&&(t=e.get(n.selectedCandidatePairId))}),t||e.forEach(e=>{"candidate-pair"===e.type&&e.selected&&(t=e)}),!t)return;let n=!1,i="",r="";if(t.remoteCandidateId){const n=e.get(t.remoteCandidateId);n&&(r=n.candidateType)}if(t.localCandidateId){const n=e.get(t.localCandidateId);n&&(i=n.candidateType)}"relay"!==i&&"relay"!==r||(n=!0),this.usingRelay=n,this.parent.emit("iceConnectionType",this,{localCandidateType:i,relayed:n,remoteCandidateType:r}),n&&void 0!==this.maxRelayBandwidth&&(this.maximumBitrate=this.maxRelayBandwidth,this.currentBitrate?this.setMaximumBitrate(Math.min(this.currentBitrate,this.maximumBitrate)):this.setMaximumBitrate(this.maximumBitrate))})}maybeRestartIce(){this.isInitiator&&(void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this._maybeRestartingIce=setTimeout(()=>{this._maybeRestartingIce=void 0,"disconnected"===this.pc.iceConnectionState&&this.restartIce()},2e3))}}t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertRequestToIntermediate=t.convertContentToIntermediate=t.convertIntermediateToRequest=t.convertIntermediateToTransport=t.convertCandidateToIntermediate=t.convertIntermediateToCandidate=t.convertIntermediateToApplication=void 0;const i=n(9),r=n(11);function s(e,t){const n=e.rtpParameters,s=e.rtcpParameters||{},o=e.rtpEncodingParameters||[];let a=!1;o&&o.length&&(a=!!o[0].ssrc);const c={applicationType:r.NS_JINGLE_RTP_1,codecs:[],headerExtensions:[],media:e.kind,rtcpMux:s.mux,rtcpReducedSize:s.reducedSize,sourceGroups:[],sources:[],ssrc:a?o[0].ssrc.toString():void 0,streams:[]};for(const e of n.headerExtensions||[]){const n={id:e.id,uri:e.uri};e.direction&&"sendrecv"!==e.direction&&(n.senders=i.directionToSenders(t,e.direction)),c.headerExtensions.push(n)}s.ssrc&&s.cname&&(c.sources=[{parameters:{cname:s.cname},ssrc:s.ssrc.toString()}]),a&&o[0]&&o[0].rtx&&(c.sourceGroups=[{semantics:"FID",sources:[o[0].ssrc.toString(),o[0].rtx.ssrc.toString()]}]);for(const t of e.streams||[])c.streams.push({id:t.stream,track:t.track});for(const e of n.codecs||[]){const t={channels:e.channels,clockRate:e.clockRate,id:e.payloadType.toString(),name:e.name,parameters:e.parameters,rtcpFeedback:e.rtcpFeedback};e.maxptime&&(t.maxptime=e.maxptime),e.parameters&&e.parameters.ptime&&(t.ptime=parseInt(e.parameters.ptime,10)),c.codecs.push(t)}return c}function o(e){let t;return t="rtp"===e.component?1:"rtcp"===e.component?2:e.component,{component:t,foundation:e.foundation,generation:void 0,id:void 0,ip:e.ip,network:void 0,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function a(e){return{address:e.ip,component:1===e.component?"rtp":2===e.component?"rtcp":e.component,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function c(e,t){const n=e.iceParameters,i=e.dtlsParameters,r={candidates:[],transportType:t};n&&(r.usernameFragment=n.usernameFragment,r.password=n.password,n.iceLite&&(r.iceLite=!0)),i&&(r.fingerprints=i.fingerprints.map(t=>({algorithm:t.algorithm,setup:e.setup,value:t.value}))),e.sctp&&(r.sctp=e.sctp);for(const t of e.candidates||[])r.candidates.push(o(t));return r}function l(e,t){const n=e.application||{},s=e.transport,o=n&&n.applicationType===r.NS_JINGLE_RTP_1,c={direction:i.sendersToDirection(t,e.senders),kind:n.media||"application",mid:e.name,protocol:o?"UDP/TLS/RTP/SAVPF":"UDP/DTLS/SCTP"};if(o){if(c.rtcpParameters={compound:!n.rtcpReducedSize,mux:n.rtcpMux,reducedSize:n.rtcpReducedSize},n.sources&&n.sources.length){const e=n.sources[0];c.rtcpParameters.ssrc=parseInt(e.ssrc,10),e.parameters&&(c.rtcpParameters.cname=e.parameters.cname)}if(c.rtpParameters={codecs:[],fecMechanisms:[],headerExtensions:[],rtcp:[]},n.streams){c.streams=[];for(const e of n.streams)c.streams.push({stream:e.id,track:e.track})}if(n.ssrc&&(c.rtpEncodingParameters=[{ssrc:parseInt(n.ssrc,10)}],n.sourceGroups&&n.sourceGroups.length)){const e=n.sourceGroups[0];c.rtpEncodingParameters[0].rtx={ssrc:parseInt(e.sources[1],10)}}let e=!1,r=!1;for(const t of n.codecs||[]){const n=t.parameters||{},i=[];for(const e of t.rtcpFeedback||[])i.push({parameter:e.parameter,type:e.type});if("red"===t.name||"ulpfec"===t.name){e=e||"red"===t.name,r=r||"ulpfec"===t.name;const n=t.name.toUpperCase();c.rtpParameters.fecMechanisms.includes(n)||c.rtpParameters.fecMechanisms.push(n)}c.rtpParameters.codecs.push({channels:t.channels,clockRate:t.clockRate,name:t.name,numChannels:t.channels,parameters:n,payloadType:parseInt(t.id,10),rtcpFeedback:i})}for(const e of n.headerExtensions||[])c.rtpParameters.headerExtensions.push({direction:i.sendersToDirection(t,e.senders||"both"),id:e.id,uri:e.uri})}if(s){if(s.usernameFragment&&s.password&&(c.iceParameters={password:s.password,usernameFragment:s.usernameFragment},s.iceLite&&(c.iceParameters.iceLite=!0)),s.fingerprints&&s.fingerprints.length){c.dtlsParameters={fingerprints:[],role:"auto"};for(const e of s.fingerprints)c.dtlsParameters.fingerprints.push({algorithm:e.algorithm,value:e.value});s.sctp&&(c.sctp=s.sctp),c.setup=s.fingerprints[0].setup}c.candidates=(s.candidates||[]).map(a)}return c}t.convertIntermediateToApplication=s,t.convertIntermediateToCandidate=o,t.convertCandidateToIntermediate=a,t.convertIntermediateToTransport=c,t.convertIntermediateToRequest=function(e,t,n){return{contents:e.media.map(e=>({application:"audio"===e.kind||"video"===e.kind?s(e,t):{applicationType:"datachannel",protocol:e.protocol},creator:i.JingleSessionRole.Initiator,name:e.mid,senders:i.directionToSenders(t,e.direction),transport:c(e,n)})),groups:e.groups?e.groups.map(e=>({contents:e.mids,semantics:e.semantics})):[]}},t.convertContentToIntermediate=l,t.convertRequestToIntermediate=function(e,t){const n={groups:[],media:[]};for(const t of e.groups||[])n.groups.push({mids:t.contents,semantics:t.semantics});for(const i of e.contents||[])n.media.push(l(i,t));return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(14),r=n(9),s=n(60),o={condition:r.StanzaErrorCondition.BadRequest},a={condition:r.StanzaErrorCondition.FeatureNotImplemented,jingleError:r.JingleErrorCondition.UnsupportedInfo,type:"modify"};t.default=class{constructor(e){this.parent=e.parent,this.sid=e.sid||s.uuid(),this.peerID=e.peerID,this.role=e.initiator?r.JingleSessionRole.Initiator:r.JingleSessionRole.Responder,this._sessionState="starting",this._connectionState="starting",this.pendingApplicationTypes=e.applicationTypes||[],this.pendingAction=void 0,this.processingQueue=i.priorityQueue(async(e,t)=>{if("ended"===this.state)return"local"===e.type&&e.reject&&e.reject(new Error("Session ended")),void(t&&t());if("local"===e.type){this._log("debug","Processing local action:",e.name);try{const t=await e.handler();e.resolve(t)}catch(t){e.reject(t)}return void(t&&t())}const{action:n,changes:i,cb:s}=e;return this._log("debug","Processing remote action:",n),new Promise(e=>{const o=(n,i)=>{s(n,i),t&&t(),e()};switch(n){case r.JingleAction.ContentAccept:return this.onContentAccept(i,o);case r.JingleAction.ContentAdd:return this.onContentAdd(i,o);case r.JingleAction.ContentModify:return this.onContentModify(i,o);case r.JingleAction.ContentReject:return this.onContentReject(i,o);case r.JingleAction.ContentRemove:return this.onContentRemove(i,o);case r.JingleAction.DescriptionInfo:return this.onDescriptionInfo(i,o);case r.JingleAction.SecurityInfo:return this.onSecurityInfo(i,o);case r.JingleAction.SessionAccept:return this.onSessionAccept(i,o);case r.JingleAction.SessionInfo:return this.onSessionInfo(i,o);case r.JingleAction.SessionInitiate:return this.onSessionInitiate(i,o);case r.JingleAction.SessionTerminate:return this.onSessionTerminate(i,o);case r.JingleAction.TransportAccept:return this.onTransportAccept(i,o);case r.JingleAction.TransportInfo:return this.onTransportInfo(i,o);case r.JingleAction.TransportReject:return this.onTransportReject(i,o);case r.JingleAction.TransportReplace:return this.onTransportReplace(i,o);default:this._log("error","Invalid or unsupported action: "+n),o({condition:r.StanzaErrorCondition.BadRequest})}})},1)}get isInitiator(){return this.role===r.JingleSessionRole.Initiator}get peerRole(){return this.isInitiator?r.JingleSessionRole.Responder:r.JingleSessionRole.Initiator}get state(){return this._sessionState}set state(e){e!==this._sessionState&&(this._log("info","Changing session state to: "+e),this._sessionState=e,this.parent&&this.parent.emit("sessionState",this,e))}get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._log("info","Changing connection state to: "+e),this._connectionState=e,this.parent&&this.parent.emit("connectionState",this,e))}send(e,t){(t=t||{}).sid=this.sid,t.action=e;new Set([r.JingleAction.ContentAccept,r.JingleAction.ContentAdd,r.JingleAction.ContentModify,r.JingleAction.ContentReject,r.JingleAction.ContentRemove,r.JingleAction.SessionAccept,r.JingleAction.SessionInitiate,r.JingleAction.TransportAccept,r.JingleAction.TransportReject,r.JingleAction.TransportReplace]).has(e)?this.pendingAction=e:this.pendingAction=void 0,this.parent.signal(this,{id:s.uuid(),jingle:t,to:this.peerID,type:"set"})}processLocal(e,t){return new Promise((n,i)=>{this.processingQueue.push({handler:t,name:e,reject:i,resolve:n,type:"local"},1)})}process(e,t,n){this.processingQueue.push({action:e,cb:n,changes:t,type:"remote"},2)}start(e,t){this._log("error","Can not start base sessions"),this.end("unsupported-applications",!0)}accept(e,t){this._log("error","Can not accept base sessions"),this.end("unsupported-applications")}cancel(){this.end("cancel")}decline(){this.end("decline")}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}_log(e,t,...n){this.parent&&(t=this.sid+": "+t,this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n))}onSessionInitiate(e,t){t()}onSessionAccept(e,t){t()}onSessionTerminate(e,t){this.end(e.reason,!0),t()}onSessionInfo(e,t){e.info?t(a):t()}onSecurityInfo(e,t){t(a)}onDescriptionInfo(e,t){t(a)}onTransportInfo(e,t){t(a)}onContentAdd(e,t){t(),this.send(r.JingleAction.ContentReject,{reason:{condition:r.JingleReasonCondition.FailedApplication,text:"content-add is not supported"}})}onContentAccept(e,t){t(o)}onContentReject(e,t){t(o)}onContentModify(e,t){t(o)}onContentRemove(e,t){t(o)}onTransportReplace(e,t){t(),this.send(r.JingleAction.TransportReject,{reason:{condition:r.JingleReasonCondition.FailedTransport,text:"transport-replace is not supported"}})}onTransportAccept(e,t){t(o)}onTransportReject(e,t){t(o)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const i=n(70),r=n(73),s=n(141);n(113);const o=n(114),a=n(116),c=n(136),l=n(140),u=n(8),p=n(18),d=n(27);let h={ping:l.Ping,reconnector:c.Reconnector,notifications:o.Notifications,webrtcSessions:a.WebrtcExtension};const f={connected:"session:started",_connected:"connected"};class m{constructor(e){this.connected=!1,this.connecting=!1,this.autoReconnect=!0,this.hardReconnectCount=0,this.reconnectLeakTime=6e5,this.deadChannels=[],this.backgroundAssistantMode=!1,this.isGuest=!1,this.http=new p.HttpClient;const t=r.createClient({});t.sasl.mechanisms.find(e=>"ANONYMOUS"===e.name).priority=0,t.sasl.mechanisms=t.sasl.mechanisms.sort((e,t)=>t.priority-e.priority),this._stanzaio=t,this.reconnectOnNoLongerSubscribed=!1!==e.reconnectOnNoLongerSubscribed,this.config={host:e.host,apiHost:e.apiHost||e.host.replace("wss://streaming.",""),authToken:e.authToken,jwt:e.jwt,jid:e.jid,jidResource:e.jidResource,channelId:null,appName:e.appName,appVersion:e.appVersion},this.backgroundAssistantMode=this.checkIsBackgroundAssistant(),this.isGuest=!this.backgroundAssistantMode&&!e.authToken;let n=e.authToken||"",o=`https://api.${this.config.apiHost}/api/v2/diagnostics/trace`;this.backgroundAssistantMode&&(n=e.jwt,o+="/backgroundassistant"),this.logger=new s.Logger({accessToken:n,url:o,uploadDebounceTime:1e3,initializeServerLogging:!this.isGuest&&!e.optOutOfWebrtcStatsTelemetry,appVersion:m.version,appName:"streaming-client",logLevel:this.config.logLevel||"info",logger:e.logger||console,formatters:e.logFormatters,originAppName:e.appName,originAppVersion:e.appVersion,originAppId:e.appId}),this.on("disconnected",()=>{if(this._stanzaio.transport||this.connecting)return void this.logger.info("disconnected event received, but reconnection is in progress");this.connected=!1,this._ping.stop(),this.logger.info("Streaming client disconnected.");const e=this.config.channelId;this.autoReconnect&&!this.deadChannels.includes(e)&&(this.logger.info("Streaming client disconnected unexpectedly. Attempting to auto reconnect",{channelId:e}),this._reconnector.start())}),this.on("connected",async e=>{this.streamId=e.resource,this._ping.start(),this.connected=!0,this._reconnector.stop(),this.connecting=!1}),this.on("session:end",()=>{this._ping.stop()}),this._stanzaio.on("sasl",e=>{if("failure"===e.type){if(this.logger.error("Authentication failed connecting to streaming service",{...e,channelId:this.config.channelId}),"temporary-auth-failure"!==e.condition)return this._ping.stop(),this.autoReconnect=!1,this.disconnect();this.logger.info("Temporary auth failure, continuing reconnect attempts")}}),this.on("notify:no_longer_subscribed",e=>{this._ping.stop();const t=e.eventBody.channelId;if(this.deadChannels.push(t),t===this.config.channelId){if(this.hardReconnectCount>=2)return this.logger.error(`no_longer_subscribed has been called ${this.hardReconnectCount} times and the threshold is 2, not attempting to reconnect\n channelId: ${this.config.channelId}`),void this.cleanupLeakTimer();if(this.logger.info("no_longer_subscribed received"),this.reconnectOnNoLongerSubscribed)return this.logger.info("streaming client attempting to reconnect on a new channel"),this.hardReconnectCount++,this.leakyReconnectTimer||(this.leakyReconnectTimer=setInterval(()=>{this.hardReconnectCount>0?this.hardReconnectCount--:this.cleanupLeakTimer()},this.reconnectLeakTime)),this._reconnector.hardReconnect();this.logger.info("`reconnectOnNoLongerSubscribed` is false, not attempting to reconnect streaming client")}else this.logger.warn("received no_longer_subscribed event for a non active channelId")}),Object.keys(h).forEach(n=>{const r=new h[n](this,e);"function"==typeof r.handleIq&&t.on("iq",r.handleIq.bind(r)),"function"==typeof r.handleMessage&&t.on("message",r.handleMessage.bind(r)),r.tokenBucket||(r.tokenBucket=new i.TokenBucket(20,25,1e3),r.tokenBucket.content=25),"function"==typeof r.on&&r.on("send",(function(e,n=!1){return r.tokenBucket.removeTokens(1,()=>!0===n?t.sendMessage(e):t.sendIQ(e))})),this[n]=r.expose,this["_"+n]=r})}checkIsBackgroundAssistant(){if(this.config.jwt){const e=u.parseJwt(this.config.jwt);return e&&"urn:purecloud:screenrecording"===e.iss}return!1}cleanupLeakTimer(){clearInterval(this.leakyReconnectTimer),this.leakyReconnectTimer=null}on(e,...t){return f[e]?this._stanzaio.on(f[e],...t):this._stanzaio.on(e,...t),this}once(e,...t){return f[e]?this._stanzaio.once(f[e],...t):this._stanzaio.once(e,...t),this}off(e,...t){return f[e]?this._stanzaio.off(f[e],...t):this._stanzaio.off(e,...t),this}disconnect(){return this.logger.info("streamingClient.disconnect was called"),this.stopServerLogging(),u.timeoutPromise(e=>{this._stanzaio.once("disconnected",e),this.autoReconnect=!1,this._reconnector.stop(new Error("Cancelling reconnect")),this.http.stopAllRetries(),this._stanzaio.disconnect()},1e3,"disconnecting streaming service")}reconnect(){return this.logger.info("streamingClient.reconnect was called"),u.timeoutPromise(e=>{this._stanzaio.once("session:started",e),this.autoReconnect=!0,this._stanzaio.disconnect()},1e4,"reconnecting streaming service")}async connect(e={keepTryingOnFailure:!1,retryDelay:5e3}){var t;try{this.logger.info("streamingClient.connect was called"),await this._tryToConnect()}catch(n){let i=!0;if(n instanceof d.AxiosError&&[401,403].includes((null===(t=n.response)||void 0===t?void 0:t.status)||0)&&(i=!1),e.keepTryingOnFailure&&this.autoReconnect){if(i)return await u.wait(e.retryDelay),this.connect(e);this.logger.error("Streaming client received and error that it can't recover from and will not attempt to reconnect",{error:n})}throw n}}_tryToConnect(){if(this.startServerLogging(),this.connecting=!0,this.config.jwt)return u.timeoutPromise(e=>{this.once("connected",e);const t=function(e){const t=u.parseJwt(e.jwt);let n;try{n=t.data.jid.split("@")[1].replace("conference.","")}catch(e){throw new Error("failed to parse jid")}let i=e.host.replace(/\/$/,"");return{resource:e.jidResource,transports:{websocket:`${i}/stream/jwt/${e.jwt}`},server:n,sasl:["anonymous"]}}(this.config);this._stanzaio.updateConfig(t),this._stanzaio.connect()},1e4,"connecting to streaming service with jwt").catch(e=>(this.connecting=!1,Promise.reject(e)));let e;if(this.config.jid)e=Promise.resolve(this.config.jid);else{const t={method:"get",host:this.config.apiHost,authToken:this.config.authToken,logger:this.logger};e=this.http.requestApiWithRetry("users/me",t).promise.then(e=>e.data.chat.jabberId)}const t={method:"post",host:this.config.apiHost,authToken:this.config.authToken,logger:this.logger},n=this.http.requestApiWithRetry("notifications/channels?connectionType=streaming",t).promise.then(e=>e.data.id);return Promise.all([e,n]).then(([e,t])=>(this.config.jid=e,this.config.channelId=t,this.autoReconnect=!0,u.timeoutPromise(e=>{this.once("connected",e);const t=function(e){let t=e.host.replace(/\/$/,"");return{jid:e.jid,resource:e.jidResource,credentials:{username:e.jid,password:"authKey:"+e.authToken},transports:{websocket:`${t}/stream/channels/${e.channelId}`}}}(this.config);this._stanzaio.updateConfig(t),this._stanzaio.connect()},1e4,"connecting to streaming service",{jid:e,channelId:t}))).catch(e=>(this.connecting=!1,Promise.reject(e)))}stopServerLogging(){this.logger.sendAllLogsInstantly(),this.logger.stopServerLogging(),this._webrtcSessions.flushStats()}startServerLogging(){this.logger.startServerLogging()}setAccessToken(e){this.config.authToken=e,this.logger.setAccessToken(e)}static extend(e,t){if(h[e])throw new Error("Cannot register already existing namespace "+e);h[e]=t}get version(){return m.version}static get version(){return"14.2.1"}}t.Client=m},function(e,t,n){(function(t){var n=function(e,t,n,i){if(this.bucketSize=e,this.tokensPerInterval=t,"string"==typeof n)switch(n){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=6e4;break;case"hr":case"hour":this.interval=36e5;break;case"day":this.interval=864e5;break;default:throw new Error("Invaid interval "+n)}else this.interval=n;this.parentBucket=i,this.content=0,this.lastDrip=+new Date};n.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(e,n){var i=this;return this.bucketSize?e>this.bucketSize?(t.nextTick(n.bind(null,"Requested tokens "+e+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),e>this.content?r():this.parentBucket?this.parentBucket.removeTokens(e,(function(t,s){return t?n(t,null):e>i.content?r():(i.content-=e,void n(null,Math.min(s,i.content)))})):(this.content-=e,t.nextTick(n.bind(null,null,this.content)),!0)):(t.nextTick(n.bind(null,null,e,Number.POSITIVE_INFINITY)),!0);function r(){var t=Math.ceil((e-i.content)*(i.interval/i.tokensPerInterval));return setTimeout((function(){i.removeTokens(e,n)}),t),!1}},tryRemoveTokens:function(e){return!this.bucketSize||!(e>this.bucketSize)&&(this.drip(),!(e>this.content)&&(!(this.parentBucket&&!this.parentBucket.tryRemoveTokens(e))&&(this.content-=e,!0)))},drip:function(){if(this.tokensPerInterval){var e=+new Date,t=Math.max(e-this.lastDrip,0);this.lastDrip=e;var n=t*(this.tokensPerInterval/this.interval);this.content=Math.min(this.content+n,this.bucketSize)}else this.content=this.bucketSize}},e.exports=n}).call(this,n(7))},function(e,t,n){"use strict";(function(t,i){var r=n(19);e.exports=y;var s,o=n(78);y.ReadableState=b;n(3).EventEmitter;var a=function(e,t){return e.listeners(t).length},c=n(40),l=n(20).Buffer,u=t.Uint8Array||function(){};var p=Object.create(n(15));p.inherits=n(16);var d=n(79),h=void 0;h=d&&d.debuglog?d.debuglog("stream"):function(){};var f,m=n(80),g=n(41);p.inherits(y,c);var v=["error","close","destroy","pause","resume"];function b(e,t){e=e||{};var i=t instanceof(s=s||n(12));this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,o=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=n(43).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function y(e){if(s=s||n(12),!(this instanceof y))return new y(e);this._readableState=new b(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function _(e,t,n,i,r){var s,o=e._readableState;null===t?(o.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,x(e)}(e,o)):(r||(s=function(e,t){var n;i=t,l.isBuffer(i)||i instanceof u||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var i;return n}(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),i?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):S(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?S(e,o,t,!1):k(e,o)):S(e,o,t,!1))):i||(o.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(o)}function S(e,t,n,i){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),k(e,t)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.push(null),t(e)},y.prototype.push=function(e,t){var n,i=this._readableState;return i.objectMode?n=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=l.from(e,t),t=""),n=!0),_(this,e,t,!1,n)},y.prototype.unshift=function(e){return _(this,e,null,!0,!1)},y.prototype.isPaused=function(){return!1===this._readableState.flowing},y.prototype.setEncoding=function(e){return f||(f=n(43).StringDecoder),this._readableState.decoder=new f(e),this._readableState.encoding=e,this};function w(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?r.nextTick(T,e):T(e))}function T(e){h("emit readable"),e.emit("readable"),N(e)}function k(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(I,e,t))}function I(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(h("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function j(e){h("readable nexttick read 0"),e.read(0)}function E(e,t){t.reading||(h("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),N(e),t.flowing&&!t.reading&&e.read(0)}function N(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function C(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var i;e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):i=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,i=1,r=n.data;e-=r.length;for(;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(o===s.length?r+=s:r+=s.slice(0,e),0===(e-=o)){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}(e,t):function(e,t){var n=l.allocUnsafe(e),i=t.head,r=1;i.data.copy(n),e-=i.data.length;for(;i=i.next;){var s=i.data,o=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,o),0===(e-=o)){o===s.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=s.slice(o));break}++r}return t.length-=r,n}(e,t);return i}(e,t.buffer,t.decoder),n);var n}function R(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,r.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1}y.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):x(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&R(this),null;var i,r=t.needReadable;return h("need readable",r),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",r=!0),t.ended||t.reading?h("reading or ended",r=!1):r&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=w(n,t))),null===(i=e>0?C(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&R(this)),null!==i&&this.emit("data",i),i},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var n=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,h("pipe count=%d opts=%j",s.pipesCount,t);var c=(!t||!1!==t.end)&&e!==i.stdout&&e!==i.stderr?u:y;function l(t,i){h("onunpipe"),t===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,h("cleanup"),e.removeListener("close",v),e.removeListener("finish",b),e.removeListener("drain",p),e.removeListener("error",g),e.removeListener("unpipe",l),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",m),d=!0,!s.awaitDrain||e._writableState&&!e._writableState.needDrain||p())}function u(){h("onend"),e.end()}s.endEmitted?r.nextTick(c):n.once("end",c),e.on("unpipe",l);var p=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,N(e))}}(n);e.on("drain",p);var d=!1;var f=!1;function m(t){h("ondata"),f=!1,!1!==e.write(t)||f||((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==A(s.pipes,e))&&!d&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,f=!0),n.pause())}function g(t){h("onerror",t),y(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",b),y()}function b(){h("onfinish"),e.removeListener("close",v),y()}function y(){h("unpipe"),n.unpipe(e)}return n.on("data",m),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?o(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",g),e.once("close",v),e.once("finish",b),e.emit("pipe",n),s.flowing||(h("pipe resume"),n.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<r;s++)i[s].emit("unpipe",this,n);return this}var o=A(t.pipes,e);return-1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},y.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&x(this):r.nextTick(j,this))}return n},y.prototype.addListener=y.prototype.on,y.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(E,e,t))}(this,e)),this},y.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this},y.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;for(var r in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(r){(h("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r)||(n.objectMode||r&&r.length)&&(t.push(r)||(i=!0,e.pause()))})),e)void 0===this[r]&&"function"==typeof e[r]&&(this[r]=function(t){return function(){return e[t].apply(e,arguments)}}(r));for(var s=0;s<v.length;s++)e.on(v[s],this.emit.bind(this,v[s]));return this._read=function(t){h("wrapped _read",t),i&&(i=!1,e.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=C}).call(this,n(5),n(7))},function(e,t,n){e.exports=n(3).EventEmitter},function(e,t,n){"use strict";var i=n(19);function r(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||i.nextTick(r,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?(i.nextTick(r,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";(function(t,i,r){var s=n(19);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var i=e.entry;e.entry=null;for(;i;){var r=i.callback;t.pendingcb--,r(n),i=i.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=b;var a,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?i:s.nextTick;b.WritableState=v;var l=Object.create(n(15));l.inherits=n(16);var u={deprecate:n(84)},p=n(40),d=n(20).Buffer,h=r.Uint8Array||function(){};var f,m=n(41);function g(){}function v(e,t){a=a||n(12),e=e||{};var i=t instanceof a;this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,l=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i&&(l||0===l)?l:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var p=!1===e.decodeStrings;this.decodeStrings=!p,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,i=n.sync,r=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,i,r){--t.pendingcb,n?(s.nextTick(r,i),s.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(r(i),e._writableState.errorEmitted=!0,e.emit("error",i),T(e,t))}(e,n,i,t,r);else{var o=w(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),i?c(_,e,n,o,r):_(e,n,o,r)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(e){if(a=a||n(12),!(f.call(b,this)||this instanceof a))return new b(e);this._writableState=new v(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),p.call(this)}function y(e,t,n,i,r,s,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,n?e._writev(r,t.onwrite):e._write(r,s,t.onwrite),t.sync=!1}function _(e,t,n,i){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),T(e,t)}function S(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,r=new Array(i),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)r[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;r.allBuffers=c,y(e,t,!0,t.length,r,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,p=n.callback;if(y(e,t,!1,t.objectMode?1:l.length,l,u,p),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function w(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),T(e,t)}))}function T(e,t){var n=w(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,s.nextTick(x,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}l.inherits(b,p),v.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(v.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===b&&(e&&e._writableState instanceof v)}})):f=function(e){return e instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(e,t,n){var i,r=this._writableState,o=!1,a=!r.objectMode&&(i=e,d.isBuffer(i)||i instanceof h);return a&&!d.isBuffer(e)&&(e=function(e){return d.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=g),r.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),s.nextTick(t,n)}(this,n):(a||function(e,t,n,i){var r=!0,o=!1;return null===n?o=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),s.nextTick(i,o),r=!1),r}(this,r,e,n))&&(r.pendingcb++,o=function(e,t,n,i,r,s){if(!n){var o=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=d.from(t,n));return t}(t,i,r);i!==o&&(n=!0,r="buffer",i=o)}var a=t.objectMode?1:i.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:r,isBuf:n,callback:s,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else y(e,t,!1,a,i,r,s);return c}(this,r,a,e,t,n)),o},b.prototype.cork=function(){this._writableState.corked++},b.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||S(this,e))},b.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(e,t,n){var i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||function(e,t,n){t.ending=!0,T(e,t),n&&(t.finished?s.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,i,n)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),b.prototype.destroy=m.destroy,b.prototype._undestroy=m.undestroy,b.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(7),n(82).setImmediate,n(5))},function(e,t,n){"use strict";var i=n(20).Buffer,r=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===r||!r(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=p,t=3;break;default:return this.write=d,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},s.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},s.prototype.text=function(e,t){var n=function(e,t,n){var i=t.length-1;if(i<n)return 0;var r=o(t[i]);if(r>=0)return r>0&&(e.lastNeed=r-1),r;if(--i<n||-2===r)return 0;if((r=o(t[i]))>=0)return r>0&&(e.lastNeed=r-2),r;if(--i<n||-2===r)return 0;if((r=o(t[i]))>=0)return r>0&&(2===r?r=0:e.lastNeed=r-3),r;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";e.exports=o;var i=n(12),r=Object.create(n(15));function s(e,t){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),i(e);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",a)}function a(){var e=this;"function"==typeof this._flush?this._flush((function(t,n){c(e,t,n)})):c(this,null,null)}function c(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}r.inherits=n(16),r.inherits(o,i),o.prototype.push=function(e,t){return this._transformState.needTransform=!1,i.prototype.push.call(this,e,t)},o.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(e,t,n){var i=this._transformState;if(i.writecb=n,i.writechunk=e,i.writeencoding=t,!i.transforming){var r=this._readableState;(i.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}},o.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},o.prototype._destroy=function(e,t){var n=this;i.prototype._destroy.call(this,e,(function(e){t(e),n.emit("close")}))}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var i=new Uint8Array(16);e.exports=function(){return n(i),i}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,r=n;return[r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],"-",r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]],r[e[i++]]].join("")}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return e.apply(t,n)}}},function(e,t,n){"use strict";var i=n(2);function r(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(i.isURLSearchParams(t))s=t.toString();else{var o=[];i.forEach(t,(function(e,t){null!=e&&(i.isArray(e)?t+="[]":e=[e],i.forEach(e,(function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),o.push(r(t)+"="+r(e))})))})),s=o.join("&")}if(s){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},function(e,t,n){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";(function(t){var i=n(2);e.exports=function(e,n){n=n||new FormData;var r=[];function s(e){return null===e?"":i.isDate(e)?e.toISOString():i.isArrayBuffer(e)||i.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):t.from(e):e}return function e(t,o){if(i.isPlainObject(t)||i.isArray(t)){if(-1!==r.indexOf(t))throw Error("Circular reference detected in "+o);r.push(t),i.forEach(t,(function(t,r){if(!i.isUndefined(t)){var a,c=o?o+"."+r:r;if(t&&!o&&"object"==typeof t)if(i.endsWith(r,"{}"))t=JSON.stringify(t);else if(i.endsWith(r,"[]")&&(a=i.toArray(t)))return void a.forEach((function(e){!i.isUndefined(e)&&n.append(c,s(e))}));e(t,c)}})),r.pop()}else n.append(o,s(t))}(e),n}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";var i=n(2),r=n(94),s=n(95),o=n(48),a=n(52),c=n(98),l=n(99),u=n(49),p=n(13),d=n(21),h=n(100);e.exports=function(e){return new Promise((function(t,n){var f,m=e.data,g=e.headers,v=e.responseType;function b(){e.cancelToken&&e.cancelToken.unsubscribe(f),e.signal&&e.signal.removeEventListener("abort",f)}i.isFormData(m)&&i.isStandardBrowserEnv()&&delete g["Content-Type"];var y=new XMLHttpRequest;if(e.auth){var _=e.auth.username||"",S=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";g.Authorization="Basic "+btoa(_+":"+S)}var w=a(e.baseURL,e.url);function x(){if(y){var i="getAllResponseHeaders"in y?c(y.getAllResponseHeaders()):null,s={data:v&&"text"!==v&&"json"!==v?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:i,config:e,request:y};r((function(e){t(e),b()}),(function(e){n(e),b()}),s),y=null}}if(y.open(e.method.toUpperCase(),o(w,e.params,e.paramsSerializer),!0),y.timeout=e.timeout,"onloadend"in y?y.onloadend=x:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(x)},y.onabort=function(){y&&(n(new p("Request aborted",p.ECONNABORTED,e,y)),y=null)},y.onerror=function(){n(new p("Network Error",p.ERR_NETWORK,e,y,y)),y=null},y.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",i=e.transitional||u;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new p(t,i.clarifyTimeoutError?p.ETIMEDOUT:p.ECONNABORTED,e,y)),y=null},i.isStandardBrowserEnv()){var T=(e.withCredentials||l(w))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;T&&(g[e.xsrfHeaderName]=T)}"setRequestHeader"in y&&i.forEach(g,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete g[t]:y.setRequestHeader(t,e)})),i.isUndefined(e.withCredentials)||(y.withCredentials=!!e.withCredentials),v&&"json"!==v&&(y.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&y.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&y.upload&&y.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(f=function(e){y&&(n(!e||e&&e.type?new d:e),y.abort(),y=null)},e.cancelToken&&e.cancelToken.subscribe(f),e.signal&&(e.signal.aborted?f():e.signal.addEventListener("abort",f))),m||(m=null);var k=h(w);k&&-1===["http","https","file"].indexOf(k)?n(new p("Unsupported protocol "+k+":",p.ERR_BAD_REQUEST,e)):y.send(m)}))}},function(e,t,n){"use strict";var i=n(96),r=n(97);e.exports=function(e,t){return e&&!i(t)?r(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var i=n(2);e.exports=function(e,t){t=t||{};var n={};function r(e,t){return i.isPlainObject(e)&&i.isPlainObject(t)?i.merge(e,t):i.isPlainObject(t)?i.merge({},t):i.isArray(t)?t.slice():t}function s(n){return i.isUndefined(t[n])?i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function o(e){if(!i.isUndefined(t[e]))return r(void 0,t[e])}function a(n){return i.isUndefined(t[n])?i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function c(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var l={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return i.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||s,r=t(e);i.isUndefined(r)&&t!==c||(n[e]=r)})),n}},function(e,t){e.exports={version:"0.27.2"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(109),r=function(){function e(e){this.options=e,this.attempt=0}return e.prototype.apply=function(){var e=this;return new Promise((function(t){return setTimeout(t,e.jitteredDelay)}))},e.prototype.setAttemptNumber=function(e){this.attempt=e},Object.defineProperty(e.prototype,"jitteredDelay",{get:function(){return i.JitterFactory(this.options)(this.delay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"delay",{get:function(){var e=this.options.startingDelay,t=this.options.timeMultiple,n=this.numOfDelayedAttempts,i=e*Math.pow(t,n);return Math.min(i,this.options.maxDelay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt},enumerable:!0,configurable:!0}),e}();t.Delay=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.define=t.XMLElement=t.Translator=t.Registry=t.StreamParser=t.parse=t.Parser=void 0;const i=n(0),r=i.__importDefault(n(23));t.XMLElement=r.default;const s=i.__importDefault(n(126));t.Registry=s.default;const o=i.__importDefault(n(58));t.Translator=o.default,i.__exportStar(n(24),t),i.__exportStar(n(31),t),i.__exportStar(n(128),t);var a=n(32);Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return i.__importDefault(a).default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return a.parse}});var c=n(129);Object.defineProperty(t,"StreamParser",{enumerable:!0,get:function(){return i.__importDefault(c).default}}),t.define=function(e){return t=>{t.define(e)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(31);t.default=class{constructor(){this.parents=new Set,this.placeholder=!1,this.typeField="",this.versionField="",this.defaultType="",this.defaultVersion="",this.languageField="lang",this.typeValues=new Map,this.typeOrders=new Map,this.importers=new Map,this.exporters=new Map,this.children=new Map,this.childrenIndex=new Map,this.implicitChildren=new Set,this.contexts=new Map}addChild(e,t,n=!1,i,r){const s={multiple:n||!1,name:e,selector:i,translator:t},o=this.children.get(e);if(!o){s.translator.parents.add(this),this.children.set(e,s);for(const[n]of t.importers)this.implicitChildren.has(n)||this.childrenIndex.set(n,e);return void(r&&this.implicitChildren.add(r))}const a=o.translator;o.multiple=n,i&&o.selector&&i!==o.selector&&(o.selector=void 0);for(const[n,i]of t.importers){const[r,s]=(a.typeValues.get(n)||"").split("__v__");a.updateDefinition({contexts:t.contexts,element:i.element,exporterOrdering:new Map,exporters:new Map,importerOrdering:i.fieldOrders,importers:i.fields,namespace:i.namespace,optionalNamespaces:new Map,type:r,version:s}),this.implicitChildren.has(n)||this.childrenIndex.set(n,e)}for(const[e,n]of t.exporters){const[i,r]=e.split("__v__");a.updateDefinition({contexts:t.contexts,element:n.element,exporterOrdering:n.fieldOrders,exporters:n.fields,importerOrdering:new Map,importers:new Map,namespace:n.namespace,optionalNamespaces:n.optionalNamespaces,type:i,version:r})}}addContext(e,t,n,i,r,s){t&&(e=`${e}[${t}]`);let o=this.contexts.get(e);o||(o={typeField:"",versionField:"",typeValues:new Map}),s&&(o.impliedType=r),o.typeField=n||"",o.typeValues.set(i,r),this.contexts.set(e,o)}getChild(e){const t=this.children.get(e);if(t)return t.translator}getImportKey(e){return this.childrenIndex.get(`{${e.getNamespace()}}${e.getName()}`)}updateDefinition(e){const t=`{${e.namespace}}${e.element}`,n=e.type||this.defaultType,i=e.version||this.defaultVersion,r=i?`${n}__v__${i}`:n,s=this.importers.get(t)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace};for(const[t,n]of e.importers)s.fields.set(t,n);for(const[t,n]of e.importerOrdering)s.fieldOrders.set(t,n);this.importers.set(t,s);const o=this.exporters.get(r)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace,optionalNamespaces:e.optionalNamespaces};for(const[t,n]of e.exporters)o.fields.set(t,n);for(const[t,n]of e.exporterOrdering)o.fieldOrders.set(t,n);for(const[t,n]of e.optionalNamespaces)o.optionalNamespaces.set(t,n);this.exporters.set(r,o);for(const[t,n]of e.contexts){const e=this.contexts.get(t)||{impliedType:void 0,typeField:n.typeField,versionField:n.versionField,typeValues:new Map};e.typeField||(e.typeField=n.typeField),e.versionField||(e.versionField=n.versionField),e.impliedType||(e.impliedType=n.impliedType);for(const[t,i]of n.typeValues)e.typeValues.set(t,i);this.contexts.set(t,e)}if(e.type)this.typeValues.set(t,r),e.typeOrder&&e.type&&this.typeOrders.set(e.type,e.typeOrder);else if(this.typeField&&!e.type){for(const[,t]of this.importers){for(const[n,i]of e.importers)t.fields.set(n,i);for(const[n,i]of e.importerOrdering)t.fieldOrders.set(n,i)}for(const[,t]of this.exporters){for(const[n,i]of e.exporters)t.fields.set(n,i);for(const[n,i]of e.exporterOrdering)t.fieldOrders.set(n,i)}}}replaceWith(e){for(const[t,n]of this.children)e.children.set(t,n);for(const[t,n]of this.childrenIndex)e.childrenIndex.set(t,n);for(const[t,n]of this.contexts)e.contexts.set(t,n);for(const t of this.implicitChildren)e.implicitChildren.add(t);for(const t of this.parents)for(const n of t.children.values())n.translator===this&&(n.translator=e);this.parents=new Set}import(e,t){const n=`{${e.getNamespace()}}${e.getName()}`,i={},r=this.importers.get(n);if(!r)return;const s=this.typeValues.get(n)||"",[o,a]=s.split("__v__"),c=t.path||"";let l;if(t.pathSelector&&(l=this.contexts.get(`${c}[${t.pathSelector}]`)),l||(l=this.contexts.get(c)),l){if(!l.impliedType){const e=l.typeValues.get(n)||"";e&&(i[l.typeField]=e)}}else this.typeField&&o&&o!==this.defaultType&&(i[this.typeField]=o);this.versionField&&a&&a!==this.defaultVersion&&(i[this.versionField]=a);const u={...t,data:i,importer:r,lang:(e.getAttribute("xml:lang")||t.lang||"").toLowerCase(),pathSelector:o,translator:this},p=[...r.fieldOrders.entries()].sort((e,t)=>e[1]>t[1]?-1:e[1]<t[1]?1:0),d=p.filter(e=>e[1]>=0),h=p.filter(e=>e[1]<0);for(const[n]of d){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}for(const n of e.children){if("string"==typeof n)continue;const e=`{${n.getNamespace()}}${n.getName()}`,r=this.childrenIndex.get(e);if(!r)continue;u.path=`${t.path}.${r}`;const{translator:s,multiple:a,selector:c}=this.children.get(r);if(!c||c===o){const e=s.import(n,u);void 0!==e&&(a?(i[r]||(i[r]=[]),i[r].push(e)):i[r]?i[r]=s.resolveCollision(i[r],e):i[r]=e)}}for(const[n]of h){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}return i}export(e,t){if(!e)return;let n=this.defaultType,r=this.defaultVersion;const s=t.path||"";let o;t.pathSelector&&(o=this.contexts.get(`${s}[${t.pathSelector}]`)),o||(o=this.contexts.get(s)),o?n=o.impliedType||e[o.typeField]||this.defaultType:this.typeField&&(n=e[this.typeField]||this.defaultType),this.versionField&&(r=e[this.versionField]||this.defaultVersion);const a=r?`${n}__v__${r}`:n,c=this.exporters.get(a);if(!c)return;const l=i.createElement(c.namespace,c.element,t.namespace,t.element);t.element&&(l.parent=t.element);for(const[e,t]of c.optionalNamespaces)l.addOptionalNamespace(e,t);const u={...t,data:e,element:l,exporter:c,lang:(e[this.languageField]||t.lang||"").toLowerCase(),namespace:l.getDefaultNamespace(),pathSelector:n,translator:this},p=c.fields.get(this.languageField);p&&p(l,e[this.languageField],t);const d=Object.keys(e);d.sort((e,t)=>(c.fieldOrders.get(e)||1e5)-(c.fieldOrders.get(t)||1e5));for(const i of d){if(i===this.languageField)continue;const r=e[i],s=c.fields.get(i);if(s){s(l,r,u);continue}const o=this.children.get(i);if(!o)continue;u.path=`${t.path?t.path+".":""}${i}`;const{translator:a,multiple:p,selector:d}=o;if(!d||d===n){let e;e=p?null!=r?r:[]:[r];for(const t of e){const e=a.export(t,u);e&&l.appendChild(e)}}}return l}resolveCollision(e,t){return(this.typeOrders.get(e[this.typeField]||this.defaultType)||0)<=(this.typeOrders.get(t[this.typeField]||this.defaultType)||0)?e:t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Receiver=t.Sender=void 0;const i=n(0),r=n(3),s=i.__importStar(n(33)),o=n(9),a=n(11),c=i.__importDefault(n(34)),l=n(26),u=n(35);class p extends r.EventEmitter{constructor(e={}){super(),this.config={chunkSize:16384,hash:"sha-1",...e},this.file=void 0,this.channel=void 0,this.hash=s.createHash(this.config.hash)}send(e,t){if(this.file&&this.channel)return;this.file=e,this.channel=t,this.channel.binaryType="arraybuffer";const n=new FileReader;let i=0,r=!1;const s=()=>{if(r||i>=e.size)return;r=!0;const t=e.slice(i,i+this.config.chunkSize);n.readAsArrayBuffer(t)};t.bufferedAmountLowThreshold=8*this.config.chunkSize,t.onbufferedamountlow=()=>{s()},n.addEventListener("load",t=>{const n=t.target.result;r=!1,i+=n.byteLength,this.channel.send(n),this.hash.update(new Uint8Array(n)),this.emit("progress",i,e.size,n),i<e.size?this.channel.bufferedAmount<=this.channel.bufferedAmountLowThreshold&&s():(this.emit("progress",e.size,e.size,null),this.emit("sentFile",{algorithm:this.config.hash,name:e.name,size:e.size,value:this.hash.digest()}))}),s()}}t.Sender=p;class d extends r.EventEmitter{constructor(e={}){super(),this.config={hash:"sha-1",...e},this.receiveBuffer=[],this.received=0,this.channel=void 0,this.hash=s.createHash(this.config.hash)}receive(e,t){this.metadata=e,this.channel=t,this.channel.binaryType="arraybuffer",this.channel.onmessage=e=>{const t=e.data.byteLength;this.received+=t,this.receiveBuffer.push(e.data),e.data&&this.hash.update(new Uint8Array(e.data)),this.emit("progress",this.received,this.metadata.size,e.data),this.received===this.metadata.size?(this.metadata.actualhash=this.hash.digest("hex"),this.emit("receivedFile",new Blob(this.receiveBuffer),this.metadata),this.receiveBuffer=[]):this.received>this.metadata.size&&(console.error("received more than expected, discarding..."),this.receiveBuffer=[])}}}t.Receiver=d;class h extends c.default{constructor(e){super(e),this.sender=void 0,this.receiver=void 0,this.file=void 0}async start(e,t){if(t=t||(()=>{}),!e||"function"==typeof e)throw new Error("File object required");this.state="pending",this.role="initiator",this.file=e,this.sender=new p,this.sender.on("progress",(e,t)=>{this._log("info","Send progress "+e+"/"+t)}),this.sender.on("sentFile",e=>{this._log("info","Sent file",e.name),this.send(o.JingleAction.SessionInfo,{info:{creator:o.JingleSessionRole.Initiator,file:{hashes:[{algorithm:e.algorithm,value:e.value}]},infoType:o.JINGLE_INFO_CHECKSUM_5,name:this.contentName}}),this.parent.emit("sentFile",this,e)}),this.channel=this.pc.createDataChannel("filetransfer",{ordered:!0}),this.channel.onopen=()=>{this.sender.send(this.file,this.channel)};try{await this.processLocal(o.JingleAction.SessionInitiate,async()=>{const t=await this.pc.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1}),n=l.importFromSDP(t.sdp),i=u.convertIntermediateToRequest(n,this.role,this.transportType);this.contentName=i.contents[0].name,i.sid=this.sid,i.action=o.JingleAction.SessionInitiate,i.contents[0].application={applicationType:a.NS_JINGLE_FILE_TRANSFER_5,file:{date:e.lastModified?new Date(e.lastModified):void 0,hashesUsed:[{algorithm:"sha-1"}],name:e.name,size:e.size}},this.send("session-initiate",i),await this.pc.setLocalDescription(t)}),t()}catch(e){return this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}async accept(e){this._log("info","Accepted incoming session"),this.role="responder",this.state="active",e=e||(()=>{});try{await this.processLocal(o.JingleAction.SessionAccept,async()=>{const e=await this.pc.createAnswer(),t=l.importFromSDP(e.sdp),n=u.convertIntermediateToRequest(t,this.role,this.transportType);n.sid=this.sid,n.action="session-accept";for(const e of n.contents)e.creator="initiator";this.contentName=n.contents[0].name,this.send("session-accept",n),await this.pc.setLocalDescription(e),await this.processBufferedCandidates()}),e()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}async onSessionInitiate(e,t){this._log("info","Initiating incoming session"),this.role="responder",this.state="pending",this.transportType=e.contents[0].transport.transportType;const n=u.convertRequestToIntermediate(e,this.peerRole),i=l.exportToSDP(n),r=e.contents[0].application,s=r.file.hashesUsed?r.file.hashesUsed:r.file.hashes||[];this.receiver=new d({hash:s[0]&&s[0].algorithm}),this.receiver.on("progress",(e,t)=>{this._log("info","Receive progress "+e+"/"+t)}),this.receiver.on("receivedFile",e=>{this.receivedFile=e,this._maybeReceivedFile()}),this.receiver.metadata=r.file,this.pc.addEventListener("datachannel",e=>{this.channel=e.channel,this.receiver.receive(this.receiver.metadata,e.channel)});try{await this.pc.setRemoteDescription({type:"offer",sdp:i}),await this.processBufferedCandidates(),t()}catch(e){this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}onSessionInfo(e,t){const n=e.info;n&&n.file&&n.file.hashes&&(this.receiver.metadata.hashes=n.file.hashes,this.receiver.metadata.actualhash&&this._maybeReceivedFile(),t())}_maybeReceivedFile(){if(this.receiver.metadata.hashes&&this.receiver.metadata.hashes.length){for(const e of this.receiver.metadata.hashes||[])if(e.value&&e.value.toString("hex")===this.receiver.metadata.actualhash)return this._log("info","File hash matches"),this.parent.emit("receivedFile",this,this.receivedFile,this.receiver.metadata),void this.end("success");this._log("error","File hash does not match"),this.end("media-error")}}}t.default=h},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.reviveData=t.uuid=t.octetCompare=t.sleep=t.timeoutPromise=void 0;const i=n(33),r=[];for(let e=0;e<256;++e)r[e]=(e+256).toString(16).substr(1);t.timeoutPromise=async function(e,t,n=(()=>{})){let i;const r=await Promise.race([e,new Promise((e,r)=>{i=setTimeout(()=>r(n()),t)})]);return clearTimeout(i),r},t.sleep=async function(e){return new Promise(t=>{setTimeout(()=>t(),e)})},t.octetCompare=function(t,n){const i="string"==typeof t?e.from(t,"utf8"):t,r="string"==typeof n?e.from(n,"utf8"):n;return i.compare(r)},t.uuid=function(){const e=i.randomBytes(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=0;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[15]]].join("")};const s=new Set(["date","expires","httpUploadRetry","idleSince","published","since","stamp","timestamp","updated","utc"]),o=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)(?:Z|((\+|-)([\d|:]*)))?$/;t.reviveData=function(t,n){return s.has(t)&&n&&"string"==typeof n&&o.test(n)?new Date(n):n&&"object"==typeof n&&"Buffer"===n.type&&Array.isArray(n.data)?e.from(n):n}}).call(this,n(10).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(9),s=i.__importDefault(n(34)),o=n(26),a=n(35);function c(e){const t=e.application;if(t.streams&&t.streams.length&&t.sources&&t.sources.length){const e=t.streams[0];t.sources[0].parameters.msid=`${e.id} ${e.track}`,t.sourceGroups&&t.sourceGroups.length>0&&t.sources.push({parameters:{cname:t.sources[0].parameters.cname,msid:`${e.id} ${e.track}`},ssrc:t.sourceGroups[0].sources[1]})}}class l extends s.default{constructor(e){if(super(e),this.includesAudio=!1,this.includesVideo=!1,this._ringing=!1,this.pc.addEventListener("track",e=>{this.onAddTrack(e.track,e.streams[0])}),e.stream)for(const t of e.stream.getTracks())this.addTrack(t,e.stream)}get ringing(){return this._ringing}set ringing(e){e!==this._ringing&&(this._ringing=e)}get streams(){return"closed"!==this.pc.signalingState?this.pc.getRemoteStreams():[]}async start(e,t){this.state="pending",1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this.role="initiator",this.offerOptions=e;try{await this.processLocal(r.JingleAction.SessionInitiate,async()=>{const t=await this.pc.createOffer(e),n=o.importFromSDP(t.sdp),i=a.convertIntermediateToRequest(n,this.role,this.transportType);i.sid=this.sid,i.action=r.JingleAction.SessionInitiate;for(const e of i.contents||[])e.creator="initiator",c(e);await this.pc.setLocalDescription(t),this.send("session-initiate",i)}),t()}catch(e){this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}async accept(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this._log("info","Accepted incoming session"),this.state="active",this.role="responder";try{await this.processLocal(r.JingleAction.SessionAccept,async()=>{const t=await this.pc.createAnswer(e),n=o.importFromSDP(t.sdp),i=a.convertIntermediateToRequest(n,this.role,this.transportType);i.sid=this.sid,i.action=r.JingleAction.SessionAccept;for(const e of i.contents||[])e.creator="initiator";await this.pc.setLocalDescription(t),await this.processBufferedCandidates(),this.send("session-accept",i)}),t()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}end(e="success",t=!1){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.end(e,t)}ring(){return this.processLocal("ring",async()=>{this._log("info","Ringing on incoming session"),this.ringing=!0,this.send(r.JingleAction.SessionInfo,{info:{infoType:r.JINGLE_INFO_RINGING}})})}mute(e,t){return this.processLocal("mute",async()=>{this._log("info","Muting",t),this.send(r.JingleAction.SessionInfo,{info:{creator:e,infoType:r.JINGLE_INFO_MUTE,name:t}})})}unmute(e,t){return this.processLocal("unmute",async()=>{this._log("info","Unmuting",t),this.send(r.JingleAction.SessionInfo,{info:{creator:e,infoType:r.JINGLE_INFO_UNMUTE,name:t}})})}hold(){return this.processLocal("hold",async()=>{this._log("info","Placing on hold"),this.send("session-info",{info:{infoType:r.JINGLE_INFO_HOLD}})})}resume(){return this.processLocal("resume",async()=>{this._log("info","Resuming from hold"),this.send("session-info",{info:{infoType:r.JINGLE_INFO_ACTIVE}})})}addTrack(e,t,n){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",async()=>{this.pc.addTrack?this.pc.addTrack(e,t):this.pc.addStream(t),n&&n()})}async removeTrack(e,t){return this.processLocal("removetrack",async()=>{if(this.pc.removeTrack(e),t)return t()})}onAddTrack(e,t){this._log("info","Track added"),this.parent.emit("peerTrackAdded",this,e,t)}onRemoveTrack(e){this._log("info","Track removed"),this.parent.emit("peerTrackRemoved",this,e)}async onSessionInitiate(e,t){this._log("info","Initiating incoming session"),this.state="pending",this.role="responder",this.transportType=e.contents[0].transport.transportType;const n=a.convertRequestToIntermediate(e,this.peerRole);for(const e of n.media)"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),e.streams||(e.streams=[{stream:"legacy",track:e.kind}]);const i=o.exportToSDP(n);try{return await this.pc.setRemoteDescription({type:"offer",sdp:i}),await this.processBufferedCandidates(),t()}catch(e){return this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}onSessionTerminate(e,t){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.onSessionTerminate(e,t)}onSessionInfo(e,t){const n=e.info||{infoType:""};switch(n.infoType){case r.JINGLE_INFO_RINGING:return this._log("info","Outgoing session is ringing"),this.ringing=!0,this.parent.emit("ringing",this),t();case r.JINGLE_INFO_HOLD:return this._log("info","On hold"),this.parent.emit("hold",this),t();case r.JINGLE_INFO_UNHOLD:case r.JINGLE_INFO_ACTIVE:return this._log("info","Resuming from hold"),this.parent.emit("resumed",this),t();case r.JINGLE_INFO_MUTE:return this._log("info","Muting",n),this.parent.emit("mute",this,n),t();case r.JINGLE_INFO_UNMUTE:return this._log("info","Unmuting",n),this.parent.emit("unmute",this,n),t()}return t()}}t.default=l},function(e,t,n){const i=n(63);e.exports=class extends i{constructor(e){super(),this.backoffStrategy_=e,this.maxNumberOfRetry_=-1,this.backoffNumber_=0,this.backoffDelay_=0,this.timeoutID_=-1,this.handlers={backoff:this.onBackoff_.bind(this)}}failAfter(e){if(void 0!==e&&e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got "+e);this.maxNumberOfRetry_=e}backoff(e){if(-1!==this.timeoutID_)throw new Error("Backoff in progress");this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))}onBackoff_(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++}reset(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1}}},function(e,t){function n(){}e.exports=n,n.mixin=function(e){var t=e.prototype||e;t.isWildEmitter=!0,t.on=function(e,t,n){this.callbacks=this.callbacks||{};var i=3===arguments.length,r=i?arguments[1]:void 0,s=i?arguments[2]:arguments[1];return s._groupName=r,(this.callbacks[e]=this.callbacks[e]||[]).push(s),this},t.once=function(e,t,n){var i=this,r=3===arguments.length,s=r?arguments[1]:void 0,o=r?arguments[2]:arguments[1];function a(){i.off(e,a),o.apply(this,arguments)}return this.on(e,s,a),this},t.releaseGroup=function(e){var t,n,i,r;for(t in this.callbacks=this.callbacks||{},this.callbacks)for(n=0,i=(r=this.callbacks[t]).length;n<i;n++)r[n]._groupName===e&&(r.splice(n,1),n--,i--);return this},t.off=function(e,t){this.callbacks=this.callbacks||{};var n,i=this.callbacks[e];return i?1===arguments.length?(delete this.callbacks[e],this):(-1!==(n=i.indexOf(t))&&(i.splice(n,1),0===i.length&&delete this.callbacks[e]),this):this},t.emit=function(e){this.callbacks=this.callbacks||{};var t,n,i,r=[].slice.call(arguments,1),s=this.callbacks[e],o=this.getWildcardCallbacks(e);if(s)for(t=0,n=(i=s.slice()).length;t<n&&i[t];++t)i[t].apply(this,r);if(o)for(n=o.length,t=0,n=(i=o.slice()).length;t<n&&i[t];++t)i[t].apply(this,[e].concat(r));return this},t.getWildcardCallbacks=function(e){this.callbacks=this.callbacks||{};var t,n,i=[];for(t in this.callbacks)n=t.split("*"),("*"===t||2===n.length&&e.slice(0,n[0].length)===n[0])&&(i=i.concat(this.callbacks[t]));return i}},n.mixin(n)},function(e,t){function n(e){return null!=e}e.exports=class{constructor(e){if(n((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(n(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(n(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}getMaxDelay(){return this.maxDelay_}getInitialDelay(){return this.initialDelay_}next(){const e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)}next_(){throw new Error("Not implemented")}reset(){this.reset_()}reset_(){throw new Error("Not implemented")}}},function(e,t,n){const i=n(64);e.exports=class extends i{constructor(e){super(e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}next_(){const e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e}reset_(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0}}},function(e,t,n){"use strict";var i;n.r(t);var r=new Uint8Array(16);function s(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(r)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var a=function(e){return"string"==typeof e&&o.test(e)},c=[],l=0;l<256;++l)c.push((l+256).toString(16).substr(1));var u,p,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n},h=0,f=0;var m=function(e,t,n){var i=t&&n||0,r=t||new Array(16),o=(e=e||{}).node||u,a=void 0!==e.clockseq?e.clockseq:p;if(null==o||null==a){var c=e.random||(e.rng||s)();null==o&&(o=u=[1|c[0],c[1],c[2],c[3],c[4],c[5]]),null==a&&(a=p=16383&(c[6]<<8|c[7]))}var l=void 0!==e.msecs?e.msecs:Date.now(),m=void 0!==e.nsecs?e.nsecs:f+1,g=l-h+(m-f)/1e4;if(g<0&&void 0===e.clockseq&&(a=a+1&16383),(g<0||l>h)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");h=l,f=m,p=a;var v=(1e4*(268435455&(l+=122192928e5))+m)%4294967296;r[i++]=v>>>24&255,r[i++]=v>>>16&255,r[i++]=v>>>8&255,r[i++]=255&v;var b=l/4294967296*1e4&268435455;r[i++]=b>>>8&255,r[i++]=255&b,r[i++]=b>>>24&15|16,r[i++]=b>>>16&255,r[i++]=a>>>8|128,r[i++]=255&a;for(var y=0;y<6;++y)r[i+y]=o[y];return t||d(r)};var g=function(e){if(!a(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};var v=function(e,t,n){function i(e,i,r,s){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=g(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o=new Uint8Array(16+e.length);if(o.set(i),o.set(e,i.length),(o=n(o))[6]=15&o[6]|t,o[8]=63&o[8]|128,r){s=s||0;for(var a=0;a<16;++a)r[s+a]=o[a];return r}return d(o)}try{i.name=e}catch(e){}return i.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",i.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",i};function b(e){return 14+(e+64>>>9<<4)+1}function y(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function _(e,t,n,i,r,s){return y((o=y(y(t,e),y(i,s)))<<(a=r)|o>>>32-a,n);var o,a}function S(e,t,n,i,r,s,o){return _(t&n|~t&i,e,t,r,s,o)}function w(e,t,n,i,r,s,o){return _(t&i|n&~i,e,t,r,s,o)}function x(e,t,n,i,r,s,o){return _(t^n^i,e,t,r,s,o)}function T(e,t,n,i,r,s,o){return _(n^(t|~i),e,t,r,s,o)}var k=v("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,i=0;i<n;i+=8){var r=e[i>>5]>>>i%32&255,s=parseInt("0123456789abcdef".charAt(r>>>4&15)+"0123456789abcdef".charAt(15&r),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[b(t)-1]=t;for(var n=1732584193,i=-271733879,r=-1732584194,s=271733878,o=0;o<e.length;o+=16){var a=n,c=i,l=r,u=s;n=S(n,i,r,s,e[o],7,-680876936),s=S(s,n,i,r,e[o+1],12,-389564586),r=S(r,s,n,i,e[o+2],17,606105819),i=S(i,r,s,n,e[o+3],22,-1044525330),n=S(n,i,r,s,e[o+4],7,-176418897),s=S(s,n,i,r,e[o+5],12,1200080426),r=S(r,s,n,i,e[o+6],17,-1473231341),i=S(i,r,s,n,e[o+7],22,-45705983),n=S(n,i,r,s,e[o+8],7,1770035416),s=S(s,n,i,r,e[o+9],12,-1958414417),r=S(r,s,n,i,e[o+10],17,-42063),i=S(i,r,s,n,e[o+11],22,-1990404162),n=S(n,i,r,s,e[o+12],7,1804603682),s=S(s,n,i,r,e[o+13],12,-40341101),r=S(r,s,n,i,e[o+14],17,-1502002290),i=S(i,r,s,n,e[o+15],22,1236535329),n=w(n,i,r,s,e[o+1],5,-165796510),s=w(s,n,i,r,e[o+6],9,-1069501632),r=w(r,s,n,i,e[o+11],14,643717713),i=w(i,r,s,n,e[o],20,-373897302),n=w(n,i,r,s,e[o+5],5,-701558691),s=w(s,n,i,r,e[o+10],9,38016083),r=w(r,s,n,i,e[o+15],14,-660478335),i=w(i,r,s,n,e[o+4],20,-405537848),n=w(n,i,r,s,e[o+9],5,568446438),s=w(s,n,i,r,e[o+14],9,-1019803690),r=w(r,s,n,i,e[o+3],14,-187363961),i=w(i,r,s,n,e[o+8],20,1163531501),n=w(n,i,r,s,e[o+13],5,-1444681467),s=w(s,n,i,r,e[o+2],9,-51403784),r=w(r,s,n,i,e[o+7],14,1735328473),i=w(i,r,s,n,e[o+12],20,-1926607734),n=x(n,i,r,s,e[o+5],4,-378558),s=x(s,n,i,r,e[o+8],11,-2022574463),r=x(r,s,n,i,e[o+11],16,1839030562),i=x(i,r,s,n,e[o+14],23,-35309556),n=x(n,i,r,s,e[o+1],4,-1530992060),s=x(s,n,i,r,e[o+4],11,1272893353),r=x(r,s,n,i,e[o+7],16,-155497632),i=x(i,r,s,n,e[o+10],23,-1094730640),n=x(n,i,r,s,e[o+13],4,681279174),s=x(s,n,i,r,e[o],11,-358537222),r=x(r,s,n,i,e[o+3],16,-722521979),i=x(i,r,s,n,e[o+6],23,76029189),n=x(n,i,r,s,e[o+9],4,-640364487),s=x(s,n,i,r,e[o+12],11,-421815835),r=x(r,s,n,i,e[o+15],16,530742520),i=x(i,r,s,n,e[o+2],23,-995338651),n=T(n,i,r,s,e[o],6,-198630844),s=T(s,n,i,r,e[o+7],10,1126891415),r=T(r,s,n,i,e[o+14],15,-1416354905),i=T(i,r,s,n,e[o+5],21,-57434055),n=T(n,i,r,s,e[o+12],6,1700485571),s=T(s,n,i,r,e[o+3],10,-1894986606),r=T(r,s,n,i,e[o+10],15,-1051523),i=T(i,r,s,n,e[o+1],21,-2054922799),n=T(n,i,r,s,e[o+8],6,1873313359),s=T(s,n,i,r,e[o+15],10,-30611744),r=T(r,s,n,i,e[o+6],15,-1560198380),i=T(i,r,s,n,e[o+13],21,1309151649),n=T(n,i,r,s,e[o+4],6,-145523070),s=T(s,n,i,r,e[o+11],10,-1120210379),r=T(r,s,n,i,e[o+2],15,718787259),i=T(i,r,s,n,e[o+9],21,-343485551),n=y(n,a),i=y(i,c),r=y(r,l),s=y(s,u)}return[n,i,r,s]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(b(t)),i=0;i<t;i+=8)n[i>>5]|=(255&e[i/8])<<i%32;return n}(e),8*e.length))}));var I=function(e,t,n){var i=(e=e||{}).random||(e.rng||s)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return d(i)};function j(e,t,n,i){switch(e){case 0:return t&n^~t&i;case 1:return t^n^i;case 2:return t&n^t&i^n&i;case 3:return t^n^i}}function E(e,t){return e<<t|e>>>32-t}var N=v("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=[];for(var r=0;r<i.length;++r)e.push(i.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var s=e.length/4+2,o=Math.ceil(s/16),a=new Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[64*c+4*u]<<24|e[64*c+4*u+1]<<16|e[64*c+4*u+2]<<8|e[64*c+4*u+3];a[c]=l}a[o-1][14]=8*(e.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(e.length-1)&4294967295;for(var p=0;p<o;++p){for(var d=new Uint32Array(80),h=0;h<16;++h)d[h]=a[p][h];for(var f=16;f<80;++f)d[f]=E(d[f-3]^d[f-8]^d[f-14]^d[f-16],1);for(var m=n[0],g=n[1],v=n[2],b=n[3],y=n[4],_=0;_<80;++_){var S=Math.floor(_/20),w=E(m,5)+j(S,g,v,b)+y+t[S]+d[_]>>>0;y=b,b=v,v=E(g,30)>>>0,g=m,m=w}n[0]=n[0]+m>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+v>>>0,n[3]=n[3]+b>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));var C=function(e){if(!a(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};n.d(t,"v1",(function(){return m})),n.d(t,"v3",(function(){return k})),n.d(t,"v4",(function(){return I})),n.d(t,"v5",(function(){return N})),n.d(t,"NIL",(function(){return"00000000-0000-0000-0000-000000000000"})),n.d(t,"version",(function(){return C})),n.d(t,"validate",(function(){return a})),n.d(t,"stringify",(function(){return d})),n.d(t,"parse",(function(){return g}))},function(e,t,n){var i=n(86),r=n(87),s=r;s.v1=i,s.v4=r,e.exports=s},function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(106),o=n(107);t.backOff=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return r(this,(function(i){switch(i.label){case 0:return n=s.getSanitizedOptions(t),[4,new a(e,n).execute()];case 1:return[2,i.sent()]}}))}))};var a=function(){function e(e,t){this.request=e,this.options=t,this.attemptNumber=0}return e.prototype.execute=function(){return i(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:if(this.attemptLimitReached)return[3,7];t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.applyDelay()];case 2:return t.sent(),[4,this.request()];case 3:return[2,t.sent()];case 4:return e=t.sent(),this.attemptNumber++,[4,this.options.retry(e,this.attemptNumber)];case 5:if(!t.sent()||this.attemptLimitReached)throw e;return[3,6];case 6:return[3,0];case 7:throw new Error("Something went wrong.")}}))}))},Object.defineProperty(e.prototype,"attemptLimitReached",{get:function(){return this.attemptNumber>=this.options.numOfAttempts},enumerable:!0,configurable:!0}),e.prototype.applyDelay=function(){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,o.DelayFactory(this.options,this.attemptNumber).apply()];case 1:return e.sent(),[2]}}))}))},e}()},function(e,t,n){"use strict";n.r(t);var i=n(37),r=n(25);for(var s in r)["HttpClient","parseJwt","default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(s);var o=n(17);for(var s in o)["HttpClient","parseJwt","default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(18);n.d(t,"HttpClient",(function(){return a.HttpClient}));var c=n(8);n.d(t,"parseJwt",(function(){return c.parseJwt})),t.default=i.Client},function(e,t,n){t.RateLimiter=n(71),t.TokenBucket=n(38)},function(e,t,n){(function(t){var i=n(38),r=n(72),s=function(e,t,n){this.tokenBucket=new i(e,e,t,null),this.tokenBucket.content=e,this.curIntervalStart=r(),this.tokensThisInterval=0,this.fireImmediately=n};s.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(e,n){if(e>this.tokenBucket.bucketSize)return t.nextTick(n.bind(null,"Requested tokens "+e+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var i=this,s=r();if((s<this.curIntervalStart||s-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=s,this.tokensThisInterval=0),e>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)t.nextTick(n.bind(null,null,-1));else{var o=Math.ceil(this.curIntervalStart+this.tokenBucket.interval-s);setTimeout((function(){i.tokenBucket.removeTokens(e,a)}),o)}return!1}return this.tokenBucket.removeTokens(e,a);function a(t,r){if(t)return n(t,null);i.tokensThisInterval+=e,n(null,r)}},tryRemoveTokens:function(e){if(e>this.tokenBucket.bucketSize)return!1;var t=r();if((t<this.curIntervalStart||t-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=t,this.tokensThisInterval=0),e>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var n=this.tokenBucket.tryRemoveTokens(e);return n&&(this.tokensThisInterval+=e),n},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},e.exports=s}).call(this,n(7))},function(e,t,n){(function(t){e.exports=function(){if(void 0!==t&&t.hrtime){var e=t.hrtime(),n=e[0],i=e[1];return 1e3*n+Math.floor(i/1e6)}return(new Date).getTime()}}).call(this,n(7))},function(e,t,n){"use strict";n.r(t),function(e,i){n.d(t,"Client",(function(){return Ba})),n.d(t,"Constants",(function(){return ds})),n.d(t,"DataForms",(function(){return Ds})),n.d(t,"JID",(function(){return Y})),n.d(t,"JXT",(function(){return vi})),n.d(t,"Jingle",(function(){return Ls})),n.d(t,"Namespaces",(function(){return si})),n.d(t,"RSM",(function(){return Ga})),n.d(t,"RTT",(function(){return za})),n.d(t,"SASL",(function(){return vr})),n.d(t,"Stanzas",(function(){return La})),n.d(t,"Utils",(function(){return Nr})),n.d(t,"VERSION",(function(){return Va})),n.d(t,"core",(function(){return Zs})),n.d(t,"createClient",(function(){return $a})),n.d(t,"getHostMeta",(function(){return ms}));var r=n(0),s=n(14),o=n(3),a=n(4),c=n.n(a),l=n(6),u=n(1);const p=Math.pow(2,32),d=(e,t)=>(e%t+t)%t;class h extends o.EventEmitter{constructor(){super(),this.allowResume=!0,this.lastAck=0,this.handled=0,this.unacked=[],this.inboundStarted=!1,this.outboundStarted=!1,this.id=void 0,this.jid=void 0,this.allowResume=!0,this.started=!1,this.cacheHandler=()=>{},this._reset()}get started(){return this.outboundStarted&&this.inboundStarted}set started(e){e||(this.outboundStarted=!1,this.inboundStarted=!1)}get resumable(){return this.started&&this.allowResume}load(e){var t;this.id=e.id,this.allowResume=null===(t=e.allowResume)||void 0===t||t,this.handled=e.handled,this.lastAck=e.lastAck,this.unacked=e.unacked,this.emit("prebound",e.jid)}cache(e){this.cacheHandler=e}bind(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.jid=e,yield this._cache()}))}enable(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.emit("send",{allowResumption:this.allowResume,type:"enable"})}))}resume(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.emit("send",{handled:this.handled,previousSession:this.id,type:"resume"})}))}enabled(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.id=e.id,this.handled=0,this.inboundStarted=!0,yield this._cache()}))}resumed(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.id=e.previousSession,this.inboundStarted=!0,yield this.process(e,!0),yield this._cache()}))}failed(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield this.process(e);for(const[e,t]of this.unacked)this.emit("failed",{kind:e,stanza:t});this._reset(),yield this._cache()}))}ack(){this.emit("send",{handled:this.handled,type:"ack"})}request(){this.emit("send",{type:"request"})}process(e,t=!1){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(void 0===e.handled)return;const n=d(e.handled-this.lastAck,p);for(let e=0;e<n&&this.unacked.length>0;e++){const[e,t]=this.unacked.shift();this.emit("acked",{kind:e,stanza:t})}if(this.lastAck=e.handled,t){const e=this.unacked;if(this.unacked=[],e.length){this.emit("begin-resend");for(const[t,n]of e)this.emit("resend",{kind:t,stanza:n});this.emit("end-resend")}}yield this._cache()}))}track(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return"sm"!==e||"enable"!==t.type&&"resume"!==t.type?!!this.outboundStarted&&(("message"===e||"presence"===e||"iq"===e)&&(this.unacked.push([e,t]),yield this._cache(),!0)):(this.handled=0,this.outboundStarted=!0,yield this._cache(),!1)}))}handle(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.inboundStarted&&(this.handled=d(this.handled+1,p),yield this._cache())}))}hibernate(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!this.resumable)return this.shutdown();for(const[e,t]of this.unacked)this.emit("hibernated",{kind:e,stanza:t})}))}shutdown(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this.failed({type:"failed"})}))}_cache(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){try{yield this.cacheHandler({allowResume:this.allowResume,handled:this.handled,id:this.id,jid:this.jid,lastAck:this.lastAck,unacked:this.unacked})}catch(e){console.error("Failed to cache stream state",e)}}))}_reset(){this.id="",this.inboundStarted=!1,this.outboundStarted=!1,this.lastAck=0,this.handled=0,this.unacked=[]}}const f={"A.1":{r:"hk:if|le:lf|nf:nv|qg:qv|rg:rj|rm:rp|rr:rt|rv:s3|vn:vv|17m:17n|17q:17v|18g:19g|1an:1ao|1cb:1cg|1e5:1ef|1fb:1ff|1fl:1gb|1gd:1gq|1gs:1gu|1hr:1hv|1im:1iv|1ne:1nf|1pd:1pf|1qb:1rv|1ti:280|29q:29r|2ae:2af|2al:2an|2bh:2c0|2cd:2ce|2ch:2ci|2dj:2dl|2dq:2dr|2e5:2e6|2e9:2ea|2ee:2em|2eo:2er|2f4:2f5|2fr:2g1|2g3:2g4|2gb:2ge|2gh:2gi|2hq:2hr|2i3:2i6|2i9:2ia|2ie:2io|2iv:2j5|2jl:2k0|2lq:2lr|2me:2mf|2mh:2mv|2n1:2n5|2ng:2o0|2od:2oe|2oh:2oi|2pk:2pl|2pq:2pr|2q4:2q6|2q9:2qa|2qe:2ql|2qo:2qr|2r2:2r5|2rh:2s1|2sb:2sd|2sm:2so|2t0:2t2|2t5:2t7|2tb:2td|2tq:2tt|2u3:2u5|2ue:2um|2uo:2v6|2vj:300|31q:31t|32e:32k|32n:32v|332:335|33g:341|35q:35t|36e:36k|36n:36t|372:375|37g:381|39q:39t|3a4:3a5|3ae:3am|3ao:3av|3b2:3b5|3bg:3c1|3cn:3cp|3du:3dv|3e7:3e9|3eb:3ee|3f0:3fh|3fl:3g0|3hr:3hu|3is:3k0|3k5:3k6|3kb:3kc|3ke:3kj|3l8:3l9|3lu:3lv|3me:3mf|3mq:3mr|3mu:3nv|3rb:3rg|3sc:3sf|3ud:3ue|3ug:3vv|41j:41l|41q:41v|42q:44v|466:46f|47p:47q|47s:47v|4aq:4au|4d3:4d7|4fq:4fv|4ie:4if|4iu:4iv|4ke:4kf|4lm:4ln|4m6:4m7|4om:4on|4qr:4r0|4rt:4sv|4vl:500|5jn:5jv|5kt:5kv|5nh:5nv|5ol:5ov|5pn:5pv|5qk:5qv|5rk:5rv|5ut:5uv|5va:5vv|60q:60v|63o:63v|65a:7fv|7ks:7kv|7nq:7nv|7om:7on|7ou:7ov|7q6:7q7|7qe:7qf|7ru:7rv|7uk:7ul|7vg:7vh|82j:82m|82o:82u|834:839|83i:83j|84f:84v|85i:86f|87b:87v|89r:89s|8ac:8ai|8c4:8cf|8uf:8vv|917:91v|92b:92v|9gk:9gl|9ju:9jv|9ka:9o0|9oa:9ob|9qj:9ql|9qv:9r0|9sl:9sn|9tv:9uf|9vc:9vf|ao0:bjv|bnk:bnv|bum:bvf|bvs:bvv|c4n:c4o|c80:c84|c9d:c9g|cdo:cff|cgt:cgv|ci4:cig|cjs:cju|cmc:cmf|crn:crq|cuu:cuv|jdm:jfv|17t6:17vv|194d:194f|1967:1avv|1lt4:1lvv|1uhe:1uhf|1ujb:1unv|1uo7:1uoi|1uoo:1uos|1uti:1uui|1va0:1vaf|1vcg:1vch|1ve8:1vef|1vft:1vfv|1vgg:1vgv|1vh4:1vhf|1vi7:1vi8|1vjc:1vjf|1vnt:1vnu|1vtv:1vu1|1vu8:1vu9|1vug:1vuh|1vuo:1vup|1vut:1vuv|1vvf:1vvo|2000:20nv|20p4:20pf|20qb:20vv|2116:2117|212e:3jvv|3k7m:3k7v|3k97:3k99|3keu:3kvv|3l50:3l51|3l53:3l54|3l57:3l58|3l8b:3l8c|3la7:3la9|3ll4:3ll7|3lua:3lud|3m00:3vvt|59mn:5tvv|5ugu:5vvt|6000:7vvt|8000:9vvt|a000:bvvt|c000:dvvt|e000:fvvt|g000:hvvt|i000:jvvt|k000:lvvt|m000:nvvt|o000:pvvt|q000:rvvt|s002:s00v|s040:tvvt",s:"9p8|9qc|9qe|9qn|9tg|147|bkq|3l2l|3l4t|3l5d|3l5q|3l5s|3l61|3l64|3l86|3l8l|3l8t|3l9q|3l9v|3la5|3lah|16f|c20|ccf|cnv|cvv|1b0|1c8|1d2|1dq|1h0|1nv|1oe|284|2c4|2d9|2dh|2dt|2eu|2h9|2hh|2hk|2hn|2ht|2it|2k4|2kc|2ke|2ki|2l9|2lh|2lk|2m6|2ma|2o4|2p9|2ph|2qu|2s4|2sh|2sr|2st|2tm|2u9|304|30d|30h|319|31k|325|329|344|34d|34h|359|35k|365|369|36v|384|38d|38h|399|3a9|3c4|3di|3ds|3el|3en|3k3|3k9|3ko|3l0|3l4|3l6|3lc|3lq|3m5|3m7|3q8|3so|3tt|412|418|41b|4g7|4i7|4i9|4in|4ip|4k7|4k9|4lf|4lh|4lv|4m1|4mf|4mn|4nf|4of|4oh|4ov|4q7|h1|5od|5rd|5rh|60f|1upn|1upt|1upv|1uq2|1uq5|1vij|1vj7|1vjl|1vo0|1vv7|20ov|7qo|7qq|7qs|7qu|7tl|7u5|7us|7vl|7vv|sb|sd|s000|t2|97v|uf|9go|9o5"},"B.1":{r:"60b:60d|80b:80d|1vg0:1vgf",s:"5d|606|1vnv|830|qf"},"B.2":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|rq:10;tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ui:u5|uj:ud|uk:ub|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|858:3i;3j|882:33|883:5g;33|887:ir|889:5g;36|88b:38|88c:38|88d:38|88g:39|88h:39|88i:3c|88l:3e|88m:3e;3f|88p:3g|88q:3h|88r:3i|88s:3i|88t:3i|890:3j;3d|891:3k;35;3c|892:3k;3d|894:3q|898:3q|89c:32|89d:33|89g:35|89h:36|89j:3d|89u:tj|89v:u0|8a5:34|crh:38;3g;31|crj:31;3l|crl:3f;3m|cs0:3g;31|cs1:3e;31|cs2:ts;31|cs3:3d;31|cs4:3b;31|cs5:3b;32|cs6:3d;32|cs7:37;32|csa:3g;36|csb:3e;36|csc:ts;36|csg:38;3q|csh:3b;38;3q|csi:3d;38;3q|csj:37;38;3q|csk:3k;38;3q|ct9:3g;31|cta:3b;3g;31|ctb:3d;3g;31|ctc:37;3g;31|ctk:3g;3m|ctl:3e;3m|ctm:ts;3m|ctn:3d;3m|cto:3b;3m|ctp:3d;3m|ctq:3g;3n|ctr:3e;3n|cts:ts;3n|ctt:3d;3n|ctu:3b;3n|ctv:3d;3n|cu0:3b;u9|cu1:3d;u9|cu3:32;3h|cu6:33;8gl;3b;37|cu7:33;3f;1e|cu8:34;32|cu9:37;3p|cub:38;3g|cud:3b;3b|cue:3b;3d|cun:3g;38|cup:3g;3g;3d|cuq:3g;3i|cus:3j;3m|cut:3n;32|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd|3l00:31|3l01:32|3l02:33|3l03:34|3l04:35|3l05:36|3l06:37|3l07:38|3l08:39|3l09:3a|3l0a:3b|3l0b:3c|3l0c:3d|3l0d:3e|3l0e:3f|3l0f:3g|3l0g:3h|3l0h:3i|3l0i:3j|3l0j:3k|3l0k:3l|3l0l:3m|3l0m:3n|3l0n:3o|3l0o:3p|3l0p:3q|3l1k:31|3l1l:32|3l1m:33|3l1n:34|3l1o:35|3l1p:36|3l1q:37|3l1r:38|3l1s:39|3l1t:3a|3l1u:3b|3l1v:3c|3l20:3d|3l21:3e|3l22:3f|3l23:3g|3l24:3h|3l25:3i|3l26:3j|3l27:3k|3l28:3l|3l29:3m|3l2a:3n|3l2b:3o|3l2c:3p|3l2d:3q|3l38:31|3l39:32|3l3a:33|3l3b:34|3l3c:35|3l3d:36|3l3e:37|3l3f:38|3l3g:39|3l3h:3a|3l3i:3b|3l3j:3c|3l3k:3d|3l3l:3e|3l3m:3f|3l3n:3g|3l3o:3h|3l3p:3i|3l3q:3j|3l3r:3k|3l3s:3l|3l3t:3m|3l3u:3n|3l3v:3o|3l40:3p|3l41:3q|3l4s:31|3l4u:33|3l4v:34|3l52:37|3l55:3a|3l56:3b|3l59:3e|3l5a:3f|3l5b:3g|3l5c:3h|3l5e:3j|3l5f:3k|3l5g:3l|3l5h:3m|3l5i:3n|3l5j:3o|3l5k:3p|3l5l:3q|3l6g:31|3l6h:32|3l6i:33|3l6j:34|3l6k:35|3l6l:36|3l6m:37|3l6n:38|3l6o:39|3l6p:3a|3l6q:3b|3l6r:3c|3l6s:3d|3l6t:3e|3l6u:3f|3l6v:3g|3l70:3h|3l71:3i|3l72:3j|3l73:3k|3l74:3l|3l75:3m|3l76:3n|3l77:3o|3l78:3p|3l79:3q|3l84:31|3l85:32|3l87:34|3l88:35|3l89:36|3l8a:37|3l8d:3a|3l8e:3b|3l8f:3c|3l8g:3d|3l8h:3e|3l8i:3f|3l8j:3g|3l8k:3h|3l8m:3j|3l8n:3k|3l8o:3l|3l8p:3m|3l8q:3n|3l8r:3o|3l8s:3p|3l9o:31|3l9p:32|3l9r:34|3l9s:35|3l9t:36|3l9u:37|3la0:39|3la1:3a|3la2:3b|3la3:3c|3la4:3d|3la6:3f|3laa:3j|3lab:3k|3lac:3l|3lad:3m|3lae:3n|3laf:3o|3lag:3p|3lbc:31|3lbd:32|3lbe:33|3lbf:34|3lbg:35|3lbh:36|3lbi:37|3lbj:38|3lbk:39|3lbl:3a|3lbm:3b|3lbn:3c|3lbo:3d|3lbp:3e|3lbq:3f|3lbr:3g|3lbs:3h|3lbt:3i|3lbu:3j|3lbv:3k|3lc0:3l|3lc1:3m|3lc2:3n|3lc3:3o|3lc4:3p|3lc5:3q|3ld0:31|3ld1:32|3ld2:33|3ld3:34|3ld4:35|3ld5:36|3ld6:37|3ld7:38|3ld8:39|3ld9:3a|3lda:3b|3ldb:3c|3ldc:3d|3ldd:3e|3lde:3f|3ldf:3g|3ldg:3h|3ldh:3i|3ldi:3j|3ldj:3k|3ldk:3l|3ldl:3m|3ldm:3n|3ldn:3o|3ldo:3p|3ldp:3q|3lek:31|3lel:32|3lem:33|3len:34|3leo:35|3lep:36|3leq:37|3ler:38|3les:39|3let:3a|3leu:3b|3lev:3c|3lf0:3d|3lf1:3e|3lf2:3f|3lf3:3g|3lf4:3h|3lf5:3i|3lf6:3j|3lf7:3k|3lf8:3l|3lf9:3m|3lfa:3n|3lfb:3o|3lfc:3p|3lfd:3q|3lg8:31|3lg9:32|3lga:33|3lgb:34|3lgc:35|3lgd:36|3lge:37|3lgf:38|3lgg:39|3lgh:3a|3lgi:3b|3lgj:3c|3lgk:3d|3lgl:3e|3lgm:3f|3lgn:3g|3lgo:3h|3lgp:3i|3lgq:3j|3lgr:3k|3lgs:3l|3lgt:3m|3lgu:3n|3lgv:3o|3lh0:3p|3lh1:3q|3lhs:31|3lht:32|3lhu:33|3lhv:34|3li0:35|3li1:36|3li2:37|3li3:38|3li4:39|3li5:3a|3li6:3b|3li7:3c|3li8:3d|3li9:3e|3lia:3f|3lib:3g|3lic:3h|3lid:3i|3lie:3j|3lif:3k|3lig:3l|3lih:3m|3lii:3n|3lij:3o|3lik:3p|3lil:3q|3ljg:31|3ljh:32|3lji:33|3ljj:34|3ljk:35|3ljl:36|3ljm:37|3ljn:38|3ljo:39|3ljp:3a|3ljq:3b|3ljr:3c|3ljs:3d|3ljt:3e|3lju:3f|3ljv:3g|3lk0:3h|3lk1:3i|3lk2:3j|3lk3:3k|3lk4:3l|3lk5:3m|3lk6:3n|3lk7:3o|3lk8:3p|3lk9:3q|3ll8:th|3ll9:ti|3lla:tj|3llb:tk|3llc:tl|3lld:tm|3lle:tn|3llf:to|3llg:tp|3llh:tq|3lli:tr|3llj:ts|3llk:tt|3lll:tu|3llm:tv|3lln:u0|3llo:u1|3llp:to|3llq:u3|3llr:u4|3lls:u5|3llt:u6|3llu:u7|3llv:u8|3lm0:u9|3lmj:u3|3ln2:th|3ln3:ti|3ln4:tj|3ln5:tk|3ln6:tl|3ln7:tm|3ln8:tn|3ln9:to|3lna:tp|3lnb:tq|3lnc:tr|3lnd:ts|3lne:tt|3lnf:tu|3lng:tv|3lnh:u0|3lni:u1|3lnj:to|3lnk:u3|3lnl:u4|3lnm:u5|3lnn:u6|3lno:u7|3lnp:u8|3lnq:u9|3lod:u3|3los:th|3lot:ti|3lou:tj|3lov:tk|3lp0:tl|3lp1:tm|3lp2:tn|3lp3:to|3lp4:tp|3lp5:tq|3lp6:tr|3lp7:ts|3lp8:tt|3lp9:tu|3lpa:tv|3lpb:u0|3lpc:u1|3lpd:to|3lpe:u3|3lpf:u4|3lpg:u5|3lph:u6|3lpi:u7|3lpj:u8|3lpk:u9|3lq7:u3|3lqm:th|3lqn:ti|3lqo:tj|3lqp:tk|3lqq:tl|3lqr:tm|3lqs:tn|3lqt:to|3lqu:tp|3lqv:tq|3lr0:tr|3lr1:ts|3lr2:tt|3lr3:tu|3lr4:tv|3lr5:u0|3lr6:u1|3lr7:to|3lr8:u3|3lr9:u4|3lra:u5|3lrb:u6|3lrc:u7|3lrd:u8|3lre:u9|3ls1:u3|3lsg:th|3lsh:ti|3lsi:tj|3lsj:tk|3lsk:tl|3lsl:tm|3lsm:tn|3lsn:to|3lso:tp|3lsp:tq|3lsq:tr|3lsr:ts|3lss:tt|3lst:tu|3lsu:tv|3lsv:u0|3lt0:u1|3lt1:to|3lt2:u3|3lt3:u4|3lt4:u5|3lt5:u6|3lt6:u7|3lt7:u8|3lt8:u9|3ltr:u3",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"B.3":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"C.1.1":{s:"10"},"C.1.2":{r:"800:80b",s:"c00|50|5k0|81f|82v"},"C.2.1":{r:"0:v",s:"3v"},"C.2.2":{r:"40:4v|80c:80d|818:819|830:833|83a:83f|1vvp:1vvs|3kbj:3kbq",s:"1mt|1of|60e|1vnv"},"C.3":{r:"1o00:1u7v|u000:vvvt|10000:11vvt"},"C.4":{r:"1veg:1vff|1vvu:1vvv|3vvu:3vvv|5vvu:5vvv|7vvu:7vvv|9vvu:9vvv|bvvu:bvvv|dvvu:dvvv|fvvu:fvvv|hvvu:hvvv|jvvu:jvvv|lvvu:lvvv|nvvu:nvvv|pvvu:pvvv|rvvu:rvvv|tvvu:tvvv|vvvu:vvvv|11vvu:11vvv"},"C.5":{r:"1m00:1nvv"},"C.6":{r:"1vvp:1vvt"},"C.7":{r:"bvg:bvr"},"C.8":{r:"q0:q1|80e:80f|81a:81e|83a:83f"},"C.9":{r:"s010:s03v",s:"s001"},"D.1":{r:"1eg:1fa|1fg:1fk|1h1:1hq|1i0:1ia|1jd:1jf|1jh:1ml|1n5:1n6|1nq:1nu|1o0:1od|1oi:1pc|1s0:1t5|1uov:1up8|1upa:1upm|1upo:1ups|1uq0:1uq1|1uq3:1uq4|1uq6:1uth|1uuj:1v9t|1vag:1vcf|1vci:1ve7|1vfg:1vfs|1vjg:1vjk|1vjm:1vns",s:"1du|1e0|1e3|1gr|1gv|1mt|1og|1th|1uot|1upu|80f"},"D.2":{r:"21:2q|31:3q|60:6m|6o:7m|7o:h0|h2:hj|ig:ld|lg:lo|lr:m1|mg:mh|n0:n4|s8:sa|se:t1|t3:ue|ug:vl|100:142|14a:16e|16g:17l|17o:17p|180:18f|19h:1am|1ap:1av|1b1:1c7|285:29p|29t:2a0|2a9:2ac|2ao:2b1|2b4:2bg|2c2:2c3|2c5:2cc|2cf:2cg|2cj:2d8|2da:2dg|2dm:2dp|2du:2e0|2e7:2e8|2eb:2ec|2es:2et|2ev:2f1|2f6:2fh|2fk:2fq|2g5:2ga|2gf:2gg|2gj:2h8|2ha:2hg|2hi:2hj|2hl:2hm|2ho:2hp|2hu:2i0|2ip:2is|2j6:2jf|2ji:2jk|2k5:2kb|2kf:2kh|2kj:2l8|2la:2lg|2li:2lj|2ll:2lp|2lt:2m0|2mb:2mc|2n6:2nf|2o2:2o3|2o5:2oc|2of:2og|2oj:2p8|2pa:2pg|2pi:2pj|2pm:2pp|2pt:2pu|2q7:2q8|2qb:2qc|2qs:2qt|2qv:2r1|2r6:2rg|2s5:2sa|2se:2sg|2si:2sl|2sp:2sq|2su:2sv|2t3:2t4|2t8:2ta|2te:2tl|2tn:2tp|2tu:2tv|2u1:2u2|2u6:2u8|2ua:2uc|2v7:2vi|301:303|305:30c|30e:30g|30i:318|31a:31j|31l:31p|321:324|330:331|336:33f|342:343|345:34c|34e:34g|34i:358|35a:35j|35l:35p|360:364|367:368|36a:36b|36l:36m|370:371|376:37f|382:383|385:38c|38e:38g|38i:398|39a:39p|39u:3a0|3a6:3a8|3aa:3ac|3b0:3b1|3b6:3bf|3c2:3c3|3c5:3cm|3cq:3dh|3dj:3dr|3e0:3e6|3ef:3eh|3eo:3ev|3fi:3fk|3g1:3hg|3hi:3hj|3i0:3i6|3if:3ir|3k1:3k2|3k7:3k8|3kk:3kn|3kp:3kv|3l1:3l3|3la:3lb|3ld:3lg|3li:3lj|3m0:3m4|3mg:3mp|3ms:3mt|3o0:3on|3oq:3pk|3pu:3q7|3q9:3ra|3s8:3sb|3tu:3u5|3u7:3uc|400:411|413:417|419:41a|420:42n|450:465|46g:47o|480:4ap|4av:4d2|4d8:4fp|4g0:4g6|4g8:4i6|4ia:4id|4ig:4im|4iq:4it|4j0:4k6|4ka:4kd|4kg:4le|4li:4ll|4lo:4lu|4m2:4m5|4m8:4me|4mg:4mm|4mo:4ne|4ng:4oe|4oi:4ol|4oo:4ou|4p0:4q6|4q8:4qq|4r1:4rs|4t0:4vk|501:5jm|5k1:5kq|5l0:5ng|5o0:5oc|5oe:5oh|5p0:5ph|5pl:5pm|5q0:5qh|5r0:5rc|5re:5rg|5s0:5tm|5tu:5u5|5u7:5u8|5uk:5uq|5v0:5v9|60g:60p|610:63n|640:658|7g0:7kr|7l0:7np|7o0:7ol|7oo:7ot|7p0:7q5|7q8:7qd|7qg:7qn|7qv:7rt|7s0:7tk|7tm:7ts|7u2:7u4|7u6:7uc|7ug:7uj|7um:7ur|7v0:7vc|7vi:7vk|7vm:7vs|88a:88j|88p:88t|89a:89d|89f:89h|89j:89p|89t:89v|8a5:8a9|8b0:8c3|8pm:8rq|94s:979|c05:c07|c11:c19|c1h:c1l|c1o:c1s|c21:c4m|c4t:c4v|c51:c7q|c7s:c7v|c85:c9c|c9h:cce|ccg:cdn|cfg:cgs|ch0:ci3|cj0:cjr|cjv:clg|cm0:cmb|cmg:cnu|co0:crm|crr:cut|cv0:cvu|d00:jdl|jg0:17t5|1800:194c|1b00:1lt3|1m00:1uhd|1uhg:1uja|1uo0:1uo6|1uoj:1uon|1vp1:1vpq|1vq1:1vqq|1vr6:1vtu|1vu2:1vu7|1vua:1vuf|1vui:1vun|1vuq:1vus|20o0:20ou|20p0:20p3|20pg:20qa|2100:2115|2118:212d|3k00:3k7l|3k80:3k96|3k9a:3kb6|3kba:3kbi|3kc3:3kc4|3kcc:3kd9|3kde:3ket|3l00:3l2k|3l2m:3l4s|3l4u:3l4v|3l55:3l56|3l59:3l5c|3l5e:3l5p|3l5t:3l60|3l62:3l63|3l65:3l85|3l87:3l8a|3l8d:3l8k|3l8m:3l8s|3l8u:3l9p|3l9r:3l9u|3la0:3la4|3laa:3lag|3lai:3ll3|3ll8:3lu9|4000:59mm|5u00:5ugt|u000:vvvt|10000:11vvt",s:"3l52|3l5r|3la6|1c9|5a|5l|5q|283|2ag|2di|2en|2iu|2k3|2kd|2m9|2mg|2n0|2q0|2qn|2s3|2ss|2un|35u|36u|3an|3dt|3k4|3ka|3kd|3l5|3l7|3lt|3m6|3pm|3po|3rv|3s5|3uf|41c|41h|41o|47r|4i8|4io|4k8|4lg|4m0|4og|5us|ne|7qp|7qr|7qt|7tu|80e|83h|83v|882|887|88l|894|896|898|rq|s6|sc|8sl"}};class m{constructor(e,t){this.singles=new Set,this.ranges=[],this.mappings=new Map;const n=f[e];this.name=e,n?(n.s&&(this.singles=new Set(n.s.split("|").map(e=>parseInt(e,32)))),n.r&&(this.ranges=n.r.split("|").map(e=>{const[t,n]=e.split(":");return[parseInt(t,32),parseInt(n,32)]})),n.m&&(this.mappings=new Map(n.m.split("|").map(e=>{const[t,n]=e.split(":"),i=n.split(";").map(e=>parseInt(e,32));return[parseInt(t,32),i]})))):t&&(this.singles=new Set(t))}contains(e){if(this.singles.has(e))return!0;let t=0,n=this.ranges.length-1;for(;t<=n;){const i=Math.floor((t+n)/2),r=this.ranges[i];if(e<r[0])n=i-1;else{if(!(e>r[1]))return!0;t=i+1}}return!1}hasMapping(e){return this.mappings.has(e)||this.contains(e)}map(e){return this.contains(e)&&!this.mappings.has(e)?String.fromCodePoint(e).toLowerCase().codePointAt(0):this.mappings.get(e)||null}}const g=new m("A.1"),v=new m("B.1"),b=new m("B.2");new m("B.3");const y=new m("C.1.1"),_=new m("C.1.2"),S=new m("C.2.1"),w=new m("C.2.2"),x=new m("C.3"),T=new m("C.4"),k=new m("C.5"),I=new m("C.6"),j=new m("C.7"),E=new m("C.8"),N=new m("C.9"),C=new m("D.1"),R=new m("D.2");function O(e,t,n=""){const i=c.a.ucs2.decode(n);let r=[];for(const n of i){if(!t&&e.unassigned.contains(n))throw new Error("Unassigned code point: x"+n.toString(16));let i=!1;for(const t of e.mappings){if(!t.hasMapping(n))continue;i=!0;const e=t.map(n);e&&(Array.isArray(e)?r=r.concat(e):r.push(e))}i||r.push(n)}let s=r;if(e.normalize){const e=c.a.ucs2.encode(r).normalize("NFKC");s=c.a.ucs2.decode(e)}let o=!1,a=!1;for(const n of s){for(const t of e.prohibited)if(t.contains(n))throw new Error("Prohibited code point: x"+n.toString(16));if(!t&&e.unassigned.contains(n))throw new Error("Prohibited code point: x"+n.toString(16));e.bidirectional&&(o=o||C.contains(n),a=a||R.contains(n))}if(e.bidirectional){if(o&&a)throw new Error("String contained both LCat and RandALCat code points");if(o&&(!C.contains(s[0])||!C.contains(s[s.length-1])))throw new Error("String containing RandALCat code points must start and end with RandALCat code points")}return c.a.ucs2.encode(s)}v.map=()=>null,y.contains=e=>32===e,_.map=e=>_.contains(e)?32:null;const A={bidirectional:!0,mappings:[v,b],normalize:!0,prohibited:[_,w,x,T,k,I,j,E,N],unassigned:g};const P=new m("NodePrepProhibited",[34,38,39,47,58,60,62,64]),q={bidirectional:!0,mappings:[v,b],normalize:!0,prohibited:[y,_,S,w,x,T,k,I,j,E,N,P],unassigned:g};const L={bidirectional:!0,mappings:[v],normalize:!0,prohibited:[_,S,w,x,T,k,I,j,E,N],unassigned:g};const F={bidirectional:!0,mappings:[_,v],normalize:!0,prohibited:[_,S,w,x,T,k,I,j,E,N],unassigned:g};function M(e,t=!1){return O(F,t,e)}function D(e=""){return e.replace(/^\s+|\s+$/g,"").replace(/\\5c/g,"\\5c5c").replace(/\\20/g,"\\5c20").replace(/\\22/g,"\\5c22").replace(/\\26/g,"\\5c26").replace(/\\27/g,"\\5c27").replace(/\\2f/g,"\\5c2f").replace(/\\3a/g,"\\5c3a").replace(/\\3c/g,"\\5c3c").replace(/\\3e/g,"\\5c3e").replace(/\\40/g,"\\5c40").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")}function B(e){return 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,"\\")}function U(e){let t=e.local||"",n=e.domain,i=e.resource||"";return t&&(t=function(e,t=!0){return O(q,t,e)}(t)),i&&(i=function(e,t=!0){return O(L,t,e)}(i)),"."===n[n.length-1]&&(n=n.slice(0,n.length-1)),n=function(e,t=!0){return O(A,t,e)}(n.split(".").map(c.a.toUnicode).join(".")),{domain:n,local:t,resource:i}}function z(e,t={}){let n=e.local;t.escaped||(n=D(e.local));const i=t.prepared?e:U({local:n,domain:e.domain,resource:e.resource}),r=n?`${n}@${i.domain}`:i.domain;return i.resource?`${r}/${i.resource}`:r}function J(e,t){return t?`${K(e)}/${t}`:K(e)}function G(e=""){let t="",n="",i="";const r=e.indexOf("/");r>0&&(i=e.slice(r+1),e=e.slice(0,r));const s=e.indexOf("@");s>0&&(t=e.slice(0,s),e=e.slice(s+1)),n=e;const o=U({domain:n,local:t,resource:i});return{bare:z({local:o.local,domain:o.domain},{escaped:!0,prepared:!0}),domain:o.domain,full:z(o,{escaped:!0,prepared:!0}),local:B(o.local),resource:o.resource}}function V(e,t){const n=new Set;if(n.add(void 0),n.add(""),e){const t=G(e);n.add(t.full),n.add(t.bare),n.add(t.domain)}if(t){const e=G(t);n.add(e.domain),n.add(e.bare),n.add(e.full)}return n}function $(e,t){if(!e||!t)return!1;const n=G(e),i=G(t);return n.local===i.local&&n.domain===i.domain}function H(e){return!!G(e).resource}function W(e=""){return G(e).domain}function Q(e=""){return G(e).resource}function K(e=""){return G(e).bare}var X,Y=Object.freeze({__proto__:null,escapeLocal:D,unescapeLocal:B,prepare:U,create:z,createFull:J,parse:G,allowedResponders:V,equal:function(e,t){if(!e||!t)return!1;const n=G(e),i=G(t);return n.local===i.local&&n.domain===i.domain&&n.resource===i.resource},equalBare:$,isFull:H,isBare:function(e){return!H(e)},getLocal:function(e=""){return G(e).local},getDomain:W,getResource:Q,toBare:K,parseURI:function(e){const t=new URL(e);if("xmpp:"!==t.protocol)throw new Error("Invalid XMPP URI, wrong protocol: "+t.protocol);const n=t.hostname?t.username?z({domain:decodeURIComponent(t.hostname),local:decodeURIComponent(t.username)},{escaped:!0}):decodeURIComponent(t.hostname):void 0,i=G(decodeURIComponent(n?t.pathname.substr(1):t.pathname)).full,r=t.search&&t.search.indexOf(";")>=1,s=r?t.search.substr(t.search.indexOf(";")+1):"",o=t.search?decodeURIComponent(t.search.substr(1,r?t.search.indexOf(";")-1:void 0)):void 0,a={};for(const e of s.split(";")){const[t,n]=e.split("=").map(decodeURIComponent);if(a[t]){const e=a[t];Array.isArray(e)?e.push(n):a[t]=[e,n]}else a[t]=n}return{action:o,identity:n,jid:i,parameters:a}},toURI:function(e){const t=["xmpp:"],n=(e,n)=>{const i=G(e);i.local&&(t.push(encodeURIComponent(D(i.local))),t.push("@")),t.push(encodeURIComponent(i.domain)),n&&i.resource&&(t.push("/"),t.push(encodeURIComponent(i.resource)))};e.identity&&(t.push("//"),n(e.identity,!1),e.jid&&t.push("/")),e.jid&&n(e.jid,!0),e.action&&(t.push("?"),t.push(encodeURIComponent(e.action)));for(const[n,i]of Object.entries(e.parameters||{}))for(const e of Array.isArray(i)?i:[i])t.push(";"),t.push(encodeURIComponent(n)),void 0!==e&&(t.push("="),t.push(encodeURIComponent(e)));return t.join("")}});!function(e){e.NotWellFormed="not-well-formed",e.RestrictedXML="restricted-xml",e.AlreadyClosed="already-closed",e.UnknownRoot="unknown-stream-root"}(X||(X={}));class Z extends Error{constructor(e){super(e.text),this.isJXTError=!0,this.condition=e.condition,this.text=e.text}static notWellFormed(e){return new Z({condition:X.NotWellFormed,text:e})}static restrictedXML(e){return new Z({condition:X.RestrictedXML,text:e})}static alreadyClosed(e){return new Z({condition:X.AlreadyClosed,text:e})}static unknownRoot(e){return new Z({condition:X.UnknownRoot,text:e})}}const ee={'"':""","&":"&","'":"'","<":"<",">":">"},te={"&":"&","'":"'",">":">","<":"<",""":'"'},ne=/&([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);/g,ie=/&|<|>|"|'/g,re=/&|<|>/g;function se(e){return ee[e]}function oe(e){return e.replace(ie,se)}function ae(e){return e.replace(ne,e=>function(e){if(te[e])return te[e];const t=e.startsWith("&#x"),n=parseInt(e.substring(t?3:2,e.length-1),t?16:10);if(9===n||10===n||13===n||32<=n&&n<=55295||57344<=n&&n<=65533||65536<=n&&n<=1114111)return String.fromCodePoint(n);throw Z.restrictedXML("Prohibited entity: "+e)}(e))}function ce(e){return e.replace(re,se)}function le(e,t=[],n=""){const i=new Set(e.map(e=>e.toLowerCase()));for(let e of t.map(e=>e.toLowerCase()))if("*"!==e)for(;e.length>0;){if(i.has(e))return e;e=e.substring(0,e.lastIndexOf("-")).toLowerCase(),e.lastIndexOf("-")===e.length-2&&(e=e.substring(0,e.lastIndexOf("-")))}return n}class ue{constructor(e,t={},n=[]){this.name=e,this.attributes=t,this.children=[],this.optionalNamespaces={};for(const e of n)if("string"!=typeof e){const t=new ue(e.name,e.attributes,e.children);t.parent=this,this.children.push(t)}else this.children.push(e)}getName(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name}getNamespace(){if(this.name.indexOf(":")>=0){const e=this.name.substr(0,this.name.indexOf(":"));return this.findNamespaceForPrefix(e)}return this.findNamespaceForPrefix()}getNamespaceContext(){let e={};this.parent&&(e=this.parent.getNamespaceContext());for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")){const i=t.substr(6);e[n]=i}return e}getDefaultNamespace(){return this.attributes.xmlns?this.attributes.xmlns:this.parent?this.parent.getDefaultNamespace():""}getNamespaceRoot(e){if(this.parent){const t=this.parent.getNamespaceRoot(e);if(t)return t}for(const[t,n]of Object.entries(this.attributes))if(t.startsWith("xmlns:")&&n===e)return this;if(this.optionalNamespaces[e])return this}getAttribute(e,t){if(!t)return this.attributes[e];const n=this.getNamespaceContext();return n[t]?this.attributes[[n[t],e].join(":")]:void 0}getChild(e,t){return this.getChildren(e,t)[0]}getChildren(e,t){const n=[];for(const i of this.children)"string"==typeof i||i.getName()!==e||t&&i.getNamespace()!==t||n.push(i);return n}getText(){let e="";for(const t of this.children)"string"==typeof t&&(e+=t);return e}appendChild(e){return this.children.push(e),"string"!=typeof e&&(e.parent=this),e}setAttribute(e,t,n=!1){this.attributes[e]=t||void 0,""===t&&n&&(this.attributes[e]=t)}addOptionalNamespace(e,t){this.optionalNamespaces[t]=e}useNamespace(e,t){return this.optionalNamespaces[t]&&(e=this.optionalNamespaces[t]),this.setAttribute("xmlns:"+e,t),e}toJSON(){const e=this.children.map(e=>"string"==typeof e?e:e?e.toJSON():void 0).filter(e=>!!e),t={};for(const[e,n]of Object.entries(this.attributes))null!=n&&(t[e]=n);return{attributes:t,children:e,name:this.name}}toString(){let e=this.openTag(!0);if(this.children.length){for(const t of this.children)"string"==typeof t?e+=ce(t):t&&(e+=t.toString());e+=this.closeTag()}return e}openTag(e=!1){let t="";t+="<"+this.name;for(const[e,n]of Object.entries(this.attributes))void 0!==n&&(t+=` ${e}="${oe(n.toString())}"`);return e&&0===this.children.length?t+="/>":t+=">",t}closeTag(){return`</${this.name}>`}findNamespaceForPrefix(e){if(e){const t="xmlns:"+e;if(this.attributes[t])return this.attributes[t];if(this.parent)return this.parent.findNamespaceForPrefix(e)}else{if(this.attributes.xmlns)return this.attributes.xmlns;if(this.parent)return this.parent.findNamespaceForPrefix()}return""}}const pe=new Set(["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul"]),de=new Set(["style"]),he=new Map([["a",new Set(["href","style"])],["body",new Set(["style","xml:lang"])],["blockquote",de],["br",de],["cite",de],["em",de],["img",new Set(["alt","height","src","style","width"])],["li",de],["ol",de],["p",de],["span",de],["strong",de],["ul",de]]),fe=new Map([["font-style",/normal|italic|oblique|inherit/i],["font-weight",/normal|bold|bolder|lighter|inherit|\d\d\d/i],["text-decoration",/none|underline|overline|line-through|blink|inherit/i]]),me=e=>!!e.match(/^(https?|xmpp|cid|mailto|ftps?|im|ircs?|sips?|tel|geo|bitcoin|magnet):/i)&&e,ge=e=>!!e.match(/^[0-9]*$/)&&e,ve={alt:e=>e,height:ge,href:me,src:me,style:e=>{const t=(";"+e).replace(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,"").replace(/\/\*.*/,"").replace(/\\([a-fA-F0-9]{1,6})\s?/,(e,t)=>String.fromCharCode(parseInt(t,16))).match(/;\s*([a-z-]+)\s*:\s*([^;]*[^\s;])\s*/g),n=[];if(!t)return!1;for(const e of t){const t=e.match(/^;\s*([a-z-]+)\s*:\s*([^;]*[^\s])\s*$/);if(!t)continue;const i=fe.get(t[1]);if(i){const e=t[2].match(i);e&&n.push(`${t[1]}:${e[0]}`)}}return!!n.length&&n.join("")},width:ge};function be(e){if("string"==typeof e)return e;if(!pe.has(e.name)){if("script"===e.name)return;return function(e){let t=[];for(const n of e.children)if("string"==typeof n)t.push(n);else{const e=be(n);e&&(Array.isArray(e)?t=t.concat(e):t.push(e))}return t}(e)}const t=e.children.map(be).filter(e=>void 0!==e),n={};for(const[t,i]of Object.entries(e.attributes)){const r=he.get(e.name);if(!r||!r.has(t))continue;if(!i)continue;const s=ve[t](i);s&&(n[t]=s)}return{attributes:n,children:t,name:e.name}}function ye(e){if("string"==typeof e)return;let t=[];for(const n of e.children){if(!n)continue;if("string"==typeof n){t.push(n);continue}const e=be(n);Array.isArray(e)?t=t.concat(e):e&&t.push(e)}const n={};return"body"===e.name?(void 0!==e.attributes.xmlns&&(n.xmlns=e.attributes.xmlns),e.attributes.style&&(n.style=e.attributes.style),void 0!==e.attributes["xml:lang"]&&(n["xml:lang"]=e.attributes["xml:lang"]),{attributes:n,children:t,name:"body"}):void 0}function _e(e){return 97<=e&&e<=122||65<=e&&e<=90||58===e||95===e}function Se(e){return 192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=767||880<=e&&e<=893||895<=e&&e<=8191||8204<=e&&e<=8205||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||65008<=e&&e<=65533||65536<=e&&e<=983039}function we(e){return _e(e)||Se(e)}function xe(e){return _e(e)||45===e||46===e||48<=e&&e<=57||183===e||768<=e&&e<=879||8255<=e&&e<=8256||Se(e)}function Te(e){return 32===e||10===e||13===e||9===e}class ke extends o.EventEmitter{constructor(e={}){super(),this.allowComments=!0,this.attributes={},this.state=34,this.tagName="",this.haveDeclaration=!1,this.recordBuffer=[],void 0!==e.allowComments&&(this.allowComments=e.allowComments)}write(e){for(const t of e){const e=t.codePointAt(0);switch(this.state){case 34:if(60===e){let e;try{e=ae(this.endRecord())}catch(e){return void this.emit("error",e)}e&&this.emit("text",e),this.transition(31);continue}this.record(t);continue;case 31:if(47===e){this.transition(7);continue}if(33===e){this.transition(24);continue}if(63===e){this.haveDeclaration&&this.restrictedXML(),this.transition(25);continue}if(we(e)){this.transition(30),this.startRecord(t);continue}return this.notWellFormed();case 30:if(xe(e)){this.record(t);continue}if(Te(e)){this.startTag(),this.transition(32);continue}if(47===e){this.startTag(),this.transition(29);continue}if(62===e){this.startTag(),this.transition(34),this.emit("startElement",this.tagName,this.attributes);continue}return this.notWellFormed();case 29:if(62===e){this.emit("startElement",this.tagName,this.attributes),this.emit("endElement",this.tagName),this.transition(34);continue}return this.notWellFormed();case 33:if(Te(e)){this.transition(32);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 32:if(Te(e))continue;if(we(e)){this.startRecord(t),this.transition(0);continue}if(47===e){this.transition(29);continue}if(62===e){this.emit("startElement",this.tagName,this.attributes),this.transition(34);continue}return this.notWellFormed();case 7:if(we(e)){this.startRecord(t),this.transition(6);continue}return this.notWellFormed();case 6:if(xe(e)){this.record(t);continue}if(Te(e)){this.transition(8);continue}if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 8:if(Te(e))continue;if(62===e){const e=this.endRecord();this.emit("endElement",e,this.attributes),this.transition(34);continue}return this.notWellFormed();case 0:if(xe(e)){this.record(t);continue}if(61===e){this.addAttribute(),this.transition(4);continue}if(Te(e)){this.addAttribute(),this.transition(3);continue}return this.notWellFormed();case 3:if(61===e){this.transition(4);continue}if(Te(e))continue;return this.notWellFormed();case 4:if(34===e){this.startRecord(),this.transition(1);continue}if(39===e){this.startRecord(),this.transition(2);continue}if(Te(e))continue;return this.notWellFormed();case 1:case 2:if(34===e&&1===this.state||39===e&&2===this.state){const e=this.endRecord();this.attributes[this.attributeName]=ae(e),this.transition(33);continue}if(60===e)return this.notWellFormed();this.record(t);continue;case 24:if(45===e){this.allowComments||this.restrictedXML(),this.transition(23);continue}if(91===e){this.transition(21);continue}return this.notWellFormed();case 23:if(45===e){this.transition(14);continue}return this.notWellFormed();case 14:45===e&&this.transition(12);continue;case 12:45===e?this.transition(11):this.transition(14);continue;case 11:62===e?this.transition(34):this.transition(14);continue;case 25:if(88===e||120===e){this.transition(28);continue}return this.notWellFormed();case 28:if(77===e||109===e){this.transition(27);continue}return this.notWellFormed();case 27:if(76===e||108===e){this.transition(26);continue}return this.notWellFormed();case 26:if(Te(e)){this.haveDeclaration=!0,this.transition(15);continue}return this.notWellFormed();case 13:if(62===e){this.transition(34);continue}return this.notWellFormed();case 15:63===e&&this.transition(13);continue;case 21:this.wait(e,67,20);continue;case 20:this.wait(e,68,19);continue;case 19:this.wait(e,65,18);continue;case 18:this.wait(e,84,17);continue;case 17:this.wait(e,65,16);continue;case 16:this.wait(e,91,5);continue;case 5:if(93===e){this.transition(10);continue}this.record(t);continue;case 10:93===e?this.transition(9):(this.record(String.fromCodePoint(93)),this.record(t),this.transition(5));continue;case 9:if(62===e){const e=this.endRecord();e&&this.emit("text",e),this.transition(34)}else this.record(String.fromCodePoint(93)),this.record(String.fromCodePoint(93)),this.record(t),this.transition(5);continue}}}end(e){e&&this.write(e),this.write=()=>{}}record(e){this.recordBuffer.push(e)}startRecord(e){this.recordBuffer=[],e&&this.recordBuffer.push(e)}endRecord(){const e=this.recordBuffer;return this.recordBuffer=[],e.join("")}startTag(){this.tagName=this.endRecord(),this.attributes={}}addAttribute(){const e=this.endRecord();if(void 0!==this.attributes[e])return this.notWellFormed();this.attributeName=e,this.attributes[e]=""}wait(e,t,n){if(e!==t)return this.notWellFormed();this.transition(n)}transition(e){this.state=e,34===e&&this.startRecord()}notWellFormed(e){this.emit("error",Z.notWellFormed(e))}restrictedXML(e){this.emit("error",Z.restrictedXML(e))}}function Ie(e,t={}){const n=new ke(t);let i,r,s=null;if(n.on("text",e=>{r&&r.children.push(e)}),n.on("startElement",(e,t)=>{const n=new ue(e,t);i||(i=n),r=r?r.appendChild(n):n}),n.on("endElement",e=>{r?e===r.name?r.parent&&(r=r.parent):n.emit("error",Z.notWellFormed("b")):n.emit("error",Z.notWellFormed("a"))}),n.on("error",e=>{s=e}),n.write(e),n.end(),s)throw s;return i}function je(e,t,n,i){if(i){e=e||i.getNamespace();const n=i.getNamespaceRoot(e);if(n){t=`${n.useNamespace("",e)}:${t}`}}const r=new ue(t);return t.indexOf(":")<0&&(!n||e!==n)&&r.setAttribute("xmlns",e),r}function Ee(e,t){return(e.getAttribute("xml:lang")||t||"").toLowerCase()}function Ne(e,t){const n=[];for(const i of e)n.push(Ee(i,t.lang));let i;return i=t.resolveLanguage?t.resolveLanguage(n,t.acceptLanguages||[],t.lang):t.lang,i||""}function Ce(e,t,n,i){const r=e.getChildren(n,t),s=Ee(e);return r.length?i?r.filter(e=>{if(Ee(e,s)===i)return!0}):r:[]}function Re(e,t,n,i){t=t||e.getNamespace();const r=Ce(e,t,n,i);if(r.length)return r[0];const s=je(t,n,e.getDefaultNamespace(),e),o=Ee(e,i);return i&&o!==i&&s.setAttribute("xml:lang",i),e.appendChild(s),s}function Oe(e){return{importer(t){const n=t.getAttribute(e.name,e.namespace);return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);if(i||e.emitEmpty)if(e.namespace&&e.prefix){let n;const r=t.getNamespaceRoot(e.namespace);if(r)n=r.useNamespace(e.prefix,e.namespace);else{const i=t.getNamespaceContext();i[e.namespace]||(n=t.useNamespace(e.prefix,e.namespace),i[e.namespace]=n)}t.setAttribute(`${n}:${e.name}`,i,e.emitEmpty)}else t.setAttribute(e.name,i,e.emitEmpty)}}}function Ae(e,t){return(n,i,r={})=>(r=Object.assign({staticDefault:i},r),Oe(Object.assign(Object.assign({name:n},e),t?t(r):r)))}function Pe(e,t){return(n,i,r,s,o={})=>(o=Object.assign({staticDefault:s},o),Oe(Object.assign(Object.assign({name:r,namespace:i,prefix:n},e),t?t(o):o)))}function qe(e){const t=e.converter||Oe(Object.assign(Object.assign({},e),{namespace:e.attributeNamespace}));return{importer(n,i){const r=n.getChild(e.element,e.namespace||n.getNamespace());return r?t.importer(r,i):e.dynamicDefault?e.dynamicDefault():e.staticDefault},exporter(n,i,r){if(void 0!==i&&i!==e.staticDefault){const s=Re(n,e.namespace||n.getNamespace(),e.element);t.exporter(s,i,r)}}}}function Le(e,t){return(n,i,r,s,o={})=>(o=Object.assign({staticDefault:s},o),qe(Object.assign(Object.assign({element:i,name:r,namespace:n},e),t?t(o):o)))}function Fe(e){return{importer(t){const n=t.getText();return n?e.parseValue(n):e.dynamicDefault?e.dynamicDefault(n):e.staticDefault},exporter(t,n){if(!n&&e.emitEmpty)return void t.children.push("");if(void 0===n||n===e.staticDefault)return;const i=e.writeValue(n);i&&t.children.push(i)}}}function Me(e){const t=Fe(e);return{importer(n,i){const r=Ce(n,e.namespace||n.getNamespace(),e.element),s=Ne(r,i);if(!r.length)return e.dynamicDefault?e.dynamicDefault():e.staticDefault;if(e.matchLanguage)for(const e of r)if(Ee(e,i.lang)===s)return t.importer(e,i);return t.importer(r[0],i)},exporter(n,i,r){if(i||!e.emitEmpty){if(void 0!==i&&i!==e.staticDefault){const s=Re(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0);t.exporter(s,i,r)}}else Re(n,e.namespace||n.getNamespace(),e.element,e.matchLanguage?r.lang:void 0)}}}const De={parseValue:e=>e,writeValue:e=>e},Be={parseValue:e=>parseInt(e,10),writeValue:e=>e.toString()},Ue={parseValue:e=>parseFloat(e),writeValue:e=>e.toString()},ze={parseValue:e=>"true"===e||"1"===e||"false"!==e&&"0"!==e&&void 0,writeValue:e=>e?"1":"0"},Je={parseValue:e=>new Date(e),writeValue:e=>"string"==typeof e?e:e.toISOString()},Ge={parseValue:e=>JSON.parse(e),writeValue:e=>JSON.stringify(e)},Ve=(t="utf8")=>({parseValue:n=>("base64"===t&&"="===n&&(n=""),e.from(n.trim(),t)),writeValue:n=>{let i;return i="string"==typeof n?e.from(n).toString(t):n?n.toString(t):"","base64"===t&&(i=i||"="),i}}),$e={parseValue:e=>{let t=-1;"-"===e.charAt(0)&&(t=1,e=e.slice(1));const n=e.split(":");return(60*parseInt(n[0],10)+parseInt(n[1],10))*t},writeValue:e=>{if("string"==typeof e)return e;{let t="-";e<0&&(e=-e,t="+");const n=e/60,i=e%60;return t+=(n<10?"0":"")+n+":"+(i<10?"0":"")+i,t}}},He=Ae(De,e=>Object.assign({dynamicDefault:e.emitEmpty?t=>""===t?"":e.staticDefault:void 0},e)),We=Ae(ze),Qe=Ae(Be),Ke=Ae(Ue),Xe=Ae(Je),Ye=Pe(De),Ze=Pe(ze),et=Pe(Be),tt=Pe(Ue),nt=Pe(Je),it=Le(De),rt=Le(ze),st=Le(Be),ot=Le(Ue),at=Le(Je),ct=e=>Fe(Object.assign({staticDefault:e},De)),lt=()=>Fe(Object.assign({},Ge)),ut=(e="utf8")=>Fe(Object.assign({},Ve(e)));function pt(){return{importer:(e,t)=>Ee(e,t.lang),exporter(e,t,n){t&&t.toLowerCase()!==n.lang?e.setAttribute("xml:lang",t):e.setAttribute("xml:lang",void 0)}}}const dt=(e,t,n,i=!1)=>Me(Object.assign({element:t,emitEmpty:i,matchLanguage:!0,namespace:e,staticDefault:n},De)),ht=(e,t,n="utf8")=>Me(Object.assign({element:t,matchLanguage:!0,namespace:e},Ve(n))),ft=(e,t)=>Me(Object.assign({element:t,namespace:e},Je)),mt=(e,t,n)=>Me(Object.assign({element:t,namespace:e,staticDefault:n},Be)),gt=(e,t,n)=>Me(Object.assign({element:t,namespace:e,staticDefault:n},Ue)),vt=(e,t)=>Me(Object.assign({element:t,namespace:e},Ge));function bt(e,t){return Me(Object.assign({element:t,namespace:e,staticDefault:0},$e))}function yt(e,t){return{importer(n){if(n.getChild(t,e||n.getNamespace()))return!0},exporter(n,i){i&&Re(n,e||n.getNamespace(),t)}}}const _t=(e,t,n)=>{if(!n)return;let i=t;for(const t of e)i=Re(i,t.namespace||i.getNamespace(),t.element);i.children.push(n.toString())};function St(e,t){return{importer(n){let i=n;for(const n of e)if(i=i.getChild(n.element,n.namespace||i.getNamespace()),!i)return t;return i.getText()||t},exporter(t,n){_t(e,t,n)}}}function wt(e,t){return{importer(n){let i=n;for(const t of e)if(i=i.getChild(t.element,t.namespace||i.getNamespace()),!i)return;const r=i.getText();return r?parseInt(r,10):t||void 0},exporter(t,n){_t(e,t,n)}}}function xt(e){return{importer(t){let n=t;for(const t of e)if(n=n.getChild(t.element,t.namespace||n.getNamespace()),!n)return!1;return!0},exporter(t,n){if(!n)return;let i=t;for(const t of e)i=Re(i,t.namespace||i.getNamespace(),t.element)}}}function Tt(e){const t=e.pop();return{importer(n,i){let r=n;for(const t of e)if(r=r.getChild(t.element,t.namespace||r.getNamespace()),!r)return[];const s=[],o=Ce(r,t.namespace||r.getNamespace(),t.element),a=Ne(o,i);for(const e of o)Ee(e,i.lang)===a&&s.push(e.getText());return s},exporter(n,i,r){if(!i.length)return;let s=n;for(const t of e)s=Re(s,t.namespace||s.getNamespace(),t.element);const{namespace:o,element:a}=t;for(const e of i){const t=je(o||s.getNamespace(),a,r.namespace,s);t.children.push(e),s.appendChild(t)}}}}function kt(e,t,n){const i=new Map,r=new Map;for(const e of t)"string"==typeof e?(i.set(e,e),r.set(e,e)):(i.set(e[1],e[0]),r.set(e[0],e[1]));return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&i.has(n.getName()))return i.get(n.getName());return n},exporter(t,n){r.has(n)&&Re(t,e,r.get(n))}}}function It(e,t,n,i){const r=new Set(t),s=new Set(n);return{importer(t){for(const n of t.children)if("string"!=typeof n&&n.getNamespace()===(e||t.getNamespace())&&r.has(n.getName())){for(const i of n.children)if("string"!=typeof i&&i.getNamespace()===(e||t.getNamespace())&&s.has(i.getName()))return[n.getName(),i.getName()];return[n.getName()]}return i},exporter(t,n){const i=Re(t,e,n[0]);n[1]&&Re(i,e,n[1])}}}function jt(e,t){return{importer(n,i){const r=[],s=Ce(n,e||n.getNamespace(),t),o=Ne(s,i);for(const e of s)Ee(e,i.lang)===o&&r.push(e.getText());return r},exporter(n,i,r){for(const s of i){const i=je(e||n.getNamespace(),t,r.namespace,n);i.children.push(s),n.appendChild(i)}}}}function Et(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(t)}return r},exporter(i,r,s){for(const o of r){const r=je(e||i.getNamespace(),t,s.namespace,i);r.setAttribute(n,o),i.appendChild(r)}}}}function Nt(e,t,n){return{importer(i){const r=[],s=i.getChildren(t,e||i.getNamespace());for(const e of s){const t=e.getAttribute(n);void 0!==t&&r.push(parseInt(t,10))}return r},exporter(i,r,s){for(const o of r){const r=je(e||i.getNamespace(),t,s.namespace,i);r.setAttribute(n,o.toString()),i.appendChild(r)}}}}function Ct(e,t){return{importer(n,i){const r=[],s=Ce(n,e||n.getNamespace(),t),o=new Set;for(const e of s){const t=e.getText();if(t){const n=Ee(e,i.lang);if(o.has(n))continue;r.push({lang:n,value:t}),o.add(n)}}return o.size>0?r:void 0},exporter(n,i,r){for(const s of i){const i=s.value;if(i){const o=je(e||n.getNamespace(),t,r.namespace,n);s.lang!==r.lang&&o.setAttribute("xml:lang",s.lang),o.children.push(i),n.appendChild(o)}}}}}function Rt(e,t){const n=new Map,i=new Map;for(const e of t)"string"==typeof e?(n.set(e,e),i.set(e,e)):(n.set(e[1],e[0]),i.set(e[0],e[1]));return{importer(t){const i=[];for(const r of t.children)"string"!=typeof r&&r.getNamespace()===(e||t.getNamespace())&&n.has(r.getName())&&i.push(n.get(r.getName()));return i},exporter(t,n){for(const r of n)Re(t,e,i.get(r))}}}function Ot(e,t,n,i=!1){return{importer(r,s){const o=r.getChild(t,e||r.getNamespace());if(!o)return;const a=[];for(const e of o.children)if("string"!=typeof e&&s.registry.getImportKey(e)===n){const t=s.registry.import(e);t&&a.push(t)}return i?a:a[0]},exporter(i,r,s){let o=[];o=Array.isArray(r)?r:[r];const a=[];for(const t of o){const r=s.registry.export(n,t,Object.assign(Object.assign({},s),{namespace:e||i.getNamespace()||void 0}));r&&a.push(r)}if(a.length){const n=Re(i,e||i.getNamespace(),t);for(const e of a)n.appendChild(e)}}}}function At(e){return{exporter:()=>{},importer:()=>e}}function Pt(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=Ce(i,e||i.getNamespace(),t),o=Ne(s,r);for(const e of s)if(Ee(e,r.lang)===o)return n?r.sanitizers[n](e.toJSON()):e.toJSON();return s[0]?n?r.sanitizers[n](s[0].toJSON()):s[0].toJSON():void 0},exporter(i,r,s){if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(r&&n){if(!s.sanitizers||!s.sanitizers[n])return;r=s.sanitizers[n](r)}if(!r)return;const o=Re(i,e||i.getNamespace(),t,s.lang);for(const e of r.children)"string"==typeof e?o.appendChild(e):e&&o.appendChild(new ue(e.name,e.attributes,e.children))}}}function qt(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=[],o=new Set,a=Ce(i,e||i.getNamespace(),t);for(const e of a){let t=e.toJSON();if(n&&(t=r.sanitizers[n](t)),t){const n=Ee(e,r.lang);if(o.has(n))continue;s.push({lang:n,value:t}),o.add(n)}}return o.size>0?s:void 0},exporter(i,r,s){for(const o of r){let r=o.value;if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(r&&n){if(!s.sanitizers||!s.sanitizers[n])continue;r=s.sanitizers[n](r)}if(r){const n=je(e||i.getNamespace(),t,s.namespace,i);i.appendChild(n),o.lang!==s.lang&&n.setAttribute("xml:lang",o.lang);for(const e of r.children)"string"==typeof e?n.appendChild(e):n.appendChild(new ue(e.name,e.attributes,e.children))}}}}}function Lt(e,t,n,i){return{importer(r,s){const o={},a=Ce(r,e,t),c=He(n).importer,l=He(i).importer;for(const e of a)o[c(e,s)]=l(e,s);return o},exporter(r,s,o){const a=He(n).exporter,c=He(i).exporter,l=e||r.getNamespace();for(const[e,n]of Object.entries(s)){const i=je(l,t,o.namespace,r);a(i,e,o),s[e]&&c(i,n,o),r.appendChild(i)}}}}class Ft{constructor(){this.parents=new Set,this.placeholder=!1,this.typeField="",this.versionField="",this.defaultType="",this.defaultVersion="",this.languageField="lang",this.typeValues=new Map,this.typeOrders=new Map,this.importers=new Map,this.exporters=new Map,this.children=new Map,this.childrenIndex=new Map,this.implicitChildren=new Set,this.contexts=new Map}addChild(e,t,n=!1,i,r){const s={multiple:n||!1,name:e,selector:i,translator:t},o=this.children.get(e);if(!o){s.translator.parents.add(this),this.children.set(e,s);for(const[n]of t.importers)this.implicitChildren.has(n)||this.childrenIndex.set(n,e);return void(r&&this.implicitChildren.add(r))}const a=o.translator;o.multiple=n,i&&o.selector&&i!==o.selector&&(o.selector=void 0);for(const[n,i]of t.importers){const[r,s]=(a.typeValues.get(n)||"").split("__v__");a.updateDefinition({contexts:t.contexts,element:i.element,exporterOrdering:new Map,exporters:new Map,importerOrdering:i.fieldOrders,importers:i.fields,namespace:i.namespace,optionalNamespaces:new Map,type:r,version:s}),this.implicitChildren.has(n)||this.childrenIndex.set(n,e)}for(const[e,n]of t.exporters){const[i,r]=e.split("__v__");a.updateDefinition({contexts:t.contexts,element:n.element,exporterOrdering:n.fieldOrders,exporters:n.fields,importerOrdering:new Map,importers:new Map,namespace:n.namespace,optionalNamespaces:n.optionalNamespaces,type:i,version:r})}}addContext(e,t,n,i,r,s){t&&(e=`${e}[${t}]`);let o=this.contexts.get(e);o||(o={typeField:"",versionField:"",typeValues:new Map}),s&&(o.impliedType=r),o.typeField=n||"",o.typeValues.set(i,r),this.contexts.set(e,o)}getChild(e){const t=this.children.get(e);if(t)return t.translator}getImportKey(e){return this.childrenIndex.get(`{${e.getNamespace()}}${e.getName()}`)}updateDefinition(e){const t=`{${e.namespace}}${e.element}`,n=e.type||this.defaultType,i=e.version||this.defaultVersion,r=i?`${n}__v__${i}`:n,s=this.importers.get(t)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace};for(const[t,n]of e.importers)s.fields.set(t,n);for(const[t,n]of e.importerOrdering)s.fieldOrders.set(t,n);this.importers.set(t,s);const o=this.exporters.get(r)||{element:e.element,fieldOrders:new Map,fields:new Map,namespace:e.namespace,optionalNamespaces:e.optionalNamespaces};for(const[t,n]of e.exporters)o.fields.set(t,n);for(const[t,n]of e.exporterOrdering)o.fieldOrders.set(t,n);for(const[t,n]of e.optionalNamespaces)o.optionalNamespaces.set(t,n);this.exporters.set(r,o);for(const[t,n]of e.contexts){const e=this.contexts.get(t)||{impliedType:void 0,typeField:n.typeField,versionField:n.versionField,typeValues:new Map};e.typeField||(e.typeField=n.typeField),e.versionField||(e.versionField=n.versionField),e.impliedType||(e.impliedType=n.impliedType);for(const[t,i]of n.typeValues)e.typeValues.set(t,i);this.contexts.set(t,e)}if(e.type)this.typeValues.set(t,r),e.typeOrder&&e.type&&this.typeOrders.set(e.type,e.typeOrder);else if(this.typeField&&!e.type){for(const[,t]of this.importers){for(const[n,i]of e.importers)t.fields.set(n,i);for(const[n,i]of e.importerOrdering)t.fieldOrders.set(n,i)}for(const[,t]of this.exporters){for(const[n,i]of e.exporters)t.fields.set(n,i);for(const[n,i]of e.exporterOrdering)t.fieldOrders.set(n,i)}}}replaceWith(e){for(const[t,n]of this.children)e.children.set(t,n);for(const[t,n]of this.childrenIndex)e.childrenIndex.set(t,n);for(const[t,n]of this.contexts)e.contexts.set(t,n);for(const t of this.implicitChildren)e.implicitChildren.add(t);for(const t of this.parents)for(const n of t.children.values())n.translator===this&&(n.translator=e);this.parents=new Set}import(e,t){const n=`{${e.getNamespace()}}${e.getName()}`,i={},r=this.importers.get(n);if(!r)return;const s=this.typeValues.get(n)||"",[o,a]=s.split("__v__"),c=t.path||"";let l;if(t.pathSelector&&(l=this.contexts.get(`${c}[${t.pathSelector}]`)),l||(l=this.contexts.get(c)),l){if(!l.impliedType){const e=l.typeValues.get(n)||"";e&&(i[l.typeField]=e)}}else this.typeField&&o&&o!==this.defaultType&&(i[this.typeField]=o);this.versionField&&a&&a!==this.defaultVersion&&(i[this.versionField]=a);const u=Object.assign(Object.assign({},t),{data:i,importer:r,lang:(e.getAttribute("xml:lang")||t.lang||"").toLowerCase(),pathSelector:o,translator:this}),p=[...r.fieldOrders.entries()].sort((e,t)=>e[1]>t[1]?-1:e[1]<t[1]?1:0),d=p.filter(e=>e[1]>=0),h=p.filter(e=>e[1]<0);for(const[n]of d){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}for(const n of e.children){if("string"==typeof n)continue;const e=`{${n.getNamespace()}}${n.getName()}`,r=this.childrenIndex.get(e);if(!r)continue;u.path=`${t.path}.${r}`;const{translator:s,multiple:a,selector:c}=this.children.get(r);if(!c||c===o){const e=s.import(n,u);void 0!==e&&(a?(i[r]||(i[r]=[]),i[r].push(e)):i[r]?i[r]=s.resolveCollision(i[r],e):i[r]=e)}}for(const[n]of h){const s=r.fields.get(n);u.path=`${t.path}.${n}`;const o=s(e,u);null!=o&&(i[n]=o)}return i}export(e,t){if(!e)return;let n=this.defaultType,i=this.defaultVersion;const r=t.path||"";let s;t.pathSelector&&(s=this.contexts.get(`${r}[${t.pathSelector}]`)),s||(s=this.contexts.get(r)),s?n=s.impliedType||e[s.typeField]||this.defaultType:this.typeField&&(n=e[this.typeField]||this.defaultType),this.versionField&&(i=e[this.versionField]||this.defaultVersion);const o=i?`${n}__v__${i}`:n,a=this.exporters.get(o);if(!a)return;const c=je(a.namespace,a.element,t.namespace,t.element);t.element&&(c.parent=t.element);for(const[e,t]of a.optionalNamespaces)c.addOptionalNamespace(e,t);const l=Object.assign(Object.assign({},t),{data:e,element:c,exporter:a,lang:(e[this.languageField]||t.lang||"").toLowerCase(),namespace:c.getDefaultNamespace(),pathSelector:n,translator:this}),u=a.fields.get(this.languageField);u&&u(c,e[this.languageField],t);const p=Object.keys(e);p.sort((e,t)=>(a.fieldOrders.get(e)||1e5)-(a.fieldOrders.get(t)||1e5));for(const i of p){if(i===this.languageField)continue;const r=e[i],s=a.fields.get(i);if(s){s(c,r,l);continue}const o=this.children.get(i);if(!o)continue;l.path=`${t.path?t.path+".":""}${i}`;const{translator:u,multiple:p,selector:d}=o;if(!d||d===n){let e;e=p?null!=r?r:[]:[r];for(const t of e){const e=u.export(t,l);e&&c.appendChild(e)}}}return c}resolveCollision(e,t){return(this.typeOrders.get(e[this.typeField]||this.defaultType)||0)<=(this.typeOrders.get(t[this.typeField]||this.defaultType)||0)?e:t}}class Mt{constructor(){this.translators=new Map,this.root=new Ft,this.setLanguageResolver(le)}setLanguageResolver(e){this.languageResolver=e}import(e,t={registry:this}){if(!this.hasTranslator(e.getNamespace(),e.getName()))return;t.acceptLanguages||(t.acceptLanguages=[]),t.acceptLanguages=t.acceptLanguages.map(e=>e.toLowerCase()),t.lang&&(t.lang=t.lang.toLowerCase()),t.resolveLanguage||(t.resolveLanguage=this.languageResolver),t.path=this.getImportKey(e),t.sanitizers||(t.sanitizers={xhtmlim:ye});return this.getOrCreateTranslator(e.getNamespace(),e.getName()).import(e,Object.assign(Object.assign({},t),{registry:this}))}export(e,t,n={registry:this}){n.acceptLanguages||(n.acceptLanguages=[]),n.acceptLanguages=n.acceptLanguages.map(e=>e.toLowerCase()),n.lang&&(n.lang=n.lang.toLowerCase()),n.sanitizers||(n.sanitizers={xhtmlim:ye}),n.path=e;const i=e.split(".").filter(e=>""!==e);let r=this.root;for(const e of i){const t=r.getChild(e);if(!t)return;r=t}return r.export(t,Object.assign(Object.assign({},n),{registry:this}))}getImportKey(e,t=""){const n=t?this.walkToTranslator(t.split(".")):this.root;if(n)return n.getImportKey(e)}define(e){if(Array.isArray(e)){for(const t of e)"object"==typeof t?this.define(t):t(this);return}if("object"!=typeof e)return void e(this);const t=e;t.aliases=t.aliases||[],t.path&&!t.aliases.includes(t.path)&&t.aliases.push(t.path);const n=t.aliases.map(e=>"string"==typeof e?{path:e}:e).sort((e,t)=>{const n=e.path.split(".").length;return t.path.split(".").length-n});let i;if(this.hasTranslator(t.namespace,t.element)&&(i=this.getOrCreateTranslator(t.namespace,t.element)),!i){let e;for(const t of n){const n=this.walkToTranslator(t.path.split("."));if(n&&!n.placeholder){i=n;break}n&&(e=n)}e&&!i&&(i=e,i.placeholder=!1)}i||(i=this.getOrCreateTranslator(t.namespace,t.element)),this.indexTranslator(t.namespace,t.element,i);const r=t.fields||{},s=new Map,o=new Map,a=new Map,c=new Map;t.typeField&&(i.typeField=t.typeField),t.defaultType&&(i.defaultType=t.defaultType),t.versionField&&(i.versionField=t.versionField),t.defaultVersion&&(i.defaultVersion=t.defaultVersion),t.languageField&&(i.languageField=t.languageField);for(const[e,t]of Object.entries(r))s.set(e,t.importer),a.set(e,t.importOrder||t.order||0),o.set(e,t.exporter),c.set(e,t.exportOrder||t.order||0);if(t.childrenExportOrder)for(const[e,n]of Object.entries(t.childrenExportOrder))c.set(e,n||0);const l=new Map;for(const[e,n]of Object.entries(t.optionalNamespaces||{}))l.set(e,n);i.updateDefinition({contexts:new Map,element:t.element,exporterOrdering:c,exporters:o,importerOrdering:a,importers:s,namespace:t.namespace,optionalNamespaces:l,type:t.type,version:t.version,typeOrder:t.typeOrder});for(const e of n)this.alias(t.namespace,t.element,e.path,e.multiple,e.selector,e.contextField,t.type,e.impliedType);for(const e of n){const t=this.walkToTranslator(e.path.split("."));t&&t!==i&&t.replaceWith(i)}}alias(e,t,n,i=!1,r,s,o,a=!1){const c=this.getOrCreateTranslator(e,t);c.placeholder=!1;const l=n.split(".").filter(e=>""!==e),u=l.pop(),p=this.walkToTranslator(l,!0),d=`{${e}}${t}`;o&&(s||a)&&c.addContext(n,r,s,d,o,a),p.addChild(u,c,i,r,d)}walkToTranslator(e,t=!1){let n=this.root;for(const i of e){let e=n.getChild(i);if(!e){if(!t)return;e=new Ft,e.placeholder=!0,n.addChild(i,e)}n=e}return n}hasTranslator(e,t){return this.translators.has(`{${e}}${t}`)}getOrCreateTranslator(e,t){let n=this.translators.get(`{${e}}${t}`);return n||(n=new Ft,this.indexTranslator(e,t,n)),n}indexTranslator(e,t,n){this.translators.set(`{${e}}${t}`,n)}}const Dt="http://www.w3.org/2005/Atom",Bt="urn:ietf:params:xml:ns:xmpp-bind",Ut="jabber:client",zt="urn:ietf:params:xml:ns:xmpp-sasl",Jt="urn:ietf:params:xml:ns:xmpp-session",Gt="urn:ietf:params:xml:ns:xmpp-stanzas",Vt="http://etherx.jabber.org/streams",$t="urn:ietf:params:xml:ns:xmpp-streams",Ht="urn:ietf:params:xml:ns:xmpp-tls",Wt="urn:ietf:params:xml:ns:xmpp-framing",Qt="jabber:x:data",Kt="jabber:iq:privacy",Xt="http://jabber.org/protocol/disco#info",Yt="http://jabber.org/protocol/disco#items",Zt="http://jabber.org/protocol/address",en="http://jabber.org/protocol/muc",tn="http://jabber.org/protocol/muc#admin",nn="http://jabber.org/protocol/muc#owner",rn="http://jabber.org/protocol/muc#user",sn="http://jabber.org/protocol/ibb",on="http://jabber.org/protocol/commands",an="http://jabber.org/protocol/rsm",cn="http://jabber.org/protocol/pubsub",ln="http://jabber.org/protocol/pubsub#errors",un="http://jabber.org/protocol/pubsub#event",pn="http://jabber.org/protocol/pubsub#owner",dn="http://jabber.org/protocol/bytestreams",hn="jabber:x:oob",fn="http://www.w3.org/1999/xhtml",mn="http://jabber.org/protocol/xhtml-im",gn="http://jabber.org/protocol/geoloc",vn="urn:xmpp:avatar:data",bn="urn:xmpp:avatar:metadata",yn="http://jabber.org/protocol/chatstates",_n="http://jabber.org/protocol/mood",Sn="http://jabber.org/protocol/activity",wn="http://jabber.org/protocol/tune",xn="http://jabber.org/protocol/xdata-validate",Tn="http://jabber.org/protocol/httpbind",kn="http://jabber.org/protocol/shim",In="http://jabber.org/protocol/compress",jn="http://jabber.org/protocol/xdata-layout",En="http://jabber.org/protocol/rosterx",Nn=e=>e+"+notify",Cn="urn:xmpp:jingle:1",Rn="urn:xmpp:jingle:apps:rtp:1",On="urn:xmpp:jingle:apps:rtp:info:1",An="http://jabber.org/protocol/nick",Pn="urn:xmpp:jingle:transports:ice-udp:1",qn="urn:xmpp:jingle:transports:raw-udp:1",Ln="urn:xmpp:sm:3",Fn="urn:xmpp:delay",Mn="urn:xmpp:bob",Dn="urn:xmpp:jingle:apps:file-transfer:5",Bn="urn:xmpp:jingle:apps:xmlstream:0",Un="urn:xmpp:jingle:transports:s5b:1",zn="urn:xmpp:jingle:transports:ibb:1",Jn="urn:xmpp:carbons:2",Gn="urn:xmpp:jingle:apps:rtp:rtcp-fb:0",Vn="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0",$n="urn:xmpp:forward:0",Hn="urn:xmpp:hashes:2",Wn=e=>"urn:xmpp:hash-function-text-names:"+e,Qn="urn:xmpp:rtt:0",Kn="urn:xmpp:hats:0",Xn="urn:xmpp:chat-markers:0",Yn="urn:xmpp:hints",Zn="urn:xmpp:json:0",ei="urn:xmpp:push:0",ti="urn:xmpp:http:upload:0",ni="urn:xmpp:jingle:transports:ice:0",ii="eu.siacs.conversations.axolotl",ri="http://docs.oasis-open.org/ns/xri/xrd-1.0";var si=Object.freeze({__proto__:null,NS_ATOM:Dt,NS_BIND:Bt,NS_CLIENT:Ut,NS_SASL:zt,NS_SERVER:"jabber:server",NS_SESSION:Jt,NS_STANZAS:Gt,NS_STREAM:Vt,NS_STREAMS:$t,NS_STARTTLS:Ht,NS_ROSTER:"jabber:iq:roster",NS_ROSTER_VERSIONING:"urn:xmpp:features:rosterver",NS_SUBSCRIPTION_PREAPPROVAL:"urn:xmpp:features:pre-approval",NS_FRAMING:Wt,NS_DATAFORM:Qt,NS_RPC:"jabber:iq:rpc",NS_LAST_ACTIVITY:"jabber:iq:last",NS_PRIVACY:Kt,NS_LEGACY_CHAT_EVENTS:"jabber:x:event",NS_DISCO_INFO:Xt,NS_DISCO_ITEMS:Yt,NS_ADDRESS:Zt,NS_MUC:en,NS_MUC_ADMIN:tn,NS_MUC_OWNER:nn,NS_MUC_USER:rn,NS_IBB:sn,NS_BOOKMARKS:"storage:bookmarks",NS_PRIVATE:"jabber:iq:private",NS_ADHOC_COMMANDS:on,NS_VCARD_TEMP:"vcard-temp",NS_SEARCH:"jabber:iq:search",NS_RSM:an,NS_PUBSUB:cn,NS_PUBSUB_ERRORS:ln,NS_PUBSUB_EVENT:un,NS_PUBSUB_OWNER:pn,NS_SOCKS5:dn,NS_OOB:hn,NS_OOB_TRANSFER:"jabber:iq:oob",NS_HTTP_AUTH:"http://jabber.org/protocol/http-auth",NS_XHTML:fn,NS_XHTML_IM:mn,NS_REGISTER:"jabber:iq:register",NS_INBAND_REGISTRATION:"http://jabber.org/features/iq-register",NS_AMP:"http://jabber.org/protocol/amp",NS_GEOLOC:gn,NS_ROSTER_DELIMITER:"roster:delimiter",NS_AVATAR_DATA:vn,NS_AVATAR_METADATA:bn,NS_CHAT_STATES:yn,NS_VERSION:"jabber:iq:version",NS_MOOD:_n,NS_ACTIVITY:Sn,NS_COMPONENT:"jabber:component:accept",NS_DISCO_LEGACY_CAPS:"http://jabber.org/protocol/caps",NS_TUNE:wn,NS_DATAFORM_VALIDATION:xn,NS_BOSH:Tn,NS_SHIM:kn,NS_COMPRESSION_FEATURE:"http://jabber.org/features/compress",NS_COMPRESSION:In,NS_DATAFORM_LAYOUT:jn,NS_ROSTER_EXCHANGE:En,NS_ROSTER_NOTES:"storage:rosternotes",NS_REACH_0:"urn:xmpp:reach:0",NS_VCARD_TEMP_UPDATE:"vcard-temp:x:update",NS_ALT_CONNECTIONS_WEBSOCKET:"urn:xmpp:alt-connections:websocket",NS_ALT_CONNECTIONS_XBOSH:"urn:xmpp:alt-connections:xbosh",NS_CAPTCHA:"urn:xmpp:captcha",NS_PEP_NOTIFY:Nn,NS_JINGLE_1:Cn,NS_JINGLE_ERRORS_1:"urn:xmpp:jingle:errors:1",NS_JINGLE_RTP_1:Rn,NS_JINGLE_RTP_ERRORS_1:"urn:xmpp:jingle:apps:rtp:errors:1",NS_JINGLE_RTP_INFO_1:On,NS_JINGLE_RTP_AUDIO:"urn:xmpp:jingle:apps:rtp:audio",NS_JINGLE_RTP_VIDEO:"urn:xmpp:jingle:apps:rtp:video",NS_LANG_TRANS:"urn:xmpp:langtrans",NS_LANG_TRANS_ITEMS:"urn:xmpp:langtrans:items",NS_NICK:An,NS_JINGLE_ICE_UDP_1:Pn,NS_JINGLE_RAW_UDP_1:qn,NS_RECEIPTS:"urn:xmpp:receipts",NS_INVISIBLE_0:"urn:xmpp:invisible:0",NS_BLOCKING:"urn:xmpp:blocking",NS_BLOCKING_ERRORS:"urn:xmpp:blocking:errors",NS_SMACKS_3:Ln,NS_PING:"urn:xmpp:ping",NS_TIME:"urn:xmpp:time",NS_DELAY:Fn,NS_BOSH_XMPP:"urn:xmpp:xbosh",NS_DISCO_EXTERNAL_1:"urn:xmpp:extdisco:1",NS_DISCO_EXTERNAL_2:"urn:xmpp:extdisco:2",NS_DATAFORM_MEDIA:"urn:xmpp:media-element",NS_ATTENTION_0:"urn:xmpp:attention:0",NS_BOB:Mn,NS_SOFTWARE_INFO:"urn:xmpp:dataforms:softwareinfo",NS_JINGLE_FILE_TRANSFER_3:"urn:xmpp:jingle:apps:file-transfer:3",NS_JINGLE_FILE_TRANSFER_4:"urn:xmpp:jingle:apps:file-transfer:4",NS_JINGLE_FILE_TRANSFER_5:Dn,NS_JINGLE_XML_0:Bn,NS_MUC_DIRECT_INVITE:"jabber:x:conference",NS_SEC_LABEL_0:"urn:xmpp:sec-label:0",NS_SEC_LABEL_CATALOG_2:"urn:xmpp:sec-label:catalog:2",NS_SEC_LABEL_ESS_0:"urn:xmpp:sec-label:ess:0",NS_JINGLE_SOCKS5_1:Un,NS_JINGLE_IBB_1:zn,NS_JINGLE_RTP_ZRTP_1:"urn:xmpp:jingle:apps:rtp:zrtp:1",NS_THUMBS_0:"urn:xmpp:thumbs:0",NS_THUMBS_1:"urn:xmpp:thumbs:1",NS_DECLOAKING_0:"urn:xmpp:decloaking:0",NS_CARBONS_2:Jn,NS_JINGLE_RTP_RTCP_FB_0:Gn,NS_JINGLE_RTP_HDREXT_0:Vn,NS_FORWARD_0:$n,NS_HASHES_1:"urn:xmpp:hashes:1",NS_HASHES_2:Hn,NS_HASH_NAME:Wn,NS_RTT_0:Qn,NS_MUC_UNIQUE:"http://jabber.org/protocol/muc#unique",NS_CORRECTION_0:"urn:xmpp:message-correct:0",NS_PSA:"urn:xmpp:psa",NS_MAM_TMP:"urn:xmpp:mam:tmp",NS_MAM_0:"urn:xmpp:mam:0",NS_MAM_1:"urn:xmpp:mam:1",NS_MAM_2:"urn:xmpp:mam:2",NS_HATS_0:Kn,NS_IDLE_1:"urn:xmpp:idle:1",NS_JINGLE_DTLS_0:"urn:xmpp:jingle:apps:dtls:0",NS_CHAT_MARKERS_0:Xn,NS_HINTS:Yn,NS_JSON_0:Zn,NS_JINGLE_GROUPING_0:"urn:xmpp:jingle:apps:grouping:0",NS_JINGLE_RTP_SSMA_0:"urn:xmpp:jingle:apps:rtp:ssma:0",NS_JINGLE_DTLS_SCTP_1:"urn:xmpp:jingle:transports:dtls-sctp:1",NS_CSI_0:"urn:xmpp:csi:0",NS_JINGLE_MSG_INITIATE_0:"urn:xmpp:jingle:jingle-message:0",NS_DELEGATION_1:"urn:xmpp:delegation:1",NS_PUSH_0:ei,NS_JINGLE_PUB_1:"urn:xmpp:jinglepub:1",NS_SID_0:"urn:xmpp:sid:0",NS_HTTP_UPLOAD_0:ti,NS_JINGLE_HTTP_0:"urn:xmpp:jingle:transports:http:0",NS_JINGLE_HTTP_UPLOAD_0:"urn:xmpp:jingle:transports:http:upload:0",NS_JINGLE_ICE_0:ni,NS_REFERENCE_0:"urn:xmpp:reference:0",NS_EME_0:"urn:xmpp:eme:0",NS_SPOILER_0:"urn:xmpp:spoiler:0",NS_OMEMO_AXOLOTL:ii,NS_OMEMO_AXOLOTL_DEVICELIST:"eu.siacs.conversations.axolotl.devicelist",NS_OMEMO_AXOLOTL_BUNDLES:"eu.siacs.conversations.axolotl.bundles",NS_OMEMO_AXOLOTL_BUNDLE:e=>"eu.siacs.conversations.axolotl.bundles:"+e,NS_JSON_MESSAGE_0:"urn:xmpp:json-msg:0",NS_XRD:ri,NS_JINGLE_RTP_MSID_0:"urn:xmpp:jingle:apps:rtp:msid:0"});const oi=He,ai=it,ci=dt;function li(e,t,n){return{aliases:Array.isArray(n)?n:[n],element:t,fields:{},namespace:e}}function ui(e){return{element:"message",fields:e,namespace:Ut}}function pi(e){return{element:"presence",fields:e,namespace:Ut}}function di(e){return{element:"iq",fields:e,namespace:Ut}}function hi(e){return{element:"features",fields:e,namespace:Vt}}function fi(e){return{element:"error",fields:e,namespace:Gt,path:"stanzaError"}}function mi(){return[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}]}class gi extends l.Transform{constructor(e){super({objectMode:!0}),this.closedStream=!1,this.wrappedStream=!1,this.registry=e.registry,this.acceptLanguages=e.acceptLanguages||[],e.wrappedStream&&(this.wrappedStream=!0,this.rootImportKey=e.rootKey),this.parser=new ke({allowComments:e.allowComments}),this.parser.on("error",e=>{this.destroy(e)}),this.parser.on("startElement",(e,t)=>{if(this.destroyed)return;if(this.closedStream)return this.destroy(Z.alreadyClosed());const n=new ue(e,t),i=this.registry.getImportKey(n);if(this.wrappedStream&&!this.rootElement){if(this.rootImportKey&&i!==this.rootImportKey)return this.destroy(Z.unknownRoot());const e=this.registry.import(n,{acceptLanguages:this.acceptLanguages,lang:this.lang});return e?(this.rootElement=n,void this.push({event:"stream-start",kind:i,stanza:e,xml:n})):this.destroy(Z.notWellFormed())}this.currentElement?this.currentElement=this.currentElement.appendChild(n):this.currentElement=n}),this.parser.on("endElement",e=>{if(!this.destroyed){if(this.wrappedStream&&!this.currentElement)return this.rootElement&&e===this.rootElement.name?(this.closedStream=!0,this.push({event:"stream-end",kind:this.rootImportKey,stanza:{},xml:this.rootElement}),this.end()):(this.closedStream=!0,this.destroy(Z.notWellFormed()));if(!this.currentElement||e!==this.currentElement.name)return this.closedStream=!0,this.destroy(Z.notWellFormed());if(this.currentElement.parent)this.currentElement=this.currentElement.parent;else{this.wrappedStream&&(this.currentElement.parent=this.rootElement);const e=this.registry.getImportKey(this.currentElement),t=this.registry.import(this.currentElement,{acceptLanguages:this.acceptLanguages,lang:this.lang});t&&this.push({kind:e,stanza:t,xml:this.currentElement}),this.currentElement=void 0}}}),this.parser.on("text",e=>{this.currentElement&&this.currentElement.children.push(e)})}_transform(e,t,n){this.parser.write(e.toString()),n()}}var vi=Object.freeze({__proto__:null,Registry:Mt,Translator:Ft,XMLElement:ue,define:function(e){return t=>{t.define(e)}},Parser:ke,parse:Ie,StreamParser:gi,escapeXML:oe,unescapeXML:ae,escapeXMLText:ce,basicLanguageResolver:le,createElement:je,getLang:Ee,getTargetLang:Ne,findAll:Ce,findOrCreate:Re,attribute:He,booleanAttribute:We,integerAttribute:Qe,floatAttribute:Ke,dateAttribute:Xe,namespacedAttribute:Ye,namespacedBooleanAttribute:Ze,namespacedIntegerAttribute:et,namespacedFloatAttribute:tt,namespacedDateAttribute:nt,childAttribute:it,childBooleanAttribute:rt,childIntegerAttribute:st,childFloatAttribute:ot,childDateAttribute:at,text:ct,textJSON:lt,textBuffer:ut,languageAttribute:pt,childLanguageAttribute:(e,t)=>qe(Object.assign({converter:pt(),element:t,name:"xml:lang",namespace:e},De)),childText:dt,childTextBuffer:ht,childDate:ft,childInteger:mt,childFloat:gt,childJSON:vt,childTimezoneOffset:bt,childBoolean:yt,deepChildText:St,deepChildInteger:wt,deepChildBoolean:xt,deepMultipleChildText:Tt,childEnum:kt,childDoubleEnum:It,multipleChildText:jt,multipleChildAttribute:Et,multipleChildIntegerAttribute:Nt,childAlternateLanguageText:Ct,multipleChildAlternateLanguageText:function(e,t){return{importer(n,i){const r=[],s=new Map;let o=!1;const a=Ce(n,e||n.getNamespace(),t);for(const e of a){const t=e.getText();if(t){const n=Ee(e,i.lang);let a=s.get(n);a||(a=[],s.set(n,a),r.push({lang:n,value:a})),a.push(t),o=!0}}return o?r:void 0},exporter(n,i,r){for(const s of i)for(const i of s.value){const o=je(e||n.getNamespace(),t,r.namespace,n);s.lang!==r.lang&&o.setAttribute("xml:lang",s.lang),o.children.push(i),n.appendChild(o)}}}},multipleChildEnum:Rt,splicePath:Ot,staticValue:At,childRawElement:function(e,t,n){return{importer(i,r){if(n&&(!r.sanitizers||!r.sanitizers[n]))return;const s=i.getChild(t,e||i.getNamespace());return s?n?r.sanitizers[n](s.toJSON()):s.toJSON():void 0},exporter(i,r,s){if("string"==typeof r){r=Ie(`<${t} xmlns="${e||i.getNamespace()}">${r}</${t}>`).toJSON()}if(n){if(!s.sanitizers||!s.sanitizers[n])return;r=s.sanitizers[n](r)}r&&i.appendChild(new ue(r.name,r.attributes,r.children))}}},childLanguageRawElement:Pt,childAlternateLanguageRawElement:qt,parameterMap:Lt,JIDAttribute:oi,childJIDAttribute:ai,childJID:ci,addAlias:li,extendMessage:ui,extendPresence:pi,extendIQ:di,extendStreamFeatures:hi,extendStanzaError:fi,pubsubItemContentAliases:mi});class bi extends l.Transform{constructor(t,n,i="be"){super(),this._block=e.alloc(t),this._finalSize=n,this._blockSize=t,this._bigEndian="be"===i,this._len=0}_transform(e,t,n){let i=null;try{this.update(e,t)}catch(e){i=e}n(i)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(t,n){"string"==typeof t&&(n=n||"utf8",t=e.from(t,n));const i=this._block,r=this._blockSize,s=t.length;let o=this._len;for(let e=0;e<s;){const n=o%r,a=Math.min(s-e,r-n);for(let r=0;r<a;r++)i[n+r]=t[e+r];o+=a,e+=a,o%r==0&&this._update(i)}return this._len+=s,this}digest(e){const t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));const n=8*this._len;if(n<=4294967295)this._bigEndian?(this._block.writeUInt32BE(0,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)):(this._block.writeUInt32LE(n,this._blockSize-8),this._block.writeUInt32LE(0,this._blockSize-4));else{const e=(4294967295&n)>>>0,t=(n-e)/4294967296;this._bigEndian?(this._block.writeUInt32BE(t,this._blockSize-8),this._block.writeUInt32BE(e,this._blockSize-4)):(this._block.writeUInt32LE(e,this._blockSize-8),this._block.writeUInt32LE(t,this._blockSize-4))}this._update(this._block);const i=this._hash();return e?i.toString(e):i}_update(e){throw new Error("_update must be implemented by subclass")}_hash(){throw new Error("_update must be implemented by subclass")}}function yi(e,t){return e<<t|e>>>32-t}function _i(e,t,n,i,r,s,o){return yi(e+(t&n|~t&i)+r+s|0,o)+t|0}function Si(e,t,n,i,r,s,o){return yi(e+(t&i|n&~i)+r+s|0,o)+t|0}function wi(e,t,n,i,r,s,o){return yi(e+(t^n^i)+r+s|0,o)+t|0}function xi(e,t,n,i,r,s,o){return yi(e+(n^(t|~i))+r+s|0,o)+t|0}const Ti=[1518500249,1859775393,-1894007588,-899497514];function ki(e){return e<<5|e>>>27}function Ii(e){return e<<30|e>>>2}function ji(e,t,n,i){return 0===e?t&n|~t&i:2===e?t&n|t&i|n&i:t^n^i}class Ei extends bi{constructor(){super(64,56),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this._w=new Array(80)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<80;++n)t[n]=(c=t[n-3]^t[n-8]^t[n-14]^t[n-16])<<1|c>>>31;var c;for(let e=0;e<80;++e){const n=~~(e/20),c=ki(i)+ji(n,r,s,o)+a+t[e]+Ti[n]|0;a=o,o=s,s=Ii(r),r=i,i=c}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0}_hash(){const t=e.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t}}const Ni=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Ci(e,t,n){return n^e&(t^n)}function Ri(e,t,n){return e&t|n&(e|t)}function Oi(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Ai(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Pi(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}class qi extends bi{constructor(){super(64,56),this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this._w=new Array(64)}_update(e){const t=this._w;let n,i=0|this._a,r=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,c=0|this._f,l=0|this._g,u=0|this._h;for(n=0;n<16;++n)t[n]=e.readInt32BE(4*n);for(;n<64;++n)t[n]=0|(((p=t[n-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10)+t[n-7]+Pi(t[n-15])+t[n-16];var p;for(let e=0;e<64;++e){const n=u+Ai(a)+Ci(a,c,l)+Ni[e]+t[e]|0,p=Oi(i)+Ri(i,r,s)|0;u=l,l=c,c=a,a=o+n|0,o=s,s=r,r=i,i=n+p|0}this._a=i+this._a|0,this._b=r+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=c+this._f|0,this._g=l+this._g|0,this._h=u+this._h|0}_hash(){const t=e.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t}}const Li=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Fi(e,t,n){return n^e&(t^n)}function Mi(e,t,n){return e&t|n&(e|t)}function Di(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Bi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Ui(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function zi(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Ji(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Gi(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Vi(e,t){return e>>>0<t>>>0?1:0}class $i extends bi{constructor(){super(128,112),this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this._w=new Array(160)}_update(e){const t=this._w;let n,i,r=0|this._ah,s=0|this._bh,o=0|this._ch,a=0|this._dh,c=0|this._eh,l=0|this._fh,u=0|this._gh,p=0|this._hh,d=0|this._al,h=0|this._bl,f=0|this._cl,m=0|this._dl,g=0|this._el,v=0|this._fl,b=0|this._gl,y=0|this._hl,_=0;for(_=0;_<32;_+=2)t[_]=e.readInt32BE(4*_),t[_+1]=e.readInt32BE(4*_+4);for(;_<160;_+=2){let e=t[_-30],r=t[_-30+1];const s=Ui(e,r),o=zi(r,e);e=t[_-4],r=t[_-4+1];const a=Ji(e,r),c=Gi(r,e),l=t[_-14],u=t[_-14+1],p=t[_-32],d=t[_-32+1];i=o+u|0,n=s+l+Vi(i,o)|0,i=i+c|0,n=n+a+Vi(i,c)|0,i=i+d|0,n=n+p+Vi(i,d)|0,t[_]=n,t[_+1]=i}for(let e=0;e<160;e+=2){n=t[e],i=t[e+1];const _=Mi(r,s,o),S=Mi(d,h,f),w=Di(r,d),x=Di(d,r),T=Bi(c,g),k=Bi(g,c),I=Li[e],j=Li[e+1],E=Fi(c,l,u),N=Fi(g,v,b);let C=y+k|0,R=p+T+Vi(C,y)|0;C=C+N|0,R=R+E+Vi(C,N)|0,C=C+j|0,R=R+I+Vi(C,j)|0,C=C+i|0,R=R+n+Vi(C,i)|0;const O=x+S|0,A=w+_+Vi(O,x)|0;p=u,y=b,u=l,b=v,l=c,v=g,g=m+C|0,c=a+R+Vi(g,m)|0,a=o,m=f,o=s,f=h,s=r,h=d,d=C+O|0,r=R+A+Vi(d,C)|0}this._al=this._al+d|0,this._bl=this._bl+h|0,this._cl=this._cl+f|0,this._dl=this._dl+m|0,this._el=this._el+g|0,this._fl=this._fl+v|0,this._gl=this._gl+b|0,this._hl=this._hl+y|0,this._ah=this._ah+r+Vi(this._al,d)|0,this._bh=this._bh+s+Vi(this._bl,h)|0,this._ch=this._ch+o+Vi(this._cl,f)|0,this._dh=this._dh+a+Vi(this._dl,m)|0,this._eh=this._eh+c+Vi(this._el,g)|0,this._fh=this._fh+l+Vi(this._fl,v)|0,this._gh=this._gh+u+Vi(this._gl,b)|0,this._hh=this._hh+p+Vi(this._hl,y)|0}_hash(){const t=e.allocUnsafe(64);function n(e,n,i){t.writeInt32BE(e,i),t.writeInt32BE(n,i+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),n(this._gh,this._gl,48),n(this._hh,this._hl,56),t}}const Hi=new Map([["md5",class extends bi{constructor(){super(64,56,"le"),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._m=new Array(16)}_update(e){const t=this._m;for(let n=0;n<16;++n)t[n]=e.readInt32LE(4*n);let n=this._a,i=this._b,r=this._c,s=this._d;n=_i(n,i,r,s,t[0],3614090360,7),s=_i(s,n,i,r,t[1],3905402710,12),r=_i(r,s,n,i,t[2],606105819,17),i=_i(i,r,s,n,t[3],3250441966,22),n=_i(n,i,r,s,t[4],4118548399,7),s=_i(s,n,i,r,t[5],1200080426,12),r=_i(r,s,n,i,t[6],2821735955,17),i=_i(i,r,s,n,t[7],4249261313,22),n=_i(n,i,r,s,t[8],1770035416,7),s=_i(s,n,i,r,t[9],2336552879,12),r=_i(r,s,n,i,t[10],4294925233,17),i=_i(i,r,s,n,t[11],2304563134,22),n=_i(n,i,r,s,t[12],1804603682,7),s=_i(s,n,i,r,t[13],4254626195,12),r=_i(r,s,n,i,t[14],2792965006,17),i=_i(i,r,s,n,t[15],1236535329,22),n=Si(n,i,r,s,t[1],4129170786,5),s=Si(s,n,i,r,t[6],3225465664,9),r=Si(r,s,n,i,t[11],643717713,14),i=Si(i,r,s,n,t[0],3921069994,20),n=Si(n,i,r,s,t[5],3593408605,5),s=Si(s,n,i,r,t[10],38016083,9),r=Si(r,s,n,i,t[15],3634488961,14),i=Si(i,r,s,n,t[4],3889429448,20),n=Si(n,i,r,s,t[9],568446438,5),s=Si(s,n,i,r,t[14],3275163606,9),r=Si(r,s,n,i,t[3],4107603335,14),i=Si(i,r,s,n,t[8],1163531501,20),n=Si(n,i,r,s,t[13],2850285829,5),s=Si(s,n,i,r,t[2],4243563512,9),r=Si(r,s,n,i,t[7],1735328473,14),i=Si(i,r,s,n,t[12],2368359562,20),n=wi(n,i,r,s,t[5],4294588738,4),s=wi(s,n,i,r,t[8],2272392833,11),r=wi(r,s,n,i,t[11],1839030562,16),i=wi(i,r,s,n,t[14],4259657740,23),n=wi(n,i,r,s,t[1],2763975236,4),s=wi(s,n,i,r,t[4],1272893353,11),r=wi(r,s,n,i,t[7],4139469664,16),i=wi(i,r,s,n,t[10],3200236656,23),n=wi(n,i,r,s,t[13],681279174,4),s=wi(s,n,i,r,t[0],3936430074,11),r=wi(r,s,n,i,t[3],3572445317,16),i=wi(i,r,s,n,t[6],76029189,23),n=wi(n,i,r,s,t[9],3654602809,4),s=wi(s,n,i,r,t[12],3873151461,11),r=wi(r,s,n,i,t[15],530742520,16),i=wi(i,r,s,n,t[2],3299628645,23),n=xi(n,i,r,s,t[0],4096336452,6),s=xi(s,n,i,r,t[7],1126891415,10),r=xi(r,s,n,i,t[14],2878612391,15),i=xi(i,r,s,n,t[5],4237533241,21),n=xi(n,i,r,s,t[12],1700485571,6),s=xi(s,n,i,r,t[3],2399980690,10),r=xi(r,s,n,i,t[10],4293915773,15),i=xi(i,r,s,n,t[1],2240044497,21),n=xi(n,i,r,s,t[8],1873313359,6),s=xi(s,n,i,r,t[15],4264355552,10),r=xi(r,s,n,i,t[6],2734768916,15),i=xi(i,r,s,n,t[13],1309151649,21),n=xi(n,i,r,s,t[4],4149444226,6),s=xi(s,n,i,r,t[11],3174756917,10),r=xi(r,s,n,i,t[2],718787259,15),i=xi(i,r,s,n,t[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+i|0,this._c=this._c+r|0,this._d=this._d+s|0}_hash(){const t=e.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t}}],["sha-1",Ei],["sha-256",qi],["sha-512",$i],["sha1",Ei],["sha256",qi],["sha512",$i]]);function Wi(e){e=e.toLowerCase();const t=Hi.get(e);if(t)return new t;throw new Error("Unsupported hash algorithm: "+e)}const Qi=e.alloc(128);class Ki extends l.Transform{constructor(t,n){super(),"string"==typeof n&&(n=e.from(n));const i="sha512"===t?128:64;this._alg=t,n.length>i?n=Wi(t).update(n).digest():n.length<i&&(n=e.concat([n,Qi],i)),this._ipad=e.alloc(i),this._opad=e.alloc(i);for(let e=0;e<i;e++)this._ipad[e]=54^n[e],this._opad[e]=92^n[e];this._hash=Wi(t).update(this._ipad)}_transform(e,t,n){let i;try{this.update(e,t)}catch(e){i=e}finally{n(i)}}_flush(e){let t;try{this.push(this._final())}catch(e){t=e}e(t)}_final(){const e=this._hash.digest();return Wi(this._alg).update(this._opad).update(e).digest()}update(e,t){return this._hash.update(e,t),this}digest(t){const n=this._final()||e.alloc(0);return t?n.toString(t):n}}let Xi;function Yi(t){const n=new Uint8Array(t);return t>0&&(Xi.crypto||Xi.msCrypto).getRandomValues(n),e.from(n.buffer)}"undefined"!=typeof window?Xi=window:void 0!==i&&(Xi=i);const Zi=fetch,er=WebSocket,tr=Xi.RTCPeerConnection;class nr{constructor(e){this.authenticated=!1,this.mutuallyAuthenticated=!1,this.name=e}getCacheableCredentials(){return null}processChallenge(e){}processSuccess(e){this.authenticated=!0}finalize(){const e={authenticated:this.authenticated,mutuallyAuthenticated:this.mutuallyAuthenticated};return this.errorData&&(e.errorData=this.errorData),e}}class ir{constructor(){this.mechanisms=[]}register(e,t,n){this.mechanisms.push({constructor:t,name:e.toUpperCase(),priority:n}),this.mechanisms.sort((e,t)=>t.priority-e.priority)}disable(e){const t=e.toUpperCase();this.mechanisms=this.mechanisms.filter(e=>e.name!==t)}createMechanism(e){const t=e.map(e=>e.toUpperCase());for(const e of this.mechanisms)for(const n of t)if(n===e.name)return new e.constructor(e.name);return null}}function rr(e=32){return Yi(e).toString("hex")}function sr(t,n){const i=[];for(let e=0;e<t.length;e++)i.push(t[e]^n[e]);return e.from(i)}function or(e,t){return Wi(t).update(e).digest()}function ar(e,t,n){return function(e,t){return new Ki(e.toLowerCase(),t)}(n,e).update(t).digest()}function cr(t,n,i,r){let s=ar(t,e.concat([n,e.from("00000001","hex")]),r),o=s;for(let e=0;e<i-1;e++)s=ar(t,s,r),o=sr(o,s);return o}function lr(e){const t={},n=e.toString().split(/,(?=(?:[^"]|"[^"]*")*$)/);for(let e=0,i=n.length;e<i;e++){const i=/(\w+)=["]?([^"]+)["]?$/.exec(n[e]);i&&(t[i[1]]=i[2])}return t}function ur(e){const t=[];for(const n of e)","===n?t.push("=2C"):"="===n?t.push("=3D"):t.push(n);return t.join("")}class pr extends nr{getExpectedCredentials(){return{optional:["trace"],required:[]}}createResponse(t){return e.from(t.trace||"")}}class dr extends nr{getExpectedCredentials(){return{optional:["authzid"],required:[]}}createResponse(t){return e.from(t.authzid||"")}}class hr extends nr{getExpectedCredentials(){return{optional:["authzid"],required:["username","password"]}}createResponse(t){return e.from((t.authzid||"")+"\0"+t.username+"\0"+(t.password||t.token))}}class fr extends nr{constructor(e){super(e),this.failed=!1,this.name=e}getExpectedCredentials(){return{optional:["authzid"],required:["token"]}}createResponse(t){if(this.failed)return e.from("");const n=`n,${ur(M(t.authzid))},`,i=`auth=Bearer ${t.token}`;return e.from(n+""+i+"","utf8")}processChallenge(e){this.failed=!0,this.errorData=JSON.parse(e.toString("utf8"))}}class mr extends nr{constructor(e){super(e),this.providesMutualAuthentication=!1,this.state="INITIAL",this.name=e}processChallenge(e){this.state="CHALLENGE";const t=lr(e);this.authenticated=!!t.rspauth,this.realm=t.realm,this.nonce=t.nonce,this.charset=t.charset}getExpectedCredentials(){return{optional:["authzid","clientNonce","realm"],required:["host","password","serviceName","serviceType","username"]}}createResponse(t){if("INITIAL"===this.state||this.authenticated)return null;let n=t.serviceType+"/"+t.host;t.serviceName&&t.host!==t.serviceName&&(n+="/"+t.serviceName);const i=t.realm||this.realm||"",r=t.clientNonce||rr(16),s="00000001";let o="";o+='username="'+t.username+'"',i&&(o+=',realm="'+i+'"'),o+=',nonce="'+this.nonce+'"',o+=',cnonce="'+r+'"',o+=",nc="+s,o+=",qop=auth",o+=',digest-uri="'+n+'"';const a=Wi("md5").update(t.username).update(":").update(i).update(":").update(t.password).digest(),c=Wi("md5").update(a).update(":").update(this.nonce).update(":").update(r);t.authzid&&c.update(":").update(t.authzid);const l=c.digest("hex"),u=Wi("md5").update("AUTHENTICATE:").update(n).digest("hex");return o+=",response="+Wi("md5").update(l).update(":").update(this.nonce).update(":").update(s).update(":").update(r).update(":").update("auth").update(":").update(u).digest("hex"),"utf-8"===this.charset&&(o+=",charset=utf-8"),t.authzid&&(o+=',authzid="'+t.authzid+'"'),e.from(o)}}class gr{constructor(e){this.providesMutualAuthentication=!0,this.name=e,this.state="INITIAL",this.useChannelBinding=this.name.toLowerCase().endsWith("-plus"),this.algorithm=this.name.toLowerCase().split("scram-")[1].split("-plus")[0]}getExpectedCredentials(){const e=["username","password"];return this.useChannelBinding&&e.push("tlsUnique"),{optional:["authzid","clientNonce"],required:e}}getCacheableCredentials(){return this.cache}createResponse(e){return"INITIAL"===this.state?this.initialResponse(e):this.challengeResponse(e)}processChallenge(t){const n=lr(t);this.salt=e.from(n.s||"","base64"),this.iterationCount=parseInt(n.i,10),this.nonce=n.r,this.verifier=n.v,this.error=n.e,this.challenge=t}processSuccess(e){this.processChallenge(e)}finalize(){return this.verifier?this.serverSignature.toString("base64")!==this.verifier?{authenticated:!1,error:"Mutual authentication failed",mutuallyAuthenticated:!1}:{authenticated:!0,mutuallyAuthenticated:!0}:{authenticated:!1,error:this.error,mutuallyAuthenticated:!1}}initialResponse(t){const n=ur(M(t.authzid)),i=ur(M(t.username));this.clientNonce=t.clientNonce||rr();let r="n";t.tlsUnique&&(r=this.useChannelBinding?"p=tls-unique":"y"),this.gs2Header=e.from(n?`${r},a=${n},`:r+",,"),this.clientFirstMessageBare=e.from(`n=${i},r=${this.clientNonce}`);const s=e.concat([this.gs2Header,this.clientFirstMessageBare]);return this.state="CHALLENGE",s}challengeResponse(t){const n=e.from("Client Key"),i=e.from("Server Key"),r=e.concat([this.gs2Header,t.tlsUnique||e.from("")]).toString("base64"),s=e.from(`c=${r},r=${this.nonce}`);let o,a,c;const l=t.salt&&0===e.compare(t.salt,this.salt);l&&t.clientKey&&t.serverKey?(a=e.from(t.clientKey),c=e.from(t.serverKey)):l&&t.saltedPassword?(o=e.from(t.saltedPassword),a=ar(o,n,this.algorithm),c=ar(o,i,this.algorithm)):(o=cr(e.from(M(t.password)),this.salt,this.iterationCount,this.algorithm),a=ar(o,n,this.algorithm),c=ar(o,i,this.algorithm));const u=or(a,this.algorithm),p=e.from(","),d=e.concat([this.clientFirstMessageBare,p,this.challenge,p,s]),h=sr(a,ar(u,d,this.algorithm)).toString("base64");this.serverSignature=ar(c,d,this.algorithm);const f=e.concat([s,e.from(",p="+h)]);return this.state="FINAL",this.cache={clientKey:a,salt:this.salt,saltedPassword:o,serverKey:c},f}}var vr=Object.freeze({__proto__:null,SimpleMech:nr,Factory:ir,createClientNonce:rr,XOR:sr,H:or,HMAC:ar,Hi:cr,ANONYMOUS:pr,EXTERNAL:dr,PLAIN:hr,OAUTH:fr,DIGEST:mr,SCRAM:gr});function br(e){e.getAccountInfo=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({account:{},to:t,type:"get"})).account})),e.updateAccount=(t,n)=>e.sendIQ({account:n,to:t,type:"set"}),e.deleteAccount=t=>e.sendIQ({account:{remove:!0},to:t,type:"set"}),e.getPrivateData=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({privateStorage:{[t]:{}},type:"get"})).privateStorage[t]})),e.setPrivateData=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return e.sendIQ({privateStorage:{[t]:n},type:"set"})})),e.getVCard=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({to:t,type:"get",vcard:{format:"vcard-temp"}})).vcard})),e.publishVCard=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",vcard:t})})),e.enableNotifications=(t,n,i=[])=>e.sendIQ({push:{action:"enable",form:{fields:[{name:"FORM_TYPE",type:"hidden",value:"http://jabber.org/protocol/pubsub#publish-options"},...i],type:"submit"},jid:t,node:n},type:"set"}),e.disableNotifications=(t,n)=>e.sendIQ({push:{action:"disable",jid:t,node:n},type:"set"})}function yr(e){e.disco.addFeature(Nn(bn)),e.on("pubsub:published",t=>{if(t.pubsub.items.node!==bn)return;const n=t.pubsub.items.published[0].content;e.emit("avatar",{avatars:n.versions||[],jid:t.from,source:"pubsub"})}),e.on("presence",t=>{t.vcardAvatar&&"string"==typeof t.vcardAvatar&&e.emit("avatar",{avatars:[{id:t.vcardAvatar}],jid:t.from,source:"vcard"})}),e.publishAvatar=(t,n)=>e.publish("",vn,{data:n,itemType:vn},t),e.useAvatars=(t,n=[])=>e.publish("",bn,{itemType:bn,pointers:n,versions:t},"current"),e.getAvatar=(t,n)=>e.getItem(t,vn,n)}function _r(e){e.registerFeature("bind",300,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const i=yield e.sendIQ({bind:{resource:e.config.resource},type:"set"});e.features.negotiated.bind=!0,e.emit("session:prebind",i.bind.jid);const r=!t.legacySession||t.legacySession&&t.legacySession.optional;return!e.sessionStarted&&r&&e.emit("session:started",e.jid),n()}catch(e){return console.error(e),n("disconnect","JID binding failed")}}))),e.registerFeature("legacySession",1e3,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sessionStarted||t.legacySession&&t.legacySession.optional)return e.features.negotiated.session=!0,n();try{return yield e.sendIQ({legacySession:!0,type:"set"}),e.features.negotiated.session=!0,e.sessionStarted||(e.sessionStarted=!0,e.emit("session:started",e.jid)),n()}catch(e){return n("disconnect","Session requeset failed")}}))),e.on("session:started",()=>{e.sessionStarted=!0}),e.on("session:prebind",t=>{e.jid=t,e.emit("session:bound",e.jid)}),e.on("--reset-stream-features",()=>{e.sessionStarted=!1,e.features.negotiated.bind=!1,e.features.negotiated.session=!1})}function Sr(e){e.disco.addFeature(on),e.disco.addItem({name:"Ad-Hoc Commands",node:on}),e.getCommands=t=>e.getDiscoItems(t,on)}const wr=[];for(let e=0;e<256;++e)wr[e]=(e+256).toString(16).substr(1);function xr(e,t,n=(()=>{})){return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;const r=yield Promise.race([e,new Promise((e,r)=>{i=setTimeout(()=>r(n()),t)})]);return clearTimeout(i),r}))}function Tr(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return new Promise(t=>{setTimeout(()=>t(),e)})}))}function kr(t,n){const i="string"==typeof t?e.from(t,"utf8"):t,r="string"==typeof n?e.from(n,"utf8"):n;return i.compare(r)}function Ir(){const e=Yi(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=0;return[wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],"-",wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[t++]],wr[e[15]]].join("")}const jr=new Set(["date","expires","httpUploadRetry","idleSince","published","since","stamp","timestamp","updated","utc"]),Er=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)(?:Z|((\+|-)([\d|:]*)))?$/;var Nr=Object.freeze({__proto__:null,timeoutPromise:xr,sleep:Tr,octetCompare:kr,uuid:Ir,reviveData:function(t,n){return jr.has(t)&&n&&"string"==typeof n&&Er.test(n)?new Date(n):n&&"object"==typeof n&&"Buffer"===n.type&&Array.isArray(n.data)?e.from(n):n}});function Cr(e,t){e.features.negotiated.clientStateIndication&&e.send("csi",{type:t})}function Rr(e){e.disco.addFeature("urn:xmpp:ping"),e.on("iq:get:ping",t=>{e.sendIQResult(t)}),e.on("--reset-stream-features",()=>{e._stopKeepAliveInterval(),e.features.negotiated.streamManagement=!1,e.features.negotiated.clientStateIndication=!1}),e.markActive=()=>Cr(e,"active"),e.markInactive=()=>Cr(e,"inactive"),e.ping=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({ping:!0,to:t,type:"get"})})),e.enableKeepAlive=(t={})=>{e._keepAliveOptions=t;const n=t.interval||300,i=t.timeout||e.config.timeout||15;clearInterval(e._keepAliveInterval),e._keepAliveInterval=setInterval((function(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sessionStarted)try{yield xr(function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.sm.started)return new Promise(t=>{e.once("stream:management:ack",()=>t()),e.sm.request()});try{yield e.ping()}catch(e){if(e.error&&"timeout"!==e.error.condition)return;throw e}}))}(e),1e3*i)}catch(t){e.emit("stream:error",{condition:"connection-timeout",text:"Server did not respond in "+i+" seconds"}),e.transport&&(e.transport.hasStream=!1,e.transport.disconnect(!1))}}))}),1e3*n)},e._stopKeepAliveInterval=()=>{e._keepAliveInterval&&(clearInterval(e._keepAliveInterval),delete e._keepAliveInterval)},e.disableKeepAlive=()=>{delete e._keepAliveOptions,e._stopKeepAliveInterval()},e.on("stream:management:resumed",()=>{e._keepAliveOptions&&e.enableKeepAlive(e._keepAliveOptions)}),e.on("stream:start",()=>{e._keepAliveOptions&&e.enableKeepAlive(e._keepAliveOptions)});const t=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!e.config.useStreamManagement)return n();const t=i=>Object(r.__awaiter)(this,void 0,void 0,(function*(){switch(i.type){case"enabled":return yield e.sm.enabled(i),e.features.negotiated.streamManagement=!0,e.off("sm",t),n();case"resumed":return yield e.sm.resumed(i),e.features.negotiated.streamManagement=!0,e.features.negotiated.bind=!0,e.sessionStarted=!0,e.sessionStarting=!1,e.off("sm",t),e.emit("stream:management:resumed",i),n("break");case"failed":yield e.sm.failed(i),e.off("sm",t),e.emit("session:end"),n()}}));e.on("sm",t),e.sm.id?e.sm.id&&e.sm.allowResume?yield e.sm.resume():(e.off("sm",t),n()):e.features.negotiated.bind?yield e.sm.enable():(e.off("sm",t),n())}));e.registerFeature("streamManagement",200,t),e.registerFeature("streamManagement",500,t),e.registerFeature("clientStateIndication",400,(t,n)=>{e.features.negotiated.clientStateIndication=!0,n()})}function Or(t){return e.from(t.replace(/</g,"<"),"utf-8")}function Ar(e=[]){const t=[];for(const n of e)"FORM_TYPE"!==n.name&&(n.rawValues?t.push({name:Or(n.name),values:n.rawValues.map(e=>Or(e)).sort(kr)}):Array.isArray(n.value)?t.push({name:Or(n.name),values:n.value.map(e=>Or(e)).sort(kr)}):!0===n.value||!1===n.value?t.push({name:Or(n.name),values:[Or(n.value?"1":"0")]}):t.push({name:Or(n.name),values:[Or(n.value||"")]}));t.sort((e,t)=>kr(e.name,t.name));const n=[];for(const e of t){n.push(e.name);for(const t of e.values)n.push(t)}return n}function Pr(t,n){const i=[],r=e.from("<","utf8"),s=e=>{i.push(e),i.push(r)},o=function(e=[]){const t=[],n=new Set;for(const{category:i,type:r,lang:s,name:o}of e){const e=`${i}/${r}/${s||""}/${o||""}`;if(n.has(e))return null;n.add(e),t.push(Or(e))}return t.sort(kr),t}(t.identities),a=function(e=[]){const t=[],n=new Set;for(const i of e){if(n.has(i))return null;n.add(i),t.push(Or(i))}return t.sort(kr),t}(t.features),c=function(e=[]){const t=[],n=new Set;for(const i of e){let e;for(const t of i.fields||[])if("FORM_TYPE"===t.name&&"hidden"===t.type){if(t.rawValues&&1===t.rawValues.length){e=Or(t.rawValues[0]);break}if(t.value&&"string"==typeof t.value){e=Or(t.value);break}}if(e){if(n.has(e.toString()))return null;n.add(e.toString()),t.push({type:e,form:i})}}t.sort((e,t)=>kr(e.type,t.type));const i=[];for(const e of t){i.push(e.type);const t=Ar(e.form.fields);for(const e of t)i.push(e)}return i}(t.extensions);if(!o||!a||!c)return null;for(const e of o)s(e);for(const e of a)s(e);for(const e of c)s(e);return Wi(n).update(e.concat(i)).digest("base64")}class qr{constructor(){this.capsAlgorithms=["sha-1"],this.features=new Map,this.identities=new Map,this.extensions=new Map,this.items=new Map,this.caps=new Map,this.features.set("",new Set),this.identities.set("",[]),this.extensions.set("",[])}getNodeInfo(e){return{extensions:[...this.extensions.get(e)||[]],features:[...this.features.get(e)||[]],identities:[...this.identities.get(e)||[]]}}addFeature(e,t=""){this.features.has(t)||this.features.set(t,new Set),this.features.get(t).add(e)}addIdentity(e,t=""){this.identities.has(t)||this.identities.set(t,[]),this.identities.get(t).push(e)}addItem(e,t=""){this.items.has(t)||this.items.set(t,[]),this.items.get(t).push(e)}addExtension(e,t=""){this.extensions.has(t)||this.extensions.set(t,[]),this.extensions.get(t).push(e)}updateCaps(e,t=this.capsAlgorithms){const n={extensions:[...this.extensions.get("")],features:[...this.features.get("")],identities:[...this.identities.get("")],type:"info"};for(const i of t){const t=Pr(n,i);if(!t){this.caps.delete(i);continue}this.caps.set(i,{algorithm:i,node:e,value:t});const r=`${e}#${t}`;for(const e of n.features)this.addFeature(e,r);for(const e of n.identities)this.addIdentity(e,r);for(const e of n.extensions)this.addExtension(e,r);this.identities.set(r,n.identities),this.features.set(r,new Set(n.features)),this.extensions.set(r,n.extensions)}return[...this.caps.values()]}getCaps(){return[...this.caps.values()]}}function Lr(e){e.disco=new qr,e.disco.addFeature(Xt),e.disco.addFeature(Yt),e.disco.addIdentity({category:"client",type:"web"}),e.registerFeature("caps",100,(t,n)=>{const i=W(e.jid)||e.config.server;e.emit("disco:caps",{caps:t.legacyCapabilities||[],jid:i}),e.features.negotiated.caps=!0,n()}),e.getDiscoInfo=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield e.sendIQ({disco:{node:n,type:"info"},to:t,type:"get"});return Object.assign({extensions:[],features:[],identities:[]},i.disco)})),e.getDiscoItems=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield e.sendIQ({disco:{node:n,type:"items"},to:t,type:"get"});return Object.assign({items:[]},i.disco)})),e.updateCaps=()=>{const t=e.config.capsNode||"https://stanzajs.org";return e.disco.updateCaps(t)},e.getCurrentCaps=()=>{const t=e.disco.getCaps();if(!t)return;const n=`${t[0].node}#${t[0].value}`;return{info:e.disco.getNodeInfo(n),legacyCapabilities:t}},e.on("presence",t=>{t.legacyCapabilities&&e.emit("disco:caps",{caps:t.legacyCapabilities,jid:t.from})}),e.on("iq:get:disco",t=>{const{type:n,node:i}=t.disco;"info"===n&&e.sendIQResult(t,{disco:Object.assign(Object.assign({},e.disco.getNodeInfo(i||"")),{node:i,type:"info"})}),"items"===n&&e.sendIQResult(t,{disco:{items:e.disco.items.get(i||"")||[],type:"items"}})})}const Fr={Bosh:Tn,Client:Ut,Component:"jabber:component:accept",Server:"jabber:server"},Mr={AccountDisabled:"account-disabled",CredentialsExpired:"credentials-expired",EncryptionRequired:"encryption-required",IncorrectEncoding:"incorrect-encoding",InvalidAuthzid:"invalid-authzid",InvalidMechanism:"invalid-mechanism",MalformedRequest:"malformed-request",MechanismTooWeak:"mechanism-too-weak",NotAuthorized:"not-authorized",TemporaryAuthFailure:"temporary-auth-failure"},Dr={BadFormat:"bad-format",BadNamespacePrefix:"bad-namespace-prefix",Conflict:"conflict",ConnectionTimeout:"connection-timeout",HostGone:"host-gone",HostUnknown:"host-unknown",ImproperAddressing:"improper-addressing",InternalServerError:"internal-server-error",InvalidFrom:"invalid-from",InvalidId:"invalid-id",InvalidNamespace:"invalid-namespace",InvalidXML:"invalid-xml",NotAuthorized:"not-authorized",NotWellFormed:"not-well-formed",PolicyViolation:"policy-violation",RemoteConnectionFailed:"remote-connection-failed",Reset:"reset",ResourceConstraint:"resource-constraint",RestrictedXML:"restricted-xml",SeeOtherHost:"see-other-host",SystemShutdown:"system-shutdown",UndefinedCondition:"undefined-condition",UnsupportedEncoding:"unsupported-encoding",UnsupportedStanzaType:"unsupported-stanza-type",UnsupportedVersion:"unsupported-version"},Br={BadRequest:"bad-request",Conflict:"conflict",FeatureNotImplemented:"feature-not-implemented",Forbidden:"forbidden",Gone:"gone",InternalServerError:"internal-server-error",ItemNotFound:"item-not-found",JIDMalformed:"jid-malformed",NotAcceptable:"not-acceptable",NotAllowed:"not-allowed",NotAuthorized:"not-authorized",PolicyViolation:"policy-violation",RecipientUnavailable:"recipient-unavailable",Redirect:"redirect",RegistrationRequired:"registration-required",RemoteServerNotFound:"remote-server-not-found",RemoteServerTimeout:"remote-server-timeout",ResourceConstraint:"resource-constraint",ServiceUnavailable:"service-unavailable",SubscriptionRequired:"subscription-required",UndefinedCondition:"undefined-condition",UnexpectedRequest:"unexpected-request"},Ur={Available:void 0,Error:"error",Probe:"probe",Subscribe:"subscribe",Subscribed:"subscribed",Unavailable:"unavailable",Unsubscribe:"unsubscribe",Unsubscribed:"unsubscribed"},zr={Boolean:"boolean",Fixed:"fixed",Hidden:"hidden",JID:"jid-single",JIDMultiple:"jid-multi",List:"list-single",ListMultiple:"list-multi",Password:"text-private",Text:"text-single",TextMultiple:"text-multi",TextPrivate:"text-private"},Jr={AffiliationChanged:"101",AffiliationLost:"321",Banned:"301",Error:"333",Kicked:"307",LoggingDisabled:"171",LoggingEnabled:"170",MembershipLost:"322",NickChanged:"303",NickChangedByService:"210",NonAnonymous:"172",NonAnonymousRoom:"100",NonPrivacyConfigurationChange:"104",RoomCreated:"201",SelfPresence:"110",SemiAnonymous:"173",Shutdown:"332",UnavailableMembersListed:"102",UnavailableMembersNotListed:"103"},Gr={ClosedNode:"closed-node",ConfigurationRequired:"configuration-required",InvalidJID:"invalid-jid",InvalidOptions:"invalid-options",InvalidPayload:"invalid-payload",InvalidSubscriptionId:"invalid-subid",ItemForbidden:"item-forbidden",ItemRequired:"item-required",JIDRequired:"jid-required",MaxItemsExceeded:"max-items-exceeded",MaxNodesExceeded:"max-nodes-exceeded",NodeIdRequired:"nodeid-required",NotInRosterGroup:"not-in-roster-group",NotSubscribed:"not-subscribed",PayloadRequired:"payload-required",PayloadTooBig:"payload-too-big",PendingSubscription:"pending-subscription",PresenceSubscriptionRequired:"presence-subscription-required",SubscriptionIdRequired:"subid-required",TooManySubscriptions:"too-many-subscriptions",Unsupported:"unsupported",UnsupportedAccessModel:"unsupported-access-model"},Vr={Active:"active",Composing:"composing",Gone:"gone",Inactive:"inactive",Paused:"paused"},$r={Initiator:"initiator",Responder:"responder"},Hr={Inactive:"inactive",Receive:"recvonly",Send:"sendonly",SendReceive:"sendrecv"},Wr={Both:"both",Initiator:"initiator",None:"none",Responder:"responder"},Qr={ContentAccept:"content-accept",ContentAdd:"content-add",ContentModify:"content-modify",ContentReject:"content-reject",ContentRemove:"content-remove",DescriptionInfo:"description-info",SecurityInfo:"security-info",SessionAccept:"session-accept",SessionInfo:"session-info",SessionInitiate:"session-initiate",SessionTerminate:"session-terminate",TransportAccept:"transport-accept",TransportInfo:"transport-info",TransportReject:"transport-reject",TransportReplace:"transport-replace"},Kr={OutOfOrder:"out-of-order",TieBreak:"tie-break",UnknownContent:"unknown-content",UnknownSession:"unknown-session",UnsupportedInfo:"unsupported-info"},Xr={AlternativeSession:"alternative-session",Busy:"busy",Cancel:"cancel",ConnectivityError:"connectivity-error",Decline:"decline",Expired:"expired",FailedApplication:"failed-application",FailedTransport:"failed-transport",GeneralError:"general-error",Gone:"gone",IncompatibleParameters:"incompatible-parameters",MediaError:"media-error",SecurityError:"security-error",Success:"success",Timeout:"timeout",UnsupportedApplications:"unsupported-applications",UnsupportedTransports:"unsupported-transports"},Yr=["afraid","amazed","amorous","angry","annoyed","anxious","aroused","ashamed","bored","brave","calm","cautious","cold","confident","confused","contemplative","contented","cranky","crazy","creative","curious","dejected","depressed","disappointed","disgusted","dismayed","distracted","embarrassed","envious","excited","flirtatious","frustrated","grateful","grieving","grumpy","guilty","happy","hopeful","hot","humbled","humiliated","hungry","hurt","impressed","in_awe","in_love","indignant","interested","intoxicated","invincible","jealous","lonely","lost","lucky","mean","moody","nervous","neutral","offended","outraged","playful","proud","relaxed","relieved","remorseful","restless","sad","sarcastic","satisfied","serious","shocked","shy","sick","sleepy","spontaneous","stressed","strong","surprised","thankful","thirsty","tired","undefined","weak","worried"],Zr=["doing_chores","drinking","eating","exercising","grooming","having_appointment","inactive","relaxing","talking","traveling","undefined","working"],es=["at_the_spa","brushing_teeth","buying_groceries","cleaning","coding","commuting","cooking","cycling","cycling","dancing","day_off","doing_maintenance","doing_the_dishes","doing_the_laundry","driving","fishing","gaming","gardening","getting_a_haircut","going_out","hanging_out","having_a_beer","having_a_snack","having_breakfast","having_coffee","having_dinner","having_lunch","having_tea","hiding","hiking","in_a_car","in_a_meeting","in_real_life","jogging","on_a_bus","on_a_plane","on_a_train","on_a_trip","on_the_phone","on_vacation","on_video_phone","other","partying","playing_sports","praying","reading","rehearsing","running","running_an_errand","scheduled_holiday","shaving","shopping","skiing","sleeping","smoking","socializing","studying","sunbathing","swimming","taking_a_bath","taking_a_shower","thinking","walking","walking_the_dog","watching_a_movie","watching_tv","working_out","writing"],ts=(e,t)=>`{${e}}${t}`,ns=ts(On,"mute"),is=ts(On,"unmute"),rs=ts(On,"hold"),ss=ts(On,"unhold"),os=ts(On,"active"),as=ts(On,"ringing"),cs=ts(Dn,"checksum"),ls=ts(Dn,"received");function us(e,t=Wr.Both){const n=e===$r.Initiator;switch(t){case Wr.Initiator:return n?Hr.Send:Hr.Receive;case Wr.Responder:return n?Hr.Receive:Hr.Send;case Wr.Both:return Hr.SendReceive}return Hr.Inactive}function ps(e,t=Hr.SendReceive){const n=e===$r.Initiator;switch(t){case Hr.Send:return n?Wr.Initiator:Wr.Responder;case Hr.Receive:return n?Wr.Responder:Wr.Initiator;case Hr.SendReceive:return Wr.Both}return Wr.None}var ds=Object.freeze({__proto__:null,VERSION:"12.17.2",StreamType:Fr,SASLFailureCondition:Mr,StreamErrorCondition:Dr,StanzaErrorCondition:Br,MessageType:{Chat:"chat",Error:"error",GroupChat:"groupchat",Headline:"headline",Normal:"normal"},PresenceType:Ur,IQType:{Error:"error",Get:"get",Result:"result",Set:"set"},PresenceShow:{Away:"away",Chat:"chat",DoNotDisturb:"dnd",ExtendedAway:"xa"},RosterSubscription:{Both:"both",From:"from",None:"none",ReceivePresenceOnly:"to",Remove:"remove",SendAndReceivePresence:"both",SendPresenceOnly:"from",To:"to"},DataFormType:{Cancel:"cancel",Form:"form",Result:"result",Submit:"submit"},DataFormFieldType:zr,MUCAffiliation:{Admin:"admin",Banned:"outcast",Member:"member",None:"none",Outcast:"outcast",Owner:"owner"},MUCRole:{Moderator:"moderator",None:"none",Participant:"participant",Visitor:"visitor"},MUCStatusCode:Jr,PubsubErrorCondition:Gr,ChatState:Vr,JingleSessionRole:$r,JingleApplicationDirection:Hr,JingleContentSenders:Wr,JingleAction:Qr,JingleErrorCondition:Kr,JingleReasonCondition:Xr,USER_MOODS:Yr,USER_ACTIVITY_GENERAL:Zr,USER_ACTIVITY_SPECIFIC:es,JINGLE_INFO:ts,JINGLE_INFO_MUTE:ns,JINGLE_INFO_UNMUTE:is,JINGLE_INFO_HOLD:rs,JINGLE_INFO_UNHOLD:ss,JINGLE_INFO_ACTIVE:os,JINGLE_INFO_RINGING:as,JINGLE_INFO_CHECKSUM_5:cs,JINGLE_INFO_RECEIVED_5:ls,sendersToDirection:us,directionToSenders:ps});function hs(e){e.disco.addFeature("jid\\20escaping"),e.disco.addFeature(Fn),e.disco.addFeature("urn:xmpp:eme:0"),e.disco.addFeature($n),e.disco.addFeature(Hn),e.disco.addFeature("urn:xmpp:hashes:1"),e.disco.addFeature("urn:xmpp:idle:1"),e.disco.addFeature(Zn),e.disco.addFeature(hn),e.disco.addFeature("urn:xmpp:psa"),e.disco.addFeature("urn:xmpp:reference:0"),e.disco.addFeature(kn),e.disco.addFeature(Qt),e.disco.addFeature("urn:xmpp:media-element"),e.disco.addFeature(xn),e.disco.addFeature(jn);const t=["sha-1","sha-256","sha-512","md5"];for(const n of t)e.disco.addFeature(Wn(n));e.disco.addFeature("urn:xmpp:time"),e.disco.addFeature("jabber:iq:version"),e.on("iq:get:softwareVersion",t=>e.sendIQResult(t,{softwareVersion:e.config.softwareVersion||{name:"stanzajs.org",version:"12.17.2"}})),e.on("iq:get:time",t=>{const n=new Date;e.sendIQResult(t,{time:{tzo:n.getTimezoneOffset(),utc:n}})}),e.getSoftwareVersion=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({softwareVersion:{},to:t,type:"get"})).softwareVersion})),e.getTime=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({time:{},to:t,type:"get"})).time})),e.getLastActivity=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({lastActivity:{},to:t,type:"get"})).lastActivity}))}function fs(e){e.features={handlers:Object.create(null),negotiated:Object.create(null),order:[]},e.registerFeature=function(t,n,i){this.features.order.push({name:t,priority:n}),this.features.order.sort((e,t)=>e.priority-t.priority),this.features.handlers[t]=i.bind(e)},e.on("features",t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=e.features.negotiated,i=e.features.handlers,r=[];for(const{name:s}of e.features.order)t[s]&&i[s]&&!n[s]&&r.push(s);function s(e){return new Promise(n=>{i[e](t,(e,t)=>{n(e?{command:e,message:t}:null)})})}for(const t of r){if(n[t])continue;let i="",r="";try{const e=yield s(t);e&&(i=e.command,r=e.message||"")}catch(e){i="disconnect",r=e.message,console.error(e)}if(i)return"restart"===i&&e.transport&&e.transport.restart(),void("disconnect"===i&&(e.emit("stream:error",{condition:"policy-violation",text:"Failed to negotiate stream features: "+r}),e.disconnect()))}})))}function ms(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){"string"==typeof t&&(t={host:t});const n=Object.assign({json:!0,ssl:!0,xrd:!0},t),i=n.ssl?"https://":"http://";return function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const t=yield Promise.all(e.map(e=>e.then(e=>Promise.reject(e),e=>Promise.resolve(e))));return Promise.reject(t)}catch(e){return Promise.resolve(e)}}))}([Zi(`${i}${n.host}/.well-known/host-meta.json`).then(e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!e.ok)throw new Error("could-not-fetch-json");return e.json()}))),Zi(`${i}${n.host}/.well-known/host-meta`).then(t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(!t.ok)throw new Error("could-not-fetch-xml");const n=Ie(yield t.text());if(n)return e.import(n)})))])}))}function gs(e,t){e.discoverBindings=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=yield ms(t,e),i={bosh:[],websocket:[]},r=n.links||[];for(const e of r)e.href&&"urn:xmpp:alt-connections:websocket"===e.rel&&i.websocket.push(e.href),e.href&&"urn:xmpp:alt-connections:xbosh"===e.rel&&i.bosh.push(e.href);return i}catch(e){return{}}}))}function vs(e){const t=u.getMediaSections(e),n=u.getDescription(e),i={groups:[],media:[]};u.matchPrefix(n,"a=ice-lite").length>0&&(i.iceLite=!0);for(const e of u.matchPrefix(n,"a=group:")){const t=e.split(" "),n=t.shift().substr(8);i.groups.push({mids:t,semantics:n})}for(const e of t){const t=u.getKind(e),r=u.isRejected(e),s=u.parseMLine(e),o={direction:u.getDirection(e,n),kind:t,mid:u.getMid(e),protocol:s.protocol};if(r||(o.iceParameters=u.getIceParameters(e,n),o.dtlsParameters=u.getDtlsParameters(e,n),o.setup=u.matchPrefix(e,"a=setup:")[0].substr(8),i.iceLite&&(o.iceParameters.iceLite=!0)),"audio"===t||"video"===t){o.rtpParameters=u.parseRtpParameters(e),o.rtpEncodingParameters=u.parseRtpEncodingParameters(e),o.rtcpParameters=u.parseRtcpParameters(e);const t=u.parseMsid(e);o.streams=t?[t]:[]}else"application"===t&&(o.sctp=u.parseSctpDescription(e));o.candidates=u.matchPrefix(e,"a=candidate:").map(u.parseCandidate),i.media.push(o)}return i}function bs(e){const t=[];t.push(u.writeSessionBoilerplate(e.sessionId,e.sessionVersion),"a=msid-semantic:WMS *\r\n"),(e.iceLite||e.media.filter(e=>e.iceParameters&&e.iceParameters.iceLite).length>0)&&t.push("a=ice-lite\r\n");for(const n of e.groups||[])t.push(`a=group:${n.semantics} ${n.mids.join(" ")}\r\n`);for(const n of e.media||[]){const e=!(n.iceParameters&&n.dtlsParameters);if("application"===n.kind&&n.sctp)t.push(u.writeSctpDescription(n,n.sctp));else if(n.rtpParameters){let i=u.writeRtpDescription(n.kind,n.rtpParameters);e&&(i=i.replace(`m=${n.kind} 9 `,`m=${n.kind} 0 `)),t.push(i),t.push(`a=${n.direction||"sendrecv"}\r\n`);for(const e of n.streams||[])t.push(`a=msid:${e.stream} ${e.track}\r\n`);if(n.rtcpParameters&&(t.push(u.writeRtcpParameters(n.rtcpParameters)),n.rtcpParameters.cname&&n.rtpEncodingParameters&&n.rtpEncodingParameters[0].rtx)){const e=n.rtpEncodingParameters[0];t.push(`a=ssrc-group:FID ${e.ssrc} ${e.rtx.ssrc}\r\n`),t.push(`a=ssrc:${e.rtx.ssrc} cname:${n.rtcpParameters.cname}\r\n`)}}if(void 0!==n.mid&&t.push(`a=mid:${n.mid}\r\n`),n.iceParameters&&t.push(u.writeIceParameters({usernameFragment:n.iceParameters.usernameFragment,password:n.iceParameters.password})),n.dtlsParameters&&n.setup&&t.push(u.writeDtlsParameters(n.dtlsParameters,n.setup)),n.candidates&&n.candidates.length)for(const e of n.candidates)t.push(`a=${u.writeCandidate(e)}\r\n`)}return t.join("")}function ys(e,t){const n=e.rtpParameters,i=e.rtcpParameters||{},r=e.rtpEncodingParameters||[];let s=!1;r&&r.length&&(s=!!r[0].ssrc);const o={applicationType:Rn,codecs:[],headerExtensions:[],media:e.kind,rtcpMux:i.mux,rtcpReducedSize:i.reducedSize,sourceGroups:[],sources:[],ssrc:s?r[0].ssrc.toString():void 0,streams:[]};for(const e of n.headerExtensions||[]){const n={id:e.id,uri:e.uri};e.direction&&"sendrecv"!==e.direction&&(n.senders=ps(t,e.direction)),o.headerExtensions.push(n)}i.ssrc&&i.cname&&(o.sources=[{parameters:{cname:i.cname},ssrc:i.ssrc.toString()}]),s&&r[0]&&r[0].rtx&&(o.sourceGroups=[{semantics:"FID",sources:[r[0].ssrc.toString(),r[0].rtx.ssrc.toString()]}]);for(const t of e.streams||[])o.streams.push({id:t.stream,track:t.track});for(const e of n.codecs||[]){const t={channels:e.channels,clockRate:e.clockRate,id:e.payloadType.toString(),name:e.name,parameters:e.parameters,rtcpFeedback:e.rtcpFeedback};e.maxptime&&(t.maxptime=e.maxptime),e.parameters&&e.parameters.ptime&&(t.ptime=parseInt(e.parameters.ptime,10)),o.codecs.push(t)}return o}function _s(e){let t;return t="rtp"===e.component?1:"rtcp"===e.component?2:e.component,{component:t,foundation:e.foundation,generation:void 0,id:void 0,ip:e.ip,network:void 0,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function Ss(e){return{address:e.ip,component:1===e.component?"rtp":2===e.component?"rtcp":e.component,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,tcpType:e.tcpType,type:e.type}}function ws(e,t){const n=e.iceParameters,i=e.dtlsParameters,r={candidates:[],transportType:t};n&&(r.usernameFragment=n.usernameFragment,r.password=n.password,n.iceLite&&(r.iceLite=!0)),i&&(r.fingerprints=i.fingerprints.map(t=>({algorithm:t.algorithm,setup:e.setup,value:t.value}))),e.sctp&&(r.sctp=e.sctp);for(const t of e.candidates||[])r.candidates.push(_s(t));return r}function xs(e,t,n){return{contents:e.media.map(e=>({application:"audio"===e.kind||"video"===e.kind?ys(e,t):{applicationType:"datachannel",protocol:e.protocol},creator:$r.Initiator,name:e.mid,senders:ps(t,e.direction),transport:ws(e,n)})),groups:e.groups?e.groups.map(e=>({contents:e.mids,semantics:e.semantics})):[]}}function Ts(e,t){const n=e.application||{},i=e.transport,r=n&&n.applicationType===Rn,s={direction:us(t,e.senders),kind:n.media||"application",mid:e.name,protocol:r?"UDP/TLS/RTP/SAVPF":"UDP/DTLS/SCTP"};if(r){if(s.rtcpParameters={compound:!n.rtcpReducedSize,mux:n.rtcpMux,reducedSize:n.rtcpReducedSize},n.sources&&n.sources.length){const e=n.sources[0];s.rtcpParameters.ssrc=parseInt(e.ssrc,10),e.parameters&&(s.rtcpParameters.cname=e.parameters.cname)}if(s.rtpParameters={codecs:[],fecMechanisms:[],headerExtensions:[],rtcp:[]},n.streams){s.streams=[];for(const e of n.streams)s.streams.push({stream:e.id,track:e.track})}if(n.ssrc&&(s.rtpEncodingParameters=[{ssrc:parseInt(n.ssrc,10)}],n.sourceGroups&&n.sourceGroups.length)){const e=n.sourceGroups[0];s.rtpEncodingParameters[0].rtx={ssrc:parseInt(e.sources[1],10)}}let e=!1,i=!1;for(const t of n.codecs||[]){const n=t.parameters||{},r=[];for(const e of t.rtcpFeedback||[])r.push({parameter:e.parameter,type:e.type});if("red"===t.name||"ulpfec"===t.name){e=e||"red"===t.name,i=i||"ulpfec"===t.name;const n=t.name.toUpperCase();s.rtpParameters.fecMechanisms.includes(n)||s.rtpParameters.fecMechanisms.push(n)}s.rtpParameters.codecs.push({channels:t.channels,clockRate:t.clockRate,name:t.name,numChannels:t.channels,parameters:n,payloadType:parseInt(t.id,10),rtcpFeedback:r})}for(const e of n.headerExtensions||[])s.rtpParameters.headerExtensions.push({direction:us(t,e.senders||"both"),id:e.id,uri:e.uri})}if(i){if(i.usernameFragment&&i.password&&(s.iceParameters={password:i.password,usernameFragment:i.usernameFragment},i.iceLite&&(s.iceParameters.iceLite=!0)),i.fingerprints&&i.fingerprints.length){s.dtlsParameters={fingerprints:[],role:"auto"};for(const e of i.fingerprints)s.dtlsParameters.fingerprints.push({algorithm:e.algorithm,value:e.value});i.sctp&&(s.sctp=i.sctp),s.setup=i.fingerprints[0].setup}s.candidates=(i.candidates||[]).map(Ss)}return s}function ks(e,t){const n={groups:[],media:[]};for(const t of e.groups||[])n.groups.push({mids:t.contents,semantics:t.semantics});for(const i of e.contents||[])n.media.push(Ts(i,t));return n}const Is={condition:Br.BadRequest},js={condition:Br.FeatureNotImplemented,jingleError:Kr.UnsupportedInfo,type:"modify"};class Es{constructor(e){this.parent=e.parent,this.sid=e.sid||Ir(),this.peerID=e.peerID,this.role=e.initiator?$r.Initiator:$r.Responder,this._sessionState="starting",this._connectionState="starting",this.pendingApplicationTypes=e.applicationTypes||[],this.pendingAction=void 0,this.processingQueue=Object(s.priorityQueue)((e,t)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if("ended"===this.state)return"local"===e.type&&e.reject&&e.reject(new Error("Session ended")),void(t&&t());if("local"===e.type){this._log("debug","Processing local action:",e.name);try{const t=yield e.handler();e.resolve(t)}catch(t){e.reject(t)}return void(t&&t())}const{action:n,changes:i,cb:r}=e;return this._log("debug","Processing remote action:",n),new Promise(e=>{const s=(n,i)=>{r(n,i),t&&t(),e()};switch(n){case Qr.ContentAccept:return this.onContentAccept(i,s);case Qr.ContentAdd:return this.onContentAdd(i,s);case Qr.ContentModify:return this.onContentModify(i,s);case Qr.ContentReject:return this.onContentReject(i,s);case Qr.ContentRemove:return this.onContentRemove(i,s);case Qr.DescriptionInfo:return this.onDescriptionInfo(i,s);case Qr.SecurityInfo:return this.onSecurityInfo(i,s);case Qr.SessionAccept:return this.onSessionAccept(i,s);case Qr.SessionInfo:return this.onSessionInfo(i,s);case Qr.SessionInitiate:return this.onSessionInitiate(i,s);case Qr.SessionTerminate:return this.onSessionTerminate(i,s);case Qr.TransportAccept:return this.onTransportAccept(i,s);case Qr.TransportInfo:return this.onTransportInfo(i,s);case Qr.TransportReject:return this.onTransportReject(i,s);case Qr.TransportReplace:return this.onTransportReplace(i,s);default:this._log("error","Invalid or unsupported action: "+n),s({condition:Br.BadRequest})}})})),1)}get isInitiator(){return this.role===$r.Initiator}get peerRole(){return this.isInitiator?$r.Responder:$r.Initiator}get state(){return this._sessionState}set state(e){e!==this._sessionState&&(this._log("info","Changing session state to: "+e),this._sessionState=e,this.parent&&this.parent.emit("sessionState",this,e))}get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._log("info","Changing connection state to: "+e),this._connectionState=e,this.parent&&this.parent.emit("connectionState",this,e))}send(e,t){(t=t||{}).sid=this.sid,t.action=e;new Set([Qr.ContentAccept,Qr.ContentAdd,Qr.ContentModify,Qr.ContentReject,Qr.ContentRemove,Qr.SessionAccept,Qr.SessionInitiate,Qr.TransportAccept,Qr.TransportReject,Qr.TransportReplace]).has(e)?this.pendingAction=e:this.pendingAction=void 0,this.parent.signal(this,{id:Ir(),jingle:t,to:this.peerID,type:"set"})}processLocal(e,t){return new Promise((n,i)=>{this.processingQueue.push({handler:t,name:e,reject:i,resolve:n,type:"local"},1)})}process(e,t,n){this.processingQueue.push({action:e,cb:n,changes:t,type:"remote"},2)}start(e,t){this._log("error","Can not start base sessions"),this.end("unsupported-applications",!0)}accept(e,t){this._log("error","Can not accept base sessions"),this.end("unsupported-applications")}cancel(){this.end("cancel")}decline(){this.end("decline")}end(e="success",t=!1){this.state="ended",this.processingQueue.kill(),"string"==typeof e&&(e={condition:e}),t||this.send("session-terminate",{reason:e}),this.parent.emit("terminated",this,e),this.parent.forgetSession(this)}_log(e,t,...n){this.parent&&(t=this.sid+": "+t,this.parent.emit("log",e,t,...n),this.parent.emit("log:"+e,t,...n))}onSessionInitiate(e,t){t()}onSessionAccept(e,t){t()}onSessionTerminate(e,t){this.end(e.reason,!0),t()}onSessionInfo(e,t){e.info?t(js):t()}onSecurityInfo(e,t){t(js)}onDescriptionInfo(e,t){t(js)}onTransportInfo(e,t){t(js)}onContentAdd(e,t){t(),this.send(Qr.ContentReject,{reason:{condition:Xr.FailedApplication,text:"content-add is not supported"}})}onContentAccept(e,t){t(Is)}onContentReject(e,t){t(Is)}onContentModify(e,t){t(Is)}onContentRemove(e,t){t(Is)}onTransportReplace(e,t){t(),this.send(Qr.TransportReject,{reason:{condition:Xr.FailedTransport,text:"transport-replace is not supported"}})}onTransportAccept(e,t){t(Is)}onTransportReject(e,t){t(Is)}}class Ns extends Es{constructor(e){super(e),this.bitrateLimit=0,this.candidateBuffer=[],this.transportType=Pn,this.restartingIce=!1,this.usingRelay=!1,this.maxRelayBandwidth=e.maxRelayBandwidth,this.pc=this.parent.createPeerConnection(this,Object.assign(Object.assign({},e.config),{iceServers:e.iceServers})),this.pc.oniceconnectionstatechange=()=>{this.onIceStateChange()},this.pc.onicecandidate=e=>{e.candidate?this.onIceCandidate(e):this.onIceEndOfCandidates()},this.restrictRelayBandwidth()}end(e="success",t=!1){this.pc.close(),super.end(e,t)}restartIce(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isInitiator){void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this.restartingIce=!0;try{yield this.processLocal("restart-ice",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=yield this.pc.createOffer({iceRestart:!0}),t=vs(e.sdp);this.send(Qr.TransportInfo,{contents:t.media.map(e=>({creator:$r.Initiator,name:e.mid,transport:ws(e,this.transportType)})),sid:this.sid}),yield this.pc.setLocalDescription(e)})))}catch(e){this._log("error","Could not create WebRTC offer",e),this.end(Xr.FailedTransport,!0)}}}))}setMaximumBitrate(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.maximumBitrate&&(e=Math.min(e,this.maximumBitrate)),this.currentBitrate=e;const t=this.pc.getSenders().find(e=>!!e.track&&"video"===e.track.kind);if(t&&t.getParameters)try{yield this.processLocal("set-bitrate",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=t.getParameters();n.encodings&&n.encodings.length||(n.encodings=[{}]),0===e?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=e,yield t.setParameters(n)})))}catch(e){this._log("error","Set maximumBitrate failed",e)}}))}onTransportInfo(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(e.contents&&e.contents[0]&&e.contents[0].transport.gatheringComplete){const n={sdpMid:e.contents[0].name,candidate:""};try{"stable"===this.pc.signalingState?yield this.pc.addIceCandidate(n):this.candidateBuffer.push(n)}catch(e){this._log("debug","Could not add null end-of-candidate")}finally{t()}return}if(this.pc.remoteDescription){const n=this.pc.remoteDescription,i=vs(n.sdp),r=i.media.find(t=>t.mid===e.contents[0].name).iceParameters.usernameFragment,s=e.contents[0].transport.usernameFragment;if(s&&r!==s){for(const[t,n]of e.contents.entries()){const e=n.transport;i.media[t].iceParameters={password:e.password,usernameFragment:e.usernameFragment},i.media[t].candidates=[]}try{if(yield this.pc.setRemoteDescription({type:n.type,sdp:bs(i)}),yield this.processBufferedCandidates(),"offer"===n.type){const e=yield this.pc.createAnswer();yield this.pc.setLocalDescription(e);const t=vs(e.sdp);this.send(Qr.TransportInfo,{contents:t.media.map(e=>({creator:$r.Initiator,name:e.mid,transport:ws(e,this.transportType)})),sid:this.sid})}else this.restartingIce=!1}catch(e){return this._log("error","Could not do remote ICE restart",e),t(e),void this.end(Xr.FailedTransport)}}}const n=(e.contents||[]).map(e=>{const t=e.name,n=(e.transport.candidates||[]).map(e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=u.writeCandidate(Ss(e));if(this.pc.remoteDescription&&"stable"===this.pc.signalingState)try{yield this.pc.addIceCandidate({sdpMid:t,candidate:n})}catch(e){this._log("error","Could not add ICE candidate",e)}else this.candidateBuffer.push({sdpMid:t,candidate:n})})));return Promise.all(n)});try{yield Promise.all(n),t()}catch(e){this._log("error","Could not process transport-info: "+e),t(e)}}))}onSessionAccept(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.state="active";const n=bs(ks(e,this.peerRole));try{yield this.pc.setRemoteDescription({type:"answer",sdp:n}),yield this.processBufferedCandidates(),this.parent.emit("accepted",this,void 0),t()}catch(e){this._log("error","Could not process WebRTC answer: "+e),t({condition:"general-error"})}}))}onSessionTerminate(e,t){this._log("info","Terminating session"),this.pc.close(),super.end(e.reason,!0),t()}onIceCandidate(e){if(!e.candidate||!e.candidate.candidate)return;const t=u.parseCandidate(e.candidate.candidate),n={contents:[{creator:$r.Initiator,name:e.candidate.sdpMid,transport:{candidates:[_s(t)],transportType:this.transportType,usernameFragment:t.usernameFragment}}]};this._log("info","Discovered new ICE candidate",n),this.send(Qr.TransportInfo,n)}onIceEndOfCandidates(){this._log("info","ICE end of candidates");const e=vs(this.pc.localDescription.sdp).media[0];this.send(Qr.TransportInfo,{contents:[{creator:$r.Initiator,name:e.mid,transport:{gatheringComplete:!0,transportType:this.transportType,usernameFragment:e.iceParameters.usernameFragment}}]})}onIceStateChange(){switch(this.pc.iceConnectionState){case"checking":this.connectionState="connecting";break;case"completed":case"connected":this.connectionState="connected";break;case"disconnected":if("stable"===this.pc.signalingState?this.connectionState="interrupted":this.connectionState="disconnected",this.restartingIce)return void this.end(Xr.FailedTransport);this.maybeRestartIce();break;case"failed":if("failed"===this.connectionState||this.restartingIce)return void this.end(Xr.FailedTransport);this.connectionState="failed",this.restartIce();break;case"closed":this.connectionState="disconnected",this.restartingIce?this.end(Xr.FailedTransport):this.end()}}processBufferedCandidates(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){for(const e of this.candidateBuffer)try{yield this.pc.addIceCandidate(e)}catch(e){this._log("error","Could not add ICE candidate",e)}this.candidateBuffer=[]}))}restrictRelayBandwidth(){this.pc.addEventListener("iceconnectionstatechange",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if("completed"!==this.pc.iceConnectionState&&"connected"!==this.pc.iceConnectionState)return;const e=yield this.pc.getStats();let t;if(e.forEach(n=>{"transport"===n.type&&(t=e.get(n.selectedCandidatePairId))}),t||e.forEach(e=>{"candidate-pair"===e.type&&e.selected&&(t=e)}),!t)return;let n=!1,i="",r="";if(t.remoteCandidateId){const n=e.get(t.remoteCandidateId);n&&(r=n.candidateType)}if(t.localCandidateId){const n=e.get(t.localCandidateId);n&&(i=n.candidateType)}"relay"!==i&&"relay"!==r||(n=!0),this.usingRelay=n,this.parent.emit("iceConnectionType",this,{localCandidateType:i,relayed:n,remoteCandidateType:r}),n&&void 0!==this.maxRelayBandwidth&&(this.maximumBitrate=this.maxRelayBandwidth,this.currentBitrate?this.setMaximumBitrate(Math.min(this.currentBitrate,this.maximumBitrate)):this.setMaximumBitrate(this.maximumBitrate))})))}maybeRestartIce(){this.isInitiator&&(void 0!==this._maybeRestartingIce&&clearTimeout(this._maybeRestartingIce),this._maybeRestartingIce=setTimeout(()=>{this._maybeRestartingIce=void 0,"disconnected"===this.pc.iceConnectionState&&this.restartIce()},2e3))}}class Cs extends o.EventEmitter{constructor(e={}){super(),this.config=Object.assign({chunkSize:16384,hash:"sha-1"},e),this.file=void 0,this.channel=void 0,this.hash=Wi(this.config.hash)}send(e,t){if(this.file&&this.channel)return;this.file=e,this.channel=t,this.channel.binaryType="arraybuffer";const n=new FileReader;let i=0,r=!1;const s=()=>{if(r||i>=e.size)return;r=!0;const t=e.slice(i,i+this.config.chunkSize);n.readAsArrayBuffer(t)};t.bufferedAmountLowThreshold=8*this.config.chunkSize,t.onbufferedamountlow=()=>{s()},n.addEventListener("load",t=>{const n=t.target.result;r=!1,i+=n.byteLength,this.channel.send(n),this.hash.update(new Uint8Array(n)),this.emit("progress",i,e.size,n),i<e.size?this.channel.bufferedAmount<=this.channel.bufferedAmountLowThreshold&&s():(this.emit("progress",e.size,e.size,null),this.emit("sentFile",{algorithm:this.config.hash,name:e.name,size:e.size,value:this.hash.digest()}))}),s()}}class Rs extends o.EventEmitter{constructor(e={}){super(),this.config=Object.assign({hash:"sha-1"},e),this.receiveBuffer=[],this.received=0,this.channel=void 0,this.hash=Wi(this.config.hash)}receive(e,t){this.metadata=e,this.channel=t,this.channel.binaryType="arraybuffer",this.channel.onmessage=e=>{const t=e.data.byteLength;this.received+=t,this.receiveBuffer.push(e.data),e.data&&this.hash.update(new Uint8Array(e.data)),this.emit("progress",this.received,this.metadata.size,e.data),this.received===this.metadata.size?(this.metadata.actualhash=this.hash.digest("hex"),this.emit("receivedFile",new Blob(this.receiveBuffer),this.metadata),this.receiveBuffer=[]):this.received>this.metadata.size&&(console.error("received more than expected, discarding..."),this.receiveBuffer=[])}}}class Os extends Ns{constructor(e){super(e),this.sender=void 0,this.receiver=void 0,this.file=void 0}start(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(t=t||(()=>{}),!e||"function"==typeof e)throw new Error("File object required");this.state="pending",this.role="initiator",this.file=e,this.sender=new Cs,this.sender.on("progress",(e,t)=>{this._log("info","Send progress "+e+"/"+t)}),this.sender.on("sentFile",e=>{this._log("info","Sent file",e.name),this.send(Qr.SessionInfo,{info:{creator:$r.Initiator,file:{hashes:[{algorithm:e.algorithm,value:e.value}]},infoType:cs,name:this.contentName}}),this.parent.emit("sentFile",this,e)}),this.channel=this.pc.createDataChannel("filetransfer",{ordered:!0}),this.channel.onopen=()=>{this.sender.send(this.file,this.channel)};try{yield this.processLocal(Qr.SessionInitiate,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1}),n=xs(vs(t.sdp),this.role,this.transportType);this.contentName=n.contents[0].name,n.sid=this.sid,n.action=Qr.SessionInitiate,n.contents[0].application={applicationType:Dn,file:{date:e.lastModified?new Date(e.lastModified):void 0,hashesUsed:[{algorithm:"sha-1"}],name:e.name,size:e.size}},this.send("session-initiate",n),yield this.pc.setLocalDescription(t)}))),t()}catch(e){return this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}))}accept(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Accepted incoming session"),this.role="responder",this.state="active",e=e||(()=>{});try{yield this.processLocal(Qr.SessionAccept,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=yield this.pc.createAnswer(),t=xs(vs(e.sdp),this.role,this.transportType);t.sid=this.sid,t.action="session-accept";for(const e of t.contents)e.creator="initiator";this.contentName=t.contents[0].name,this.send("session-accept",t),yield this.pc.setLocalDescription(e),yield this.processBufferedCandidates()}))),e()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}))}onSessionInitiate(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Initiating incoming session"),this.role="responder",this.state="pending",this.transportType=e.contents[0].transport.transportType;const n=bs(ks(e,this.peerRole)),i=e.contents[0].application,r=i.file.hashesUsed?i.file.hashesUsed:i.file.hashes||[];this.receiver=new Rs({hash:r[0]&&r[0].algorithm}),this.receiver.on("progress",(e,t)=>{this._log("info","Receive progress "+e+"/"+t)}),this.receiver.on("receivedFile",e=>{this.receivedFile=e,this._maybeReceivedFile()}),this.receiver.metadata=i.file,this.pc.addEventListener("datachannel",e=>{this.channel=e.channel,this.receiver.receive(this.receiver.metadata,e.channel)});try{yield this.pc.setRemoteDescription({type:"offer",sdp:n}),yield this.processBufferedCandidates(),t()}catch(e){this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}))}onSessionInfo(e,t){const n=e.info;n&&n.file&&n.file.hashes&&(this.receiver.metadata.hashes=n.file.hashes,this.receiver.metadata.actualhash&&this._maybeReceivedFile(),t())}_maybeReceivedFile(){if(this.receiver.metadata.hashes&&this.receiver.metadata.hashes.length){for(const e of this.receiver.metadata.hashes||[])if(e.value&&e.value.toString("hex")===this.receiver.metadata.actualhash)return this._log("info","File hash matches"),this.parent.emit("receivedFile",this,this.receivedFile,this.receiver.metadata),void this.end("success");this._log("error","File hash does not match"),this.end("media-error")}}}function As(e){const t=e.application;if(t.streams&&t.streams.length&&t.sources&&t.sources.length){const e=t.streams[0];t.sources[0].parameters.msid=`${e.id} ${e.track}`,t.sourceGroups&&t.sourceGroups.length>0&&t.sources.push({parameters:{cname:t.sources[0].parameters.cname,msid:`${e.id} ${e.track}`},ssrc:t.sourceGroups[0].sources[1]})}}class Ps extends Ns{constructor(e){if(super(e),this.includesAudio=!1,this.includesVideo=!1,this._ringing=!1,this.pc.addEventListener("track",e=>{this.onAddTrack(e.track,e.streams[0])}),e.stream)for(const t of e.stream.getTracks())this.addTrack(t,e.stream)}get ringing(){return this._ringing}set ringing(e){e!==this._ringing&&(this._ringing=e)}get streams(){return"closed"!==this.pc.signalingState?this.pc.getRemoteStreams():[]}start(e,t){return Object(r.__awaiter)(this,arguments,void 0,(function*(){this.state="pending",1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this.role="initiator",this.offerOptions=e;try{yield this.processLocal(Qr.SessionInitiate,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createOffer(e),n=xs(vs(t.sdp),this.role,this.transportType);n.sid=this.sid,n.action=Qr.SessionInitiate;for(const e of n.contents||[])e.creator="initiator",As(e);yield this.pc.setLocalDescription(t),this.send("session-initiate",n)}))),t()}catch(e){this._log("error","Could not create WebRTC offer",e),this.end("failed-application",!0)}}))}accept(e,t){return Object(r.__awaiter)(this,arguments,void 0,(function*(){1===arguments.length&&"function"==typeof e&&(t=e,e={}),t=t||(()=>{}),e=e||{},this._log("info","Accepted incoming session"),this.state="active",this.role="responder";try{yield this.processLocal(Qr.SessionAccept,()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.pc.createAnswer(e),n=xs(vs(t.sdp),this.role,this.transportType);n.sid=this.sid,n.action=Qr.SessionAccept;for(const e of n.contents||[])e.creator="initiator";yield this.pc.setLocalDescription(t),yield this.processBufferedCandidates(),this.send("session-accept",n)}))),t()}catch(e){this._log("error","Could not create WebRTC answer",e),this.end("failed-application")}}))}end(e="success",t=!1){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.end(e,t)}ring(){return this.processLocal("ring",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Ringing on incoming session"),this.ringing=!0,this.send(Qr.SessionInfo,{info:{infoType:as}})})))}mute(e,t){return this.processLocal("mute",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Muting",t),this.send(Qr.SessionInfo,{info:{creator:e,infoType:ns,name:t}})})))}unmute(e,t){return this.processLocal("unmute",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Unmuting",t),this.send(Qr.SessionInfo,{info:{creator:e,infoType:is,name:t}})})))}hold(){return this.processLocal("hold",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Placing on hold"),this.send("session-info",{info:{infoType:rs}})})))}resume(){return this.processLocal("resume",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Resuming from hold"),this.send("session-info",{info:{infoType:os}})})))}addTrack(e,t,n){return"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),this.processLocal("addtrack",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){this.pc.addTrack?this.pc.addTrack(e,t):this.pc.addStream(t),n&&n()})))}removeTrack(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this.processLocal("removetrack",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.pc.removeTrack(e),t)return t()})))}))}onAddTrack(e,t){this._log("info","Track added"),this.parent.emit("peerTrackAdded",this,e,t)}onRemoveTrack(e){this._log("info","Track removed"),this.parent.emit("peerTrackRemoved",this,e)}onSessionInitiate(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this._log("info","Initiating incoming session"),this.state="pending",this.role="responder",this.transportType=e.contents[0].transport.transportType;const n=ks(e,this.peerRole);for(const e of n.media)"audio"===e.kind&&(this.includesAudio=!0),"video"===e.kind&&(this.includesVideo=!0),e.streams||(e.streams=[{stream:"legacy",track:e.kind}]);const i=bs(n);try{return yield this.pc.setRemoteDescription({type:"offer",sdp:i}),yield this.processBufferedCandidates(),t()}catch(e){return this._log("error","Could not create WebRTC answer",e),t({condition:"general-error"})}}))}onSessionTerminate(e,t){for(const e of this.pc.getReceivers())this.onRemoveTrack(e.track);super.onSessionTerminate(e,t)}onSessionInfo(e,t){const n=e.info||{infoType:""};switch(n.infoType){case as:return this._log("info","Outgoing session is ringing"),this.ringing=!0,this.parent.emit("ringing",this),t();case rs:return this._log("info","On hold"),this.parent.emit("hold",this),t();case ss:case os:return this._log("info","Resuming from hold"),this.parent.emit("resumed",this),t();case ns:return this._log("info","Muting",n),this.parent.emit("mute",this,n),t();case is:return this._log("info","Unmuting",n),this.parent.emit("unmute",this,n),t()}return t()}}class qs extends o.EventEmitter{constructor(e={}){super(),e=e||{},this.selfID=e.selfID,this.sessions={},this.peers={},this.iceServers=e.iceServers||[],this.prepareSession=e.prepareSession||(e=>{if(this.config.hasRTCPeerConnection)return e.applicationTypes.indexOf(Rn)>=0?new Ps(e):e.applicationTypes.indexOf(Dn)>=0?new Os(e):void 0}),this.performTieBreak=e.performTieBreak||((e,t)=>{const n=(t.jingle.contents||[]).map(e=>{if(e.application)return e.application.applicationType});return(e.pendingApplicationTypes||[]).filter(e=>n.includes(e)).length>0}),this.createPeerConnection=e.createPeerConnection||((e,t)=>{if(tr)return new tr(t)}),this.config=Object.assign({debug:!1,hasRTCPeerConnection:!!tr,peerConnectionConfig:{bundlePolicy:e.bundlePolicy||"balanced",iceTransportPolicy:e.iceTransportPolicy||"all",rtcpMuxPolicy:e.rtcpMuxPolicy||"require",sdpSemantics:e.sdpSemantics},peerConnectionConstraints:{optional:[{DtlsSrtpKeyAgreement:!0},{RtpDataChannels:!1}]}},e)}addICEServer(e){if("string"==typeof e)return void this.iceServers.push({urls:e});if(!(t=e).type&&(t.urls||t.url))return void this.iceServers.push(e);var t;let n=e.host||"";n.indexOf(":")>=0&&(n=`[${n}]`);let i=`${e.type}:${n}`;e.port&&(i+=":"+e.port),e.transport&&(i+="?transport="+e.transport),"turn"===e.type||"turns"===e.type?this.iceServers.push({credential:e.password,urls:[i],username:e.username}):"stun"!==e.type&&"stuns"!==e.type||this.iceServers.push({urls:[i]})}resetICEServers(){this.iceServers=[]}addSession(e){e.parent=this;const t=e.sid,n=e.peerID;return this.sessions[t]=e,this.peers[n]||(this.peers[n]=[]),this.peers[n].push(e),this.emit("createdSession",e),e}forgetSession(e){const t=this.peers[e.peerID]||[];t.length&&t.splice(t.indexOf(e),1),delete this.sessions[e.sid]}createMediaSession(e,t,n){const i=new Ps({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t,stream:n});return this.addSession(i),i}createFileTransferSession(e,t){const n=new Os({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t});return this.addSession(n),n}endPeerSessions(e,t,n=!1){const i=this.peers[e]||[];delete this.peers[e];for(const e of i)e.end(t||"gone",n)}endAllSessions(e,t=!1){for(const n of Object.keys(this.peers))this.endPeerSessions(n,e,t)}process(e){const t=e.jingle?e.jingle.sid:void 0;let n=t?this.sessions[t]:void 0;const i=e.id,r=e.from;if(!r)return;if("error"===e.type){if(this._log("error","Received error response",e),n&&e.error&&"unknown-session"===e.error.jingleError)return n.end("gone",!0);const t=e.error&&"tie-break"===e.error.jingleError;return n&&"pending"===n.state&&t?n.end("alternative-session",!0):void(n&&(n.pendingAction=void 0))}if("result"===e.type)return void(n&&(n.pendingAction=void 0));const s=e.jingle.action,o=e.jingle.contents||[],a=o.map(e=>e.application?e.application.applicationType:void 0),c=o.map(e=>e.transport?e.transport.transportType:void 0);if(s!==Qr.SessionInitiate){if(!n)return"session-terminate"===s?void this.emit("send",{id:i,to:r,type:"result"}):(this._log("error","Unknown session",t),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"}));if(n.peerID!==r||"ended"===n.state)return this._log("error","Session has ended, or action has wrong sender"),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"});if("session-accept"===s&&"pending"!==n.state)return this._log("error","Tried to accept session twice",t),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if("session-terminate"!==s&&s===n.pendingAction&&(this._log("error","Tie break during pending request"),n.isInitiator))return this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(n){if(n.peerID!==r)return this._log("error","Duplicate sid from new sender"),this._sendError(r,i,{condition:"service-unavailable"});if("pending"!==n.state)return this._log("error","Someone is doing this wrong"),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if(this.selfID&&this.selfID>n.peerID&&this.performTieBreak(n,e))return this._log("error","Tie break new session because of duplicate sids"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(this.peers[r]&&this.peers[r].length)for(let n=0,s=this.peers[r].length;n<s;n++){const s=this.peers[r][n];if(s&&"pending"===s.state&&t&&kr(s.sid,t)>0&&this.performTieBreak(s,e))return this._log("info","Tie break session-initiate"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}if("session-initiate"===s){if(!o.length)return this._sendError(r,i,{condition:"bad-request"});n=this._createIncomingSession({applicationTypes:a,config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!1,parent:this,peerID:r,sid:t,transportTypes:c},e)}n.process(s,e.jingle,t=>{t?(this._log("error","Could not process request",e,t),this._sendError(r,i,t)):(this.emit("send",{id:i,to:r,type:"result"}),"session-initiate"===s&&this.emit("incoming",n))})}signal(e,t){const n=t.jingle&&t.jingle.action;e.isInitiator&&n===Qr.SessionInitiate&&this.emit("outgoing",e),this.emit("send",t)}_createIncomingSession(e,t){let n;return this.prepareSession&&(n=this.prepareSession(e,t)),n||(n=new Es(e)),this.addSession(n),n}_sendError(e,t,n){n.type||(n.type="cancel"),this.emit("send",{error:n,id:t,to:e,type:"error"})}_log(e,t,...n){this.emit("log",e,t,...n),this.emit("log:"+e,t,...n)}}var Ls=Object.freeze({__proto__:null,Session:Es,ICESession:Ns,MediaSession:Ps,FileSession:Os,SessionManager:qs,importFromSDP:vs,exportToSDP:bs});function Fs(e){const t=!!tr,n={advertiseAudio:t,advertiseFileTransfer:t,advertiseVideo:t,bundlePolicy:"balanced",hasRTCPeerConnection:t,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",rtcpMuxPolicy:"require",trickleIce:!0},i=e.config.jingle,s=Object.assign(Object.assign({},n),i),o=e.jingle=new qs(s),a=[Cn];s.hasRTCPeerConnection&&(a.push(ni,Pn,"urn:xmpp:jingle:transports:dtls-sctp:1","urn:xmpp:jingle:apps:dtls:0","urn:ietf:rfc:5888"),!1===s.trickleIce&&a.push("urn:ietf:rfc:3264"),(s.advertiseAudio||s.advertiseVideo)&&a.push(Rn,Gn,Vn,"urn:ietf:rfc:5576"),s.advertiseAudio&&a.push("urn:xmpp:jingle:apps:rtp:audio"),s.advertiseVideo&&a.push("urn:xmpp:jingle:apps:rtp:video"),s.advertiseFileTransfer&&a.push("urn:xmpp:jingle:apps:file-transfer:4",Dn));for(const t of a)e.disco.addFeature(t);const c=["outgoing","incoming","accepted","terminated","ringing","mute","unmute","hold","resumed"];for(const t of c)o.on(t,(n,i)=>{e.emit("jingle:"+t,n,i)});o.on("createdSession",t=>{e.emit("jingle:created",t)}),o.on("send",t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{if("set"===t.type){const n=yield e.sendIQ(t);n.jingle||(n.jingle={}),n.jingle.sid=t.jingle.sid,o.process(n)}"result"===t.type&&e.sendIQResult({type:"set",id:t.id,from:t.to},t),"error"===t.type&&e.sendIQError({type:"set",id:t.id,from:t.to},t)}catch(e){e.jingle||(e.jingle=t.jingle),e.jingle.sid=t.jingle.sid,o.process(e)}}))),e.on("session:bound",e=>{o.selfID=e}),e.on("iq:set:jingle",e=>{o.process(e)}),e.on("unavailable",e=>{o.endPeerSessions(e.from,void 0,!0)}),e.getServices=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=(yield e.sendIQ({externalServices:{type:n,version:i},to:t,type:"get"})).externalServices;return r.services=r.services||[],r})),e.getServiceCredentials=(t,n,i,s,o)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({externalServiceCredentials:{host:n,port:s,type:i,version:o},to:t,type:"get"})).externalServiceCredentials})),e.discoverICEServers=(t={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=(yield e.getServices(e.config.server,void 0,t.version)).services||[],i=[];for(const t of n)e.jingle.addICEServer(t);return i}catch(e){return[]}}))}function Ms(e,t){const n=[],i=new Map;for(const e of t)e.name&&i.set(e.name,e);const r=new Set;for(const t of e)t.name&&i.has(t.name)?(n.push(Object.assign(Object.assign({},t),i.get(t.name))),r.add(t.name)):n.push(Object.assign({},t));for(const e of t)(!e.name||e.name&&!r.has(e.name))&&n.push(Object.assign({},e));return n}var Ds=Object.freeze({__proto__:null,mergeFields:Ms});function Bs(e){e.getHistorySearchForm=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({archive:{type:"query",version:n.version},to:t,type:"get"})).archive.form})),e.searchHistory=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=e.nextId();let r="";"string"==typeof t?r=t:(r=t.to||"",n=t),n.queryId=i;const s=n.form||{};s.type="submit";const o=s.fields||[],a=[{name:"FORM_TYPE",type:"hidden",value:"urn:xmpp:mam:2"}];n.with&&a.push({name:"with",type:"text-single",value:n.with}),n.start&&a.push({name:"start",type:"text-single",value:n.start.toISOString()}),n.end&&a.push({name:"end",type:"text-single",value:n.end.toISOString()}),s.fields=Ms(a,o),n.form=s;const c=V(e.jid,r),l=[],u=e=>{c.has(e.from)&&e.archive&&e.archive.queryId===i&&l.push(e.archive)};e.on("mam:item",u);try{const t=yield e.sendIQ({archive:n,id:i,to:r,type:"set"});return Object.assign(Object.assign({},t.archive),{results:l})}finally{e.off("mam:item",u)}})),e.getHistoryPreferences=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({archive:{type:"preferences"},type:"get"})).archive})),e.setHistoryPreferences=t=>e.sendIQ({archive:Object.assign({type:"preferences"},t),type:"set"}),e.on("message",t=>{t.archive&&e.emit("mam:item",t)})}const Us=new Set(["chat","groupchat","headline","normal"]),zs=new Set(["chat","groupchat","normal"]),Js=new Map([["markable",0],["received",1],["displayed",2],["acknowledged",3]]),Gs=(e,t)=>{var n;return e.marker&&(Js.get(e.marker.type)<Js.get(t)||"markable"===(null===(n=e.marker)||void 0===n?void 0:n.type))};function Vs(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({carbons:{action:t},type:"set"})}))}function $s(e){e.disco.addFeature("urn:xmpp:attention:0"),e.disco.addFeature(Xn),e.disco.addFeature(yn),e.disco.addFeature("urn:xmpp:message-correct:0"),e.disco.addFeature("urn:xmpp:receipts"),e.disco.addFeature(Qn),e.enableCarbons=()=>Vs(e,"enable"),e.disableCarbons=()=>Vs(e,"disable"),e.markReceived=t=>e.sendMarker(t,"received"),e.markDisplayed=t=>e.sendMarker(t,"displayed"),e.markAcknowledged=t=>e.sendMarker(t,"acknowledged"),e.getAttention=(t,n={})=>e.sendMessage(Object.assign(Object.assign({},n),{requestingAttention:!0,to:t,type:"headline"})),e.sendMarker=(t,n,i)=>{if(!Gs(t,n)&&!i)return;const r=!1!==e.config.groupchatMarkersUseStanzaID;let s=t.id;if("groupchat"===t.type&&t.stanzaIds&&r){const e=t.stanzaIds.find(e=>$(e.by,t.from));e&&(s=e.id)}e.sendMessage({marker:{id:s,type:n},to:"groupchat"===t.type?K(t.from):t.from,type:t.type})},e.on("message",t=>{if(t.carbon&&$(t.from,e.jid)){const n=t.carbon.forward.message;n.delay||(n.delay=t.carbon.forward.delay||{timestamp:new Date(Date.now())}),(e=>!!e.carbon&&"received"===e.carbon.type)(t)&&(e.emit("carbon:received",t),e.emit("message",n)),(e=>!!e.carbon&&"sent"===e.carbon.type)(t)&&(e.emit("carbon:sent",t),e.emit("message:sent",n,!0))}(e=>!!e.forms&&e.forms.length>0)(t)&&e.emit("dataform",t),t.requestingAttention&&e.emit("attention",t),(e=>!!e.rtt)(t)&&e.emit("rtt",t),(e=>!!e.replace)(t)&&e.emit("replace",t),(e=>!!e.chatState)(t)&&zs.has(t.type||"normal")&&e.emit("chat:state",t);const n=!1!==e.config.sendReceipts,i=!1!==e.config.sendMUCReceipts,r=!1!==e.config.chatMarkers,s=!1!==e.config.groupchatMarkersUseStanzaID,o=(e=>{var t;return!!e.receipt&&"request"===e.receipt.type&&Us.has(null!==(t=e.type)&&void 0!==t?t:"normal")})(t),a=Gs(t,"received"),c=o&&n&&("groupchat"!==t.type||i);if(c||r&&a){const n="groupchat"===t.type?K(t.from):t.from;let i=t.id;if("groupchat"===t.type&&t.stanzaIds&&s){const e=t.stanzaIds.find(e=>$(e.by,t.from));e&&(i=e.id)}e.sendMessage({receipt:c?{id:t.id,type:"received"}:void 0,marker:r&&a?{id:i,type:"received"}:void 0,to:n,type:t.type})}t.receipt&&"received"===t.receipt.type&&e.emit("receipt",t),t.marker&&"markable"!==t.marker.type&&e.emit("marker:"+t.marker.type,t)})}function Hs(e){e.disco.addFeature(en),e.disco.addFeature("jabber:x:conference"),e.disco.addFeature(Kn),e.joinedRooms=new Map,e.joiningRooms=new Map,e.leavingRooms=new Map,e.on("session:started",(function(){const t=e.joiningRooms;e.joiningRooms=new Map;for(const[n,i]of t)e.joinRoom(n,i);const n=e.joinedRooms;e.joinedRooms=new Map;for(const[t,i]of n)e.joinRoom(t,i)})),e.on("message",t=>{if("groupchat"===t.type&&t.hasSubject)e.emit("muc:topic",{from:t.from,room:K(t.from),topic:t.subject||""});else if(t.muc)if("direct-invite"===t.muc.type||!t.muc.invite&&t.legacyMUC){const n="direct-invite"===t.muc.type?t.muc:t.legacyMUC;e.emit("muc:invite",{from:t.from,password:n.password,reason:n.reason,room:n.jid,thread:n.thread,type:"direct"})}else t.muc.invite?e.emit("muc:invite",{from:t.muc.invite[0].from,password:t.muc.password,reason:t.muc.invite[0].reason,room:t.from,thread:t.muc.invite[0].thread,type:"mediated"}):t.muc.decline?e.emit("muc:declined",{from:t.muc.decline.from,reason:t.muc.decline.reason,room:t.from}):e.emit("muc:other",t)}),e.on("presence",t=>{const n=K(t.from);if(e.joiningRooms.has(n)&&"error"===t.type)return e.joiningRooms.delete(n),e.emit("muc:failed",t),void e.emit("muc:error",t);if(!function(e){return!!e.muc}(t))return;const i=t.muc.statusCodes&&t.muc.statusCodes.indexOf(Jr.SelfPresence)>=0,r=t.muc.statusCodes&&t.muc.statusCodes.indexOf(Jr.NickChanged)>=0;if("error"===t.type)return void e.emit("muc:error",t);if("unavailable"===t.type)return e.emit("muc:unavailable",t),i&&(r?e.joinedRooms.set(n,t.muc.nick):(e.emit("muc:leave",t),e.joinedRooms.delete(n),e.leavingRooms.delete(n))),void(t.muc.destroy&&e.emit("muc:destroyed",{newRoom:t.muc.destroy.jid,password:t.muc.destroy.password,reason:t.muc.destroy.reason,room:n}));e.emit("muc:available",t);const s=e.joiningRooms.has(n)||!e.joinedRooms.has(n);i&&(e.joinedRooms.set(n,Q(t.from)),s&&(e.joiningRooms.delete(n),e.emit("muc:join",t)))}),e.joinRoom=(t,n,i={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(t=K(t),e.joiningRooms.set(t,n||""),!n)try{n=yield e.getReservedNick(t),e.joiningRooms.set(t,n)}catch(e){throw new Error("Room nick required")}return new Promise((r,s)=>{function o(n){$(n.from,t)&&(e.off("muc:join",o),e.off("muc:failed",a),r(n))}function a(n){$(n.from,t)&&(e.off("muc:join",o),e.off("muc:failed",a),s(n))}e.on("muc:join",o),e.on("muc:failed",a),e.sendPresence(Object.assign(Object.assign({},i),{muc:Object.assign(Object.assign({},i.muc),{type:"join"}),to:J(t,n)}))})})),e.leaveRoom=(t,n,i={})=>(t=K(t),n=n||e.joinedRooms.get(t),e.leavingRooms.set(t,n),new Promise((r,s)=>{const o=i.id||Ir(),a=V(t);function c(n){$(n.from,t)&&(e.off("muc:leave",c),e.off("presence:error",l),r(n))}function l(n){n.id===o&&a.has(n.from)&&(e.joinedRooms.has(t)||e.leavingRooms.delete(t),e.off("muc:leave",c),e.off("presence:error",l),s(n))}e.on("muc:leave",c),e.on("presence:error",l),e.sendPresence(Object.assign(Object.assign({},i),{id:o,to:J(t,n),type:"unavailable"}))})),e.ban=(t,n,i)=>e.setRoomAffiliation(t,n,"outcast",i),e.kick=(t,n,i)=>e.setRoomRole(t,n,"none",i),e.invite=(t,n=[])=>{Array.isArray(n)||(n=[n]),e.sendMessage({muc:{invite:n,type:"info"},to:t})},e.directInvite=(t,n,i={})=>{e.sendMessage({muc:Object.assign(Object.assign({},i),{jid:t,type:"direct-invite"}),to:n})},e.declineInvite=(t,n,i)=>{e.sendMessage({muc:{decline:{reason:i,to:n},type:"info"},to:t})},e.changeNick=(t,n)=>{const i=Ir(),r=J(t,n),s=V(t);return new Promise((t,n)=>{function o(n){s.has(K(n.from))&&n.muc.statusCodes&&n.muc.statusCodes.includes(Jr.SelfPresence)&&(e.off("muc:available",o),e.off("presence:id:"+i,a),t(n))}function a(r){s.has(K(r.from))&&r.id===i&&(e.off("muc:available",o),e.off("presence:id:"+i,a),"error"===r.type?n(r):t(r))}e.on("muc:available",o),e.on("presence:id:"+i,a),e.sendPresence({id:i,to:r})})},e.setSubject=(t,n)=>{e.sendMessage({subject:n,to:t,type:"groupchat"})},e.getReservedNick=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){try{const n=(yield e.getDiscoInfo(t,"x-roomuser-item")).identities[0];if(n.name)return n.name;throw new Error("No nickname reserved")}catch(e){throw new Error("No nickname reserved")}})),e.requestRoomVoice=t=>{e.sendMessage({forms:[{fields:[{name:"FORM_TYPE",type:"hidden",value:"http://jabber.org/protocol/muc#request"},{name:"muc#role",type:"text-single",value:"participant"}],type:"submit"}],to:t})},e.setRoomAffiliation=(t,n,i,r)=>e.sendIQ({muc:{type:"user-list",users:[{affiliation:i,jid:n,reason:r}]},to:t,type:"set"}),e.setRoomRole=(t,n,i,r)=>e.sendIQ({muc:{type:"user-list",users:[{nick:n,reason:r,role:i}]},to:t,type:"set"}),e.getRoomMembers=(t,n={affiliation:"member"})=>e.sendIQ({muc:{type:"user-list",users:[n]},to:t,type:"get"}),e.getRoomConfig=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.sendIQ({muc:{type:"configure"},to:t,type:"get"});if(!n.muc.form)throw new Error("No configuration form returned");return n.muc.form})),e.configureRoom=(t,n={})=>e.sendIQ({muc:{form:Object.assign(Object.assign({},n),{type:"submit"}),type:"configure"},to:t,type:"set"}),e.destroyRoom=(t,n={})=>e.sendIQ({muc:{destroy:n,type:"configure"},to:t,type:"set"}),e.getUniqueRoomName=function(e){return Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield this.sendIQ({muc:{type:"unique"},to:e,type:"get"});if(!t.muc.name)throw new Error("No unique name returned");return t.muc.name}))},e.getBookmarks=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.getPrivateData("bookmarks");return t&&t.rooms?t.rooms:[]})),e.setBookmarks=t=>e.setPrivateData("bookmarks",{rooms:t}),e.addBookmark=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.getBookmarks(),i=[];let r=!1;for(const e of n)$(e.jid,t.jid)?(i.push(Object.assign(Object.assign({},e),t)),r=!0):i.push(e);return r||i.push(t),e.setBookmarks(i)})),e.removeBookmark=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=(yield e.getBookmarks()).filter(e=>!$(e.jid,t));return e.setBookmarks(n)}))}function Ws(e){e.disco.addFeature(Sn),e.disco.addFeature(gn),e.disco.addFeature(_n),e.disco.addFeature(An),e.disco.addFeature(wn),e.disco.addFeature(Nn(Sn)),e.disco.addFeature(Nn(gn)),e.disco.addFeature(Nn(_n)),e.disco.addFeature(Nn(An)),e.disco.addFeature(Nn(wn)),e.publishActivity=t=>e.publish("",Sn,Object.assign({itemType:Sn},t)),e.publishGeoLoc=t=>e.publish("",gn,Object.assign({itemType:gn},t)),e.publishMood=t=>e.publish("",_n,Object.assign({itemType:_n},t)),e.publishNick=t=>e.publish("",An,{itemType:An,nick:t}),e.publishTune=t=>e.publish("",wn,Object.assign({itemType:wn},t)),e.on("pubsub:published",t=>{const n=t.pubsub.items.published[0].content;switch(t.pubsub.items.node){case Sn:return e.emit("activity",{activity:n,jid:t.from});case gn:return e.emit("geoloc",{geoloc:n,jid:t.from});case _n:return e.emit("mood",{jid:t.from,mood:n});case An:return e.emit("nick",{jid:t.from,nick:n.nick});case wn:return e.emit("tune",{jid:t.from,tune:t.pubsub.items.published[0].content})}})}function Qs(e){e.disco.addFeature(kn+"#SubID",kn),e.on("message",t=>{!function(e){return!!e.pubsub&&!(e.pubsub.context&&"user"!==e.pubsub.context||!e.pubsub.affiliations)}(t)?function(e){return!!e.pubsub}(t)&&(e.emit("pubsub:event",t),!function(e){return!!e.pubsub.items&&!!e.pubsub.items.published}(t)?!function(e){return!!e.pubsub.items&&!!e.pubsub.items.retracted}(t)?!function(e){return"purge"===e.pubsub.eventType}(t)?!function(e){return"delete"===e.pubsub.eventType}(t)?!function(e){return"subscription"===e.pubsub.eventType}(t)?function(e){return"configuration"===e.pubsub.eventType}(t)&&e.emit("pubsub:config",t):e.emit("pubsub:subscription",t):e.emit("pubsub:deleted",t):e.emit("pubsub:purged",t):e.emit("pubsub:retracted",t):e.emit("pubsub:published",t)):e.emit("pubsub:affiliations",t)}),e.subscribeToNode=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i={};let r;"string"==typeof n?(i.node=n,i.jid=K(e.jid)):(i.node=n.node,i.jid=n.jid||(n.useBareJID?K(e.jid):e.jid),r=n.options);const s=yield e.sendIQ({pubsub:{context:"user",subscribe:i,subscriptionOptions:r?{form:r}:void 0},to:t,type:"set"}),o=s.pubsub.subscription||{};return s.pubsub.subscriptionOptions&&(o.options=s.pubsub.subscriptionOptions.form),o})),e.unsubscribeFromNode=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i={};"string"==typeof n?(i.node=n,i.jid=K(e.jid)):(i.node=n.node,i.subid=n.subid,i.jid=n.jid||(n.useBareJID?K(e.jid):e.jid));const r=yield e.sendIQ({pubsub:{context:"user",unsubscribe:i},to:t,type:"set"});return r.pubsub&&r.pubsub.subscription?r.pubsub.subscription:Object.assign(Object.assign({},i),{state:"none"})})),e.publish=(t,n,i,r)=>e.sendIQ({pubsub:{context:"user",publish:{item:{content:i,id:r},node:n}},to:t,type:"set"}),e.getItem=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"user",fetch:{items:[{id:i}],node:n}},to:t,type:"get"})).pubsub.fetch.items[0]})),e.getItems=(t,n,i={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=yield e.sendIQ({pubsub:{context:"user",fetch:{max:i.max,node:n},paging:i},to:t,type:"get"}),s=r.pubsub.fetch;return s.paging=r.pubsub.paging,s})),e.retract=(t,n,i,r)=>e.sendIQ({pubsub:{context:"user",retract:{id:i,node:n,notify:r}},to:t,type:"set"}),e.purgeNode=(t,n)=>e.sendIQ({pubsub:{context:"owner",purge:n},to:t,type:"set"}),e.deleteNode=(t,n,i)=>e.sendIQ({pubsub:{context:"owner",destroy:{node:n,redirect:i}},to:t,type:"set"}),e.createNode=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const r=yield e.sendIQ({pubsub:{configure:i?{form:i}:void 0,context:"user",create:{node:n}},to:t,type:"set"});return r.pubsub&&r.pubsub.create?r.pubsub.create:{node:n}})),e.getSubscriptions=(t,n={})=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"user",subscriptions:n},to:t,type:"get"})).pubsub.subscriptions})),e.getAffiliations=(t,n)=>e.sendIQ({pubsub:{affiliations:{node:n}},to:t,type:"get"}),e.getNodeSubscribers=(t,n,i={})=>("string"==typeof n?i.node=n:i=Object.assign(Object.assign({},i),n),e.sendIQ({pubsub:{context:"owner",subscriptions:i},to:t,type:"get"})),e.updateNodeSubscriptions=(t,n,i)=>e.sendIQ({pubsub:{context:"owner",subscriptions:{items:i,node:n}},to:t,type:"set"}),e.getNodeAffiliations=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{affiliations:{node:n},context:"owner"},to:t,type:"get"})).pubsub.affiliations})),e.updateNodeAffiliations=(t,n,i)=>e.sendIQ({pubsub:{affiliations:{items:i,node:n},context:"owner"},to:t,type:"set"}),e.getNodeConfig=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{configure:{node:n},context:"owner"},to:t,type:"get"})).pubsub.configure.form||{}})),e.getDefaultNodeConfig=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{context:"owner",defaultConfiguration:{}},to:t,type:"get"})).pubsub.defaultConfiguration.form||{}})),e.configureNode=(t,n,i)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return e.sendIQ({pubsub:{configure:{form:i,node:n},context:"owner"},to:t,type:"set"})})),e.getDefaultSubscriptionOptions=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({pubsub:{defaultSubscriptionOptions:{}},to:t,type:"get"})).pubsub.defaultSubscriptionOptions.form||{}}))}function Ks(e){function t(t,n){return Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({blockList:{action:t,jids:[n]},type:"set"})}))}e.on("iq:set:roster",t=>{if(!V(e.jid).has(t.from))return e.sendIQError(t,{error:{condition:"service-unavailable",type:"cancel"}});e.emit("roster:update",t),e.sendIQResult(t)}),e.on("iq:set:blockList",t=>{if(!V(e.jid).has(t.from))return e.sendIQError(t,{error:{condition:"service-unavailable",type:"cancel"}});const n=t.blockList;e.emit(n.action,{jids:n.jids||[]}),e.sendIQResult(t)}),e.getRoster=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.sendIQ({roster:{version:e.config.rosterVer},type:"get"});if(t.roster){const n=t.roster.version;return n&&(e.config.rosterVer=n,e.emit("roster:ver",n)),t.roster.items=t.roster.items||[],t.roster}return{items:[]}})),e.updateRosterItem=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({roster:{items:[t]},type:"set"})})),e.removeRosterItem=t=>e.updateRosterItem({jid:t,subscription:"remove"}),e.subscribe=t=>{e.sendPresence({type:"subscribe",to:t})},e.unsubscribe=t=>{e.sendPresence({type:"unsubscribe",to:t})},e.acceptSubscription=t=>{e.sendPresence({type:"subscribed",to:t})},e.denySubscription=t=>{e.sendPresence({type:"unsubscribed",to:t})},e.getBlocked=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const t=yield e.sendIQ({blockList:{action:"list"},type:"get"});return Object.assign({jids:[]},t.blockList)})),e.block=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return t("block",e)})),e.unblock=e=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return t("unblock",e)})),e.goInvisible=(t=!1)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",visiblity:{probe:t,type:"invisible"}})})),e.goVisible=()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){yield e.sendIQ({type:"set",visiblity:{type:"visible"}})}))}function Xs(e){e.registerFeature("sasl",100,(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=e.sasl.createMechanism(t.sasl.mechanisms),s=t=>Object(r.__awaiter)(this,void 0,void 0,(function*(){if(i)switch(t.type){case"success":return e.features.negotiated.sasl=!0,e.off("sasl",s),e.emit("auth:success",e.config.credentials),e.transport&&(e.transport.authenticated=!0),void n("restart");case"challenge":i.processChallenge(t.value);try{const t=yield e.getCredentials(),n=i.createResponse(t);n||""===n?e.send("sasl",{type:"response",value:n}):e.send("sasl",{type:"response"});const r=i.getCacheableCredentials();r&&(e.config.credentials||(e.config.credentials={}),e.config.credentials=Object.assign(Object.assign({},e.config.credentials),r),e.emit("credentials:update",e.config.credentials))}catch(t){console.error(t),e.send("sasl",{type:"abort"})}return;case"failure":case"abort":return e.off("sasl",s),e.emit("auth:failed"),void n("disconnect","authentication failed")}}));if(!i)return e.off("sasl",s),e.emit("auth:failed"),n("disconnect","authentication failed");e.on("sasl",s),e.once("--reset-stream-features",()=>{e.features.negotiated.sasl=!1,e.off("sasl",s)});try{const t=yield e.getCredentials();e.send("sasl",{mechanism:i.name,type:"auth",value:i.createResponse(t)})}catch(t){console.error(t),e.send("sasl",{type:"abort"})}})))}function Ys(e){function t(t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){const n=yield e.getDiscoInfo(t);if(!n.features||!n.features.includes(ti))return;let i;for(const e of n.extensions||[]){const n=e.fields||[];if(n.some(e=>"FORM_TYPE"===e.name&&e.value===ti)){const e=n.find(e=>"max-file-size"===e.name);return e&&(i=parseInt(e.value,10)),{jid:t,maxSize:i}}}}))}e.disco.addFeature(Mn),e.getBits=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({bits:{cid:n},to:t,type:"get"})).bits})),e.getUploadService=(n=W(e.jid))=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const i=yield t(n);if(i)return i;const r=yield e.getDiscoItems(n);for(const e of r.items||[]){if(!e.jid)continue;const n=yield t(e.jid);if(n)return n}throw new Error("No upload service discovered on: "+n)})),e.getUploadSlot=(t,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){return(yield e.sendIQ({httpUpload:Object.assign({type:"request"},n),to:t,type:"get"})).httpUpload}))}function Zs(e){e.use(fs),e.use(Lr),e.use(_r),e.use(Rr),e.use(gs),e.use(Xs)}function eo(e){e.use(br),e.use($s),e.use(yr),e.use(Sr),e.use(hs),e.use(Fs),e.use(Bs),e.use(Hs),e.use(Ws),e.use(Qs),e.use(Ks),e.use(Ys)}const to={aliases:["features.legacySession","iq.legacySession"],element:"session",fields:{optional:yt(null,"optional")},namespace:Jt},no=[{aliases:["atomentry",{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"entry",fields:{id:dt(null,"id"),published:ft(null,"published"),updated:ft(null,"updated")},namespace:Dt,type:Dt,typeField:"itemType"},{element:"summary",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.summary"},{element:"title",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.title"},{aliases:[{path:"atomentry.links",multiple:!0}],element:"link",fields:{href:He("href"),mediaType:He("type"),rel:He("rel")},namespace:Dt},{aliases:[{path:"atomentry.authors",multiple:!0}],element:"author",fields:{name:dt(null,"name"),uri:dt(null,"uri"),email:dt(null,"email")},namespace:Dt},{aliases:[{path:"atomentry.contributors",multiple:!0}],element:"contributor",fields:{name:dt(null,"name"),uri:dt(null,"uri"),email:dt(null,"email")},namespace:Dt},{aliases:[{path:"atomentry.categories",multiple:!0}],element:"category",fields:{term:He("term"),scheme:He("scheme"),label:He("label")},namespace:Dt},{element:"content",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.content"},{element:"rights",fields:{text:ct(),type:He("type","text")},namespace:Dt,path:"atomentry.rights"}],io={defaultType:"stream",element:"stream",fields:{from:He("from"),id:He("id"),lang:pt(),to:He("to"),version:He("version")},namespace:Vt,path:"stream",type:"stream",typeField:"action"},ro={element:"features",namespace:Vt,path:"features"},so={element:"error",fields:{alternateLanguageText:Ct($t,"text"),condition:kt($t,Object.values(Dr),Dr.UndefinedCondition),seeOtherHost:dt($t,Dr.SeeOtherHost),text:dt($t,"text")},namespace:Vt,path:"streamError"},oo=Object.values(Fr).map(e=>({aliases:["stanzaError","message.error","presence.error","iq.error"],defaultType:Ut,element:"error",fields:{alternateLanguageText:Ct(Gt,"text"),by:oi("by"),condition:kt(Gt,Object.values(Br),Br.UndefinedCondition),gone:dt(Gt,Br.Gone),redirect:dt(Gt,Br.Redirect),text:dt(Gt,"text"),type:He("type")},namespace:e,type:e,typeField:"streamType"})),ao=new Set(["from","id","lang","to","type","payloadType","error","streamType"]),co=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"iq",fields:{from:oi("from"),id:He("id"),lang:pt(),payloadType:{order:-1e4,importer(e,t){if("get"!==t.data.type&&"set"!==t.data.type)return;if(1!==e.children.filter(e=>"string"!=typeof e).length)return"invalid-payload-count";const n=Object.keys(t.data).filter(e=>!ao.has(e));return 1!==n.length?"unknown-payload":n[0]}},to:oi("to"),type:He("type")},namespace:e,path:"iq",type:e,typeField:"streamType"})),lo=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"message",fields:{from:oi("from"),id:He("id"),lang:pt(),to:oi("to")},namespace:e,path:"message",type:e,typeField:"streamType"})),uo=Object.values(Fr).map(e=>({childrenExportOrder:{error:2e5},defaultType:Ut,element:"presence",fields:{from:oi("from"),id:He("id"),lang:pt(),to:oi("to")},namespace:e,path:"presence",type:e,typeField:"streamType"})),po=[io,ro,so,...oo,...[{element:"mechanisms",fields:{mechanisms:jt(null,"mechanism")},namespace:zt,path:"features.sasl"},{element:"abort",namespace:zt,path:"sasl",type:"abort",typeField:"type"},{element:"auth",fields:{mechanism:He("mechanism"),value:ut("base64")},namespace:zt,path:"sasl",type:"auth",typeField:"type"},{element:"challenge",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"challenge",typeField:"type"},{element:"response",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"response",typeField:"type"},{element:"success",fields:{value:ut("base64")},namespace:zt,path:"sasl",type:"success",typeField:"type"},{element:"failure",fields:{alternateLanguageText:Ct(zt,"text"),condition:kt(zt,Object.values(Mr)),text:dt(zt,"text")},namespace:zt,path:"sasl",type:"failure",typeField:"type"}],...[{aliases:["features.tls"],defaultType:"start",element:"starttls",fields:{required:yt(null,"required")},namespace:Ht,path:"tls",type:"start",typeField:"type"},{element:"proceed",namespace:Ht,path:"tls",type:"proceed",typeField:"type"},{element:"failure",namespace:Ht,path:"tls",type:"failure",typeField:"type"}],...co,...lo,...uo,{aliases:["features.bind","iq.bind"],element:"bind",fields:{jid:dt(null,"jid"),resource:dt(null,"resource")},namespace:Bt}],ho=[hi({rosterPreApproval:yt("urn:xmpp:features:pre-approval","sub"),rosterVersioning:yt("urn:xmpp:features:rosterver","ver")}),ui({alternateLanguageBodies:Ct(null,"body"),alternateLanguageSubjects:Ct(null,"subject"),body:dt(null,"body"),hasSubject:yt(null,"subject"),parentThread:it(null,"thread","parent"),subject:dt(null,"subject"),thread:dt(null,"thread"),type:He("type")}),pi({alternateLanguageStatuses:Ct(null,"status"),priority:mt(null,"priority",0),show:dt(null,"show"),status:dt(null,"status"),type:He("type")}),{element:"query",fields:{version:He("ver",void 0,{emitEmpty:!0})},namespace:"jabber:iq:roster",path:"iq.roster"},{aliases:[{path:"iq.roster.items",multiple:!0}],element:"item",fields:{groups:jt(null,"group"),jid:oi("jid"),name:He("name"),pending:He("ask"),preApproved:We("approved"),subscription:He("subscription")},namespace:"jabber:iq:roster"}],fo=[{element:"open",fields:{from:He("from"),id:He("id"),lang:pt(),to:He("to"),version:He("version")},namespace:Wt,path:"stream",type:"open"},{element:"close",fields:{seeOtherURI:He("see-other-uri")},namespace:Wt,path:"stream",type:"close"}],mo=[{aliases:[{path:"message.forms",multiple:!0}],element:"x",fields:{instructions:Object.assign(Object.assign({},jt(null,"instructions")),{exportOrder:2}),reported:Object.assign(Object.assign({},Ot(null,"reported","dataformField",!0)),{exportOrder:3}),title:Object.assign(Object.assign({},dt(null,"title")),{exportOrder:1}),type:He("type")},namespace:Qt,optionalNamespaces:{xdv:xn},path:"dataform"},{aliases:[{path:"dataform.fields",multiple:!0},{path:"dataform.items.fields",multiple:!0}],element:"field",fields:{description:dt(null,"desc"),label:He("label"),name:He("var"),rawValues:Object.assign(Object.assign({},jt(null,"value")),{exporter:()=>null}),required:yt(null,"required"),type:He("type"),value:{importer(e,t){const n=e.getAttribute("type"),i=jt(Qt,"value").importer(e,t),r=i[0];switch(n){case zr.TextMultiple:case zr.ListMultiple:case zr.JIDMultiple:return i;case zr.Hidden:case zr.Fixed:return 1===i.length?r:i;case zr.Boolean:if(r)return"1"===r||"true"===r;break;default:return r}},exporter(e,t,n){const i=jt(null,"value");let r=[];const s=n.data&&n.data.rawValues?n.data.rawValues[0]:void 0;if("boolean"==typeof t)r="true"===s||"false"===s?[s]:[t?"1":"0"];else if(Array.isArray(t))for(const e of t)r.push(e.toString());else r=[t.toString()];i.exporter(e,r,Object.assign({},n,{namespace:Qt}))}}},namespace:Qt,path:"dataformField"},{aliases:[{path:"dataform.fields.options",multiple:!0}],element:"option",fields:{label:He("label"),value:dt(null,"value")},namespace:Qt},{aliases:[{path:"dataform.items",multiple:!0}],element:"item",namespace:Qt},{element:"validate",fields:{listMax:st(null,"list-range","max"),listMin:st(null,"list-range","min"),method:kt(null,["basic","open","range","regex"],"basic"),rangeMax:it(null,"range","max"),rangeMin:it(null,"range","min"),regex:dt(null,"regex"),type:He("datatype","xs:string")},namespace:xn,path:"dataform.fields.validation"}],go=[{aliases:["presence.legacyLastActivity","iq.lastActivity"],element:"query",fields:{seconds:Qe("seconds"),status:ct()},namespace:"jabber:iq:last"}],vo=[{element:"query",fields:{activeList:it(null,"active","name"),defaultList:it(null,"default","name")},namespace:Kt,path:"iq.privacy"},{aliases:[{path:"iq.privacy.lists",multiple:!0}],element:"list",fields:{name:He("name")},namespace:Kt},{aliases:[{path:"iq.privacy.lists.items",multiple:!0}],element:"item",fields:{action:He("action"),incomingPresence:yt(null,"presence-in"),iq:yt(null,"iq"),messages:yt(null,"message"),order:Qe("order"),outgoingPresence:yt(null,"presence-out"),type:He("type"),value:He("value")},namespace:Kt}],bo=[{aliases:["iq.disco","message.disco","features.disco"],childrenExportOrder:{identities:1,features:2,extensions:3},element:"query",fields:{features:Et(null,"feature","var"),node:He("node")},namespace:Xt,path:"disco",type:"info",typeField:"type"},{aliases:[{path:"disco.identities",selector:"info",multiple:!0}],element:"identity",fields:{category:He("category"),lang:pt(),name:He("name"),type:He("type")},namespace:Xt},{aliases:[{path:"disco.items",multiple:!0,selector:"items"}],element:"item",fields:{jid:oi("jid"),name:He("name"),node:He("node")},namespace:Yt},{aliases:[{path:"disco.items",multiple:!0,selector:"info"}],element:"item",fields:{category:oi("category"),lang:pt(),name:He("name"),type:He("type")},namespace:Xt},li(Qt,"x",[{path:"disco.extensions",multiple:!0,selector:"info"}]),li(an,"set",[{path:"disco.paging",selector:"items"}]),{aliases:["iq.disco","message.disco","features.disco"],element:"query",fields:{node:He("node")},namespace:Yt,path:"disco",type:"items",typeField:"type"}],yo=[ui({addresses:Ot(Zt,"addresses","extendedAddress",!0)}),pi({addresses:Ot(Zt,"addresses","extendedAddress",!0)}),{element:"address",fields:{alternateLanguageDescriptions:Ct(null,"desc"),delivered:We("delivered"),description:He("desc"),jid:oi("jid"),node:He("node"),type:He("type"),uri:He("uri")},namespace:Zt,path:"extendedAddress"}],_o=[li(Qt,"x",[{path:"iq.muc.form",selector:"configure"}]),{defaultType:"info",element:"x",fields:{password:dt(null,"password")},namespace:en,path:"presence.muc",type:"join",typeField:"type"},{aliases:[{path:"presence.muc.history",selector:"join"}],element:"history",fields:{maxCharacters:Qe("maxchars"),maxStanzas:Qe("maxstanzas"),seconds:Qe("seconds"),since:Xe("since")},namespace:en},{aliases:["presence.muc","message.muc"],defaultType:"info",element:"x",fields:{action:kt(null,["invite","decline","destroy"]),actor:Ot(null,"item","mucactor"),affiliation:it(null,"item","affiliation"),jid:ai(null,"item","jid"),nick:it(null,"item","nick"),password:dt(null,"password"),reason:St([{namespace:null,element:"item"},{namespace:null,element:"reason"}]),role:it(null,"item","role"),statusCodes:Et(null,"status","code")},namespace:rn,type:"info",typeField:"type",typeOrder:1},{element:"actor",fields:{jid:oi("jid"),nick:He("nick")},namespace:rn,path:"mucactor"},{element:"destroy",fields:{jid:oi("jid"),password:dt(null,"password"),reason:dt(null,"reason")},namespace:rn,path:"presence.muc.destroy"},{aliases:[{path:"message.muc.invite",multiple:!0}],element:"invite",fields:{continue:yt(null,"continue"),from:oi("from"),reason:dt(null,"reason"),thread:it(null,"continue","thread"),to:oi("to")},namespace:rn},{element:"decline",fields:{from:oi("from"),reason:dt(null,"reason"),to:oi("to")},namespace:rn,path:"message.muc",type:"decline"},{element:"query",namespace:tn,path:"iq.muc",type:"user-list",typeField:"type"},{aliases:[{path:"iq.muc.users",multiple:!0,selector:"user-list"}],element:"item",fields:{affiliation:He("affiliation"),jid:oi("jid"),nick:He("nick"),reason:dt(null,"reason"),role:He("role")},namespace:tn},{aliases:["iq.muc.users.actor"],element:"actor",fields:{jid:oi("jid"),nick:He("nick")},namespace:tn},{element:"query",namespace:nn,path:"iq.muc",type:"configure",typeField:"type"},{aliases:[{path:"iq.muc.destroy",selector:"configure"}],element:"destroy",fields:{jid:oi("jid"),password:dt(null,"password"),reason:dt(null,"reason")},namespace:nn},{element:"x",fields:{action:At("invite"),continue:We("continue"),jid:oi("jid"),legacyReason:ct(),password:He("password"),reason:He("reason"),thread:He("thread")},namespace:"jabber:x:conference",path:"message.muc",type:"direct-invite",typeOrder:2},{element:"unique",fields:{name:ct()},namespace:"http://jabber.org/protocol/muc#unique",path:"iq.muc",type:"unique"},ui({legacyMUC:{exporter(e,t,n){const i=n.registry?n.registry.export("message.muc",Object.assign(Object.assign({},t),{type:"direct-invite"})):void 0;i&&e.appendChild(i)},exportOrder:100001,importer(e,t){if(!Ce(e,rn,"x")[0])return;const n=Ce(e,"jabber:x:conference","x")[0];return n&&t.registry?t.registry.import(n,Object.assign(Object.assign({},t),{path:"message"})):void 0},importOrder:-1}})],So=[{aliases:["iq.ibb","message.ibb"],element:"open",fields:{ack:{importer:(e,t)=>"message"!==He("stanza","iq").importer(e,t),exporter(e,t,n){He("stanza").exporter(e,t?"iq":"message",n)}},blockSize:Qe("block-size"),sid:He("sid")},namespace:sn,type:"open",typeField:"action"},{aliases:["iq.ibb","message.ibb"],element:"close",fields:{sid:He("sid")},namespace:sn,type:"close",typeField:"action"},{aliases:["iq.ibb","message.ibb"],element:"data",fields:{data:ut("base64"),seq:Qe("seq"),sid:He("sid")},namespace:sn,type:"data",typeField:"action"}],wo=[{aliases:[{path:"bookmarkStorage",impliedType:!0},{path:"iq.privateStorage.bookmarks",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"storage",namespace:"storage:bookmarks",type:"storage:bookmarks",typeField:"itemType"},{aliases:[{path:"bookmarkStorage.rooms",multiple:!0}],element:"conference",fields:{autoJoin:We("autojoin"),jid:oi("jid"),name:He("name"),nick:dt(null,"nick"),password:dt(null,"password")},namespace:"storage:bookmarks"}],xo={element:"query",namespace:"jabber:iq:private",path:"iq.privateStorage"},To=[li(Qt,"x",["iq.command.form"]),fi({commandError:kt(on,["bad-action","bad-locale","bad-payload","bad-sessionid","malformed-action","session-expired"])}),{element:"command",fields:{action:He("action"),node:He("node"),sid:He("sessionid"),status:He("status")},namespace:on,path:"iq.command"},{element:"actions",fields:{complete:yt(null,"complete"),execute:He("execute"),next:yt(null,"next"),prev:yt(null,"prev")},namespace:on,path:"iq.command.availableActions"},{aliases:[{path:"iq.command.notes",multiple:!0}],element:"note",fields:{type:He("type"),value:ct()},namespace:on}],ko="vcardTemp.records";function Io(e,t){return{aliases:[{multiple:!0,path:ko}],element:e,fields:{value:ct()},namespace:"vcard-temp",type:t,typeField:"type"}}const jo=[{aliases:[{path:"iq.vcard"}],defaultType:"vcard-temp",element:"vCard",fields:{fullName:dt(null,"FN")},namespace:"vcard-temp",path:"vcardTemp",type:"vcard-temp",typeField:"format"},{element:"N",fields:{additional:Object.assign(Object.assign({},dt(null,"MIDDLE")),{order:3}),family:Object.assign(Object.assign({},dt(null,"FAMILY")),{order:1}),given:Object.assign(Object.assign({},dt(null,"GIVEN")),{order:2}),prefix:Object.assign(Object.assign({},dt(null,"PREFIX")),{order:4}),suffix:Object.assign(Object.assign({},dt(null,"SUFFIX")),{order:5})},namespace:"vcard-temp",path:"vcardTemp.name"},Io("NICKNAME","nickname"),Io("BDAY","birthday"),Io("JABBERID","jid"),Io("TZ","timezone"),Io("TITLE","title"),Io("ROLE","role"),Io("URL","url"),Io("NOTE","note"),Io("SORT-STRING","sort"),Io("UID","uid"),Io("REV","revision"),Io("PRODID","productId"),Io("DESC","description"),{aliases:[{multiple:!0,path:ko}],element:"EMAIL",fields:{preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"],["internet","INTERNET"]]),value:dt(null,"USERID")},namespace:"vcard-temp",type:"email"},{aliases:[{path:ko,multiple:!0}],element:"ORG",fields:{units:Object.assign(Object.assign({},jt(null,"ORGUNIT")),{order:2}),value:Object.assign(Object.assign({},dt(null,"ORGNAME")),{order:1})},namespace:"vcard-temp",type:"organization",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"ADR",fields:{city:dt(null,"LOCALITY"),code:dt(null,"PCODE"),country:dt(null,"CTRY"),pobox:dt(null,"POBOX"),preferred:yt(null,"PREF"),region:dt(null,"REGION"),street:dt(null,"STREET"),street2:dt(null,"EXTADD"),types:Rt(null,[["home","HOME"],["work","WORK"],["domestic","DOM"],["international","INTL"],["postal","POSTAL"],["parcel","PARCEL"]])},namespace:"vcard-temp",type:"address",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"LABEL",fields:{lines:jt(null,"LINE"),preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"]])},namespace:"vcard-temp",type:"addressLabel",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"TEL",fields:{preferred:yt(null,"PREF"),types:Rt(null,[["home","HOME"],["work","WORK"],["cell","CELL"],["fax","FAX"],["voice","VOICE"],["msg","MSG"]]),value:dt(null,"NUMBER","",!0)},namespace:"vcard-temp",type:"tel",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"PHOTO",fields:{data:dt(null,"BINVAL"),mediaType:dt(null,"TYPE"),url:dt(null,"EXTVAL")},namespace:"vcard-temp",type:"photo",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"LOGO",fields:{data:dt(null,"BINVAL"),mediaType:dt(null,"TYPE"),url:dt(null,"EXTVAL")},namespace:"vcard-temp",type:"logo",typeField:"type"},{aliases:[{multiple:!0,path:ko}],element:"CATEGORIES",fields:{value:jt(null,"KEYWORD")},namespace:"vcard-temp",type:"categories",typeField:"type"}],Eo=[li(Qt,"x",["iq.search.form"]),li(an,"set",["iq.search.paging"]),{element:"query",fields:{email:dt(null,"email"),familyName:dt(null,"last"),givenName:dt(null,"first"),instructions:dt(null,"instructions"),nick:dt(null,"nick")},namespace:"jabber:iq:search",path:"iq.search"},{aliases:[{path:"iq.search.items",multiple:!0}],element:"item",fields:{email:dt(null,"email"),familyName:dt(null,"last"),givenName:dt(null,"first"),jid:oi("jid"),nick:dt(null,"nick")},namespace:"jabber:iq:search"}],No={aliases:["iq.pubsub.paging"],element:"set",fields:{after:dt(null,"after"),before:dt(null,"before"),count:mt(null,"count"),first:dt(null,"first"),firstIndex:st(null,"first","index"),index:mt(null,"index"),last:dt(null,"last"),max:mt(null,"max")},namespace:an,path:"paging"},Co={configurable:yt(null,"subscribe-options"),configurationRequired:xt([{namespace:null,element:"subscribe-options"},{namespace:null,element:"required"}]),jid:oi("jid"),node:He("node"),state:He("subscription"),subid:He("subid")},Ro={node:He("node")},Oo=[{aliases:["pubsub","iq.pubsub","message.pubsub"],childrenExportOrder:{configure:0,create:100,publish:100,subscribe:100,subscriptionOptions:0},defaultType:"user",element:"pubsub",fields:{publishOptions:Ot(null,"publish-options","dataform")},namespace:cn,type:"user",typeField:"context"},{aliases:["pubsub","iq.pubsub","message.pubsub"],defaultType:"user",element:"pubsub",fields:{purge:it(null,"purge","node")},namespace:pn,type:"owner",typeField:"context"},li(Qt,"x",["iq.pubsub.configure.form","iq.pubsub.defaultConfiguration.form","iq.pubsub.defaultSubscriptionOptions.form","iq.pubsub.subscriptionOptions.form","message.pubsub.configuration.form"]),li(an,"set",["iq.pubsub.fetch.paging"]),fi({pubsubError:kt(ln,Object.values(Gr)),pubsubUnsupportedFeature:it(ln,"unsupported","feature")}),{element:"subscribe",fields:{jid:oi("jid"),node:He("node")},namespace:cn,path:"iq.pubsub.subscribe"},{element:"unsubscribe",fields:{jid:oi("jid"),node:He("node"),subid:He("subid")},namespace:cn,path:"iq.pubsub.unsubscribe"},{element:"options",fields:{jid:oi("jid"),node:He("node"),subid:He("subid")},namespace:cn,path:"iq.pubsub.subscriptionOptions"},{aliases:[{path:"iq.pubsub.subscriptions",selector:"user",impliedType:!0}],element:"subscriptions",fields:{jid:oi("jid"),node:He("node")},namespace:cn,type:"user"},{aliases:[{path:"iq.pubsub.subscriptions",selector:"owner",impliedType:!0}],element:"subscriptions",fields:{jid:oi("jid"),node:He("node")},namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.subscription",selector:"owner"},{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"owner"}],element:"subscription",fields:Co,namespace:cn},{aliases:[{path:"iq.pubsub.subscription",selector:"user"},{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"user"}],element:"subscription",fields:Co,namespace:cn,type:"user"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.subscriptions.items",selector:"owner"}],element:"subscription",fields:Co,namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.affiliations",selector:"user",impliedType:!0},{path:"message.pubsub.affiliations",selector:"user",impliedType:!0}],element:"affiliations",fields:Ro,namespace:cn,type:"user"},{aliases:[{path:"iq.pubsub.affiliations",selector:"owner",impliedType:!0}],element:"affiliations",fields:Ro,namespace:pn,type:"owner"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.affiliations.items",selector:"user"},{impliedType:!0,multiple:!0,path:"message.pubsub.affiliations.items",selector:"user"}],element:"affiliation",fields:{affiliation:He("affiliation"),jid:oi("jid"),node:He("node")},namespace:cn,type:"user"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.pubsub.affiliations.items",selector:"owner"}],element:"affiliation",fields:{affiliation:He("affiliation"),jid:oi("jid"),node:He("node")},namespace:pn,type:"owner"},{element:"create",fields:Ro,namespace:cn,path:"iq.pubsub.create"},{aliases:[{path:"iq.pubsub.destroy",selector:"owner"}],element:"delete",fields:{node:He("node"),redirect:it(null,"redirect","uri")},namespace:pn},{aliases:[{path:"iq.pubsub.configure",selector:"owner",impliedType:!0}],element:"configure",fields:Ro,namespace:pn,type:"owner"},{aliases:[{path:"iq.pubsub.configure",selector:"user",impliedType:!0}],element:"configure",fields:Ro,namespace:cn,type:"user"},{element:"default",fields:{node:He("node")},namespace:cn,path:"iq.pubsub.defaultSubscriptionOptions"},{element:"default",fields:{},namespace:pn,path:"iq.pubsub.defaultConfiguration"},{element:"publish",fields:Ro,namespace:cn,path:"iq.pubsub.publish"},{element:"retract",fields:{id:it(null,"item","id"),node:He("node"),notify:We("notify")},namespace:cn,path:"iq.pubsub.retract"},{element:"items",fields:{max:Qe("max_items"),node:He("node")},namespace:cn,path:"iq.pubsub.fetch"},{aliases:["pubsubitem","iq.pubsub.publish.item",{multiple:!0,path:"iq.pubsub.fetch.items"}],element:"item",fields:{id:He("id"),publisher:oi("publisher")},namespace:cn},{element:"event",fields:{eventType:kt(null,["purge","delete","subscription","configuration","items"])},namespace:un,path:"message.pubsub",type:"event",typeField:"context"},{aliases:[{path:"message.pubsub.items.published",multiple:!0}],element:"item",fields:{id:He("id"),publisher:oi("publisher")},namespace:un,path:"pubsubeventitem"},{element:"purge",fields:Ro,namespace:un,path:"message.pubsub.purge"},{element:"delete",fields:{node:He("node"),redirect:it(null,"redirect","uri")},namespace:un,path:"message.pubsub.delete"},{aliases:[{path:"message.pubsub.subscription",selector:"event",impliedType:!0}],element:"subscription",fields:{expires:(Ao="expiry",{importer(e){const t=e.getAttribute(Ao);return"presence"===t?t:t?new Date(t):void 0},exporter(e,t){let n;n="string"==typeof t?t:t.toISOString(),e.setAttribute(Ao,n)}}),jid:oi("jid"),node:He("node"),subid:He("subid"),type:He("subscription")},namespace:un,type:"event"},{element:"configuration",fields:Ro,namespace:un,path:"message.pubsub.configuration"},{element:"items",fields:{node:He("node"),retracted:Et(null,"retract","id")},namespace:un,path:"message.pubsub.items"}];var Ao;const Po=[{element:"query",fields:{activate:dt(null,"activate"),address:He("dstaddr"),candidateUsed:ai(null,"streamhost-used","jid"),mode:He("mode","tcp"),sid:He("sid"),udpSuccess:it(null,"udpsuccess","dstaddr")},namespace:dn,path:"iq.socks5"},{aliases:[{multiple:!0,path:"iq.socks5.candidates"}],element:"streamhost",fields:{host:He("host"),jid:oi("jid"),port:Qe("port"),uri:He("uri")},namespace:dn}],qo=[{aliases:[{multiple:!0,path:"message.links"}],element:"x",fields:{description:dt(null,"desc"),url:dt(null,"url")},namespace:hn},{element:"query",fields:{description:dt(null,"desc"),url:dt(null,"url")},namespace:"jabber:iq:oob",path:"iq.transferLink"}],Lo={element:"html",fields:{alternateLanguageBodies:qt(fn,"body","xhtmlim"),body:Pt(fn,"body","xhtmlim")},namespace:mn,path:"message.html"},Fo=[hi({inbandRegistration:yt("http://jabber.org/features/iq-register","register")}),li(Qt,"x",["iq.account.form"]),li(hn,"x",["iq.account.registrationLink"]),{element:"query",fields:{address:dt(null,"address"),date:ft(null,"date"),email:dt(null,"email"),familyName:dt(null,"last"),fullName:dt(null,"name"),givenName:dt(null,"first"),instructions:dt(null,"instructions"),key:dt(null,"key"),locality:dt(null,"city"),misc:dt(null,"misc"),nick:dt(null,"nick"),password:dt(null,"password"),phone:dt(null,"phone"),postalCode:dt(null,"zip"),region:dt(null,"state"),registered:yt(null,"registered"),remove:yt(null,"remove"),text:dt(null,"text"),uri:dt(null,"uri"),username:dt(null,"username")},namespace:"jabber:iq:register",path:"iq.account"}],Mo={aliases:[{path:"message.geoloc",impliedType:!0},{path:"dataform.fields.geoloc",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"geoloc",fields:{accuracy:gt(null,"accuracy"),altitude:gt(null,"alt"),altitudeAccuracy:gt(null,"altaccuracy"),area:dt(null,"area"),building:dt(null,"building"),country:dt(null,"country"),countryCode:dt(null,"countrycode"),datum:dt(null,"datum"),description:dt(null,"description"),error:gt(null,"error"),floor:dt(null,"floor"),heading:gt(null,"bearing"),lang:pt(),latitude:gt(null,"lat"),locality:dt(null,"locality"),longitude:gt(null,"lon"),postalCode:dt(null,"postalcode"),region:dt(null,"region"),room:dt(null,"room"),speed:gt(null,"speed"),street:dt(null,"street"),text:dt(null,"text"),timestamp:ft(null,"timestamp"),tzo:bt(null,"tzo"),uri:dt(null,"uri")},namespace:gn,type:gn},Do=[{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"data",fields:{data:ut("base64")},namespace:vn,path:"avatar",type:vn,typeField:"itemType"},{aliases:[{path:"avatar",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"metadata",namespace:bn,type:bn,typeField:"itemType",childrenExportOrder:{versions:1,pointers:2}},{aliases:[{multiple:!0,path:"avatar.versions",selector:bn}],element:"info",fields:{bytes:Qe("bytes"),height:Qe("height"),id:He("id"),mediaType:He("type"),uri:He("url"),width:Qe("width")},namespace:bn},{aliases:[{multiple:!0,path:"avatar.pointers",selector:bn}],element:"pointer",fields:{bytes:Qe("bytes"),height:Qe("height"),id:He("id"),mediaType:He("type"),width:Qe("width")},namespace:bn}];var Bo=ui({chatState:kt(yn,Object.values(Vr))});const Uo={element:"query",fields:{name:dt(null,"name"),os:dt(null,"os"),version:dt(null,"version")},namespace:"jabber:iq:version",path:"iq.softwareVersion"},zo={aliases:[{path:"message.mood",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"mood",fields:{alternateLanguageText:Ct(null,"text"),text:dt(null,"text"),value:kt(null,Yr)},namespace:_n,type:_n},Jo={aliases:[{path:"activity",impliedType:!0},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"activity",fields:{activity:It(null,Zr,es),alternateLanguageText:Ct(null,"text"),text:dt(null,"text")},namespace:Sn,type:Sn},Go={element:"handshake",fields:{value:ut("hex")},namespace:"jabber:component:accept",path:"handshake"},Vo={aliases:[{path:"presence.legacyCapabilities",multiple:!0},{path:"features.legacyCapabilities",multiple:!0}],element:"c",fields:{algorithm:He("hash"),legacy:At(!0),node:He("node"),value:He("ver")},namespace:"http://jabber.org/protocol/caps"},$o={aliases:[{impliedType:!0,path:"tune"},{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"tune",fields:{artist:dt(null,"artist"),length:mt(null,"length"),rating:mt(null,"rating"),source:dt(null,"source"),title:dt(null,"title"),track:dt(null,"track"),uri:dt(null,"uri")},namespace:wn,type:wn},Ho=["dataformLayout",{multiple:!0,path:"dataformLayout.contents"},{multiple:!0,path:"dataform.layout.contents"}],Wo=[{aliases:[{multiple:!0,path:"dataform.layout"}],element:"page",fields:{label:He("label")},namespace:jn},{aliases:Ho,element:"section",fields:{label:He("label")},namespace:jn,type:"section",typeField:"type"},{aliases:Ho,element:"text",fields:{value:ct()},namespace:jn,type:"text",typeField:"type"},{aliases:Ho,element:"fieldref",fields:{field:He("var")},namespace:jn,type:"fieldref",typeField:"type"},{aliases:Ho,element:"reportedref",namespace:jn,type:"reportedref",typeField:"type"}],Qo={element:"body",fields:{acceptMediaTypes:He("accept"),ack:Qe("ack"),authId:He("authid"),characterSets:He("charsets"),condition:He("condition"),from:oi("from"),key:He("key"),lang:pt(),maxClientRequests:Qe("requests"),maxHoldOpen:Qe("hold"),maxInactivityTime:Qe("inactivity"),maxSessionPause:Qe("maxpause"),maxWaitTime:Qe("wait"),mediaType:He("content"),minPollingInterval:Qe("polling"),newKey:He("newkey"),pauseSession:Qe("pause"),report:Qe("report"),rid:Qe("rid"),route:He("string"),seeOtherURI:dt(null,"uri"),sid:He("sid"),stream:He("stream"),time:Qe("time"),to:oi("to"),type:He("type"),version:He("ver"),xmppRestart:Ze("xmpp","urn:xmpp:xbosh","restart",void 0,{writeValue:e=>e?"true":"false"}),xmppRestartLogic:Ze("xmpp","urn:xmpp:xbosh","restartlogic",void 0,{writeValue:e=>e?"true":"false"}),xmppVersion:Ye("xmpp","urn:xmpp:xbosh","version")},namespace:Tn,path:"bosh"},Ko=[ui({headers:Ot(kn,"headers","header",!0)}),pi({headers:Ot(kn,"headers","header",!0)}),{element:"header",fields:{name:He("name"),value:ct()},namespace:kn,path:"header"}],Xo=[{element:"compression",fields:{methods:jt(null,"method")},namespace:"http://jabber.org/features/compress",path:"features.compression"},{element:"compress",fields:{method:dt(null,"method")},namespace:In,path:"compression",type:"start",typeField:"type"},{aliases:["error.compressionError"],element:"failure",fields:{condition:kt(null,["unsupported-method","setup-failed","processing-failed"])},namespace:In,path:"compression",type:"failure",typeField:"type"},{element:"compressed",namespace:In,path:"compression",type:"success",typeField:"type"}],Yo=[ui({rosterExchange:Ot(En,"x","rosterExchange",!0)}),di({rosterExchange:Ot(En,"x","rosterExchange",!0)}),{element:"item",fields:{action:He("action"),groups:jt(null,"group"),jid:oi("jid"),name:He("name")},namespace:En,path:"rosterExchange"}];var Zo=pi({vcardAvatar:{importer(e){const t=Ce(e,"vcard-temp:x:update","x");if(!t.length)return;const n=Ce(t[0],"vcard-temp:x:update","photo");return!n.length||n[0].getText()},exporter(e,t){const n=Re(e,"vcard-temp:x:update","x");if(""===t)Re(n,"vcard-temp:x:update","photo");else{if(!0===t)return;if(t){Re(n,"vcard-temp:x:update","photo").children.push(t)}}}}});const ea=[ui({captcha:Ot("urn:xmpp:captcha","captcha","dataform")}),di({captcha:Ot("urn:xmpp:captcha","captcha","dataform")})],ta=[fi({jingleError:kt("urn:xmpp:jingle:errors:1",Object.values(Kr))}),{element:"jingle",fields:{action:He("action"),initiator:oi("initiator"),responder:oi("responder"),sid:He("sid")},namespace:Cn,path:"iq.jingle"},{aliases:[{multiple:!0,path:"iq.jingle.contents"}],element:"content",fields:{creator:He("creator"),disposition:He("disposition","session"),name:He("name"),senders:He("senders","both")},namespace:Cn},{element:"reason",fields:{alternativeSession:dt(null,"alternative-session"),condition:kt(null,Object.values(Xr)),text:dt(null,"text")},namespace:Cn,path:"iq.jingle.reason"}];function na(){return{importer(e,t){let n=Ce(e,Gn,"rtcp-fb");const i=He("type").importer,r=He("subtype").importer,s=He("value").importer,o=[];for(const e of n){const n=i(e,t),s=r(e,t);o.push(s?{type:n,parameter:s}:{type:n})}n=Ce(e,Gn,"rtcp-fb-trr-int");for(const e of n){const n=s(e,t);o.push(n?{type:"trr-int",parameter:n}:{type:"trr-int"})}return o},exporter(e,t,n){const i=He("type").exporter,r=He("subtype").exporter,s=He("value").exporter;for(const o of t){let t;"trr-int"===o.type?(t=je(Gn,"rtcp-fb-trr-int",n.namespace,e),o.parameter&&s(t,o.parameter,n)):(t=je(Gn,"rtcp-fb",n.namespace,e),i(t,o.type,n),o.parameter&&r(t,o.parameter,n)),e.appendChild(t)}}}}const ia="iq.jingle.info",ra=[{aliases:["iq.jingle.contents.application"],childrenExportOrder:{codecs:4,encryption:5,headerExtensions:6,sourceGroups:8,sources:7,streams:9},element:"description",fields:{media:He("media"),rtcpFeedback:Object.assign(Object.assign({},na()),{exportOrder:3}),rtcpMux:Object.assign(Object.assign({},yt(null,"rtcp-mux")),{exportOrder:1}),rtcpReducedSize:Object.assign(Object.assign({},yt(null,"rtcp-reduced-size")),{exportOrder:2}),ssrc:He("ssrc")},namespace:Rn,optionalNamespaces:{rtcpf:Gn,rtph:Vn},type:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.headerExtensions",selector:Rn}],element:"rtp-hdrext",fields:{id:Qe("id"),senders:He("senders"),uri:He("uri")},namespace:Vn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.codecs",selector:Rn},"rtpcodec"],element:"payload-type",fields:{channels:Qe("channels"),clockRate:Qe("clockrate"),id:He("id"),maxptime:Qe("maxptime"),name:He("name"),parameters:Lt(Rn,"parameter","name","value"),ptime:Qe("ptime"),rtcpFeedback:na()},namespace:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.sources",selector:Rn}],element:"source",fields:{parameters:Lt("urn:xmpp:jingle:apps:rtp:ssma:0","parameter","name","value"),ssrc:He("ssrc")},namespace:"urn:xmpp:jingle:apps:rtp:ssma:0"},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.sourceGroups",selector:Rn}],element:"ssrc-group",fields:{semantics:He("semantics"),sources:Et(null,"source","ssrc")},namespace:"urn:xmpp:jingle:apps:rtp:ssma:0"},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.streams",selector:Rn}],element:"stream",fields:{id:He("id"),track:He("track")},namespace:"urn:xmpp:jingle:apps:rtp:msid:0"},{aliases:[{path:"iq.jingle.contents.application.encryption",selector:Rn}],element:"encryption",fields:{required:We("required")},namespace:Rn},{aliases:[{multiple:!0,path:"iq.jingle.contents.application.encryption.sdes",selector:Rn}],element:"crypto",fields:{cryptoSuite:He("crypto-suite"),keyParameters:He("key-params"),sessionParameters:He("session-params"),tag:Qe("tag")},namespace:Rn},{aliases:[{path:"iq.jingle.contents.application.encryption.zrtp",selector:Rn}],element:"zrtp-hash",fields:{value:ut("hex"),version:He("version")},namespace:Rn},{element:"mute",fields:{creator:He("creator"),name:He("name")},namespace:On,path:ia,type:ns},{element:"unmute",fields:{creator:He("creator"),name:He("name")},namespace:On,path:ia,type:is},{element:"hold",namespace:On,path:ia,type:rs},{element:"unhold",namespace:On,path:ia,type:ss},{element:"active",namespace:On,path:ia,type:os},{element:"ringing",namespace:On,path:ia,type:as}],sa=[ui({nick:dt(An,"nick")}),pi({nick:dt(An,"nick")}),{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"nick",fields:{nick:ct()},namespace:An,type:An}],oa=e=>[{element:"transport",fields:{gatheringComplete:yt(null,"gathering-complete"),password:He("pwd"),usernameFragment:He("ufrag")},namespace:e,path:"iq.jingle.contents.transport",type:e,typeField:"transportType"},{aliases:[{impliedType:!0,path:"iq.jingle.contents.transport.remoteCandidate",selector:e}],element:"remote-candidate",fields:{component:Qe("component"),ip:He("ip"),port:Qe("port")},namespace:e,type:e,typeField:"transportType"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:e}],element:"candidate",fields:{component:Qe("component"),foundation:He("foundation"),generation:Qe("generation"),id:He("id"),ip:He("ip"),network:Qe("network"),port:Qe("port"),priority:Qe("priority"),protocol:He("protocol"),relatedAddress:He("rel-addr"),relatedPort:He("rel-port"),tcpType:He("tcptype"),type:He("type")},namespace:e,type:e,typeField:"transportType"}],aa=[...oa(ni),...oa(Pn)],ca=[{element:"transport",fields:{gatheringComplete:yt(null,"gathering-complete"),password:He("pwd"),usernameFragment:He("ufrag")},namespace:qn,path:"iq.jingle.contents.transport",type:qn,typeField:"transportType"},{aliases:[{impliedType:!0,multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:qn}],element:"candidate",fields:{component:Qe("component"),foundation:He("foundation"),generation:Qe("generation"),id:He("id"),ip:He("ip"),port:Qe("port"),type:He("type")},namespace:qn,type:qn,typeField:"transportType"}],la=[{element:"request",namespace:"urn:xmpp:receipts",path:"message.receipt",type:"request",typeField:"type"},{element:"received",fields:{id:He("id")},namespace:"urn:xmpp:receipts",path:"message.receipt",type:"received",typeField:"type"}],ua=[{element:"invisible",fields:{probe:We("probe")},namespace:"urn:xmpp:invisible:0",path:"iq.visibility",type:"invisible",typeField:"type"},{element:"visible",namespace:"urn:xmpp:invisible:0",path:"iq.visibility",type:"visible"}],pa=[fi({blocked:yt("urn:xmpp:blocking:errors","blocked")}),{element:"blocklist",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"list",typeField:"action"},{element:"block",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"block",typeField:"action"},{element:"unblock",fields:{jids:Et(null,"item","jid")},namespace:"urn:xmpp:blocking",path:"iq.blockList",type:"unblock",typeField:"action"}],da=[hi({streamManagement:yt(Ln,"sm")}),{element:"a",fields:{handled:Qe("h")},namespace:Ln,path:"sm",type:"ack",typeField:"type"},{element:"r",namespace:Ln,path:"sm",type:"request",typeField:"type"},{element:"enable",fields:{allowResumption:We("resume")},namespace:Ln,path:"sm",type:"enable",typeField:"type"},{element:"enabled",fields:{id:He("id"),resume:We("resume")},namespace:Ln,path:"sm",type:"enabled",typeField:"type"},{element:"resume",fields:{handled:Qe("h"),previousSession:He("previd")},namespace:Ln,path:"sm",type:"resume",typeField:"type"},{element:"resumed",fields:{handled:Qe("h"),previousSession:He("previd")},namespace:Ln,path:"sm",type:"resumed",typeField:"type"},{element:"failed",fields:{handled:Qe("h")},namespace:Ln,path:"sm",type:"failed",typeField:"type"}];var ha=di({ping:yt("urn:xmpp:ping","ping")});const fa={element:"time",fields:{tzo:bt(null,"tzo"),utc:ft(null,"utc")},namespace:"urn:xmpp:time",path:"iq.time"},ma={aliases:["message.delay","presence.delay"],element:"delay",fields:{from:oi("from"),reason:ct(),timestamp:Xe("stamp")},namespace:Fn},ga={2:"urn:xmpp:extdisco:2",1:"urn:xmpp:extdisco:1"},va=[];for(const[e,t]of Object.entries(ga))va.push({aliases:["iq.externalServiceCredentials"],defaultType:"2",element:"credentials",fields:{expires:at(null,"service","expires"),host:it(null,"service","host"),name:it(null,"service","name"),password:it(null,"service","password"),port:st(null,"service","port"),restricted:rt(null,"service","restricted"),transport:it(null,"service","transport"),type:it(null,"service","type"),username:it(null,"service","username")},namespace:t,type:e,typeField:"version"},{aliases:["iq.externalServices"],defaultType:"2",element:"services",fields:{type:He("type")},namespace:t,type:e,typeField:"version"},{aliases:[{path:"iq.externalServices.services",multiple:!0}],defaultType:"2",element:"service",fields:{expires:Xe("expires"),host:He("host"),name:He("name"),password:He("password"),port:Qe("port"),restricted:We("restricted"),transport:He("transport"),type:He("type"),username:He("username")},namespace:t,type:e,typeField:"version"});const ba=[{element:"media",fields:{height:Qe("height"),width:Qe("width")},namespace:"urn:xmpp:media-element",path:"dataform.fields.media"},{aliases:[{multiple:!0,path:"dataform.fields.media.sources"}],element:"uri",fields:{mediaType:He("type"),uri:ct()},namespace:"urn:xmpp:media-element"}];var ya=ui({requestingAttention:yt("urn:xmpp:attention:0","attention")});const _a={aliases:["iq.bits",{path:"message.bits",multiple:!0},{path:"presence.bits",multiple:!0},{path:"iq.jingle.bits",multiple:!0}],element:"data",fields:{cid:He("cid"),data:ut("base64"),maxAge:Qe("max-age"),mediaType:He("type")},namespace:Mn};let Sa=[li(Hn,"hash",[{path:"file.hashes",multiple:!0},{path:"file.range.hashes",multiple:!0}]),li("urn:xmpp:hashes:1","hash",[{path:"file.hashes",multiple:!0},{path:"file.range.hashes",multiple:!0}]),li(Hn,"hash-used",[{path:"file.hashesUsed",multiple:!0}]),li("urn:xmpp:thumbs:1","thumbnail",[{path:"file.thumbnails",multiple:!0}])];for(const e of["urn:xmpp:jingle:apps:file-transfer:4",Dn])Sa=Sa.concat([{aliases:["file",{impliedType:!0,path:"iq.jingle.contents.application.file",selector:e},{impliedType:!0,path:"iq.jingle.info.file",selector:`{${e}}checksum`}],defaultType:Dn,element:"file",fields:{date:ft(null,"date"),description:dt(null,"desc"),mediaType:dt(null,"media-type"),name:dt(null,"name"),size:mt(null,"size")},namespace:e,type:e,typeField:"version"},{aliases:[{impliedType:!0,path:"file.range",selector:e}],defaultType:Dn,element:"range",fields:{length:Qe("length"),offset:Qe("offset",0)},namespace:e,type:e,typeField:"version"},{element:"description",namespace:e,path:"iq.jingle.contents.application",type:e,typeField:"applicationType"},{element:"received",fields:{creator:He("creator"),name:He("name")},namespace:e,path:"iq.jingle.info",type:`{${e}}received`,typeField:"infoType"},{element:"checksum",fields:{creator:He("creator"),name:He("name")},namespace:e,path:"iq.jingle.info",type:`{${e}}checksum`,typeField:"infoType"}]);var wa=Sa;const xa={element:"description",namespace:Bn,path:"iq.jingle.contents.application",type:Bn,typeField:"applicationType"},Ta=[{element:"transport",fields:{activated:it(null,"activated","cid"),address:He("dstaddr"),candidateError:yt(null,"candidate-error"),candidateUsed:it(null,"candidate-used","cid"),mode:He("mode","tcp"),proxyError:yt(null,"proxy-error"),sid:He("sid")},namespace:Un,path:"iq.jingle.contents.transport",type:Un,typeField:"transportType"},{aliases:[{multiple:!0,path:"iq.jingle.contents.transport.candidates",selector:Un}],element:"candidate",fields:{cid:He("cid"),host:He("host"),jid:oi("jid"),port:Qe("port"),priority:Qe("priority"),type:He("type"),uri:He("uri")},namespace:Un}],ka={element:"transport",fields:{ack:{importer:(e,t)=>"message"!==He("stanza","iq").importer(e,t),exporter(e,t,n){!1===t&&He("stanza").exporter(e,"message",n)}},blockSize:Qe("block-size"),sid:He("sid")},namespace:zn,path:"iq.jingle.contents.transport",type:zn,typeField:"transportType"},Ia=[li(Mn,"data",[{path:"iq.jingle.bits",multiple:!0}]),{element:"thumbnail",fields:{height:Qe("height"),mediaType:He("media-type"),uri:He("uri"),width:Qe("width")},namespace:"urn:xmpp:thumbs:1",path:"thumbnail"}],ja=[li($n,"forwarded",["message.carbon.forward"]),{element:"enable",namespace:Jn,path:"iq.carbons",type:"enable",typeField:"action"},{element:"disable",namespace:Jn,path:"iq.carbons",type:"disable",typeField:"action"},{element:"sent",namespace:Jn,path:"message.carbon",type:"sent",typeField:"type"},{element:"received",namespace:Jn,path:"message.carbon",type:"received",typeField:"type"}],Ea=[...Object.values(Fr).map(e=>li(e,"message",["forward.message"])),...Object.values(Fr).map(e=>li(e,"presence",["forward.presence"])),...Object.values(Fr).map(e=>li(e,"iq",["forward.iq"])),li(Fn,"delay",["forward.delay"]),{aliases:["message.forward"],element:"forwarded",namespace:$n,path:"forward"}],Na=[{defaultType:"2",element:"hash",fields:{algorithm:He("algo"),value:ut("base64"),version:At("2")},namespace:Hn,path:"hash",type:"2",typeField:"version"},{element:"hash-used",fields:{algorithm:He("algo"),version:At("2")},namespace:Hn,path:"hashUsed"},{element:"hash",fields:{algorithm:He("algo"),value:ut("hex"),version:At("1")},namespace:"urn:xmpp:hashes:1",path:"hash",type:"1",typeField:"version"}],Ca=[{element:"rtt",fields:{event:He("event","edit"),id:He("id"),seq:Qe("seq")},namespace:Qn,path:"message.rtt"},{aliases:[{path:"message.rtt.actions",multiple:!0}],element:"t",fields:{position:Qe("p"),text:ct()},namespace:Qn,type:"insert",typeField:"type"},{aliases:[{path:"message.rtt.actions",multiple:!0}],element:"e",fields:{length:Qe("n",1),position:Qe("p")},namespace:Qn,type:"erase",typeField:"type"},{aliases:[{multiple:!0,path:"message.rtt.actions"}],element:"w",fields:{duration:Qe("n",0)},namespace:Qn,type:"wait",typeField:"type"}];var Ra=ui({replace:it("urn:xmpp:message-correct:0","replace","id")});const Oa={2:"urn:xmpp:mam:2",1:"urn:xmpp:mam:1"},Aa=[li(Qt,"x",["iq.archive.form"]),li($n,"forwarded",["message.archive.item"]),li(an,"set",["iq.archive.paging"])];for(const[e,t]of Object.entries(Oa))Aa.push({defaultType:"query",defaultVersion:"2",element:"query",fields:{node:He("node"),queryId:He("queryid")},namespace:t,path:"iq.archive",type:"query",typeField:"type",version:e,versionField:"version"},{element:"fin",fields:{complete:We("complete"),stable:We("stable")},namespace:t,path:"iq.archive",type:"result",version:e},{element:"prefs",fields:{default:He("default"),always:Tt([{namespace:null,element:"always"},{namespace:null,element:"jid"}]),never:Tt([{namespace:null,element:"never"},{namespace:null,element:"jid"}])},namespace:t,path:"iq.archive",type:"preferences",version:e},{element:"result",defaultType:"2",fields:{id:He("id"),queryId:He("queryid")},namespace:t,path:"message.archive",type:e,typeField:"version"});const Pa="message.marker";const qa=[to,no,po,ho,fo,mo,go,vo,bo,yo,_o,So,wo,xo,To,jo,Eo,No,Oo,Po,qo,Lo,Fo,Mo,Do,Bo,Uo,zo,Jo,Go,Vo,$o,Qo,Ko,Xo,Wo,Yo,Zo,ea,ta,ra,sa,aa,ca,la,ua,pa,da,ha,fa,ma,va,ba,ya,_a,wa,xa,Ta,ka,Ia,ja,Ea,Na,Ca,Ra,Aa,[pi({hats:Ot(Kn,"hats","hat",!0)}),{element:"hat",fields:{id:He("name"),name:He("displayName")},namespace:Kn,path:"hat"}],pi({idleSince:ft("urn:xmpp:idle:1","since")}),{aliases:[{multiple:!0,path:"iq.jingle.contents.transport.fingerprints",selector:Pn},{multiple:!0,path:"iq.jingle.contents.transport.fingerprints",selector:ni},{multiple:!0,path:"iq.jingle.contents.application.encryption.dtls",selector:Rn}],element:"fingerprint",fields:{algorithm:He("hash"),setup:He("setup"),value:ct()},namespace:"urn:xmpp:jingle:apps:dtls:0"},[{element:"markable",namespace:Xn,path:Pa,type:"markable",typeField:"type"},{element:"received",fields:{id:He("id")},namespace:Xn,path:Pa,type:"received"},{element:"displayed",fields:{id:He("id")},namespace:Xn,path:Pa,type:"displayed"},{element:"acknowledged",fields:{id:He("id")},namespace:Xn,path:Pa,type:"acknowledged"}],ui({processingHints:{importer(e){const t={};let n=!1;for(const i of e.children)if("string"!=typeof i&&i.getNamespace()===Yn)switch(i.getName()){case"no-copy":t.noCopy=!0,n=!0;break;case"no-permanent-store":t.noPermanentStore=!0,n=!0;break;case"no-store":t.noStore=!0,n=!0;break;case"store":t.store=!0,n=!0}return n?t:void 0},exporter(e,t,n){t.noCopy&&e.appendChild(je(Yn,"no-copy",n.namespace,e)),t.noPermanentStore&&e.appendChild(je(Yn,"no-permanent-store",n.namespace,e)),t.noStore&&e.appendChild(je(Yn,"no-store",n.namespace,e)),t.store&&e.appendChild(je(Yn,"store",n.namespace,e))}}}),[ui({json:vt(Zn,"json")}),{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"json",fields:{json:lt()},namespace:Zn,type:Zn},{aliases:[{path:"message.jsonPayloads",multiple:!0}],element:"payload",fields:{type:He("datatype"),data:vt(Zn,"json")},namespace:"urn:xmpp:json-msg:0"}],[{aliases:[{path:"iq.jingle.groups",multiple:!0}],element:"group",fields:{contents:Et(null,"content","name"),semantics:He("semantics")},namespace:"urn:xmpp:jingle:apps:grouping:0"}],{aliases:[{path:"iq.jingle.contents.transport.sctp",selector:Pn},{path:"iq.jingle.contents.transport.sctp",selector:ni}],element:"sctpmap",fields:{port:Qe("number"),protocol:He("protocol"),streams:He("streams")},namespace:"urn:xmpp:jingle:transports:dtls-sctp:1"},[{element:"active",namespace:"urn:xmpp:csi:0",path:"csi",type:"active",typeField:"state"},{element:"inactive",namespace:"urn:xmpp:csi:0",path:"csi",type:"inactive",typeField:"state"}],[li(Qt,"x",["iq.push.form","pushNotification.form"]),{element:"enable",fields:{jid:oi("jid"),node:He("node")},namespace:ei,path:"iq.push",type:"enable",typeField:"action"},{element:"disable",fields:{jid:oi("jid"),node:He("node")},namespace:ei,path:"iq.push",type:"disable",typeField:"action"},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"notification",namespace:ei,path:"pushNotification",type:ei,typeField:"itemType"}],[ui({originId:it("urn:xmpp:sid:0","origin-id","id")}),{aliases:[{path:"message.stanzaIds",multiple:!0}],element:"stanza-id",fields:{by:oi("by"),id:He("id")},namespace:"urn:xmpp:sid:0"}],[fi({httpUploadError:kt(ti,["file-too-large","retry"]),httpUploadMaxFileSize:wt([{namespace:ti,element:"file-too-large"},{namespace:ti,element:"max-file-size"}]),httpUploadRetry:at(ti,"retry","stamp")}),{element:"request",fields:{mediaType:He("content-type"),name:He("filename"),size:Qe("size")},namespace:ti,path:"iq.httpUpload",type:"request",typeField:"type"},{element:"slot",fields:{download:it(null,"get","url")},namespace:ti,path:"iq.httpUpload",type:"slot"},{aliases:[{path:"iq.httpUpload.upload",selector:"slot"}],element:"put",fields:{url:He("url")},namespace:ti},{aliases:[{path:"iq.httpUpload.upload.headers",multiple:!0}],element:"header",fields:{name:He("name"),value:ct()},namespace:ti}],{element:"encryption",fields:{id:He("namespace"),name:He("name")},namespace:"urn:xmpp:eme:0",path:"message.encryptionMethod"},[{aliases:["message.omemo"],element:"encrypted",fields:{payload:ht(null,"payload","base64")},namespace:ii,path:"omemo"},{element:"header",fields:{iv:ht(null,"iv","base64"),sid:Qe("sid")},namespace:ii,path:"omemo.header"},{aliases:[{path:"omemo.header.keys",multiple:!0}],element:"key",fields:{preKey:We("prekey"),rid:Qe("rid"),value:ut("base64")},namespace:ii},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"list",fields:{devices:Nt(null,"device","id")},namespace:ii,type:"eu.siacs.conversations.axolotl.devicelist",typeField:"itemType"},{element:"preKeyPublic",fields:{id:Qe("preKeyId"),value:ut("base64")},namespace:ii,path:"omemoPreKey"},{element:"signedPreKeyPublic",fields:{id:Qe("signedPreKeyId"),value:ut("base64")},namespace:ii,path:"omemoDevice.signedPreKeyPublic"},{aliases:[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}],element:"bundle",fields:{identityKey:ht(null,"identityKey","base64"),preKeys:Ot(null,"prekeys","omemoPreKey",!0),signedPreKeySignature:ht(null,"signedPreKeySignature","base64")},namespace:ii,path:"omemoDevice",type:"eu.siacs.conversations.axolotl.bundles",typeField:"itemType"}],[{element:"XRD",fields:{subject:dt(null,"Subject")},namespace:ri,path:"xrd"},{aliases:[{path:"xrd.links",multiple:!0}],element:"Link",fields:{href:He("href"),rel:He("rel"),type:He("type")},namespace:ri}]];var La=Object.freeze({__proto__:null,default:qa});class Fa{constructor(e){this.active=!1,this.maxRetries=5,this.stream=e,this.maxTimeout=1100*this.stream.maxWaitTime}send(e,t){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.rid=e,this.active=!0;let n=0;for(;n<=this.maxRetries;){n+=1;try{const e=yield xr(Zi(this.stream.url,{body:t,headers:{"Content-Type":this.stream.contentType},method:"POST"}),this.maxTimeout,()=>new Error("Request timed out"));if(!e.ok)throw new Error("HTTP Status Error: "+e.status);const n=yield e.text();return this.active=!1,n}catch(e){if(1===n)continue;if(n<this.maxRetries){const e=Math.min(this.maxTimeout,1e3*Math.pow(n,2));yield Tr(e+1e3*Math.random());continue}throw this.active=!1,e}}throw new Error("Request failed")}))}}class Ma extends l.Duplex{constructor(e,t,n){super({objectMode:!0}),this.rid=Math.floor(4294967295*Math.random()),this.sid="",this.maxHoldOpen=2,this.maxWaitTime=30,this.contentType="text/xml; charset=utf-8",this.channels=[new Fa(this),new Fa(this)],this.activeChannelID=0,this.queue=[],this.isEnded=!1,this.client=e,this.sm=t,this.stanzas=n,this.on("data",e=>{this.client.emit("stream:data",e.stanza,e.kind)}),this.on("end",()=>{this.isEnded=!0,clearTimeout(this.idleTimeout),this.client.transport===this&&this.client.emit("--transport-disconnected")})}_write(e,t,n){this.queue.push([e,n]),this.scheduleRequests()}_writev(e,t){this.queue.push([e.map(e=>e.chunk).join(""),t]),this.scheduleRequests()}_read(){}process(e){const t=new gi({acceptLanguages:this.config.acceptLanguages,allowComments:!1,lang:this.config.lang,registry:this.stanzas,rootKey:"bosh",wrappedStream:!0});t.on("error",e=>{const t={condition:Dr.InvalidXML};return this.client.emit("stream:error",t,e),this.send("error",t),this.disconnect()}),t.on("data",e=>{if("stream-start"===e.event)return this.stream=e.stanza,void("terminate"===e.stanza.type?(this.hasStream=!1,this.rid=void 0,this.sid=void 0,this.isEnded||(this.isEnded=!0,this.client.emit("bosh:terminate",e.stanza),this.client.emit("stream:end"),this.push(null))):this.hasStream||(this.hasStream=!0,this.stream=e.stanza,this.sid=e.stanza.sid||this.sid,this.maxWaitTime=e.stanza.maxWaitTime||this.maxWaitTime,this.client.emit("stream:start",e.stanza)));e.event||this.push({kind:e.kind,stanza:e.stanza})}),this.client.emit("raw","incoming",e),t.write(e),this.scheduleRequests()}connect(e){if(this.config=e,this.url=e.url,e.rid&&(this.rid=e.rid),e.sid&&(this.sid=e.sid),e.wait&&(this.maxWaitTime=e.wait),e.maxHoldOpen&&(this.maxHoldOpen=e.maxHoldOpen),this.sid)return this.hasStream=!0,this.stream={},this.client.emit("connected"),this.client.emit("session:prebind",this.config.jid),void this.client.emit("session:started");this._send({lang:e.lang,maxHoldOpen:this.maxHoldOpen,maxWaitTime:this.maxWaitTime,to:e.server,version:"1.6",xmppVersion:"1.0"})}restart(){this.hasStream=!1,this._send({to:this.config.server,xmppRestart:!0})}disconnect(e=!0){this.hasStream&&e?this._send({type:"terminate"}):(this.stream=void 0,this.sid=void 0,this.rid=void 0,this.client.emit("--transport-disconnected"))}send(e,t){var n;return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;if(t&&(i=null===(n=this.stanzas.export(e,t))||void 0===n?void 0:n.toString()),i)return new Promise((e,t)=>{this.write(i,"utf8",n=>n?t(n):e())})}))}get sendingChannel(){return this.channels[this.activeChannelID]}get pollingChannel(){return this.channels[0===this.activeChannelID?1:0]}toggleChannel(){this.activeChannelID=0===this.activeChannelID?1:0}_send(e,t=""){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isEnded)return;const n=this.rid++,i=this.stanzas.export("bosh",Object.assign(Object.assign({},e),{rid:n,sid:this.sid}));let r;r=t?[i.openTag(),t,i.closeTag()].join(""):i.toString(),this.client.emit("raw","outgoing",r),this.sendingChannel.send(n,r).then(e=>{this.process(e)}).catch(e=>{this.end(e)}),this.toggleChannel()}))}_poll(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(this.isEnded)return;const e=this.rid++,t=this.stanzas.export("bosh",{rid:e,sid:this.sid}).toString();this.client.emit("raw","outgoing",t),this.pollingChannel.send(e,t).then(e=>{this.process(e)}).catch(e=>{this.end(e)})}))}scheduleRequests(){clearTimeout(this.idleTimeout),this.idleTimeout=setTimeout(()=>{this.fireRequests()},10)}fireRequests(){if(!this.isEnded)if(this.queue.length)if(this.sendingChannel.active)this.scheduleRequests();else{const[e,t]=this.queue.shift();this._send({},e),t()}else!this.authenticated||this.channels[0].active||this.channels[1].active||this._poll()}}class Da extends l.Duplex{constructor(e,t,n){super({objectMode:!0}),this.sm=t,this.stanzas=n,this.closing=!1,this.client=e,this.on("data",e=>{this.client.emit("stream:data",e.stanza,e.kind)}),this.on("error",()=>{this.end()}),this.on("end",()=>{this.client.transport===this&&this.client.emit("--transport-disconnected")})}_read(){}_write(t,n,i){if(!this.socket||1!==this.socket.readyState)return i(new Error("Socket closed"));const r=e.from(t,"utf8").toString();this.client.emit("raw","outgoing",r),this.socket.send(r),i()}connect(t){this.config=t,this.hasStream=!1,this.closing=!1,this.parser=new gi({acceptLanguages:this.config.acceptLanguages,allowComments:!1,lang:this.config.lang,registry:this.stanzas,wrappedStream:!1}),this.parser.on("data",e=>{const t=e.kind,n=e.stanza;if("stream"===t){if("open"===n.action)return this.hasStream=!0,this.stream=n,this.client.emit("stream:start",n);if("close"===n.action)return this.client.emit("stream:end"),this.disconnect()}this.push({kind:e.kind,stanza:e.stanza})}),this.parser.on("error",e=>{const t={condition:Dr.InvalidXML};return this.client.emit("stream:error",t,e),this.write(this.stanzas.export("error",t).toString()),this.disconnect()}),this.socket=new er(t.url,"xmpp"),this.socket.onopen=()=>{this.emit("connect"),this.sm.started=!1,this.client.emit("connected"),this.write(this.startHeader())},this.socket.onmessage=t=>{const n=e.from(t.data,"utf8").toString();this.client.emit("raw","incoming",n),this.parser&&this.parser.write(n)},this.socket.onclose=()=>{this.push(null)}}disconnect(e=!0){this.socket&&!this.closing&&this.hasStream&&e?(this.closing=!0,this.write(this.closeHeader())):(this.hasStream=!1,this.stream=void 0,this.socket&&(this.end(),this.socket.close(),this.client.transport===this&&this.client.emit("--transport-disconnected")),this.socket=void 0)}send(e,t){var n;return Object(r.__awaiter)(this,void 0,void 0,(function*(){let i;if(t&&(i=null===(n=this.stanzas.export(e,t))||void 0===n?void 0:n.toString()),i)return new Promise((e,t)=>{this.write(i,"utf8",n=>n?t(n):e())})}))}restart(){this.hasStream=!1,this.write(this.startHeader())}startHeader(){return this.stanzas.export("stream",{action:"open",lang:this.config.lang,to:this.config.server,version:"1.0"}).toString()}closeHeader(){return this.stanzas.export("stream",{action:"close"}).toString()}}class Ba extends o.EventEmitter{constructor(e={}){super(),this.reconnectAttempts=0,this.setMaxListeners(100),this.off=this.removeListener,this.updateConfig(e),this.jid="",this.sasl=new ir,this.sasl.register("EXTERNAL",dr,1e3),this.sasl.register("SCRAM-SHA-256-PLUS",gr,350),this.sasl.register("SCRAM-SHA-256",gr,300),this.sasl.register("SCRAM-SHA-1-PLUS",gr,250),this.sasl.register("SCRAM-SHA-1",gr,200),this.sasl.register("DIGEST-MD5",mr,100),this.sasl.register("OAUTHBEARER",fr,100),this.sasl.register("X-OAUTH2",hr,50),this.sasl.register("PLAIN",hr,1),this.sasl.register("ANONYMOUS",pr,0),this.stanzas=new Mt,this.stanzas.define(qa),this.use(Zs),this.sm=new h,void 0!==this.config.allowResumption&&(this.sm.allowResume=this.config.allowResumption),this.sm.on("prebound",e=>{this.jid=e,this.emit("session:bound",e)}),this.on("session:bound",e=>this.sm.bind(e)),this.sm.on("send",e=>this.send("sm",e)),this.sm.on("acked",e=>this.emit("stanza:acked",e)),this.sm.on("failed",e=>this.emit("stanza:failed",e)),this.sm.on("hibernated",e=>this.emit("stanza:hibernated",e)),this.sm.on("begin-resend",()=>this.outgoingDataQueue.pause()),this.sm.on("resend",({kind:e,stanza:t})=>this.send(e,t,!0)),this.sm.on("end-resend",()=>this.outgoingDataQueue.resume());for(const e of["acked","hibernated","failed"])this.on("stanza:"+e,t=>{"message"===t.kind&&this.emit("message:"+e,t.stanza)});this.transports={bosh:Ma,websocket:Da},this.incomingDataQueue=Object(s.priorityQueue)((e,t)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const{kind:n,stanza:i}=e;this.emit(n,i),i.id&&this.emit(n+":id:"+i.id,i),"message"===n||"presence"===n||"iq"===n?(this.emit("stanza",i),yield this.sm.handle()):"sm"===n&&("ack"===i.type&&(yield this.sm.process(i),this.emit("stream:management:ack",i)),"request"===i.type&&this.sm.ack()),t&&t()})),1);const t=(e,t)=>{["message","presence","iq"].includes(e)&&(this.sm.started&&this.sm.resumable?this.sm.resumable&&!this.transport&&this.emit("stanza:hibernated",{kind:e,stanza:t}):this.emit("stanza:failed",{kind:e,stanza:t}))};this.outgoingDataQueue=Object(s.priorityQueue)((e,n)=>Object(r.__awaiter)(this,void 0,void 0,(function*(){var i;const{kind:r,stanza:s,replay:o}=e,a=o||(yield this.sm.track(r,s));if("message"===r&&(o?this.emit("message:retry",s):this.emit("message:sent",s,!1)),this.transport)try{yield this.transport.send(r,s),a&&(null===(i=this.transport)||void 0===i||i.send("sm",{type:"request"}))}catch(e){console.error(e),t(r,s)}else t(r,s);n&&n()})),1),this.on("stream:data",(e,t)=>{this.incomingDataQueue.push({kind:t,stanza:e},0)}),this.on("--transport-disconnected",()=>Object(r.__awaiter)(this,void 0,void 0,(function*(){const e=[];this.incomingDataQueue.idle()||e.push(this.incomingDataQueue.drain()),this.outgoingDataQueue.idle()||e.push(this.outgoingDataQueue.drain()),yield Promise.all(e),yield this.sm.hibernate(),this.transport&&delete this.transport,this.emit("--reset-stream-features"),!this.sessionTerminating&&this.config.autoReconnect&&(this.reconnectAttempts+=1,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.connect()},1e3*Math.min(Math.pow(2,this.reconnectAttempts)+Math.random(),this.config.maxReconnectBackoff||32))),this.emit("disconnected")}))),this.on("iq",e=>{const t=e.type,n=e.payloadType,i="iq:"+t+":"+n;if("get"===t||"set"===t){if("invalid-payload-count"===n)return this.sendIQError(e,{error:{condition:"bad-request",type:"modify"}});if("unknown-payload"===n||0===this.listenerCount(i))return this.sendIQError(e,{error:{condition:"service-unavailable",type:"cancel"}});this.emit(i,e)}}),this.on("message",e=>{const t=e.alternateLanguageBodies&&e.alternateLanguageBodies.length||e.links&&e.links.length,n=e.marker&&"markable"!==e.marker.type;t&&!n&&("chat"===e.type||"normal"===e.type?this.emit("chat",e):"groupchat"===e.type&&this.emit("groupchat",e)),"error"===e.type&&this.emit("message:error",e)}),this.on("presence",e=>{let t=e.type||"available";"error"===t&&(t="presence:error"),this.emit(t,e)}),this.on("session:started",()=>{this.sessionStarting=!1,this.reconnectAttempts=0,this.reconnectTimer&&clearTimeout(this.reconnectTimer)})}updateConfig(e={}){const t=this.config||{};this.config=Object.assign(Object.assign({allowResumption:!0,jid:"",transports:{bosh:!0,websocket:!0},useStreamManagement:!0},t),e),this.config.server||(this.config.server=W(this.config.jid)),this.config.password&&(this.config.credentials=this.config.credentials||{},this.config.credentials.password=this.config.password,delete this.config.password)}get stream(){return this.transport?this.transport.stream:void 0}emit(e,...t){const n=super.emit(e,...t);return"raw"===e?(super.emit("raw:"+t[0],t[1]),super.emit("raw:*","raw:"+t[0],t[1]),super.emit("*","raw:"+t[0],t[1])):super.emit("*",e,...t),n}use(e){"function"==typeof e&&e(this,this.stanzas,this.config)}nextId(){return Ir()}getCredentials(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return this._getConfiguredCredentials()}))}connect(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.sessionTerminating=!1,this.sessionStarting=!0,this.emit("--reset-stream-features"),this.transport&&this.transport.disconnect(!1);const e=["websocket","bosh"];let t;for(const n of e){let e=this.config.transports[n];if(e){if("string"==typeof e)e={url:e};else if(!0===e){if(!t)try{t=yield this.discoverBindings(this.config.server)}catch(e){console.error(e);continue}if(t[n]=(t[n]||[]).filter(e=>e.startsWith("wss:")||e.startsWith("https:")),!t[n]||!t[n].length)continue;e={url:t[n][0]}}return this.transport=new this.transports[n](this,this.sm,this.stanzas),void this.transport.connect(Object.assign({acceptLanguages:this.config.acceptLanguages||["en"],jid:this.config.jid,lang:this.config.lang||"en",server:this.config.server,url:e.url},e))}}console.error("No endpoints found for the requested transports."),this.emit("--transport-disconnected")}))}disconnect(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){this.sessionTerminating=!0,clearTimeout(this.reconnectTimer),this.outgoingDataQueue.pause(),this.sessionStarted&&!this.sm.started&&this.emit("session:end"),this.emit("--reset-stream-features"),this.sessionStarted=!1,this.transport?this.transport.disconnect():this.emit("--transport-disconnected"),this.outgoingDataQueue.resume(),this.outgoingDataQueue.idle()||(yield this.outgoingDataQueue.drain()),yield this.sm.shutdown()}))}send(e,t,n=!1){return Object(r.__awaiter)(this,void 0,void 0,(function*(){return new Promise((i,r)=>{this.outgoingDataQueue.push({kind:e,stanza:t,replay:n},n?0:1,e=>e?r(e):i())})}))}sendMessage(e){const t=e.id||this.nextId(),n=Object.assign({id:t,originId:t},e);return this.send("message",n),n.id}sendPresence(e={}){const t=Object.assign({id:this.nextId()},e);return this.send("presence",t),t.id}sendIQ(e){const t=Object.assign({id:this.nextId()},e),n=V(this.jid,e.to),i="iq:id:"+t.id,r=new Promise((e,t)=>{const r=s=>{n.has(s.from)&&("result"!==s.type&&"error"!==s.type||(this.off(i,r),"result"===s.type?e(s):t(s)))};this.on(i,r)});this.send("iq",t);const s=this.config.timeout||15;return xr(r,1e3*s,()=>Object.assign(Object.assign({},t),{to:void 0,from:void 0,error:{condition:"timeout",text:`Request timed out after ${s} seconds.`},id:t.id,type:"error"}))}sendIQResult(e,t){this.send("iq",Object.assign(Object.assign({},t),{id:e.id,to:e.from,type:"result"}))}sendIQError(e,t){this.send("iq",Object.assign(Object.assign({},t),{id:e.id,to:e.from,type:"error"}))}sendStreamError(e){this.emit("stream:error",e),this.send("error",e),this.disconnect()}_getConfiguredCredentials(){const e=this.config.credentials||{},t=G(this.config.jid||""),n=e.username||t.local,i=e.host||t.domain;return Object.assign({host:i,password:this.config.password,realm:i,serviceName:i,serviceType:"xmpp",username:n},e)}}function Ua(e,t){const n=e.length,i=t.length,r=Math.min(n,i);let s=0;for(s=0;s<r&&e[s]===t[s];s++);let o=0;for(o=0;o<r-s&&e[n-o-1]===t[i-o-1];o++);const a=s+o,l=[];if(a<n&&l.push({length:n-a,position:n-o,type:"erase"}),a<i){const e=t.slice(s,s+i-a);l.push({position:s,text:c.a.ucs2.encode(e),type:"insert"})}return l}var za=Object.freeze({__proto__:null,diff:Ua,DisplayBuffer:class{constructor(e,t=!1){this.synced=!1,this.cursorPosition=0,this.ignoreWaits=!1,this.timeDeficit=0,this.sequenceNumber=0,this.onStateChange=e||function(){},this.ignoreWaits=t,this.buffer=[],this.resetActionQueue()}get text(){return c.a.ucs2.encode(this.buffer.slice())}commit(){this.resetActionQueue()}process(e){if("cancel"!==e.event&&"init"!==e.event){if("reset"===e.event||"new"===e.event?(this.resetActionQueue(),void 0!==e.seq&&(this.sequenceNumber=e.seq)):e.seq!==this.sequenceNumber&&(this.synced=!1),e.actions){const t=Date.now();let n=0;for(const i of e.actions)i.baseTime=t+n,"wait"===i.type&&(n+=i.duration),this.actionQueue.push(i,0)}this.sequenceNumber=this.sequenceNumber+1}else this.resetActionQueue()}insert(e="",t=this.buffer.length){e=e.normalize("NFC");const n=c.a.ucs2.decode(e);this.buffer.splice(t,0,...n),this.cursorPosition=t+n.length,this.emitState()}erase(e=1,t=this.buffer.length){t=Math.max(Math.min(t,this.buffer.length),0),e=Math.max(Math.min(e,this.text.length),0),this.buffer.splice(Math.max(t-e,0),e),this.cursorPosition=Math.max(t-e,0),this.emitState()}emitState(e={}){this.onStateChange(Object.assign({cursorPosition:this.cursorPosition,synced:this.synced,text:this.text},e))}resetActionQueue(){this.actionQueue&&this.actionQueue.kill(),this.sequenceNumber=0,this.synced=!0,this.buffer=[],this.timeDeficit=0,this.actionQueue=Object(s.priorityQueue)((e,t)=>{const n=Date.now();if("insert"===e.type)return this.insert(e.text,e.position),t();if("erase"===e.type)return this.erase(e.length,e.position),t();if("wait"!==e.type)return t();{if(this.ignoreWaits)return t();e.duration>700&&(e.duration=700);const i=e.duration-(n-e.baseTime)+this.timeDeficit;if(i<=0)return this.timeDeficit=i,t();this.timeDeficit=0,setTimeout(()=>t(),i)}},1),this.emitState()}},InputBuffer:class{constructor(e,t=!1){this.resetInterval=1e4,this.ignoreWaits=!1,this.isStarting=!1,this.isReset=!1,this.changedBetweenResets=!1,this.onStateChange=e||function(){},this.ignoreWaits=t,this.buffer=[],this.actionQueue=[],this.sequenceNumber=0}get text(){return c.a.ucs2.encode(this.buffer.slice())}update(e){let t=[];if(void 0!==e){e=e.normalize("NFC");const n=c.a.ucs2.decode(e);t=Ua(this.buffer,n.slice()),this.buffer=n,this.emitState()}const n=Date.now();if(this.changedBetweenResets&&n-this.lastResetTime>this.resetInterval)this.actionQueue=[],this.actionQueue.push({position:0,text:this.text,type:"insert"}),this.isReset=!0,this.lastActionTime=n,this.lastResetTime=n,this.changedBetweenResets=!1;else if(t.length){const e=n-(this.lastActionTime||n);e>0&&!this.ignoreWaits&&this.actionQueue.push({duration:e,type:"wait"});for(const e of t)this.actionQueue.push(e);this.lastActionTime=n,this.changedBetweenResets=!0}else this.lastActionTime=n}start(e=this.resetInterval){return this.commit(),this.isStarting=!0,this.resetInterval=e,this.sequenceNumber=Math.floor(1e4*Math.random()+1),{event:"init"}}stop(){return this.commit(),{event:"cancel"}}diff(){if(this.update(),!this.actionQueue.length)return null;const e={actions:this.actionQueue,seq:this.sequenceNumber++};return this.isStarting?(e.event="new",this.isStarting=!1,this.lastResetTime=Date.now()):this.isReset&&(e.event="reset",this.isReset=!1),this.actionQueue=[],e}commit(){this.sequenceNumber=0,this.lastActionTime=0,this.actionQueue=[],this.buffer=[]}emitState(){this.onStateChange({text:this.text})}}});class Ja{constructor(e){var t,n,i;this.resultComplete=!1,this.fetchedCount=0,this.yieldedCount=0,this.cursor={first:e.before,last:e.after},this.query=e.query,this.direction=null!==(t=e.direction)&&void 0!==t?t:"forward",this.reverse=null!==(n=e.reverse)&&void 0!==n?n:"backward"===this.direction,this.pageSize=null!==(i=e.pageSize)&&void 0!==i?i:20}[Symbol.asyncIterator](){return Object(r.__asyncGenerator)(this,arguments,(function*(){let e=[];do{e=yield Object(r.__await)(this.fetchPage());for(const t of e)this.yieldedCount+=1,yield yield Object(r.__await)(t)}while(e.length>0)}))}size(){return Object(r.__awaiter)(this,void 0,void 0,(function*(){if(void 0!==this.resultCount)return this.resultCount;const{paging:e}=yield this.query({max:0});return this.resultCount=e.count,e.count}))}queryCompleted(){return this.resultComplete}finished(){return this.resultComplete&&this.yieldedCount===this.fetchedCount}fetchPage(){var e;return Object(r.__awaiter)(this,void 0,void 0,(function*(){const{results:t,paging:n}=yield this.query({before:"backward"===this.direction?null!==(e=this.cursor.first)&&void 0!==e?e:"":void 0,after:"forward"===this.direction?this.cursor.last:void 0,max:this.pageSize});return this.cursor=n,this.resultCount=n.count,this.fetchedCount+=t.length,(this.pageSize&&t.length<this.pageSize||this.resultCount&&this.fetchedCount===this.resultCount)&&(this.resultComplete=!0),this.reverse&&t.reverse(),t}))}}var Ga=Object.freeze({__proto__:null,ResultSetPager:Ja,createPager:function(e){return new Ja(e)}});const Va="12.17.2";function $a(e){const t=new Ba(e);return t.use(eo),t}}.call(this,n(10).Buffer,n(5))},function(e,t,n){"use strict";t.byteLength=function(e){var t=l(e),n=t[0],i=t[1];return 3*(n+i)/4-i},t.toByteArray=function(e){var t,n,i=l(e),o=i[0],a=i[1],c=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),u=0,p=a>0?o-4:o;for(n=0;n<p;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[u++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=0,a=n-r;o<a;o+=16383)s.push(u(e,o,o+16383>a?a:o+16383));1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)i[a]=o[a],r[o.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,n){for(var r,s,o=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(i[(s=r)>>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(e,t){
|
|
39
39
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
40
40
|
t.read=function(e,t,n,i,r){var s,o,a=8*r-i-1,c=(1<<a)-1,l=c>>1,u=-7,p=n?r-1:0,d=n?-1:1,h=e[t+p];for(p+=d,s=h&(1<<-u)-1,h>>=-u,u+=a;u>0;s=256*s+e[t+p],p+=d,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=i;u>0;o=256*o+e[t+p],p+=d,u-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,i),s-=l}return(h?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,t,n,i,r,s){var o,a,c,l=8*s-r-1,u=(1<<l)-1,p=u>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:s-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(o++,c/=2),o+p>=u?(a=0,o=u):o+p>=1?(a=(t*c-1)*Math.pow(2,r),o+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,r),o=0));r>=8;e[n+h]=255&a,h+=f,a/=256,r-=8);for(o=o<<r|a,l+=r;l>0;e[n+h]=255&o,h+=f,o/=256,l-=8);e[n+h-f]|=128*m}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t){},function(e,t,n){"use strict";var i=n(20).Buffer,r=n(81);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var t,n,r,s=i.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,n=s,r=a,t.copy(n,r),a+=o.data.length,o=o.next;return s},e}(),r&&r.inspect&&r.inspect.custom&&(e.exports.prototype[r.inspect.custom]=function(){var e=r.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function s(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new s(r.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new s(r.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(83),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(5))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var i,r,s,o,a,c=1,l={},u=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?i=function(e){t.nextTick((function(){f(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){f(e.data)},i=function(e){s.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(r=p.documentElement,i=function(e){var t=p.createElement("script");t.onreadystatechange=function(){f(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):i=function(e){setTimeout(f,0,e)}:(o="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(o)&&f(+t.data.slice(o.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),i=function(t){e.postMessage(o+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var r={callback:e,args:t};return l[c]=r,i(c),c++},d.clearImmediate=h}function h(e){delete l[e]}function f(e){if(u)setTimeout(f,0,e);else{var t=l[e];if(t){u=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n)}}(t)}finally{h(e),u=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(5),n(7))},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this,n(5))},function(e,t,n){"use strict";e.exports=s;var i=n(44),r=Object.create(n(15));function s(e){if(!(this instanceof s))return new s(e);i.call(this,e)}r.inherits=n(16),r.inherits(s,i),s.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){var i,r,s=n(45),o=n(46),a=0,c=0;e.exports=function(e,t,n){var l=t&&n||0,u=t||[],p=(e=e||{}).node||i,d=void 0!==e.clockseq?e.clockseq:r;if(null==p||null==d){var h=s();null==p&&(p=i=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=r=16383&(h[6]<<8|h[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),m=void 0!==e.nsecs?e.nsecs:c+1,g=f-a+(m-c)/1e4;if(g<0&&void 0===e.clockseq&&(d=d+1&16383),(g<0||f>a)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=f,c=m,r=d;var v=(1e4*(268435455&(f+=122192928e5))+m)%4294967296;u[l++]=v>>>24&255,u[l++]=v>>>16&255,u[l++]=v>>>8&255,u[l++]=255&v;var b=f/4294967296*1e4&268435455;u[l++]=b>>>8&255,u[l++]=255&b,u[l++]=b>>>24&15|16,u[l++]=b>>>16&255,u[l++]=d>>>8|128,u[l++]=255&d;for(var y=0;y<6;++y)u[l+y]=p[y];return t||o(u)}},function(e,t,n){var i=n(45),r=n(46);e.exports=function(e,t,n){var s=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||i)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;++a)t[s+a]=o[a];return t||r(o)}},function(e,t,n){"use strict";var i=n(2),r=n(47),s=n(89),o=n(54);var a=function e(t){var n=new s(t),a=r(s.prototype.request,n);return i.extend(a,s.prototype,n),i.extend(a,n),a.create=function(n){return e(o(t,n))},a}(n(29));a.Axios=s,a.CanceledError=n(21),a.CancelToken=n(103),a.isCancel=n(53),a.VERSION=n(55).version,a.toFormData=n(50),a.AxiosError=n(13),a.Cancel=a.CanceledError,a.all=function(e){return Promise.all(e)},a.spread=n(104),a.isAxiosError=n(105),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var i=n(2),r=n(48),s=n(90),o=n(91),a=n(54),c=n(52),l=n(102),u=l.validators;function p(e){this.defaults=e,this.interceptors={request:new s,response:new s}}p.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&l.assertOptions(n,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var i=[],r=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));var s,c=[];if(this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)})),!r){var p=[o,void 0];for(Array.prototype.unshift.apply(p,i),p=p.concat(c),s=Promise.resolve(t);p.length;)s=s.then(p.shift(),p.shift());return s}for(var d=t;i.length;){var h=i.shift(),f=i.shift();try{d=h(d)}catch(e){f(e);break}}try{s=o(d)}catch(e){return Promise.reject(e)}for(;c.length;)s=s.then(c.shift(),c.shift());return s},p.prototype.getUri=function(e){e=a(this.defaults,e);var t=c(e.baseURL,e.url);return r(t,e.params,e.paramsSerializer)},i.forEach(["delete","get","head","options"],(function(e){p.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),i.forEach(["post","put","patch"],(function(e){function t(t){return function(n,i,r){return this.request(a(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}p.prototype[e]=t(),p.prototype[e+"Form"]=t(!0)})),e.exports=p},function(e,t,n){"use strict";var i=n(2);function r(){this.handlers=[]}r.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){i.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=r},function(e,t,n){"use strict";var i=n(2),r=n(92),s=n(53),o=n(29),a=n(21);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(e){return c(e),e.headers=e.headers||{},e.data=r.call(e,e.data,e.headers,e.transformRequest),e.headers=i.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),i.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||o.adapter)(e).then((function(t){return c(e),t.data=r.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(c(e),t&&t.response&&(t.response.data=r.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var i=n(2),r=n(29);e.exports=function(e,t,n){var s=this||r;return i.forEach(n,(function(n){e=n.call(s,e,t)})),e}},function(e,t,n){"use strict";var i=n(2);e.exports=function(e,t){i.forEach(e,(function(n,i){i!==t&&i.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[i])}))}},function(e,t,n){"use strict";var i=n(13);e.exports=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new i("Request failed with status code "+n.status,[i.ERR_BAD_REQUEST,i.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}},function(e,t,n){"use strict";var i=n(2);e.exports=i.isStandardBrowserEnv()?{write:function(e,t,n,r,s,o){var a=[];a.push(e+"="+encodeURIComponent(t)),i.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),i.isString(r)&&a.push("path="+r),i.isString(s)&&a.push("domain="+s),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var i=n(2),r=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,o={};return e?(i.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=i.trim(e.substr(0,s)).toLowerCase(),n=i.trim(e.substr(s+1)),t){if(o[t]&&r.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o}},function(e,t,n){"use strict";var i=n(2);e.exports=i.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var i=e;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=i.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,n){"use strict";var i=n(55).version,r=n(13),s={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){s[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={};s.transitional=function(e,t,n){function s(e,t){return"[Axios v"+i+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,i,a){if(!1===e)throw new r(s(i," has been removed"+(t?" in "+t:"")),r.ERR_DEPRECATED);return t&&!o[i]&&(o[i]=!0,console.warn(s(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new r("options must be an object",r.ERR_BAD_OPTION_VALUE);for(var i=Object.keys(e),s=i.length;s-- >0;){var o=i[s],a=t[o];if(a){var c=e[o],l=void 0===c||a(c,o,e);if(!0!==l)throw new r("option "+o+" must be "+l,r.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new r("Unknown option "+o,r.ERR_BAD_OPTION)}},validators:s}},function(e,t,n){"use strict";var i=n(21);function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,i=n._listeners.length;for(t=0;t<i;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,i=new Promise((function(e){n.subscribe(e),t=e})).then(e);return i.cancel=function(){n.unsubscribe(t)},i},e((function(e){n.reason||(n.reason=new i(e),t(n.reason))}))}r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},r.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},r.source=function(){var e;return{token:new r((function(t){e=t})),cancel:e}},e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";var i=n(2);e.exports=function(e){return i.isObject(e)&&!0===e.isAxiosError}},function(e,t,n){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var r={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:function(){return!0},startingDelay:100,timeMultiple:2};t.getSanitizedOptions=function(e){var t=i(i({},r),e);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(108),r=n(112);t.DelayFactory=function(e,t){var n=function(e){if(!e.delayFirstAttempt)return new i.SkipFirstDelay(e);return new r.AlwaysDelay(e)}(e);return n.setAttemptNumber(t),n}},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.apply=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,!!this.isFirstAttempt||e.prototype.apply.call(this)]}))}))},Object.defineProperty(t.prototype,"isFirstAttempt",{get:function(){return 0===this.attempt},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt-1},enumerable:!0,configurable:!0}),t}(n(56).Delay);t.SkipFirstDelay=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(110),r=n(111);t.JitterFactory=function(e){switch(e.jitter){case"full":return i.fullJitter;case"none":default:return r.noJitter}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fullJitter=function(e){var t=Math.random()*e;return Math.round(t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noJitter=function(e){return e}},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(n(56).Delay);t.AlwaysDelay=s},function(e,t,n){"use strict";(function(e){e||Object.defineProperty(window,"crypto",{value:window.crypto||window.msCrypto,writable:!1,configurable:!1})}).call(this,n(5))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Notifications=void 0;const i=n(115),r=n(8);function s(e,t){return[...e,...t].filter((e,t,n)=>n.indexOf(e)===t)}t.Notifications=class{constructor(e){this.subscriptions={},this.bulkSubscriptions={},this.topicPriorities={},this.client=e,e.on("pubsub:event",this.pubsubEvent.bind(this)),e.on("connected",this.subscriptionsKeepAlive.bind(this)),this.debouncedResubscribe=i(this.resubscribe.bind(this),100)}get pubsubHost(){try{return"notifications."+this.client.config.apiHost.replace(/http(s?):\/\//,"")}catch(e){return"notifications.mypurecloud.com"}}topicHandlers(e){return this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e]}pubsubEvent({pubsub:e}){let t=e.items.node;t.includes("no_longer_subscribed")&&(t="no_longer_subscribed");const n=e.items.published[0].content.json,i=this.topicHandlers(t);this.client._stanzaio.emit("notify",{topic:t,data:n}),this.client._stanzaio.emit("notify:"+t,n),i.forEach(e=>{e(n)})}async xmppSubscribe(e){if(0!==this.topicHandlers(e).length||this.bulkSubscriptions[e])return Promise.resolve();const t=()=>this.client._stanzaio.subscribeToNode(this.pubsubHost,e);return this.client.connected?t():new Promise((e,n)=>{this.client.once("connected",()=>t().then(e,n))})}xmppUnsubscribe(e){if(0!==this.topicHandlers(e).length||this.bulkSubscriptions[e])return Promise.resolve();const t=()=>this.client._stanzaio.unsubscribeFromNode(this.pubsubHost,e);return this.client.connected?t():new Promise((e,n)=>{this.client.once("connected",()=>t().then(e,n))})}mapCombineTopics(e){const t={},n=[],i=[];e.forEach(e=>{e.includes("?")?n.push({id:e}):i.push(e)}),i.map(e=>{const t=e.split("."),n=t.splice(t.length-1);return{prefix:t.join("."),postfix:n}}).forEach(e=>{t[e.prefix]?t[e.prefix].push(e.postfix):t[e.prefix]=[e.postfix]});let r=[];const s=(e,t)=>{const n=`${e}${1===t.length?".":"?"}${t.join("&")}`;n.length<200?r.push({id:n}):1===t.length?this.client.logger.error("Refusing to attempt topic with length > 200",n):(s(e,t.slice(0,t.length/2)),s(e,t.slice(t.length/2)))};Object.keys(t).forEach(e=>{const n=t[e];s(e,n)});const o=r.concat(n);return this.truncateTopicList(this.prioritizeTopicList(o))}prioritizeTopicList(e){return e.sort((e,t)=>this.getTopicPriority(t.id)-this.getTopicPriority(e.id)),e}getTopicPriority(e,t=!0){const{prefix:n,postfixes:i}=this.getTopicParts(e),r=this.topicPriorities[n],s=r&&Object.keys(r).filter(e=>i.includes(e)).map(e=>r[e]),o=s&&s.length&&s.reduce((e,t)=>t>e?t:e);return t?o||0:o}truncateTopicList(e){const t=e.slice(0,1e3);if(e.length>1e3){let t=e.slice(1e3);if(t.length>20){const e=t.length-20;t=t.slice(20),t.push(`...and ${e} more`)}this.client.logger.warn("Too many topics to subscribe to; truncating extra topics",{droppedTopics:t})}return t}makeBulkSubscribeRequest(e,t){const n={method:t.replace?"put":"post",host:this.client.config.apiHost,authToken:this.client.config.authToken,data:JSON.stringify(this.mapCombineTopics(e)),logger:this.client.logger},i=this.client.config.channelId;return this.client.http.requestApi(`notifications/channels/${i}/subscriptions`,n)}createSubscription(e,t){r.splitIntoIndividualTopics(e).forEach(e=>{let n=this.topicHandlers(e);n.includes(t)||n.push(t)})}removeSubscription(e,t){r.splitIntoIndividualTopics(e).forEach(e=>{let n=this.topicHandlers(e),i=n.indexOf(t);i>-1&&n.splice(i,1),n.length||delete this.subscriptions[e]})}removeTopicPriority(e){if(this.getTopicPriority(e,!1)){const{prefix:t,postfixes:n}=this.getTopicParts(e);n.forEach(e=>{delete this.topicPriorities[t][e]}),Object.keys(this.topicPriorities[t]).length||delete this.topicPriorities[t]}}getActiveIndividualTopics(){const e=[];return Object.keys(this.subscriptions).forEach(t=>{if("streaming-subscriptions-expiring"===t)return;this.topicHandlers(t).length>0&&e.push(t)}),e}resubscribe(){const e=Object.keys(this.bulkSubscriptions);return e.length+this.getActiveIndividualTopics().length===0?Promise.resolve():this.bulkSubscribe(e,{replace:!0})}subscriptionsKeepAlive(){const e="streaming-subscriptions-expiring";0===this.topicHandlers(e).length&&this.createSubscription(e,()=>{this.client.logger.info(e+" - Triggering resubscribe.",{channelId:this.client.config.channelId}),this.resubscribe().catch(e=>{const t="Error resubscribing to topics";this.client.logger.error(t,e),this.client._stanzaio.emit("pubsub:error",{msg:t,err:e})})})}getTopicParts(e){const t=e.includes("?"),n=t?"?":".",i=e.split(n),r=t?i[1]:i.splice(i.length-1),s=t?i[0]:i.join(".");let o=[];return o=t?r.split("&"):r,{prefix:s,postfixes:o}}setTopicPriorities(e={}){Object.keys(e).forEach(t=>{const n=this.getTopicParts(t),i=this.topicPriorities[n.prefix],r=e[t];if(i)n.postfixes.forEach(e=>{const t=i[e];(t&&t<r||!t)&&(i[e]=r)});else{const e=n.postfixes.reduce((e,t)=>(e[t]=r,e),{});this.topicPriorities[n.prefix]=e}})}subscribe(e,t,n,i){let r;return i&&this.setTopicPriorities({[e]:i}),r=n?this.xmppSubscribe(e):this.debouncedResubscribe(),t?this.createSubscription(e,t):this.bulkSubscriptions[e]=!0,r}unsubscribe(e,t,n){return t?this.removeSubscription(e,t):(delete this.bulkSubscriptions[e],delete this.subscriptions[e]),this.removeTopicPriority(e),n?this.xmppUnsubscribe(e):this.debouncedResubscribe()}async bulkSubscribe(e,t={replace:!1,force:!1},n={}){this.setTopicPriorities(n);let i=s(e,[]);t.replace&&!t.force?i=s(i,this.getActiveIndividualTopics()):t.force&&(this.subscriptions={}),await this.makeBulkSubscribeRequest(i,t),t.replace&&(this.bulkSubscriptions={}),e.forEach(e=>{this.bulkSubscriptions[e]=!0})}get expose(){return{subscribe:this.subscribe.bind(this),unsubscribe:this.unsubscribe.bind(this),bulkSubscribe:this.bulkSubscribe.bind(this)}}}},function(e,t,n){"use strict";function i(e){return"function"==typeof e?e():e}function r(){var e={};return e.promise=new Promise((function(t,n){e.resolve=t,e.reject=n})),e}e.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=void 0,o=void 0,a=void 0,c=[];return function(){var u=i(t),p=(new Date).getTime(),d=!s||p-s>u;s=p;for(var h=arguments.length,f=Array(h),m=0;m<h;m++)f[m]=arguments[m];if(d&&n.leading)return n.accumulate?Promise.resolve(e.call(this,[f])).then((function(e){return e[0]})):Promise.resolve(e.call.apply(e,[this].concat(f)));if(o?clearTimeout(a):o=r(),c.push(f),a=setTimeout(l.bind(this),u),n.accumulate){var g=c.length-1;return o.promise.then((function(e){return e[g]}))}return o.promise};function l(){var t=o;clearTimeout(a),Promise.resolve(n.accumulate?e.call(this,c):e.apply(this,c[c.length-1])).then(t.resolve,t.reject),c=[],o=null}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebrtcExtension=void 0;const i=n(22),r=n(3),s=n(117),o=i.__importDefault(n(120)),a=n(9),c=n(66),l=i.__importDefault(n(123)),u=n(124),p=n(125),d=n(25),h=n(8),f=i.__importDefault(n(134)),m=n(135),g=n(17),v="requestIncomingRtcSession",b="cancelIncomingRtcSession",y="handledIncomingRtcSession",_="incomingRtcSession",S="outgoingRtcSession",w="rtcSessionError";class x extends r.EventEmitter{constructor(e,t){super(),this.ignoredSessions=new o.default({max:10,maxAge:216e3}),this.pendingSessions={},this.statsArr=[],this.throttleSendStatsInterval=25e3,this.currentMaxStatSize=15e3,this.statsSizeDecreaseAmount=3e3,this.statBuffer=0,this.discoRetries=0,this.client=e,this.config={allowIPv6:!0===t.allowIPv6,optOutOfWebrtcStatsTelemetry:t.optOutOfWebrtcStatsTelemetry},this.logger=e.logger,e._stanzaio.stanzas.define(p.definitions),e._stanzaio.jingle.prepareSession=this.prepareSession.bind(this),this.jingleJs=e._stanzaio.jingle,this.addEventListeners(),this.proxyEvents(),this.configureStanzaJingle(),this.throttledSendStats=l.default(this.sendStats.bind(this),this.throttleSendStatsInterval,{leading:!1,trailing:!0})}get jid(){return this.client._stanzaio.jid}configureStanzaJingle(){Object.assign(this.client._stanzaio.jingle.config.peerConnectionConfig,{sdpSemantics:"unified-plan"}),this.client._stanzaio.jingle.config.iceServers=[],this.setIceServers([])}prepareSession(e){const t=this.pendingSessions[e.sid];t&&delete this.pendingSessions[t.sessionId];const n="relay"===this.getIceTransportPolicy()&&u.isFirefox,i={options:e,optOutOfWebrtcStatsTelemetry:!!this.config.optOutOfWebrtcStatsTelemetry,conversationId:null==t?void 0:t.conversationId,fromUserId:null==t?void 0:t.fromJid,originalRoomJid:null==t?void 0:t.originalRoomJid,sessionType:null==t?void 0:t.sessionType,allowIPv6:this.config.allowIPv6,ignoreHostCandidatesFromRemote:n},r=new d.GenesysCloudMediaSession(i);return this.proxyStatsForSession(r),r}proxyStatsForSession(e){e.on("stats",t=>{if(this.client.logger.stopReason)return;const n=JSON.parse(JSON.stringify(t)),i={conference:e.conversationId,session:e.sid,sessionType:e.sessionType},r=m.formatStatsEvent(n,i),s=h.calculatePayloadSize(r),o=this.statBuffer+s>this.currentMaxStatSize;this.statsArr.push(r),this.statBuffer+=s,o?this.flushStats():this.throttledSendStats()})}getLogDetailsForPendingSessionId(e){const t={sessionId:e},n=this.pendingSessions[e];return n&&(t.sessionType=n.sessionType,t.conversationId=n.conversationId),t}flushStats(){this.throttledSendStats.flush()}async sendStats(){const e=[];let t=0;for(const n of this.statsArr){const i=h.calculatePayloadSize(n);if(!(t+i<this.currentMaxStatSize))break;e.push(n),t+=i}if(this.statsArr.splice(0,e.length),this.statBuffer=this.statsArr.reduce((e,t)=>e+h.calculatePayloadSize(t),0),!e.length||this.client.isGuest)return;const n={appName:"streamingclient",appVersion:f.default.version,originAppName:this.client.config.appName,originAppVersion:this.client.config.appVersion,actions:e};try{let e=this.client.config.authToken,t="diagnostics/newrelic/insights";this.client.backgroundAssistantMode&&(e=this.client.config.jwt,t+="/backgroundassistant"),await this.client.http.requestApi(t,{method:"post",host:this.client.config.apiHost,authToken:e,logger:this.client.logger,data:n}),this.currentMaxStatSize=15e3}catch(t){if(413===t.status){const t=this.currentMaxStatSize;this.currentMaxStatSize-=this.statsSizeDecreaseAmount,this.statsArr=[...e,...this.statsArr],this.statBuffer=this.statsArr.reduce((e,t)=>e+h.calculatePayloadSize(t),0),this.logger.info("Failed to send stats due to 413, retrying with smaller set",{attemptedPayloadSize:t,newPayloadSize:this.currentMaxStatSize}),await this.sendStats()}else this.logger.error("Failed to send stats",{err:t,numberOfFailedStats:e.length})}}addEventListeners(){this.client.on("connected",()=>(this.refreshIceServersTimer&&(clearInterval(this.refreshIceServersTimer),this.refreshIceServersTimer=null),this.refreshIceServersTimer=setInterval(this.refreshIceServers.bind(this),216e5),this.refreshIceServers().catch(e=>this.logger.error("Error fetching ice servers after streaming-client connected",{error:e,channelId:this.client.config.channelId})))),this.client.on("disconnected",()=>{clearInterval(this.refreshIceServersTimer),this.refreshIceServersTimer=null}),this.client._stanzaio.jingle.on("log",(e,t,n)=>{this.logger[e](t,n)}),this.client._stanzaio.on("message",async e=>{e.propose?await this.handlePropose(e):e.retract?this.handleRetract(e.retract.sessionId):e.accept&&this.handledIncomingRtcSession(e.accept.sessionId)})}proxyEvents(){this.client._stanzaio.on("jingle:outgoing",e=>this.emit(S,e)),this.client._stanzaio.on("jingle:incoming",e=>this.emit(_,e));const e=["iceConnectionType","peerTrackAdded","peerTrackRemoved","mute","unmute","sessionState","connectionState","terminated","stats","endOfCandidates"];for(const t of e)this.client._stanzaio.jingle.on(t,(e,...n)=>{e.emit(t,...n)})}async handlePropose(e){if(e.from===this.jid)return;const t=e.propose.sessionId;let n=this.pendingSessions[t];const i=!!n,r=this.getSessionTypeByJid(e.from),s={sessionId:t,conversationId:e.propose.conversationId,sessionType:r,isDuplicatePropose:i};if(this.logger.info("propose received",s),!i){const i=e.from,s=i;e.propose.originalRoomJid=e.propose.originalRoomJid||s,n={...e.propose,toJid:e.to,fromJid:i,sessionType:r,roomJid:s,id:t},this.pendingSessions[t]=n}if(n.accepted)return this.logger.info("proceed already sent for this session, but sending another",s),void await this.acceptRtcSession(t);this.emit(v,Object.assign(n))}handleRetract(e){return this.logger.info("retract received",this.getLogDetailsForPendingSessionId(e)),delete this.pendingSessions[e],this.emit(b,e)}handledIncomingRtcSession(e){return this.logger.info("accept received",this.getLogDetailsForPendingSessionId(e)),this.emit(y,e)}async initiateRtcSession(e){const t={to:e.jid,propose:{id:c.v4(),descriptions:[]}};if(e.stream)for(let n of Array.from(e.stream.getTracks()))t.propose.descriptions.push({media:n.kind});if(e.provideVideo){t.propose.descriptions.filter(e=>"video"===e.media).length>0||t.propose.descriptions.push({media:"video"})}if(e.provideAudio){t.propose.descriptions.filter(e=>"audio"===e.media).length>0||t.propose.descriptions.push({media:"audio"})}if(e.mediaPurpose&&t.propose.descriptions.push({media:e.mediaPurpose}),e.jid&&e.jid.match(/@conference/)){let n=t.propose.descriptions;0===n.length&&(n=[{media:"listener"}]);const i={type:"upgradeMedia",to:e.jid,id:c.v4(),from:this.jid,media:{conversationId:e.conversationId,sourceCommunicationId:e.sourceCommunicationId}};for(const e of n)i.media[e.media]=!0;await this.client._stanzaio.send("presence",i)}else await this.client._stanzaio.send("message",t),this.pendingSessions[t.propose.id]=t;return t.propose.id}async acceptRtcSession(e){const t=this.pendingSessions[e];if(!t)return void this.emit(w,"Cannot accept session because it is not pending or does not exist");const n={to:t.fromJid,proceed:{sessionId:e}};t.accepted=!0;const i=this.getLogDetailsForPendingSessionId(e);this.logger.info("sending jingle proceed",i),await this.client._stanzaio.send("message",n),this.logger.info("sent jingle proceed",i)}async rejectRtcSession(e,t=!1){const n=this.getLogDetailsForPendingSessionId(e),i=this.pendingSessions[e];if(i)if(delete this.pendingSessions[e],t)this.ignoredSessions.set(e,!0);else{const t={to:s.toBare(this.jid),reject:{sessionId:e}},r=this.client._stanzaio.send("message",t),o={to:i.fromJid,reject:{sessionId:e}},a=this.client._stanzaio.send("message",o);this.logger.info("sending jingle reject",n),await Promise.all([r,a]),this.logger.info("sent jingle reject",n)}else this.emit(w,"Cannot reject session because it is not pending or does not exist")}async rtcSessionAccepted(e){this.pendingSessions[e];const t=this.getLogDetailsForPendingSessionId(e),n={to:s.toBare(this.jid),accept:{sessionId:e}};this.logger.info("sending session-info:accept",t),await this.client._stanzaio.send("message",n),this.logger.info("sent session-info:accept",t)}notifyScreenShareStart(e){return this.client._stanzaio.send("iq",{to:""+e.peerID,from:this.jid,type:"set",jingle:{action:a.JingleAction.SessionInfo,sid:e.sid,screenstart:{}}})}notifyScreenShareStop(e){return this.client._stanzaio.send("iq",{to:""+e.peerID,from:this.jid,type:"set",jingle:{action:a.JingleAction.SessionInfo,sid:e.sid,screenstop:{}}})}async cancelRtcSession(e){const t=this.pendingSessions[e],n=this.getLogDetailsForPendingSessionId(e);if(!t)return void this.emit(w,"Cannot cancel session because it is not pending or does not exist");const i={to:t.toJid,retract:{sessionId:e}};delete this.pendingSessions[e],this.logger.info("sending jingle retract",n),await this.client._stanzaio.send("message",i),this.logger.info("sent jingle retract",n)}async refreshIceServers(){return this.refreshIceServersRetryPromise||(this.refreshIceServersRetryPromise=h.retryPromise(this._refreshIceServers.bind(this),e=>++this.discoRetries>2?(this.logger.warn("fetching ice servers failed. max retries reached.",{retryAttempt:this.discoRetries,MAX_DISCO_RETRIES:2,error:e,channelId:this.client.config.channelId}),!1):(this.logger.warn("fetching ice servers failed. retrying",{retryAttempt:this.discoRetries,error:e,channelId:this.client.config.channelId}),!0),0,this.client.logger)),this.refreshIceServersRetryPromise.promise.finally(()=>{this.discoRetries=0,this.refreshIceServersRetryPromise=void 0})}async _refreshIceServers(){const e=this.client._stanzaio.config.server,t=this.client._stanzaio.getServices(e,"turn","1"),n=this.client._stanzaio.getServices(e,"stun","1"),i=new Promise((e,i)=>{setTimeout(()=>{i(new Error("Timeout waiting for refresh ice servers to finish"))},15e3),Promise.all([t,n]).then(([t,n])=>{e([t,n])}).catch(i)}),[r,s]=await i;this.logger.debug("STUN/TURN server discovery result",{turnServers:r,stunServers:s});const o=[...r.services,...s.services].map(e=>{const t=e.port?":"+e.port:"",n={type:e.type,urls:`${e.type}:${e.host}${t}`};return["turn","turns"].includes(e.type)&&(e.transport&&"udp"!==e.transport&&(n.urls+="?transport="+e.transport),e.username&&(n.username=e.username),e.password&&(n.credential=e.password)),n});return this.setIceServers(o),s.services.length?this.setIceTransportPolicy("all"):(this.logger.info('No stun servers received, setting iceTransportPolicy to "relay"'),this.setIceTransportPolicy("relay")),o}setIceServers(e){this.client._stanzaio.jingle.iceServers=e}getIceTransportPolicy(){return this.client._stanzaio.jingle.config.peerConnectionConfig.iceTransportPolicy}setIceTransportPolicy(e){this.client._stanzaio.jingle.config.peerConnectionConfig.iceTransportPolicy=e}getSessionTypeByJid(e){return h.isAcdJid(e)?g.SessionTypes.acdScreenShare:h.isScreenRecordingJid(e)?g.SessionTypes.screenRecording:h.isSoftphoneJid(e)?g.SessionTypes.softphone:h.isVideoJid(e)?g.SessionTypes.collaborateVideo:g.SessionTypes.unknown}get expose(){return{on:this.on.bind(this),once:this.once.bind(this),off:this.off.bind(this),removeAllListeners:this.removeAllListeners.bind(this),removeListener:this.removeListener.bind(this),refreshIceServers:this.refreshIceServers.bind(this),acceptRtcSession:this.acceptRtcSession.bind(this),rejectRtcSession:this.rejectRtcSession.bind(this),cancelRtcSession:this.cancelRtcSession.bind(this),notifyScreenShareStart:this.notifyScreenShareStart.bind(this),notifyScreenShareStop:this.notifyScreenShareStop.bind(this),rtcSessionAccepted:this.rtcSessionAccepted.bind(this),initiateRtcSession:this.initiateRtcSession.bind(this),getSessionTypeByJid:this.getSessionTypeByJid.bind(this),jingle:this.client._stanzaio.jingle}}}t.WebrtcExtension=x},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toURI=t.parseURI=t.toBare=t.getResource=t.getDomain=t.getLocal=t.isBare=t.isFull=t.equalBare=t.equal=t.allowedResponders=t.parse=t.createFull=t.create=t.prepare=t.unescapeLocal=t.escapeLocal=void 0;const i=n(0).__importDefault(n(4)),r=n(118);function s(e=""){return e.replace(/^\s+|\s+$/g,"").replace(/\\5c/g,"\\5c5c").replace(/\\20/g,"\\5c20").replace(/\\22/g,"\\5c22").replace(/\\26/g,"\\5c26").replace(/\\27/g,"\\5c27").replace(/\\2f/g,"\\5c2f").replace(/\\3a/g,"\\5c3a").replace(/\\3c/g,"\\5c3c").replace(/\\3e/g,"\\5c3e").replace(/\\40/g,"\\5c40").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")}function o(e){return 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,"\\")}function a(e){let t=e.local||"",n=e.domain,s=e.resource||"";return t&&(t=r.nodeprep(t)),s&&(s=r.resourceprep(s)),"."===n[n.length-1]&&(n=n.slice(0,n.length-1)),n=r.nameprep(n.split(".").map(i.default.toUnicode).join(".")),{domain:n,local:t,resource:s}}function c(e,t={}){let n=e.local;t.escaped||(n=s(e.local));const i=t.prepared?e:a({local:n,domain:e.domain,resource:e.resource}),r=n?`${n}@${i.domain}`:i.domain;return i.resource?`${r}/${i.resource}`:r}function l(e=""){let t="",n="",i="";const r=e.indexOf("/");r>0&&(i=e.slice(r+1),e=e.slice(0,r));const s=e.indexOf("@");s>0&&(t=e.slice(0,s),e=e.slice(s+1)),n=e;const l=a({domain:n,local:t,resource:i});return{bare:c({local:l.local,domain:l.domain},{escaped:!0,prepared:!0}),domain:l.domain,full:c(l,{escaped:!0,prepared:!0}),local:o(l.local),resource:l.resource}}function u(e){return!!l(e).resource}function p(e=""){return l(e).bare}t.escapeLocal=s,t.unescapeLocal=o,t.prepare=a,t.create=c,t.createFull=function(e,t){return t?`${p(e)}/${t}`:p(e)},t.parse=l,t.allowedResponders=function(e,t){const n=new Set;if(n.add(void 0),n.add(""),e){const t=l(e);n.add(t.full),n.add(t.bare),n.add(t.domain)}if(t){const e=l(t);n.add(e.domain),n.add(e.bare),n.add(e.full)}return n},t.equal=function(e,t){if(!e||!t)return!1;const n=l(e),i=l(t);return n.local===i.local&&n.domain===i.domain&&n.resource===i.resource},t.equalBare=function(e,t){if(!e||!t)return!1;const n=l(e),i=l(t);return n.local===i.local&&n.domain===i.domain},t.isFull=u,t.isBare=function(e){return!u(e)},t.getLocal=function(e=""){return l(e).local},t.getDomain=function(e=""){return l(e).domain},t.getResource=function(e=""){return l(e).resource},t.toBare=p,t.parseURI=function(e){const t=new URL(e);if("xmpp:"!==t.protocol)throw new Error("Invalid XMPP URI, wrong protocol: "+t.protocol);const n=t.hostname?t.username?c({domain:decodeURIComponent(t.hostname),local:decodeURIComponent(t.username)},{escaped:!0}):decodeURIComponent(t.hostname):void 0,i=l(decodeURIComponent(n?t.pathname.substr(1):t.pathname)).full,r=t.search&&t.search.indexOf(";")>=1,s=r?t.search.substr(t.search.indexOf(";")+1):"",o=t.search?decodeURIComponent(t.search.substr(1,r?t.search.indexOf(";")-1:void 0)):void 0,a={};for(const e of s.split(";")){const[t,n]=e.split("=").map(decodeURIComponent);if(a[t]){const e=a[t];Array.isArray(e)?e.push(n):a[t]=[e,n]}else a[t]=n}return{action:o,identity:n,jid:i,parameters:a}},t.toURI=function(e){const t=["xmpp:"],n=(e,n)=>{const i=l(e);i.local&&(t.push(encodeURIComponent(s(i.local))),t.push("@")),t.push(encodeURIComponent(i.domain)),n&&i.resource&&(t.push("/"),t.push(encodeURIComponent(i.resource)))};e.identity&&(t.push("//"),n(e.identity,!1),e.jid&&t.push("/")),e.jid&&n(e.jid,!0),e.action&&(t.push("?"),t.push(encodeURIComponent(e.action)));for(const[n,i]of Object.entries(e.parameters||{}))for(const e of Array.isArray(i)?i:[i])t.push(";"),t.push(encodeURIComponent(n)),void 0!==e&&(t.push("="),t.push(encodeURIComponent(e)));return t.join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saslprep=t.resourceprep=t.nodeprep=t.NodePrepProhibited=t.nameprep=t.prepare=t.D2=t.D1=t.C9=t.C8=t.C7=t.C6=t.C5=t.C4=t.C3=t.C22=t.C21=t.C12=t.C11=t.B3=t.B2=t.B1=t.A1=t.Table=void 0;const i=n(0).__importDefault(n(4)),r=n(119);class s{constructor(e,t){this.singles=new Set,this.ranges=[],this.mappings=new Map;const n=r.TABLE_DATA[e];this.name=e,n?(n.s&&(this.singles=new Set(n.s.split("|").map(e=>parseInt(e,32)))),n.r&&(this.ranges=n.r.split("|").map(e=>{const[t,n]=e.split(":");return[parseInt(t,32),parseInt(n,32)]})),n.m&&(this.mappings=new Map(n.m.split("|").map(e=>{const[t,n]=e.split(":"),i=n.split(";").map(e=>parseInt(e,32));return[parseInt(t,32),i]})))):t&&(this.singles=new Set(t))}contains(e){if(this.singles.has(e))return!0;let t=0,n=this.ranges.length-1;for(;t<=n;){const i=Math.floor((t+n)/2),r=this.ranges[i];if(e<r[0])n=i-1;else{if(!(e>r[1]))return!0;t=i+1}}return!1}hasMapping(e){return this.mappings.has(e)||this.contains(e)}map(e){return this.contains(e)&&!this.mappings.has(e)?String.fromCodePoint(e).toLowerCase().codePointAt(0):this.mappings.get(e)||null}}function o(e,n,r=""){const s=i.default.ucs2.decode(r);let o=[];for(const t of s){if(!n&&e.unassigned.contains(t))throw new Error("Unassigned code point: x"+t.toString(16));let i=!1;for(const n of e.mappings){if(!n.hasMapping(t))continue;i=!0;const e=n.map(t);e&&(Array.isArray(e)?o=o.concat(e):o.push(e))}i||o.push(t)}let a=o;if(e.normalize){const e=i.default.ucs2.encode(o).normalize("NFKC");a=i.default.ucs2.decode(e)}let c=!1,l=!1;for(const i of a){for(const t of e.prohibited)if(t.contains(i))throw new Error("Prohibited code point: x"+i.toString(16));if(!n&&e.unassigned.contains(i))throw new Error("Prohibited code point: x"+i.toString(16));e.bidirectional&&(c=c||t.D1.contains(i),l=l||t.D2.contains(i))}if(e.bidirectional){if(c&&l)throw new Error("String contained both LCat and RandALCat code points");if(c&&(!t.D1.contains(a[0])||!t.D1.contains(a[a.length-1])))throw new Error("String containing RandALCat code points must start and end with RandALCat code points")}return i.default.ucs2.encode(a)}t.Table=s,t.A1=new s("A.1"),t.B1=new s("B.1"),t.B2=new s("B.2"),t.B3=new s("B.3"),t.C11=new s("C.1.1"),t.C12=new s("C.1.2"),t.C21=new s("C.2.1"),t.C22=new s("C.2.2"),t.C3=new s("C.3"),t.C4=new s("C.4"),t.C5=new s("C.5"),t.C6=new s("C.6"),t.C7=new s("C.7"),t.C8=new s("C.8"),t.C9=new s("C.9"),t.D1=new s("D.1"),t.D2=new s("D.2"),t.B1.map=()=>null,t.C11.contains=e=>32===e,t.C12.map=e=>t.C12.contains(e)?32:null,t.prepare=o;const a={bidirectional:!0,mappings:[t.B1,t.B2],normalize:!0,prohibited:[t.C12,t.C22,t.C3,t.C4,t.C5,t.C6,t.C7,t.C8,t.C9],unassigned:t.A1};t.nameprep=function(e,t=!0){return o(a,t,e)},t.NodePrepProhibited=new s("NodePrepProhibited",[34,38,39,47,58,60,62,64]);const c={bidirectional:!0,mappings:[t.B1,t.B2],normalize:!0,prohibited:[t.C11,t.C12,t.C21,t.C22,t.C3,t.C4,t.C5,t.C6,t.C7,t.C8,t.C9,t.NodePrepProhibited],unassigned:t.A1};t.nodeprep=function(e,t=!0){return o(c,t,e)};const l={bidirectional:!0,mappings:[t.B1],normalize:!0,prohibited:[t.C12,t.C21,t.C22,t.C3,t.C4,t.C5,t.C6,t.C7,t.C8,t.C9],unassigned:t.A1};t.resourceprep=function(e,t=!0){return o(l,t,e)};const u={bidirectional:!0,mappings:[t.C12,t.B1],normalize:!0,prohibited:[t.C12,t.C21,t.C22,t.C3,t.C4,t.C5,t.C6,t.C7,t.C8,t.C9],unassigned:t.A1};t.saslprep=function(e,t=!1){return o(u,t,e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TABLE_DATA=void 0,t.TABLE_DATA={"A.1":{r:"hk:if|le:lf|nf:nv|qg:qv|rg:rj|rm:rp|rr:rt|rv:s3|vn:vv|17m:17n|17q:17v|18g:19g|1an:1ao|1cb:1cg|1e5:1ef|1fb:1ff|1fl:1gb|1gd:1gq|1gs:1gu|1hr:1hv|1im:1iv|1ne:1nf|1pd:1pf|1qb:1rv|1ti:280|29q:29r|2ae:2af|2al:2an|2bh:2c0|2cd:2ce|2ch:2ci|2dj:2dl|2dq:2dr|2e5:2e6|2e9:2ea|2ee:2em|2eo:2er|2f4:2f5|2fr:2g1|2g3:2g4|2gb:2ge|2gh:2gi|2hq:2hr|2i3:2i6|2i9:2ia|2ie:2io|2iv:2j5|2jl:2k0|2lq:2lr|2me:2mf|2mh:2mv|2n1:2n5|2ng:2o0|2od:2oe|2oh:2oi|2pk:2pl|2pq:2pr|2q4:2q6|2q9:2qa|2qe:2ql|2qo:2qr|2r2:2r5|2rh:2s1|2sb:2sd|2sm:2so|2t0:2t2|2t5:2t7|2tb:2td|2tq:2tt|2u3:2u5|2ue:2um|2uo:2v6|2vj:300|31q:31t|32e:32k|32n:32v|332:335|33g:341|35q:35t|36e:36k|36n:36t|372:375|37g:381|39q:39t|3a4:3a5|3ae:3am|3ao:3av|3b2:3b5|3bg:3c1|3cn:3cp|3du:3dv|3e7:3e9|3eb:3ee|3f0:3fh|3fl:3g0|3hr:3hu|3is:3k0|3k5:3k6|3kb:3kc|3ke:3kj|3l8:3l9|3lu:3lv|3me:3mf|3mq:3mr|3mu:3nv|3rb:3rg|3sc:3sf|3ud:3ue|3ug:3vv|41j:41l|41q:41v|42q:44v|466:46f|47p:47q|47s:47v|4aq:4au|4d3:4d7|4fq:4fv|4ie:4if|4iu:4iv|4ke:4kf|4lm:4ln|4m6:4m7|4om:4on|4qr:4r0|4rt:4sv|4vl:500|5jn:5jv|5kt:5kv|5nh:5nv|5ol:5ov|5pn:5pv|5qk:5qv|5rk:5rv|5ut:5uv|5va:5vv|60q:60v|63o:63v|65a:7fv|7ks:7kv|7nq:7nv|7om:7on|7ou:7ov|7q6:7q7|7qe:7qf|7ru:7rv|7uk:7ul|7vg:7vh|82j:82m|82o:82u|834:839|83i:83j|84f:84v|85i:86f|87b:87v|89r:89s|8ac:8ai|8c4:8cf|8uf:8vv|917:91v|92b:92v|9gk:9gl|9ju:9jv|9ka:9o0|9oa:9ob|9qj:9ql|9qv:9r0|9sl:9sn|9tv:9uf|9vc:9vf|ao0:bjv|bnk:bnv|bum:bvf|bvs:bvv|c4n:c4o|c80:c84|c9d:c9g|cdo:cff|cgt:cgv|ci4:cig|cjs:cju|cmc:cmf|crn:crq|cuu:cuv|jdm:jfv|17t6:17vv|194d:194f|1967:1avv|1lt4:1lvv|1uhe:1uhf|1ujb:1unv|1uo7:1uoi|1uoo:1uos|1uti:1uui|1va0:1vaf|1vcg:1vch|1ve8:1vef|1vft:1vfv|1vgg:1vgv|1vh4:1vhf|1vi7:1vi8|1vjc:1vjf|1vnt:1vnu|1vtv:1vu1|1vu8:1vu9|1vug:1vuh|1vuo:1vup|1vut:1vuv|1vvf:1vvo|2000:20nv|20p4:20pf|20qb:20vv|2116:2117|212e:3jvv|3k7m:3k7v|3k97:3k99|3keu:3kvv|3l50:3l51|3l53:3l54|3l57:3l58|3l8b:3l8c|3la7:3la9|3ll4:3ll7|3lua:3lud|3m00:3vvt|59mn:5tvv|5ugu:5vvt|6000:7vvt|8000:9vvt|a000:bvvt|c000:dvvt|e000:fvvt|g000:hvvt|i000:jvvt|k000:lvvt|m000:nvvt|o000:pvvt|q000:rvvt|s002:s00v|s040:tvvt",s:"9p8|9qc|9qe|9qn|9tg|147|bkq|3l2l|3l4t|3l5d|3l5q|3l5s|3l61|3l64|3l86|3l8l|3l8t|3l9q|3l9v|3la5|3lah|16f|c20|ccf|cnv|cvv|1b0|1c8|1d2|1dq|1h0|1nv|1oe|284|2c4|2d9|2dh|2dt|2eu|2h9|2hh|2hk|2hn|2ht|2it|2k4|2kc|2ke|2ki|2l9|2lh|2lk|2m6|2ma|2o4|2p9|2ph|2qu|2s4|2sh|2sr|2st|2tm|2u9|304|30d|30h|319|31k|325|329|344|34d|34h|359|35k|365|369|36v|384|38d|38h|399|3a9|3c4|3di|3ds|3el|3en|3k3|3k9|3ko|3l0|3l4|3l6|3lc|3lq|3m5|3m7|3q8|3so|3tt|412|418|41b|4g7|4i7|4i9|4in|4ip|4k7|4k9|4lf|4lh|4lv|4m1|4mf|4mn|4nf|4of|4oh|4ov|4q7|h1|5od|5rd|5rh|60f|1upn|1upt|1upv|1uq2|1uq5|1vij|1vj7|1vjl|1vo0|1vv7|20ov|7qo|7qq|7qs|7qu|7tl|7u5|7us|7vl|7vv|sb|sd|s000|t2|97v|uf|9go|9o5"},"B.1":{r:"60b:60d|80b:80d|1vg0:1vgf",s:"5d|606|1vnv|830|qf"},"B.2":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|rq:10;tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ui:u5|uj:ud|uk:ub|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|858:3i;3j|882:33|883:5g;33|887:ir|889:5g;36|88b:38|88c:38|88d:38|88g:39|88h:39|88i:3c|88l:3e|88m:3e;3f|88p:3g|88q:3h|88r:3i|88s:3i|88t:3i|890:3j;3d|891:3k;35;3c|892:3k;3d|894:3q|898:3q|89c:32|89d:33|89g:35|89h:36|89j:3d|89u:tj|89v:u0|8a5:34|crh:38;3g;31|crj:31;3l|crl:3f;3m|cs0:3g;31|cs1:3e;31|cs2:ts;31|cs3:3d;31|cs4:3b;31|cs5:3b;32|cs6:3d;32|cs7:37;32|csa:3g;36|csb:3e;36|csc:ts;36|csg:38;3q|csh:3b;38;3q|csi:3d;38;3q|csj:37;38;3q|csk:3k;38;3q|ct9:3g;31|cta:3b;3g;31|ctb:3d;3g;31|ctc:37;3g;31|ctk:3g;3m|ctl:3e;3m|ctm:ts;3m|ctn:3d;3m|cto:3b;3m|ctp:3d;3m|ctq:3g;3n|ctr:3e;3n|cts:ts;3n|ctt:3d;3n|ctu:3b;3n|ctv:3d;3n|cu0:3b;u9|cu1:3d;u9|cu3:32;3h|cu6:33;8gl;3b;37|cu7:33;3f;1e|cu8:34;32|cu9:37;3p|cub:38;3g|cud:3b;3b|cue:3b;3d|cun:3g;38|cup:3g;3g;3d|cuq:3g;3i|cus:3j;3m|cut:3n;32|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd|3l00:31|3l01:32|3l02:33|3l03:34|3l04:35|3l05:36|3l06:37|3l07:38|3l08:39|3l09:3a|3l0a:3b|3l0b:3c|3l0c:3d|3l0d:3e|3l0e:3f|3l0f:3g|3l0g:3h|3l0h:3i|3l0i:3j|3l0j:3k|3l0k:3l|3l0l:3m|3l0m:3n|3l0n:3o|3l0o:3p|3l0p:3q|3l1k:31|3l1l:32|3l1m:33|3l1n:34|3l1o:35|3l1p:36|3l1q:37|3l1r:38|3l1s:39|3l1t:3a|3l1u:3b|3l1v:3c|3l20:3d|3l21:3e|3l22:3f|3l23:3g|3l24:3h|3l25:3i|3l26:3j|3l27:3k|3l28:3l|3l29:3m|3l2a:3n|3l2b:3o|3l2c:3p|3l2d:3q|3l38:31|3l39:32|3l3a:33|3l3b:34|3l3c:35|3l3d:36|3l3e:37|3l3f:38|3l3g:39|3l3h:3a|3l3i:3b|3l3j:3c|3l3k:3d|3l3l:3e|3l3m:3f|3l3n:3g|3l3o:3h|3l3p:3i|3l3q:3j|3l3r:3k|3l3s:3l|3l3t:3m|3l3u:3n|3l3v:3o|3l40:3p|3l41:3q|3l4s:31|3l4u:33|3l4v:34|3l52:37|3l55:3a|3l56:3b|3l59:3e|3l5a:3f|3l5b:3g|3l5c:3h|3l5e:3j|3l5f:3k|3l5g:3l|3l5h:3m|3l5i:3n|3l5j:3o|3l5k:3p|3l5l:3q|3l6g:31|3l6h:32|3l6i:33|3l6j:34|3l6k:35|3l6l:36|3l6m:37|3l6n:38|3l6o:39|3l6p:3a|3l6q:3b|3l6r:3c|3l6s:3d|3l6t:3e|3l6u:3f|3l6v:3g|3l70:3h|3l71:3i|3l72:3j|3l73:3k|3l74:3l|3l75:3m|3l76:3n|3l77:3o|3l78:3p|3l79:3q|3l84:31|3l85:32|3l87:34|3l88:35|3l89:36|3l8a:37|3l8d:3a|3l8e:3b|3l8f:3c|3l8g:3d|3l8h:3e|3l8i:3f|3l8j:3g|3l8k:3h|3l8m:3j|3l8n:3k|3l8o:3l|3l8p:3m|3l8q:3n|3l8r:3o|3l8s:3p|3l9o:31|3l9p:32|3l9r:34|3l9s:35|3l9t:36|3l9u:37|3la0:39|3la1:3a|3la2:3b|3la3:3c|3la4:3d|3la6:3f|3laa:3j|3lab:3k|3lac:3l|3lad:3m|3lae:3n|3laf:3o|3lag:3p|3lbc:31|3lbd:32|3lbe:33|3lbf:34|3lbg:35|3lbh:36|3lbi:37|3lbj:38|3lbk:39|3lbl:3a|3lbm:3b|3lbn:3c|3lbo:3d|3lbp:3e|3lbq:3f|3lbr:3g|3lbs:3h|3lbt:3i|3lbu:3j|3lbv:3k|3lc0:3l|3lc1:3m|3lc2:3n|3lc3:3o|3lc4:3p|3lc5:3q|3ld0:31|3ld1:32|3ld2:33|3ld3:34|3ld4:35|3ld5:36|3ld6:37|3ld7:38|3ld8:39|3ld9:3a|3lda:3b|3ldb:3c|3ldc:3d|3ldd:3e|3lde:3f|3ldf:3g|3ldg:3h|3ldh:3i|3ldi:3j|3ldj:3k|3ldk:3l|3ldl:3m|3ldm:3n|3ldn:3o|3ldo:3p|3ldp:3q|3lek:31|3lel:32|3lem:33|3len:34|3leo:35|3lep:36|3leq:37|3ler:38|3les:39|3let:3a|3leu:3b|3lev:3c|3lf0:3d|3lf1:3e|3lf2:3f|3lf3:3g|3lf4:3h|3lf5:3i|3lf6:3j|3lf7:3k|3lf8:3l|3lf9:3m|3lfa:3n|3lfb:3o|3lfc:3p|3lfd:3q|3lg8:31|3lg9:32|3lga:33|3lgb:34|3lgc:35|3lgd:36|3lge:37|3lgf:38|3lgg:39|3lgh:3a|3lgi:3b|3lgj:3c|3lgk:3d|3lgl:3e|3lgm:3f|3lgn:3g|3lgo:3h|3lgp:3i|3lgq:3j|3lgr:3k|3lgs:3l|3lgt:3m|3lgu:3n|3lgv:3o|3lh0:3p|3lh1:3q|3lhs:31|3lht:32|3lhu:33|3lhv:34|3li0:35|3li1:36|3li2:37|3li3:38|3li4:39|3li5:3a|3li6:3b|3li7:3c|3li8:3d|3li9:3e|3lia:3f|3lib:3g|3lic:3h|3lid:3i|3lie:3j|3lif:3k|3lig:3l|3lih:3m|3lii:3n|3lij:3o|3lik:3p|3lil:3q|3ljg:31|3ljh:32|3lji:33|3ljj:34|3ljk:35|3ljl:36|3ljm:37|3ljn:38|3ljo:39|3ljp:3a|3ljq:3b|3ljr:3c|3ljs:3d|3ljt:3e|3lju:3f|3ljv:3g|3lk0:3h|3lk1:3i|3lk2:3j|3lk3:3k|3lk4:3l|3lk5:3m|3lk6:3n|3lk7:3o|3lk8:3p|3lk9:3q|3ll8:th|3ll9:ti|3lla:tj|3llb:tk|3llc:tl|3lld:tm|3lle:tn|3llf:to|3llg:tp|3llh:tq|3lli:tr|3llj:ts|3llk:tt|3lll:tu|3llm:tv|3lln:u0|3llo:u1|3llp:to|3llq:u3|3llr:u4|3lls:u5|3llt:u6|3llu:u7|3llv:u8|3lm0:u9|3lmj:u3|3ln2:th|3ln3:ti|3ln4:tj|3ln5:tk|3ln6:tl|3ln7:tm|3ln8:tn|3ln9:to|3lna:tp|3lnb:tq|3lnc:tr|3lnd:ts|3lne:tt|3lnf:tu|3lng:tv|3lnh:u0|3lni:u1|3lnj:to|3lnk:u3|3lnl:u4|3lnm:u5|3lnn:u6|3lno:u7|3lnp:u8|3lnq:u9|3lod:u3|3los:th|3lot:ti|3lou:tj|3lov:tk|3lp0:tl|3lp1:tm|3lp2:tn|3lp3:to|3lp4:tp|3lp5:tq|3lp6:tr|3lp7:ts|3lp8:tt|3lp9:tu|3lpa:tv|3lpb:u0|3lpc:u1|3lpd:to|3lpe:u3|3lpf:u4|3lpg:u5|3lph:u6|3lpi:u7|3lpj:u8|3lpk:u9|3lq7:u3|3lqm:th|3lqn:ti|3lqo:tj|3lqp:tk|3lqq:tl|3lqr:tm|3lqs:tn|3lqt:to|3lqu:tp|3lqv:tq|3lr0:tr|3lr1:ts|3lr2:tt|3lr3:tu|3lr4:tv|3lr5:u0|3lr6:u1|3lr7:to|3lr8:u3|3lr9:u4|3lra:u5|3lrb:u6|3lrc:u7|3lrd:u8|3lre:u9|3ls1:u3|3lsg:th|3lsh:ti|3lsi:tj|3lsj:tk|3lsk:tl|3lsl:tm|3lsm:tn|3lsn:to|3lso:tp|3lsp:tq|3lsq:tr|3lsr:ts|3lss:tt|3lst:tu|3lsu:tv|3lsv:u0|3lt0:u1|3lt1:to|3lt2:u3|3lt3:u4|3lt4:u5|3lt5:u6|3lt6:u7|3lt7:u8|3lt8:u9|3ltr:u3",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"B.3":{m:"5l:ts|6v:3j;3j|9g:39;o7|a9:ls;3e|bv:3j|fg:3a;oc|q5:tp|sg:tp;o8;o1|tg:u5;o8;o1|u2:u3|ug:ti|uh:to|ul:u6|um:u0|vg:tq|vh:u1|vi:u3|vl:tl|1c7:1b5;1c2|7km:38;ph|7kn:3k;o8|7ko:3n;oa|7kp:3p;oa|7kq:31;lu|7kr:7j1|7qg:u5;oj|7qi:u5;oj;o0|7qk:u5;oj;o1|7qm:u5;oj;q2|7s0:7o0;tp|7s1:7o1;tp|7s2:7o2;tp|7s3:7o3;tp|7s4:7o4;tp|7s5:7o5;tp|7s6:7o6;tp|7s7:7o7;tp|7s8:7o0;tp|7s9:7o1;tp|7sa:7o2;tp|7sb:7o3;tp|7sc:7o4;tp|7sd:7o5;tp|7se:7o6;tp|7sf:7o7;tp|7sg:7p0;tp|7sh:7p1;tp|7si:7p2;tp|7sj:7p3;tp|7sk:7p4;tp|7sl:7p5;tp|7sm:7p6;tp|7sn:7p7;tp|7so:7p0;tp|7sp:7p1;tp|7sq:7p2;tp|7sr:7p3;tp|7ss:7p4;tp|7st:7p5;tp|7su:7p6;tp|7sv:7p7;tp|7t0:7r0;tp|7t1:7r1;tp|7t2:7r2;tp|7t3:7r3;tp|7t4:7r4;tp|7t5:7r5;tp|7t6:7r6;tp|7t7:7r7;tp|7t8:7r0;tp|7t9:7r1;tp|7ta:7r2;tp|7tb:7r3;tp|7tc:7r4;tp|7td:7r5;tp|7te:7r6;tp|7tf:7r7;tp|7ti:7rg;tp|7tj:th;tp|7tk:tc;tp|7tm:th;q2|7tn:th;q2;tp|7ts:th;tp|7tu:tp|7u2:7rk;tp|7u3:tn;tp|7u4:te;tp|7u6:tn;q2|7u7:tn;q2;tp|7uc:tn;tp|7ui:tp;o8;o0|7uj:tp;o8;o1|7um:tp;q2|7un:tp;o8;q2|7v2:u5;o8;o0|7v3:u5;o8;o1|7v4:u1;oj|7v6:u5;q2|7v7:u5;o8;q2|7vi:7rs;tp|7vj:u9;tp|7vk:ue;tp|7vm:u9;q2|7vn:u9;q2;tp|7vs:u9;tp|1uo0:36;36|1uo1:36;39|1uo2:36;3c|1uo3:36;36;39|1uo4:36;36;3c|1uo5:3j;3k|1uo6:3j;3k|1uoj:1bk;1bm|1uok:1bk;1b5|1uol:1bk;1bb|1uom:1bu;1bm|1uon:1bk;1bd",r:"23:2c|2i:2k|2m:2q|60:6m|6o:6u|bo:bp|c1:c2|c6:c7|c9:cb|ce:ch|cj:ck|cm:co|cs:ct|cv:d0|d6:d7|de:df|dh:dj|dn:do|e4:e5|e7:e8|ea:eb|fh:fi|fm:fo|s8:sa|se:sf|sh:t1|t3:tb|100:11f|19h:1am|7o8:7of|7oo:7ot|7p8:7pf|7po:7pv|7q8:7qd|7r8:7rf|7to:7tr|7u8:7ub|7uo:7ur|7v8:7vc|7vo:7vr|89a:89b|8b0:8bf|95m:96f|1vp1:1vpq|2100:2115",s:"v8|va|vc|ve|vk|130|132|134|136|138|13a|13c|13e|13g|13i|13k|13m|13o|13q|13s|13u|140|14a|14c|14e|14g|14i|14k|14m|14o|14q|14s|14u|150|152|154|156|158|15a|15c|15e|15g|15i|15k|15m|15o|15q|15s|15u|161|163|165|167|169|16b|16d|16g|16i|16k|16m|16o|16q|16s|16u|170|172|174|176|178|17a|17c|17e|17g|17i|17k|17o|180|182|184|186|188|18a|18c|18e|80|82|84|86|88|8a|8c|8e|8g|8i|8k|8m|8o|8q|8s|8u|90|92|94|96|98|9a|9c|9e|9i|9k|9m|9p|9r|9t|9v|a1|a3|a5|a7|aa|ac|ae|ag|ai|ak|am|ao|aq|as|au|b0|b2|b4|b6|b8|ba|bc|be|bg|bi|bk|bm|br|bt|c4|d2|d4|d9|dc|dl|ds|ed|ef|eh|ej|el|en|ep|er|eu|f0|f2|f4|f6|f8|fa|fc|fe|fk|fq|fs|fu|g0|g2|g4|g6|g8|ga|gc|ge|gg|gi|gk|gm|go|gq|gs|gu|h0|h2|h4|h6|h8|ha|hc|he|hg|hi|21|22|7g0|7g2|7g4|7g6|7g8|7ga|7gc|7ge|7gg|7gi|2d|7gk|7gm|7go|7gq|7gs|7gu|7h0|7h2|7h4|7h6|7h8|7ha|7hc|7he|7hg|7hi|7hk|7hm|7ho|7hq|7hs|7hu|7i0|7i2|7i4|7i6|7i8|7ia|7ic|7ie|7ig|7ii|7ik|7im|7io|7iq|7is|7iu|7j0|7j2|7j4|7j6|7j8|7ja|7jc|7je|7jg|7ji|7jk|7jm|2e|7jo|7jq|7js|7ju|7k0|7k2|7k4|7k6|7k8|7ka|7kc|7ke|7kg|7ki|7kk|7l0|7l2|7l4|7l6|7l8|7la|7lc|7le|7lg|7li|7lk|7lm|7lo|7lq|7ls|7lu|7m0|7m2|7m4|7m6|7m8|7ma|7mc|7me|7mg|7mi|7mk|7mm|7mo|7mq|2f|7ms|7mu|7n0|7n2|7n4|7n6|7n8|7na|7nc|7ne|7ng|7ni|7nk|7nm|7no|2g|7qp|7qr|7qt|7qv|2h|896|2l|s6|sc|uo|uq|us|uu|v0|v2|v4|v6"},"C.1.1":{s:"10"},"C.1.2":{r:"800:80b",s:"c00|50|5k0|81f|82v"},"C.2.1":{r:"0:v",s:"3v"},"C.2.2":{r:"40:4v|80c:80d|818:819|830:833|83a:83f|1vvp:1vvs|3kbj:3kbq",s:"1mt|1of|60e|1vnv"},"C.3":{r:"1o00:1u7v|u000:vvvt|10000:11vvt"},"C.4":{r:"1veg:1vff|1vvu:1vvv|3vvu:3vvv|5vvu:5vvv|7vvu:7vvv|9vvu:9vvv|bvvu:bvvv|dvvu:dvvv|fvvu:fvvv|hvvu:hvvv|jvvu:jvvv|lvvu:lvvv|nvvu:nvvv|pvvu:pvvv|rvvu:rvvv|tvvu:tvvv|vvvu:vvvv|11vvu:11vvv"},"C.5":{r:"1m00:1nvv"},"C.6":{r:"1vvp:1vvt"},"C.7":{r:"bvg:bvr"},"C.8":{r:"q0:q1|80e:80f|81a:81e|83a:83f"},"C.9":{r:"s010:s03v",s:"s001"},"D.1":{r:"1eg:1fa|1fg:1fk|1h1:1hq|1i0:1ia|1jd:1jf|1jh:1ml|1n5:1n6|1nq:1nu|1o0:1od|1oi:1pc|1s0:1t5|1uov:1up8|1upa:1upm|1upo:1ups|1uq0:1uq1|1uq3:1uq4|1uq6:1uth|1uuj:1v9t|1vag:1vcf|1vci:1ve7|1vfg:1vfs|1vjg:1vjk|1vjm:1vns",s:"1du|1e0|1e3|1gr|1gv|1mt|1og|1th|1uot|1upu|80f"},"D.2":{r:"21:2q|31:3q|60:6m|6o:7m|7o:h0|h2:hj|ig:ld|lg:lo|lr:m1|mg:mh|n0:n4|s8:sa|se:t1|t3:ue|ug:vl|100:142|14a:16e|16g:17l|17o:17p|180:18f|19h:1am|1ap:1av|1b1:1c7|285:29p|29t:2a0|2a9:2ac|2ao:2b1|2b4:2bg|2c2:2c3|2c5:2cc|2cf:2cg|2cj:2d8|2da:2dg|2dm:2dp|2du:2e0|2e7:2e8|2eb:2ec|2es:2et|2ev:2f1|2f6:2fh|2fk:2fq|2g5:2ga|2gf:2gg|2gj:2h8|2ha:2hg|2hi:2hj|2hl:2hm|2ho:2hp|2hu:2i0|2ip:2is|2j6:2jf|2ji:2jk|2k5:2kb|2kf:2kh|2kj:2l8|2la:2lg|2li:2lj|2ll:2lp|2lt:2m0|2mb:2mc|2n6:2nf|2o2:2o3|2o5:2oc|2of:2og|2oj:2p8|2pa:2pg|2pi:2pj|2pm:2pp|2pt:2pu|2q7:2q8|2qb:2qc|2qs:2qt|2qv:2r1|2r6:2rg|2s5:2sa|2se:2sg|2si:2sl|2sp:2sq|2su:2sv|2t3:2t4|2t8:2ta|2te:2tl|2tn:2tp|2tu:2tv|2u1:2u2|2u6:2u8|2ua:2uc|2v7:2vi|301:303|305:30c|30e:30g|30i:318|31a:31j|31l:31p|321:324|330:331|336:33f|342:343|345:34c|34e:34g|34i:358|35a:35j|35l:35p|360:364|367:368|36a:36b|36l:36m|370:371|376:37f|382:383|385:38c|38e:38g|38i:398|39a:39p|39u:3a0|3a6:3a8|3aa:3ac|3b0:3b1|3b6:3bf|3c2:3c3|3c5:3cm|3cq:3dh|3dj:3dr|3e0:3e6|3ef:3eh|3eo:3ev|3fi:3fk|3g1:3hg|3hi:3hj|3i0:3i6|3if:3ir|3k1:3k2|3k7:3k8|3kk:3kn|3kp:3kv|3l1:3l3|3la:3lb|3ld:3lg|3li:3lj|3m0:3m4|3mg:3mp|3ms:3mt|3o0:3on|3oq:3pk|3pu:3q7|3q9:3ra|3s8:3sb|3tu:3u5|3u7:3uc|400:411|413:417|419:41a|420:42n|450:465|46g:47o|480:4ap|4av:4d2|4d8:4fp|4g0:4g6|4g8:4i6|4ia:4id|4ig:4im|4iq:4it|4j0:4k6|4ka:4kd|4kg:4le|4li:4ll|4lo:4lu|4m2:4m5|4m8:4me|4mg:4mm|4mo:4ne|4ng:4oe|4oi:4ol|4oo:4ou|4p0:4q6|4q8:4qq|4r1:4rs|4t0:4vk|501:5jm|5k1:5kq|5l0:5ng|5o0:5oc|5oe:5oh|5p0:5ph|5pl:5pm|5q0:5qh|5r0:5rc|5re:5rg|5s0:5tm|5tu:5u5|5u7:5u8|5uk:5uq|5v0:5v9|60g:60p|610:63n|640:658|7g0:7kr|7l0:7np|7o0:7ol|7oo:7ot|7p0:7q5|7q8:7qd|7qg:7qn|7qv:7rt|7s0:7tk|7tm:7ts|7u2:7u4|7u6:7uc|7ug:7uj|7um:7ur|7v0:7vc|7vi:7vk|7vm:7vs|88a:88j|88p:88t|89a:89d|89f:89h|89j:89p|89t:89v|8a5:8a9|8b0:8c3|8pm:8rq|94s:979|c05:c07|c11:c19|c1h:c1l|c1o:c1s|c21:c4m|c4t:c4v|c51:c7q|c7s:c7v|c85:c9c|c9h:cce|ccg:cdn|cfg:cgs|ch0:ci3|cj0:cjr|cjv:clg|cm0:cmb|cmg:cnu|co0:crm|crr:cut|cv0:cvu|d00:jdl|jg0:17t5|1800:194c|1b00:1lt3|1m00:1uhd|1uhg:1uja|1uo0:1uo6|1uoj:1uon|1vp1:1vpq|1vq1:1vqq|1vr6:1vtu|1vu2:1vu7|1vua:1vuf|1vui:1vun|1vuq:1vus|20o0:20ou|20p0:20p3|20pg:20qa|2100:2115|2118:212d|3k00:3k7l|3k80:3k96|3k9a:3kb6|3kba:3kbi|3kc3:3kc4|3kcc:3kd9|3kde:3ket|3l00:3l2k|3l2m:3l4s|3l4u:3l4v|3l55:3l56|3l59:3l5c|3l5e:3l5p|3l5t:3l60|3l62:3l63|3l65:3l85|3l87:3l8a|3l8d:3l8k|3l8m:3l8s|3l8u:3l9p|3l9r:3l9u|3la0:3la4|3laa:3lag|3lai:3ll3|3ll8:3lu9|4000:59mm|5u00:5ugt|u000:vvvt|10000:11vvt",s:"3l52|3l5r|3la6|1c9|5a|5l|5q|283|2ag|2di|2en|2iu|2k3|2kd|2m9|2mg|2n0|2q0|2qn|2s3|2ss|2un|35u|36u|3an|3dt|3k4|3ka|3kd|3l5|3l7|3lt|3m6|3pm|3po|3rv|3s5|3uf|41c|41h|41o|47r|4i8|4io|4k8|4lg|4m0|4og|5us|ne|7qp|7qr|7qt|7tu|80e|83h|83v|882|887|88l|894|896|898|rq|s6|sc|8sl"}}},function(e,t,n){"use strict";const i=n(121),r=Symbol("max"),s=Symbol("length"),o=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),l=Symbol("dispose"),u=Symbol("noDisposeOnSet"),p=Symbol("lruList"),d=Symbol("cache"),h=Symbol("updateAgeOnGet"),f=()=>1;const m=(e,t,n)=>{const i=e[d].get(t);if(i){const t=i.value;if(g(e,t)){if(b(e,i),!e[a])return}else n&&(e[h]&&(i.value.now=Date.now()),e[p].unshiftNode(i));return t.value}},g=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[c]&&n>e[c]},v=e=>{if(e[s]>e[r])for(let t=e[p].tail;e[s]>e[r]&&null!==t;){const n=t.prev;b(e,t),t=n}},b=(e,t)=>{if(t){const n=t.value;e[l]&&e[l](n.key,n.value),e[s]-=n.length,e[d].delete(n.key),e[p].removeNode(t)}};class y{constructor(e,t,n,i,r){this.key=e,this.value=t,this.length=n,this.now=i,this.maxAge=r||0}}const _=(e,t,n,i)=>{let r=n.value;g(e,r)&&(b(e,n),e[a]||(r=void 0)),r&&t.call(i,r.value,r.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[r]=e.max||1/0;const t=e.length||f;if(this[o]="function"!=typeof t?f:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[l]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[h]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[r]=e||1/0,v(this)}get max(){return this[r]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=f),e!==this[o]&&(this[o]=e,this[s]=0,this[p].forEach(e=>{e.length=this[o](e.value,e.key),this[s]+=e.length})),v(this)}get lengthCalculator(){return this[o]}get length(){return this[s]}get itemCount(){return this[p].length}rforEach(e,t){t=t||this;for(let n=this[p].tail;null!==n;){const i=n.prev;_(this,e,n,t),n=i}}forEach(e,t){t=t||this;for(let n=this[p].head;null!==n;){const i=n.next;_(this,e,n,t),n=i}}keys(){return this[p].toArray().map(e=>e.key)}values(){return this[p].toArray().map(e=>e.value)}reset(){this[l]&&this[p]&&this[p].length&&this[p].forEach(e=>this[l](e.key,e.value)),this[d]=new Map,this[p]=new i,this[s]=0}dump(){return this[p].map(e=>!g(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[p]}set(e,t,n){if((n=n||this[c])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const i=n?Date.now():0,a=this[o](t,e);if(this[d].has(e)){if(a>this[r])return b(this,this[d].get(e)),!1;const o=this[d].get(e).value;return this[l]&&(this[u]||this[l](e,o.value)),o.now=i,o.maxAge=n,o.value=t,this[s]+=a-o.length,o.length=a,this.get(e),v(this),!0}const h=new y(e,t,a,i,n);return h.length>this[r]?(this[l]&&this[l](e,t),!1):(this[s]+=h.length,this[p].unshift(h),this[d].set(e,this[p].head),v(this),!0)}has(e){if(!this[d].has(e))return!1;const t=this[d].get(e).value;return!g(this,t)}get(e){return m(this,e,!0)}peek(e){return m(this,e,!1)}pop(){const e=this[p].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[d].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const i=e[n],r=i.e||0;if(0===r)this.set(i.k,i.v);else{const e=r-t;e>0&&this.set(i.k,i.v,e)}}}prune(){this[d].forEach((e,t)=>m(this,t,!1))}}},function(e,t,n){"use strict";function i(e){var t=this;if(t instanceof i||(t=new i),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var n=0,r=arguments.length;n<r;n++)t.push(arguments[n]);return t}function r(e,t,n){var i=t===e.head?new a(n,null,t,e):new a(n,t,t.next,e);return null===i.next&&(e.tail=i),null===i.prev&&(e.head=i),e.length++,i}function s(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function o(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,n,i){if(!(this instanceof a))return new a(e,t,n,i);this.list=i,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}e.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},i.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},i.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},i.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},i.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},i.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},i.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},i.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,i=0;null!==n;i++)e.call(t,n.value,i,this),n=n.next},i.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,i=this.length-1;null!==n;i--)e.call(t,n.value,i,this),n=n.prev},i.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},i.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},i.prototype.map=function(e,t){t=t||this;for(var n=new i,r=this.head;null!==r;)n.push(e.call(t,r.value,this)),r=r.next;return n},i.prototype.mapReverse=function(e,t){t=t||this;for(var n=new i,r=this.tail;null!==r;)n.push(e.call(t,r.value,this)),r=r.prev;return n},i.prototype.reduce=function(e,t){var n,i=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,n=this.head.value}for(var r=0;null!==i;r++)n=e(n,i.value,r),i=i.next;return n},i.prototype.reduceReverse=function(e,t){var n,i=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,n=this.tail.value}for(var r=this.length-1;null!==i;r--)n=e(n,i.value,r),i=i.prev;return n},i.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},i.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},i.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new i;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var r=0,s=this.head;null!==s&&r<e;r++)s=s.next;for(;null!==s&&r<t;r++,s=s.next)n.push(s.value);return n},i.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new i;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var r=this.length,s=this.tail;null!==s&&r>t;r--)s=s.prev;for(;null!==s&&r>e;r--,s=s.prev)n.push(s.value);return n},i.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var i=0,s=this.head;null!==s&&i<e;i++)s=s.next;var o=[];for(i=0;s&&i<t;i++)o.push(s.value),s=this.removeNode(s);null===s&&(s=this.tail),s!==this.head&&s!==this.tail&&(s=s.prev);for(i=0;i<n.length;i++)s=r(this,s,n[i]);return o},i.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var i=n.prev;n.prev=n.next,n.next=i}return this.head=t,this.tail=e,this};try{n(122)(i)}catch(e){}},function(e,t,n){"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},function(e,t,n){(function(t){var n=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,s=/^0o[0-7]+$/i,o=parseInt,a="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,l=a||c||Function("return this")(),u=Object.prototype.toString,p=Math.max,d=Math.min,h=function(){return l.Date.now()};function f(e,t,n){var i,r,s,o,a,c,l=0,u=!1,f=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=i,s=r;return i=r=void 0,l=t,o=e.apply(s,n)}function y(e){return l=e,a=setTimeout(S,t),u?b(e):o}function _(e){var n=e-c;return void 0===c||n>=t||n<0||f&&e-l>=s}function S(){var e=h();if(_(e))return w(e);a=setTimeout(S,function(e){var n=t-(e-c);return f?d(n,s-(e-l)):n}(e))}function w(e){return a=void 0,v&&i?b(e):(i=r=void 0,o)}function x(){var e=h(),n=_(e);if(i=arguments,r=this,c=e,n){if(void 0===a)return y(c);if(f)return a=setTimeout(S,t),b(c)}return void 0===a&&(a=setTimeout(S,t)),o}return t=g(t)||0,m(n)&&(u=!!n.leading,s=(f="maxWait"in n)?p(g(n.maxWait)||0,t):s,v="trailing"in n?!!n.trailing:v),x.cancel=function(){void 0!==a&&clearTimeout(a),l=0,i=c=r=a=void 0},x.flush=function(){return void 0===a?o:w(h())},x}function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==u.call(e)}(e))return NaN;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var a=r.test(e);return a||s.test(e)?o(e.slice(2),a?2:8):i.test(e)?NaN:+e}e.exports=function(e,t,n){var i=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return m(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),f(e,t,{leading:i,maxWait:t,trailing:r})}}).call(this,n(5))},function(e,t,n){e.exports=function(){"use strict";var e="undefined"==typeof window,t=!1,n=!1,i=!1,r=!1,s=!1,o=!1,a=!1,c=!1,l=!1,u=!1;return e||(t="undefined"!=typeof InstallTrigger,n=!!window.chrome,i=!(!window.chrome||!window.navigator||!window.navigator.plugins||!window.navigator.plugins.namedItem("Chrome PDF Plugin")&&!window.chrome.runtime),r=n&&!window.chrome.webstore&&!window.chrome.runtime,s=0<Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")||window.safari&&window.safari.pushNotification,o=!!window.opr&&!!window.opr.addons||!!window.opera,a=!!window.StyleMedia,c=n&&!!navigator.userAgent.match(/edg/i),l=(i||o)&&!!window.CSS,u=!(n||s||t||o||!document.documentMode)),{get isChrome(){return i},get isChromeOrChromium(){return n},get isChromium(){return r},get isFirefox(){return t},get isSafari(){return s},get isOpera(){return o},get isEdge(){return a},get isEdgeChromium(){return c},get isIE(){return u},get isBlink(){return l}}}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.definitions=void 0;const i=n(57),r=n(11),s={aliases:["message.propose"],element:"propose",fields:{conversationId:i.attribute("inin-cid"),persistentConversationId:i.attribute("inin-persistent-cid"),originalRoomJid:i.attribute("inin-ofrom"),autoAnswer:i.booleanAttribute("inin-autoanswer"),fromUserId:i.attribute("inin-user-id"),sessionId:i.attribute("id")},namespace:"urn:xmpp:jingle-message:0"},o={aliases:["message.proceed"],element:"proceed",fields:{sessionId:i.attribute("id")},namespace:"urn:xmpp:jingle-message:0"},a={aliases:["message.accept"],element:"accept",fields:{sessionId:i.attribute("id")},namespace:"urn:xmpp:jingle-message:0"},c={aliases:["message.reject"],element:"reject",fields:{sessionId:i.attribute("id")},namespace:"urn:xmpp:jingle-message:0"},l={aliases:["message.retract"],element:"retract",fields:{sessionId:i.attribute("id")},namespace:"urn:xmpp:jingle-message:0"},u={aliases:["iq.jingle.screenstart"],element:"screen-start",namespace:r.NS_JINGLE_RTP_INFO_1},p={aliases:["iq.jingle.screenstop"],element:"screen-stop",namespace:r.NS_JINGLE_RTP_INFO_1},d={aliases:["presence.media"],element:"x",fields:{conversationId:i.attribute("conversationId"),sourceCommunicationId:i.attribute("sourceCommunicationId"),screenShare:i.childAttribute(null,"mediastream","screenShare"),video:i.childAttribute(null,"mediastream","video"),audio:i.childAttribute(null,"mediastream","audio"),listener:i.childAttribute(null,"mediastream","listener"),screenRecording:i.childAttribute(null,"mediastream","screenRecording")},namespace:"orgspan:mediastream"};t.definitions=[s,o,a,c,l,u,p,d]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(24),s=i.__importDefault(n(127)),o=i.__importDefault(n(58));t.default=class{constructor(){this.translators=new Map,this.root=new o.default,this.setLanguageResolver(r.basicLanguageResolver)}setLanguageResolver(e){this.languageResolver=e}import(e,t={registry:this}){if(!this.hasTranslator(e.getNamespace(),e.getName()))return;t.acceptLanguages||(t.acceptLanguages=[]),t.acceptLanguages=t.acceptLanguages.map(e=>e.toLowerCase()),t.lang&&(t.lang=t.lang.toLowerCase()),t.resolveLanguage||(t.resolveLanguage=this.languageResolver),t.path=this.getImportKey(e),t.sanitizers||(t.sanitizers={xhtmlim:s.default});return this.getOrCreateTranslator(e.getNamespace(),e.getName()).import(e,{...t,registry:this})}export(e,t,n={registry:this}){n.acceptLanguages||(n.acceptLanguages=[]),n.acceptLanguages=n.acceptLanguages.map(e=>e.toLowerCase()),n.lang&&(n.lang=n.lang.toLowerCase()),n.sanitizers||(n.sanitizers={xhtmlim:s.default}),n.path=e;const i=e.split(".").filter(e=>""!==e);let r=this.root;for(const e of i){const t=r.getChild(e);if(!t)return;r=t}return r.export(t,{...n,registry:this})}getImportKey(e,t=""){const n=t?this.walkToTranslator(t.split(".")):this.root;if(n)return n.getImportKey(e)}define(e){if(Array.isArray(e)){for(const t of e)"object"==typeof t?this.define(t):t(this);return}if("object"!=typeof e)return void e(this);const t=e;t.aliases=t.aliases||[],t.path&&!t.aliases.includes(t.path)&&t.aliases.push(t.path);const n=t.aliases.map(e=>"string"==typeof e?{path:e}:e).sort((e,t)=>{const n=e.path.split(".").length;return t.path.split(".").length-n});let i;if(this.hasTranslator(t.namespace,t.element)&&(i=this.getOrCreateTranslator(t.namespace,t.element)),!i){let e;for(const t of n){const n=this.walkToTranslator(t.path.split("."));if(n&&!n.placeholder){i=n;break}n&&(e=n)}e&&!i&&(i=e,i.placeholder=!1)}i||(i=this.getOrCreateTranslator(t.namespace,t.element)),this.indexTranslator(t.namespace,t.element,i);const r=t.fields||{},s=new Map,o=new Map,a=new Map,c=new Map;t.typeField&&(i.typeField=t.typeField),t.defaultType&&(i.defaultType=t.defaultType),t.versionField&&(i.versionField=t.versionField),t.defaultVersion&&(i.defaultVersion=t.defaultVersion),t.languageField&&(i.languageField=t.languageField);for(const[e,t]of Object.entries(r))s.set(e,t.importer),a.set(e,t.importOrder||t.order||0),o.set(e,t.exporter),c.set(e,t.exportOrder||t.order||0);if(t.childrenExportOrder)for(const[e,n]of Object.entries(t.childrenExportOrder))c.set(e,n||0);const l=new Map;for(const[e,n]of Object.entries(t.optionalNamespaces||{}))l.set(e,n);i.updateDefinition({contexts:new Map,element:t.element,exporterOrdering:c,exporters:o,importerOrdering:a,importers:s,namespace:t.namespace,optionalNamespaces:l,type:t.type,version:t.version,typeOrder:t.typeOrder});for(const e of n)this.alias(t.namespace,t.element,e.path,e.multiple,e.selector,e.contextField,t.type,e.impliedType);for(const e of n){const t=this.walkToTranslator(e.path.split("."));t&&t!==i&&t.replaceWith(i)}}alias(e,t,n,i=!1,r,s,o,a=!1){const c=this.getOrCreateTranslator(e,t);c.placeholder=!1;const l=n.split(".").filter(e=>""!==e),u=l.pop(),p=this.walkToTranslator(l,!0),d=`{${e}}${t}`;o&&(s||a)&&c.addContext(n,r,s,d,o,a),p.addChild(u,c,i,r,d)}walkToTranslator(e,t=!1){let n=this.root;for(const i of e){let e=n.getChild(i);if(!e){if(!t)return;e=new o.default,e.placeholder=!0,n.addChild(i,e)}n=e}return n}hasTranslator(e,t){return this.translators.has(`{${e}}${t}`)}getOrCreateTranslator(e,t){let n=this.translators.get(`{${e}}${t}`);return n||(n=new o.default,this.indexTranslator(e,t,n)),n}indexTranslator(e,t,n){this.translators.set(`{${e}}${t}`,n)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=new Set(["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul"]),r=new Set(["style"]),s=new Map([["a",new Set(["href","style"])],["body",new Set(["style","xml:lang"])],["blockquote",r],["br",r],["cite",r],["em",r],["img",new Set(["alt","height","src","style","width"])],["li",r],["ol",r],["p",r],["span",r],["strong",r],["ul",r]]),o=new Map([["font-style",/normal|italic|oblique|inherit/i],["font-weight",/normal|bold|bolder|lighter|inherit|\d\d\d/i],["text-decoration",/none|underline|overline|line-through|blink|inherit/i]]),a=e=>!!e.match(/^(https?|xmpp|cid|mailto|ftps?|im|ircs?|sips?|tel|geo|bitcoin|magnet):/i)&&e,c=e=>!!e.match(/^[0-9]*$/)&&e,l={alt:e=>e,height:c,href:a,src:a,style:e=>{const t=(";"+e).replace(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,"").replace(/\/\*.*/,"").replace(/\\([a-fA-F0-9]{1,6})\s?/,(e,t)=>String.fromCharCode(parseInt(t,16))).match(/;\s*([a-z-]+)\s*:\s*([^;]*[^\s;])\s*/g),n=[];if(!t)return!1;for(const e of t){const t=e.match(/^;\s*([a-z-]+)\s*:\s*([^;]*[^\s])\s*$/);if(!t)continue;const i=o.get(t[1]);if(i){const e=t[2].match(i);e&&n.push(`${t[1]}:${e[0]}`)}}return!!n.length&&n.join("")},width:c};function u(e){if("string"==typeof e)return e;if(!i.has(e.name)){if("script"===e.name)return;return function(e){let t=[];for(const n of e.children)if("string"==typeof n)t.push(n);else{const e=u(n);e&&(Array.isArray(e)?t=t.concat(e):t.push(e))}return t}(e)}const t=e.children.map(u).filter(e=>void 0!==e),n={};for(const[t,i]of Object.entries(e.attributes)){const r=s.get(e.name);if(!r||!r.has(t))continue;if(!i)continue;const o=l[t](i);o&&(n[t]=o)}return{attributes:n,children:t,name:e.name}}t.default=function(e){if("string"==typeof e)return;let t=[];for(const n of e.children){if(!n)continue;if("string"==typeof n){t.push(n);continue}const e=u(n);Array.isArray(e)?t=t.concat(e):e&&t.push(e)}const n={};return"body"===e.name?(void 0!==e.attributes.xmlns&&(n.xmlns=e.attributes.xmlns),e.attributes.style&&(n.style=e.attributes.style),void 0!==e.attributes["xml:lang"]&&(n["xml:lang"]=e.attributes["xml:lang"]),{attributes:n,children:t,name:"body"}):void 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pubsubItemContentAliases=t.extendStanzaError=t.extendStreamFeatures=t.extendIQ=t.extendPresence=t.extendMessage=t.addAlias=t.childJID=t.childJIDAttribute=t.JIDAttribute=void 0;const i=n(11),r=n(31);t.JIDAttribute=r.attribute,t.childJIDAttribute=r.childAttribute,t.childJID=r.childText,t.addAlias=function(e,t,n){return{aliases:Array.isArray(n)?n:[n],element:t,fields:{},namespace:e}},t.extendMessage=function(e){return{element:"message",fields:e,namespace:i.NS_CLIENT}},t.extendPresence=function(e){return{element:"presence",fields:e,namespace:i.NS_CLIENT}},t.extendIQ=function(e){return{element:"iq",fields:e,namespace:i.NS_CLIENT}},t.extendStreamFeatures=function(e){return{element:"features",fields:e,namespace:i.NS_STREAM}},t.extendStanzaError=function(e){return{element:"error",fields:e,namespace:i.NS_STANZAS,path:"stanzaError"}},t.pubsubItemContentAliases=function(){return[{path:"pubsubcontent",contextField:"itemType"},{path:"pubsubitem.content",contextField:"itemType"},{path:"pubsubeventitem.content",contextField:"itemType"},{path:"iq.pubsub.publish.items",contextField:"itemType"}]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(6),s=i.__importDefault(n(23)),o=i.__importDefault(n(30)),a=i.__importDefault(n(32));class c extends r.Transform{constructor(e){super({objectMode:!0}),this.closedStream=!1,this.wrappedStream=!1,this.registry=e.registry,this.acceptLanguages=e.acceptLanguages||[],e.wrappedStream&&(this.wrappedStream=!0,this.rootImportKey=e.rootKey),this.parser=new a.default({allowComments:e.allowComments}),this.parser.on("error",e=>{this.destroy(e)}),this.parser.on("startElement",(e,t)=>{if(this.destroyed)return;if(this.closedStream)return this.destroy(o.default.alreadyClosed());const n=new s.default(e,t),i=this.registry.getImportKey(n);if(this.wrappedStream&&!this.rootElement){if(this.rootImportKey&&i!==this.rootImportKey)return this.destroy(o.default.unknownRoot());const e=this.registry.import(n,{acceptLanguages:this.acceptLanguages,lang:this.lang});return e?(this.rootElement=n,void this.push({event:"stream-start",kind:i,stanza:e,xml:n})):this.destroy(o.default.notWellFormed())}this.currentElement?this.currentElement=this.currentElement.appendChild(n):this.currentElement=n}),this.parser.on("endElement",e=>{if(!this.destroyed){if(this.wrappedStream&&!this.currentElement)return this.rootElement&&e===this.rootElement.name?(this.closedStream=!0,this.push({event:"stream-end",kind:this.rootImportKey,stanza:{},xml:this.rootElement}),this.end()):(this.closedStream=!0,this.destroy(o.default.notWellFormed()));if(!this.currentElement||e!==this.currentElement.name)return this.closedStream=!0,this.destroy(o.default.notWellFormed());if(this.currentElement.parent)this.currentElement=this.currentElement.parent;else{this.wrappedStream&&(this.currentElement.parent=this.rootElement);const e=this.registry.getImportKey(this.currentElement),t=this.registry.import(this.currentElement,{acceptLanguages:this.acceptLanguages,lang:this.lang});t&&this.push({kind:e,stanza:t,xml:this.currentElement}),this.currentElement=void 0}}}),this.parser.on("text",e=>{this.currentElement&&this.currentElement.children.push(e)})}_transform(e,t,n){this.parser.write(e.toString()),n()}}t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SessionManager=t.FileSession=t.MediaSession=t.ICESession=t.Session=t.exportToSDP=t.importFromSDP=void 0;const i=n(0),r=i.__importDefault(n(59));t.FileSession=r.default;const s=i.__importDefault(n(34));t.ICESession=s.default;const o=i.__importDefault(n(61));t.MediaSession=o.default;const a=i.__importDefault(n(36));t.Session=a.default;const c=i.__importDefault(n(131));t.SessionManager=c.default;var l=n(26);Object.defineProperty(t,"importFromSDP",{enumerable:!0,get:function(){return l.importFromSDP}}),Object.defineProperty(t,"exportToSDP",{enumerable:!0,get:function(){return l.exportToSDP}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),r=n(3),s=n(33),o=n(9),a=n(11),c=n(60),l=i.__importDefault(n(59)),u=i.__importDefault(n(61)),p=i.__importDefault(n(36));class d extends r.EventEmitter{constructor(e={}){super(),e=e||{},this.selfID=e.selfID,this.sessions={},this.peers={},this.iceServers=e.iceServers||[],this.prepareSession=e.prepareSession||(e=>{if(this.config.hasRTCPeerConnection)return e.applicationTypes.indexOf(a.NS_JINGLE_RTP_1)>=0?new u.default(e):e.applicationTypes.indexOf(a.NS_JINGLE_FILE_TRANSFER_5)>=0?new l.default(e):void 0}),this.performTieBreak=e.performTieBreak||((e,t)=>{const n=(t.jingle.contents||[]).map(e=>{if(e.application)return e.application.applicationType});return(e.pendingApplicationTypes||[]).filter(e=>n.includes(e)).length>0}),this.createPeerConnection=e.createPeerConnection||((e,t)=>{if(s.RTCPeerConnection)return new s.RTCPeerConnection(t)}),this.config={debug:!1,hasRTCPeerConnection:!!s.RTCPeerConnection,peerConnectionConfig:{bundlePolicy:e.bundlePolicy||"balanced",iceTransportPolicy:e.iceTransportPolicy||"all",rtcpMuxPolicy:e.rtcpMuxPolicy||"require",sdpSemantics:e.sdpSemantics},peerConnectionConstraints:{optional:[{DtlsSrtpKeyAgreement:!0},{RtpDataChannels:!1}]},...e}}addICEServer(e){if("string"==typeof e)return void this.iceServers.push({urls:e});if(!(t=e).type&&(t.urls||t.url))return void this.iceServers.push(e);var t;let n=e.host||"";n.indexOf(":")>=0&&(n=`[${n}]`);let i=`${e.type}:${n}`;e.port&&(i+=":"+e.port),e.transport&&(i+="?transport="+e.transport),"turn"===e.type||"turns"===e.type?this.iceServers.push({credential:e.password,urls:[i],username:e.username}):"stun"!==e.type&&"stuns"!==e.type||this.iceServers.push({urls:[i]})}resetICEServers(){this.iceServers=[]}addSession(e){e.parent=this;const t=e.sid,n=e.peerID;return this.sessions[t]=e,this.peers[n]||(this.peers[n]=[]),this.peers[n].push(e),this.emit("createdSession",e),e}forgetSession(e){const t=this.peers[e.peerID]||[];t.length&&t.splice(t.indexOf(e),1),delete this.sessions[e.sid]}createMediaSession(e,t,n){const i=new u.default({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t,stream:n});return this.addSession(i),i}createFileTransferSession(e,t){const n=new l.default({config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!0,maxRelayBandwidth:786432,parent:this,peerID:e,sid:t});return this.addSession(n),n}endPeerSessions(e,t,n=!1){const i=this.peers[e]||[];delete this.peers[e];for(const e of i)e.end(t||"gone",n)}endAllSessions(e,t=!1){for(const n of Object.keys(this.peers))this.endPeerSessions(n,e,t)}process(e){const t=e.jingle?e.jingle.sid:void 0;let n=t?this.sessions[t]:void 0;const i=e.id,r=e.from;if(!r)return;if("error"===e.type){if(this._log("error","Received error response",e),n&&e.error&&"unknown-session"===e.error.jingleError)return n.end("gone",!0);const t=e.error&&"tie-break"===e.error.jingleError;return n&&"pending"===n.state&&t?n.end("alternative-session",!0):void(n&&(n.pendingAction=void 0))}if("result"===e.type)return void(n&&(n.pendingAction=void 0));const s=e.jingle.action,a=e.jingle.contents||[],l=a.map(e=>e.application?e.application.applicationType:void 0),u=a.map(e=>e.transport?e.transport.transportType:void 0);if(s!==o.JingleAction.SessionInitiate){if(!n)return"session-terminate"===s?void this.emit("send",{id:i,to:r,type:"result"}):(this._log("error","Unknown session",t),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"}));if(n.peerID!==r||"ended"===n.state)return this._log("error","Session has ended, or action has wrong sender"),this._sendError(r,i,{condition:"item-not-found",jingleError:"unknown-session"});if("session-accept"===s&&"pending"!==n.state)return this._log("error","Tried to accept session twice",t),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if("session-terminate"!==s&&s===n.pendingAction&&(this._log("error","Tie break during pending request"),n.isInitiator))return this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(n){if(n.peerID!==r)return this._log("error","Duplicate sid from new sender"),this._sendError(r,i,{condition:"service-unavailable"});if("pending"!==n.state)return this._log("error","Someone is doing this wrong"),this._sendError(r,i,{condition:"unexpected-request",jingleError:"out-of-order"});if(this.selfID&&this.selfID>n.peerID&&this.performTieBreak(n,e))return this._log("error","Tie break new session because of duplicate sids"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}else if(this.peers[r]&&this.peers[r].length)for(let n=0,s=this.peers[r].length;n<s;n++){const s=this.peers[r][n];if(s&&"pending"===s.state&&t&&c.octetCompare(s.sid,t)>0&&this.performTieBreak(s,e))return this._log("info","Tie break session-initiate"),this._sendError(r,i,{condition:"conflict",jingleError:"tie-break"})}if("session-initiate"===s){if(!a.length)return this._sendError(r,i,{condition:"bad-request"});n=this._createIncomingSession({applicationTypes:l,config:this.config.peerConnectionConfig,constraints:this.config.peerConnectionConstraints,iceServers:this.iceServers,initiator:!1,parent:this,peerID:r,sid:t,transportTypes:u},e)}n.process(s,e.jingle,t=>{t?(this._log("error","Could not process request",e,t),this._sendError(r,i,t)):(this.emit("send",{id:i,to:r,type:"result"}),"session-initiate"===s&&this.emit("incoming",n))})}signal(e,t){const n=t.jingle&&t.jingle.action;e.isInitiator&&n===o.JingleAction.SessionInitiate&&this.emit("outgoing",e),this.emit("send",t)}_createIncomingSession(e,t){let n;return this.prepareSession&&(n=this.prepareSession(e,t)),n||(n=new p.default(e)),this.addSession(n),n}_sendError(e,t,n){n.type||(n.type="cancel"),this.emit("send",{error:n,id:t,to:e,type:"error"})}_log(e,t,...n){this.emit("log",e,t,...n),this.emit("log:"+e,t,...n)}}t.default=d},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||s(t,e,n)},a=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var l,u=n(3);o(n(133),t);var p=function(e){function t(t,n){void 0===n&&(n={});var i=e.call(this)||this;return i.peerConnection=t,i.haveConnectionMetrics=!1,l="undefined"!=typeof window,i.session=n.session,i.initiator=n.initiator,i.conference=n.conference,i.statsInterval=1e3*(n.interval||5),i.logger=n.logger||console,["new","checking"].includes(t.iceConnectionState)&&("checking"===t.iceConnectionState&&(i.logger.warn("iceConnectionState is already in checking state so ice connect time may not be accurate"),i.handleIceStateChange()),t.addEventListener("iceconnectionstatechange",i.handleIceStateChange.bind(i))),t.addEventListener("connectionstatechange",i.handleConnectionStateChange.bind(i)),"connected"===t.connectionState&&i.pollForStats(),i}return r(t,e),t.prototype.handleIceStateChange=function(){var e=this,t=this.peerConnection.iceConnectionState;if("checking"===t&&l&&(this.iceStartTime=window.performance.now()),"connected"===t){if(this.haveConnectionMetrics)return;this.haveConnectionMetrics=!0;var n=void 0,i=void 0,r=void 0;l&&(this.iceConnectionTime=window.performance.now()-this.iceStartTime,n=window.navigator.userAgent,i=window.navigator.platform,r=window.navigator.hardwareConcurrency);var s={name:"connect",userAgent:n,platform:i,cores:r,session:this.session,conference:this.conference,connectTime:this.iceConnectionTime};return this.waitForSelectedCandidatePair().then((function(t){e.gatherSelectedCandidateInfo(t,s),e.emit("stats",s)}))}if("failed"===t)return l&&(this.iceFailedTime=window.performance.now()-this.iceStartTime),this.gatherStats().then((function(t){var n={name:"failure",session:e.session,initiator:e.initiator,conference:e.conference,failTime:e.iceFailedTime,iceRW:0,numLocalHostCandidates:0,numLocalSrflxCandidates:0,numLocalRelayCandidates:0,numRemoteHostCandidates:0,numRemoteSrflxCandidates:0,numRemoteRelayCandidates:0},i=e.peerConnection.localDescription.sdp.split("\r\n").filter((function(e){return e.indexOf("a=candidate:")>-1})),r=e.peerConnection.remoteDescription.sdp.split("\r\n").filter((function(e){return e.indexOf("a=candidate:")>-1}));["Host","Srflx","Relay"].forEach((function(e){n["numLocal"+e+"Candidates"]=i.filter((function(t){return t.split(" ")[7]===e.toLowerCase()})).length,n["numRemote"+e+"Candidates"]=r.filter((function(t){return t.split(" ")[7]===e.toLowerCase()})).length})),e.emit("stats",n)}))},t.prototype.waitForSelectedCandidatePair=function(e,t){var n=this;return void 0===e&&(e=300),void 0===t&&(t=1),this.gatherStats().then((function(i){return n.getSelectedCandidatePair(i)?i:t>3?Promise.reject(new Error("Max wait attempts for connected candidate info reached")):new Promise((function(i,r){setTimeout((function(){return n.waitForSelectedCandidatePair(e,t+1).then(i,r)}),e)}))}))},t.prototype.getSelectedCandidatePair=function(e){var t=null;return e.forEach((function(e){var n=e.value;"candidate-pair"===n.type&&n.nominated&&"succeeded"===n.state&&(t=n)})),t},t.prototype.gatherSelectedCandidateInfo=function(e,t){var n=this.getSelectedCandidatePair(e);if(n){var i,r,s=n.localCandidateId,o=n.remoteCandidateId;if(e.forEach((function(e){e.key;var n=e.value;s&&"local-candidate"===n.type&&n.id===s&&(i=n,t.localCandidateType=n.candidateType),o&&"remote-candidate"===n.type&&n.id===o&&(r=n,t.remoteCandidateType=n.candidateType)})),i&&r&&(t.candidatePair=i.candidateType+";"+r.candidateType,t.candidatePairDetails={local:i,remote:r,pair:n}),i){if(t.transport=i.transport||i.protocol,i.priority){var a=parseInt(i.priority,10);t.turnType={2:"udp",1:"tcp",0:"tls"}[a>>24],t.networkType=i.networkType}t.usingIPv6=i.ipAddress&&0===i.ipAddress.indexOf("[")}}},t.prototype.handleConnectionStateChange=function(){return a(this,void 0,void 0,(function(){var e,t=this;return c(this,(function(n){if("connected"===(e=this.peerConnection.connectionState))this.pollForStats();else{if("disconnected"===e)return"stable"!==this.peerConnection.signalingState?[2]:[2,this.gatherStats().then((function(e){var n=t.createStatsReport(e);n.type="disconnected",t.emit("stats",n)}))];"closed"===e&&this.pollingInterval&&(l&&window.clearInterval(this.pollingInterval),this.pollingInterval=null)}return[2]}))}))},t.prototype.pollForStats=function(){var e=this;if(!this.pollingInterval){var t=function(){return e.gatherStats().then((function(t){var n=e.createStatsReport(t,!0);(n.tracks.length>0||n.remoteTracks.length>0)&&e.emit("stats",n)}))};l&&(window.setTimeout(t,0),this.pollingInterval=window.setInterval(t,this.statsInterval))}},t.prototype.polyFillStats=function(e){if(!e)return[];if(Array.isArray(e))return e;var t=[];if(this.isNativeStatsReport(e))e.forEach((function(e,n){t.push({key:n,value:e})}));else{if(!(Object.keys(e).length>0))return this.logger.warn("Unknown stats results format, returning unmodified",e),[];Object.keys(e).forEach((function(n){t.push({key:n,value:e[n]})}))}return t},t.prototype.isNativeStatsReport=function(e){return void 0!==window.RTCStatsReport&&e instanceof window.RTCStatsReport},t.prototype.gatherStats=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.peerConnection.getStats(null).then(this.polyFillStats.bind(this))];case 1:return[2,t.sent()];case 2:return e=t.sent(),this.logger.error("Failed to gather stats. Are you using RTCPeerConnection as your connection? {expect peerconnection.getStats}",{peerConnection:this.peerConnection,err:e}),[2,Promise.reject(e)];case 3:return[2]}}))}))},t.prototype.createStatsReport=function(e,t){var n=this;void 0===t&&(t=!0);var i={name:"getStats",session:this.session,initiator:this.initiator,conference:this.conference,tracks:[],remoteTracks:[]};e.filter((function(e){return["inbound-rtp","outbound-rtp"].indexOf(e.value.type)>-1})).forEach((function(t){n.processSource({source:t.value,event:i,results:e})}));var r=e.find((function(e){return"candidate-pair"===e.value.type&&"succeeded"===e.value.state&&!0===e.value.nominated}));return r&&this.processSelectedCandidatePair({report:r.value,event:i,results:e}),t&&(this.lastResult=e),i},t.prototype.processSource=function(e){var t,n,i,r,s,o,a,c=e.source,l=e.results,u=e.event,p=new Date(c.timestamp),h=this.lastResult&&this.lastResult.find((function(e){return e.key===c.id}));(h=h&&h.value)&&(t=(t=this.lastResult&&this.lastResult.find((function(e){return e.value.localId===h.id})))&&t.value),l.forEach((function(e){e.value.localId===c.id?n=e.value:e.key===c.transportId?i=e.value:e.key===c.trackId?s=e.value:e.key===c.mediaSourceId?o=e.value:e.key===c.codecId&&(a=e.value)})),i&&(r=(r=l.find((function(e){return e.key===i.selectedCandidatePairId})))&&r.value),r&&(u.candidatePairHadActiveSource=!0);var f=c.kind||c.mediaType,m="outbound-rtp"===c.type,g={track:s&&s.trackIdentifier,kind:f,jitter:d("jitter",c,n),roundTripTime:d("roundTripTime",c,n),packetsLost:d("packetsLost",c,n)||0,packetLoss:0,bytes:parseInt(m?c.bytesSent:c.bytesReceived,10)||0};if(a&&(g.codec=a.payloadType+" "+a.mimeType+" "+a.clockRate),h){var v=parseInt(m?h.bytesSent:h.bytesReceived,10)||0,b=p.getTime()-new Date(h.timestamp).getTime();g.bitrate=Math.floor(8*(g.bytes-v)/b)}var y=d("packetsLost",h,t);m?(g.packetsSent=c.packetsSent,g.packetLoss=g.packetsLost/(g.packetsSent||1)*100,h&&(g.intervalPacketsSent=g.packetsSent-(h.packetsSent||0),g.intervalPacketsLost=g.packetsLost-(y||0),g.intervalPacketLoss=g.intervalPacketsLost/(g.intervalPacketsSent||1)*100),g.retransmittedBytesSent=c.retransmittedBytesSent,g.retransmittedPacketsSent=c.retransmittedPacketsSent):(g.packetsReceived=c.packetsReceived,g.packetLoss=g.packetsLost/(100*g.packetsReceived||1),h&&(g.intervalPacketsReceived=g.packetsReceived-h.packetsReceived,g.intervalPacketsLost=g.packetsLost-y,g.intervalPacketLoss=g.intervalPacketsLost/(g.intervalPacketsReceived||1)*100)),s&&"audio"===f&&(s.remoteSource?(g.audioLevel=s.audioLevel,g.totalAudioEnergy=s.totalAudioEnergy):(g.echoReturnLoss=s.echoReturnLoss,g.echoReturnLossEnhancement=s.echoReturnLossEnhancement)),"audio"!==f||!o||s&&s.remoteSource||(g.audioLevel=o.audioLevel,g.totalAudioEnergy=o.totalAudioEnergy),Object.keys(g).forEach((function(e){return void 0===g[e]&&delete g[e]})),m?u.tracks.push(g):u.remoteTracks.push(g)},t.prototype.processSelectedCandidatePair=function(e){var t=this,n=e.report,i=e.event,r=e.results,s=n.localCandidateId,o=n.remoteCandidateId;i.localCandidateChanged=!!this.lastActiveLocalCandidate&&s!==this.lastActiveLocalCandidate.id,i.remoteCandidateChanged=!!this.lastActiveRemoteCandidate&&o!==this.lastActiveRemoteCandidate.id,(!this.lastActiveLocalCandidate||i.localCandidateChanged||i.remoteCandidateChanged)&&r.forEach((function(e){t.checkLastActiveCandidate({localId:s,remoteId:o,key:e.key,report:e.value})})),this.lastActiveLocalCandidate&&(i.networkType=this.lastActiveLocalCandidate.networkType,this.lastActiveRemoteCandidate&&(i.candidatePair=this.lastActiveLocalCandidate.candidateType+";"+this.lastActiveRemoteCandidate.candidateType)),i.bytesSent=n.bytesSent,i.bytesReceived=n.bytesReceived,i.requestsReceived=n.requestsReceived,i.requestsSent=n.requestsSent,i.responsesReceived=n.responsesReceived,i.responsesSent=n.responsesSent,i.consentRequestsSent=n.consentRequestsSent,i.totalRoundTripTime=n.totalRoundTripTime},t.prototype.checkLastActiveCandidate=function(e){var t=e.localId,n=e.remoteId,i=(e.key,e.report);t&&"local-candidate"===i.type&&i.id===t&&(this.lastActiveLocalCandidate=i),n&&"remote-candidate"===i.type&&i.id===n&&(this.lastActiveRemoteCandidate=i)},t}(u.EventEmitter);function d(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=t.find((function(t){return t&&(t[e]||0===t[e])}));return i&&i[e]}t.default=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJwt=t.HttpClient=void 0;const i=n(22),r=n(37);i.__exportStar(n(25),t),i.__exportStar(n(17),t);var s=n(18);Object.defineProperty(t,"HttpClient",{enumerable:!0,get:function(){return s.HttpClient}});var o=n(8);Object.defineProperty(t,"parseJwt",{enumerable:!0,get:function(){return o.parseJwt}}),t.default=r.Client},function(e,t,n){"use strict";function i(e,t=""){const n={};if(Array.isArray(e))for(let r=0;r<e.length;r++)Object.assign(n,i(e[r],`${t}_[${r}]`));else"object"!=typeof e?n[t]=e:Object.keys(e).filter(e=>"ip"!==e.toLowerCase()).forEach(r=>{const s=e[r],o=t?`${t}_${r}`:r;"object"==typeof s||Array.isArray(s)?Object.assign(n,i(s,o)):n[o]=s});return n}Object.defineProperty(t,"__esModule",{value:!0}),t.deepFlatten=t.formatStatsEvent=void 0,t.formatStatsEvent=function(e,t={}){let n;const r=e.name;if("connect"===e.name){const t=e;n=t,Object.assign(n,i(t.candidatePairDetails,"candidatePairDetails")),delete n.candidatePairDetails}else if("getStats"===e.name){const t=e;n=t,Object.assign(n,i(t.tracks,"localTrack")),delete n.tracks,Object.assign(n,i(t.remoteTracks,"remoteTrack")),delete n.remoteTracks}else n={},e.name,Object.assign(n,i(e));return delete n.name,Object.assign(n,t,{_eventType:r}),Object.keys(n).forEach(e=>{const t=n[e];"boolean"==typeof t&&(n[e]=""+t)}),{actionName:"WebrtcStats",actionDate:Date.now(),details:n}},t.deepFlatten=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reconnector=t.CXFRDefinition=void 0;const i=n(137),r=n(57),s=n(8),o=n(18);t.CXFRDefinition={aliases:["iq.cxfr"],element:"query",fields:{domain:r.childText(null,"domain"),server:r.childText(null,"server")},namespace:"urn:xmpp:cxfr"};t.Reconnector=class{constructor(e){this._hasConnected=!1,this._backoffActive=!1,this._hardReconnectRetryInfo=null,this.client=e,this.backoff=i.exponential({randomisationFactor:.2,initialDelay:250,maxDelay:5e3,factor:2}),this.backoff.failAfter(10),this.backoff.on("ready",(e,t)=>{var n;if(this.client.connected)this.client.logger.debug("Backoff ready, client already connected");else{if(null===(n=this.client._stanzaio.transport)||void 0===n?void 0:n.hasStream)return this.client.logger.debug("Backoff ready, connection is pending"),void this.backoff.backoff();this.client.logger.debug("Backoff ready, attempting reconnect"),this.client.connecting=!0,this.client._stanzaio.connect(),this.backoff.backoff()}}),this.backoff.on("fail",()=>this.hardReconnect()),this.client.on("connected",()=>{this._hasConnected=!0,this.stop()}),this.client._stanzaio.on("sasl",e=>{if("failure"!==e.type)return;const t="temporary-auth-failure"===e.condition;if(this._hasConnected&&"not-authorized"===e.condition)return this.hardReconnect();if(!t){const t="Critical error reconnecting; stopping automatic reconnect";this.client.logger.error(t,e),this.stop(new Error(t))}});this.client._stanzaio.stanzas.define(t.CXFRDefinition),this.client._stanzaio.on("iq:set:cxfr",e=>{const t=setTimeout(this.client.reconnect,6e5),n=setTimeout(()=>(clearTimeout(t),this.client.reconnect()),1e3);this.client._stanzaio.emit("requestReconnect",e=>{if(!0===e.pending&&clearTimeout(n),e.done)return clearTimeout(n),clearTimeout(t),this.client.reconnect()})}),this._backoffActive=!1}async hardReconnect(){if(this._hardReconnectRetryInfo)return this._hardReconnectRetryInfo.promise;this.cleanupReconnect(),this._hasConnected=!1,this._hardReconnectRetryInfo=s.retryPromise(this._attemptHardReconnect.bind(this),this._shouldRetryError.bind(this),15e3,this.client.logger);try{await this._hardReconnectRetryInfo.promise,this._stopHardReconnect()}catch(e){throw this._stopHardReconnect(e),e}}cleanupReconnect(){this.backoff.reset(),this._backoffActive=!1}start(){this._backoffActive||(this.backoff.backoff(),this._backoffActive=!0)}stop(e){this.cleanupReconnect(),this._stopHardReconnect(e)}_stopHardReconnect(e){this._hardReconnectRetryInfo&&(e?("string"==typeof e&&(e=new Error(e)),this._hardReconnectRetryInfo.cancel(e)):this._hardReconnectRetryInfo.complete(),this._hardReconnectRetryInfo=null)}async _attemptHardReconnect(){if(!navigator.onLine)throw new Error("OFFLINE_ERROR");this.client.logger.info("Attempting to reconnect with new channel."),await this.client.connect()}_shouldRetryError(e){return"OFFLINE_ERROR"===e.message?(this.client.logger.debug("Browser is offline. Not attempting to reconnect with new channel."),!0):e.message.startsWith("Request has been terminated")?(this.client.logger.debug("request offline. attempting reconnect again",e),!0):e.message.startsWith("Timeout: ")?(this.client.logger.debug(`Streaming-client timed out. attempting reconnect again: "${e.message}"`),!0):!(!e||!o.HttpClient.retryStatusCodes.has(e.status))&&(this.client.logger.debug("Received HTTP status code eligible for retry. attempting reconnect again",e),!0)}}},function(e,t,n){const i=n(62),r=n(138),s=n(65),o=n(139);e.exports.Backoff=i,e.exports.FunctionCall=o,e.exports.FibonacciStrategy=s,e.exports.ExponentialStrategy=r,e.exports.fibonacci=function(e){return new i(new s(e))},e.exports.exponential=function(e){return new i(new r(e))},e.exports.call=function(...e){const t=e[0],n=e.slice(1,e.length-1),i=e[e.length-1];return new o(t,n,i)}},function(e,t,n){const i=n(64);class r extends i{constructor(e){if(super(e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=r.DEFAULT_FACTOR,e&&void 0!==e.factor){if(e.factor<1)throw new Error("Exponential factor should be greater than 1 but got %s.");this.factor_=e.factor}}next_(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_}reset_(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}}r.DEFAULT_FACTOR=2,e.exports=r},function(e,t,n){const i=n(63),r=n(62),s=n(65);class o extends i{constructor(e,t,n){if(super(),"function"!=typeof e)throw new Error("Expected first argument to be a function");if(!Array.isArray(t))throw new Error("Expected second argument to be an array");if("function"!=typeof n)throw new Error("Expected third (last) arugment to be a function");this.function_=e,this.arguments_=t,this.callback_=n,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=o.DEFAULT_RETRY_PREDICATE_,this.state_=o.State_.PENDING}isPending(){return this.state_===o.State_.PENDING}isRunning(){return this.state_===o.State_.RUNNING}isCompleted(){return this.state_===o.State_.COMPLETED}isAborted(){return this.state_===o.State_.ABORTED}setStrategy(e){if(!this.isPending())throw new Error("FunctionCall is in progress");return this.strategy_=e,this}retryIf(e){if(!this.isPending())throw new Error("FunctionCall in progress");return this.retryPredicate_=e,this}getLastResult(){return this.lastResult_.concat()}getNumRetries(){return this.numRetries_}failAfter(e){if(!this.isPending())throw new Error("FunctionCall in progress");return this.failAfter_=e,this}abort(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=o.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())}start(e){if(this.isAborted())throw new Error("FunctionCall is aborted");if(!this.isPending())throw new Error("FunctionCall already started");const t=this.strategy_||new s;this.backoff_=e?e(t):new r(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=o.State_.RUNNING,this.doCall_(!1)}doCall_(e){e&&this.numRetries_++,this.emit("call",...this.arguments_);const t=this.handleFunctionCallback_.bind(this);this.function_.call(null,...this.arguments_,t)}doCallback_(){this.callback_.apply(null,this.lastResult_)}handleFunctionCallback_(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,this.emit("callback",...e);var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=o.State_.COMPLETED,this.doCallback_())}}handleBackoff_(e,t,n){this.emit("backoff",e,t,n)}}o.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},o.DEFAULT_RETRY_PREDICATE_=function(){return!0},e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Ping=void 0;t.Ping=class{constructor(e,t={}){this.client=e,this.options=t,this.pingInterval=t.pingInterval||15e3,this.failedPingsBeforeDisconnect=t.failedPingsBeforeDisconnect||1,this.numberOfFailedPings=0,this.nextPingTimeoutId=null}start(){this.nextPingTimeoutId||this.queueNextPing()}stop(){clearTimeout(this.nextPingTimeoutId),this.nextPingTimeoutId=null,this.numberOfFailedPings=0}async performPing(){try{await this.client._stanzaio.ping(this.options.jid),this.numberOfFailedPings=0,this.queueNextPing()}catch(e){const t={channelId:this.client.config.channelId,jid:this.client._stanzaio.jid};this.client.logger.warn("Missed a ping.",Object.assign({error:e},t)),++this.numberOfFailedPings>this.failedPingsBeforeDisconnect?(this.stop(),this.client.logger.error("Missed too many pings, disconnecting",Object.assign({numberOfFailedPings:this.numberOfFailedPings},t)),this.client._stanzaio.sendStreamError({text:"too many missed pongs",condition:"connection-timeout"})):this.queueNextPing()}}queueNextPing(){this.nextPingTimeoutId=setTimeout(this.performPing.bind(this),this.pingInterval)}}},function(e,t,n){"use strict";n.r(t);var i=n(3),r=n(67),s=n(28),o=n.n(s);const a=function(e){const t=JSON.stringify(e),n=encodeURIComponent(t).match(/%[89ABab]/g);return t.length+(n?n.length:0)},c=function e(t){if(t){if(Array.isArray(t)){const n=[];for(let i=0;i<t.length;i++)n[i]=e(t[i]);return n}if("object"==typeof t){const n=Object.assign({},t);for(const i in t)n[i]=e(t[i]);return n}}return t};var l=n(27),u=n.n(l),p=n(68),d=function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};const h=new Map;class f{constructor(e,t=!1){this.url=e,this.debugMode=t,this.sendQueue=[],this.hasPendingRequest=!1}postLogsToEndpoint(e){const t=(()=>{let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}})();return this.sendQueue.push({requestParams:e,deferred:t}),this.sendNextQueuedLogToServer(),this.debug("adding requestParams to sendQueue",{requestParams:e,updatedSendQueue:this.sendQueue.map(e=>e.requestParams),hasPendingRequest:this.hasPendingRequest}),t.promise}postLogsToEndpointInstantly(e){return this.debug("sending request instantly",{requestParams:e,sendQueue:this.sendQueue.map(e=>e.requestParams)}),this.sendPostRequest(e)}sendEntireQueue(){this.debug("sending all queued requests instantly to clear out sendQueue",{sendQueue:this.sendQueue.map(e=>e.requestParams)});const e=[];let t;for(;t=this.sendQueue.shift();)e.push(this.postLogsToEndpointInstantly(t.requestParams));return e}resetSendQueue(){this.debug("reseting send queue without sending currently queued data",{queueLength:this.sendQueue.length}),this.sendQueue=[]}sendNextQueuedLogToServer(){return d(this,void 0,void 0,(function*(){if(this.hasPendingRequest||0===this.sendQueue.length)return void this.debug("sendNextQueuedLogToServer() but not sending request",{hasPendingRequest:this.hasPendingRequest,sendQueueLength:this.sendQueue.length});const e=this.sendQueue.shift();return e.deferred.promise.finally(()=>{this.debug("queue item completed. removing from queue and resetting send queue",{queueItemRequestParams:e.requestParams,updatedSendQueue:this.sendQueue.map(e=>e.requestParams)}),this.hasPendingRequest=!1,this.sendNextQueuedLogToServer()}),this.hasPendingRequest=!0,this.debug("sending logs to server",{queueItem:e.requestParams,sendQueue:this.sendQueue.map(e=>e.requestParams)}),Object(p.backOff)(()=>this.sendPostRequest(e.requestParams),{retry:e=>!(!e||429!==e.status),numOfAttempts:10,startingDelay:0,delayFirstAttempt:!1,maxDelay:15e3}).then(t=>{this.debug("successfully sent logs to server",{requestParams:e.requestParams,response:t}),e.deferred.resolve(t)}).catch(t=>(this.debug("ERROR sending logs to server",{requestParams:e.requestParams,error:t}),e.deferred.reject(t)))}))}sendPostRequest(e){this.debug("issuing POST request",{requestParams:e});const t=Object.assign({},e);return delete t.accessToken,u()({method:"post",url:this.url,headers:{authorization:"Bearer "+e.accessToken,"content-type":"application/json; charset=UTF-8"},data:t})}debug(e,t){this.debugMode&&console.log("%c [DEBUG:log-uploader] "+e,"color: #32a0a8",c(t))}}var m=function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};class g{constructor(e){if(this.isInitialized=!1,this.logBuffer=[],this.debounceTimer=null,this.logger=e,!e.config.url||!e.config.appVersion){const t="Missing `url` and/or `appVersion` config options to set up server logging. Not sending logs to server for this logger instance";throw this.logger.error(t,{providedConfig:e.config},{skipServer:!0}),new Error(t)}this.isInitialized=!0,this.debounceLogUploadTime=e.config.uploadDebounceTime||4e3,this.logUploader=((e,t=!1)=>{let n=h.get(e);return n||(n=new f(e,t),h.set(e,n)),n})(e.config.url,e.config.debugMode),window.addEventListener("unload",this.sendAllLogsInstantly.bind(this)),this.logger.on("onStop",e=>{this.debug("`onStop` received. Clearing logBuffer and sendQueue",{logBuffer:this.logBuffer,sendQueue:this.logUploader.sendQueue}),this.logBuffer=[],this.logUploader.resetSendQueue()})}addLogToSend(e,t,n){if(!this.isInitialized)return;const i=this.convertToLogMessage(t,n);let r=this.convertToTrace(e,i),s=a(r);if(s>14500){const t=this.truncateLog(e,i);if(null===t)return void this.logger.error("truncated message is too large to send to server. not sending message",{originalTrace:r,originalTraceSize:a(r),truncatedTrace:t,truncatedTraceSize:a(t)},{skipServer:!0});s=a(t),r=t}const o=!this.logBuffer.length;let c;c=o?{size:0,traces:[]}:this.logBuffer[this.logBuffer.length-1];if(c.size+s>14500)return this.debug("`exceedsMaxLogSize` was `true`",{logBuffer:this.logBuffer,bufferItem:c,incomingTrace:r,incomingTraceSize:s,maxAllowedTraceSize:14500}),this.logBuffer.push({size:s,traces:[r]}),this.debug("calling sendLogsToServer(true)",{logBuffer:this.logBuffer}),void this.sendLogsToServer(!0);c.size+=s,c.traces.push(r),o&&(this.debug("`this.logBuffer` was empty. pushing new buffer item",{logBuffer:this.logBuffer,bufferItem:c}),this.logBuffer.push(c)),this.debug("calling sendLogsToServer()",{logBuffer:this.logBuffer}),this.sendLogsToServer()}sendAllLogsInstantly(){return this.logUploader.sendEntireQueue().concat(this.logBuffer.map(e=>this.logUploader.postLogsToEndpointInstantly(this.convertToRequestParams(e.traces.reverse()))))}sendLogsToServer(e=!1){return m(this,void 0,void 0,(function*(){if(!this.logBuffer.length)return clearTimeout(this.debounceTimer),this.debounceTimer=null,void this.debug("buffer empty, not sending http request");if(!e)return void(this.debounceTimer?this.debug("sendLogsToServer() 'immediate' is false. 'debounceTimer' is already running"):(this.debug(`sendLogsToServer() 'immediate' is false. setting up 'debounceTimer' to ${this.debounceLogUploadTime}ms`),this.debounceTimer=setTimeout(()=>this.sendLogsToServer(!0),this.debounceLogUploadTime)));clearTimeout(this.debounceTimer),this.debounceTimer=null;const[t]=this.logBuffer.splice(0,1);try{this.debug("calling logUploader.postLogsToEndpoint() with",{bufferItem:t,newLogBuffer:this.logBuffer}),yield this.logUploader.postLogsToEndpoint(this.convertToRequestParams(t.traces.reverse()))}catch(e){this.logger.emit("onError",e),this.logger.error("Error sending logs to server",e,{skipServer:!0});const t=""+(null==e?void 0:e.status);["401","404"].includes(t)&&(this.debug(`received a ${t} from logUploader. stopping logging to server`),this.logger.stopServerLogging(t))}finally{this.sendLogsToServer()}}))}truncateLog(e,t){let n,i;const r=a(this.convertToTrace(e,t)),s=c(t);return s.details="[[TRUNCATED]]",n=this.convertToTrace(e,s),i=a(n),i<=14500?(this.logger.warn("message too large to send to server. truncated log details",{originalLog:t,truncatedLog:s,originalTraceSize:r,truncatedTraceSize:i,maxAllowedTraceSize:14500},{skipServer:!0}),n):(s.message=s.message.substr(0,150)+"... [[TRUNCATED]]",n=this.convertToTrace(e,s),i=a(n),i<=14500?(this.logger.warn("message too large to send to server. truncated log details & log message",{originalLog:t,truncatedLog:s,originalTraceSize:r,truncatedTraceSize:i,maxAllowedTraceSize:14500},{skipServer:!0}),n):null)}convertToLogMessage(e,t){const n={clientTime:(new Date).toISOString(),clientId:this.logger.clientId,message:e,details:t},{originAppName:i,originAppVersion:r,originAppId:s}=this.logger.config;return i&&(n.originAppName=i,n.originAppVersion=r,n.originAppId=s),n}convertToTrace(e,t){return{topic:this.logger.config.appName,level:e.toUpperCase(),message:o()(t)}}convertToRequestParams(e){return{accessToken:this.logger.config.accessToken,app:{appId:this.logger.config.appName,appVersion:this.logger.config.appVersion},traces:e}}debug(e,t){this.logger.config.debugMode&&console.log(`%c [DEBUG:${this.logger.config.appName}] ${e}`,"color: #32a852",c(t))}}class v extends i.EventEmitter{constructor(e){super(),this.defaultFormatter=(e,t,n,i,r)=>{if(i.skipDefaultFormatter)return r();t instanceof Error&&(n=n||t,t=t.message);r(e,t=`${this.config.appName?`[${this.config.appName}] `:""}${t}`,n,i)},this.logMessage=(e,t,n,i)=>{if(!i.skipSecondaryLogger)try{const i=[t];void 0!==n&&i.push(this.config.stringify?o()(n):n),this.secondaryLogger[e].apply(this.secondaryLogger,i)}catch(e){console.error("Error logging using custom logger passed into `genesys-cloud-client-logger`",{error:e,secondaryLogger:this.secondaryLogger,message:t,details:n,messageOptions:i})}!i.skipServer&&!this.stopReason&&this.serverLogger&&this.logRank(e)>=this.logRank(this.config.logLevel)&&this.serverLogger.addLogToSend(e,t,n)},Object.defineProperty(this,"clientId",{value:Object(r.v4)(),writable:!1}),this.config=Object.assign({},e),this.secondaryLogger=this.config.logger||console,delete this.config.logger,-1===this.logRank(this.config.logLevel)&&(e.logLevel&&this.warn(`Invalid log level: "${e.logLevel}". Default "info" will be used instead.`,null,{skipServer:!0}),this.config.logLevel="info"),!e.appName&&e.logTopic&&(this.warn("`logTopic` has been renamed to `appName`. Please use `appName`",null,{skipServer:!0}),this.config.appName=e.logTopic),!1!==this.config.initializeServerLogging&&(this.serverLogger=new g(this)),this.config.startServerLoggingPaused&&this.stopServerLogging()}get VERSION(){return v.VERSION}setAccessToken(e){this.config.accessToken=e,"401"===this.stopReason&&this.startServerLogging()}log(e,t,n){this.formatMessage("log",e,t,n)}debug(e,t,n){this.formatMessage("debug",e,t,n)}info(e,t,n){this.formatMessage("info",e,t,n)}warn(e,t,n){this.formatMessage("warn",e,t,n)}error(e,t,n){this.formatMessage("error",e,t,n)}startServerLogging(){if(this.stopReason=void 0,!this.serverLogger)return this.warn("`startServerLogging` called but the logger instance is not configured to send logs to the server. Ignoring call to start sending logs to server.",void 0,{skipServer:!0});this.emit("onStart")}stopServerLogging(e="force"){"force"===this.stopReason&&"force"!==e||(this.stopReason=e,this.emit("onStop",e))}sendAllLogsInstantly(){var e;return(null===(e=this.serverLogger)||void 0===e?void 0:e.sendAllLogsInstantly())||[]}formatMessage(e,t,n,i){let r=[this.defaultFormatter.bind(this)];this.config.formatters&&(r=[...this.config.formatters,this.defaultFormatter.bind(this)]),this.callNextFormatter(r,e,t,n,i)}callNextFormatter(e,t,n,i,r={}){const[s,...o]=e;if(!s)return this.logMessage(t,n,i,r);s(t,n,i,r,(e,s,a,c)=>{void 0!==e?this.callNextFormatter(o,e,s,a,c):this.callNextFormatter(o,t,n,i,r)})}logRank(e){switch(e){case"log":return 0;case"debug":return 1;case"info":return 2;case"warn":return 3;case"error":return 4;default:return-1}}}v.VERSION="4.1.1",n.d(t,"Logger",(function(){return v}));t.default=v}]).default;
|