1/** 2 * Minified by jsDelivr using Terser v5.39.0. 3 * Original file: /npm/strophe@1.2.4/strophe.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7!function(t){var e,n;if(e=this,n=function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return{encode:function(e){var n,s,i,r,o,a,h,c="",u=0;do{r=(n=e.charCodeAt(u++))>>2,o=(3&n)<<4|(s=e.charCodeAt(u++))>>4,a=(15&s)<<2|(i=e.charCodeAt(u++))>>6,h=63&i,isNaN(s)?(o=(3&n)<<4,a=h=64):isNaN(i)&&(h=64),c=c+t.charAt(r)+t.charAt(o)+t.charAt(a)+t.charAt(h)}while(u<e.length);return c},decode:function(e){var n,s,i,r,o,a,h="",c=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{n=t.indexOf(e.charAt(c++))<<2|(r=t.indexOf(e.charAt(c++)))>>4,s=(15&r)<<4|(o=t.indexOf(e.charAt(c++)))>>2,i=(3&o)<<6|(a=t.indexOf(e.charAt(c++))),h+=String.fromCharCode(n),64!=o&&(h+=String.fromCharCode(s)),64!=a&&(h+=String.fromCharCode(i))}while(c<e.length);return h}}},"function"==typeof define&&define.amd?define("strophe-base64",(function(){return n()})):e.Base64=n(),function(t,e){"function"==typeof define&&define.amd?define("strophe-sha1",(function(){return e()})):t.SHA1=e()}(this,(function(){function t(t,s){t[s>>5]|=128<<24-s%32,t[15+(s+64>>9<<4)]=s;var o,a,h,c,u,l,d,_,f=new Array(80),m=1732584193,p=-271733879,g=-1732584194,S=271733878,b=-1009589776;for(o=0;o<t.length;o+=16){for(c=m,u=p,l=g,d=S,_=b,a=0;a<80;a++)f[a]=a<16?t[o+a]:r(f[a-3]^f[a-8]^f[a-14]^f[a-16],1),h=i(i(r(m,5),e(a,p,g,S)),i(i(b,f[a]),n(a))),b=S,S=g,g=r(p,30),p=m,m=h;m=i(m,c),p=i(p,u),g=i(g,l),S=i(S,d),b=i(b,_)}return[m,p,g,S,b]}function e(t,e,n,s){return t<20?e&n|~e&s:t<40?e^n^s:t<60?e&n|e&s|n&s:e^n^s}function n(t){return t<20?1518500249:t<40?1859775393:t<60?-1894007588:-899497514}function s(e,n){var s=o(e);s.length>16&&(s=t(s,8*e.length));for(var i=new Array(16),r=new Array(16),a=0;a<16;a++)i[a]=909522486^s[a],r[a]=1549556828^s[a];var h=t(i.concat(o(n)),512+8*n.length);return t(r.concat(h),672)}function i(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function r(t,e){return t<<e|t>>>32-e}function o(t){for(var e=[],n=0;n<8*t.length;n+=8)e[n>>5]|=(255&t.charCodeAt(n/8))<<24-n%32;return e}function a(t){for(var e="",n=0;n<32*t.length;n+=8)e+=String.fromCharCode(t[n>>5]>>>24-n%32&255);return e}function h(t){for(var e,n,s="",i=0;i<4*t.length;i+=3)for(e=(t[i>>2]>>8*(3-i%4)&255)<<16|(t[i+1>>2]>>8*(3-(i+1)%4)&255)<<8|t[i+2>>2]>>8*(3-(i+2)%4)&255,n=0;n<4;n++)8*i+6*n>32*t.length?s+="=":s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e>>6*(3-n)&63);return s}return{b64_hmac_sha1:function(t,e){return h(s(t,e))},b64_sha1:function(e){return h(t(o(e),8*e.length))},binb2str:a,core_hmac_sha1:s,str_hmac_sha1:function(t,e){return a(s(t,e))},str_sha1:function(e){return a(t(o(e),8*e.length))}}})),function(t,e){"function"==typeof define&&define.amd?define("strophe-md5",(function(){return e()})):t.MD5=e()}(this,(function(t){var e=function(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n},n=function(t){for(var e=[],n=0;n<8*t.length;n+=8)e[n>>5]|=(255&t.charCodeAt(n/8))<<n%32;return e},s=function(t,n,s,i,r,o){return e((a=e(e(n,t),e(i,o)))<<(h=r)|a>>>32-h,s);var a,h},i=function(t,e,n,i,r,o,a){return s(e&n|~e&i,t,e,r,o,a)},r=function(t,e,n,i,r,o,a){return s(e&i|n&~i,t,e,r,o,a)},o=function(t,e,n,i,r,o,a){return s(e^n^i,t,e,r,o,a)},a=function(t,e,n,i,r,o,a){return s(n^(e|~i),t,e,r,o,a)},h=function(t,n){t[n>>5]|=128<<n%32,t[14+(n+64>>>9<<4)]=n;for(var s,h,c,u,l=1732584193,d=-271733879,_=-1732584194,f=271733878,m=0;m<t.length;m+=16)s=l,h=d,c=_,u=f,l=i(l,d,_,f,t[m+0],7,-680876936),f=i(f,l,d,_,t[m+1],12,-389564586),_=i(_,f,l,d,t[m+2],17,606105819),d=i(d,_,f,l,t[m+3],22,-1044525330),l=i(l,d,_,f,t[m+4],7,-176418897),f=i(f,l,d,_,t[m+5],12,1200080426),_=i(_,f,l,d,t[m+6],17,-1473231341),d=i(d,_,f,l,t[m+7],22,-45705983),l=i(l,d,_,f,t[m+8],7,1770035416),f=i(f,l,d,_,t[m+9],12,-1958414417),_=i(_,f,l,d,t[m+10],17,-42063),d=i(d,_,f,l,t[m+11],22,-1990404162),l=i(l,d,_,f,t[m+12],7,1804603682),f=i(f,l,d,_,t[m+13],12,-40341101),_=i(_,f,l,d,t[m+14],17,-1502002290),d=i(d,_,f,l,t[m+15],22,1236535329),l=r(l,d,_,f,t[m+1],5,-165796510),f=r(f,l,d,_,t[m+6],9,-1069501632),_=r(_,f,l,d,t[m+11],14,643717713),d=r(d,_,f,l,t[m+0],20,-373897302),l=r(l,d,_,f,t[m+5],5,-701558691),f=r(f,l,d,_,t[m+10],9,38016083),_=r(_,f,l,d,t[m+15],14,-660478335),d=r(d,_,f,l,t[m+4],20,-405537848),l=r(l,d,_,f,t[m+9],5,568446438),f=r(f,l,d,_,t[m+14],9,-1019803690),_=r(_,f,l,d,t[m+3],14,-187363961),d=r(d,_,f,l,t[m+8],20,1163531501),l=r(l,d,_,f,t[m+13],5,-1444681467),f=r(f,l,d,_,t[m+2],9,-51403784),_=r(_,f,l,d,t[m+7],14,1735328473),d=r(d,_,f,l,t[m+12],20,-1926607734),l=o(l,d,_,f,t[m+5],4,-378558),f=o(f,l,d,_,t[m+8],11,-2022574463),_=o(_,f,l,d,t[m+11],16,1839030562),d=o(d,_,f,l,t[m+14],23,-35309556),l=o(l,d,_,f,t[m+1],4,-1530992060),f=o(f,l,d,_,t[m+4],11,1272893353),_=o(_,f,l,d,t[m+7],16,-155497632),d=o(d,_,f,l,t[m+10],23,-1094730640),l=o(l,d,_,f,t[m+13],4,681279174),f=o(f,l,d,_,t[m+0],11,-358537222),_=o(_,f,l,d,t[m+3],16,-722521979),d=o(d,_,f,l,t[m+6],23,76029189),l=o(l,d,_,f,t[m+9],4,-640364487),f=o(f,l,d,_,t[m+12],11,-421815835),_=o(_,f,l,d,t[m+15],16,530742520),d=o(d,_,f,l,t[m+2],23,-995338651),l=a(l,d,_,f,t[m+0],6,-198630844),f=a(f,l,d,_,t[m+7],10,1126891415),_=a(_,f,l,d,t[m+14],15,-1416354905),d=a(d,_,f,l,t[m+5],21,-57434055),l=a(l,d,_,f,t[m+12],6,1700485571),f=a(f,l,d,_,t[m+3],10,-1894986606),_=a(_,f,l,d,t[m+10],15,-1051523),d=a(d,_,f,l,t[m+1],21,-2054922799),l=a(l,d,_,f,t[m+8],6,1873313359),f=a(f,l,d,_,t[m+15],10,-30611744),_=a(_,f,l,d,t[m+6],15,-1560198380),d=a(d,_,f,l,t[m+13],21,1309151649),l=a(l,d,_,f,t[m+4],6,-145523070),f=a(f,l,d,_,t[m+11],10,-1120210379),_=a(_,f,l,d,t[m+2],15,718787259),d=a(d,_,f,l,t[m+9],21,-343485551),l=e(l,s),d=e(d,h),_=e(_,c),f=e(f,u);return[l,d,_,f]};return{hexdigest:function(t){return function(t){for(var e="0123456789abcdef",n="",s=0;s<4*t.length;s++)n+=e.charAt(t[s>>2]>>s%4*8+4&15)+e.charAt(t[s>>2]>>s%4*8&15);return n}(h(n(t),8*t.length))},hash:function(t){return function(t){for(var e="",n=0;n<32*t.length;n+=8)e+=String.fromCharCode(t[n>>5]>>>n%32&255);return e}(h(n(t),8*t.length))}}})),function(t,e){"function"==typeof define&&define.amd?define("strophe-utils",(function(){return e()})):t.stropheUtils=e()}(this,(function(){return{utf16to8:function(t){var e,n,s="",i=t.length;for(e=0;e<i;e++)(n=t.charCodeAt(e))>=0&&n<=127?s+=t.charAt(e):n>2047?(s+=String.fromCharCode(224|n>>12&15),s+=String.fromCharCode(128|n>>6&63),s+=String.fromCharCode(128|63&n)):(s+=String.fromCharCode(192|n>>6&31),s+=String.fromCharCode(128|63&n));return s}}})),function(t,e){if("function"!=typeof define||!define.amd)return e();define("strophe-polyfill",[],(function(){return e()}))}(0,(function(){Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=Array.prototype.slice,s=Array.prototype.concat,i=n.call(arguments,1);return function(){return e.apply(t||this,s.call(i,n.call(arguments,0)))}}),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=this.length,n=Number(arguments[1])||0;for((n=n<0?Math.ceil(n):Math.floor(n))<0&&(n+=e);n<e;n++)if(n in this&&this[n]===t)return n;return-1})})),function(t,e){if("function"==typeof define&&define.amd)define("strophe-core",["strophe-sha1","strophe-base64","strophe-md5","strophe-utils","strophe-polyfill"],(function(){return e.apply(this,arguments)}));else{var n=e(t.SHA1,t.Base64,t.MD5,t.stropheUtils);window.Strophe=n.Strophe,window.$build=n.$build,window.$iq=n.$iq,window.$msg=n.$msg,window.$pres=n.$pres,window.SHA1=n.SHA1,window.Base64=n.Base64,window.MD5=n.MD5,window.b64_hmac_sha1=n.SHA1.b64_hmac_sha1,window.b64_sha1=n.SHA1.b64_sha1,window.str_hmac_sha1=n.SHA1.str_hmac_sha1,window.str_sha1=n.SHA1.str_sha1}}(this,(function(t,e,n,s){var i;function r(t,e){return new i.Builder(t,e)}function o(t){return new i.Builder("iq",t)}function a(t){return new i.Builder("presence",t)}return i={VERSION:"1.2.4",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(t){for(var e=0;e<i.XHTML.tags.length;e++)if(t==i.XHTML.tags[e])return!0;return!1},validAttribute:function(t,e){if(void 0!==i.XHTML.attributes[t]&&i.XHTML.attributes[t].length>0)for(var n=0;n<i.XHTML.attributes[t].length;n++)if(e==i.XHTML.attributes[t][n])return!0;return!1},validCSS:function(t){for(var e=0;e<i.XHTML.css.length;e++)if(t==i.XHTML.css[e])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},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(t,e){i.NS[t]=e},forEachChild:function(t,e,n){var s,r;for(s=0;s<t.childNodes.length;s++)(r=t.childNodes[s]).nodeType!=i.ElementType.NORMAL||e&&!this.isTagEqual(r,e)||n(r)},isTagEqual:function(t,e){return t.tagName==e},_xmlGenerator:null,_makeGenerator:function(){var t;return void 0===document.implementation.createDocument||document.implementation.createDocument&&document.documentMode&&document.documentMode<10?(t=this._getIEXmlDom()).appendChild(t.createElement("strophe")):t=document.implementation.createDocument("jabber:client","strophe",null),t},xmlGenerator:function(){return i._xmlGenerator||(i._xmlGenerator=i._makeGenerator()),i._xmlGenerator},_getIEXmlDom:function(){for(var t=null,e=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"],n=0;n<e.length&&null===t;n++)try{t=new ActiveXObject(e[n])}catch(e){t=null}return t},xmlElement:function(t){if(!t)return null;var e,n,s,r=i.xmlGenerator().createElement(t);for(e=1;e<arguments.length;e++){var o=arguments[e];if(o)if("string"==typeof o||"number"==typeof o)r.appendChild(i.xmlTextNode(o));else if("object"==typeof o&&"function"==typeof o.sort)for(n=0;n<o.length;n++){var a=o[n];"object"==typeof a&&"function"==typeof a.sort&&void 0!==a[1]&&null!==a[1]&&r.setAttribute(a[0],a[1])}else if("object"==typeof o)for(s in o)o.hasOwnProperty(s)&&void 0!==o[s]&&null!==o[s]&&r.setAttribute(s,o[s])}return r},xmlescape:function(t){return t=(t=(t=(t=(t=t.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,""")},xmlunescape:function(t){return t=(t=(t=(t=(t=t.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')},xmlTextNode:function(t){return i.xmlGenerator().createTextNode(t)},xmlHtmlNode:function(t){var e;window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):((e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t));return e},getText:function(t){if(!t)return null;var e="";0===t.childNodes.length&&t.nodeType==i.ElementType.TEXT&&(e+=t.nodeValue);for(var n=0;n<t.childNodes.length;n++)t.childNodes[n].nodeType==i.ElementType.TEXT&&(e+=t.childNodes[n].nodeValue);return i.xmlescape(e)},copyElement:function(t){var e,n;if(t.nodeType==i.ElementType.NORMAL){for(n=i.xmlElement(t.tagName),e=0;e<t.attributes.length;e++)n.setAttribute(t.attributes[e].nodeName,t.attributes[e].value);for(e=0;e<t.childNodes.length;e++)n.appendChild(i.copyElement(t.childNodes[e]))}else t.nodeType==i.ElementType.TEXT&&(n=i.xmlGenerator().createTextNode(t.nodeValue));return n},createHtml:function(t){var e,n,s,r,o,a,h,c,u,l,d;if(t.nodeType==i.ElementType.NORMAL)if(r=t.nodeName.toLowerCase(),i.XHTML.validTag(r))try{for(n=i.xmlElement(r),e=0;e<i.XHTML.attributes[r].length;e++)if(o=i.XHTML.attributes[r][e],null!=(a=t.getAttribute(o))&&""!==a&&!1!==a&&0!==a)if("style"==o&&"object"==typeof a&&void 0!==a.cssText&&(a=a.cssText),"style"==o){for(h=[],c=a.split(";"),s=0;s<c.length;s++)l=(u=c[s].split(":"))[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase(),i.XHTML.validCSS(l)&&(d=u[1].replace(/^\s*/,"").replace(/\s*$/,""),h.push(l+": "+d));h.length>0&&(a=h.join("; "),n.setAttribute(o,a))}else n.setAttribute(o,a);for(e=0;e<t.childNodes.length;e++)n.appendChild(i.createHtml(t.childNodes[e]))}catch(t){n=i.xmlTextNode("")}else for(n=i.xmlGenerator().createDocumentFragment(),e=0;e<t.childNodes.length;e++)n.appendChild(i.createHtml(t.childNodes[e]));else if(t.nodeType==i.ElementType.FRAGMENT)for(n=i.xmlGenerator().createDocumentFragment(),e=0;e<t.childNodes.length;e++)n.appendChild(i.createHtml(t.childNodes[e]));else t.nodeType==i.ElementType.TEXT&&(n=i.xmlTextNode(t.nodeValue));return n},escapeNode:function(t){return"string"!=typeof t?t:t.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(t){return"string"!=typeof t?t:t.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(t){return t.indexOf("@")<0?null:t.split("@")[0]},getDomainFromJid:function(t){var e=i.getBareJidFromJid(t);if(e.indexOf("@")<0)return e;var n=e.split("@");return n.splice(0,1),n.join("@")},getResourceFromJid:function(t){var e=t.split("/");return e.length<2?null:(e.splice(0,1),e.join("/"))},getBareJidFromJid:function(t){return t?t.split("/")[0]:null},log:function(t,e){},debug:function(t){this.log(this.LogLevel.DEBUG,t)},info:function(t){this.log(this.LogLevel.INFO,t)},warn:function(t){this.log(this.LogLevel.WARN,t)},error:function(t){this.log(this.LogLevel.ERROR,t)},fatal:function(t){this.log(this.LogLevel.FATAL,t)},serialize:function(t){var e;if(!t)return null;"function"==typeof t.tree&&(t=t.tree());var n,s,r=t.nodeName;for(t.getAttribute("_realname")&&(r=t.getAttribute("_realname")),e="<"+r,n=0;n<t.attributes.length;n++)"_realname"!=t.attributes[n].nodeName&&(e+=" "+t.attributes[n].nodeName+"='"+t.attributes[n].value.replace(/&/g,"&").replace(/\'/g,"'").replace(/>/g,">").replace(/</g,"<")+"'");if(t.childNodes.length>0){for(e+=">",n=0;n<t.childNodes.length;n++)switch((s=t.childNodes[n]).nodeType){case i.ElementType.NORMAL:e+=i.serialize(s);break;case i.ElementType.TEXT:e+=i.xmlescape(s.nodeValue);break;case i.ElementType.CDATA:e+="<![CDATA["+s.nodeValue+"]]>"}e+="</"+r+">"}else e+="/>";return e},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(t,e){i._connectionPlugins[t]=e}},i.Builder=function(t,e){"presence"!=t&&"message"!=t&&"iq"!=t||(e&&!e.xmlns?e.xmlns=i.NS.CLIENT:e||(e={xmlns:i.NS.CLIENT})),this.nodeTree=i.xmlElement(t,e),this.node=this.nodeTree},i.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return i.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},attrs:function(t){for(var e in t)t.hasOwnProperty(e)&&(void 0===t[e]?this.node.removeAttribute(e):this.node.setAttribute(e,t[e]));return this},c:function(t,e,n){var s=i.xmlElement(t,e,n);return this.node.appendChild(s),"string"!=typeof n&&(this.node=s),this},cnode:function(t){var e,n=i.xmlGenerator();try{e=void 0!==n.importNode}catch(t){e=!1}var s=e?n.importNode(t,!0):i.copyElement(t);return this.node.appendChild(s),this.node=s,this},t:function(t){var e=i.xmlTextNode(t);return this.node.appendChild(e),this},h:function(t){var e=document.createElement("body");e.innerHTML=t;for(var n=i.createHtml(e);n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}},i.Handler=function(t,e,n,s,r,o,a){this.handler=t,this.ns=e,this.name=n,this.type=s,this.id=r,this.options=a||{matchBare:!1},this.options.matchBare||(this.options.matchBare=!1),this.options.matchBare?this.from=o?i.getBareJidFromJid(o):null:this.from=o,this.user=!0},i.Handler.prototype={isMatch:function(t){var e,n=null;if(n=this.options.matchBare?i.getBareJidFromJid(t.getAttribute("from")):t.getAttribute("from"),e=!1,this.ns){var s=this;i.forEachChild(t,null,(function(t){t.getAttribute("xmlns")==s.ns&&(e=!0)})),e=e||t.getAttribute("xmlns")==this.ns}else e=!0;var r=t.getAttribute("type");return!(!e||this.name&&!i.isTagEqual(t,this.name)||this.type&&(Array.isArray(this.type)?-1==this.type.indexOf(r):r!=this.type)||this.id&&t.getAttribute("id")!=this.id||this.from&&n!=this.from)},run:function(t){var e=null;try{e=this.handler(t)}catch(t){throw t.sourceURL?i.fatal("error: "+this.handler+" "+t.sourceURL+":"+t.line+" - "+t.name+": "+t.message):t.fileName?("undefined"!=typeof console&&(console.trace(),console.error(this.handler," - error - ",t,t.message)),i.fatal("error: "+this.handler+" "+t.fileName+":"+t.lineNumber+" - "+t.name+": "+t.message)):i.fatal("error: "+t.message+"\n"+t.stack),t}return e},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},i.TimedHandler=function(t,e){this.period=t,this.handler=e,this.lastCalled=(new Date).getTime(),this.user=!0},i.TimedHandler.prototype={run:function(){return this.lastCalled=(new Date).getTime(),this.handler()},reset:function(){this.lastCalled=(new Date).getTime()},toString:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}},i.Connection=function(t,e){this.service=t,this.options=e||{};var n=this.options.protocol||"";for(var s in 0===t.indexOf("ws:")||0===t.indexOf("wss:")||0===n.indexOf("ws")?this._proto=new i.Websocket(this):this._proto=new i.Bosh(this),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._authentication={},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(this._onIdle.bind(this),100),i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(s)){var r=i._connectionPlugins[s],o=function(){};o.prototype=r,this[s]=new o,this[s].init(this)}},i.Connection.prototype={reset: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._authentication={},this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0},pause:function(){this.paused=!0},resume:function(){this.paused=!1},getUniqueId:function(t){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}));return"string"==typeof t||"number"==typeof t?e+":"+t:e+""},connect:function(t,e,n,s,r,o,a){this.jid=t,this.authzid=i.getBareJidFromJid(this.jid),this.authcid=a||i.getNodeFromJid(this.jid),this.pass=e,this.servtype="xmpp",this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=i.getDomainFromJid(this.jid),this._changeConnectStatus(i.Status.CONNECTING,null),this._proto._connect(s,r,o)},attach:function(t,e,n,s,r,o,a){if(!(this._proto instanceof i.Bosh))throw{name:"StropheSessionError",message:'The "attach" method can only be used with a BOSH connection.'};this._proto._attach(t,e,n,s,r,o,a)},restore:function(t,e,n,s,i){if(!this._sessionCachingSupported())throw{name:"StropheSessionError",message:'The "restore" method can only be used with a BOSH connection.'};this._proto._restore(t,e,n,s,i)},_sessionCachingSupported:function(){if(this._proto instanceof i.Bosh){if(!JSON)return!1;try{window.sessionStorage.setItem("_strophe_","_strophe_"),window.sessionStorage.removeItem("_strophe_")}catch(t){return!1}return!0}return!1},xmlInput:function(t){},xmlOutput:function(t){},rawInput:function(t){},rawOutput:function(t){},nextValidRid:function(t){},send:function(t){if(null!==t){if("function"==typeof t.sort)for(var e=0;e<t.length;e++)this._queueData(t[e]);else"function"==typeof t.tree?this._queueData(t.tree()):this._queueData(t);this._proto._send()}},flush:function(){clearTimeout(this._idleTimeout),this._onIdle()},sendIQ:function(t,e,n,s){var r=null,o=this;"function"==typeof t.tree&&(t=t.tree());var a=t.getAttribute("id");a||(a=this.getUniqueId("sendIQ"),t.setAttribute("id",a));var h=t.getAttribute("to"),c=this.jid,u=this.addHandler((function(t){r&&o.deleteTimedHandler(r);var s=!1,a=t.getAttribute("from");if(a!==h&&(h||a!==i.getBareJidFromJid(c)&&a!==i.getDomainFromJid(c)&&a!==c)||(s=!0),!s)throw{name:"StropheError",message:"Got answer to IQ from wrong jid:"+a+"\nExpected jid: "+h};var u=t.getAttribute("type");if("result"==u)e&&e(t);else{if("error"!=u)throw{name:"StropheError",message:"Got bad IQ type of "+u};n&&n(t)}}),null,"iq",["error","result"],a);return s&&(r=this.addTimedHandler(s,(function(){return o.deleteHandler(u),n&&n(null),!1}))),this.send(t),a},_queueData:function(t){if(null===t||!t.tagName||!t.childNodes)throw{name:"StropheError",message:"Cannot queue non-DOMElement."};this._data.push(t)},_sendRestart:function(){this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout(this._onIdle.bind(this),100)},addTimedHandler:function(t,e){var n=new i.TimedHandler(t,e);return this.addTimeds.push(n),n},deleteTimedHandler:function(t){this.removeTimeds.push(t)},addHandler:function(t,e,n,s,r,o,a){var h=new i.Handler(t,e,n,s,r,o,a);return this.addHandlers.push(h),h},deleteHandler:function(t){this.removeHandlers.push(t);var e=this.addHandlers.indexOf(t);e>=0&&this.addHandlers.splice(e,1)},disconnect:function(t){if(this._changeConnectStatus(i.Status.DISCONNECTING,t),i.info("Disconnect was called because: "+t),this.connected){var e=!1;this.disconnecting=!0,this.authenticated&&(e=a({xmlns:i.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else i.info("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests()},_changeConnectStatus:function(t,e){for(var n in i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(n)){var s=this[n];if(s.statusChanged)try{s.statusChanged(t,e)}catch(t){i.error(n+" plugin caused an exception changing status: "+t)}}if(this.connect_callback)try{this.connect_callback(t,e)}catch(t){i.error("User connection callback caused an exception: "+t)}},_doDisconnect:function(t){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),i.info("_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(i.Status.DISCONNECTED,t),this.connected=!1},_dataRecv:function(t,e){i.info("_dataRecv called");var n=this._proto._reqToData(t);if(null!==n){var s,r;for(this.xmlInput!==i.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==i.Connection.prototype.rawInput&&(e?this.rawInput(e):this.rawInput(i.serialize(n)));this.removeHandlers.length>0;)r=this.removeHandlers.pop(),(s=this.handlers.indexOf(r))>=0&&this.handlers.splice(s,1);for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())this._doDisconnect();else{var o,a,h=n.getAttribute("type");if(null!==h&&"terminate"==h){if(this.disconnecting)return;return o=n.getAttribute("condition"),a=n.getElementsByTagName("conflict"),null!==o?("remote-stream-error"==o&&a.length>0&&(o="conflict"),this._changeConnectStatus(i.Status.CONNFAIL,o)):this._changeConnectStatus(i.Status.CONNFAIL,"unknown"),void this._doDisconnect(o)}var c=this;i.forEachChild(n,null,(function(t){var e,n;for(n=c.handlers,c.handlers=[],e=0;e<n.length;e++){var s=n[e];try{(!s.isMatch(t)||!c.authenticated&&s.user||s.run(t))&&c.handlers.push(s)}catch(t){i.warn("Removing Strophe handlers due to uncaught exception: "+t.message)}}}))}}},mechanisms:{},_connect_cb:function(t,e,n){var s;i.info("_connect_cb was called"),this.connected=!0;try{s=this._proto._reqToData(t)}catch(t){if("badformat"!=t)throw t;this._changeConnectStatus(i.Status.CONNFAIL,"bad-format"),this._doDisconnect("bad-format")}if(s&&(this.xmlInput!==i.Connection.prototype.xmlInput&&(s.nodeName===this._proto.strip&&s.childNodes.length?this.xmlInput(s.childNodes[0]):this.xmlInput(s)),this.rawInput!==i.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(i.serialize(s))),this._proto._connect_cb(s)!==i.Status.CONNFAIL)){var r;this._authentication.sasl_scram_sha1=!1,this._authentication.sasl_plain=!1,this._authentication.sasl_digest_md5=!1,this._authentication.sasl_anonymous=!1,this._authentication.legacy_auth=!1,r=s.getElementsByTagNameNS?s.getElementsByTagNameNS(i.NS.STREAM,"features").length>0:s.getElementsByTagName("stream:features").length>0||s.getElementsByTagName("features").length>0;var o,a,h=s.getElementsByTagName("mechanism"),c=[];if(r){if(h.length>0)for(o=0;o<h.length;o++)a=i.getText(h[o]),this.mechanisms[a]&&c.push(this.mechanisms[a]);this._authentication.legacy_auth=s.getElementsByTagName("auth").length>0,this._authentication.legacy_auth||c.length>0?!1!==this.do_authentication&&this.authenticate(c):this._proto._no_auth_received(e)}else this._proto._no_auth_received(e)}},authenticate:function(t){var n;for(n=0;n<t.length-1;++n){for(var s=n,a=n+1;a<t.length;++a)t[a].prototype.priority>t[s].prototype.priority&&(s=a);if(s!=n){var h=t[n];t[n]=t[s],t[s]=h}}var c=!1;for(n=0;n<t.length;++n)if(t[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=new t[n],this._sasl_mechanism.onStart(this);var u=r("auth",{xmlns:i.NS.SASL,mechanism:this._sasl_mechanism.name});if(this._sasl_mechanism.isClientFirst){var l=this._sasl_mechanism.onChallenge(this,null);u.t(e.encode(l))}this.send(u.tree()),c=!0;break}c||(null===i.getNodeFromJid(this.jid)?(this._changeConnectStatus(i.Status.CONNFAIL,"x-strophe-bad-non-anon-jid"),this.disconnect("x-strophe-bad-non-anon-jid")):(this._changeConnectStatus(i.Status.AUTHENTICATING,null),this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1"),this.send(o({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:i.NS.AUTH}).c("username",{}).t(i.getNodeFromJid(this.jid)).tree())))},_sasl_challenge_cb:function(t){var n=e.decode(i.getText(t)),s=this._sasl_mechanism.onChallenge(this,n),o=r("response",{xmlns:i.NS.SASL});return""!==s&&o.t(e.encode(s)),this.send(o.tree()),!0},_auth1_cb:function(t){var e=o({type:"set",id:"_auth_2"}).c("query",{xmlns:i.NS.AUTH}).c("username",{}).t(i.getNodeFromJid(this.jid)).up().c("password").t(this.pass);return i.getResourceFromJid(this.jid)||(this.jid=i.getBareJidFromJid(this.jid)+"/strophe"),e.up().c("resource",{}).t(i.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(e.tree()),!1},_sasl_success_cb:function(t){if(this._sasl_data["server-signature"]){var n,s=e.decode(i.getText(t)).match(/([a-z]+)=([^,]+)(,|$)/);if("v"==s[1]&&(n=s[2]),n!=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)}i.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);var r=[],o=function(t,e){for(;t.length;)this.deleteHandler(t.pop());return this._sasl_auth1_cb.bind(this)(e),!1};return r.push(this._addSysHandler(function(t){o.bind(this)(r,t)}.bind(this),null,"stream:features",null,null)),r.push(this._addSysHandler(function(t){o.bind(this)(r,t)}.bind(this),i.NS.STREAM,"features",null,null)),this._sendRestart(),!1},_sasl_auth1_cb:function(t){var e,n;for(this.features=t,e=0;e<t.childNodes.length;e++)"bind"==(n=t.childNodes[e]).nodeName&&(this.do_bind=!0),"session"==n.nodeName&&(this.do_session=!0);if(!this.do_bind)return this._changeConnectStatus(i.Status.AUTHFAIL,null),!1;this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var s=i.getResourceFromJid(this.jid);return s?this.send(o({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:i.NS.BIND}).c("resource",{}).t(s).tree()):this.send(o({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:i.NS.BIND}).tree()),!1},_sasl_bind_cb:function(t){var e;if("error"==t.getAttribute("type"))return i.info("SASL binding failed."),t.getElementsByTagName("conflict").length>0&&(e="conflict"),this._changeConnectStatus(i.Status.AUTHFAIL,e),!1;var n,s=t.getElementsByTagName("bind");if(!(s.length>0))return i.info("SASL binding failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1;(n=s[0].getElementsByTagName("jid")).length>0&&(this.jid=i.getText(n[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(o({type:"set",id:"_session_auth_2"}).c("session",{xmlns:i.NS.SESSION}).tree())):(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null)))},_sasl_session_cb:function(t){if("result"==t.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null);else if("error"==t.getAttribute("type"))return i.info("Session creation failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1;return!1},_sasl_failure_cb:function(t){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(i.Status.AUTHFAIL,null),!1},_auth2_cb:function(t){return"result"==t.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null)):"error"==t.getAttribute("type")&&(this._changeConnectStatus(i.Status.AUTHFAIL,null),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(t,e){var n=new i.TimedHandler(t,e);return n.user=!1,this.addTimeds.push(n),n},_addSysHandler:function(t,e,n,s,r){var o=new i.Handler(t,e,n,s,r);return o.user=!1,this.addHandlers.push(o),o},_onDisconnectTimeout:function(){return i.info("_onDisconnectTimeout was called"),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1},_onIdle:function(){for(var t,e,n;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;)e=this.removeTimeds.pop(),(t=this.timedHandlers.indexOf(e))>=0&&this.timedHandlers.splice(t,1);var s=(new Date).getTime();for(n=[],t=0;t<this.timedHandlers.length;t++)e=this.timedHandlers[t],!this.authenticated&&e.user||(e.lastCalled+e.period-s<=0?e.run()&&n.push(e):n.push(e));this.timedHandlers=n,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(this._onIdle.bind(this),100))}},i.SASLMechanism=function(t,e,n){this.name=t,this.isClientFirst=e,this.priority=n},i.SASLMechanism.prototype={test:function(t){return!0},onStart:function(t){this._connection=t},onChallenge:function(t,e){throw new Error("You should implement challenge handling!")},onFailure:function(){this._connection=null},onSuccess:function(){this._connection=null}},i.SASLAnonymous=function(){},i.SASLAnonymous.prototype=new i.SASLMechanism("ANONYMOUS",!1,10),i.SASLAnonymous.test=function(t){return null===t.authcid},i.Connection.prototype.mechanisms[i.SASLAnonymous.prototype.name]=i.SASLAnonymous,i.SASLPlain=function(){},i.SASLPlain.prototype=new i.SASLMechanism("PLAIN",!0,20),i.SASLPlain.test=function(t){return null!==t.authcid},i.SASLPlain.prototype.onChallenge=function(t){var e=t.authzid;return e+="\0",e+=t.authcid,e+="\0",e+=t.pass,s.utf16to8(e)},i.Connection.prototype.mechanisms[i.SASLPlain.prototype.name]=i.SASLPlain,i.SASLSHA1=function(){},i.SASLSHA1.prototype=new i.SASLMechanism("SCRAM-SHA-1",!0,40),i.SASLSHA1.test=function(t){return null!==t.authcid},i.SASLSHA1.prototype.onChallenge=function(i,r,o){var a=o||n.hexdigest(1234567890*Math.random()),h="n="+s.utf16to8(i.authcid);return h+=",r=",h+=a,i._sasl_data.cnonce=a,i._sasl_data["client-first-message-bare"]=h,h="n,,"+h,this.onChallenge=function(n,i){for(var r,o,a,h,c,u,l,d,_,f,m,p,g="c=biws,",S=n._sasl_data["client-first-message-bare"]+","+i+",",b=n._sasl_data.cnonce,v=/([a-z]+)=([^,]+)(,|$)/;i.match(v);){var y=i.match(v);switch(i=i.replace(y[0],""),y[1]){case"r":r=y[2];break;case"s":o=y[2];break;case"i":a=y[2]}}if(r.substr(0,b.length)!==b)return n._sasl_data={},n._sasl_failure_cb();for(S+=g+="r="+r,o=e.decode(o),o+="\0\0\0",_=s.utf16to8(n.pass),h=u=t.core_hmac_sha1(_,o),l=1;l<a;l++){for(c=t.core_hmac_sha1(_,t.binb2str(u)),d=0;d<5;d++)h[d]^=c[d];u=c}for(h=t.binb2str(h),f=t.core_hmac_sha1(h,"Client Key"),m=t.str_hmac_sha1(h,"Server Key"),p=t.core_hmac_sha1(t.str_sha1(t.binb2str(f)),S),n._sasl_data["server-signature"]=t.b64_hmac_sha1(m,S),d=0;d<5;d++)f[d]^=p[d];return g+=",p="+e.encode(t.binb2str(f))}.bind(this),h},i.Connection.prototype.mechanisms[i.SASLSHA1.prototype.name]=i.SASLSHA1,i.SASLMD5=function(){},i.SASLMD5.prototype=new i.SASLMechanism("DIGEST-MD5",!1,30),i.SASLMD5.test=function(t){return null!==t.authcid},i.SASLMD5.prototype._quote=function(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},i.SASLMD5.prototype.onChallenge=function(t,e,i){for(var r,o=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,a=i||n.hexdigest(""+1234567890*Math.random()),h="",c=null,u="";e.match(o);)switch(r=e.match(o),e=e.replace(r[0],""),r[2]=r[2].replace(/^"(.+)"$/,"$1"),r[1]){case"realm":h=r[2];break;case"nonce":u=r[2];break;case"qop":r[2];break;case"host":c=r[2]}var l=t.servtype+"/"+t.domain;null!==c&&(l=l+"/"+c);var d=s.utf16to8(t.authcid+":"+h+":"+this._connection.pass),_=n.hash(d)+":"+u+":"+a,f="AUTHENTICATE:"+l,m="";return m+="charset=utf-8,",m+="username="+this._quote(s.utf16to8(t.authcid))+",",m+="realm="+this._quote(h)+",",m+="nonce="+this._quote(u)+",",m+="nc=00000001,",m+="cnonce="+this._quote(a)+",",m+="digest-uri="+this._quote(l)+",",m+="response="+n.hexdigest(n.hexdigest(_)+":"+u+":00000001:"+a+":auth:"+n.hexdigest(f))+",",m+="qop=auth",this.onChallenge=function(){return""}.bind(this),m},i.Connection.prototype.mechanisms[i.SASLMD5.prototype.name]=i.SASLMD5,{Strophe:i,$build:r,$msg:function(t){return new i.Builder("message",t)},$iq:o,$pres:a,SHA1:t,Base64:e,MD5:n}})),function(t,e){if("function"!=typeof define||!define.amd)return e(Strophe,$build);define("strophe-bosh",["strophe-core"],(function(t){return e(t.Strophe,t.$build)}))}(0,(function(t,e){return t.Request=function(e,n,s,i){this.id=++t._requestId,this.xmlData=e,this.data=t.serialize(e),this.origFunc=n,this.func=n,this.rid=s,this.date=NaN,this.sends=i||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()},t.Request.prototype={getResponse:function(){var e=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if("parsererror"==(e=this.xhr.responseXML.documentElement).tagName)throw t.error("invalid response received"),t.error("responseText: "+this.xhr.responseText),t.error("responseXML: "+t.serialize(this.xhr.responseXML)),"parsererror"}else if(this.xhr.responseText)throw t.error("invalid response received"),t.error("responseText: "+this.xhr.responseText),"badformat";return e},_newXHR:function(){var t=null;return window.XMLHttpRequest?(t=new XMLHttpRequest).overrideMimeType&&t.overrideMimeType("text/xml; charset=utf-8"):window.ActiveXObject&&(t=new ActiveXObject("Microsoft.XMLHTTP")),t.onreadystatechange=this.func.bind(null,this),t}},t.Bosh=function(t){this._conn=t,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this._requests=[]},t.Bosh.prototype={strip:null,_buildBody:function(){var n=e("body",{rid:this.rid++,xmlns:t.NS.HTTPBIND});return null!==this.sid&&n.attrs({sid:this.sid}),this._conn.options.keepalive&&this._cacheSession(),n},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_connect:function(e,n,s){this.wait=e||this.wait,this.hold=n||this.hold,this.errors=0;var i=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":t.NS.BOSH});s&&i.attrs({route:s});var r=this._conn._connect_cb;this._requests.push(new t.Request(i.tree(),this._onRequestStateChange.bind(this,r.bind(this._conn)),i.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(e,n,s,i,r,o,a){this._conn.jid=e,this.sid=n,this.rid=s,this._conn.connect_callback=i,this._conn.domain=t.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=r||this.wait,this.hold=o||this.hold,this.window=a||this.window,this._conn._changeConnectStatus(t.Status.ATTACHED,null)},_restore:function(e,n,s,i,r){var o=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!(null!=o&&o.rid&&o.sid&&o.jid)||void 0!==e&&"null"!==e&&t.getBareJidFromJid(o.jid)!=t.getBareJidFromJid(e))throw{name:"StropheSessionError",message:"_restore: no restoreable session."};this._conn.restored=!0,this._attach(o.jid,o.sid,o.rid,n,s,i,r)},_cacheSession: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")},_connect_cb:function(e){var n,s,i=e.getAttribute("type");if(null!==i&&"terminate"==i)return n=e.getAttribute("condition"),t.error("BOSH-Connection failed: "+n),s=e.getElementsByTagName("conflict"),null!==n?("remote-stream-error"==n&&s.length>0&&(n="conflict"),this._conn._changeConnectStatus(t.Status.CONNFAIL,n)):this._conn._changeConnectStatus(t.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(n),t.Status.CONNFAIL;this.sid||(this.sid=e.getAttribute("sid"));var r=e.getAttribute("requests");r&&(this.window=parseInt(r,10));var o=e.getAttribute("hold");o&&(this.hold=parseInt(o,10));var a=e.getAttribute("wait");a&&(this.wait=parseInt(a,10))},_disconnect:function(t){this._sendTerminate(t)},_doDisconnect:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_emptyQueue:function(){return 0===this._requests.length},_hitError:function(e){this.errors++,t.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()},_no_auth_received:function(e){e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);var n=this._buildBody();this._requests.push(new t.Request(n.tree(),this._onRequestStateChange.bind(this,e.bind(this._conn)),n.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout:function(){this._abortAllRequests()},_abortAllRequests:function(){for(var t;this._requests.length>0;)(t=this._requests.pop()).abort=!0,t.xhr.abort(),t.xhr.onreadystatechange=function(){}},_onIdle:function(){var e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(t.info("no requests during idle cycle, sending blank request"),e.push(null)),!this._conn.paused){if(this._requests.length<2&&e.length>0){for(var n=this._buildBody(),s=0;s<e.length;s++)null!==e[s]&&("restart"===e[s]?n.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":t.NS.BOSH}):n.cnode(e[s]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new t.Request(n.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),n.tree().getAttribute("rid"))),this._throttledRequestHandler()}if(this._requests.length>0){var i=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(t.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),i>Math.floor(t.TIMEOUT*this.wait)&&(t.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(t.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_onRequestStateChange:function(e,n){var s;if(t.debug("request id "+n.id+"."+n.sends+" state changed to "+n.xhr.readyState),n.abort)n.abort=!1;else if(4==n.xhr.readyState){s=0;try{s=n.xhr.status}catch(t){}if(void 0===s&&(s=0),this.disconnecting&&s>=400)return void this._hitError(s);var i=this._requests[0]==n,r=this._requests[1]==n;(s>0&&s<500||n.sends>5)&&(this._removeRequest(n),t.debug("request id "+n.id+" should now be removed")),200==s?((r||i&&this._requests.length>0&&this._requests[0].age()>Math.floor(t.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(n.rid)+1),t.debug("request id "+n.id+"."+n.sends+" got 200"),e(n),this.errors=0):(t.error("request id "+n.id+"."+n.sends+" error "+s+" happened"),(0===s||s>=400&&s<600||s>=12e3)&&(this._hitError(s),s>=400&&s<500&&(this._conn._changeConnectStatus(t.Status.DISCONNECTING,null),this._conn._doDisconnect()))),s>0&&s<500||n.sends>5||this._throttledRequestHandler()}},_processRequest:function(e){var n=this,s=this._requests[e],i=-1;try{4==s.xhr.readyState&&(i=s.xhr.status)}catch(n){t.error("caught an error in _requests["+e+"], reqStatus: "+i)}if(void 0===i&&(i=-1),s.sends>this._conn.maxRetries)this._conn._onDisconnectTimeout();else{var r=s.age(),o=!isNaN(r)&&r>Math.floor(t.TIMEOUT*this.wait),a=null!==s.dead&&s.timeDead()>Math.floor(t.SECONDARY_TIMEOUT*this.wait),h=4==s.xhr.readyState&&(i<1||i>=500);if((o||a||h)&&(a&&t.error("Request "+this._requests[e].id+" timed out (secondary), restarting"),s.abort=!0,s.xhr.abort(),s.xhr.onreadystatechange=function(){},this._requests[e]=new t.Request(s.xmlData,s.origFunc,s.rid,s.sends),s=this._requests[e]),0===s.xhr.readyState){t.debug("request id "+s.id+"."+s.sends+" posting");try{s.xhr.open("POST",this._conn.service,!this._conn.options.sync),s.xhr.setRequestHeader("Content-Type","text/xml; charset=utf-8")}catch(e){return t.error("XHR open failed."),this._conn.connected||this._conn._changeConnectStatus(t.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var c=function(){if(s.date=new Date,n._conn.options.customHeaders){var t=n._conn.options.customHeaders;for(var e in t)t.hasOwnProperty(e)&&s.xhr.setRequestHeader(e,t[e])}s.xhr.send(s.data)};if(s.sends>1){var u=1e3*Math.min(Math.floor(t.TIMEOUT*this.wait),Math.pow(s.sends,3));setTimeout(c,u)}else c();s.sends++,this._conn.xmlOutput!==t.Connection.prototype.xmlOutput&&(s.xmlData.nodeName===this.strip&&s.xmlData.childNodes.length?this._conn.xmlOutput(s.xmlData.childNodes[0]):this._conn.xmlOutput(s.xmlData)),this._conn.rawOutput!==t.Connection.prototype.rawOutput&&this._conn.rawOutput(s.data)}else t.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+s.xhr.readyState)}},_removeRequest:function(e){var n;for(t.debug("removing request"),n=this._requests.length-1;n>=0;n--)e==this._requests[n]&&this._requests.splice(n,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()},_restartRequest:function(t){var e=this._requests[t];null===e.dead&&(e.dead=new Date),this._processRequest(t)},_reqToData:function(t){try{return t.getResponse()}catch(t){if("parsererror"!=t)throw t;this._conn.disconnect("strophe-parsererror")}},_sendTerminate:function(e){t.info("_sendTerminate was called");var n=this._buildBody().attrs({type:"terminate"});e&&n.cnode(e.tree());var s=new t.Request(n.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),n.tree().getAttribute("rid"));this._requests.push(s),this._throttledRequestHandler()},_send:function(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(this._conn._onIdle.bind(this._conn),100)},_sendRestart:function(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)},_throttledRequestHandler:function(){this._requests?t.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):t.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)<this.window&&this._processRequest(1))}},t})),function(t,e){if("function"!=typeof define||!define.amd)return e(Strophe,$build);define("strophe-websocket",["strophe-core"],(function(t){return e(t.Strophe,t.$build)}))}(0,(function(t,e){return t.Websocket=function(t){this._conn=t,this.strip="wrapper";var e=t.service;if(0!==e.indexOf("ws:")&&0!==e.indexOf("wss:")){var n="";"ws"===t.options.protocol&&"https:"!==window.location.protocol?n+="ws":n+="wss",n+="://"+window.location.host,0!==e.indexOf("/")?n+=window.location.pathname+e:n+=e,t.service=n}},t.Websocket.prototype={_buildStream:function(){return e("open",{xmlns:t.NS.FRAMING,to:this._conn.domain,version:"1.0"})},_check_streamerror:function(e,n){var s;if(0===(s=e.getElementsByTagNameNS?e.getElementsByTagNameNS(t.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;for(var i=s[0],r="",o="",a=0;a<i.childNodes.length;a++){var h=i.childNodes[a];if("urn:ietf:params:xml:ns:xmpp-streams"!==h.getAttribute("xmlns"))break;"text"===h.nodeName?o=h.textContent:r=h.nodeName}var c="WebSocket stream error: ";return c+=r||"unknown",o&&(c+=" - "+r),t.error(c),this._conn._changeConnectStatus(n,r),this._conn._doDisconnect(),!0},_reset:function(){},_connect:function(){this._closeSocket(),this.socket=new WebSocket(this._conn.service,"xmpp"),this.socket.onopen=this._onOpen.bind(this),this.socket.onerror=this._onError.bind(this),this.socket.onclose=this._onClose.bind(this),this.socket.onmessage=this._connect_cb_wrapper.bind(this)},_connect_cb:function(e){if(this._check_streamerror(e,t.Status.CONNFAIL))return t.Status.CONNFAIL},_handleStreamStart:function(e){var n=!1,s=e.getAttribute("xmlns");"string"!=typeof s?n="Missing xmlns in <open />":s!==t.NS.FRAMING&&(n="Wrong xmlns in <open />: "+s);var i=e.getAttribute("version");return"string"!=typeof i?n="Missing version in <open />":"1.0"!==i&&(n="Wrong version in <open />: "+i),!n||(this._conn._changeConnectStatus(t.Status.CONNFAIL,n),this._conn._doDisconnect(),!1)},_connect_cb_wrapper:function(e){if(0===e.data.indexOf("<open ")||0===e.data.indexOf("<?xml")){var n=e.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===n)return;var s=(new DOMParser).parseFromString(n,"text/xml").documentElement;this._conn.xmlInput(s),this._conn.rawInput(e.data),this._handleStreamStart(s)&&this._connect_cb(s)}else if(0===e.data.indexOf("<close ")){this._conn.rawInput(e.data),this._conn.xmlInput(e);var i=e.getAttribute("see-other-uri");i?(this._conn._changeConnectStatus(t.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=i,this._connect()):(this._conn._changeConnectStatus(t.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect())}else{var r=this._streamWrap(e.data),o=(new DOMParser).parseFromString(r,"text/xml").documentElement;this.socket.onmessage=this._onMessage.bind(this),this._conn._connect_cb(o,null,e.data)}},_disconnect:function(n){if(this.socket&&this.socket.readyState!==WebSocket.CLOSED){n&&this._conn.send(n);var s=e("close",{xmlns:t.NS.FRAMING});this._conn.xmlOutput(s);var i=t.serialize(s);this._conn.rawOutput(i);try{this.socket.send(i)}catch(e){t.info("Couldn't send <close /> tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){t.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(t){return"<wrapper>"+t+"</wrapper>"},_closeSocket:function(){if(this.socket)try{this.socket.close()}catch(t){}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(){this._conn.connected&&!this._conn.disconnecting?(t.error("Websocket closed unexcectedly"),this._conn._doDisconnect()):t.info("Websocket closed")},_no_auth_received:function(e){t.error("Server did not send any auth methods"),this._conn._changeConnectStatus(t.Status.CONNFAIL,"Server did not send any auth methods"),e&&(e=e.bind(this._conn))(),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(e){t.error("Websocket error "+e),this._conn._changeConnectStatus(t.Status.CONNFAIL,"The WebSocket connection could not be established was disconnected."),this._disconnect()},_onIdle:function(){var e=this._conn._data;if(e.length>0&&!this._conn.paused){for(var n=0;n<e.length;n++){var s,i;if(null!==e[n])s="restart"===e[n]?this._buildStream().tree():e[n],i=t.serialize(s),this._conn.xmlOutput(s),this._conn.rawOutput(i),this.socket.send(i)}this._conn._data=[]}},_onMessage:function(e){var n,s,i='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(e.data===i)return this._conn.rawInput(i),this._conn.xmlInput(e),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===e.data.search("<open ")){if(n=(new DOMParser).parseFromString(e.data,"text/xml").documentElement,!this._handleStreamStart(n))return}else s=this._streamWrap(e.data),n=(new DOMParser).parseFromString(s,"text/xml").documentElement;return this._check_streamerror(n,t.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===n.firstChild.nodeName&&"unavailable"===n.firstChild.getAttribute("type")?(this._conn.xmlInput(n),void this._conn.rawInput(t.serialize(n))):void this._conn._dataRecv(n,e.data)},_onOpen:function(){t.info("Websocket open");var e=this._buildStream();this._conn.xmlOutput(e.tree());var n=t.serialize(e);this._conn.rawOutput(n),this.socket.send(n)},_reqToData:function(t){return t},_send:function(){this._conn.flush()},_sendRestart:function(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}},t})),"function"==typeof define&&define.amd&&define("strophe",["strophe-core","strophe-bosh","strophe-websocket"],(function(t){return t})),t){if("function"!=typeof define||!define.amd)return t(Strophe,$build,$msg,$iq,$pres);var s=t;require(["strophe"],(function(t){s(t.Strophe,t.$build,t.$msg,t.$iq,t.$pres)}))}}((function(t,e,n,s,i){window.Strophe=t,window.$build=e,window.$msg=n,window.$iq=s,window.$pres=i})); 8//# sourceMappingURL=/sm/f639e21f90696805e92e8d51a11f8d74ddfc1abf17435052bc8eba79394c510c.map