c3d2-web/content/static/candy/libs.min.js

3 lines
78 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(a){return function(a,b){"function"==typeof define&&define.amd?define("strophe-base64",function(){return b()}):a.Base64=b()}(this,function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b={encode:function(b){var c,d,e,f,g,h,i,j="",k=0;do c=b.charCodeAt(k++),d=b.charCodeAt(k++),e=b.charCodeAt(k++),f=c>>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?(g=(3&c)<<4,h=i=64):isNaN(e)&&(i=64),j=j+a.charAt(f)+a.charAt(g)+a.charAt(h)+a.charAt(i);while(k<b.length);return j},decode:function(b){var c,d,e,f,g,h,i,j="",k=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do f=a.indexOf(b.charAt(k++)),g=a.indexOf(b.charAt(k++)),h=a.indexOf(b.charAt(k++)),i=a.indexOf(b.charAt(k++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!=h&&(j+=String.fromCharCode(d)),64!=i&&(j+=String.fromCharCode(e));while(k<b.length);return j}};return b}),function(a,b){"function"==typeof define&&define.amd?define("strophe-sha1",function(){return b()}):a.SHA1=b()}(this,function(){function a(a,d){a[d>>5]|=128<<24-d%32,a[(d+64>>9<<4)+15]=d;var g,h,i,j,k,l,m,n,o=new Array(80),p=1732584193,q=-271733879,r=-1732584194,s=271733878,t=-1009589776;for(g=0;g<a.length;g+=16){for(j=p,k=q,l=r,m=s,n=t,h=0;80>h;h++)16>h?o[h]=a[g+h]:o[h]=f(o[h-3]^o[h-8]^o[h-14]^o[h-16],1),i=e(e(f(p,5),b(h,q,r,s)),e(e(t,o[h]),c(h))),t=s,s=r,r=f(q,30),q=p,p=i;p=e(p,j),q=e(q,k),r=e(r,l),s=e(s,m),t=e(t,n)}return[p,q,r,s,t]}function b(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d}function c(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function d(b,c){var d=g(b);d.length>16&&(d=a(d,8*b.length));for(var e=new Array(16),f=new Array(16),h=0;16>h;h++)e[h]=909522486^d[h],f[h]=1549556828^d[h];var i=a(e.concat(g(c)),512+8*c.length);return a(f.concat(i),672)}function e(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function f(a,b){return a<<b|a>>>32-b}function g(a){for(var b=[],c=255,d=0;d<8*a.length;d+=8)b[d>>5]|=(a.charCodeAt(d/8)&c)<<24-d%32;return b}function h(a){for(var b="",c=255,d=0;d<32*a.length;d+=8)b+=String.fromCharCode(a[d>>5]>>>24-d%32&c);return b}function i(a){for(var b,c,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="",f=0;f<4*a.length;f+=3)for(b=(a[f>>2]>>8*(3-f%4)&255)<<16|(a[f+1>>2]>>8*(3-(f+1)%4)&255)<<8|a[f+2>>2]>>8*(3-(f+2)%4)&255,c=0;4>c;c++)e+=8*f+6*c>32*a.length?"=":d.charAt(b>>6*(3-c)&63);return e}return{b64_hmac_sha1:function(a,b){return i(d(a,b))},b64_sha1:function(b){return i(a(g(b),8*b.length))},binb2str:h,core_hmac_sha1:d,str_hmac_sha1:function(a,b){return h(d(a,b))},str_sha1:function(b){return h(a(g(b),8*b.length))}}}),function(a,b){"function"==typeof define&&define.amd?define("strophe-md5",function(){return b()}):a.MD5=b()}(this,function(a){var b=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},c=function(a,b){return a<<b|a>>>32-b},d=function(a){for(var b=[],c=0;c<8*a.length;c+=8)b[c>>5]|=(255&a.charCodeAt(c/8))<<c%32;return b},e=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>c%32&255);return b},f=function(a){for(var b="0123456789abcdef",c="",d=0;d<4*a.length;d++)c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},g=function(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)},h=function(a,b,c,d,e,f,h){return g(b&c|~b&d,a,b,e,f,h)},i=function(a,b,c,d,e,f,h){return g(b&d|c&~d,a,b,e,f,h)},j=function(a,b,c,d,e,f,h){return g(b^c^d,a,b,e,f,h)},k=function(a,b,c,d,e,f,h){return g(c^(b|~d),a,b,e,f,h)},l=function(a,c){a[c>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var d,e,f,g,l=1732584193,m=-271733879,n=-1732584194,o=271733878,p=0;p<a.length;p+=16)d=l,e=m,f=n,g=o,l=h(l,m,n,o,a[p+0],7,-680876936),o=h(o,l,m,n,a[p+1],12,-389564586),n=h(n,o,l,m,a[p+2],17,606105819),m=h(m,n,o,l,a[p+3],22,-1044525330),l=h(l,m,n,o,a[p+4],7,-176418897),o=h(o,l,m,n,a[p+5],12,1200080426),n=h(n,o,l,m,a[p+6],17,-1473231341),m=h(m,n,o,l,a[p+7],22,-45705983),l=h(l,m,n,o,a[p+8],7,1770035416),o=h(o,l,m,n,a[p+9],12,-1958414417),n=h(n,o,l,m,a[p+10],17,-42063),m=h(m,n,o,l,a[p+11],22,-1990404162),l=h(l,m,n,o,a[p+12],7,1804603682),o=h(o,l,m,n,a[p+13],12,-40341101),n=h(n,o,l,m,a[p+14],17,-1502002290),m=h(m,n,o,l,a[p+15],22,1236535329),l=i(l,m,n,o,a[p+1],5,-165796510),o=i(o,l,m,n,a[p+6],9,-1069501632),n=i(n,o,l,m,a[p+11],14,643717713),m=i(m,n,o,l,a[p+0],20,-373897302),l=i(l,m,n,o,a[p+5],5,-701558691),o=i(o,l,m,n,a[p+10],9,38016083),n=i(n,o,l,m,a[p+15],14,-660478335),m=i(m,n,o,l,a[p+4],20,-405537848),l=i(l,m,n,o,a[p+9],5,568446438),o=i(o,l,m,n,a[p+14],9,-1019803690),n=i(n,o,l,m,a[p+3],14,-187363961),m=i(m,n,o,l,a[p+8],20,1163531501),l=i(l,m,n,o,a[p+13],5,-1444681467),o=i(o,l,m,n,a[p+2],9,-51403784),n=i(n,o,l,m,a[p+7],14,1735328473),m=i(m,n,o,l,a[p+12],20,-1926607734),l=j(l,m,n,o,a[p+5],4,-378558),o=j(o,l,m,n,a[p+8],11,-2022574463),n=j(n,o,l,m,a[p+11],16,1839030562),m=j(m,n,o,l,a[p+14],23,-35309556),l=j(l,m,n,o,a[p+1],4,-1530992060),o=j(o,l,m,n,a[p+4],11,1272893353),n=j(n,o,l,m,a[p+7],16,-155497632),m=j(m,n,o,l,a[p+10],23,-1094730640),l=j(l,m,n,o,a[p+13],4,681279174),o=j(o,l,m,n,a[p+0],11,-358537222),n=j(n,o,l,m,a[p+3],16,-722521979),m=j(m,n,o,l,a[p+6],23,76029189),l=j(l,m,n,o,a[p+9],4,-640364487),o=j(o,l,m,n,a[p+12],11,-421815835),n=j(n,o,l,m,a[p+15],16,530742520),m=j(m,n,o,l,a[p+2],23,-995338651),l=k(l,m,n,o,a[p+0],6,-198630844),o=k(o,l,m,n,a[p+7],10,1126891415),n=k(n,o,l,m,a[p+14],15,-1416354905),m=k(m,n,o,l,a[p+5],21,-57434055),l=k(l,m,n,o,a[p+12],6,1700485571),o=k(o,l,m,n,a[p+3],10,-1894986606),n=k(n,o,l,m,a[p+10],15,-1051523),m=k(m,n,o,l,a[p+1],21,-2054922799),l=k(l,m,n,o,a[p+8],6,1873313359),o=k(o,l,m,n,a[p+15],10,-30611744),n=k(n,o,l,m,a[p+6],15,-1560198380),m=k(m,n,o,l,a[p+13],21,1309151649),l=k(l,m,n,o,a[p+4],6,-145523070),o=k(o,l,m,n,a[p+11],10,-1120210379),n=k(n,o,l,m,a[p+2],15,718787259),m=k(m,n,o,l,a[p+9],21,-343485551),l=b(l,d),m=b(m,e),n=b(n,f),o=b(o,g);return[l,m,n,o]},m={hexdigest:function(a){return f(l(d(a),8*a.length))},hash:function(a){return e(l(d(a),8*a.length))}};return m}),Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=Array.prototype.slice,d=Array.prototype.concat,e=c.call(arguments,1);return function(){return b.apply(a?a:this,d.call(e,c.call(arguments,0)))}}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),function(a,b){if("function"==typeof define&&define.amd)define("strophe-core",["strophe-sha1","strophe-base64","strophe-md5","strophe-polyfill"],function(){return b.apply(this,arguments)});else{var c=b(a.SHA1,a.Base64,a.MD5);window.Strophe=c.Strophe,window.$build=c.$build,window.$iq=c.$iq,window.$msg=c.$msg,window.$pres=c.$pres,window.SHA1=c.SHA1,window.Base64=c.Base64,window.MD5=c.MD5,window.b64_hmac_sha1=c.SHA1.b64_hmac_sha1,window.b64_sha1=c.SHA1.b64_sha1,window.str_hmac_sha1=c.SHA1.str_hmac_sha1,window.str_sha1=c.SHA1.str_sha1}}(this,function(a,b,c){function d(a,b){return new h.Builder(a,b)}function e(a){return new h.Builder("message",a)}function f(a){return new h.Builder("iq",a)}function g(a){return new h.Builder("presence",a)}var h;return h={VERSION:"1.2.2",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(a){for(var b=0;b<h.XHTML.tags.length;b++)if(a==h.XHTML.tags[b])return!0;return!1},validAttribute:function(a,b){if("undefined"!=typeof h.XHTML.attributes[a]&&h.XHTML.attributes[a].length>0)for(var c=0;c<h.XHTML.attributes[a].length;c++)if(b==h.XHTML.attributes[a][c])return!0;return!1},validCSS:function(a){for(var b=0;b<h.XHTML.css.length;b++)if(a==h.XHTML.css[b])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(a,b){h.NS[a]=b},forEachChild:function(a,b,c){var d,e;for(d=0;d<a.childNodes.length;d++)e=a.childNodes[d],e.nodeType!=h.ElementType.NORMAL||b&&!this.isTagEqual(e,b)||c(e)},isTagEqual:function(a,b){return a.tagName==b},_xmlGenerator:null,_makeGenerator:function(){var a;return void 0===document.implementation.createDocument||document.implementation.createDocument&&document.documentMode&&document.documentMode<10?(a=this._getIEXmlDom(),a.appendChild(a.createElement("strophe"))):a=document.implementation.createDocument("jabber:client","strophe",null),a},xmlGenerator:function(){return h._xmlGenerator||(h._xmlGenerator=h._makeGenerator()),h._xmlGenerator},_getIEXmlDom:function(){for(var a=null,b=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"],c=0;c<b.length&&null===a;c++)try{a=new ActiveXObject(b[c])}catch(d){a=null}return a},xmlElement:function(a){if(!a)return null;var b,c,d,e=h.xmlGenerator().createElement(a);for(b=1;b<arguments.length;b++)if(arguments[b])if("string"==typeof arguments[b]||"number"==typeof arguments[b])e.appendChild(h.xmlTextNode(arguments[b]));else if("object"==typeof arguments[b]&&"function"==typeof arguments[b].sort)for(c=0;c<arguments[b].length;c++)"object"==typeof arguments[b][c]&&"function"==typeof arguments[b][c].sort&&e.setAttribute(arguments[b][c][0],arguments[b][c][1]);else if("object"==typeof arguments[b])for(d in arguments[b])arguments[b].hasOwnProperty(d)&&e.setAttribute(d,arguments[b][d]);return e},xmlescape:function(a){return a=a.replace(/\&/g,"&amp;"),a=a.replace(/</g,"&lt;"),a=a.replace(/>/g,"&gt;"),a=a.replace(/'/g,"&apos;"),a=a.replace(/"/g,"&quot;")},xmlunescape:function(a){return a=a.replace(/\&amp;/g,"&"),a=a.replace(/&lt;/g,"<"),a=a.replace(/&gt;/g,">"),a=a.replace(/&apos;/g,"'"),a=a.replace(/&quot;/g,'"')},xmlTextNode:function(a){return h.xmlGenerator().createTextNode(a)},xmlHtmlNode:function(a){var b;if(window.DOMParser){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a);return b},getText:function(a){if(!a)return null;var b="";0===a.childNodes.length&&a.nodeType==h.ElementType.TEXT&&(b+=a.nodeValue);for(var c=0;c<a.childNodes.length;c++)a.childNodes[c].nodeType==h.ElementType.TEXT&&(b+=a.childNodes[c].nodeValue);return h.xmlescape(b)},copyElement:function(a){var b,c;if(a.nodeType==h.ElementType.NORMAL){for(c=h.xmlElement(a.tagName),b=0;b<a.attributes.length;b++)c.setAttribute(a.attributes[b].nodeName,a.attributes[b].value);for(b=0;b<a.childNodes.length;b++)c.appendChild(h.copyElement(a.childNodes[b]))}else a.nodeType==h.ElementType.TEXT&&(c=h.xmlGenerator().createTextNode(a.nodeValue));return c},createHtml:function(a){var b,c,d,e,f,g,i,j,k,l,m;if(a.nodeType==h.ElementType.NORMAL)if(e=a.nodeName,h.XHTML.validTag(e))try{for(c=h.xmlElement(e),b=0;b<h.XHTML.attributes[e].length;b++)if(f=h.XHTML.attributes[e][b],g=a.getAttribute(f),"undefined"!=typeof g&&null!==g&&""!==g&&g!==!1&&0!==g)if("style"==f&&"object"==typeof g&&"undefined"!=typeof g.cssText&&(g=g.cssText),"style"==f){for(i=[],j=g.split(";"),d=0;d<j.length;d++)k=j[d].split(":"),l=k[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase(),h.XHTML.validCSS(l)&&(m=k[1].replace(/^\s*/,"").replace(/\s*$/,""),i.push(l+": "+m));i.length>0&&(g=i.join("; "),c.setAttribute(f,g))}else c.setAttribute(f,g);for(b=0;b<a.childNodes.length;b++)c.appendChild(h.createHtml(a.childNodes[b]))}catch(n){c=h.xmlTextNode("")}else for(c=h.xmlGenerator().createDocumentFragment(),b=0;b<a.childNodes.length;b++)c.appendChild(h.createHtml(a.childNodes[b]));else if(a.nodeType==h.ElementType.FRAGMENT)for(c=h.xmlGenerator().createDocumentFragment(),b=0;b<a.childNodes.length;b++)c.appendChild(h.createHtml(a.childNodes[b]));else a.nodeType==h.ElementType.TEXT&&(c=h.xmlTextNode(a.nodeValue));return c},escapeNode:function(a){return"string"!=typeof a?a:a.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(a){return"string"!=typeof a?a:a.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(a){return a.indexOf("@")<0?null:a.split("@")[0]},getDomainFromJid:function(a){var b=h.getBareJidFromJid(a);if(b.indexOf("@")<0)return b;var c=b.split("@");return c.splice(0,1),c.join("@")},getResourceFromJid:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),b.join("/"))},getBareJidFromJid:function(a){return a?a.split("/")[0]:null},log:function(a,b){},debug:function(a){this.log(this.LogLevel.DEBUG,a)},info:function(a){this.log(this.LogLevel.INFO,a)},warn:function(a){this.log(this.LogLevel.WARN,a)},error:function(a){this.log(this.LogLevel.ERROR,a)},fatal:function(a){this.log(this.LogLevel.FATAL,a)},serialize:function(a){var b;if(!a)return null;"function"==typeof a.tree&&(a=a.tree());var c,d,e=a.nodeName;for(a.getAttribute("_realname")&&(e=a.getAttribute("_realname")),b="<"+e,c=0;c<a.attributes.length;c++)"_realname"!=a.attributes[c].nodeName&&(b+=" "+a.attributes[c].nodeName+"='"+a.attributes[c].value.replace(/&/g,"&amp;").replace(/\'/g,"&apos;").replace(/>/g,"&gt;").replace(/</g,"&lt;")+"'");if(a.childNodes.length>0){for(b+=">",c=0;c<a.childNodes.length;c++)switch(d=a.childNodes[c],d.nodeType){case h.ElementType.NORMAL:b+=h.serialize(d);break;case h.ElementType.TEXT:b+=h.xmlescape(d.nodeValue);break;case h.ElementType.CDATA:b+="<![CDATA["+d.nodeValue+"]]>"}b+="</"+e+">"}else b+="/>";return b},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(a,b){h._connectionPlugins[a]=b}},h.Builder=function(a,b){("presence"==a||"message"==a||"iq"==a)&&(b&&!b.xmlns?b.xmlns=h.NS.CLIENT:b||(b={xmlns:h.NS.CLIENT})),this.nodeTree=h.xmlElement(a,b),this.node=this.nodeTree},h.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return h.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},attrs:function(a){for(var b in a)a.hasOwnProperty(b)&&this.node.setAttribute(b,a[b]);return this},c:function(a,b,c){var d=h.xmlElement(a,b,c);return this.node.appendChild(d),c||(this.node=d),this},cnode:function(a){var b,c=h.xmlGenerator();try{b=void 0!==c.importNode}catch(d){b=!1}var e=b?c.importNode(a,!0):h.copyElement(a);return this.node.appendChild(e),this.node=e,this},t:function(a){var b=h.xmlTextNode(a);return this.node.appendChild(b),this},h:function(a){var b=document.createElement("body");b.innerHTML=a;for(var c=h.createHtml(b);c.childNodes.length>0;)this.node.appendChild(c.childNodes[0]);return this}},h.Handler=function(a,b,c,d,e,f,g){this.handler=a,this.ns=b,this.name=c,this.type=d,this.id=e,this.options=g||{matchBare:!1},this.options.matchBare||(this.options.matchBare=!1),this.options.matchBare?this.from=f?h.getBareJidFromJid(f):null:this.from=f,this.user=!0},h.Handler.prototype={isMatch:function(a){var b,c=null;if(c=this.options.matchBare?h.getBareJidFromJid(a.getAttribute("from")):a.getAttribute("from"),b=!1,this.ns){var d=this;h.forEachChild(a,null,function(a){a.getAttribute("xmlns")==d.ns&&(b=!0)}),b=b||a.getAttribute("xmlns")==this.ns}else b=!0;var e=a.getAttribute("type");return!b||this.name&&!h.isTagEqual(a,this.name)||this.type&&(Array.isArray(this.type)?-1==this.type.indexOf(e):e!=this.type)||this.id&&a.getAttribute("id")!=this.id||this.from&&c!=this.from?!1:!0},run:function(a){var b=null;try{b=this.handler(a)}catch(c){throw c.sourceURL?h.fatal("error: "+this.handler+" "+c.sourceURL+":"+c.line+" - "+c.name+": "+c.message):c.fileName?("undefined"!=typeof console&&(console.trace(),console.error(this.handler," - error - ",c,c.message)),h.fatal("error: "+this.handler+" "+c.fileName+":"+c.lineNumber+" - "+c.name+": "+c.message)):h.fatal("error: "+c.message+"\n"+c.stack),c}return b},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},h.TimedHandler=function(a,b){this.period=a,this.handler=b,this.lastCalled=(new Date).getTime(),this.user=!0},h.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+")}"}},h.Connection=function(a,b){this.service=a,this.options=b||{};var c=this.options.protocol||"";0===a.indexOf("ws:")||0===a.indexOf("wss:")||0===c.indexOf("ws")?this._proto=new h.Websocket(this):this._proto=new h.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.do_authentication=!0,this.authenticated=!1,this.disconnecting=!1,this.connected=!1,this.paused=!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);for(var d in h._connectionPlugins)if(h._connectionPlugins.hasOwnProperty(d)){var e=h._connectionPlugins[d],f=function(){};f.prototype=e,this[d]=new f,this[d].init(this)}},h.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.disconnecting=!1,this.connected=!1,this._data=[],this._requests=[],this._uniqueId=0},pause:function(){this.paused=!0},resume:function(){this.paused=!1},getUniqueId:function(a){return"string"==typeof a||"number"==typeof a?++this._uniqueId+":"+a:++this._uniqueId+""},connect:function(a,b,c,d,e,f,g){this.jid=a,this.authzid=h.getBareJidFromJid(this.jid),this.authcid=g||h.getNodeFromJid(this.jid),this.pass=b,this.servtype="xmpp",this.connect_callback=c,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.domain=h.getDomainFromJid(this.jid),this._changeConnectStatus(h.Status.CONNECTING,null),this._proto._connect(d,e,f)},attach:function(a,b,c,d,e,f,g){this._proto._attach(a,b,c,d,e,f,g)},xmlInput:function(a){},xmlOutput:function(a){},rawInput:function(a){},rawOutput:function(a){},send:function(a){if(null!==a){if("function"==typeof a.sort)for(var b=0;b<a.length;b++)this._queueData(a[b]);else this._queueData("function"==typeof a.tree?a.tree():a);this._proto._send()}},flush:function(){clearTimeout(this._idleTimeout),this._onIdle()},sendIQ:function(a,b,c,d){var e=null,f=this;"function"==typeof a.tree&&(a=a.tree());var g=a.getAttribute("id");g||(g=this.getUniqueId("sendIQ"),a.setAttribute("id",g));var i=a.getAttribute("to"),j=this.jid,k=this.addHandler(function(a){e&&f.deleteTimedHandler(e);var d=!1,g=a.getAttribute("from");if((g===i||null===i&&(g===h.getBareJidFromJid(j)||g===h.getDomainFromJid(j)||g===j))&&(d=!0),!d)throw{name:"StropheError",message:"Got answer to IQ from wrong jid:"+g+"\nExpected jid: "+i};var k=a.getAttribute("type");if("result"==k)b&&b(a);else{if("error"!=k)throw{name:"StropheError",message:"Got bad IQ type of "+k};c&&c(a)}},null,"iq",["error","result"],g);return d&&(e=this.addTimedHandler(d,function(){return f.deleteHandler(k),c&&c(null),!1})),this.send(a),g},_queueData:function(a){if(null===a||!a.tagName||!a.childNodes)throw{name:"StropheError",message:"Cannot queue non-DOMElement."};this._data.push(a)},_sendRestart:function(){this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout(this._onIdle.bind(this),100)},addTimedHandler:function(a,b){var c=new h.TimedHandler(a,b);return this.addTimeds.push(c),c},deleteTimedHandler:function(a){this.removeTimeds.push(a)},addHandler:function(a,b,c,d,e,f,g){var i=new h.Handler(a,b,c,d,e,f,g);return this.addHandlers.push(i),i},deleteHandler:function(a){this.removeHandlers.push(a);var b=this.addHandlers.indexOf(a);b>=0&&this.addHandlers.splice(b,1)},disconnect:function(a){if(this._changeConnectStatus(h.Status.DISCONNECTING,a),h.info("Disconnect was called because: "+a),this.connected){var b=!1;this.disconnecting=!0,this.authenticated&&(b=g({xmlns:h.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(b)}else h.info("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests()},_changeConnectStatus:function(a,b){for(var c in h._connectionPlugins)if(h._connectionPlugins.hasOwnProperty(c)){var d=this[c];if(d.statusChanged)try{d.statusChanged(a,b)}catch(e){h.error(""+c+" plugin caused an exception changing status: "+e)}}if(this.connect_callback)try{this.connect_callback(a,b)}catch(f){h.error("User connection callback caused an exception: "+f)}},_doDisconnect:function(){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),h.info("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(h.Status.DISCONNECTED,null),this.connected=!1},_dataRecv:function(a,b){h.info("_dataRecv called");var c=this._proto._reqToData(a);if(null!==c){this.xmlInput!==h.Connection.prototype.xmlInput&&this.xmlInput(c.nodeName===this._proto.strip&&c.childNodes.length?c.childNodes[0]:c),this.rawInput!==h.Connection.prototype.rawInput&&this.rawInput(b?b:h.serialize(c));for(var d,e;this.removeHandlers.length>0;)e=this.removeHandlers.pop(),d=this.handlers.indexOf(e),d>=0&&this.handlers.splice(d,1);for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();var f,g,i=c.getAttribute("type");if(null!==i&&"terminate"==i){if(this.disconnecting)return;return f=c.getAttribute("condition"),g=c.getElementsByTagName("conflict"),null!==f?("remote-stream-error"==f&&g.length>0&&(f="conflict"),this._changeConnectStatus(h.Status.CONNFAIL,f)):this._changeConnectStatus(h.Status.CONNFAIL,"unknown"),void this._doDisconnect()}var j=this;h.forEachChild(c,null,function(a){var b,c;for(c=j.handlers,j.handlers=[],b=0;b<c.length;b++){var d=c[b];try{!d.isMatch(a)||!j.authenticated&&d.user?j.handlers.push(d):d.run(a)&&j.handlers.push(d)}catch(e){h.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}}})}},mechanisms:{},_connect_cb:function(a,b,c){h.info("_connect_cb was called"),this.connected=!0;var d=this._proto._reqToData(a);if(d){this.xmlInput!==h.Connection.prototype.xmlInput&&this.xmlInput(d.nodeName===this._proto.strip&&d.childNodes.length?d.childNodes[0]:d),this.rawInput!==h.Connection.prototype.rawInput&&this.rawInput(c?c:h.serialize(d));var e=this._proto._connect_cb(d);if(e!==h.Status.CONNFAIL){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;var f,g,i=d.getElementsByTagNameNS(h.NS.STREAM,"features").length>0,j=d.getElementsByTagName("mechanism"),k=[],l=!1;if(!i)return void this._proto._no_auth_received(b);if(j.length>0)for(f=0;f<j.length;f++)g=h.getText(j[f]),this.mechanisms[g]&&k.push(this.mechanisms[g]);return this._authentication.legacy_auth=d.getElementsByTagName("auth").length>0,(l=this._authentication.legacy_auth||k.length>0)?void(this.do_authentication!==!1&&this.authenticate(k)):void this._proto._no_auth_received(b)}}},authenticate:function(a){var c;for(c=0;c<a.length-1;++c){for(var e=c,g=c+1;g<a.length;++g)a[g].prototype.priority>a[e].prototype.priority&&(e=g);if(e!=c){var i=a[c];a[c]=a[e],a[e]=i}}var j=!1;for(c=0;c<a.length;++c)if(a[c].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 a[c],this._sasl_mechanism.onStart(this);var k=d("auth",{xmlns:h.NS.SASL,mechanism:this._sasl_mechanism.name});if(this._sasl_mechanism.isClientFirst){var l=this._sasl_mechanism.onChallenge(this,null);k.t(b.encode(l))}this.send(k.tree()),j=!0;break}j||(null===h.getNodeFromJid(this.jid)?(this._changeConnectStatus(h.Status.CONNFAIL,"x-strophe-bad-non-anon-jid"),this.disconnect("x-strophe-bad-non-anon-jid")):(this._changeConnectStatus(h.Status.AUTHENTICATING,null),this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1"),this.send(f({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:h.NS.AUTH}).c("username",{}).t(h.getNodeFromJid(this.jid)).tree())))},_sasl_challenge_cb:function(a){var c=b.decode(h.getText(a)),e=this._sasl_mechanism.onChallenge(this,c),f=d("response",{xmlns:h.NS.SASL});return""!==e&&f.t(b.encode(e)),this.send(f.tree()),!0},_auth1_cb:function(a){var b=f({type:"set",id:"_auth_2"}).c("query",{xmlns:h.NS.AUTH}).c("username",{}).t(h.getNodeFromJid(this.jid)).up().c("password").t(this.pass);return h.getResourceFromJid(this.jid)||(this.jid=h.getBareJidFromJid(this.jid)+"/strophe"),b.up().c("resource",{}).t(h.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(b.tree()),!1},_sasl_success_cb:function(a){if(this._sasl_data["server-signature"]){var c,d=b.decode(h.getText(a)),e=/([a-z]+)=([^,]+)(,|$)/,f=d.match(e);if("v"==f[1]&&(c=f[2]),c!=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)}h.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 g=[],i=function(a,b){for(;a.length;)this.deleteHandler(a.pop());return this._sasl_auth1_cb.bind(this)(b),!1};return g.push(this._addSysHandler(function(a){i.bind(this)(g,a)}.bind(this),null,"stream:features",null,null)),g.push(this._addSysHandler(function(a){i.bind(this)(g,a)}.bind(this),h.NS.STREAM,"features",null,null)),this._sendRestart(),!1},_sasl_auth1_cb:function(a){this.features=a;var b,c;for(b=0;b<a.childNodes.length;b++)c=a.childNodes[b],"bind"==c.nodeName&&(this.do_bind=!0),"session"==c.nodeName&&(this.do_session=!0);if(!this.do_bind)return this._changeConnectStatus(h.Status.AUTHFAIL,null),!1;this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var d=h.getResourceFromJid(this.jid);return this.send(d?f({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:h.NS.BIND}).c("resource",{}).t(d).tree():f({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:h.NS.BIND}).tree()),!1},_sasl_bind_cb:function(a){if("error"==a.getAttribute("type")){h.info("SASL binding failed.");var b,c=a.getElementsByTagName("conflict");return c.length>0&&(b="conflict"),this._changeConnectStatus(h.Status.AUTHFAIL,b),!1}var d,e=a.getElementsByTagName("bind");return e.length>0?(d=e[0].getElementsByTagName("jid"),void(d.length>0&&(this.jid=h.getText(d[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(f({type:"set",id:"_session_auth_2"}).c("session",{xmlns:h.NS.SESSION}).tree())):(this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null))))):(h.info("SASL binding failed."),this._changeConnectStatus(h.Status.AUTHFAIL,null),!1)},_sasl_session_cb:function(a){if("result"==a.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null);else if("error"==a.getAttribute("type"))return h.info("Session creation failed."),this._changeConnectStatus(h.Status.AUTHFAIL,null),!1;return!1},_sasl_failure_cb:function(a){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(h.Status.AUTHFAIL,null),!1},_auth2_cb:function(a){return"result"==a.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(h.Status.CONNECTED,null)):"error"==a.getAttribute("type")&&(this._changeConnectStatus(h.Status.AUTHFAIL,null),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(a,b){var c=new h.TimedHandler(a,b);return c.user=!1,this.addTimeds.push(c),c},_addSysHandler:function(a,b,c,d,e){var f=new h.Handler(a,b,c,d,e);return f.user=!1,this.addHandlers.push(f),f},_onDisconnectTimeout:function(){return h.info("_onDisconnectTimeout was called"),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1},_onIdle:function(){for(var a,b,c,d;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;)b=this.removeTimeds.pop(),a=this.timedHandlers.indexOf(b),a>=0&&this.timedHandlers.splice(a,1);var e=(new Date).getTime();for(d=[],a=0;a<this.timedHandlers.length;a++)b=this.timedHandlers[a],(this.authenticated||!b.user)&&(c=b.lastCalled+b.period,0>=c-e?b.run()&&d.push(b):d.push(b));this.timedHandlers=d,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(this._onIdle.bind(this),100))}},h.SASLMechanism=function(a,b,c){this.name=a,this.isClientFirst=b,this.priority=c},h.SASLMechanism.prototype={test:function(a){return!0},onStart:function(a){this._connection=a},onChallenge:function(a,b){throw new Error("You should implement challenge handling!")},onFailure:function(){this._connection=null},onSuccess:function(){this._connection=null}},h.SASLAnonymous=function(){},h.SASLAnonymous.prototype=new h.SASLMechanism("ANONYMOUS",!1,10),h.SASLAnonymous.test=function(a){return null===a.authcid},h.Connection.prototype.mechanisms[h.SASLAnonymous.prototype.name]=h.SASLAnonymous,h.SASLPlain=function(){},h.SASLPlain.prototype=new h.SASLMechanism("PLAIN",!0,20),h.SASLPlain.test=function(a){return null!==a.authcid},h.SASLPlain.prototype.onChallenge=function(a){var b=a.authzid;
return b+="\x00",b+=a.authcid,b+="\x00",b+=a.pass},h.Connection.prototype.mechanisms[h.SASLPlain.prototype.name]=h.SASLPlain,h.SASLSHA1=function(){},h.SASLSHA1.prototype=new h.SASLMechanism("SCRAM-SHA-1",!0,40),h.SASLSHA1.test=function(a){return null!==a.authcid},h.SASLSHA1.prototype.onChallenge=function(d,e,f){var g=f||c.hexdigest(1234567890*Math.random()),h="n="+d.authcid;return h+=",r=",h+=g,d._sasl_data.cnonce=g,d._sasl_data["client-first-message-bare"]=h,h="n,,"+h,this.onChallenge=function(c,d){for(var e,f,g,h,i,j,k,l,m,n,o,p="c=biws,",q=c._sasl_data["client-first-message-bare"]+","+d+",",r=c._sasl_data.cnonce,s=/([a-z]+)=([^,]+)(,|$)/;d.match(s);){var t=d.match(s);switch(d=d.replace(t[0],""),t[1]){case"r":e=t[2];break;case"s":f=t[2];break;case"i":g=t[2]}}if(e.substr(0,r.length)!==r)return c._sasl_data={},c._sasl_failure_cb();for(p+="r="+e,q+=p,f=b.decode(f),f+="\x00\x00\x00",h=j=a.core_hmac_sha1(c.pass,f),k=1;g>k;k++){for(i=a.core_hmac_sha1(c.pass,a.binb2str(j)),l=0;5>l;l++)h[l]^=i[l];j=i}for(h=a.binb2str(h),m=a.core_hmac_sha1(h,"Client Key"),n=a.str_hmac_sha1(h,"Server Key"),o=a.core_hmac_sha1(a.str_sha1(a.binb2str(m)),q),c._sasl_data["server-signature"]=a.b64_hmac_sha1(n,q),l=0;5>l;l++)m[l]^=o[l];return p+=",p="+b.encode(a.binb2str(m))}.bind(this),h},h.Connection.prototype.mechanisms[h.SASLSHA1.prototype.name]=h.SASLSHA1,h.SASLMD5=function(){},h.SASLMD5.prototype=new h.SASLMechanism("DIGEST-MD5",!1,30),h.SASLMD5.test=function(a){return null!==a.authcid},h.SASLMD5.prototype._quote=function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},h.SASLMD5.prototype.onChallenge=function(a,b,d){for(var e,f=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,g=d||c.hexdigest(""+1234567890*Math.random()),h="",i=null,j="",k="";b.match(f);)switch(e=b.match(f),b=b.replace(e[0],""),e[2]=e[2].replace(/^"(.+)"$/,"$1"),e[1]){case"realm":h=e[2];break;case"nonce":j=e[2];break;case"qop":k=e[2];break;case"host":i=e[2]}var l=a.servtype+"/"+a.domain;null!==i&&(l=l+"/"+i);var m=c.hash(a.authcid+":"+h+":"+this._connection.pass)+":"+j+":"+g,n="AUTHENTICATE:"+l,o="";return o+="charset=utf-8,",o+="username="+this._quote(a.authcid)+",",o+="realm="+this._quote(h)+",",o+="nonce="+this._quote(j)+",",o+="nc=00000001,",o+="cnonce="+this._quote(g)+",",o+="digest-uri="+this._quote(l)+",",o+="response="+c.hexdigest(c.hexdigest(m)+":"+j+":00000001:"+g+":auth:"+c.hexdigest(n))+",",o+="qop=auth",this.onChallenge=function(){return""}.bind(this),o},h.Connection.prototype.mechanisms[h.SASLMD5.prototype.name]=h.SASLMD5,{Strophe:h,$build:d,$msg:e,$iq:f,$pres:g,SHA1:a,Base64:b,MD5:c}}),function(a,b){return"function"==typeof define&&define.amd?void define("strophe-bosh",["strophe-core"],function(a){return b(a.Strophe,a.$build)}):b(Strophe,$build)}(this,function(a,b){return a.Request=function(b,c,d,e){this.id=++a._requestId,this.xmlData=b,this.data=a.serialize(b),this.origFunc=c,this.func=c,this.rid=d,this.date=NaN,this.sends=e||0,this.abort=!1,this.dead=null,this.age=function(){if(!this.date)return 0;var a=new Date;return(a-this.date)/1e3},this.timeDead=function(){if(!this.dead)return 0;var a=new Date;return(a-this.dead)/1e3},this.xhr=this._newXHR()},a.Request.prototype={getResponse:function(){var b=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(b=this.xhr.responseXML.documentElement,"parsererror"==b.tagName)throw a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)),"parsererror"}else this.xhr.responseText&&(a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)));return b},_newXHR:function(){var a=null;return window.XMLHttpRequest?(a=new XMLHttpRequest,a.overrideMimeType&&a.overrideMimeType("text/xml; charset=utf-8")):window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP")),a.onreadystatechange=this.func.bind(null,this),a}},a.Bosh=function(a){this._conn=a,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this._requests=[]},a.Bosh.prototype={strip:null,_buildBody:function(){var c=b("body",{rid:this.rid++,xmlns:a.NS.HTTPBIND});return null!==this.sid&&c.attrs({sid:this.sid}),c},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0},_connect:function(b,c,d){this.wait=b||this.wait,this.hold=c||this.hold,this.errors=0;var e=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":a.NS.BOSH});d&&e.attrs({route:d});var f=this._conn._connect_cb;this._requests.push(new a.Request(e.tree(),this._onRequestStateChange.bind(this,f.bind(this._conn)),e.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(b,c,d,e,f,g,h){this._conn.jid=b,this.sid=c,this.rid=d,this._conn.connect_callback=e,this._conn.domain=a.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=f||this.wait,this.hold=g||this.hold,this.window=h||this.window,this._conn._changeConnectStatus(a.Status.ATTACHED,null)},_connect_cb:function(b){var c,d,e=b.getAttribute("type");if(null!==e&&"terminate"==e)return a.error("BOSH-Connection failed: "+c),c=b.getAttribute("condition"),d=b.getElementsByTagName("conflict"),null!==c?("remote-stream-error"==c&&d.length>0&&(c="conflict"),this._conn._changeConnectStatus(a.Status.CONNFAIL,c)):this._conn._changeConnectStatus(a.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(),a.Status.CONNFAIL;this.sid||(this.sid=b.getAttribute("sid"));var f=b.getAttribute("requests");f&&(this.window=parseInt(f,10));var g=b.getAttribute("hold");g&&(this.hold=parseInt(g,10));var h=b.getAttribute("wait");h&&(this.wait=parseInt(h,10))},_disconnect:function(a){this._sendTerminate(a)},_doDisconnect:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random())},_emptyQueue:function(){return 0===this._requests.length},_hitError:function(b){this.errors++,a.warn("request errored, status: "+b+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()},_no_auth_received:function(b){b=b?b.bind(this._conn):this._conn._connect_cb.bind(this._conn);var c=this._buildBody();this._requests.push(new a.Request(c.tree(),this._onRequestStateChange.bind(this,b.bind(this._conn)),c.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout:function(){this._abortAllRequests()},_abortAllRequests:function(){for(var a;this._requests.length>0;)a=this._requests.pop(),a.abort=!0,a.xhr.abort(),a.xhr.onreadystatechange=function(){}},_onIdle:function(){var b=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===b.length&&!this._conn.disconnecting&&(a.info("no requests during idle cycle, sending blank request"),b.push(null)),!this._conn.paused){if(this._requests.length<2&&b.length>0){for(var c=this._buildBody(),d=0;d<b.length;d++)null!==b[d]&&("restart"===b[d]?c.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":a.NS.BOSH}):c.cnode(b[d]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new a.Request(c.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),c.tree().getAttribute("rid"))),this._throttledRequestHandler()}if(this._requests.length>0){var e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(a.TIMEOUT*this.wait)&&(a.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(a.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_onRequestStateChange:function(b,c){if(a.debug("request id "+c.id+"."+c.sends+" state changed to "+c.xhr.readyState),c.abort)return void(c.abort=!1);var d;if(4==c.xhr.readyState){d=0;try{d=c.xhr.status}catch(e){}if("undefined"==typeof d&&(d=0),this.disconnecting&&d>=400)return void this._hitError(d);var f=this._requests[0]==c,g=this._requests[1]==c;(d>0&&500>d||c.sends>5)&&(this._removeRequest(c),a.debug("request id "+c.id+" should now be removed")),200==d?((g||f&&this._requests.length>0&&this._requests[0].age()>Math.floor(a.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),a.debug("request id "+c.id+"."+c.sends+" got 200"),b(c),this.errors=0):(a.error("request id "+c.id+"."+c.sends+" error "+d+" happened"),(0===d||d>=400&&600>d||d>=12e3)&&(this._hitError(d),d>=400&&500>d&&(this._conn._changeConnectStatus(a.Status.DISCONNECTING,null),this._conn._doDisconnect()))),d>0&&500>d||c.sends>5||this._throttledRequestHandler()}},_processRequest:function(b){var c=this,d=this._requests[b],e=-1;try{4==d.xhr.readyState&&(e=d.xhr.status)}catch(f){a.error("caught an error in _requests["+b+"], reqStatus: "+e)}if("undefined"==typeof e&&(e=-1),d.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();var g=d.age(),h=!isNaN(g)&&g>Math.floor(a.TIMEOUT*this.wait),i=null!==d.dead&&d.timeDead()>Math.floor(a.SECONDARY_TIMEOUT*this.wait),j=4==d.xhr.readyState&&(1>e||e>=500);if((h||i||j)&&(i&&a.error("Request "+this._requests[b].id+" timed out (secondary), restarting"),d.abort=!0,d.xhr.abort(),d.xhr.onreadystatechange=function(){},this._requests[b]=new a.Request(d.xmlData,d.origFunc,d.rid,d.sends),d=this._requests[b]),0===d.xhr.readyState){a.debug("request id "+d.id+"."+d.sends+" posting");try{d.xhr.open("POST",this._conn.service,this._conn.options.sync?!1:!0),d.xhr.setRequestHeader("Content-Type","text/xml; charset=utf-8")}catch(k){return a.error("XHR open failed."),this._conn.connected||this._conn._changeConnectStatus(a.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var l=function(){if(d.date=new Date,c._conn.options.customHeaders){var a=c._conn.options.customHeaders;for(var b in a)a.hasOwnProperty(b)&&d.xhr.setRequestHeader(b,a[b])}d.xhr.send(d.data)};if(d.sends>1){var m=1e3*Math.min(Math.floor(a.TIMEOUT*this.wait),Math.pow(d.sends,3));setTimeout(l,m)}else l();d.sends++,this._conn.xmlOutput!==a.Connection.prototype.xmlOutput&&this._conn.xmlOutput(d.xmlData.nodeName===this.strip&&d.xmlData.childNodes.length?d.xmlData.childNodes[0]:d.xmlData),this._conn.rawOutput!==a.Connection.prototype.rawOutput&&this._conn.rawOutput(d.data)}else a.debug("_processRequest: "+(0===b?"first":"second")+" request has readyState of "+d.xhr.readyState)},_removeRequest:function(b){a.debug("removing request");var c;for(c=this._requests.length-1;c>=0;c--)b==this._requests[c]&&this._requests.splice(c,1);b.xhr.onreadystatechange=function(){},this._throttledRequestHandler()},_restartRequest:function(a){var b=this._requests[a];null===b.dead&&(b.dead=new Date),this._processRequest(a)},_reqToData:function(a){try{return a.getResponse()}catch(b){if("parsererror"!=b)throw b;this._conn.disconnect("strophe-parsererror")}},_sendTerminate:function(b){a.info("_sendTerminate was called");var c=this._buildBody().attrs({type:"terminate"});b&&c.cnode(b.tree());var d=new a.Request(c.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),c.tree().getAttribute("rid"));this._requests.push(d),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(){a.debug(this._requests?"_throttledRequestHandler called with "+this._requests.length+" requests":"_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))}},a}),function(a,b){return"function"==typeof define&&define.amd?void define("strophe-websocket",["strophe-core"],function(a){return b(a.Strophe,a.$build)}):b(Strophe,$build)}(this,function(a,b){return a.Websocket=function(a){this._conn=a,this.strip="wrapper";var b=a.service;if(0!==b.indexOf("ws:")&&0!==b.indexOf("wss:")){var c="";c+="ws"===a.options.protocol&&"https:"!==window.location.protocol?"ws":"wss",c+="://"+window.location.host,c+=0!==b.indexOf("/")?window.location.pathname+b:b,a.service=c}},a.Websocket.prototype={_buildStream:function(){return b("open",{xmlns:a.NS.FRAMING,to:this._conn.domain,version:"1.0"})},_check_streamerror:function(b,c){var d=b.getElementsByTagNameNS(a.NS.STREAM,"error");if(0===d.length)return!1;for(var e=d[0],f="",g="",h="urn:ietf:params:xml:ns:xmpp-streams",i=0;i<e.childNodes.length;i++){var j=e.childNodes[i];if(j.getAttribute("xmlns")!==h)break;"text"===j.nodeName?g=j.textContent:f=j.nodeName}var k="WebSocket stream error: ";return k+=f?f:"unknown",g&&(k+=" - "+f),a.error(k),this._conn._changeConnectStatus(c,f),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(b){var c=this._check_streamerror(b,a.Status.CONNFAIL);return c?a.Status.CONNFAIL:void 0},_handleStreamStart:function(b){var c=!1,d=b.getAttribute("xmlns");"string"!=typeof d?c="Missing xmlns in <open />":d!==a.NS.FRAMING&&(c="Wrong xmlns in <open />: "+d);var e=b.getAttribute("version");return"string"!=typeof e?c="Missing version in <open />":"1.0"!==e&&(c="Wrong version in <open />: "+e),c?(this._conn._changeConnectStatus(a.Status.CONNFAIL,c),this._conn._doDisconnect(),!1):!0},_connect_cb_wrapper:function(b){if(0===b.data.indexOf("<open ")||0===b.data.indexOf("<?xml")){var c=b.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===c)return;var d=(new DOMParser).parseFromString(c,"text/xml").documentElement;this._conn.xmlInput(d),this._conn.rawInput(b.data),this._handleStreamStart(d)&&this._connect_cb(d)}else if(0===b.data.indexOf("<close ")){this._conn.rawInput(b.data),this._conn.xmlInput(b);var e=b.getAttribute("see-other-uri");e?(this._conn._changeConnectStatus(a.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=e,this._connect()):(this._conn._changeConnectStatus(a.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect())}else{var f=this._streamWrap(b.data),g=(new DOMParser).parseFromString(f,"text/xml").documentElement;this.socket.onmessage=this._onMessage.bind(this),this._conn._connect_cb(g,null,b.data)}},_disconnect:function(c){if(this.socket&&this.socket.readyState!==WebSocket.CLOSED){c&&this._conn.send(c);var d=b("close",{xmlns:a.NS.FRAMING});this._conn.xmlOutput(d);var e=a.serialize(d);this._conn.rawOutput(e);try{this.socket.send(e)}catch(f){a.info("Couldn't send <close /> tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){a.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(a){return"<wrapper>"+a+"</wrapper>"},_closeSocket:function(){if(this.socket)try{this.socket.close()}catch(a){}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(){this._conn.connected&&!this._conn.disconnecting?(a.error("Websocket closed unexcectedly"),this._conn._doDisconnect()):a.info("Websocket closed")},_no_auth_received:function(b){a.error("Server did not send any auth methods"),this._conn._changeConnectStatus(a.Status.CONNFAIL,"Server did not send any auth methods"),b&&(b=b.bind(this._conn))(),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(b){a.error("Websocket error "+b),this._conn._changeConnectStatus(a.Status.CONNFAIL,"The WebSocket connection could not be established was disconnected."),this._disconnect()},_onIdle:function(){var b=this._conn._data;if(b.length>0&&!this._conn.paused){for(var c=0;c<b.length;c++)if(null!==b[c]){var d,e;d="restart"===b[c]?this._buildStream().tree():b[c],e=a.serialize(d),this._conn.xmlOutput(d),this._conn.rawOutput(e),this.socket.send(e)}this._conn._data=[]}},_onMessage:function(b){var c,d,e='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(b.data===e)return this._conn.rawInput(e),this._conn.xmlInput(b),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===b.data.search("<open ")){if(c=(new DOMParser).parseFromString(b.data,"text/xml").documentElement,!this._handleStreamStart(c))return}else d=this._streamWrap(b.data),c=(new DOMParser).parseFromString(d,"text/xml").documentElement;return this._check_streamerror(c,a.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===c.firstChild.nodeName&&"unavailable"===c.firstChild.getAttribute("type")?(this._conn.xmlInput(c),void this._conn.rawInput(a.serialize(c))):void this._conn._dataRecv(c,b.data)},_onOpen:function(){a.info("Websocket open");var b=this._buildStream();this._conn.xmlOutput(b.tree());var c=a.serialize(b);this._conn.rawOutput(c),this.socket.send(c)},_reqToData:function(a){return a},_send:function(){this._conn.flush()},_sendRestart:function(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}},a}),a?a(Strophe,$build,$msg,$iq,$pres):void 0}(function(a,b,c,d,e){window.Strophe=a,window.$build=b,window.$msg=c,window.$iq=d,window.$pres=e}),function(){var a,b,c,d={}.hasOwnProperty,e=function(a,b){return function(){return a.apply(b,arguments)}};Strophe.addConnectionPlugin("muc",{_connection:null,rooms:{},roomNames:[],init:function(a){return this._connection=a,this._muc_handler=null,Strophe.addNamespace("MUC_OWNER",Strophe.NS.MUC+"#owner"),Strophe.addNamespace("MUC_ADMIN",Strophe.NS.MUC+"#admin"),Strophe.addNamespace("MUC_USER",Strophe.NS.MUC+"#user"),Strophe.addNamespace("MUC_ROOMCONF",Strophe.NS.MUC+"#roomconfig"),Strophe.addNamespace("MUC_REGISTER","jabber:iq:register")},join:function(a,b,d,e,f,g,h,i){var j,k;return k=this.test_append_nick(a,b),j=$pres({from:this._connection.jid,to:k}).c("x",{xmlns:Strophe.NS.MUC}),null!=h&&(j=j.c("history",h).up()),null!=g&&j.cnode(Strophe.xmlElement("password",[],g)),null!=i&&j.up().cnode(i),null==this._muc_handler&&(this._muc_handler=this._connection.addHandler(function(b){return function(c){var d,e,f,g,h,i,j,k,l,m;if(d=c.getAttribute("from"),!d)return!0;if(h=d.split("/")[0],!b.rooms[h])return!0;if(a=b.rooms[h],f={},"message"===c.nodeName)f=a._message_handlers;else if("presence"===c.nodeName&&(k=c.getElementsByTagName("x"),k.length>0))for(l=0,m=k.length;m>l;l++)if(i=k[l],j=i.getAttribute("xmlns"),j&&j.match(Strophe.NS.MUC)){f=a._presence_handlers;break}for(g in f)e=f[g],e(c,a)||delete f[g];return!0}}(this))),this.rooms.hasOwnProperty(a)||(this.rooms[a]=new c(this,a,b,g),this.roomNames.push(a)),e&&this.rooms[a].addHandler("presence",e),d&&this.rooms[a].addHandler("message",d),f&&this.rooms[a].addHandler("roster",f),this._connection.send(j)},leave:function(a,b,c,d){var e,f,g,h;return e=this.roomNames.indexOf(a),delete this.rooms[a],e>=0&&(this.roomNames.splice(e,1),0===this.roomNames.length&&(this._connection.deleteHandler(this._muc_handler),this._muc_handler=null)),h=this.test_append_nick(a,b),g=this._connection.getUniqueId(),f=$pres({type:"unavailable",id:g,from:this._connection.jid,to:h}),null!=d&&f.c("status",d),null!=c&&this._connection.addHandler(c,null,"presence",null,g),this._connection.send(f),g},message:function(a,b,c,d,e,f){var g,h,i;return i=this.test_append_nick(a,b),e=e||(null!=b?"chat":"groupchat"),f=f||this._connection.getUniqueId(),g=$msg({to:i,from:this._connection.jid,type:e,id:f}).c("body").t(c),g.up(),null!=d&&(g.c("html",{xmlns:Strophe.NS.XHTML_IM}).c("body",{xmlns:Strophe.NS.XHTML}).h(d),0===g.node.childNodes.length?(h=g.node.parentNode,g.up().up(),g.node.removeChild(h)):g.up().up()),g.c("x",{xmlns:"jabber:x:event"}).c("composing"),this._connection.send(g),f},groupchat:function(a,b,c,d){return this.message(a,null,b,c,void 0,d)},invite:function(a,b,c){var d,e;return e=this._connection.getUniqueId(),d=$msg({from:this._connection.jid,to:a,id:e}).c("x",{xmlns:Strophe.NS.MUC_USER}).c("invite",{to:b}),null!=c&&d.c("reason",c),this._connection.send(d),e},multipleInvites:function(a,b,c){var d,e,f,g,h;for(e=this._connection.getUniqueId(),d=$msg({from:this._connection.jid,to:a,id:e}).c("x",{xmlns:Strophe.NS.MUC_USER}),g=0,h=b.length;h>g;g++)f=b[g],d.c("invite",{to:f}),null!=c&&(d.c("reason",c),d.up()),d.up();return this._connection.send(d),e},directInvite:function(a,b,c,d){var e,f,g;return g=this._connection.getUniqueId(),e={xmlns:"jabber:x:conference",jid:a},null!=c&&(e.reason=c),null!=d&&(e.password=d),f=$msg({from:this._connection.jid,to:b,id:g}).c("x",e),this._connection.send(f),g},queryOccupants:function(a,b,c){var d,e;return d={xmlns:Strophe.NS.DISCO_ITEMS},e=$iq({from:this._connection.jid,to:a,type:"get"}).c("query",d),this._connection.sendIQ(e,b,c)},configure:function(a,b,c){var d,e;return d=$iq({to:a,type:"get"}).c("query",{xmlns:Strophe.NS.MUC_OWNER}),e=d.tree(),this._connection.sendIQ(e,b,c)},cancelConfigure:function(a){var b,c;return b=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"cancel"}),c=b.tree(),this._connection.sendIQ(c)},saveConfiguration:function(a,b,c,d){var e,f,g,h,i;if(f=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_OWNER}),"undefined"!=typeof Form&&b instanceof Form)b.type="submit",f.cnode(b.toXML());else for(f.c("x",{xmlns:"jabber:x:data",type:"submit"}),h=0,i=b.length;i>h;h++)e=b[h],f.cnode(e).up();return g=f.tree(),this._connection.sendIQ(g,c,d)},createInstantRoom:function(a,b,c){var d;return d=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"submit"}),this._connection.sendIQ(d.tree(),b,c)},createConfiguredRoom:function(a,b,c,e){var f,g,h;g=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"submit"}),g.c("field",{"var":"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#roomconfig").up().up();for(f in b)d.call(b,f)&&(h=b[f],g.c("field",{"var":f}).c("value").t(h).up().up());return this._connection.sendIQ(g.tree(),c,e)},setTopic:function(a,b){var c;return c=$msg({to:a,from:this._connection.jid,type:"groupchat"}).c("subject",{xmlns:"jabber:client"}).t(b),this._connection.send(c.tree())},_modifyPrivilege:function(a,b,c,d,e){var f;return f=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_ADMIN}).cnode(b.node),null!=c&&f.c("reason",c),this._connection.sendIQ(f.tree(),d,e)},modifyRole:function(a,b,c,d,e,f){var g;return g=$build("item",{nick:b,role:c}),this._modifyPrivilege(a,g,d,e,f)},kick:function(a,b,c,d,e){return this.modifyRole(a,b,"none",c,d,e)},voice:function(a,b,c,d,e){return this.modifyRole(a,b,"participant",c,d,e)},mute:function(a,b,c,d,e){return this.modifyRole(a,b,"visitor",c,d,e)},op:function(a,b,c,d,e){return this.modifyRole(a,b,"moderator",c,d,e)},deop:function(a,b,c,d,e){return this.modifyRole(a,b,"participant",c,d,e)},modifyAffiliation:function(a,b,c,d,e,f){var g;return g=$build("item",{jid:b,affiliation:c}),this._modifyPrivilege(a,g,d,e,f)},ban:function(a,b,c,d,e){return this.modifyAffiliation(a,b,"outcast",c,d,e)},member:function(a,b,c,d,e){return this.modifyAffiliation(a,b,"member",c,d,e)},revoke:function(a,b,c,d,e){return this.modifyAffiliation(a,b,"none",c,d,e)},owner:function(a,b,c,d,e){return this.modifyAffiliation(a,b,"owner",c,d,e)},admin:function(a,b,c,d,e){return this.modifyAffiliation(a,b,"admin",c,d,e)},changeNick:function(a,b){var c,d;return d=this.test_append_nick(a,b),c=$pres({from:this._connection.jid,to:d,id:this._connection.getUniqueId()}),this._connection.send(c.tree())},setStatus:function(a,b,c,d){var e,f;return f=this.test_append_nick(a,b),e=$pres({from:this._connection.jid,to:f}),null!=c&&e.c("show",c).up(),null!=d&&e.c("status",d),this._connection.send(e.tree())},registrationRequest:function(a,b,c){var d;return d=$iq({to:a,from:this._connection.jid,type:"get"}).c("query",{xmlns:Strophe.NS.MUC_REGISTER}),this._connection.sendIQ(d,function(a){var c,d,e,f,g,h,i;for(d=a.getElementsByTagName("field"),g=d.length,f={required:[],optional:[]},h=0,i=d.length;i>h;h++)c=d[h],e={"var":c.getAttribute("var"),label:c.getAttribute("label"),type:c.getAttribute("type")},c.getElementsByTagName("required").length>0?f.required.push(e):f.optional.push(e);return b(f)},c)},submitRegistrationForm:function(a,b,c,d){var e,f,g;e=$iq({to:a,type:"set"}).c("query",{xmlns:Strophe.NS.MUC_REGISTER}),e.c("x",{xmlns:"jabber:x:data",type:"submit"}),e.c("field",{"var":"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#register").up().up();for(f in b)g=b[f],e.c("field",{"var":f}).c("value").t(g).up().up();return this._connection.sendIQ(e,c,d)},listRooms:function(a,b,c){var d;return d=$iq({to:a,from:this._connection.jid,type:"get"}).c("query",{xmlns:Strophe.NS.DISCO_ITEMS}),this._connection.sendIQ(d,b,c)},test_append_nick:function(a,b){var c,d;return d=Strophe.escapeNode(Strophe.getNodeFromJid(a)),c=Strophe.getDomainFromJid(a),d+"@"+c+(null!=b?"/"+b:"")}}),c=function(){function b(a,b,c,d){this.client=a,this.name=b,this.nick=c,this.password=d,this._roomRosterHandler=e(this._roomRosterHandler,this),this._addOccupant=e(this._addOccupant,this),this.roster={},this._message_handlers={},this._presence_handlers={},this._roster_handlers={},this._handler_ids=0,a.muc&&(this.client=a.muc),this.name=Strophe.getBareJidFromJid(b),this.addHandler("presence",this._roomRosterHandler)}return b.prototype.join=function(a,b,c){return this.client.join(this.name,this.nick,a,b,c,this.password)},b.prototype.leave=function(a,b){return this.client.leave(this.name,this.nick,a,b),delete this.client.rooms[this.name]},b.prototype.message=function(a,b,c,d){return this.client.message(this.name,a,b,c,d)},b.prototype.groupchat=function(a,b){return this.client.groupchat(this.name,a,b)},b.prototype.invite=function(a,b){return this.client.invite(this.name,a,b)},b.prototype.multipleInvites=function(a,b){return this.client.invite(this.name,a,b)},b.prototype.directInvite=function(a,b){return this.client.directInvite(this.name,a,b,this.password)},b.prototype.configure=function(a){return this.client.configure(this.name,a)},b.prototype.cancelConfigure=function(){return this.client.cancelConfigure(this.name)},b.prototype.saveConfiguration=function(a){return this.client.saveConfiguration(this.name,a)},b.prototype.queryOccupants=function(a,b){return this.client.queryOccupants(this.name,a,b)},b.prototype.setTopic=function(a){return this.client.setTopic(this.name,a)},b.prototype.modifyRole=function(a,b,c,d,e){return this.client.modifyRole(this.name,a,b,c,d,e)},b.prototype.kick=function(a,b,c,d){return this.client.kick(this.name,a,b,c,d)},b.prototype.voice=function(a,b,c,d){return this.client.voice(this.name,a,b,c,d)},b.prototype.mute=function(a,b,c,d){return this.client.mute(this.name,a,b,c,d)},b.prototype.op=function(a,b,c,d){return this.client.op(this.name,a,b,c,d)},b.prototype.deop=function(a,b,c,d){return this.client.deop(this.name,a,b,c,d)},b.prototype.modifyAffiliation=function(a,b,c,d,e){return this.client.modifyAffiliation(this.name,a,b,c,d,e)},b.prototype.ban=function(a,b,c,d){return this.client.ban(this.name,a,b,c,d)},b.prototype.member=function(a,b,c,d){return this.client.member(this.name,a,b,c,d)},b.prototype.revoke=function(a,b,c,d){return this.client.revoke(this.name,a,b,c,d)},b.prototype.owner=function(a,b,c,d){return this.client.owner(this.name,a,b,c,d)},b.prototype.admin=function(a,b,c,d){return this.client.admin(this.name,a,b,c,d)},b.prototype.changeNick=function(a){return this.nick=a,this.client.changeNick(this.name,a)},b.prototype.setStatus=function(a,b){return this.client.setStatus(this.name,this.nick,a,b)},b.prototype.addHandler=function(a,b){var c;switch(c=this._handler_ids++,a){case"presence":this._presence_handlers[c]=b;break;case"message":this._message_handlers[c]=b;break;case"roster":this._roster_handlers[c]=b;break;default:return this._handler_ids--,null}return c},b.prototype.removeHandler=function(a){return delete this._presence_handlers[a],delete this._message_handlers[a],delete this._roster_handlers[a]},b.prototype._addOccupant=function(b){var c;return c=new a(b,this),this.roster[c.nick]=c,c},b.prototype._roomRosterHandler=function(a){var c,d,e,f,g,h;switch(c=b._parsePresence(a),g=c.nick,f=c.newnick||null,c.type){case"error":return!0;case"unavailable":f&&(c.nick=f,this.roster[g]&&this.roster[f]&&(this.roster[g].update(this.roster[f]),this.roster[f]=this.roster[g]),this.roster[g]&&!this.roster[f]&&(this.roster[f]=this.roster[g].update(c))),delete this.roster[g];break;default:this.roster[g]?this.roster[g].update(c):this._addOccupant(c)}h=this._roster_handlers;for(e in h)d=h[e],d(this.roster,this)||delete this._roster_handlers[e];return!0},b._parsePresence=function(a){var b,c,d,e,f,g,h,i,j;for(d={},d.nick=Strophe.getResourceFromJid(a.getAttribute("from")),d.type=a.getAttribute("type"),d.states=[],i=a.childNodes,e=0,g=i.length;g>e;e++)switch(b=i[e],b.nodeName){case"status":d.status=b.textContent||null;break;case"show":d.show=b.textContent||null;break;case"x":if(b.getAttribute("xmlns")===Strophe.NS.MUC_USER)for(j=b.childNodes,f=0,h=j.length;h>f;f++)switch(c=j[f],c.nodeName){case"item":d.affiliation=c.getAttribute("affiliation"),d.role=c.getAttribute("role"),d.jid=c.getAttribute("jid"),d.newnick=c.getAttribute("nick");break;case"status":c.getAttribute("code")&&d.states.push(c.getAttribute("code"))}}return d},b}(),b=function(){function a(a){this.parse=e(this.parse,this),null!=a&&this.parse(a)}return a.prototype.parse=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;for(g=a.getElementsByTagName("query")[0].childNodes,this.identities=[],this.features=[],this.x=[],h=0,k=g.length;k>h;h++)switch(d=g[h],c=d.attributes,d.nodeName){case"identity":for(f={},i=0,l=c.length;l>i;i++)b=c[i],f[b.name]=b.textContent;this.identities.push(f);break;case"feature":this.features.push(d.getAttribute("var"));break;case"x":if("FORM_TYPE"===!d.childNodes[0].getAttribute("var")||"hidden"===!d.childNodes[0].getAttribute("type"))break;for(n=d.childNodes,j=0,m=n.length;m>j;j++)e=n[j],e.attributes.type||this.x.push({"var":e.getAttribute("var"),label:e.getAttribute("label")||"",value:e.firstChild.textContent||""})}return{identities:this.identities,features:this.features,x:this.x}},a}(),a=function(){function a(a,b){this.room=b,this.update=e(this.update,this),this.admin=e(this.admin,this),this.owner=e(this.owner,this),this.revoke=e(this.revoke,this),this.member=e(this.member,this),this.ban=e(this.ban,this),this.modifyAffiliation=e(this.modifyAffiliation,this),this.deop=e(this.deop,this),this.op=e(this.op,this),this.mute=e(this.mute,this),this.voice=e(this.voice,this),this.kick=e(this.kick,this),this.modifyRole=e(this.modifyRole,this),this.update(a)}return a.prototype.modifyRole=function(a,b,c,d){return this.room.modifyRole(this.nick,a,b,c,d)},a.prototype.kick=function(a,b,c){return this.room.kick(this.nick,a,b,c)},a.prototype.voice=function(a,b,c){return this.room.voice(this.nick,a,b,c)},a.prototype.mute=function(a,b,c){return this.room.mute(this.nick,a,b,c)},a.prototype.op=function(a,b,c){return this.room.op(this.nick,a,b,c)},a.prototype.deop=function(a,b,c){return this.room.deop(this.nick,a,b,c)},a.prototype.modifyAffiliation=function(a,b,c,d){return this.room.modifyAffiliation(this.jid,a,b,c,d)},a.prototype.ban=function(a,b,c){return this.room.ban(this.jid,a,b,c)},a.prototype.member=function(a,b,c){return this.room.member(this.jid,a,b,c)},a.prototype.revoke=function(a,b,c){return this.room.revoke(this.jid,a,b,c)},a.prototype.owner=function(a,b,c){return this.room.owner(this.jid,a,b,c)},a.prototype.admin=function(a,b,c){return this.room.admin(this.jid,a,b,c)},a.prototype.update=function(a){return this.nick=a.nick||null,this.affiliation=a.affiliation||null,this.role=a.role||null,this.jid=a.jid||null,this.status=a.status||null,this.show=a.show||null,
this},a}()}.call(this),Strophe.addConnectionPlugin("roster",{init:function(a){this._connection=a,this._callbacks=[],this._callbacks_request=[],items=[],ver=null;var b,c=this,d=a.connect,e=a.attach,f=function(d){if(d==Strophe.Status.ATTACHED||d==Strophe.Status.CONNECTED)try{a.addHandler(c._onReceivePresence.bind(c),null,"presence",null,null,null),a.addHandler(c._onReceiveIQ.bind(c),Strophe.NS.ROSTER,"iq","set",null,null)}catch(e){Strophe.error(e)}"function"==typeof b&&b.apply(this,arguments)};a.connect=function(c,e,g,h,i,j,k){b=g,"undefined"==typeof c&&(c=null),"undefined"==typeof e&&(e=null),g=f,d.apply(a,[c,e,g,h,i,j,k])},a.attach=function(c,d,g,h,i,j,k){b=h,"undefined"==typeof c&&(c=null),"undefined"==typeof d&&(d=null),"undefined"==typeof g&&(g=null),h=f,e.apply(a,[c,d,g,h,i,j,k])},Strophe.addNamespace("ROSTER_VER","urn:xmpp:features:rosterver"),Strophe.addNamespace("NICK","http://jabber.org/protocol/nick")},supportVersioning:function(){return this._connection.features&&this._connection.features.getElementsByTagName("ver").length>0},get:function(a,b,c){var d={xmlns:Strophe.NS.ROSTER};this.items=[],this.supportVersioning()&&(d.ver=b||"",this.items=c||[]);var e=$iq({type:"get",id:this._connection.getUniqueId("roster")}).c("query",d);return this._connection.sendIQ(e,this._onReceiveRosterSuccess.bind(this,a),this._onReceiveRosterError.bind(this,a))},registerCallback:function(a){this._callbacks.push(a)},registerRequestCallback:function(a){this._callbacks_request.push(a)},findItem:function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]&&this.items[b].jid==a)return this.items[b];return!1},removeItem:function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]&&this.items[b].jid==a)return this.items.splice(b,1),!0;return!1},subscribe:function(a,b,c){var d=$pres({to:a,type:"subscribe"});b&&""!==b&&d.c("status").t(b).up(),c&&""!==c&&d.c("nick",{xmlns:Strophe.NS.NICK}).t(c).up(),this._connection.send(d)},unsubscribe:function(a,b){var c=$pres({to:a,type:"unsubscribe"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},authorize:function(a,b){var c=$pres({to:a,type:"subscribed"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},unauthorize:function(a,b){var c=$pres({to:a,type:"unsubscribed"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},add:function(a,b,c,d){for(var e=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:a,name:b}),f=0;f<c.length;f++)e.c("group").t(c[f]).up();this._connection.sendIQ(e,d,d)},update:function(a,b,c,d){var e=this.findItem(a);if(!e)throw"item not found";for(var f=b||e.name,g=c||e.groups,h=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:e.jid,name:f}),i=0;i<g.length;i++)h.c("group").t(g[i]).up();return this._connection.sendIQ(h,d,d)},remove:function(a,b){var c=this.findItem(a);if(!c)throw"item not found";var d=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:c.jid,subscription:"remove"});this._connection.sendIQ(d,b,b)},_onReceiveRosterSuccess:function(a,b){this._updateItems(b),this._call_backs(this.items),"function"==typeof a&&a(this.items)},_onReceiveRosterError:function(a,b){a(this.items)},_onReceivePresence:function(a){var b=a.getAttribute("from"),c=Strophe.getBareJidFromJid(b),d=this.findItem(c),e=a.getAttribute("type");if(!d)return"subscribe"===e&&this._call_backs_request(c),!0;if("unavailable"==e)delete d.resources[Strophe.getResourceFromJid(b)];else{if(e)return!0;d.resources[Strophe.getResourceFromJid(b)]={show:0!==a.getElementsByTagName("show").length?Strophe.getText(a.getElementsByTagName("show")[0]):"",status:0!==a.getElementsByTagName("status").length?Strophe.getText(a.getElementsByTagName("status")[0]):"",priority:0!==a.getElementsByTagName("priority").length?Strophe.getText(a.getElementsByTagName("priority")[0]):""}}return this._call_backs(this.items,d),!0},_call_backs_request:function(a){for(var b=0;b<this._callbacks_request.length;b++)this._callbacks_request[b](a)},_call_backs:function(a,b,c){for(var d=0;d<this._callbacks.length;d++)this._callbacks[d](a,b,c)},_onReceiveIQ:function(a){var b=a.getAttribute("id"),c=a.getAttribute("from");if(c&&""!==c&&c!=this._connection.jid&&c!=Strophe.getBareJidFromJid(this._connection.jid))return!0;var d=$iq({type:"result",id:b,from:this._connection.jid});return this._connection.send(d),this._updateItems(a),!0},_updateItems:function(a){var b=a.getElementsByTagName("query");if(0!==b.length){this.ver=b.item(0).getAttribute("ver");var c=this;Strophe.forEachChild(b.item(0),"item",function(a){c._updateItem(a)})}},_updateItem:function(a){var b=a.getAttribute("jid"),c=a.getAttribute("name"),d=a.getAttribute("subscription"),e=a.getAttribute("ask"),f=[];Strophe.forEachChild(a,"group",function(a){f.push(Strophe.getText(a))});var g,h;if("remove"==d){var i=this.removeItem(b);return void(i&&this._call_backs(this.items,{jid:b,subscription:"remove"}))}g=this.findItem(b),g?(h={name:g.name,subscription:g.subscription,ask:g.ask,groups:g.groups},g.name=c,g.subscription=d,g.ask=e,g.groups=f):(g={name:c,jid:b,subscription:d,ask:e,groups:f,resources:{}},this.items.push(g)),this._call_backs(this.items,g,h)}}),Strophe.addConnectionPlugin("disco",{_connection:null,_identities:[],_features:[],_items:[],init:function(a){this._connection=a,this._identities=[],this._features=[],this._items=[],a.addHandler(this._onDiscoInfo.bind(this),Strophe.NS.DISCO_INFO,"iq","get",null,null),a.addHandler(this._onDiscoItems.bind(this),Strophe.NS.DISCO_ITEMS,"iq","get",null,null)},addIdentity:function(a,b,c,d){for(var e=0;e<this._identities.length;e++)if(this._identities[e].category==a&&this._identities[e].type==b&&this._identities[e].name==c&&this._identities[e].lang==d)return!1;return this._identities.push({category:a,type:b,name:c,lang:d}),!0},addFeature:function(a){for(var b=0;b<this._features.length;b++)if(this._features[b]==a)return!1;return this._features.push(a),!0},removeFeature:function(a){for(var b=0;b<this._features.length;b++)if(this._features[b]===a)return this._features.splice(b,1),!0;return!1},addItem:function(a,b,c,d){return c&&!d?!1:(this._items.push({jid:a,name:b,node:c,call_back:d}),!0)},info:function(a,b,c,d,e){var f={xmlns:Strophe.NS.DISCO_INFO};b&&(f.node=b);var g=$iq({from:this._connection.jid,to:a,type:"get"}).c("query",f);this._connection.sendIQ(g,c,d,e)},items:function(a,b,c,d,e){var f={xmlns:Strophe.NS.DISCO_ITEMS};b&&(f.node=b);var g=$iq({from:this._connection.jid,to:a,type:"get"}).c("query",f);this._connection.sendIQ(g,c,d,e)},_buildIQResult:function(a,b){var c=a.getAttribute("id"),d=a.getAttribute("from"),e=$iq({type:"result",id:c});return null!==d&&e.attrs({to:d}),e.c("query",b)},_onDiscoInfo:function(a){var b,c=a.getElementsByTagName("query")[0].getAttribute("node"),d={xmlns:Strophe.NS.DISCO_INFO};c&&(d.node=c);var e=this._buildIQResult(a,d);for(b=0;b<this._identities.length;b++)d={category:this._identities[b].category,type:this._identities[b].type},this._identities[b].name&&(d.name=this._identities[b].name),this._identities[b].lang&&(d["xml:lang"]=this._identities[b].lang),e.c("identity",d).up();for(b=0;b<this._features.length;b++)e.c("feature",{"var":this._features[b]}).up();return this._connection.send(e.tree()),!0},_onDiscoItems:function(a){var b,c,d={xmlns:Strophe.NS.DISCO_ITEMS},e=a.getElementsByTagName("query")[0].getAttribute("node");if(e){for(d.node=e,b=[],c=0;c<this._items.length;c++)if(this._items[c].node==e){b=this._items[c].call_back(a);break}}else b=this._items;var f=this._buildIQResult(a,d);for(c=0;c<b.length;c++){var g={jid:b[c].jid};b[c].name&&(g.name=b[c].name),b[c].node&&(g.node=b[c].node),f.c("item",g).up()}return this._connection.send(f.tree()),!0}}),Strophe.addConnectionPlugin("caps",{HASH:"sha-1",node:"http://strophe.im/strophejs/",_ver:"",_connection:null,_knownCapabilities:{},_jidVerIndex:{},init:function(a){if(this._connection=a,Strophe.addNamespace("CAPS","http://jabber.org/protocol/caps"),!this._connection.disco)throw"Caps plugin requires the disco plugin to be installed.";this._connection.disco.addFeature(Strophe.NS.CAPS),this._connection.addHandler(this._delegateCapabilities.bind(this),Strophe.NS.CAPS)},generateCapsAttrs:function(){return{xmlns:Strophe.NS.CAPS,hash:this.HASH,node:this.node,ver:this.generateVer()}},generateVer:function(){if(""!==this._ver)return this._ver;for(var a="",b=this._connection.disco._identities.sort(this._sortIdentities),c=b.length,d=this._connection.disco._features.sort(),e=d.length,f=0;c>f;f++){var g=b[f];a+=g.category+"/"+g.type+"/"+g.lang+"/"+g.name+"<"}for(var f=0;e>f;f++)a+=d[f]+"<";return this._ver=b64_sha1(a),this._ver},getCapabilitiesByJid:function(a){return this._jidVerIndex[a]?this._knownCapabilities[this._jidVerIndex[a]]:null},_delegateCapabilities:function(a){var b=a.getAttribute("from"),c=a.querySelector("c"),d=c.getAttribute("ver"),e=c.getAttribute("node");return this._knownCapabilities[d]?(this._jidVerIndex[b]=d,this._jidVerIndex[b]&&!this._jidVerIndex[b]===d||(this._jidVerIndex[b]=d),!0):this._requestCapabilities(b,e,d)},_requestCapabilities:function(a,b,c){if(a!==this._connection.jid){var d=this._connection.disco.info(a,b+"#"+c);this._connection.addHandler(this._handleDiscoInfoReply.bind(this),Strophe.NS.DISCO_INFO,"iq","result",d,a)}return!0},_handleDiscoInfoReply:function(a){var b=a.querySelector("query"),c=b.getAttribute("node").split("#"),d=c[1],e=a.getAttribute("from");if(this._knownCapabilities[d])this._jidVerIndex[e]&&!this._jidVerIndex[e]===d||(this._jidVerIndex[e]=d);else{var f=b.childNodes,g=f.length;this._knownCapabilities[d]=[];for(var h=0;g>h;h++){var c=f[h];this._knownCapabilities[d].push({name:c.nodeName,attributes:c.attributes})}this._jidVerIndex[e]=d}return!1},_sortIdentities:function(a,b){return a.category>b.category?1:a.category<b.category?-1:a.type>b.type?1:a.type<b.type?-1:a.lang>b.lang?1:a.lang<b.lang?-1:0}});var Mustache=function(){var a=function(){};return a.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":!0},context:{},render:function(a,b,c,d){if(d||(this.context=b,this.buffer=[]),!this.includes("",a))return d?a:void this.send(a);a=this.render_pragmas(a);var e=this.render_section(a,b,c);return d?this.render_tags(e,b,c,d):void this.render_tags(e,b,c,d)},send:function(a){""!=a&&this.buffer.push(a)},render_pragmas:function(a){if(!this.includes("%",a))return a;var b=this,c=new RegExp(this.otag+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+this.ctag);return a.replace(c,function(a,c,d){if(!b.pragmas_implemented[c])throw{message:"This implementation of mustache doesn't understand the '"+c+"' pragma"};if(b.pragmas[c]={},d){var e=d.split("=");b.pragmas[c][e[0]]=e[1]}return""})},render_partial:function(a,b,c){if(a=this.trim(a),!c||void 0===c[a])throw{message:"unknown_partial '"+a+"'"};return"object"!=typeof b[a]?this.render(c[a],b,c,!0):this.render(c[a],b[a],c,!0)},render_section:function(a,b,c){if(!this.includes("#",a)&&!this.includes("^",a))return a;var d=this,e=new RegExp(this.otag+"(\\^|\\#)\\s*(.+)\\s*"+this.ctag+"\n*([\\s\\S]+?)"+this.otag+"\\/\\s*\\2\\s*"+this.ctag+"\\s*","mg");return a.replace(e,function(a,e,f,g){var h=d.find(f,b);return"^"==e?!h||d.is_array(h)&&0===h.length?d.render(g,b,c,!0):"":"#"==e?d.is_array(h)?d.map(h,function(a){return d.render(g,d.create_context(a),c,!0)}).join(""):d.is_object(h)?d.render(g,d.create_context(h),c,!0):"function"==typeof h?h.call(b,g,function(a){return d.render(a,b,c,!0)}):h?d.render(g,b,c,!0):"":void 0})},render_tags:function(a,b,c,d){for(var e=this,f=function(){return new RegExp(e.otag+"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+e.ctag+"+","g")},g=f(),h=function(a,d,h){switch(d){case"!":return"";case"=":return e.set_delimiters(h),g=f(),"";case">":return e.render_partial(h,b,c);case"{":return e.find(h,b);default:return e.escape(e.find(h,b))}},i=a.split("\n"),j=0;j<i.length;j++)i[j]=i[j].replace(g,h,this),d||this.send(i[j]);return d?i.join("\n"):void 0},set_delimiters:function(a){var b=a.split(" ");this.otag=this.escape_regex(b[0]),this.ctag=this.escape_regex(b[1])},escape_regex:function(a){if(!arguments.callee.sRE){var b=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+b.join("|\\")+")","g")}return a.replace(arguments.callee.sRE,"\\$1")},find:function(a,b){function c(a){return a===!1||0===a||a}a=this.trim(a);var d;return c(b[a])?d=b[a]:c(this.context[a])&&(d=this.context[a]),"function"==typeof d?d.apply(b):void 0!==d?d:""},includes:function(a,b){return-1!=b.indexOf(this.otag+a)},escape:function(a){return a=String(null===a?"":a),a.replace(/&(?!\w+;)|["<>\\]/g,function(a){switch(a){case"&":return"&amp;";case"\\":return"\\\\";case'"':return'"';case"<":return"&lt;";case">":return"&gt;";default:return a}})},create_context:function(a){if(this.is_object(a))return a;var b=".";this.pragmas["IMPLICIT-ITERATOR"]&&(b=this.pragmas["IMPLICIT-ITERATOR"].iterator);var c={};return c[b]=a,c},is_object:function(a){return a&&"object"==typeof a},is_array:function(a){return"[object Array]"===Object.prototype.toString.call(a)},trim:function(a){return a.replace(/^\s*|\s*$/g,"")},map:function(a,b){if("function"==typeof a.map)return a.map(b);for(var c=[],d=a.length,e=0;d>e;e++)c.push(b(a[e]));return c}},{name:"mustache.js",version:"0.3.0",to_html:function(b,c,d,e){var f=new a;return e&&(f.send=e),f.render(b,c,d),e?void 0:f.buffer.join("\n")}}}();!function(a){var b=Array.prototype.slice,c={dict:null,load:function(b){null!==this.dict?a.extend(this.dict,b):this.dict=b},_:function(a){return dict=this.dict,dict&&dict.hasOwnProperty(a)&&(a=dict[a]),args=b.call(arguments),args[0]=a,this.printf.apply(this,args)},printf:function(c,d){return arguments.length<2?c:(d=a.isArray(d)?d:b.call(arguments,1),c.replace(/([^%]|^)%(?:(\d+)\$)?s/g,function(a,b,c){return c?b+d[parseInt(c)-1]:b+d.shift()}).replace(/%%s/g,"%s"))}};a.fn._t=function(b,d){return a(this).html(c._.apply(c,arguments))},a.i18n=c}(jQuery);var dateFormat=function(){var a=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,b=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,c=/[^-+\dA-Z]/g,d=function(a,b){for(a=String(a),b=b||2;a.length<b;)a="0"+a;return a};return function(e,f,g){var h=dateFormat;if(1!=arguments.length||"[object String]"!=Object.prototype.toString.call(e)||/\d/.test(e)||(f=e,e=void 0),e=e?new Date(e):new Date,isNaN(e))throw SyntaxError("invalid date");f=String(h.masks[f]||f||h.masks["default"]),"UTC:"==f.slice(0,4)&&(f=f.slice(4),g=!0);var i=g?"getUTC":"get",j=e[i+"Date"](),k=e[i+"Day"](),l=e[i+"Month"](),m=e[i+"FullYear"](),n=e[i+"Hours"](),o=e[i+"Minutes"](),p=e[i+"Seconds"](),q=e[i+"Milliseconds"](),r=g?0:e.getTimezoneOffset(),s={d:j,dd:d(j),ddd:h.i18n.dayNames[k],dddd:h.i18n.dayNames[k+7],m:l+1,mm:d(l+1),mmm:h.i18n.monthNames[l],mmmm:h.i18n.monthNames[l+12],yy:String(m).slice(2),yyyy:m,h:n%12||12,hh:d(n%12||12),H:n,HH:d(n),M:o,MM:d(o),s:p,ss:d(p),l:d(q,3),L:d(q>99?Math.round(q/10):q),t:12>n?"a":"p",tt:12>n?"am":"pm",T:12>n?"A":"P",TT:12>n?"AM":"PM",Z:g?"UTC":(String(e).match(b)||[""]).pop().replace(c,""),o:(r>0?"-":"+")+d(100*Math.floor(Math.abs(r)/60)+Math.abs(r)%60,4),S:["th","st","nd","rd"][j%10>3?0:(j%100-j%10!=10)*j%10]};return f.replace(a,function(a){return a in s?s[a]:a.slice(1,a.length-1)})}}();dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},Date.prototype.format=function(a,b){return dateFormat(this,a,b)};