quickblox 2.19.0 → 2.19.2
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/{LICENSE → LICENSE.md} +35 -49
- package/README.md +3 -1
- package/package.json +2 -2
- package/quickblox.d.ts +3 -0
- package/quickblox.js +37367 -26454
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChat.js +35 -18
- package/src/qbConfig.js +2 -2
- package/src/qbStrophe.js +6 -4
- package/strophejs-1.4.0/dist/strophe.common.js +0 -6668
- package/strophejs-1.4.0/dist/strophe.esm.js +0 -6660
- package/strophejs-1.4.0/dist/strophe.umd.js +0 -6873
- package/strophejs-1.4.0/dist/strophe.umd.min.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).strophe={})}(this,function(e){"use strict";var t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=s(n);return c(this,r?(e=s(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function u(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(){var e=t.WebSocket;if(void 0===e)try{e=require("ws")}catch(e){throw new Error('You must install the "ws" package to use Strophe in nodejs.')}}();var d=function(){var e=t.DOMParser;if(void 0===e)try{e=require("xmldom").DOMParser}catch(e){throw new Error('You must install the "xmldom" package to use Strophe in nodejs.')}return e}();function _(){if("undefined"==typeof document)try{return(new(require("xmldom").DOMImplementation)).createDocument("jabber:client","strophe",null)}catch(e){throw new Error('You must install the "xmldom" package to use Strophe in nodejs.')}if(void 0===document.implementation.createDocument||document.implementation.createDocument&&document.documentMode&&document.documentMode<10){var e=function(){for(var e=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"],t=0;t<e.length;t++)try{return new ActiveXObject(e[t])}catch(e){}}();return e.appendChild(e.createElement("strophe")),e}return document.implementation.createDocument("jabber:client","strophe",null)}function f(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function p(e){if("string"!=typeof e)throw new Error("str2binl was passed a non-string");for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function g(e,t,n,r,s,i){return f((o=f(f(t,e),f(r,i)))<<(a=s)|o>>>32-a,n);var o,a}function v(e,t,n,r,s,i,o){return g(t&n|~t&r,e,t,s,i,o)}function y(e,t,n,r,s,i,o){return g(t&r|n&~r,e,t,s,i,o)}function S(e,t,n,r,s,i,o){return g(t^n^r,e,t,s,i,o)}function b(e,t,n,r,s,i,o){return g(n^(t|~r),e,t,s,i,o)}function T(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n,r,s,i,o=1732584193,a=-271733879,c=-1732584194,l=271733878,u=0;u<e.length;u+=16)o=v(n=o,r=a,s=c,i=l,e[u+0],7,-680876936),l=v(l,o,a,c,e[u+1],12,-389564586),c=v(c,l,o,a,e[u+2],17,606105819),a=v(a,c,l,o,e[u+3],22,-1044525330),o=v(o,a,c,l,e[u+4],7,-176418897),l=v(l,o,a,c,e[u+5],12,1200080426),c=v(c,l,o,a,e[u+6],17,-1473231341),a=v(a,c,l,o,e[u+7],22,-45705983),o=v(o,a,c,l,e[u+8],7,1770035416),l=v(l,o,a,c,e[u+9],12,-1958414417),c=v(c,l,o,a,e[u+10],17,-42063),a=v(a,c,l,o,e[u+11],22,-1990404162),o=v(o,a,c,l,e[u+12],7,1804603682),l=v(l,o,a,c,e[u+13],12,-40341101),c=v(c,l,o,a,e[u+14],17,-1502002290),a=v(a,c,l,o,e[u+15],22,1236535329),o=y(o,a,c,l,e[u+1],5,-165796510),l=y(l,o,a,c,e[u+6],9,-1069501632),c=y(c,l,o,a,e[u+11],14,643717713),a=y(a,c,l,o,e[u+0],20,-373897302),o=y(o,a,c,l,e[u+5],5,-701558691),l=y(l,o,a,c,e[u+10],9,38016083),c=y(c,l,o,a,e[u+15],14,-660478335),a=y(a,c,l,o,e[u+4],20,-405537848),o=y(o,a,c,l,e[u+9],5,568446438),l=y(l,o,a,c,e[u+14],9,-1019803690),c=y(c,l,o,a,e[u+3],14,-187363961),a=y(a,c,l,o,e[u+8],20,1163531501),o=y(o,a,c,l,e[u+13],5,-1444681467),l=y(l,o,a,c,e[u+2],9,-51403784),c=y(c,l,o,a,e[u+7],14,1735328473),a=y(a,c,l,o,e[u+12],20,-1926607734),o=S(o,a,c,l,e[u+5],4,-378558),l=S(l,o,a,c,e[u+8],11,-2022574463),c=S(c,l,o,a,e[u+11],16,1839030562),a=S(a,c,l,o,e[u+14],23,-35309556),o=S(o,a,c,l,e[u+1],4,-1530992060),l=S(l,o,a,c,e[u+4],11,1272893353),c=S(c,l,o,a,e[u+7],16,-155497632),a=S(a,c,l,o,e[u+10],23,-1094730640),o=S(o,a,c,l,e[u+13],4,681279174),l=S(l,o,a,c,e[u+0],11,-358537222),c=S(c,l,o,a,e[u+3],16,-722521979),a=S(a,c,l,o,e[u+6],23,76029189),o=S(o,a,c,l,e[u+9],4,-640364487),l=S(l,o,a,c,e[u+12],11,-421815835),c=S(c,l,o,a,e[u+15],16,530742520),a=S(a,c,l,o,e[u+2],23,-995338651),o=b(o,a,c,l,e[u+0],6,-198630844),l=b(l,o,a,c,e[u+7],10,1126891415),c=b(c,l,o,a,e[u+14],15,-1416354905),a=b(a,c,l,o,e[u+5],21,-57434055),o=b(o,a,c,l,e[u+12],6,1700485571),l=b(l,o,a,c,e[u+3],10,-1894986606),c=b(c,l,o,a,e[u+10],15,-1051523),a=b(a,c,l,o,e[u+1],21,-2054922799),o=b(o,a,c,l,e[u+8],6,1873313359),l=b(l,o,a,c,e[u+15],10,-30611744),c=b(c,l,o,a,e[u+6],15,-1560198380),a=b(a,c,l,o,e[u+13],21,1309151649),o=b(o,a,c,l,e[u+4],6,-145523070),l=b(l,o,a,c,e[u+11],10,-1120210379),c=b(c,l,o,a,e[u+2],15,718787259),a=b(a,c,l,o,e[u+9],21,-343485551),o=f(o,n),a=f(a,r),c=f(c,s),l=f(l,i);return[o,a,c,l]}var x={hexdigest:function(e){return function(e){for(var t="0123456789abcdef",n="",r=0;r<4*e.length;r++)n+=t.charAt(e[r>>2]>>r%4*8+4&15)+t.charAt(e[r>>2]>>r%4*8&15);return n}(T(p(e),8*e.length))},hash:function(e){return function(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(T(p(e),8*e.length))}};function w(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,r,s,i,o,a,c,l,u=new Array(80),h=1732584193,d=-271733879,_=-1732584194,f=271733878,m=-1009589776,p=0;p<e.length;p+=16){for(s=h,i=d,o=_,a=f,c=m,n=0;n<80;n++)u[n]=n<16?e[p+n]:C(u[n-3]^u[n-8]^u[n-14]^u[n-16],1),r=A(A(C(h,5),function(e,t,n,r){if(e<20)return t&n|~t&r;if(e<40)return t^n^r;if(e<60)return t&n|t&r|n&r;return t^n^r}(n,d,_,f)),A(A(m,u[n]),(l=n)<20?1518500249:l<40?1859775393:l<60?-1894007588:-899497514)),m=f,f=_,_=C(d,30),d=h,h=r;h=A(h,s),d=A(d,i),_=A(_,o),f=A(f,a),m=A(m,c)}return[h,d,_,f,m]}function N(e,t){var n=k(e);16<n.length&&(n=w(n,8*e.length));for(var r=new Array(16),s=new Array(16),i=0;i<16;i++)r[i]=909522486^n[i],s[i]=1549556828^n[i];var o=w(r.concat(k(t)),512+8*t.length);return w(s.concat(o),672)}function A(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function C(e,t){return e<<t|e>>>32-t}function k(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function E(e){for(var t,n,r="",s=0;s<4*e.length;s+=3)for(t=(e[s>>2]>>8*(3-s%4)&255)<<16|(e[s+1>>2]>>8*(3-(s+1)%4)&255)<<8|e[s+2>>2]>>8*(3-(s+2)%4)&255,n=0;n<4;n++)8*s+6*n>32*e.length?r+="=":r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return r}function O(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}var L={b64_hmac_sha1:function(e,t){return E(N(e,t))},b64_sha1:function(e){return E(w(k(e),8*e.length))},binb2str:O,core_hmac_sha1:N,str_hmac_sha1:function(e,t){return O(N(e,t))},str_sha1:function(e){return O(w(k(e),8*e.length))}},I={utf16to8:function(e){for(var t,n="",r=e.length,s=0;s<r;s++)0<=(t=e.charCodeAt(s))&&t<=127?n+=e.charAt(s):(2047<t?(n+=String.fromCharCode(224|t>>12&15),n+=String.fromCharCode(128|t>>6&63)):n+=String.fromCharCode(192|t>>6&31),n+=String.fromCharCode(128|t>>0&63));return n},addCookies:function(e){for(var t in e=e||{}){var n,r,s,i,o,a;Object.prototype.hasOwnProperty.call(e,t)&&(s=r=n="",o="object"===m(i=e[t]),a=escape(unescape(o?i.value:i)),o&&(n=i.expires?";expires="+i.expires:"",r=i.domain?";domain="+i.domain:"",s=i.path?";path="+i.path:""),document.cookie=t+"="+a+n+r+s)}}};var R={atob:function(e){if((e=(e="".concat(e)).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;for(var t="",n=0,r=0,s=0;s<e.length;s++)n<<=6,n|=function(e){if(/[A-Z]/.test(e))return e.charCodeAt(0)-"A".charCodeAt(0);if(/[a-z]/.test(e))return e.charCodeAt(0)-"a".charCodeAt(0)+26;if(/[0-9]/.test(e))return e.charCodeAt(0)-"0".charCodeAt(0)+52;if("+"===e)return 62;if("/"!==e)return;return 63}(e[s]),24===(r+=6)&&(t+=String.fromCharCode((16711680&n)>>16),t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n),n=r=0);return 12===r?(n>>=4,t+=String.fromCharCode(n)):18===r&&(n>>=2,t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n)),t},btoa:function(e){for(e="".concat(e),n=0;n<e.length;n++)if(255<e.charCodeAt(n))return null;for(var t="",n=0;n<e.length;n+=3){var r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(n)>>2,r[1]=(3&e.charCodeAt(n))<<4,e.length>n+1&&(r[1]|=e.charCodeAt(n+1)>>4,r[2]=(15&e.charCodeAt(n+1))<<2),e.length>n+2&&(r[2]|=e.charCodeAt(n+2)>>6,r[3]=63&e.charCodeAt(n+2));for(var s=0;s<r.length;s++)void 0===r[s]?t+="=":t+=function(e){if(e<26)return String.fromCharCode(e+"A".charCodeAt(0));if(e<52)return String.fromCharCode(e-26+"a".charCodeAt(0));if(e<62)return String.fromCharCode(e-52+"0".charCodeAt(0));if(62===e)return"+";if(63!==e)return;return"/"}(r[s])}return t}};function H(e,t){return new F.Builder(e,t)}function M(e){return new F.Builder("message",e)}function D(e){return new F.Builder("iq",e)}function q(e){return new F.Builder("presence",e)}var F={VERSION:"1.4.0",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},XHTML:{tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"],validTag:function(e){for(var t=0;t<F.XHTML.tags.length;t++)if(e===F.XHTML.tags[t])return!0;return!1},validAttribute:function(e,t){if(void 0!==F.XHTML.attributes[e]&&0<F.XHTML.attributes[e].length)for(var n=0;n<F.XHTML.attributes[e].length;n++)if(t===F.XHTML.attributes[e][n])return!0;return!1},validCSS:function(e){for(var t=0;t<F.XHTML.css.length;t++)if(e===F.XHTML.css[t])return!0;return!1}},Status:{ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8,REDIRECT:9,CONNTIMEOUT:10,BINDREQUIRED:11,ATTACHFAIL:12},ErrorCondition:{BAD_FORMAT:"bad-format",CONFLICT:"conflict",MISSING_JID_NODE:"x-strophe-bad-non-anon-jid",NO_AUTH_MECH:"no-auth-mech",UNKNOWN_REASON:"unknown"},LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},ElementType:{NORMAL:1,TEXT:3,CDATA:4,FRAGMENT:11},TIMEOUT:1.1,SECONDARY_TIMEOUT:.1,addNamespace:function(e,t){F.NS[e]=t},forEachChild:function(e,t,n){for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes[r];s.nodeType!==F.ElementType.NORMAL||t&&!this.isTagEqual(s,t)||n(s)}},isTagEqual:function(e,t){return e.tagName===t},_xmlGenerator:null,xmlGenerator:function(){return F._xmlGenerator||(F._xmlGenerator=_()),F._xmlGenerator},xmlElement:function(e){if(!e)return null;for(var t=F.xmlGenerator().createElement(e),n=1;n<arguments.length;n++){var r=arguments[n];if(r)if("string"==typeof r||"number"==typeof r)t.appendChild(F.xmlTextNode(r));else if("object"===m(r)&&"function"==typeof r.sort)for(var s=0;s<r.length;s++){var i=r[s];"object"===m(i)&&"function"==typeof i.sort&&void 0!==i[1]&&null!==i[1]&&t.setAttribute(i[0],i[1])}else if("object"===m(r))for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&void 0!==r[o]&&null!==r[o]&&t.setAttribute(o,r[o])}return t},xmlescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,""")},xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')},xmlTextNode:function(e){return F.xmlGenerator().createTextNode(e)},xmlHtmlNode:function(e){var t;return d?t=(new d).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)),t},getText:function(e){if(!e)return null;var t="";0===e.childNodes.length&&e.nodeType===F.ElementType.TEXT&&(t+=e.nodeValue);for(var n=0;n<e.childNodes.length;n++)e.childNodes[n].nodeType===F.ElementType.TEXT&&(t+=e.childNodes[n].nodeValue);return F.xmlescape(t)},copyElement:function(e){var t;if(e.nodeType===F.ElementType.NORMAL){t=F.xmlElement(e.tagName);for(var n=0;n<e.attributes.length;n++)t.setAttribute(e.attributes[n].nodeName,e.attributes[n].value);for(var r=0;r<e.childNodes.length;r++)t.appendChild(F.copyElement(e.childNodes[r]))}else e.nodeType===F.ElementType.TEXT&&(t=F.xmlGenerator().createTextNode(e.nodeValue));return t},createHtml:function(e){var t;if(e.nodeType===F.ElementType.NORMAL){var n=e.nodeName.toLowerCase();if(F.XHTML.validTag(n))try{t=F.xmlElement(n);for(var r=0;r<F.XHTML.attributes[n].length;r++){var s=F.XHTML.attributes[n][r],i=e.getAttribute(s);if(null!=i&&""!==i&&!1!==i&&0!==i)if("style"===s&&"object"===m(i)&&void 0!==i.cssText&&(i=i.cssText),"style"===s){for(var o=[],a=i.split(";"),c=0;c<a.length;c++){var l,u=a[c].split(":"),h=u[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase();F.XHTML.validCSS(h)&&(l=u[1].replace(/^\s*/,"").replace(/\s*$/,""),o.push(h+": "+l))}0<o.length&&(i=o.join("; "),t.setAttribute(s,i))}else t.setAttribute(s,i)}for(var d=0;d<e.childNodes.length;d++)t.appendChild(F.createHtml(e.childNodes[d]))}catch(e){t=F.xmlTextNode("")}else{t=F.xmlGenerator().createDocumentFragment();for(var _=0;_<e.childNodes.length;_++)t.appendChild(F.createHtml(e.childNodes[_]))}}else if(e.nodeType===F.ElementType.FRAGMENT){t=F.xmlGenerator().createDocumentFragment();for(var f=0;f<e.childNodes.length;f++)t.appendChild(F.createHtml(e.childNodes[f]))}else e.nodeType===F.ElementType.TEXT&&(t=F.xmlTextNode(e.nodeValue));return t},escapeNode:function(e){return"string"!=typeof e?e:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e: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,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){var t=F.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;var n=t.split("@");return n.splice(0,1),n.join("@")},getResourceFromJid:function(e){if(!e)return null;var t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:function(e){return e?e.split("/")[0]:null},_handleError:function(e){void 0!==e.stack&&F.fatal(e.stack),e.sourceURL?F.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?F.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):F.fatal("error: "+e.message)},log:function(e,t){e===this.LogLevel.FATAL&&"object"===m(window.console)&&"function"==typeof window.console.error&&window.console.error(t)},debug:function(e){this.log(this.LogLevel.DEBUG,e)},info:function(e){this.log(this.LogLevel.INFO,e)},warn:function(e){this.log(this.LogLevel.WARN,e)},error:function(e){this.log(this.LogLevel.ERROR,e)},fatal:function(e){this.log(this.LogLevel.FATAL,e)},serialize:function(n){if(!n)return null;"function"==typeof n.tree&&(n=n.tree());var e=u(Array(n.attributes.length).keys()).map(function(e){return n.attributes[e].nodeName});e.sort();var t=e.reduce(function(e,t){return"".concat(e," ").concat(t,'="').concat(F.xmlescape(n.attributes.getNamedItem(t).value),'"')},"<".concat(n.nodeName));if(0<n.childNodes.length){t+=">";for(var r=0;r<n.childNodes.length;r++){var s=n.childNodes[r];switch(s.nodeType){case F.ElementType.NORMAL:t+=F.serialize(s);break;case F.ElementType.TEXT:t+=F.xmlescape(s.nodeValue);break;case F.ElementType.CDATA:t+="<![CDATA["+s.nodeValue+"]]>"}}t+="</"+n.nodeName+">"}else t+="/>";return t},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(e,t){F._connectionPlugins[e]=t}};F.Builder=function(){function n(e,t){a(this,n),"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=F.NS.CLIENT:t=t||{xmlns:F.NS.CLIENT}),this.nodeTree=F.xmlElement(e,t),this.node=this.nodeTree}return i(n,[{key:"tree",value:function(){return this.nodeTree}},{key:"toString",value:function(){return F.serialize(this.nodeTree)}},{key:"up",value:function(){return this.node=this.node.parentNode,this}},{key:"root",value:function(){return this.node=this.nodeTree,this}},{key:"attrs",value:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this}},{key:"c",value:function(e,t,n){var r=F.xmlElement(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this}},{key:"cnode",value:function(e){var t,n=F.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}var r=t?n.importNode(e,!0):F.copyElement(e);return this.node.appendChild(r),this.node=r,this}},{key:"t",value:function(e){var t=F.xmlTextNode(e);return this.node.appendChild(t),this}},{key:"h",value:function(e){var t=F.xmlGenerator().createElement("body");t.innerHTML=e;for(var n=F.createHtml(t);0<n.childNodes.length;)this.node.appendChild(n.childNodes[0]);return this}}]),n}(),F.Handler=function(e,t,n,r,s,i,o){this.handler=e,this.ns=t,this.name=n,this.type=r,this.id=s,this.options=o||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBare&&(F.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.'),this.options.matchBareFromJid=this.options.matchBare,delete this.options.matchBare),this.options.matchBareFromJid?this.from=i?F.getBareJidFromJid(i):null:this.from=i,this.user=!0},F.Handler.prototype={getNamespace:function(e){var t=e.getAttribute("xmlns");return t&&this.options.ignoreNamespaceFragment&&(t=t.split("#")[0]),t},namespaceMatch:function(e){var t=this,n=!1;return!this.ns||(F.forEachChild(e,null,function(e){t.getNamespace(e)===t.ns&&(n=!0)}),n||this.getNamespace(e)===this.ns)},isMatch:function(e){var t=e.getAttribute("from");this.options.matchBareFromJid&&(t=F.getBareJidFromJid(t));var n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!F.isTagEqual(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(n):n!==this.type)||this.id&&e.getAttribute("id")!==this.id||this.from&&t!==this.from)},run:function(e){var t=null;try{t=this.handler(e)}catch(e){throw F._handleError(e),e}return t},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},F.TimedHandler=function(){function n(e,t){a(this,n),this.period=e,this.handler=t,this.lastCalled=(new Date).getTime(),this.user=!0}return i(n,[{key:"run",value:function(){return this.lastCalled=(new Date).getTime(),this.handler()}},{key:"reset",value:function(){this.lastCalled=(new Date).getTime()}},{key:"toString",value:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}}]),n}(),F.Connection=function(){function o(e,t){var n=this;a(this,o),this.service=e,this.options=t||{};var r,s=this.options.protocol||"";for(var i in this.options.worker?this._proto=new F.WorkerWebsocket(this):0===e.indexOf("ws:")||0===e.indexOf("wss:")||0===s.indexOf("ws")?this._proto=new F.Websocket(this):this._proto=new F.Bosh(this),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_bind=!1,this.do_session=!1,this.mechanisms={},this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.protocolErrorHandlers={HTTP:{},websocket:{}},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout(function(){return n._onIdle()},100),I.addCookies(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),F._connectionPlugins){Object.prototype.hasOwnProperty.call(F._connectionPlugins,i)&&((r=function(){}).prototype=F._connectionPlugins[i],this[i]=new r,this[i].init(this))}}return i(o,[{key:"reset",value:function(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0}},{key:"pause",value:function(){this.paused=!0}},{key:"resume",value:function(){this.paused=!1}},{key:"getUniqueId",value:function(e){var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}},{key:"addProtocolErrorHandler",value:function(e,t,n){this.protocolErrorHandlers[e][t]=n}},{key:"connect",value:function(e,t,n,r,s,i,o,a){this.jid=e,this.authzid=F.getBareJidFromJid(this.jid),this.authcid=a||F.getNodeFromJid(this.jid),this.pass=t,this.clientLogger=r||function(e){return console.log(e)},this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=F.getDomainFromJid(this.jid),this._changeConnectStatus(F.Status.CONNECTING,null),this._proto._connect(s,i,o),this.clientLogger("Strophe connect method is completed.")}},{key:"attach",value:function(e,t,n,r,s,i,o){if(this._proto._attach)return this._proto._attach(e,t,n,r,s,i,o);var a=new Error('The "attach" method is not available for your connection protocol');throw a.name="StropheSessionError",a}},{key:"restore",value:function(e,t,n,r,s){if(!this._sessionCachingSupported()){var i=new Error('The "restore" method can only be used with a BOSH connection.');throw i.name="StropheSessionError",i}this._proto._restore(e,t,n,r,s),this.clientLogger&&this.clientLogger("Strophe call unexpected method restore.")}},{key:"_sessionCachingSupported",value:function(){if(this._proto instanceof F.Bosh){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1}},{key:"xmlInput",value:function(){}},{key:"xmlOutput",value:function(){}},{key:"rawInput",value:function(){}},{key:"rawOutput",value:function(){}},{key:"nextValidRid",value:function(){}},{key:"send",value:function(e){if(null!==e){if("function"==typeof e.sort)for(var t=0;t<e.length;t++)this._queueData(e[t]);else"function"==typeof e.tree?this._queueData(e.tree()):this._queueData(e);this._proto._send()}}},{key:"flush",value:function(){clearTimeout(this._idleTimeout),this._onIdle()}},{key:"sendPresence",value:function(e,t,n,r){var s=this,i=null;"function"==typeof e.tree&&(e=e.tree());var o,a=e.getAttribute("id");return a||(a=this.getUniqueId("sendPresence"),e.setAttribute("id",a)),"function"!=typeof t&&"function"!=typeof n||(o=this.addHandler(function(e){i&&s.deleteTimedHandler(i),"error"===e.getAttribute("type")?n&&n(e):t&&t(e)},null,"presence",null,a),r&&(i=this.addTimedHandler(r,function(){return s.deleteHandler(o),n&&n(null),!1}))),this.send(e),a}},{key:"sendIQ",value:function(e,r,s,t){var i=this,o=null;"function"==typeof e.tree&&(e=e.tree());var n,a=e.getAttribute("id");return a||(a=this.getUniqueId("sendIQ"),e.setAttribute("id",a)),"function"!=typeof r&&"function"!=typeof s||(n=this.addHandler(function(e){o&&i.deleteTimedHandler(o);var t=e.getAttribute("type");if("result"===t)r&&r(e);else{if("error"!==t){var n=new Error("Got bad IQ type of ".concat(t));throw n.name="StropheError",n}s&&s(e)}},null,"iq",["error","result"],a),t&&(o=this.addTimedHandler(t,function(){return i.deleteHandler(n),s&&s(null),!1}))),this.send(e),a}},{key:"_queueData",value:function(e){if(null===e||!e.tagName||!e.childNodes){var t=new Error("Cannot queue non-DOMElement.");throw t.name="StropheError",t}this._data.push(e)}},{key:"_sendRestart",value:function(){var e=this;this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout(function(){return e._onIdle()},100),this.clientLogger&&this.clientLogger("Strophe _sendRestart method is called.")}},{key:"addTimedHandler",value:function(e,t){var n=new F.TimedHandler(e,t);return this.addTimeds.push(n),n}},{key:"deleteTimedHandler",value:function(e){this.removeTimeds.push(e)}},{key:"addHandler",value:function(e,t,n,r,s,i,o){var a=new F.Handler(e,t,n,r,s,i,o);return this.addHandlers.push(a),a}},{key:"deleteHandler",value:function(e){this.removeHandlers.push(e);var t=this.addHandlers.indexOf(e);0<=t&&this.addHandlers.splice(t,1)}},{key:"registerSASLMechanisms",value:function(e){var t=this;this.mechanisms={},(e=e||[F.SASLAnonymous,F.SASLExternal,F.SASLOAuthBearer,F.SASLXOAuth2,F.SASLPlain,F.SASLSHA1]).forEach(function(e){return t.registerSASLMechanism(e)})}},{key:"registerSASLMechanism",value:function(e){var t=new e;this.mechanisms[t.mechname]=t}},{key:"disconnect",value:function(e){var t;this._changeConnectStatus(F.Status.DISCONNECTING,e),e?(F.warn("Disconnect was called because: "+e),this.clientLogger&&this.clientLogger("Disconnect was called because: "+e)):(F.info("Disconnect was called"),this.clientLogger&&this.clientLogger("Disconnect was called")),this.connected?(t=!1,this.disconnecting=!0,this.authenticated&&(t=q({xmlns:F.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(t)):(F.warn("Disconnect was called before Strophe connected to the server"),this.clientLogger&&this.clientLogger("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect())}},{key:"_changeConnectStatus",value:function(e,t,n){for(var r in F._connectionPlugins)if(Object.prototype.hasOwnProperty.call(F._connectionPlugins,r)){var s=this[r];if(s.statusChanged)try{s.statusChanged(e,t)}catch(e){F.error("".concat(r," plugin caused an exception changing status: ").concat(e))}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){F._handleError(e),F.error("User connection callback caused an exception: ".concat(e)),this.clientLogger("User connection callback caused an exception: ".concat(e))}this.clientLogger("_changeConnectStatus is completed. Connection status changed to: "+e)}},{key:"_doDisconnect",value:function(e){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),F.debug("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(F.Status.DISCONNECTED,e),this.connected=!1}},{key:"_dataRecv",value:function(e,t){var s=this,n=this._proto._reqToData(e);if(null!==n){for(this.xmlInput!==F.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==F.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(F.serialize(n)));0<this.removeHandlers.length;){var r=this.removeHandlers.pop(),i=this.handlers.indexOf(r);0<=i&&this.handlers.splice(i,1)}for(;0<this.addHandlers.length;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())this._doDisconnect();else{var o=n.getAttribute("type");if(null!==o&&"terminate"===o){if(this.disconnecting)return;var a=n.getAttribute("condition"),c=n.getElementsByTagName("conflict");return null!==a?("remote-stream-error"===a&&0<c.length&&(a="conflict"),this._changeConnectStatus(F.Status.CONNFAIL,a)):this._changeConnectStatus(F.Status.CONNFAIL,F.ErrorCondition.UNKOWN_REASON),void this._doDisconnect(a)}F.forEachChild(n,null,function(e){var t=s.handlers;s.handlers=[];for(var n=0;n<t.length;n++){var r=t[n];try{(!r.isMatch(e)||!s.authenticated&&r.user||r.run(e))&&s.handlers.push(r)}catch(e){F.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}}})}}}},{key:"_connect_cb",value:function(e,t,n){var r,s,i=this;F.debug("_connect_cb was called"),this.connected=!0;try{r=this._proto._reqToData(e)}catch(e){if(e.name!==F.ErrorCondition.BAD_FORMAT)throw e;this._changeConnectStatus(F.Status.CONNFAIL,F.ErrorCondition.BAD_FORMAT),this._doDisconnect(F.ErrorCondition.BAD_FORMAT)}r&&(this.xmlInput!==F.Connection.prototype.xmlInput&&(r.nodeName===this._proto.strip&&r.childNodes.length?this.xmlInput(r.childNodes[0]):this.xmlInput(r)),this.rawInput!==F.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(F.serialize(r))),this._proto._connect_cb(r)!==F.Status.CONNFAIL&&((r.getElementsByTagNameNS?0<r.getElementsByTagNameNS(F.NS.STREAM,"features").length:0<r.getElementsByTagName("stream:features").length||0<r.getElementsByTagName("features").length)&&(0!==(s=Array.from(r.getElementsByTagName("mechanism")).map(function(e){return i.mechanisms[e.textContent]}).filter(function(e){return e})).length||0!==r.getElementsByTagName("auth").length)?!1!==this.do_authentication&&this.authenticate(s):this._proto._no_auth_received(t)))}},{key:"sortMechanismsByPriority",value:function(e){for(var t=0;t<e.length-1;++t){for(var n,r=t,s=t+1;s<e.length;++s)e[s].priority>e[r].priority&&(r=s);r!==t&&(n=e[t],e[t]=e[r],e[r]=n)}return e}},{key:"authenticate",value:function(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}},{key:"_attemptSASLAuth",value:function(e){e=this.sortMechanismsByPriority(e||[]);for(var t=!1,n=0;n<e.length;++n)if(e[n].test(this)){this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null),this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null),this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge_cb.bind(this),null,"challenge",null,null),this._sasl_mechanism=e[n],this._sasl_mechanism.onStart(this);var r,s=H("auth",{xmlns:F.NS.SASL,mechanism:this._sasl_mechanism.mechname});this._sasl_mechanism.isClientFirst&&(r=this._sasl_mechanism.onChallenge(this,null),s.t(R.btoa(r))),this.send(s.tree()),t=!0;break}return t}},{key:"_sasl_challenge_cb",value:function(e){var t=R.atob(F.getText(e)),n=this._sasl_mechanism.onChallenge(this,t),r=H("response",{xmlns:F.NS.SASL});return""!==n&&r.t(R.btoa(n)),this.send(r.tree()),!0}},{key:"_attemptLegacyAuth",value:function(){null===F.getNodeFromJid(this.jid)?(this._changeConnectStatus(F.Status.CONNFAIL,F.ErrorCondition.MISSING_JID_NODE),this.disconnect(F.ErrorCondition.MISSING_JID_NODE)):(this._changeConnectStatus(F.Status.AUTHENTICATING,null),this._addSysHandler(this._onLegacyAuthIQResult.bind(this),null,null,null,"_auth_1"),this.send(D({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:F.NS.AUTH}).c("username",{}).t(F.getNodeFromJid(this.jid)).tree()))}},{key:"_onLegacyAuthIQResult",value:function(){var e=D({type:"set",id:"_auth_2"}).c("query",{xmlns:F.NS.AUTH}).c("username",{}).t(F.getNodeFromJid(this.jid)).up().c("password").t(this.pass);return F.getResourceFromJid(this.jid)||(this.jid=F.getBareJidFromJid(this.jid)+"/strophe"),e.up().c("resource",{}).t(F.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(e.tree()),!1}},{key:"_sasl_success_cb",value:function(e){var n=this;if(this._sasl_data["server-signature"]){var t,r=R.atob(F.getText(e)).match(/([a-z]+)=([^,]+)(,|$)/);if("v"===r[1]&&(t=r[2]),t!==this._sasl_data["server-signature"])return this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_data={},this._sasl_failure_cb(null)}F.info("SASL authentication succeeded."),this._sasl_mechanism&&this._sasl_mechanism.onSuccess(),this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null);function s(e,t){for(;e.length;)n.deleteHandler(e.pop());return n._onStreamFeaturesAfterSASL(t),!1}var i=[];return i.push(this._addSysHandler(function(e){return s(i,e)},null,"stream:features",null,null)),i.push(this._addSysHandler(function(e){return s(i,e)},F.NS.STREAM,"features",null,null)),this._sendRestart(),!1}},{key:"_onStreamFeaturesAfterSASL",value:function(e){this.features=e;for(var t=0;t<e.childNodes.length;t++){var n=e.childNodes[t];"bind"===n.nodeName&&(this.do_bind=!0),"session"===n.nodeName&&(this.do_session=!0)}return this.do_bind?this.options.explicitResourceBinding?this._changeConnectStatus(F.Status.BINDREQUIRED,null):this.bind():this._changeConnectStatus(F.Status.AUTHFAIL,null),!1}},{key:"bind",value:function(){var e;this.do_bind?(this._addSysHandler(this._onResourceBindResultIQ.bind(this),null,null,null,"_bind_auth_2"),(e=F.getResourceFromJid(this.jid))?this.send(D({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:F.NS.BIND}).c("resource",{}).t(e).tree()):this.send(D({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:F.NS.BIND}).tree())):F.log(F.LogLevel.INFO,'Strophe.Connection.prototype.bind called but "do_bind" is false')}},{key:"_onResourceBindResultIQ",value:function(e){var t;if("error"===e.getAttribute("type"))return F.warn("Resource binding failed."),0<e.getElementsByTagName("conflict").length&&(t=F.ErrorCondition.CONFLICT),this._changeConnectStatus(F.Status.AUTHFAIL,t,e),!1;var n=e.getElementsByTagName("bind");if(!(0<n.length))return F.warn("Resource binding failed."),this._changeConnectStatus(F.Status.AUTHFAIL,null,e),!1;var r=n[0].getElementsByTagName("jid");0<r.length&&(this.authenticated=!0,this.jid=F.getText(r[0]),this.do_session?this._establishSession():this._changeConnectStatus(F.Status.CONNECTED,null))}},{key:"_establishSession",value:function(){if(!this.do_session)throw new Error("Strophe.Connection.prototype._establishSession "+"called but apparently ".concat(F.NS.SESSION," wasn't advertised by the server"));this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(D({type:"set",id:"_session_auth_2"}).c("session",{xmlns:F.NS.SESSION}).tree())}},{key:"_onSessionResultIQ",value:function(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(F.Status.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,F.warn("Session creation failed."),this._changeConnectStatus(F.Status.AUTHFAIL,null,e),!1;return!1}},{key:"_sasl_failure_cb",value:function(e){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(F.Status.AUTHFAIL,null,e),!1}},{key:"_auth2_cb",value:function(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(F.Status.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(F.Status.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}},{key:"_addSysTimedHandler",value:function(e,t){var n=new F.TimedHandler(e,t);return n.user=!1,this.addTimeds.push(n),n}},{key:"_addSysHandler",value:function(e,t,n,r,s){var i=new F.Handler(e,t,n,r,s);return i.user=!1,this.addHandlers.push(i),i}},{key:"_onDisconnectTimeout",value:function(){return F.debug("_onDisconnectTimeout was called"),this._changeConnectStatus(F.Status.CONNTIMEOUT,null),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1}},{key:"_onIdle",value:function(){for(var e=this;0<this.addTimeds.length;)this.timedHandlers.push(this.addTimeds.pop());for(;0<this.removeTimeds.length;){var t=this.removeTimeds.pop(),n=this.timedHandlers.indexOf(t);0<=n&&this.timedHandlers.splice(n,1)}for(var r=(new Date).getTime(),s=[],i=0;i<this.timedHandlers.length;i++){var o=this.timedHandlers[i];!this.authenticated&&o.user||o.lastCalled+o.period-r<=0&&!o.run()||s.push(o)}this.timedHandlers=s,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(function(){return e._onIdle()},100))}}]),o}(),F.SASLMechanism=function(){function r(e,t,n){a(this,r),this.mechname=e,this.isClientFirst=t,this.priority=n}return i(r,[{key:"test",value:function(){return!0}},{key:"onStart",value:function(e){this._connection=e}},{key:"onChallenge",value:function(){throw new Error("You should implement challenge handling!")}},{key:"onFailure",value:function(){this._connection=null}},{key:"onSuccess",value:function(){this._connection=null}}]),r}(),F.SASLAnonymous=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"ANONYMOUS",t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:20;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"test",value:function(e){return null===e.authcid}}]),s}(),F.SASLPlain=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"PLAIN",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:50;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"test",value:function(e){return null!==e.authcid}},{key:"onChallenge",value:function(e){var t=e.authcid,n=e.authzid,r=e.domain,s=e.pass;if(!r)throw new Error("SASLPlain onChallenge: domain is not defined!");var i=n!=="".concat(t,"@").concat(r)?n:"";return i+="\0",i+=t,i+="\0",i+=s,I.utf16to8(i)}}]),s}(),F.SASLSHA1=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"SCRAM-SHA-1",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:60;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"test",value:function(e){return null!==e.authcid}},{key:"onChallenge",value:function(e,t,n){var r=n||x.hexdigest(""+1234567890*Math.random()),s="n="+I.utf16to8(e.authcid);return s+=",r=",s+=r,e._sasl_data.cnonce=r,s="n,,"+(e._sasl_data["client-first-message-bare"]=s),this.onChallenge=function(e,t){for(var n,r,s,i,o,a,c="c=biws,",l="".concat(e._sasl_data["client-first-message-bare"],",").concat(t,","),u=e._sasl_data.cnonce,h=/([a-z]+)=([^,]+)(,|$)/;t.match(h);){var d=t.match(h);switch(t=t.replace(d[0],""),d[1]){case"r":n=d[2];break;case"s":r=d[2];break;case"i":s=d[2]}}if(n.substr(0,u.length)!==u)return e._sasl_data={},e._sasl_failure_cb();l+=c+="r="+n,r=R.atob(r),r+="\0\0\0";for(var _=I.utf16to8(e.pass),f=o=L.core_hmac_sha1(_,r),m=1;m<s;m++){for(i=L.core_hmac_sha1(_,L.binb2str(o)),a=0;a<5;a++)f[a]^=i[a];o=i}f=L.binb2str(f);var p=L.core_hmac_sha1(f,"Client Key"),g=L.str_hmac_sha1(f,"Server Key"),v=L.core_hmac_sha1(L.str_sha1(L.binb2str(p)),l);for(e._sasl_data["server-signature"]=L.b64_hmac_sha1(g,l),a=0;a<5;a++)p[a]^=v[a];return c+=",p="+R.btoa(L.binb2str(p))},s}}]),s}(),F.SASLOAuthBearer=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"OAUTHBEARER",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:40;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"test",value:function(e){return null!==e.pass}},{key:"onChallenge",value:function(e){var t="n,";return null!==e.authcid&&(t=t+"a="+e.authzid),t+=",",t+="",t+="auth=Bearer ",t+=e.pass,t+="",t+="",I.utf16to8(t)}}]),s}(),F.SASLExternal=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"EXTERNAL",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:10;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"onChallenge",value:function(e){return e.authcid===e.authzid?"":e.authzid}}]),s}(),F.SASLXOAuth2=function(){o(s,F.SASLMechanism);var r=l(s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"X-OAUTH2",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:30;return a(this,s),r.call(this,e,t,n)}return i(s,[{key:"test",value:function(e){return null!==e.pass}},{key:"onChallenge",value:function(e){var t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,I.utf16to8(t)}}]),s}();var j={Strophe:F,$build:H,$iq:D,$msg:M,$pres:q,SHA1:L,MD5:x,b64_hmac_sha1:L.b64_hmac_sha1,b64_sha1:L.b64_sha1,str_hmac_sha1:L.str_hmac_sha1,str_sha1:L.str_sha1};F.Request=function(){function s(e,t,n,r){a(this,s),this.id=++F._requestId,this.xmlData=e,this.data=F.serialize(e),this.origFunc=t,this.func=t,this.rid=n,this.date=NaN,this.sends=r||0,this.abort=!1,this.dead=null,this.age=function(){return this.date?(new Date-this.date)/1e3:0},this.timeDead=function(){return this.dead?(new Date-this.dead)/1e3:0},this.xhr=this._newXHR()}return i(s,[{key:"getResponse",value:function(){var e=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if("parsererror"===(e=this.xhr.responseXML.documentElement).tagName)throw F.error("invalid response received"),F.error("responseText: "+this.xhr.responseText),F.error("responseXML: "+F.serialize(this.xhr.responseXML)),new Error("parsererror")}else if(this.xhr.responseText){if(F.debug("Got responseText but no responseXML; attempting to parse it with DOMParser..."),!(e=(new d).parseFromString(this.xhr.responseText,"application/xml").documentElement))throw new Error("Parsing produced null node");if(e.querySelector("parsererror")){F.error("invalid response received: "+e.querySelector("parsererror").textContent),F.error("responseText: "+this.xhr.responseText);var t=new Error;throw t.name=F.ErrorCondition.BAD_FORMAT,t}}return e}},{key:"_newXHR",value:function(){var e=null;return window.XMLHttpRequest?(e=new XMLHttpRequest).overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8"):window.ActiveXObject&&(e=new ActiveXObject("Microsoft.XMLHTTP")),e.onreadystatechange=this.func.bind(null,this),e}}]),s}(),F.Bosh=function(){function h(e){a(this,h),this._conn=e,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this.inactivity=null,this.lastResponseHeaders=null,this._requests=[]}return i(h,[{key:"_buildBody",value:function(){var e=H("body",{rid:this.rid++,xmlns:F.NS.HTTPBIND});return null!==this.sid&&e.attrs({sid:this.sid}),this._conn.options.keepalive&&this._conn._sessionCachingSupported()&&this._cacheSession(),e}},{key:"_reset",value:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,this._conn._sessionCachingSupported()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}},{key:"_connect",value:function(e,t,n){this.wait=e||this.wait,this.hold=t||this.hold,this.errors=0;var r=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":F.NS.BOSH});n&&r.attrs({route:n});var s=this._conn._connect_cb;this._requests.push(new F.Request(r.tree(),this._onRequestStateChange.bind(this,s.bind(this._conn)),r.tree().getAttribute("rid"))),this._throttledRequestHandler(),this._conn.clientLogger("_connect method was called with BOSH protocol")}},{key:"_attach",value:function(e,t,n,r,s,i,o){this._conn.jid=e,this.sid=t,this.rid=n,this._conn.connect_callback=r,this._conn.domain=F.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=s||this.wait,this.hold=i||this.hold,this.window=o||this.window,this._conn._changeConnectStatus(F.Status.ATTACHED,null)}},{key:"_restore",value:function(e,t,n,r,s){var i=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!(null!=i&&i.rid&&i.sid&&i.jid&&(null==e||F.getBareJidFromJid(i.jid)===F.getBareJidFromJid(e)||null===F.getNodeFromJid(e)&&F.getDomainFromJid(i.jid)===e))){var o=new Error("_restore: no restoreable session.");throw o.name="StropheSessionError",o}this._conn.restored=!0,this._attach(i.jid,i.sid,i.rid,t,n,r,s)}},{key:"_cacheSession",value:function(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&window.sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):window.sessionStorage.removeItem("strophe-bosh-session")}},{key:"_connect_cb",value:function(e){var t=e.getAttribute("type");if(null!==t&&"terminate"===t){var n=e.getAttribute("condition");F.error("BOSH-Connection failed: "+n);var r=e.getElementsByTagName("conflict");return null!==n?("remote-stream-error"===n&&0<r.length&&(n="conflict"),this._conn._changeConnectStatus(F.Status.CONNFAIL,n)):this._conn._changeConnectStatus(F.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(n),F.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));var s=e.getAttribute("requests");s&&(this.window=parseInt(s,10));var i=e.getAttribute("hold");i&&(this.hold=parseInt(i,10));var o=e.getAttribute("wait");o&&(this.wait=parseInt(o,10));var a=e.getAttribute("inactivity");a&&(this.inactivity=parseInt(a,10))}},{key:"_disconnect",value:function(e){this._sendTerminate(e)}},{key:"_doDisconnect",value:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}},{key:"_emptyQueue",value:function(){return 0===this._requests.length}},{key:"_callProtocolErrorHandlers",value:function(e){var t=h._getRequestStatus(e),n=this._conn.protocolErrorHandlers.HTTP[t];n&&n.call(this,t)}},{key:"_hitError",value:function(e){this.errors++,F.warn("request errored, status: "+e+", number of errors: "+this.errors),4<this.errors&&this._conn._onDisconnectTimeout()}},{key:"_no_auth_received",value:function(e){F.warn("Server did not yet offer a supported authentication mechanism. Sending a blank poll request."),e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);var t=this._buildBody();this._requests.push(new F.Request(t.tree(),this._onRequestStateChange.bind(this,e),t.tree().getAttribute("rid"))),this._throttledRequestHandler()}},{key:"_onDisconnectTimeout",value:function(){this._abortAllRequests()}},{key:"_abortAllRequests",value:function(){for(;0<this._requests.length;){var e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}}},{key:"_onIdle",value:function(){var e,t=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===t.length&&!this._conn.disconnecting&&(F.debug("no requests during idle cycle, sending blank request"),t.push(null)),!this._conn.paused){if(this._requests.length<2&&0<t.length){for(var n=this._buildBody(),r=0;r<t.length;r++)null!==t[r]&&("restart"===t[r]?n.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":F.NS.BOSH}):n.cnode(t[r]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new F.Request(n.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),n.tree().getAttribute("rid"))),this._throttledRequestHandler()}0<this._requests.length&&(e=this._requests[0].age(),null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(F.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(F.TIMEOUT*this.wait)&&(F.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(F.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler()))}}},{key:"_onRequestStateChange",value:function(e,t){if(F.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)t.abort=!1;else if(4===t.xhr.readyState){var n=h._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this._conn.disconnecting&&400<=n)return this._hitError(n),void this._callProtocolErrorHandlers(t);var r,s=0<n&&n<500,i=t.sends>this._conn.maxRetries;(s||i)&&(this._removeRequest(t),F.debug("request id "+t.id+" should now be removed")),200===n?(r=this._requests[0]===t,(this._requests[1]===t||r&&0<this._requests.length&&this._requests[0].age()>Math.floor(F.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(t.rid)+1),F.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0):0===n||400<=n&&n<600||12e3<=n?(F.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),400<=n&&n<500&&(this._conn._changeConnectStatus(F.Status.DISCONNECTING,null),this._conn._doDisconnect())):F.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),s||i?i&&!this._conn.connected&&this._conn._changeConnectStatus(F.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}}},{key:"_processRequest",value:function(e){var n=this,r=this._requests[e],t=h._getRequestStatus(r,-1);if(r.sends>this._conn.maxRetries)this._conn._onDisconnectTimeout();else{var s=r.age(),i=!isNaN(s)&&s>Math.floor(F.TIMEOUT*this.wait),o=null!==r.dead&&r.timeDead()>Math.floor(F.SECONDARY_TIMEOUT*this.wait),a=4===r.xhr.readyState&&(t<1||500<=t);if((i||o||a)&&(o&&F.error("Request ".concat(this._requests[e].id," timed out (secondary), restarting")),r.abort=!0,r.xhr.abort(),r.xhr.onreadystatechange=function(){},this._requests[e]=new F.Request(r.xmlData,r.origFunc,r.rid,r.sends),r=this._requests[e]),0===r.xhr.readyState){F.debug("request id "+r.id+"."+r.sends+" posting");try{var c=this._conn.options.contentType||"text/xml; charset=utf-8";r.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==r.xhr.setRequestHeader&&r.xhr.setRequestHeader("Content-Type",c),this._conn.options.withCredentials&&(r.xhr.withCredentials=!0)}catch(e){return F.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(F.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var l,u=function(){if(r.date=new Date,n._conn.options.customHeaders){var e=n._conn.options.customHeaders;for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.xhr.setRequestHeader(t,e[t])}r.xhr.send(r.data)};1<r.sends?(l=1e3*Math.min(Math.floor(F.TIMEOUT*this.wait),Math.pow(r.sends,3)),setTimeout(function(){u()},l)):u(),r.sends++,this._conn.xmlOutput!==F.Connection.prototype.xmlOutput&&(r.xmlData.nodeName===this.strip&&r.xmlData.childNodes.length?this._conn.xmlOutput(r.xmlData.childNodes[0]):this._conn.xmlOutput(r.xmlData)),this._conn.rawOutput!==F.Connection.prototype.rawOutput&&this._conn.rawOutput(r.data)}else F.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+r.xhr.readyState)}}},{key:"_removeRequest",value:function(e){F.debug("removing request");for(var t=this._requests.length-1;0<=t;t--)e===this._requests[t]&&this._requests.splice(t,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()}},{key:"_restartRequest",value:function(e){var t=this._requests[e];null===t.dead&&(t.dead=new Date),this._processRequest(e)}},{key:"_reqToData",value:function(e){try{return e.getResponse()}catch(e){if("parsererror"!==e.message)throw e;this._conn.disconnect("strophe-parsererror")}}},{key:"_sendTerminate",value:function(e){F.debug("_sendTerminate was called");var t=this._buildBody().attrs({type:"terminate"});e&&t.cnode(e.tree());var n=new F.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),t.tree().getAttribute("rid"));this._requests.push(n),this._throttledRequestHandler()}},{key:"_send",value:function(){var e=this;clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(function(){return e._conn._onIdle()},100)}},{key:"_sendRestart",value:function(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)}},{key:"_throttledRequestHandler",value:function(){this._requests?F.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):F.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(0<this._requests.length&&this._processRequest(0),1<this._requests.length&&Math.abs(this._requests[0].rid-this._requests[1].rid)<this.window&&this._processRequest(1))}}],[{key:"_getRequestStatus",value:function(e,t){var n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){F.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n}}]),h}(),F.Bosh.prototype.strip=null,F.Websocket=function(){function r(e){a(this,r),this._conn=e,this.strip="wrapper";var t,n=e.service;0!==n.indexOf("ws:")&&0!==n.indexOf("wss:")&&(t="","ws"===e.options.protocol&&"https:"!==window.location.protocol?t+="ws":t+="wss",t+="://"+window.location.host,0!==n.indexOf("/")?t+=window.location.pathname+n:t+=n,e.service=t)}return i(r,[{key:"_buildStream",value:function(){return H("open",{xmlns:F.NS.FRAMING,to:this._conn.domain,version:"1.0"})}},{key:"_checkStreamError",value:function(e,t){var n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(F.NS.STREAM,"error"):e.getElementsByTagName("stream:error");if(0===n.length)return!1;for(var r=n[0],s="",i="",o=0;o<r.childNodes.length;o++){var a=r.childNodes[o];if("urn:ietf:params:xml:ns:xmpp-streams"!==a.getAttribute("xmlns"))break;"text"===a.nodeName?i=a.textContent:s=a.nodeName}var c="WebSocket stream error: ";return c+=s||"unknown",i&&(c+=" - "+i),F.error(c),this._conn._changeConnectStatus(t,s),this._conn._doDisconnect(),!0}},{key:"_reset",value:function(){}},{key:"_connect",value:function(){var t=this;this._closeSocket(),this.socket=new WebSocket(this._conn.service,"xmpp"),this.socket.onopen=function(){return t._onOpen()},this.socket.onerror=function(e){return t._onError(e)},this.socket.onclose=function(e){return t._onClose(e)},this.socket.onmessage=function(e){return t._onInitialMessage(e)},this._conn.clientLogger&&this._conn.clientLogger("_connect method was called with WebSocket protocol")}},{key:"_connect_cb",value:function(e){if(this._checkStreamError(e,F.Status.CONNFAIL))return F.Status.CONNFAIL}},{key:"_handleStreamStart",value:function(e){var t=!1,n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in <open />":n!==F.NS.FRAMING&&(t="Wrong xmlns in <open />: "+n);var r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in <open />":"1.0"!==r&&(t="Wrong version in <open />: "+r),!t||(this._conn._changeConnectStatus(F.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)}},{key:"_onInitialMessage",value:function(e){if(0===e.data.indexOf("<open ")||0===e.data.indexOf("<?xml")){var t=e.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===t)return;var n=(new d).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else{var r,s,i,o,a;0===e.data.indexOf("<close ")?(r=(new d).parseFromString(e.data,"text/xml").documentElement,this._conn.xmlInput(r),this._conn.rawInput(e.data),(s=r.getAttribute("see-other-uri"))?(0<=(i=this._conn.service).indexOf("wss:")&&0<=s.indexOf("wss:")||0<=i.indexOf("ws:"))&&(this._conn._changeConnectStatus(F.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=s,this._connect()):(this._conn._changeConnectStatus(F.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect())):(this._replaceMessageHandler(),o=this._streamWrap(e.data),a=(new d).parseFromString(o,"text/xml").documentElement,this._conn._connect_cb(a,null,e.data))}}},{key:"_replaceMessageHandler",value:function(){var t=this;this.socket.onmessage=function(e){return t._onMessage(e)}}},{key:"_disconnect",value:function(e){var t=this;if(this.socket&&this.socket.readyState!==WebSocket.CLOSED){e&&this._conn.send(e);var n=H("close",{xmlns:F.NS.FRAMING});this._conn.xmlOutput(n.tree());var r=F.serialize(n);this._conn.rawOutput(r);try{this.socket.send(r)}catch(e){F.warn("Couldn't send <close /> tag.")}}setTimeout(function(){return t._conn._doDisconnect},0)}},{key:"_doDisconnect",value:function(){F.debug("WebSockets _doDisconnect was called"),this._conn.clientLogger&&this._conn.clientLogger("WebSockets _doDisconnect was called"),this._closeSocket()}},{key:"_streamWrap",value:function(e){return"<wrapper>"+e+"</wrapper>"}},{key:"_closeSocket",value:function(){if(this.socket)try{this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close()}catch(e){F.debug(e.message),this._conn.clientLogger&&this._conn.clientLogger(e.message)}this.socket=null}},{key:"_emptyQueue",value:function(){return!0}},{key:"_onClose",value:function(e){this._conn.connected&&!this._conn.disconnecting?(F.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(F.error("Websocket closed unexcectedly"),this._conn.clientLogger&&this._conn.clientLogger("Websocket closed unexcectedly"),this._conn._changeConnectStatus(F.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):F.debug("Websocket closed")}},{key:"_no_auth_received",value:function(e){F.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus(F.Status.CONNFAIL,F.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()}},{key:"_onDisconnectTimeout",value:function(){}},{key:"_abortAllRequests",value:function(){}},{key:"_onError",value:function(e){F.error("Websocket error "+e),this._conn.clientLogger&&this._conn.clientLogger("Websocket error "+e),this._conn._changeConnectStatus(F.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()}},{key:"_onIdle",value:function(){var e=this._conn._data;if(0<e.length&&!this._conn.paused){for(var t,n,r=0;r<e.length;r++){null!==e[r]&&(t=void 0,t="restart"===e[r]?this._buildStream().tree():e[r],n=F.serialize(t),this._conn.xmlOutput(t),this._conn.rawOutput(n),this.socket.send(n))}this._conn._data=[]}}},{key:"_onMessage",value:function(e){var t='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(e.data===t)return this._conn.rawInput(t),this._conn.xmlInput(e),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===e.data.search("<open ")){if(r=(new d).parseFromString(e.data,"text/xml").documentElement,!this._handleStreamStart(r))return}else var n=this._streamWrap(e.data),r=(new d).parseFromString(n,"text/xml").documentElement;return this._checkStreamError(r,F.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===r.firstChild.nodeName&&"unavailable"===r.firstChild.getAttribute("type")?(this._conn.xmlInput(r),void this._conn.rawInput(F.serialize(r))):void this._conn._dataRecv(r,e.data)}},{key:"_onOpen",value:function(){F.debug("Websocket open");var e=this._buildStream();this._conn.xmlOutput(e.tree());var t=F.serialize(e);this._conn.rawOutput(t),this.socket.send(t)}},{key:"_reqToData",value:function(e){return e}},{key:"_send",value:function(){this._conn.flush()}},{key:"_sendRestart",value:function(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}}]),r}();var B={};B.debug=F.LogLevel.DEBUG,B.info=F.LogLevel.INFO,B.warn=F.LogLevel.WARN,B.error=F.LogLevel.ERROR,B.fatal=F.LogLevel.FATAL,F.WorkerWebsocket=function(){o(r,F.Websocket);var n=l(r);function r(e){var t;return a(this,r),(t=n.call(this,e))._conn=e,t.worker=new SharedWorker(t._conn.options.worker,"Strophe XMPP Connection"),t.worker.onerror=function(e){var t;null!==(t=console)&&void 0!==t&&t.error(e),F.log(F.LogLevel.ERROR,"Shared Worker Error: ".concat(e))},t}return i(r,[{key:"_connect",value:function(){var t=this;this._messageHandler=function(e){return t._onInitialMessage(e)},this.worker.port.start(),this.worker.port.onmessage=function(e){return t._onWorkerMessage(e)},this.worker.port.postMessage(["_connect",this._conn.service,this._conn.jid]),this._conn.clientLogger&&this._conn.clientLogger("_connect method was called with WebSocket worker protocol")}},{key:"_attach",value:function(e){var t=this;this._messageHandler=function(e){return t._onMessage(e)},this._conn.connect_callback=e,this.worker.port.start(),this.worker.port.onmessage=function(e){return t._onWorkerMessage(e)},this.worker.port.postMessage(["_attach",this._conn.service])}},{key:"_attachCallback",value:function(e,t){e===F.Status.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus(F.Status.ATTACHED)):e===F.Status.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus(F.Status.ATTACHFAIL))}},{key:"_disconnect",value:function(e,t){t&&this._conn.send(t);var n=H("close",{xmlns:F.NS.FRAMING});this._conn.xmlOutput(n.tree());var r=F.serialize(n);this._conn.rawOutput(r),this.worker.port.postMessage(["send",r]),this._conn._doDisconnect()}},{key:"_onClose",value:function(e){this._conn.connected&&!this._conn.disconnecting?(F.error("Websocket closed unexpectedly"),this._conn.clientLogger&&this._conn.clientLogger("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected?(F.error("Websocket closed unexcectedly"),this._conn.clientLogger&&this._conn.clientLogger("Websocket closed unexpectedly"),this._conn._changeConnectStatus(F.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):F.debug("Websocket closed")}},{key:"_closeSocket",value:function(){this.worker.port.postMessage(["_closeSocket"])}},{key:"_replaceMessageHandler",value:function(){var t=this;this._messageHandler=function(e){return t._onMessage(e)}}},{key:"_onWorkerMessage",value:function(e){var t,n,r=e.data,s=r[0];if("_onMessage"===s)this._messageHandler(r[1]);else if(s in this)try{this[s].apply(this,e.data.slice(1))}catch(e){F.log(F.LogLevel.ERROR,e)}else{"log"===s?(t=r[1],n=r[2],F.log(B[t],n)):F.log(F.LogLevel.ERROR,"Found unhandled service worker message: ".concat(r))}}},{key:"socket",get:function(){var t=this;return{send:function(e){return t.worker.port.postMessage(["send",e])}}}}]),r}(),t.$build=j.$build,t.$iq=j.$iq,t.$msg=j.$msg,t.$pres=j.$pres,t.Strophe=j.Strophe,e.$build=H,e.$iq=D,e.$msg=M,e.$pres=q,e.Strophe=F,Object.defineProperty(e,"__esModule",{value:!0})});
|