forked from QuickBlox/quickblox-javascript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickblox.min.js
More file actions
5 lines (5 loc) · 94.4 KB
/
Copy pathquickblox.min.js
File metadata and controls
5 lines (5 loc) · 94.4 KB
1
2
3
4
5
/* QuickBlox JavaScript SDK - v1.9.3 - 2015-07-14 */
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.QB=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){this.service=a}function e(a){var b={application_id:g.creds.appId,auth_key:g.creds.authKey,nonce:h.randomNonce(),timestamp:h.unixTime()};return a.login&&a.password?b.user={login:a.login,password:a.password}:a.email&&a.password?b.user={email:a.email,password:a.password}:a.provider&&(b.provider=a.provider,a.scope&&(b.scope=a.scope),a.keys&&a.keys.token&&(b.keys={token:a.keys.token}),a.keys&&a.keys.secret&&(messages.keys.secret=a.keys.secret)),b}function f(a,b){var c=Object.keys(a).map(function(b){return"object"==typeof a[b]?Object.keys(a[b]).map(function(c){return b+"["+c+"]="+a[b][c]}).sort().join("&"):b+"="+a[b]}).sort().join("&");return i(c,b).toString()}var g=a("../qbConfig"),h=a("../qbUtils"),i=a("crypto-js/hmac-sha1");d.prototype={getSession:function(a){g.debug&&console.log("AuthProxy.getSession"),this.service.ajax({url:h.getUrl(g.urls.session)},function(b,c){b?a(b,null):a(b,c)})},createSession:function(a,b){if(""===g.creds.appId||""===g.creds.authKey||""===g.creds.authSecret)throw new Error("Cannot create a new session without app credentials (app ID, auth key and auth secret)");var c,d=this;"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),c=e(a),c.signature=f(c,g.creds.authSecret),g.debug&&console.log("AuthProxy.createSession",c),this.service.ajax({url:h.getUrl(g.urls.session),type:"POST",data:c},function(a,c){a?b(a,null):(d.service.setSession(c.session),b(null,c.session))})},destroySession:function(a){var b=this;g.debug&&console.log("AuthProxy.destroySession"),this.service.ajax({url:h.getUrl(g.urls.session),type:"DELETE",dataType:"text"},function(c,d){c?a(c,null):(b.service.setSession(null),a(null,d))})},login:function(a,b){g.debug&&console.log("AuthProxy.login",a),this.service.ajax({url:h.getUrl(g.urls.login),type:"POST",data:a},function(a,c){a?b(a,null):b(null,c.user)})},logout:function(a){g.debug&&console.log("AuthProxy.logout"),this.service.ajax({url:h.getUrl(g.urls.login),type:"DELETE",dataType:"text"},a)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13,"crypto-js/hmac-sha1":17}],2:[function(a,b,c){function d(a,b,c){var d=this;r=b,q=c,this.service=a,o&&(this.roster=new e(a),this.muc=new f(a)),this.dialog=new g(a),this.message=new h(a),this.helpers=new i,this._isLogout=!1,this._onMessage=function(a){var b,c,e,f,g,h=a.getAttribute("from"),i=(a.getAttribute("to"),a.getAttribute("type")),j=a.querySelector("body"),k=(a.querySelector("markable"),a.querySelector("received")),l=a.querySelector("displayed"),m=a.querySelector("invite"),n=a.querySelector("extraParams"),o=a.querySelector("delay"),p=a.getAttribute("id"),q="groupchat"===i?d.helpers.getDialogIdFromNode(h):null,r="groupchat"===i?d.helpers.getIdFromResource(h):d.helpers.getIdFromNode(h),s=k||l||null;if(m)return!0;if(n){c={},e=[];for(var t=0,u=n.childNodes.length;u>t;t++)if("attachment"===n.childNodes[t].tagName){f={},g=n.childNodes[t].attributes;for(var v=0,w=g.length;w>v;v++)"id"===g[v].name||"size"===g[v].name?f[g[v].name]=parseInt(g[v].value):f[g[v].name]=g[v].value;e.push(f)}else if(n.childNodes[t].childNodes.length>1){var x=n.childNodes[t].textContent.length;if(x>4096){for(var y="",v=0;v<n.childNodes[t].childNodes.length;++v)y+=n.childNodes[t].childNodes[v].textContent;c[n.childNodes[t].tagName]=y}else c=d._XMLtoJS(c,n.childNodes[t].tagName,n.childNodes[t])}else c[n.childNodes[t].tagName]=n.childNodes[t].textContent;e.length>0&&(c.attachments=e)}return b={id:p,dialog_id:q,type:i,body:j&&j.textContent||null,extension:c||null,delay:o},s&&(b.markerType=k?"received":"displayed",b.markerMessageId=s.getAttribute("id")),"function"!=typeof d.onMessageListener||"chat"!==i&&"groupchat"!==i&&o||d.onMessageListener(r,b),!0},this._onPresence=function(a){var b=a.getAttribute("from"),c=a.getAttribute("type"),e=d.helpers.getIdFromNode(b);if(c)switch(c){case"subscribe":u[e]&&"to"===u[e].subscription?(u[e]={subscription:"both",ask:null},d.roster._sendSubscriptionPresence({jid:b,type:"subscribed"})):"function"==typeof d.onSubscribeListener&&d.onSubscribeListener(e);break;case"subscribed":u[e]&&"from"===u[e].subscription?u[e]={subscription:"both",ask:null}:(u[e]={subscription:"to",ask:null},"function"==typeof d.onConfirmSubscribeListener&&d.onConfirmSubscribeListener(e));break;case"unsubscribed":u[e]={subscription:"none",ask:null},"function"==typeof d.onRejectSubscribeListener&&d.onRejectSubscribeListener(e);break;case"unsubscribe":u[e]={subscription:"to",ask:null};break;case"unavailable":"function"==typeof d.onContactListListener&&u[e]&&"none"!==u[e].subscription&&d.onContactListListener(e,c)}else"function"==typeof d.onContactListListener&&u[e]&&"none"!==u[e].subscription&&d.onContactListListener(e);return!0},this._onIQ=function(a){return!0}}function e(a){this.service=a,this.helpers=new i}function f(a){this.service=a,this.helpers=new i}function g(a){this.service=a,this.helpers=new i}function h(a){this.service=a,this.helpers=new i}function i(){}function j(a){console.log("[QBChat]:",a)}function k(a,b){var c={code:a,status:"error",message:401===a?"Unauthorized":"Unprocessable Entity",detail:b};return j(b),c}function l(){return(new Date).toTimeString().split(" ")[0]}var m=a("../qbConfig"),n=a("../qbUtils"),o="undefined"!=typeof window,p="This function isn't supported outside of the browser (...yet)";o&&(a("../../lib/strophe/strophe.min"),Strophe.addNamespace("CARBONS","urn:xmpp:carbons:2"),Strophe.addNamespace("CHAT_MARKERS","urn:xmpp:chat-markers:0"));var q,r,s=m.urls.chat+"/Dialog",t=m.urls.chat+"/Message",u={},v={};d.prototype={connect:function(a,b){if(!o)throw p;m.debug&&console.log("ChatProxy.connect",a);var c,d,e,f=this;"userId"in a?e=a.userId+"-"+m.creds.appId+"@"+m.endpoints.chat:"jid"in a&&(e=a.jid),q.connect(e,a.password,function(e){switch(e){case Strophe.Status.ERROR:c=k(422,"Status.ERROR - An error has occurred"),"function"==typeof b&&b(c,null);break;case Strophe.Status.CONNECTING:j("Status.CONNECTING"),j("Chat Protocol - "+(1===m.chatProtocol.active?"BOSH":"WebSocket"));break;case Strophe.Status.CONNFAIL:c=k(422,"Status.CONNFAIL - The connection attempt failed"),"function"==typeof b&&b(c,null);break;case Strophe.Status.AUTHENTICATING:j("Status.AUTHENTICATING");break;case Strophe.Status.AUTHFAIL:c=k(401,"Status.AUTHFAIL - The authentication attempt failed"),"function"==typeof b&&b(c,null);break;case Strophe.Status.CONNECTED:j("Status.CONNECTED at "+l()),q.addHandler(f._onMessage,null,"message","chat"),q.addHandler(f._onMessage,null,"message","groupchat"),q.addHandler(f._onPresence,null,"presence"),q.addHandler(f._onIQ,null,"iq"),q.addHandler(r._onMessage,null,"message","headline"),f._enableCarbons(function(){f.roster.get(function(a){if(u=a,q.send($pres().tree()),q.addTimedHandler(55e3,f._autoSendPresence),"function"==typeof b)b(null,u);else{f._isLogout=!1,d=Object.keys(v);for(var c=0,e=d.length;e>c;c++)f.muc.join(d[c]);"function"==typeof f.onReconnectListener&&f.onReconnectListener()}})});break;case Strophe.Status.DISCONNECTING:j("Status.DISCONNECTING");break;case Strophe.Status.DISCONNECTED:j("Status.DISCONNECTED at "+l()),q.reset(),"function"==typeof f.onDisconnectingListener&&f.onDisconnectingListener(),f._isLogout||f.connect(a);break;case Strophe.Status.ATTACHED:j("Status.ATTACHED")}})},send:function(a,b){if(!o)throw p;var c;if("string"==typeof a)c=a;else{if("number"!=typeof a)throw p;c=a+"-"+m.creds.appId+"@"+m.endpoints.chat}var d=this,e=$msg({from:q.jid,to:c,type:b.type,id:b.id||n.getBsonObjectId()});b.body&&e.c("body",{xmlns:Strophe.NS.CLIENT}).t(b.body).up(),b.extension&&(e.c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b.extension).forEach(function(a){"attachments"===a?b.extension[a].forEach(function(a){e.c("attachment",a).up()}):"object"==typeof b.extension[a]?d._JStoXML(a,b.extension[a],e):e.c(a).t(b.extension[a]).up()}),e.up()),"chat"===b.type&&e.c("markable",{xmlns:Strophe.NS.CHAT_MARKERS}),q.send(e)},sendPres:function(a){if(!o)throw p;q.send($pres({from:q.jid,type:a}))},sendDeliveredMessage:function(a,b){if(!o)throw p;var c=$msg({from:q.jid,to:a,type:"chat",id:n.getBsonObjectId()});c.c("received",{xmlns:Strophe.NS.CHAT_MARKERS,id:b}),q.send(c)},sendReadMessage:function(a,b){if(!o)throw p;var c=$msg({from:q.jid,to:a,type:"chat",id:n.getBsonObjectId()});c.c("displayed",{xmlns:Strophe.NS.CHAT_MARKERS,id:b}),q.send(c)},disconnect:function(){if(!o)throw p;v={},this._isLogout=!0,q.flush(),q.disconnect()},addListener:function(a,b){function c(){return b(),a.live!==!1}if(!o)throw p;return q.addHandler(c,null,a.name||null,a.type||null,a.id||null,a.from||null)},deleteListener:function(a){if(!o)throw p;q.deleteHandler(a)},_JStoXML:function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},_XMLtoJS:function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a},_autoSendPresence:function(){if(!o)throw p;return q.send($pres().tree()),!0},_enableCarbons:function(a){if(!o)throw p;var b;b=$iq({from:q.jid,type:"set",id:q.getUniqueId("enableCarbons")}).c("enable",{xmlns:Strophe.NS.CARBONS}),q.sendIQ(b,function(b){a()})}},e.prototype={get:function(a){var b,c,d,e=this,f={};b=$iq({from:q.jid,type:"get",id:q.getUniqueId("getRoster")}).c("query",{xmlns:Strophe.NS.ROSTER}),q.sendIQ(b,function(b){c=b.getElementsByTagName("item");for(var g=0,h=c.length;h>g;g++)d=e.helpers.getIdFromNode(c[g].getAttribute("jid")).toString(),f[d]={subscription:c[g].getAttribute("subscription"),ask:c[g].getAttribute("ask")||null};a(f)})},add:function(a,b){var c=this,d=c.helpers.getIdFromNode(a).toString();u[d]={subscription:"none",ask:"subscribe"},c._sendSubscriptionPresence({jid:a,type:"subscribe"}),"function"==typeof b&&b()},confirm:function(a,b){var c=this,d=c.helpers.getIdFromNode(a).toString();u[d]={subscription:"from",ask:"subscribe"},c._sendSubscriptionPresence({jid:a,type:"subscribed"}),c._sendSubscriptionPresence({jid:a,type:"subscribe"}),"function"==typeof b&&b()},reject:function(a,b){var c=this,d=c.helpers.getIdFromNode(a).toString();u[d]={subscription:"none",ask:null},c._sendSubscriptionPresence({jid:a,type:"unsubscribed"}),"function"==typeof b&&b()},remove:function(a,b){var c,d,e=this;c=$iq({from:q.jid,type:"set",id:q.getUniqueId("removeRosterItem")}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:a,subscription:"remove"}),d=e.helpers.getIdFromNode(a).toString(),q.sendIQ(c,function(){delete u[d],"function"==typeof b&&b()})},_sendSubscriptionPresence:function(a){var b;b=$pres({to:a.jid,type:a.type}),q.send(b)}},f.prototype={join:function(a,b){var c,d=this,e=q.getUniqueId("join");v[a]=!0,c=$pres({from:q.jid,to:d.helpers.getRoomJid(a),id:e}).c("x",{xmlns:Strophe.NS.MUC}).c("history",{maxstanzas:0}),"function"==typeof b&&q.addHandler(b,null,"presence",null,e),q.send(c)},leave:function(a,b){var c,d=this,e=d.helpers.getRoomJid(a);delete v[a],c=$pres({from:q.jid,to:e,type:"unavailable"}),"function"==typeof b&&q.addHandler(b,null,"presence","unavailable",null,e),q.send(c)}},g.prototype={list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),m.debug&&console.log("DialogProxy.list",a),this.service.ajax({url:n.getUrl(s),data:a},b)},create:function(a,b){m.debug&&console.log("DialogProxy.create",a),this.service.ajax({url:n.getUrl(s),type:"POST",data:a},b)},update:function(a,b,c){m.debug&&console.log("DialogProxy.update",a,b),this.service.ajax({url:n.getUrl(s,a),type:"PUT",data:b},c)},"delete":function(a,b){m.debug&&console.log("DialogProxy.delete",a),this.service.ajax({url:n.getUrl(s,a),type:"DELETE",dataType:"text"},b)}},h.prototype={list:function(a,b){m.debug&&console.log("MessageProxy.list",a),this.service.ajax({url:n.getUrl(t),data:a},b)},create:function(a,b){m.debug&&console.log("MessageProxy.create",a),this.service.ajax({url:n.getUrl(t),type:"POST",data:a},b)},update:function(a,b,c){m.debug&&console.log("MessageProxy.update",a,b),this.service.ajax({url:n.getUrl(t,a),type:"PUT",data:b},c)},"delete":function(a,b){m.debug&&console.log("MessageProxy.delete",a),this.service.ajax({url:n.getUrl(t,a),type:"DELETE",dataType:"text"},b)}},i.prototype={getUserJid:function(a,b){return a+"-"+b+"@"+m.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])},getDialogIdFromNode:function(a){return a.indexOf("@")<0?null:a.split("@")[0].split("_")[1]},getRoomJid:function(a){if(!o)throw p;return a+"/"+this.getIdFromNode(q.jid)},getIdFromResource:function(a){var b=a.split("/");return b.length<2?null:(b.splice(0,1),parseInt(b.join("/")))},getUniqueId:function(a){if(!o)throw p;return q.getUniqueId(a)},getBsonObjectId:function(){return n.getBsonObjectId()}},b.exports=d},{"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],3:[function(a,b,c){function d(a){this.service=a}function e(a){for(var b=e.options,c=b.parser[b.strictMode?"strict":"loose"].exec(a),d={},f=14;f--;)d[b.key[f]]=c[f]||"";return d[b.q.name]={},d[b.key[12]].replace(b.q.parser,function(a,c,e){c&&(d[b.q.name][c]=e)}),d}var f=a("../qbConfig"),g=a("../qbUtils"),h=f.urls.blobs+"/tagged";d.prototype={create:function(a,b){f.debug&&console.log("ContentProxy.create",a),this.service.ajax({url:g.getUrl(f.urls.blobs),data:{blob:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.blob)})},list:function(a,b){"function"==typeof a&&"undefined"==typeof b&&(b=a,a=null),this.service.ajax({url:g.getUrl(f.urls.blobs),data:a,type:"GET"},function(a,c){a?b(a,null):b(a,c)})},"delete":function(a,b){this.service.ajax({url:g.getUrl(f.urls.blobs,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},createAndUpload:function(a,b){var c,d,g,h,i,j={},k=this;f.debug&&console.log("ContentProxy.createAndUpload",a),c=a.file,d=a.name||c.name,g=a.type||c.type,h=c.size,j.name=d,j.content_type=g,a["public"]&&(j["public"]=a["public"]),a.tag_list&&(j.tag_list=a.tag_list),this.create(j,function(a,d){if(a)b(a,null);else{var g=e(d.blob_object_access.params),j={url:(f.ssl?"https://":"http://")+g.host},l=new FormData;i=d.id,Object.keys(g.queryKey).forEach(function(a){l.append(a,decodeURIComponent(g.queryKey[a]))}),l.append("file",c,d.name),j.data=l,k.upload(j,function(a,c){a?b(a,null):(d.path=f.ssl?c.Location.replace("http://","https://"):c.Location,k.markUploaded({id:i,size:h},function(a,c){a?b(a,null):b(null,d)}))})}})},upload:function(a,b){this.service.ajax({url:a.url,data:a.data,dataType:"xml",contentType:!1,processData:!1,type:"POST"},function(a,c){if(a)b(a,null);else{var d,e,g={},h=c.documentElement,i=h.childNodes;for(d=0,e=i.length;e>d;d++)g[i[d].nodeName]=i[d].childNodes[0].nodeValue;f.debug&&console.log("result",g),b(null,g)}})},taggedForCurrentUser:function(a){this.service.ajax({url:g.getUrl(h)},function(b,c){b?a(b,null):a(null,c)})},markUploaded:function(a,b){this.service.ajax({url:g.getUrl(f.urls.blobs,a.id+"/complete"),type:"PUT",data:{size:a.size},dataType:"text"},function(a,c){a?b(a,null):b(null,c)})},getInfo:function(a,b){this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFile:function(a,b){this.service.ajax({url:g.getUrl(f.urls.blobs,a)},function(a,c){a?b(a,null):b(null,c)})},getFileUrl:function(a,b){this.service.ajax({url:g.getUrl(f.urls.blobs,a+"/getblobobjectbyid"),type:"POST"},function(a,c){a?b(a,null):b(null,c.blob_object_access.params)})},update:function(a,b){var c={};c.blob={},"undefined"!=typeof a.name&&(c.blob.name=a.name),this.service.ajax({url:g.getUrl(f.urls.blobs,a.id),data:c},function(a,c){a?b(a,null):b(null,c)})}},b.exports=d,e.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},{"../qbConfig":9,"../qbUtils":13}],4:[function(a,b,c){function d(a){this.service=a,e.debug&&console.log("LocationProxy",a)}var e=a("../qbConfig"),f=a("../qbUtils");d.prototype={create:function(a,b,c){e.debug&&console.log("DataProxy.create",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},list:function(a,b,c){"undefined"==typeof c&&"function"==typeof b&&(c=b,b=null),e.debug&&console.log("DataProxy.list",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a),data:b},function(a,b){a?c(a,null):c(a,b)})},update:function(a,b,c){e.debug&&console.log("DataProxy.update",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b._id),data:b,type:"PUT"},function(a,b){a?c(a,null):c(a,b)})},"delete":function(a,b,c){e.debug&&console.log("DataProxy.delete",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b),type:"DELETE",dataType:"text"},function(a,b){a?c(a,null):c(a,!0)})},uploadFile:function(a,b,c){var d;e.debug&&console.log("DataProxy.uploadFile",a,b),d=new FormData,d.append("field_name",b.field_name),d.append("file",b.file),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:d,contentType:!1,processData:!1,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},updateFile:function(a,b,c){var d;e.debug&&console.log("DataProxy.updateFile",a,b),d=new FormData,d.append("field_name",b.field_name),d.append("file",b.file),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:d,contentType:!1,processData:!1,type:"POST"},function(a,b){a?c(a,null):c(a,b)})},downloadFile:function(a,b,c){e.debug&&console.log("DataProxy.downloadFile",a,b);var d=f.getUrl(e.urls.data,a+"/"+b.id+"/file");d+="?field_name="+b.field_name+"&token="+this.service.getSession().token,c(null,d)},deleteFile:function(a,b,c){e.debug&&console.log("DataProxy.deleteFile",a,b),this.service.ajax({url:f.getUrl(e.urls.data,a+"/"+b.id+"/file"),data:{field_name:b.field_name},dataType:"text",type:"DELETE"},function(a,b){a?c(a,null):c(a,!0)})}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],5:[function(a,b,c){function d(a){this.service=a,this.geodata=new e(a),this.places=new f(a),g.debug&&console.log("LocationProxy",a)}function e(a){this.service=a}function f(a){this.service=a}var g=a("../qbConfig"),h=a("../qbUtils"),i=g.urls.geodata+"/find";e.prototype={create:function(a,b){g.debug&&console.log("GeoProxy.create",{geo_data:a}),this.service.ajax({url:h.getUrl(g.urls.geodata),data:{geo_data:a},type:"POST"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},update:function(a,b){var c,d=["longitude","latitude","status"],e={};for(c in a)a.hasOwnProperty(c)&&d.indexOf(c)>0&&(e[c]=a[c]);g.debug&&console.log("GeoProxy.create",a),this.service.ajax({url:h.getUrl(g.urls.geodata,a.id),data:{geo_data:e},type:"PUT"},function(a,c){a?b(a,null):b(a,c.geo_datum)})},get:function(a,b){g.debug&&console.log("GeoProxy.get",a),this.service.ajax({url:h.getUrl(g.urls.geodata,a)},function(a,c){a?b(a,null):b(null,c.geo_datum)})},list:function(a,b){"function"==typeof a&&(b=a,a=void 0),g.debug&&console.log("GeoProxy.find",a),this.service.ajax({url:h.getUrl(i),data:a},b)},"delete":function(a,b){g.debug&&console.log("GeoProxy.delete",a),this.service.ajax({url:h.getUrl(g.urls.geodata,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})},purge:function(a,b){g.debug&&console.log("GeoProxy.purge",a),this.service.ajax({url:h.getUrl(g.urls.geodata),data:{days:a},type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},f.prototype={list:function(a,b){g.debug&&console.log("PlacesProxy.list",a),this.service.ajax({url:h.getUrl(g.urls.places)},b)},create:function(a,b){g.debug&&console.log("PlacesProxy.create",a),this.service.ajax({url:h.getUrl(g.urls.places),data:{place:a},type:"POST"},b)},get:function(a,b){g.debug&&console.log("PlacesProxy.get",a),this.service.ajax({url:h.getUrl(g.urls.places,a)},b)},update:function(a,b){g.debug&&console.log("PlacesProxy.update",a),this.service.ajax({url:h.getUrl(g.urls.places,a.id),data:{place:a},type:"PUT"},b)},"delete":function(a,b){g.debug&&console.log("PlacesProxy.delete",a),this.service.ajax({url:h.getUrl(g.urls.places,a),type:"DELETE",dataType:"text"},b)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],6:[function(a,b,c){function d(a){this.service=a,this.tokens=new e(a),this.subscriptions=new f(a),this.events=new g(a)}function e(a){this.service=a}function f(a){this.service=a}function g(a){this.service=a}var h=a("../qbConfig"),i=a("../qbUtils");e.prototype={create:function(a,b){var c={push_token:{environment:a.environment,client_identification_sequence:a.client_identification_sequence},device:{platform:a.platform,udid:a.udid}};h.debug&&console.log("TokensProxy.create",c),this.service.ajax({url:i.getUrl(h.urls.pushtokens),type:"POST",data:c},function(a,c){a?b(a,null):b(null,c.push_token)})},"delete":function(a,b){h.debug&&console.log("MessageProxy.deletePushToken",a),this.service.ajax({url:i.getUrl(h.urls.pushtokens,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},f.prototype={create:function(a,b){h.debug&&console.log("MessageProxy.createSubscription",a),this.service.ajax({url:i.getUrl(h.urls.subscriptions),type:"POST",data:a},b)},list:function(a){h.debug&&console.log("MessageProxy.listSubscription"),this.service.ajax({url:i.getUrl(h.urls.subscriptions)},a)},"delete":function(a,b){h.debug&&console.log("MessageProxy.deleteSubscription",a),this.service.ajax({url:i.getUrl(h.urls.subscriptions,a),type:"DELETE",dataType:"text"},function(a,c){a?b(a,null):b(null,!0)})}},g.prototype={create:function(a,b){h.debug&&console.log("MessageProxy.createEvent",a);var c={event:a};this.service.ajax({url:i.getUrl(h.urls.events),type:"POST",data:c},b)},list:function(a){h.debug&&console.log("MessageProxy.listEvents"),this.service.ajax({url:i.getUrl(h.urls.events)},a)},get:function(a,b){h.debug&&console.log("MessageProxy.getEvent",a),this.service.ajax({url:i.getUrl(h.urls.events,a)},b)},status:function(a,b){h.debug&&console.log("MessageProxy.getEventStatus",a),this.service.ajax({url:i.getUrl(h.urls.events,a+"/status")},b)},update:function(a,b){h.debug&&console.log("MessageProxy.createEvent",a);var c={event:a};this.service.ajax({url:i.getUrl(h.urls.events,a.id),type:"PUT",data:c},b)},"delete":function(a,b){h.debug&&console.log("MessageProxy.deleteEvent",a),this.service.ajax({url:i.getUrl(h.urls.events,a),type:"DELETE"},b)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],7:[function(a,b,c){function d(a){this.service=a}function e(a){var b=a.field in i?"date":typeof a.value;return a.value instanceof Array&&("object"==b&&(b=typeof a.value[0]),a.value=a.value.toString()),[b,a.field,a.param,a.value].join(" ")}function f(a){var b=a.field in i?"date":a.field in j?"number":"string";return[a.sort,b,a.field].join(" ")}var g=a("../qbConfig"),h=a("../qbUtils"),i=["created_at","updated_at","last_request_at"],j=["id","external_user_id"],k=g.urls.users+"/password/reset";d.prototype={listUsers:function(a,b){var c,d={},i=[];"function"==typeof a&&"undefined"==typeof b&&(b=a,a={}),a.filter&&(a.filter instanceof Array?a.filter.forEach(function(a){c=e(a),i.push(c)}):(c=e(a.filter),i.push(c)),d.filter=i),a.order&&(d.order=f(a.order)),a.page&&(d.page=a.page),a.per_page&&(d.per_page=a.per_page),g.debug&&console.log("UsersProxy.listUsers",d),this.service.ajax({url:h.getUrl(g.urls.users),data:d},b)},get:function(a,b){var c;"number"==typeof a?(c=a,a={}):a.login?c="by_login":a.full_name?c="by_full_name":a.facebook_id?c="by_facebook_id":a.twitter_id?c="by_twitter_id":a.email?c="by_email":a.tags?c="by_tags":a.external&&(c="external/"+a.external,a={}),g.debug&&console.log("UsersProxy.get",a),this.service.ajax({url:h.getUrl(g.urls.users,c),data:a},function(a,c){a?b(a,null):b(null,c.user||c)})},create:function(a,b){g.debug&&console.log("UsersProxy.create",a),this.service.ajax({url:h.getUrl(g.urls.users),type:"POST",data:{user:a}},function(a,c){a?b(a,null):b(null,c.user)})},update:function(a,b,c){g.debug&&console.log("UsersProxy.update",a,b),this.service.ajax({url:h.getUrl(g.urls.users,a),type:"PUT",data:{user:b}},function(a,b){a?c(a,null):c(null,b.user)})},"delete":function(a,b){var c;"number"==typeof a?c=a:a.external&&(c="external/"+a.external),g.debug&&console.log("UsersProxy.delete",c),this.service.ajax({url:h.getUrl(g.urls.users,c),type:"DELETE",dataType:"text"},b)},resetPassword:function(a,b){g.debug&&console.log("UsersProxy.resetPassword",a),this.service.ajax({url:h.getUrl(k),data:{email:a}},b)}},b.exports=d},{"../qbConfig":9,"../qbUtils":13}],8:[function(a,b,c){function d(a,b){var c=this;i=b,this.service=a,this.helpers=new e,this._onMessage=function(a){var b=a.getAttribute("from"),d=a.querySelector("extraParams"),e=a.querySelector("delay"),g=c.helpers.getIdFromNode(b),h=c._getExtension(d);if(e||h.moduleIdentifier!==u)return!0;switch(delete h.moduleIdentifier,h.signalType){case s.CALL:if(f("onCall from "+g),v[g])return!0;v[g]={sessionID:h.sessionID,sdp:h.sdp},h.callType="1"===h.callType?"video":"audio",delete h.sdp,"function"==typeof c.onCallListener&&c.onCallListener(g,h);break;case s.ACCEPT:f("onAccept from "+g),"object"==typeof j&&j.onRemoteSessionCallback(h.sdp,"answer"),delete h.sdp,"function"==typeof c.onAcceptCallListener&&c.onAcceptCallListener(g,h);break;case s.REJECT:f("onReject from "+g),c._close(),"function"==typeof c.onRejectCallListener&&c.onRejectCallListener(g,h);break;case s.STOP:f("onStop from "+g),v[g]&&delete v[g],c._checkReason(h.reason),"function"==typeof c.onStopCallListener&&c.onStopCallListener(g,h);break;case s.CANDIDATE:"object"==typeof j&&(j.addCandidates(h.iceCandidates),"answer"===j.type&&c._sendCandidate(j.opponentId,j.iceCandidates));break;case s.PARAMETERS_CHANGED:f("onUpdateCall from "+g),"function"==typeof c.onUpdateCallListener&&c.onUpdateCallListener(g,h)}return!0},this._getExtension=function(a){var b,d,e,f,g={},h=[],i=[];if(a){for(var j=0,k=a.childNodes.length;k>j;j++)if("iceCandidates"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var l=0,m=e.length;m>l;l++){b={},f=e[l].childNodes;for(var n=0,o=f.length;o>n;n++)b[f[n].tagName]=f[n].textContent;h.push(b)}}else if("opponentsIDs"===a.childNodes[j].tagName){e=a.childNodes[j].childNodes;for(var l=0,m=e.length;m>l;l++)d=e[l].textContent,i.push(d)}else a.childNodes[j].childNodes.length>1?g=c._XMLtoJS(g,a.childNodes[j].tagName,a.childNodes[j]):g[a.childNodes[j].tagName]=a.childNodes[j].textContent;h.length>0&&(g.iceCandidates=h),i.length>0&&(g.opponents=i)}return g},this._checkReason=function(a){var b=this;a===t.MANUALLY&&b._close()}}function e(){}function f(a){console.log("[QBWebRTC]:",a)}function g(){var a=(new Date).toString().split(" ");return a.slice(1,5).join("-")}function h(a,b){for(var c=[],d=window.atob(a.split(",")[1]),e=0,f=d.length;f>e;e++)c.push(d.charCodeAt(e));return new Blob([new Uint8Array(c)],{type:b})}a("../../lib/strophe/strophe.min");var i,j,k=a("../../lib/download/download.min"),l=a("../qbConfig"),m=a("../qbUtils"),n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,o=window.RTCSessionDescription||window.mozRTCSessionDescription,p=window.RTCIceCandidate||window.mozRTCIceCandidate,q=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,r=window.URL||window.webkitURL,s={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},t={MANUALLY:"manually",BAD_CONNECTION:"bad_connection",CANCEL:"cancel",NOT_ANSWER:"not_answer"},u="WebRTCVideoChat",v={};d.prototype.getUserMedia=function(a,b){if(!q)throw new Error("getUserMedia() is not supported in your browser");q=q.bind(navigator);var c=this;q({audio:a.audio||!1,video:a.video||!1},function(d){c.localStream=d,a.elemId&&c.attachMediaStream(a.elemId,d,a.options),b(null,d)},function(a){b(a,null)})},d.prototype.attachMediaStream=function(a,b,c){var d=document.getElementById(a);d&&(d.src=r.createObjectURL(b),c&&c.muted&&(d.muted=!0),c&&c.mirror&&(d.style.webkitTransform="scaleX(-1)",d.style.transform="scaleX(-1)"),d.play())},d.prototype.snapshot=function(a){var b,c,d=document.getElementById(a),e=document.createElement("canvas"),f=e.getContext("2d");return d?(e.width=d.clientWidth,e.height=d.clientHeight,"scaleX(-1)"===d.style.transform&&(f.translate(e.width,0),f.scale(-1,1)),f.drawImage(d,0,0,d.clientWidth,d.clientHeight),b=e.toDataURL(),c=h(b,"image/png"),c.name="snapshot_"+g()+".png",c.url=b,c):void 0},d.prototype.filter=function(a,b){var c=document.getElementById(a);c&&(c.style.webkitFilter=b,c.style.filter=b)},d.prototype.mute=function(a){this._switchOffDevice(0,a)},d.prototype.unmute=function(a){this._switchOffDevice(1,a)},d.prototype._switchOffDevice=function(a,b){"audio"===b&&this.localStream.getAudioTracks().length>0&&this.localStream.getAudioTracks().forEach(function(b){b.enabled=!!a}),"video"===b&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach(function(b){b.enabled=!!a})},d.prototype._createPeer=function(a){if(!n)throw new Error("RTCPeerConnection() is not supported in your browser");if(!this.localStream)throw new Error("You don't have an access to the local stream");var b={iceServers:l.iceServers};j=new n(b),j.init(this,a),f("SessionID "+j.sessionID),f(j)},d.prototype.call=function(a,b,c){this._createPeer();var d=this,e=a instanceof Array?a:[a];j.opponentId=e[0],j.getSessionDescription(function(a,g){a?f(a):(f("call "+j.opponentId),d._sendMessage(j.opponentId,c,"CALL",b,e))})},d.prototype.accept=function(a,b){v[a]&&(this._createPeer({sessionID:v[a].sessionID,description:v[a].sdp}),delete v[a]);var c=this;j.opponentId=a,j.getSessionDescription(function(d,e){d?f(d):(f("accept "+a),c._sendMessage(a,b,"ACCEPT"))})},d.prototype.reject=function(a,b){var b=b||{};v[a]&&(b.sessionID=v[a].sessionID,delete v[a]),f("reject "+a),this._sendMessage(a,b,"REJECT")},d.prototype.stop=function(a,b,c){var c=c||{},d=b||"manually";c.reason=t[d.toUpperCase()]||b,f("stop "+a),this._sendMessage(a,c,"STOP"),this._close()},d.prototype.update=function(a,b){f("update "+a),this._sendMessage(a,b,"PARAMETERS_CHANGED")},d.prototype._close=function(){j&&j.close(),this.localStream&&(this.localStream.stop(),this.localStream=null)},d.prototype._sendCandidate=function(a,b){var c={iceCandidates:b};this._sendMessage(a,c,"CANDIDATE")},d.prototype._sendMessage=function(a,b,c,d,e){var f,g,b=b||{},h=this;b.moduleIdentifier=u,b.signalType=s[c],b.sessionID=j&&j.sessionID||b.sessionID,d&&(b.callType="video"===d?"1":"2"),("CALL"===c||"ACCEPT"===c)&&(b.sdp=j.localDescription.sdp,b.platform="web"),"CALL"===c&&(b.callerID=this.helpers.getIdFromNode(i.jid),b.opponentsIDs=e),g={from:i.jid,to:this.helpers.getUserJid(a,this.service.getSession().application_id),type:"headline",id:m.getBsonObjectId()},f=$msg(g).c("extraParams",{xmlns:Strophe.NS.CLIENT}),Object.keys(b).forEach(function(a){"iceCandidates"===a?(f=f.c("iceCandidates"),b[a].forEach(function(a){f=f.c("iceCandidate"),Object.keys(a).forEach(function(b){f.c(b).t(a[b]).up()}),f.up()}),f.up()):"opponentsIDs"===a?(f=f.c("opponentsIDs"),b[a].forEach(function(a){
f=f.c("opponentID").t(a).up()}),f.up()):"object"==typeof b[a]?h._JStoXML(a,b[a],f):f.c(a).t(b[a]).up()}),i.send(f)},d.prototype._JStoXML=function(a,b,c){var d=this;c.c(a),Object.keys(b).forEach(function(a){"object"==typeof b[a]?d._JStoXML(a,b[a],c):c.c(a).t(b[a]).up()}),c.up()},d.prototype._XMLtoJS=function(a,b,c){var d=this;a[b]={};for(var e=0,f=c.childNodes.length;f>e;e++)c.childNodes[e].childNodes.length>1?a[b]=d._XMLtoJS(a[b],c.childNodes[e].tagName,c.childNodes[e]):a[b][c.childNodes[e].tagName]=c.childNodes[e].textContent;return a},n&&(n.prototype.init=function(a,b){this.service=a,this.sessionID=b&&b.sessionID||Date.now(),this.type=b&&b.description?"answer":"offer",this.addStream(this.service.localStream),this.onicecandidate=this.onIceCandidateCallback,this.onaddstream=this.onRemoteStreamCallback,this.onsignalingstatechange=this.onSignalingStateCallback,this.oniceconnectionstatechange=this.onIceConnectionStateCallback,"answer"===this.type&&this.onRemoteSessionCallback(b.description,"offer")},n.prototype.getSessionDescription=function(a){function b(b){j.setLocalDescription(b,function(){a(null,b)},c)}function c(b){a(b,null)}"offer"===j.type?j.createOffer(b,c):j.createAnswer(b,c)},n.prototype.onIceCandidateCallback=function(a){var b=a.candidate;b&&(j.iceCandidates=j.iceCandidates||[],j.iceCandidates.push({sdpMLineIndex:b.sdpMLineIndex,sdpMid:b.sdpMid,candidate:b.candidate}))},n.prototype.onRemoteSessionCallback=function(a,b){var c=new o({sdp:a,type:b});this.setRemoteDescription(c)},n.prototype.onRemoteStreamCallback=function(a){"function"==typeof j.service.onRemoteStreamListener&&j.service.onRemoteStreamListener(a.stream)},n.prototype.addCandidates=function(a){for(var b,c=0,d=a.length;d>c;c++)b={sdpMLineIndex:a[c].sdpMLineIndex,sdpMid:a[c].sdpMid,candidate:a[c].candidate},this.addIceCandidate(new p(b))},n.prototype.onSignalingStateCallback=function(){j&&"stable"===j.signalingState&&"offer"===j.type&&j.service._sendCandidate(j.opponentId,j.iceCandidates)},n.prototype.onIceConnectionStateCallback=function(){("closed"===j.iceConnectionState||"disconnected"===j.iceConnectionState)&&(j=null)}),e.prototype={getUserJid:function(a,b){return a+"-"+b+"@"+l.endpoints.chat},getIdFromNode:function(a){return a.indexOf("@")<0?null:parseInt(a.split("@")[0].split("-")[0])}},b.exports=d,Blob.prototype.download=function(){k(this,this.name,this.type)}},{"../../lib/download/download.min":14,"../../lib/strophe/strophe.min":15,"../qbConfig":9,"../qbUtils":13}],9:[function(a,b,c){var d={version:"1.9.3",creds:{appId:"",authKey:"",authSecret:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com",turn:"turnserver.quickblox.com",s3Bucket:"qbprod"},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},iceServers:[{url:"stun:stun.l.google.com:19302"},{url:"stun:turn.quickblox.com",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=udp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"},{url:"turn:turn.quickblox.com:3478?transport=tcp",username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"}],urls:{session:"session",login:"login",users:"users",chat:"chat",blobs:"blobs",geodata:"geodata",places:"places",pushtokens:"push_tokens",subscriptions:"subscriptions",events:"events",data:"data",type:".json"},on:{sessionExpired:null},ssl:!0,timeout:null,debug:!1,addISOTime:!1};d.set=function(a){Object.keys(a).forEach(function(b){"set"!==b&&d.hasOwnProperty(b)&&("object"!=typeof a[b]?d[b]=a[b]:Object.keys(a[b]).forEach(function(c){d[b].hasOwnProperty(c)&&(d[b][c]=a[b][c])}))})},b.exports=d},{}],10:[function(a,b,c){function d(){}var e=a("./qbConfig"),f="undefined"!=typeof window;d.prototype={init:function(b,c,d,g){g&&"boolean"==typeof g?e.debug=g:g&&"object"==typeof g&&e.set(g);var h=a("./qbProxy");this.service=new h;var i=a("./modules/qbAuth"),j=a("./modules/qbUsers"),k=a("./modules/qbChat"),l=a("./modules/qbContent"),m=a("./modules/qbLocation"),n=a("./modules/qbMessages"),o=a("./modules/qbData");if(f){var p=a("./qbStrophe"),q=new p,r=a("./modules/qbWebRTC");this.webrtc=new r(this.service,q||null)}this.auth=new i(this.service),this.users=new j(this.service),this.chat=new k(this.service,this.webrtc||null,q||null),this.content=new l(this.service),this.location=new m(this.service),this.messages=new n(this.service),this.data=new o(this.service),"string"!=typeof b||c||d?(e.creds.appId=b,e.creds.authKey=c,e.creds.authSecret=d):this.service.setSession({token:b}),console&&e.debug&&console.log("QuickBlox.init",this)},getSession:function(a){this.auth.getSession(a)},createSession:function(a,b){this.auth.createSession(a,b)},destroySession:function(a){this.auth.destroySession(a)},login:function(a,b){this.auth.login(a,b)},logout:function(a){this.auth.logout(a)}};var g=new d;g.QuickBlox=d,b.exports=g},{"./modules/qbAuth":1,"./modules/qbChat":2,"./modules/qbContent":3,"./modules/qbData":4,"./modules/qbLocation":5,"./modules/qbMessages":6,"./modules/qbUsers":7,"./modules/qbWebRTC":8,"./qbConfig":9,"./qbProxy":11,"./qbStrophe":12}],11:[function(a,b,c){function d(){this.qbInst={config:e,session:null},e.debug&&console.log("ServiceProxy",this.qbInst)}var e=a("./qbConfig"),f=a("./qbUtils"),g=e.version,h="undefined"!=typeof window;if(!h)var i=a("request");var j=h&&window.jQuery&&window.jQuery.ajax||h&&window.Zepto&&window.Zepto.ajax;if(h&&!j)throw new Error("Quickblox requires jQuery or Zepto");d.prototype={setSession:function(a){this.qbInst.session=a},getSession:function(){return this.qbInst.session},handleResponse:function(a,b,c,d){!a||"function"!=typeof e.on.sessionExpired||"Unauthorized"!==a.message&&"401 Unauthorized"!==a.status?a?c(a,null):(e.addISOTime&&(b=f.injectISOTimes(b)),c(null,b)):e.on.sessionExpired(function(){c(a,b)},d)},ajax:function(a,b){e.debug&&console.log("ServiceProxy",a.type||"GET",a);var c=this,d=function(d){d&&c.setSession(d),c.ajax(a,b)},f={url:a.url,type:a.type||"GET",dataType:a.dataType||"json",data:a.data||" ",timeout:e.timeout,beforeSend:function(a,b){e.debug&&console.log("ServiceProxy.ajax beforeSend",a,b),-1===b.url.indexOf("://"+e.endpoints.s3Bucket)&&(e.debug&&console.log("setting headers on request to "+b.url),c.qbInst.session&&c.qbInst.session.token&&(a.setRequestHeader("QB-Token",c.qbInst.session.token),a.setRequestHeader("QB-SDK","JS "+g+" - Client")))},success:function(f,g,h){e.debug&&console.log("ServiceProxy.ajax success",f),-1===a.url.indexOf(e.urls.session)?c.handleResponse(null,f,b,d):b(null,f)},error:function(f,g,h){e.debug&&console.log("ServiceProxy.ajax error",f.status,h,f.responseText);var i={code:f.status,status:g,message:h,detail:f.responseText};-1===a.url.indexOf(e.urls.session)?c.handleResponse(i,null,b,d):b(i,null)}};if(!h)var k="json"===f.dataType,l=-1===a.url.indexOf("://"+e.endpoints.s3Bucket)&&c.qbInst&&c.qbInst.session&&c.qbInst.session.token||!1,m={url:f.url,method:f.type,timeout:e.timeout,json:k?f.data:null,form:k?null:f.data,headers:l?{"QB-Token":c.qbInst.session.token,"QB-SDK":"JS "+g+" - Server"}:null},n=function(a,f,g){if(a||200!==f.statusCode&&201!==f.statusCode&&202!==f.statusCode){var h;try{h={code:f&&f.statusCode||a&&a.code,status:f&&f.headers&&f.headers.status||"error",message:g||a&&a.errno,detail:g&&g.errors||a&&a.syscall}}catch(i){h=a}-1===m.url.indexOf(e.urls.session)?c.handleResponse(h,null,b,d):b(h,null)}else-1===m.url.indexOf(e.urls.session)?c.handleResponse(null,g,b,d):b(null,g)};("boolean"==typeof a.contentType||"string"==typeof a.contentType)&&(f.contentType=a.contentType),"boolean"==typeof a.processData&&(f.processData=a.processData),h?j(f):i(m,n)}},b.exports=d},{"./qbConfig":9,"./qbUtils":13,request:20}],12:[function(a,b,c){function d(){var a=1===e.chatProtocol.active?e.chatProtocol.bosh:e.chatProtocol.websocket,b=new Strophe.Connection(a);return 1===e.chatProtocol.active?(b.xmlInput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)console.log("[QBChat RECV]:",a.childNodes[b])},b.xmlOutput=function(a){if(a.childNodes[0])for(var b=0,c=a.childNodes.length;c>b;b++)console.log("[QBChat SENT]:",a.childNodes[b])}):(b.xmlInput=function(a){console.log("[QBChat RECV]:",a)},b.xmlOutput=function(a){console.log("[QBChat SENT]:",a)}),b}a("../lib/strophe/strophe.min");var e=a("./qbConfig");b.exports=d},{"../lib/strophe/strophe.min":15,"./qbConfig":9}],13:[function(a,b,c){var d=a("./qbConfig"),e={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0},f={randomNonce:function(){return Math.floor(1e4*Math.random())},unixTime:function(){return Math.floor(Date.now()/1e3)},getUrl:function(a,b){var c=d.ssl?"https://":"http://",e=b?"/"+b:"";return c+d.endpoints.api+"/"+a+e+d.urls.type},getBsonObjectId:function(){var a=this.unixTime().toString(16),b=(e.increment++).toString(16);return b>16777215&&(e.increment=0),"00000000".substr(0,8-a.length)+a+"000000".substr(0,6-e.machine.length)+e.machine+"0000".substr(0,4-e.pid.length)+e.pid+"000000".substr(0,6-b.length)+b},injectISOTimes:function(a){if(a.created_at)"number"==typeof a.created_at&&(a.iso_created_at=new Date(1e3*a.created_at).toISOString()),"number"==typeof a.updated_at&&(a.iso_updated_at=new Date(1e3*a.updated_at).toISOString());else if(a.items)for(var b=0,c=a.items.length;c>b;++b)"number"==typeof a.items[b].created_at&&(a.items[b].iso_created_at=new Date(1e3*a.items[b].created_at).toISOString()),"number"==typeof a.items[b].updated_at&&(a.items[b].iso_updated_at=new Date(1e3*a.items[b].updated_at).toISOString());return a}};b.exports=f},{"./qbConfig":9}],14:[function(a,b,c){function d(a,b,c){function d(a){var b=a.split(/[:;,]/),c=b[1],d="base64"==b[2]?atob:decodeURIComponent,e=d(b.pop()),f=e.length,g=0,h=new Uint8Array(f);for(g;f>g;++g)h[g]=e.charCodeAt(g);return new m([h],{type:c})}function e(a,b){if("download"in k)return k.href=a,k.setAttribute("download",p),k.innerHTML="downloading...",j.body.appendChild(k),setTimeout(function(){k.click(),j.body.removeChild(k),b===!0&&setTimeout(function(){f.URL.revokeObjectURL(k.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g),window.open(a)||confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=j.createElement("iframe");j.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,g)),c.src=a,setTimeout(function(){j.body.removeChild(c)},333)}var f=window,g="application/octet-stream",h=c||g,i=a,j=document,k=j.createElement("a"),l=function(a){return String(a)},m=f.Blob||f.MozBlob||f.WebKitBlob||l;m=m.call?m.bind(f):Blob;var n,o,p=b||"download";if("true"===String(this)&&(i=[i,h],h=i[0],i=i[1]),String(i).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(d(i),p):e(i);if(n=i instanceof m?i:new m([i],{type:h}),navigator.msSaveBlob)return navigator.msSaveBlob(n,p);if(f.URL)e(f.URL.createObjectURL(n),!0);else{if("string"==typeof n||n.constructor===l)try{return e("data:"+h+";base64,"+f.btoa(n))}catch(q){return e("data:"+h+","+encodeURIComponent(n))}o=new FileReader,o.onload=function(){e(this.result)},o.readAsDataURL(n)}return!0}b.exports=d},{}],15:[function(a,b,c){function d(a){return n(g(m(a),8*a.length))}function e(a,b){return o(j(a,b))}function f(a,b){return n(j(a,b))}function g(a,b){a[b>>5]|=128<<24-b%32,a[(b+64>>9<<4)+15]=b;var c,d,e,f,g,j,m,n,o=new Array(80),p=1732584193,q=-271733879,r=-1732584194,s=271733878,t=-1009589776;for(c=0;c<a.length;c+=16){for(f=p,g=q,j=r,m=s,n=t,d=0;80>d;d++)o[d]=16>d?a[c+d]:l(o[d-3]^o[d-8]^o[d-14]^o[d-16],1),e=k(k(l(p,5),h(d,q,r,s)),k(k(t,o[d]),i(d))),t=s,s=r,r=l(q,30),q=p,p=e;p=k(p,f),q=k(q,g),r=k(r,j),s=k(s,m),t=k(t,n)}return[p,q,r,s,t]}function h(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 i(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function j(a,b){var c=m(a);c.length>16&&(c=g(c,8*a.length));for(var d=new Array(16),e=new Array(16),f=0;16>f;f++)d[f]=909522486^c[f],e[f]=1549556828^c[f];var h=g(d.concat(m(b)),512+8*b.length);return g(e.concat(h),672)}function k(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function l(a,b){return a<<b|a>>>32-b}function m(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 n(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 o(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}var p=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)?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}(),q=function(){var a=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},b=function(a,b){return a<<b|a>>>32-b},c=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},d=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>c%32&255);return b},e=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},f=function(c,d,e,f,g,h){return a(b(a(a(d,c),a(f,h)),g),e)},g=function(a,b,c,d,e,g,h){return f(b&c|~b&d,a,b,e,g,h)},h=function(a,b,c,d,e,g,h){return f(b&d|c&~d,a,b,e,g,h)},i=function(a,b,c,d,e,g,h){return f(b^c^d,a,b,e,g,h)},j=function(a,b,c,d,e,g,h){return f(c^(b|~d),a,b,e,g,h)},k=function(b,c){b[c>>5]|=128<<c%32,b[(c+64>>>9<<4)+14]=c;for(var d,e,f,k,l=1732584193,m=-271733879,n=-1732584194,o=271733878,p=0;p<b.length;p+=16)d=l,e=m,f=n,k=o,l=g(l,m,n,o,b[p+0],7,-680876936),o=g(o,l,m,n,b[p+1],12,-389564586),n=g(n,o,l,m,b[p+2],17,606105819),m=g(m,n,o,l,b[p+3],22,-1044525330),l=g(l,m,n,o,b[p+4],7,-176418897),o=g(o,l,m,n,b[p+5],12,1200080426),n=g(n,o,l,m,b[p+6],17,-1473231341),m=g(m,n,o,l,b[p+7],22,-45705983),l=g(l,m,n,o,b[p+8],7,1770035416),o=g(o,l,m,n,b[p+9],12,-1958414417),n=g(n,o,l,m,b[p+10],17,-42063),m=g(m,n,o,l,b[p+11],22,-1990404162),l=g(l,m,n,o,b[p+12],7,1804603682),o=g(o,l,m,n,b[p+13],12,-40341101),n=g(n,o,l,m,b[p+14],17,-1502002290),m=g(m,n,o,l,b[p+15],22,1236535329),l=h(l,m,n,o,b[p+1],5,-165796510),o=h(o,l,m,n,b[p+6],9,-1069501632),n=h(n,o,l,m,b[p+11],14,643717713),m=h(m,n,o,l,b[p+0],20,-373897302),l=h(l,m,n,o,b[p+5],5,-701558691),o=h(o,l,m,n,b[p+10],9,38016083),n=h(n,o,l,m,b[p+15],14,-660478335),m=h(m,n,o,l,b[p+4],20,-405537848),l=h(l,m,n,o,b[p+9],5,568446438),o=h(o,l,m,n,b[p+14],9,-1019803690),n=h(n,o,l,m,b[p+3],14,-187363961),m=h(m,n,o,l,b[p+8],20,1163531501),l=h(l,m,n,o,b[p+13],5,-1444681467),o=h(o,l,m,n,b[p+2],9,-51403784),n=h(n,o,l,m,b[p+7],14,1735328473),m=h(m,n,o,l,b[p+12],20,-1926607734),l=i(l,m,n,o,b[p+5],4,-378558),o=i(o,l,m,n,b[p+8],11,-2022574463),n=i(n,o,l,m,b[p+11],16,1839030562),m=i(m,n,o,l,b[p+14],23,-35309556),l=i(l,m,n,o,b[p+1],4,-1530992060),o=i(o,l,m,n,b[p+4],11,1272893353),n=i(n,o,l,m,b[p+7],16,-155497632),m=i(m,n,o,l,b[p+10],23,-1094730640),l=i(l,m,n,o,b[p+13],4,681279174),o=i(o,l,m,n,b[p+0],11,-358537222),n=i(n,o,l,m,b[p+3],16,-722521979),m=i(m,n,o,l,b[p+6],23,76029189),l=i(l,m,n,o,b[p+9],4,-640364487),o=i(o,l,m,n,b[p+12],11,-421815835),n=i(n,o,l,m,b[p+15],16,530742520),m=i(m,n,o,l,b[p+2],23,-995338651),l=j(l,m,n,o,b[p+0],6,-198630844),o=j(o,l,m,n,b[p+7],10,1126891415),n=j(n,o,l,m,b[p+14],15,-1416354905),m=j(m,n,o,l,b[p+5],21,-57434055),l=j(l,m,n,o,b[p+12],6,1700485571),o=j(o,l,m,n,b[p+3],10,-1894986606),n=j(n,o,l,m,b[p+10],15,-1051523),m=j(m,n,o,l,b[p+1],21,-2054922799),l=j(l,m,n,o,b[p+8],6,1873313359),o=j(o,l,m,n,b[p+15],10,-30611744),n=j(n,o,l,m,b[p+6],15,-1560198380),m=j(m,n,o,l,b[p+13],21,1309151649),l=j(l,m,n,o,b[p+4],6,-145523070),o=j(o,l,m,n,b[p+11],10,-1120210379),n=j(n,o,l,m,b[p+2],15,718787259),m=j(m,n,o,l,b[p+9],21,-343485551),l=a(l,d),m=a(m,e),n=a(n,f),o=a(o,k);return[l,m,n,o]},l={hexdigest:function(a){return e(k(c(a),8*a.length))},hash:function(a){return d(k(c(a),8*a.length))}};return l}();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.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){function b(a,b){return new i.Builder(a,b)}function c(a){return new i.Builder("message",a)}function g(a){return new i.Builder("iq",a)}function h(a){return new i.Builder("presence",a)}var i;i={VERSION:"1.1.3",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",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<i.XHTML.tags.length;b++)if(a==i.XHTML.tags[b])return!0;return!1},validAttribute:function(a,b){if("undefined"!=typeof i.XHTML.attributes[a]&&i.XHTML.attributes[a].length>0)for(var c=0;c<i.XHTML.attributes[a].length;c++)if(b==i.XHTML.attributes[a][c])return!0;return!1},validCSS:function(a){for(var b=0;b<i.XHTML.css.length;b++)if(a==i.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},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){i.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!=i.ElementType.NORMAL||b&&!this.isTagEqual(e,b)||c(e)},isTagEqual:function(a,b){return a.tagName.toLowerCase()==b.toLowerCase()},_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 i._xmlGenerator||(i._xmlGenerator=i._makeGenerator()),i._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=i.xmlGenerator().createElement(a);for(b=1;b<arguments.length;b++)if(arguments[b])if("string"==typeof arguments[b]||"number"==typeof arguments[b])e.appendChild(i.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,"&"),a=a.replace(/</g,"<"),a=a.replace(/>/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,""")},xmlunescape:function(a){return a=a.replace(/\&/g,"&"),a=a.replace(/</g,"<"),a=a.replace(/>/g,">"),a=a.replace(/'/g,"'"),a=a.replace(/"/g,'"')},xmlTextNode:function(a){return i.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==i.ElementType.TEXT&&(b+=a.nodeValue);for(var c=0;c<a.childNodes.length;c++)a.childNodes[c].nodeType==i.ElementType.TEXT&&(b+=a.childNodes[c].nodeValue);return i.xmlescape(b)},copyElement:function(a){var b,c;if(a.nodeType==i.ElementType.NORMAL){for(c=i.xmlElement(a.tagName),b=0;b<a.attributes.length;b++)c.setAttribute(a.attributes[b].nodeName.toLowerCase(),a.attributes[b].value);for(b=0;b<a.childNodes.length;b++)c.appendChild(i.copyElement(a.childNodes[b]))}else a.nodeType==i.ElementType.TEXT&&(c=i.xmlGenerator().createTextNode(a.nodeValue));return c},createHtml:function(a){var b,c,d,e,f,g,h,j,k,l,m;if(a.nodeType==i.ElementType.NORMAL)if(e=a.nodeName.toLowerCase(),i.XHTML.validTag(e))try{for(c=i.xmlElement(e),b=0;b<i.XHTML.attributes[e].length;b++)if(f=i.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(h=[],j=g.split(";"),d=0;d<j.length;d++)k=j[d].split(":"),l=k[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase(),i.XHTML.validCSS(l)&&(m=k[1].replace(/^\s*/,"").replace(/\s*$/,""),h.push(l+": "+m));h.length>0&&(g=h.join("; "),c.setAttribute(f,g))}else c.setAttribute(f,g);for(b=0;b<a.childNodes.length;b++)c.appendChild(i.createHtml(a.childNodes[b]))}catch(n){c=i.xmlTextNode("")}else for(c=i.xmlGenerator().createDocumentFragment(),b=0;b<a.childNodes.length;b++)c.appendChild(i.createHtml(a.childNodes[b]));else if(a.nodeType==i.ElementType.FRAGMENT)for(c=i.xmlGenerator().createDocumentFragment(),b=0;b<a.childNodes.length;b++)c.appendChild(i.createHtml(a.childNodes[b]));else a.nodeType==i.ElementType.TEXT&&(c=i.xmlTextNode(a.nodeValue));return c},escapeNode:function(a){return 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 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=i.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(){},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.toLowerCase()+"='"+a.attributes[c].value.replace(/&/g,"&").replace(/\'/g,"'").replace(/>/g,">").replace(/</g,"<")+"'");if(a.childNodes.length>0){for(b+=">",c=0;c<a.childNodes.length;c++)switch(d=a.childNodes[c],d.nodeType){case i.ElementType.NORMAL:b+=i.serialize(d);break;case i.ElementType.TEXT:b+=i.xmlescape(d.nodeValue);break;case i.ElementType.CDATA:b+="<![CDATA["+d.nodeValue+"]]>"}b+="</"+e+">"}else b+="/>";return b},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(a,b){i._connectionPlugins[a]=b}},i.Builder=function(a,b){("presence"==a||"message"==a||"iq"==a)&&(b&&!b.xmlns?b.xmlns=i.NS.CLIENT:b||(b={xmlns:i.NS.CLIENT})),this.nodeTree=i.xmlElement(a,b),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(a){for(var b in a)a.hasOwnProperty(b)&&this.node.setAttribute(b,a[b]);return this},c:function(a,b,c){var d=i.xmlElement(a,b,c);return this.node.appendChild(d),c||(this.node=d),this},cnode:function(a){var b,c=i.xmlGenerator();try{b=void 0!==c.importNode}catch(d){b=!1}var e=b?c.importNode(a,!0):i.copyElement(a);return this.node.appendChild(e),this.node=e,this},t:function(a){var b=i.xmlTextNode(a);return this.node.appendChild(b),this},h:function(a){var b=document.createElement("body");b.innerHTML=a;for(var c=i.createHtml(b);c.childNodes.length>0;)this.node.appendChild(c.childNodes[0]);return this}},i.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.from=this.options.matchBare?f?i.getBareJidFromJid(f):null:f,this.user=!0},i.Handler.prototype={isMatch:function(a){var b,c=null;if(c=this.options.matchBare?i.getBareJidFromJid(a.getAttribute("from")):a.getAttribute("from"),b=!1,this.ns){var d=this;i.forEachChild(a,null,function(a){a.getAttribute("xmlns")==d.ns&&(b=!0)}),b=b||a.getAttribute("xmlns")==this.ns}else b=!0;return!b||this.name&&!i.isTagEqual(a,this.name)||this.type&&a.getAttribute("type")!=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?i.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)),i.fatal("error: "+this.handler+" "+c.fileName+":"+c.lineNumber+" - "+c.name+": "+c.message)):i.fatal("error: "+c.message+"\n"+c.stack),c}return b},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},i.TimedHandler=function(a,b){this.period=a,this.handler=b,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(a,b){this.service=a,this.options=b||{};var c=this.options.protocol||"";this._proto=0===a.indexOf("ws:")||0===a.indexOf("wss:")||0===c.indexOf("ws")?new i.Websocket(this):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.do_authentication=!0,this.authenticated=!1,this.disconnecting=!1,this.connected=!1,this.errors=0,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 i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(d)){var e=i._connectionPlugins[d],f=function(){};f.prototype=e,this[d]=new f,this[d].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.disconnecting=!1,this.connected=!1,this.errors=0,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){this.jid=a,this.authzid=i.getBareJidFromJid(this.jid),this.authcid=i.getNodeFromJid(this.jid),this.pass=b,this.servtype="xmpp",this.connect_callback=c,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.errors=0,this.domain=i.getDomainFromJid(this.jid),this._changeConnectStatus(i.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(){},xmlOutput:function(){},rawInput:function(){},rawOutput:function(){},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 h=this.addHandler(function(a){e&&f.deleteTimedHandler(e);var d=a.getAttribute("type");if("result"==d)b&&b(a);else{if("error"!=d)throw{name:"StropheError",message:"Got bad IQ type of "+d};c&&c(a)}},null,"iq",null,g);return d&&(e=this.addTimedHandler(d,function(){return f.deleteHandler(h),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 i.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 h=new i.Handler(a,b,c,d,e,f,g);return this.addHandlers.push(h),h},deleteHandler:function(a){this.removeHandlers.push(a)},disconnect:function(a){if(this._changeConnectStatus(i.Status.DISCONNECTING,a),i.info("Disconnect was called because: "+a),this.connected){var b=!1;this.disconnecting=!0,this.authenticated&&(b=h({xmlns:i.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(b)}},_changeConnectStatus:function(a,b){for(var c in i._connectionPlugins)if(i._connectionPlugins.hasOwnProperty(c)){var d=this[c];if(d.statusChanged)try{d.statusChanged(a,b)}catch(e){i.error(""+c+" plugin caused an exception changing status: "+e)}}if(this.connect_callback)try{this.connect_callback(a,b)}catch(f){i.error("User connection callback caused an exception: "+f)}},_doDisconnect:function(){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.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(i.Status.DISCONNECTED,null),this.connected=!1},_dataRecv:function(a,b){i.info("_dataRecv called");var c=this._proto._reqToData(a);if(null!==c){this.xmlInput!==i.Connection.prototype.xmlInput&&this.xmlInput(c.nodeName===this._proto.strip&&c.childNodes.length?c.childNodes[0]:c),this.rawInput!==i.Connection.prototype.rawInput&&this.rawInput(b?b:i.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,h=c.getAttribute("type");if(null!==h&&"terminate"==h){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(i.Status.CONNFAIL,f)):this._changeConnectStatus(i.Status.CONNFAIL,"unknown"),void this.disconnect("unknown stream-error")}var j=this;i.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){i.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}}})}},mechanisms:{},_connect_cb:function(a,b,c){i.info("_connect_cb was called"),this.connected=!0;var d=this._proto._reqToData(a);if(d){this.xmlInput!==i.Connection.prototype.xmlInput&&this.xmlInput(d.nodeName===this._proto.strip&&d.childNodes.length?d.childNodes[0]:d),this.rawInput!==i.Connection.prototype.rawInput&&this.rawInput(c?c:i.serialize(d));var e=this._proto._connect_cb(d);if(e!==i.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=d.getElementsByTagName("stream:features").length>0;f||(f=d.getElementsByTagName("features").length>0);var g,h,j=d.getElementsByTagName("mechanism"),k=[],l=!1;if(!f)return void this._proto._no_auth_received(b);if(j.length>0)for(g=0;g<j.length;g++)h=i.getText(j[g]),this.mechanisms[h]&&k.push(this.mechanisms[h]);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 d=c,e=c+1;e<a.length;++e)a[e].prototype.priority>a[d].prototype.priority&&(d=e);if(d!=c){var f=a[c];a[c]=a[d],a[d]=f}}var h=!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 j=b("auth",{xmlns:i.NS.SASL,mechanism:this._sasl_mechanism.name});if(this._sasl_mechanism.isClientFirst){var k=this._sasl_mechanism.onChallenge(this,null);j.t(p.encode(k))}this.send(j.tree()),h=!0;break}h||(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(g({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(a){var c=p.decode(i.getText(a)),d=this._sasl_mechanism.onChallenge(this,c),e=b("response",{xmlns:i.NS.SASL});return""!==d&&e.t(p.encode(d)),this.send(e.tree()),!0},_auth1_cb:function(){var a=g({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"),a.up().c("resource",{}).t(i.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(a.tree()),!1},_sasl_success_cb:function(a){if(this._sasl_data["server-signature"]){var b,c=p.decode(i.getText(a)),d=/([a-z]+)=([^,]+)(,|$)/,e=c.match(d);if("v"==e[1]&&(b=e[2]),b!=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)}return 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),this._addSysHandler(this._sasl_auth1_cb.bind(this),null,"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(i.Status.AUTHFAIL,null),!1;this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var d=i.getResourceFromJid(this.jid);return this.send(d?g({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:i.NS.BIND}).c("resource",{}).t(d).tree():g({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:i.NS.BIND}).tree()),!1},_sasl_bind_cb:function(a){if("error"==a.getAttribute("type")){i.info("SASL binding failed.");var b,c=a.getElementsByTagName("conflict");return c.length>0&&(b="conflict"),this._changeConnectStatus(i.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=i.getText(d[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(g({type:"set",id:"_session_auth_2"}).c("session",{xmlns:i.NS.SESSION}).tree())):(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null))))):(i.info("SASL binding failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1)},_sasl_session_cb:function(a){if("result"==a.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null);else if("error"==a.getAttribute("type"))return i.info("Session creation failed."),this._changeConnectStatus(i.Status.AUTHFAIL,null),!1;return!1},_sasl_failure_cb:function(){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(a){return"result"==a.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(i.Status.CONNECTED,null)):"error"==a.getAttribute("type")&&(this._changeConnectStatus(i.Status.AUTHFAIL,null),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(a,b){var c=new i.TimedHandler(a,b);return c.user=!1,this.addTimeds.push(c),c},_addSysHandler:function(a,b,c,d,e){var f=new i.Handler(a,b,c,d,e);return f.user=!1,this.addHandlers.push(f),f},_onDisconnectTimeout:function(){return i.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))}},a&&a(i,b,c,g,h),i.SASLMechanism=function(a,b,c){this.name=a,this.isClientFirst=b,this.priority=c},i.SASLMechanism.prototype={test:function(){return!0},onStart:function(a){this._connection=a},onChallenge:function(){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(a){return null===a.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(a){return null!==a.authcid},i.SASLPlain.prototype.onChallenge=function(a){var b=a.authzid;return b+="\x00",b+=a.authcid,b+="\x00",b+=a.pass},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(a){return null!==a.authcid},i.SASLSHA1.prototype.onChallenge=function(a,b,c){var g=c||q.hexdigest(1234567890*Math.random()),h="n="+a.authcid;return h+=",r=",h+=g,a._sasl_data.cnonce=g,a._sasl_data["client-first-message-bare"]=h,h="n,,"+h,this.onChallenge=function(a,b){for(var c,g,h,i,k,l,m,o,q,r,s,t="c=biws,",u=a._sasl_data["client-first-message-bare"]+","+b+",",v=a._sasl_data.cnonce,w=/([a-z]+)=([^,]+)(,|$)/;b.match(w);){var x=b.match(w);switch(b=b.replace(x[0],""),x[1]){case"r":c=x[2];break;case"s":g=x[2];break;case"i":h=x[2]}}if(c.substr(0,v.length)!==v)return a._sasl_data={},a._sasl_failure_cb();for(t+="r="+c,u+=t,g=p.decode(g),g+="\x00\x00\x00",i=l=j(a.pass,g),m=1;h>m;m++){for(k=j(a.pass,n(l)),o=0;5>o;o++)i[o]^=k[o];l=k}for(i=n(i),q=j(i,"Client Key"),r=f(i,"Server Key"),s=j(d(n(q)),u),a._sasl_data["server-signature"]=e(r,u),o=0;5>o;o++)q[o]^=s[o];return t+=",p="+p.encode(n(q))}.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(a){return null!==a.authcid},i.SASLMD5.prototype._quote=function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},i.SASLMD5.prototype.onChallenge=function(a,b,c){for(var d,e=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,f=c||q.hexdigest(""+1234567890*Math.random()),g="",h=null,i="",j="";b.match(e);)switch(d=b.match(e),b=b.replace(d[0],""),d[2]=d[2].replace(/^"(.+)"$/,"$1"),d[1]){case"realm":g=d[2];break;case"nonce":i=d[2];break;case"qop":j=d[2];break;case"host":h=d[2]}var k=a.servtype+"/"+a.domain;null!==h&&(k=k+"/"+h);var l=q.hash(a.authcid+":"+g+":"+this._connection.pass)+":"+i+":"+f,m="AUTHENTICATE:"+k,n="";return n+="charset=utf-8,",n+="username="+this._quote(a.authcid)+",",n+="realm="+this._quote(g)+",",n+="nonce="+this._quote(i)+",",n+="nc=00000001,",n+="cnonce="+this._quote(f)+",",n+="digest-uri="+this._quote(k)+",",n+="response="+q.hexdigest(q.hexdigest(l)+":"+i+":00000001:"+f+":auth:"+q.hexdigest(m))+",",n+="qop=auth",this.onChallenge=function(){return""}.bind(this),n},i.Connection.prototype.mechanisms[i.SASLMD5.prototype.name]=i.SASLMD5}(function(){window.Strophe=arguments[0],window.$build=arguments[1],window.$msg=arguments[2],window.$iq=arguments[3],window.$pres=arguments[4]}),Strophe.Request=function(a,b,c,d){this.id=++Strophe._requestId,this.xmlData=a,this.data=Strophe.serialize(a),this.origFunc=b,this.func=b,this.rid=c,this.date=NaN,this.sends=d||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()},Strophe.Request.prototype={getResponse:function(){var a=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(a=this.xhr.responseXML.documentElement,"parsererror"==a.tagName)throw Strophe.error("invalid response received"),Strophe.error("responseText: "+this.xhr.responseText),Strophe.error("responseXML: "+Strophe.serialize(this.xhr.responseXML)),"parsererror"}else this.xhr.responseText&&(Strophe.error("invalid response received"),Strophe.error("responseText: "+this.xhr.responseText),Strophe.error("responseXML: "+Strophe.serialize(this.xhr.responseXML)));return a},_newXHR:function(){var a=null;return window.XMLHttpRequest?(a=new XMLHttpRequest,a.overrideMimeType&&a.overrideMimeType("text/xml")):window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP")),a.onreadystatechange=this.func.bind(null,this),a}},Strophe.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._requests=[]},Strophe.Bosh.prototype={strip:null,_buildBody:function(){var a=$build("body",{rid:this.rid++,xmlns:Strophe.NS.HTTPBIND});return null!==this.sid&&a.attrs({sid:this.sid}),a},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null},_connect:function(a,b,c){this.wait=a||this.wait,this.hold=b||this.hold;var d=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":Strophe.NS.BOSH});c&&d.attrs({route:c});var e=this._conn._connect_cb;this._requests.push(new Strophe.Request(d.tree(),this._onRequestStateChange.bind(this,e.bind(this._conn)),d.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(a,b,c,d,e,f,g){this._conn.jid=a,this.sid=b,this.rid=c,this._conn.connect_callback=d,this._conn.domain=Strophe.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=e||this.wait,this.hold=f||this.hold,this.window=g||this.window,this._conn._changeConnectStatus(Strophe.Status.ATTACHED,null)},_connect_cb:function(a){var b,c,d=a.getAttribute("type");if(null!==d&&"terminate"==d)return Strophe.error("BOSH-Connection failed: "+b),b=a.getAttribute("condition"),c=a.getElementsByTagName("conflict"),null!==b?("remote-stream-error"==b&&c.length>0&&(b="conflict"),this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,b)):this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(),Strophe.Status.CONNFAIL;this.sid||(this.sid=a.getAttribute("sid"));var e=a.getAttribute("requests");e&&(this.window=parseInt(e,10));var f=a.getAttribute("hold");f&&(this.hold=parseInt(f,10));var g=a.getAttribute("wait");g&&(this.wait=parseInt(g,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(a){this.errors++,Strophe.warn("request errored, status: "+a+", number of errors: "+this.errors),this.errors>4&&this._onDisconnectTimeout()},_no_auth_received:function(a){a=a?a.bind(this._conn):this._conn._connect_cb.bind(this._conn);var b=this._buildBody();this._requests.push(new Strophe.Request(b.tree(),this._onRequestStateChange.bind(this,a.bind(this._conn)),b.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout: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 a=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===a.length&&!this._conn.disconnecting&&(Strophe.info("no requests during idle cycle, sending blank request"),a.push(null)),this._requests.length<2&&a.length>0&&!this._conn.paused){for(var b=this._buildBody(),c=0;c<a.length;c++)null!==a[c]&&("restart"===a[c]?b.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":Strophe.NS.BOSH}):b.cnode(a[c]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new Strophe.Request(b.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),b.tree().getAttribute("rid"))),this._processRequest(this._requests.length-1)}if(this._requests.length>0){var d=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),d>Math.floor(Strophe.TIMEOUT*this.wait)&&(Strophe.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(Strophe.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}},_onRequestStateChange:function(a,b){if(Strophe.debug("request id "+b.id+"."+b.sends+" state changed to "+b.xhr.readyState),b.abort)return void(b.abort=!1);var c;if(4==b.xhr.readyState){c=0;try{c=b.xhr.status}catch(d){}if("undefined"==typeof c&&(c=0),this.disconnecting&&c>=400)return void this._hitError(c);var e=this._requests[0]==b,f=this._requests[1]==b;(c>0&&500>c||b.sends>5)&&(this._removeRequest(b),Strophe.debug("request id "+b.id+" should now be removed")),200==c?((f||e&&this._requests.length>0&&this._requests[0].age()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),Strophe.debug("request id "+b.id+"."+b.sends+" got 200"),a(b),this.errors=0):(Strophe.error("request id "+b.id+"."+b.sends+" error "+c+" happened"),(0===c||c>=400&&600>c||c>=12e3)&&(this._hitError(c),c>=400&&500>c&&(this._conn._changeConnectStatus(Strophe.Status.DISCONNECTING,null),this._conn._doDisconnect()))),c>0&&500>c||b.sends>5||this._throttledRequestHandler()}},_processRequest:function(a){var b=this,c=this._requests[a],d=-1;try{4==c.xhr.readyState&&(d=c.xhr.status)}catch(e){Strophe.error("caught an error in _requests["+a+"], reqStatus: "+d)}if("undefined"==typeof d&&(d=-1),c.sends>this.maxRetries)return void this._onDisconnectTimeout();var f=c.age(),g=!isNaN(f)&&f>Math.floor(Strophe.TIMEOUT*this.wait),h=null!==c.dead&&c.timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait),i=4==c.xhr.readyState&&(1>d||d>=500);if((g||h||i)&&(h&&Strophe.error("Request "+this._requests[a].id+" timed out (secondary), restarting"),c.abort=!0,c.xhr.abort(),c.xhr.onreadystatechange=function(){},this._requests[a]=new Strophe.Request(c.xmlData,c.origFunc,c.rid,c.sends),c=this._requests[a]),0===c.xhr.readyState){Strophe.debug("request id "+c.id+"."+c.sends+" posting");try{c.xhr.open("POST",this._conn.service,this._conn.options.sync?!1:!0)}catch(j){return Strophe.error("XHR open failed."),this._conn.connected||this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var k=function(){if(c.date=new Date,b._conn.options.customHeaders){var a=b._conn.options.customHeaders;for(var d in a)a.hasOwnProperty(d)&&c.xhr.setRequestHeader(d,a[d])}c.xhr.setRequestHeader("Content-Type","text/plain"),c.xhr.send(c.data)};if(c.sends>1){var l=1e3*Math.min(Math.floor(Strophe.TIMEOUT*this.wait),Math.pow(c.sends,3));setTimeout(k,l)}else k();c.sends++,this._conn.xmlOutput!==Strophe.Connection.prototype.xmlOutput&&this._conn.xmlOutput(c.xmlData.nodeName===this.strip&&c.xmlData.childNodes.length?c.xmlData.childNodes[0]:c.xmlData),this._conn.rawOutput!==Strophe.Connection.prototype.rawOutput&&this._conn.rawOutput(c.data)}else Strophe.debug("_processRequest: "+(0===a?"first":"second")+" request has readyState of "+c.xhr.readyState)},_removeRequest:function(a){Strophe.debug("removing request");var b;for(b=this._requests.length-1;b>=0;b--)a==this._requests[b]&&this._requests.splice(b,1);a.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(a){Strophe.info("_sendTerminate was called");var b=this._buildBody().attrs({type:"terminate"});a&&b.cnode(a.tree());var c=new Strophe.Request(b.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),b.tree().getAttribute("rid"));this._requests.push(c),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(){Strophe.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))}},Strophe.Websocket=function(a){this._conn=a,this.strip="stream:stream";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}},Strophe.Websocket.prototype={_buildStream:function(){return $build("stream:stream",{to:this._conn.domain,xmlns:Strophe.NS.CLIENT,"xmlns:stream":Strophe.NS.STREAM,version:"1.0"})},_check_streamerror:function(a,b){var c=a.getElementsByTagName("stream:error");if(0===c.length)return!1;for(var d=c[0],e="",f="",g="urn:ietf:params:xml:ns:xmpp-streams",h=0;h<d.childNodes.length;h++){var i=d.childNodes[h];if(i.getAttribute("xmlns")!==g)break;"text"===i.nodeName?f=i.textContent:e=i.nodeName}var j="WebSocket stream error: ";return j+=e?e:"unknown",f&&(j+=" - "+e),Strophe.error(j),this._conn._changeConnectStatus(b,e),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(a){var b=this._check_streamerror(a,Strophe.Status.CONNFAIL);return b?Strophe.Status.CONNFAIL:void 0},_handleStreamStart:function(a){var b=!1,c=a.getAttribute("xmlns");"string"!=typeof c?b="Missing xmlns in stream:stream":c!==Strophe.NS.CLIENT&&(b="Wrong xmlns in stream:stream: "+c);var d=a.namespaceURI;"string"!=typeof d?b="Missing xmlns:stream in stream:stream":d!==Strophe.NS.STREAM&&(b="Wrong xmlns:stream in stream:stream: "+d);var e=a.getAttribute("version");return"string"!=typeof e?b="Missing version in stream:stream":"1.0"!==e&&(b="Wrong version in stream:stream: "+e),b?(this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,b),this._conn._doDisconnect(),!1):!0},_connect_cb_wrapper:function(a){if(0===a.data.indexOf("<stream:stream ")||0===a.data.indexOf("<?xml")){var b=a.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===b)return;b=a.data.replace(/<stream:stream (.*[^\/])>/,"<stream:stream $1/>");var c=(new DOMParser).parseFromString(b,"text/xml").documentElement;this._conn.xmlInput(c),this._conn.rawInput(a.data),this._handleStreamStart(c)&&(this._connect_cb(c),this.streamStart=a.data.replace(/^<stream:(.*)\/>$/,"<stream:$1>"))}else{if("</stream:stream>"===a.data)return this._conn.rawInput(a.data),this._conn.xmlInput(document.createElement("stream:stream")),this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,"Received closing stream"),void this._conn._doDisconnect();var d=this._streamWrap(a.data),e=(new DOMParser).parseFromString(d,"text/xml").documentElement;this.socket.onmessage=this._onMessage.bind(this),this._conn._connect_cb(e,null,a.data)}},_disconnect:function(a){if(this.socket.readyState!==WebSocket.CLOSED){a&&this._conn.send(a);var b="</stream:stream>";this._conn.xmlOutput(document.createElement("stream:stream")),this._conn.rawOutput(b);try{this.socket.send(b)}catch(c){Strophe.info("Couldn't send closing stream tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){Strophe.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(a){return this.streamStart+a+"</stream:stream>"},_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?(Strophe.error("Websocket closed unexcectedly"),this._conn._doDisconnect()):Strophe.info("Websocket closed")},_no_auth_received:function(a){Strophe.error("Server did not send any auth methods"),this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,"Server did not send any auth methods"),a&&(a=a.bind(this._conn))(),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_onError:function(a){Strophe.error("Websocket error "+a),this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,"The WebSocket connection could not be established was disconnected."),this._disconnect()},_onIdle:function(){var a=this._conn._data;if(a.length>0&&!this._conn.paused){for(var b=0;b<a.length;b++)if(null!==a[b]){var c,d;"restart"===a[b]?(c=this._buildStream(),d=this._removeClosingTag(c),c=c.tree()):(c=a[b],d=Strophe.serialize(c)),this._conn.xmlOutput(c),this._conn.rawOutput(d),this.socket.send(d)}this._conn._data=[]}},_onMessage:function(a){var b,c;if("</stream:stream>"===a.data){var d="</stream:stream>";return this._conn.rawInput(d),this._conn.xmlInput(document.createElement("stream:stream")),void(this._conn.disconnecting||this._conn._doDisconnect())}if(0===a.data.search("<stream:stream ")){if(c=a.data.replace(/<stream:stream (.*[^\/])>/,"<stream:stream $1/>"),b=(new DOMParser).parseFromString(c,"text/xml").documentElement,!this._handleStreamStart(b))return}else c=this._streamWrap(a.data),b=(new DOMParser).parseFromString(c,"text/xml").documentElement;return this._check_streamerror(b,Strophe.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===b.firstChild.nodeName&&"unavailable"===b.firstChild.getAttribute("type")?(this._conn.xmlInput(b),void this._conn.rawInput(Strophe.serialize(b))):void this._conn._dataRecv(b,a.data)},_onOpen:function(){Strophe.info("Websocket open");var a=this._buildStream();this._conn.xmlOutput(a.tree());var b=this._removeClosingTag(a);this._conn.rawOutput(b),this.socket.send(b)},_removeClosingTag:function(a){var b=Strophe.serialize(a);return b=b.replace(/<(stream:stream .*[^\/])\/>$/,"<$1>")},_reqToData:function(a){return a},_send:function(){this._conn.flush()},_sendRestart:function(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}}},{}],16:[function(b,c,d){!function(b,e){"object"==typeof d?c.exports=d=e():"function"==typeof a&&a.amd?a([],e):b.CryptoJS=e()}(this,function(){var a=a||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)}),c.init.prototype=c,c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,e=a.sigBytes;if(this.clamp(),d%4)for(var f=0;e>f;f++){var g=255&c[f>>>2]>>>24-8*(f%4);b[d+f>>>2]|=g<<24-8*((d+f)%4)}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(0|4294967296*a.random());return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=255&b[e>>>2]>>>24-8*(e%4);d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new l.HMAC.init(a,c).finalize(b)}}});var l=c.algo={};return c}(Math);return a})},{}],17:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core"),b("./sha1"),b("./hmac")):"function"==typeof a&&a.amd?a(["./core","./sha1","./hmac"],f):f(e.CryptoJS)}(this,function(a){return a.HmacSHA1})},{"./core":16,"./hmac":18,"./sha1":19}],18:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){!function(){var b=a,c=b.lib,d=c.Base,e=b.enc,f=e.Utf8,g=b.algo;g.HMAC=d.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=f.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),g=this._iKey=b.clone(),h=e.words,i=g.words,j=0;c>j;j++)h[j]^=1549556828,i[j]^=909522486;e.sigBytes=g.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher,c=b.finalize(a);b.reset();var d=b.finalize(this._oKey.clone().concat(c));return d}})}()})},{"./core":16}],19:[function(b,c,d){!function(e,f){"object"==typeof d?c.exports=d=f(b("./core")):"function"==typeof a&&a.amd?a(["./core"],f):f(e.CryptoJS)}(this,function(a){return function(){var b=a,c=b.lib,d=c.WordArray,e=c.Hasher,f=b.algo,g=[],h=f.SHA1=e.extend({_doReset:function(){this._hash=new d.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)g[j]=0|a[b+j];else{var k=g[j-3]^g[j-8]^g[j-14]^g[j-16];g[j]=k<<1|k>>>31}var l=(d<<5|d>>>27)+i+g[j];l+=20>j?(e&f|~e&h)+1518500249:40>j?(e^f^h)+1859775393:60>j?(e&f|e&h|f&h)-1894007588:(e^f^h)-899497514,
i=h,h=f,f=e<<30|e>>>2,e=d,d=l}c[0]=0|c[0]+d,c[1]=0|c[1]+e,c[2]=0|c[2]+f,c[3]=0|c[3]+h,c[4]=0|c[4]+i},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA1=e._createHelper(h),b.HmacSHA1=e._createHmacHelper(h)}(),a.SHA1})},{"./core":16}],20:[function(a,b,c){},{}]},{},[10])(10)});