From 3924bdd74f686c4ed1325e9b9bd3e0a63e969071 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 24 Sep 2013 02:05:10 -0700 Subject: [PATCH] Add and track pending state for messages. --- clientapp/helpers/xmppEventHandlers.js | 16 +++++++++++++++- clientapp/libraries/stanza.io.js | 2 +- clientapp/models/contact.js | 3 ++- clientapp/models/message.js | 9 ++++++++- clientapp/models/messages.js | 11 +---------- clientapp/views/message.js | 2 +- public/css/app/chat.styl | 3 +++ public/css/otalk.css | 3 +++ 8 files changed, 34 insertions(+), 15 deletions(-) diff --git a/clientapp/helpers/xmppEventHandlers.js b/clientapp/helpers/xmppEventHandlers.js index dff24a8..2cc2b9a 100644 --- a/clientapp/helpers/xmppEventHandlers.js +++ b/clientapp/helpers/xmppEventHandlers.js @@ -248,6 +248,7 @@ module.exports = function (client, app) { }); } + message.acked = true; contact.addMessage(message, true); contact.lockedResource = msg.from.full; } @@ -262,6 +263,7 @@ module.exports = function (client, app) { } var message = new Message(msg); + message.acked = true; contact.addMessage(message, true); } }); @@ -278,7 +280,7 @@ module.exports = function (client, app) { original.correct(msg); }); - + client.on('carbon:received', function (carbon) { if (!me.isMe(carbon.from)) return; @@ -317,4 +319,16 @@ module.exports = function (client, app) { discoCapsQueue.push(pres); } }); + + client.on('stanza:acked', function (stanza) { + if (stanza.body) { + var contact = me.getContact(stanza.to, stanza.from); + if (contact) { + var msg = contact.messages.get(stanza.id); + if (msg) { + msg.acked = true; + } + } + } + }); }; diff --git a/clientapp/libraries/stanza.io.js b/clientapp/libraries/stanza.io.js index d28e19f..fa73809 100644 --- a/clientapp/libraries/stanza.io.js +++ b/clientapp/libraries/stanza.io.js @@ -1,5 +1,5 @@ !function(t){if("function"==typeof bootstrap)bootstrap("xmpp",t);else if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeXMPP=t}else"undefined"!=typeof window?window.XMPP=t():global.XMPP=t()}(function(){var t;return function(t,e,n){function r(n,o){if(!e[n]){if(!t[n]){var a="function"==typeof require&&require;if(!o&&a)return a(n,!0);if(i)return i(n,!0);throw new Error("Cannot find module '"+n+"'")}var s=e[n]={exports:{}};t[n][0].call(s.exports,function(e){var i=t[n][1][e];return r(i?i:e)},s,s.exports)}return e[n].exports}for(var i="function"==typeof require&&require,o=0;o0?this.jid.slice(0,t):this.jid,this.parts.bare},get resource(){if(this.parts.resource)return this.parts.resource;var t=this.jid.indexOf("/");return this.parts.resource=t>0?this.jid.slice(t+1):"",this.parts.resource},get local(){if(this.parts.local)return this.parts.local;var t=this.bare,e=t.indexOf("@");return this.parts.local=e>0?t.slice(0,e):t,this.parts.local},get domain(){if(this.parts.domain)return this.parts.domain;var t=this.bare,e=t.indexOf("@");return this.parts.domain=e>0?t.slice(e+1):t,this.parts.domain}},e.exports=n},{}],4:[function(t,e){e.exports=function(t){t.disco.addFeature("urn:xmpp:attention:0"),t.getAttention=function(e,n){n=n||{},n.to=e,n.type="headline",n.attention=!0,t.sendMessage(n)},t.on("message",function(e){e._extensions._attention&&t.emit("attention",e)})}},{}],5:[function(t,e){t("../stanza/avatar"),e.exports=function(t){t.disco.addFeature("urn:xmpp:avatar:metadata+notify"),t.on("pubsubEvent",function(e){e.event._extensions.updated&&"urn:xmpp:avatar:metadata"===e.event.updated.node&&t.emit("avatar",{jid:e.from,avatars:e.event.updated.published[0].avatars})}),t.publishAvatar=function(e,n,r){t.publish("","urn:xmpp:avatar:data",{id:e,avatarData:n},r)},t.useAvatars=function(e,n){t.publish("","urn:xmpp:avatar:metadata",{id:"current",avatars:e},n)},t.getAvatar=function(e,n,r){t.getItem(e,"urn:xmpp:avatar:data",n,r)}}},{"../stanza/avatar":23}],6:[function(t,e){t("../stanza/bookmarks"),e.exports=function(t){t.getBookmarks=function(t){this.getPrivateData({bookmarks:{}},t)},t.setBookmarks=function(t,e){this.setPrivateData({bookmarks:t},e)}}},{"../stanza/bookmarks":25}],7:[function(t,e){t("../stanza/carbons"),e.exports=function(t){t.disco.addFeature("urn:xmpp:carbons:2"),t.enableCarbons=function(t){this.sendIq({type:"set",enableCarbons:!0},t)},t.disableCarbons=function(t){this.sendIq({type:"set",disableCarbons:!0},t)},t.on("message",function(e){return e._extensions.carbonSent?t.emit("carbon:sent",e):e._extensions.carbonReceived?t.emit("carbon:received",e):void 0})}},{"../stanza/carbons":27}],8:[function(t,e){t("../stanza/chatstates"),e.exports=function(t){t.disco.addFeature("http://jabber.org/protocol/chatstates"),t.on("message",function(e){e.chatState&&t.emit("chatState",{to:e.to,from:e.from,chatState:e.chatState})})}},{"../stanza/chatstates":28}],9:[function(t,e){e.exports=function(t){t.disco.addFeature("urn:xmpp:message-correct:0"),t.on("message",function(e){e.replace&&(t.emit("replace",e),t.emit("replace:"+e.id,e))})}},{}],10:[function(t,e){t("../stanza/delayed"),e.exports=function(t){t.disco.addFeature("urn:xmpp:delay")}},{"../stanza/delayed":30}],11:[function(t,e){function n(t,e,n){"sha-1"===e&&(e="sha1");var i=r(t,e);return i&&i==n}function r(t,e){var n="",r=t.features.sort(),i=[],u={},c=[];o.forEach(t.identities,function(t){i.push([t.category||"",t.type||"",t.lang||"",t.name||""].join("/"))});var f=i.length,l=r.length;if(i=o.unique(i,!0),r=o.unique(r,!0),l!=r.length||f!=i.length)return!1;n+=i.join("<")+"<",n+=r.join("<")+"<";var p=!1;if(o.forEach(t.extensions,function(t){for(var e=t.fields,n=0,r=e.length;r>n;n++)if("FORM_TYPE"==e[n].name&&"hidden"==e[n].type){var i=e[n].value;return u[i]?(p=!0,void 0):(u[i]=t,c.push(i),void 0)}}),p)return!1;c.sort(),o.forEach(c,function(t){var e=u[t],r={},i=[];n+="<"+t,o.forEach(e.fields,function(t){var e=t.name;if("FORM_TYPE"!=e){var n=t.value||"";"object"!=typeof n&&(n=n.split("\n")),r[e]=n.sort(),i.push(e)}}),i.sort(),o.forEach(i,function(t){n+="<"+t,o.forEach(r[t],function(t){n+="<"+t})})}),"sha-1"===e&&(e="sha1");var h=a.createHash(e).update(s.encode(n)).digest("base64"),d=4-h.length%4;4===d&&(d=0);for(var m=0;d>m;m++)h+="=";return h}function i(){this.features={},this.identities={},this.extensions={},this.items={},this.caps={}}var o=t("underscore"),a=t("crypto");t("../stanza/disco"),t("../stanza/caps");var s={encode:function(t){return unescape(encodeURIComponent(t))},decode:function(t){return decodeURIComponent(escape(t))}};i.prototype={constructor:{value:i},addFeature:function(t,e){e=e||"",this.features[e]||(this.features[e]=[]),this.features[e].push(t)},addIdentity:function(t,e){e=e||"",this.identities[e]||(this.identities[e]=[]),this.identities[e].push(t)},addItem:function(t,e){e=e||"",this.items[e]||(this.items[e]=[]),this.items[e].push(t)},addExtension:function(t,e){e=e||"",this.extensions[e]||(this.extensions[e]=[]),this.extensions[e].push(t)}},e.exports=function(t){t.disco=new i(t),t.disco.addFeature("http://jabber.org/protocol/disco#info"),t.disco.addIdentity({category:"client",type:"web"}),t.getDiscoInfo=function(t,e,n){this.sendIq({to:t,type:"get",discoInfo:{node:e}},n)},t.getDiscoItems=function(t,e,n){this.sendIq({to:t,type:"get",discoItems:{node:e}},n)},t.updateCaps=function(){var e=this.config.capsNode||"https://stanza.io",n=JSON.parse(JSON.stringify({identities:this.disco.identities[""],features:this.disco.features[""],extensions:this.disco.extensions[""]})),i=r(n,"sha-1");return this.disco.caps={node:e,hash:"sha-1",ver:i},e=e+"#"+i,this.disco.features[e]=n.features,this.disco.identities[e]=n.identities,this.disco.extensions[e]=n.extensions,t.getCurrentCaps()},t.getCurrentCaps=function(){var e=t.disco.caps;if(!e.ver)return{ver:null,discoInfo:null};var n=e.node+"#"+e.ver;return{ver:e.ver,discoInfo:{identities:t.disco.identities[n],features:t.disco.features[n],extensions:t.disco.extensions[n]}}},t.on("presence",function(e){e._extensions.caps&&t.emit("disco:caps",e)}),t.on("iq:get:discoInfo",function(e){var n=e.discoInfo.node,r=e.discoInfo.node;n===t.disco.caps.node+"#"+t.disco.caps.ver&&(r=n,n=""),t.sendIq(e.resultReply({discoInfo:{node:r,identities:t.disco.identities[n]||[],features:t.disco.features[n]||[],extensions:t.disco.extensions[n]||[]}}))}),t.on("iq:get:discoItems",function(e){var n=e.discoInfo.node;t.sendIq(e.resultReply({discoItems:{node:n,items:t.disco.items[n]||[]}}))}),t.verifyVerString=n,t.generateVerString=r}},{"../stanza/caps":26,"../stanza/disco":31,crypto:63,underscore:96}],12:[function(t,e){t("../stanza/forwarded"),e.exports=function(t){t.disco.addFeature("urn:xmpp:forward:0")}},{"../stanza/forwarded":33}],13:[function(t,e){t("../stanza/idle"),e.exports=function(t){t.disco.addFeature("urn:xmpp:idle:0")}},{"../stanza/idle":34}],14:[function(t,e){t("../stanza/visibility"),e.exports=function(t){t.goInvisible=function(){this.sendIq({type:"set",invisible:!0})},t.goVisible=function(){this.sendIq({type:"set",visible:!0})}}},{"../stanza/visibility":54}],15:[function(t,e){t("../stanza/mam"),e.exports=function(t){t.disco.addFeature("urn:xmpp:mam:tmp"),t.getHistory=function(t,e){var n=this,r=this.nextId();t=t||{},t.queryid=r;var i=[];this.on("mam:"+r,"session",function(t){i.push(t)}),e=e||function(){},this.sendIq({type:"get",id:r,mamQuery:t},function(t,o){t?e(t):(n.off("mam:"+r),o.mamQuery.results=i,e(null,o))})},t.getHistoryPreferences=function(e){t.sendIq({type:"get",mamPrefs:{}},e)},t.setHistoryPreferences=function(e,n){t.sendIq({type:"set",mamPrefs:e},n)},t.on("message",function(e){e._extensions.mam&&t.emit("mam:"+e.mam.queryid,e)})}},{"../stanza/mam":36}],16:[function(t,e){t("../stanza/muc"),e.exports=function(t){t.joinRoom=function(t,e,n){n=n||{},n.to=t+"/"+e,n.caps=this.disco.caps,n.joinMuc=n.joinMuc||{},this.sendPresence(n)},t.leaveRoom=function(t,e,n){n=n||{},n.to=t+"/"+e,n.type="unavailable",this.sendPresence(n)}}},{"../stanza/muc":38}],17:[function(t,e){t("../stanza/private"),e.exports=function(t){t.getPrivateData=function(t,e){this.sendIq({type:"get",privateStorage:t},e)},t.setPrivateData=function(t,e){this.sendIq({type:"set",privateStorage:t},e)}}},{"../stanza/private":40}],18:[function(t,e){t("../stanza/pubsub"),e.exports=function(t){t.on("message",function(e){e._extensions.event&&t.emit("pubsubEvent",e)}),t.subscribeToNode=function(e,n,r){t.sendIq({type:"set",to:e,pubsub:{subscribe:{node:n.node,jid:n.jid||t.jid}}},r)},t.unsubscribeFromNode=function(e,n,r){t.sendIq({type:"set",to:e,pubsub:{unsubscribe:{node:n.node,jid:n.jid||t.jid.split("/")[0]}}},r)},t.publish=function(e,n,r,i){t.sendIq({type:"set",to:e,pubsub:{publish:{node:n,item:r}}},i)},t.getItem=function(e,n,r,i){t.sendIq({type:"get",to:e,pubsub:{retrieve:{node:n,item:r}}},i)},t.getItems=function(e,n,r,i){r=r||{},r.node=n,t.sendIq({type:"get",to:e,pubsub:{retrieve:{node:n,max:r.max},rsm:r.rsm}},i)},t.retract=function(e,n,r,i,o){t.sendIq({type:"set",to:e,pubsub:{retract:{node:n,notify:i,id:r}}},o)},t.purgeNode=function(e,n,r){t.sendIq({type:"set",to:e,pubsubOwner:{purge:n}},r)},t.deleteNode=function(e,n,r){t.sendIq({type:"set",to:e,pubsubOwner:{del:n}},r)},t.createNode=function(e,n,r,i){var o={type:"set",to:e,pubsubOwner:{create:n}};r&&(o.pubsubOwner.config={form:r}),t.sendIq(o,i)}}},{"../stanza/pubsub":41}],19:[function(t,e){t("../stanza/receipts"),e.exports=function(t){t.disco.addFeature("urn:xmpp:receipts"),t.on("message",function(e){var n={normal:!0,chat:!0,headline:!0};n[e.type]&&e.requestReceipt&&!e._extensions.receipt&&t.sendMessage({to:e.from,receipt:{id:e.id},id:e.id}),e._extensions.receipt&&t.emit("receipt:"+e.receipt.id)})}},{"../stanza/receipts":42}],20:[function(t,e){t("../stanza/time"),e.exports=function(t){t.disco.addFeature("urn:xmpp:time"),t.getTime=function(t,e){this.sendIq({to:t,type:"get",time:!0},e)},t.on("iq:get:time",function(e){var n=new Date;t.sendIq(e.resultReply({time:{utc:n,tzo:n.getTimezoneOffset()}}))})}},{"../stanza/time":51}],21:[function(t,e){t("../stanza/version"),e.exports=function(t){t.disco.addFeature("jabber:iq:version"),t.on("iq:get:version",function(e){t.sendIq(e.resultReply({version:t.config.version||{name:"stanza.io"}}))}),t.getSoftwareVersion=function(t,e){this.sendIq({to:t,type:"get",version:{}},e)}}},{"../stanza/version":53}],22:[function(t,e){function n(t,e){return(t%e+e)%e}function r(t){this.conn=t,this.id=!1,this.allowResume=!0,this.started=!1,this.lastAck=0,this.handled=0,this.windowSize=1,this.windowCount=0,this.unacked=[]}var i=t("./stanza/sm"),o=Math.pow(2,32);r.prototype={constructor:{value:r},enable:function(){var t=new i.Enable;t.resume=this.allowResume,this.conn.send(t),this.handled=0,this.started=!0},resume:function(){var t=new i.Resume({h:this.handled,previd:this.id});this.conn.send(t),this.started=!0},enabled:function(t){this.id=t.id},resumed:function(t){this.id=t.id,t.h&&this.process(t,!0)},failed:function(){this.started=!1,this.id=!1,this.lastAck=0,this.handled=0,this.windowCount=0,this.unacked=[]},ack:function(){this.conn.send(new i.Ack({h:this.handled}))},request:function(){this.conn.send(new i.Request)},process:function(t,e){for(var r=this,i=n(t.h-this.lastAck,o),a=0;i>a&&this.unacked.length>0;a++)this.conn.emit("stanza:acked",this.unacked.shift());if(e){var s=this.unacked;this.unacked=[],s.forEach(function(t){r.conn.send(t)})}this.lastAck=t.h},track:function(t){var e=t._name,n={message:!0,presence:!0,iq:!0};this.started&&n[e]&&(this.unacked.push(t),this.windowCount+=1,this.windowCount==this.windowSize&&(this.request(),this.windowCount=0))},handle:function(){this.started&&(this.handled=n(this.handled+1,o))}},e.exports=r},{"./stanza/sm":47}],23:[function(t,e){var n=t("underscore"),r=t("jxt"),i=t("./pubsub").Item,o=t("./pubsub").EventItem,a=e.exports=r.define({name:"avatar",namespace:"urn:xmpp:avatar:metadata",element:"info",fields:{id:r.attribute("id"),bytes:r.attribute("bytes"),height:r.attribute("height"),width:r.attribute("width"),type:r.attribute("type","image/png"),url:r.attribute("url")}}),s={get:function(){var t=r.find(this.xml,"urn:xmpp:avatar:metadata","metadata"),e=[];if(t.length){var i=r.find(t[0],"urn:xmpp:avatar:metadata","info");n.forEach(i,function(t){e.push(new a({},t))})}return e},set:function(t){var e=r.findOrCreate(this.xml,"urn:xmpp:avatar:metadata","metadata");r.setAttribute(e,"xmlns","urn:xmpp:avatar:metadata"),n.forEach(t,function(t){var n=new a(t);e.appendChild(n.xml)})}};r.add(i,"avatars",s),r.add(o,"avatars",s),r.add(i,"avatarData",r.subText("urn:xmpp:avatar:data","data")),r.add(o,"avatarData",r.subText("urn:xmpp:avatar:data","data"))},{"./pubsub":41,jxt:77,underscore:96}],24:[function(t,e){var n=t("jxt"),r=t("./iq"),i=t("./streamFeatures"),o=t("./util"),a="urn:ietf:params:xml:ns:xmpp-bind",s=e.exports=n.define({name:"bind",namespace:a,element:"bind",fields:{resource:n.subText(a,"resource"),jid:o.jidSub(a,"jid")}});n.extend(r,s),n.extend(i,s)},{"./iq":35,"./streamFeatures":50,"./util":52,jxt:77}],25:[function(t,e){var n=t("jxt"),r=t("./util"),i=t("./private"),o=n.define({name:"conference",namespace:"storage:bookmarks",element:"conference",fields:{name:n.attribute("name"),autoJoin:n.boolAttribute("autojoin"),jid:r.jidAttribute("jid"),nick:n.subText("storage:bookmarks","nick")}}),a=e.exports=n.define({name:"bookmarks",namespace:"storage:bookmarks",element:"storage"});n.extend(i,a),n.extend(a,o,"conferences")},{"./private":40,"./util":52,jxt:77}],26:[function(t,e){var n=t("jxt"),r=t("./presence"),i=t("./streamFeatures"),o=e.exports=n.define({name:"caps",namespace:"http://jabber.org/protocol/caps",element:"c",fields:{ver:n.attribute("ver"),node:n.attribute("node"),hash:n.attribute("hash"),ext:n.attribute("ext")}});n.extend(r,o),n.extend(i,o)},{"./presence":39,"./streamFeatures":50,jxt:77}],27:[function(t,e,n){var r=t("jxt"),i=t("./message"),o=t("./iq"),a=t("./forwarded");n.Sent=r.define({name:"carbonSent",eventName:"carbon:sent",namespace:"urn:xmpp:carbons:2",element:"sent"}),n.Received=r.define({name:"carbonReceived",eventName:"carbon:received",namespace:"urn:xmpp:carbons:2",element:"received"}),n.Private=r.define({name:"carbonPrivate",eventName:"carbon:private",namespace:"urn:xmpp:carbons:2",element:"private"}),n.Enable=r.define({name:"enableCarbons",namespace:"urn:xmpp:carbons:2",element:"enable"}),n.Disable=r.define({name:"disableCarbons",namespace:"urn:xmpp:carbons:2",element:"disable"}),r.extend(n.Sent,a),r.extend(n.Received,a),r.extend(i,n.Sent),r.extend(i,n.Received),r.extend(i,n.Private),r.extend(o,n.Enable),r.extend(o,n.Disable)},{"./forwarded":33,"./iq":35,"./message":37,jxt:77}],28:[function(t){var e=t("jxt"),n=t("./message"),r="http://jabber.org/protocol/chatstates",i=e.define({name:"chatStateActive",eventName:"chat:active",namespace:r,element:"active"}),o=e.define({name:"chatStateComposing",eventName:"chat:composing",namespace:r,element:"composing"}),a=e.define({name:"chatStatePaused",eventName:"chat:paused",namespace:r,element:"paused"}),s=e.define({name:"chatStateInactive",eventName:"chat:inactive",namespace:r,element:"inactive"}),u=e.define({name:"chatStateGone",eventName:"chat:gone",namespace:r,element:"gone"});e.extend(n,i),e.extend(n,o),e.extend(n,a),e.extend(n,s),e.extend(n,u),e.add(n,"chatState",{get:function(){for(var t=this,e=["Active","Composing","Paused","Inactive","Gone"],n=0;n1?"text-multi"===this._type?t.join("\n"):t:t[0]},set:function(t){"boolean"===this._type?r.setSubText(this.xml,this._NS,"value",t?"1":"0"):("text-multi"===this._type&&(t=t.split("\n")),r.setMultiSubText(this.xml,this._NS,"value",t))}},options:{get:function(){var t=this;return r.getMultiSubText(this.xml,this._NS,"option",function(e){return r.getSubText(e,t._NS,"value")})},set:function(t){var e=this;r.setMultiSubText(this.xml,this._NS,"option",t,function(t){var n=document.createElementNS(e._NS,"option"),r=document.createElementNS(e._NS,"value");n.appendChild(r),r.textContent=t,e.xml.appendChild(n)})}}}}),r.extend(i,n.DataForm)},{"./message":37,"./util":52,jxt:77,underscore:96}],30:[function(t,e){var n=t("jxt"),r=t("./message"),i=t("./presence"),o=t("./util"),a=e.exports=n.define({name:"delay",namespace:"urn:xmpp:delay",element:"delay",fields:{from:o.jidAttribute("from"),stamp:o.dateAttribute("stamp"),reason:n.text()}});n.extend(r,a),n.extend(i,a)},{"./message":37,"./presence":39,"./util":52,jxt:77}],31:[function(t,e,n){t("underscore");var r=t("jxt"),i=t("../jid"),o=t("./iq"),a=t("./rsm"),s=t("./dataforms").DataForm;n.DiscoInfo=r.define({name:"discoInfo",namespace:"http://jabber.org/protocol/disco#info",element:"query",fields:{node:r.attribute("node"),identities:{get:function(){var t=[],e=r.find(this.xml,this._NS,"identity");return e.forEach(function(e){t.push({category:r.getAttribute(e,"category"),type:r.getAttribute(e,"type"),lang:e.getAttributeNS(r.XML_NS,"lang"),name:r.getAttribute(e,"name")})}),t},set:function(t){var e=this,n=r.find(this.xml,this._NS,"identity");n.forEach(function(t){e.xml.removeChild(t)}),t.forEach(function(t){var n=document.createElementNS(e._NS,"identity");r.setAttribute(n,"category",t.category),r.setAttribute(n,"type",t.type),r.setAttribute(n,"name",t.name),t.lang&&n.setAttributeNS(r.XML_NS,"lang",t.lang),e.xml.appendChild(n)})}},features:{get:function(){var t=[],e=r.find(this.xml,this._NS,"feature");return e.forEach(function(e){t.push(e.getAttribute("var"))}),t},set:function(t){var e=this,n=r.find(this.xml,this._NS,"feature");n.forEach(function(t){e.xml.removeChild(t)}),t.forEach(function(t){var n=document.createElementNS(e._NS,"feature");n.setAttribute("var",t),e.xml.appendChild(n)})}}}}),n.DiscoItems=r.define({name:"discoItems",namespace:"http://jabber.org/protocol/disco#items",element:"query",fields:{node:r.attribute("node"),items:{get:function(){var t=[],e=r.find(this.xml,this._NS,"item");return e.forEach(function(e){t.push({jid:new i(r.getAttribute(e,"jid")),node:r.getAttribute(e,"node"),name:r.getAttribute(e,"name")})}),t},set:function(t){var e=this,n=r.find(this.xml,this._NS,"item");n.forEach(function(t){e.xml.removeChild(t)}),t.forEach(function(t){var n=document.createElementNS(e._NS,"item");r.setAttribute(n,"jid",t.jid.toString()),r.setAttribute(n,"node",t.node),r.setAttribute(n,"name",t.name),e.xml.appendChild(n)})}}}}),r.extend(o,n.DiscoInfo),r.extend(o,n.DiscoItems),r.extend(n.DiscoItems,a),r.extend(n.DiscoInfo,s,"extensions")},{"../jid":3,"./dataforms":29,"./iq":35,"./rsm":44,jxt:77,underscore:96}],32:[function(t,e){t("underscore");var n=t("jxt"),r=t("./util"),i=t("./message"),o=t("./presence"),a=t("./iq"),s="urn:ietf:params:xml:ns:xmpp-stanzas",u=["bad-request","conflict","feature-not-implemented","forbidden","gone","internal-server-error","item-not-found","jid-malformed","not-acceptable","not-allowed","not-authorized","payment-required","recipient-unavailable","redirect","registration-required","remote-server-not-found","remote-server-timeout","resource-constraint","service-unavailable","subscription-required","undefined-condition","unexpected-request"],c=e.exports=n.define({name:"error",namespace:"jabber:client",element:"error",fields:{lang:{get:function(){return(this.parent||{}).lang||""}},condition:{get:function(){var t=this,e=[];return u.forEach(function(r){var i=n.find(t.xml,s,r);i.length&&e.push(i[0].tagName)}),e[0]||""},set:function(t){var e=this;if(u.forEach(function(t){var r=n.find(e.xml,e._ERR_NS,t);r.length&&e.xml.removeChild(r[0])}),t){var r=document.createElementNS(this._ERR_NS,t);r.setAttribute("xmlns",this._ERR_NS),this.xml.appendChild(r)}}},gone:{get:function(){return n.getSubText(this.xml,s,"gone")},set:function(t){this.condition="gone",n.setSubText(this.xml,s,"gone",t)}},redirect:{get:function(){return n.getSubText(this.xml,s,"redirect")},set:function(t){this.condition="redirect",n.setSubText(this.xml,s,"redirect",t)}},code:n.attribute("code"),type:n.attribute("type"),by:r.jidAttribute("by"),$text:{get:function(){return n.getSubLangText(this.xml,s,"text",this.lang)}},text:{get:function(){var t=this.$text;return t[this.lang]||""},set:function(t){n.setSubLangText(this.xml,s,"text",t,this.lang)}}}});n.extend(i,c),n.extend(o,c),n.extend(a,c)},{"./iq":35,"./message":37,"./presence":39,"./util":52,jxt:77,underscore:96}],33:[function(t,e){var n=t("jxt"),r=t("./message"),i=t("./presence"),o=t("./iq"),a=t("./delayed"),s=e.exports=n.define({name:"forwarded",eventName:"forward",namespace:"urn:xmpp:forward:0",element:"forwarded"});n.extend(r,s),n.extend(s,r),n.extend(s,i),n.extend(s,o),n.extend(s,a)},{"./delayed":30,"./iq":35,"./message":37,"./presence":39,jxt:77}],34:[function(t,e){var n=t("jxt"),r=t("./util"),i=t("./presence"),o=e.exports=n.define({name:"idle",namespace:"urn:xmpp:idle:0",element:"idle",fields:{since:r.dateAttribute("since")}});n.extend(i,o)},{"./presence":39,"./util":52,jxt:77}],35:[function(t,e){var n=t("jxt"),r=t("./util"),i=e.exports=n.define({name:"iq",namespace:"jabber:client",element:"iq",topLevel:!0,fields:{lang:r.langAttribute(),id:n.attribute("id"),to:r.jidAttribute("to"),from:r.jidAttribute("from"),type:n.attribute("type")}}); -i.prototype.resultReply=function(t){return t.to=this.from,t.id=this.id,t.type="result",new i(t)},i.prototype.errorReply=function(t){return t.to=this.from,t.id=this.id,t.type="error",new i(t)}},{"./util":52,jxt:77}],36:[function(t,e,n){var r=t("jxt"),i=t("./util"),o=t("./message"),a=t("./iq"),s=t("./forwarded"),u=t("./rsm"),c=t("../jid");n.MAMQuery=r.define({name:"mamQuery",namespace:"urn:xmpp:mam:tmp",element:"query",fields:{queryid:r.attribute("queryid"),start:i.dateSub("urn:xmpp:mam:tmp","start"),end:i.dateSub("urn:xmpp:mam:tmp","end"),"with":i.jidSub("urn:xmpp:mam:tmp","with")}}),n.Result=r.define({name:"mam",eventName:"mam:result",namespace:"urn:xmpp:mam:tmp",element:"result",fields:{queryid:r.attribute("queryid"),id:r.attribute("id")}}),n.Archived=r.define({name:"mamArchived",namespace:"urn:xmpp:mam:tmp",element:"archived",fields:{by:i.jidAttribute("by"),id:r.attribute("id")}}),n.Prefs=r.define({name:"mamPrefs",namespace:"urn:xmpp:mam:tmp",element:"prefs",fields:{defaultCondition:r.attribute("default"),always:{get:function(){var t=[],e=r.find(this.xml,this._NS,"always");if(0===e.length)return t;e=e[0];var n=r.getMultiSubText(e,this._NS,"jid");return n.forEach(function(e){t.push(new c(e.textContent))}),t},set:function(t){if(t.length>0){var e=r.find(this.xml,this._NS,"always");r.setMultiSubText(e,this._NS,"jid",t)}}},never:{get:function(){var t=[],e=r.find(this.xml,this._NS,"always");if(0===e.length)return t;e=e[0];var n=r.getMultiSubText(e,this._NS,"jid");return n.forEach(function(e){t.push(new c(e.textContent))}),t},set:function(t){if(t.length>0){var e=r.find(this.xml,this._NS,"never");r.setMultiSubText(e,this._NS,"jid",t)}}}}}),r.extend(o,n.Archived,"archived"),r.extend(a,n.MAMQuery),r.extend(a,n.Prefs),r.extend(o,n.Result),r.extend(n.Result,s),r.extend(n.MAMQuery,u)},{"../jid":3,"./forwarded":33,"./iq":35,"./message":37,"./rsm":44,"./util":52,jxt:77}],37:[function(t,e){t("underscore");var n=t("jxt"),r=t("./util");e.exports=n.define({name:"message",namespace:"jabber:client",element:"message",topLevel:!0,fields:{lang:r.langAttribute(),id:n.attribute("id"),to:r.jidAttribute("to"),from:r.jidAttribute("from"),type:n.attribute("type","normal"),thread:n.subText("jabber:client","thread"),parentThread:n.subAttribute("jabber:client","thread","parent"),$body:{get:function(){return n.getSubLangText(this.xml,this._NS,"body",this.lang)}},body:{get:function(){var t=this.$body;return t[this.lang]||""},set:function(t){n.setSubLangText(this.xml,this._NS,"body",t,this.lang)}},attention:n.boolSub("urn:xmpp:attention:0","attention"),replace:n.subAttribute("urn:xmpp:message-correct:0","replace","id")}})},{"./util":52,jxt:77,underscore:96}],38:[function(t,e,n){var r=t("jxt");t("./message");var i=t("./presence");t("./iq");var o="http://jabber.org/protocol/muc";n.MUCJoin=r.define({name:"joinMuc",namespace:o,element:"x",fields:{password:r.subText(o,"password"),history:{get:function(){var t={},e=r.find(this.xml,this._NS,"history");if(!e.length)return{};e=e[0];var n=e.getAttribute("maxchars")||"",i=e.getAttribute("maxstanas")||"",o=e.getAttribute("seconds")||"",a=e.getAttribute("since")||"";n&&(t.maxchars=parseInt(n,10)),i&&(t.maxstanzas=parseInt(i,10)),o&&(t.seconds=parseInt(o,10)),a&&(t.since=new Date(a))},set:function(t){var e=r.find(this.xml,this._NS,"history");if(e.length)for(var n=0;nt&&(t=-t,i="+"),e=t/60,r=t%60,i+=(10>e?"0":"")+e+":"+(10>r?"0":"")+r):i=t,n.setSubText(this.xml,this._NS,"tzo",i)}}}});n.extend(i,o)},{"./iq":35,"./util":52,jxt:77}],52:[function(t,e,n){var r=t("jxt"),i=t("../jid"),o="http://www.w3.org/XML/1998/namespace";n.langAttribute=r.field(function(t){return t.getAttributeNS(o,"lang")||""},function(t,e){t.setAttributeNS(o,"lang",e)}),n.jidAttribute=r.field(function(t,e){return new i(r.getAttribute(t,e))},function(t,e,n){r.setAttribute(t,e,(n||"").toString())}),n.jidSub=r.field(function(t,e,n){return new i(r.getSubText(t,e,n))},function(t,e,n,i){r.setSubText(t,e,n,(i||"").toString())}),n.b64Text=r.field(function(t){return t.textContent&&"="!=t.textContent?atob(t.textContent):""},function(t,e){t.textContent=btoa(e)||"="}),n.dateAttribute=r.field(function(t,e){return new Date(r.getAttribute(t,e))||Date.now()},function(t,e,n){n&&r.setAttribute(t,e,n.toISOString())}),n.dateSub=r.field(function(t,e,n){return new Date(r.getSubText(t,e,n))||Date.now()},function(t,e,n,i){i&&r.setSubText(t,e,n,i.toISOString())}),n.numberAttribute=r.field(function(t,e,n){return parseInt(r.getAttribute(t,e,n),10)},function(t,e,n){r.setAttribute(t,e,n.toString())}),n.numberSub=r.field(function(t,e,n,i){return parseInt(r.getSubText(t,e,n,i),10)},function(t,e,n,i){r.setSubText(t,e,n,i.toString())})},{"../jid":3,jxt:77}],53:[function(t,e){var n=t("jxt"),r=t("./iq"),i="jabber:iq:version",o=e.exports=n.define({name:"version",namespace:i,element:"query",fields:{name:n.subText(i,"name"),version:n.subText(i,"version"),os:n.subText(i,"os")}});n.extend(r,o)},{"./iq":35,jxt:77}],54:[function(t){var e=t("jxt"),n=t("./iq");e.add(n,"visible",e.boolSub("urn:xmpp:invisible:0","visible")),e.add(n,"invisible",e.boolSub("urn:xmpp:invisible:0","invisible"))},{"./iq":35,jxt:77}],55:[function(t,e){function n(){function t(t){var e=[n.streamStart,t,n.streamEnd].join("");return e}function e(t){for(var e=n.parser.parseFromString(t,"application/xml").childNodes,r=0;r'].join(" "))}),n.on("raw:incoming",function(i){var o,s;if(i=i.trim(),i=i.replace(/^(\s*<\?.*\?>\s*)*/,""),""!==i){if(i.match(n.streamEnd))return n.disconnect();if(n.hasStream)try{o=new a({},e(t(i)))}catch(u){return n.disconnect()}else{var c=i.match(/^<(\S+:)?(\S+) /);n.streamStart=i,n.streamEnd="",s=!1;try{o=new a({},e(i+n.streamEnd))}catch(u){try{o=new a({},e(i)),s=!0}catch(f){return n.disconnect()}}n.hasStream=!0,n.stream=o,n.emit("stream:start",o)}r.each(o._extensions,function(t){t.lang||(t.lang=n.stream.lang),("message"===t._name||"presence"===t._name||"iq"===t._name)&&(n.sm.handle(t),n.emit("stanza",t)),n.emit(t._eventname||t._name,t),n.emit("stream:data",t),t.id&&n.emit("id:"+t.id,t)}),s&&n.emit("stream:end")}})}var r=t("underscore"),i=t("wildemitter"),o=t("async"),a=t("./stanza/stream");t("./stanza/message"),t("./stanza/presence"),t("./stanza/iq");var s=t("./sm");t("node-uuid"),n.prototype=Object.create(i.prototype,{constructor:{value:n}}),n.prototype.connect=function(t){var e=this;e.config=t,e.hasStream=!1,e.streamStart='',e.streamEnd="",e.parser=new DOMParser,e.serializer=new XMLSerializer,e.conn=new WebSocket(t.wsURL,"xmpp"),e.conn.onerror=function(t){return t.preventDefault(),e.emit("disconnected",e),!1},e.conn.onclose=function(){e.emit("disconnected",e)},e.conn.onopen=function(){e.sm.started=!1,e.emit("connected",e)},e.conn.onmessage=function(t){e.emit("raw:incoming",t.data)}},n.prototype.disconnect=function(){this.conn&&(this.hasStream&&(this.conn.send(""),this.emit("raw:outgoing",""),this.emit("stream:end")),this.hasStream=!1,this.conn.close(),this.stream=void 0,this.conn=void 0,this.sm.failed())},n.prototype.restart=function(){var t=this;t.hasStream=!1,t.send(["'].join(" "))},n.prototype.send=function(t){this.sendQueue.push(t)},e.exports=n},{"./sm":22,"./stanza/iq":35,"./stanza/message":37,"./stanza/presence":39,"./stanza/stream":48,async:56,"node-uuid":82,underscore:96,wildemitter:97}],56:[function(e,n){var r=e("__browserify_process");!function(){function e(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var s=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n=t.length&&r(null))}))})},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){var i=l(e);i.apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var i=0,o=0,a=0;!function s(){if(i>=e.length)return r();for(;t>a&&o=e.length?r():s())})}()}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},h=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(n))}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},m=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){i[t.index]=r,e(n)})},function(t){r(t,i)})};a.map=p(m),a.mapSeries=d(m),a.mapLimit=function(t,e,n,r){return g(e)(t,n,r)};var g=function(t){return h(t,m)};a.reduce=function(t,e,n,r){a.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){r(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=u(t,function(t){return t}).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var v=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.filter=p(v),a.filterSeries=d(v),a.select=a.filter,a.selectSeries=a.filterSeries;var y=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.reject=p(y),a.rejectSeries=d(y);var b=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};a.detect=p(b),a.detectSeries=d(b),a.some=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r()})},function(){n(!1)})},a.any=a.some,a.every=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t||(n(!1),n=function(){}),r()})},function(){n(!0)})},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){if(t)return n(t);var r=function(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0};n(null,u(e.sort(r),function(t){return t.value}))})},a.auto=function(t,e){e=e||function(){};var n=f(t);if(!n.length)return e(null);var r={},i=[],o=function(t){i.unshift(t)},u=function(t){for(var e=0;ee;e++)t[e].apply(null,arguments)}])))};return i.memo=n,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.map(r,e,n)},a.timesSeries=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.mapSeries(r,e,n)},a.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var e=this,n=Array.prototype.slice.call(arguments),r=n.pop();a.reduce(t,n,function(t,n,r){n.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,n){r.apply(e,[t].concat(n))})}};var E=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=p(E),a.applyEachSeries=d(E),a.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()},"undefined"!=typeof t&&t.amd?t([],function(){return a}):"undefined"!=typeof n&&n.exports?n.exports=a:i.async=a}()},{__browserify_process:69}],57:[function(t,e){function n(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}function r(t,e){return void 0===e?""+e:"number"!=typeof e||!isNaN(e)&&isFinite(e)?"function"==typeof e||e instanceof RegExp?e.toString():e:e.toString()}function i(t,e){return"string"==typeof t?t.length0){var e=r.find(this.xml,this._NS,"always");r.setMultiSubText(e,this._NS,"jid",t)}}},never:{get:function(){var t=[],e=r.find(this.xml,this._NS,"always");if(0===e.length)return t;e=e[0];var n=r.getMultiSubText(e,this._NS,"jid");return n.forEach(function(e){t.push(new c(e.textContent))}),t},set:function(t){if(t.length>0){var e=r.find(this.xml,this._NS,"never");r.setMultiSubText(e,this._NS,"jid",t)}}}}}),r.extend(o,n.Archived,"archived"),r.extend(a,n.MAMQuery),r.extend(a,n.Prefs),r.extend(o,n.Result),r.extend(n.Result,s),r.extend(n.MAMQuery,u)},{"../jid":3,"./forwarded":33,"./iq":35,"./message":37,"./rsm":44,"./util":52,jxt:77}],37:[function(t,e){t("underscore");var n=t("jxt"),r=t("./util");e.exports=n.define({name:"message",namespace:"jabber:client",element:"message",topLevel:!0,fields:{lang:r.langAttribute(),id:n.attribute("id"),to:r.jidAttribute("to"),from:r.jidAttribute("from"),type:n.attribute("type","normal"),thread:n.subText("jabber:client","thread"),parentThread:n.subAttribute("jabber:client","thread","parent"),$body:{get:function(){return n.getSubLangText(this.xml,this._NS,"body",this.lang)}},body:{get:function(){var t=this.$body;return t[this.lang]||""},set:function(t){n.setSubLangText(this.xml,this._NS,"body",t,this.lang)}},attention:n.boolSub("urn:xmpp:attention:0","attention"),replace:n.subAttribute("urn:xmpp:message-correct:0","replace","id")}})},{"./util":52,jxt:77,underscore:96}],38:[function(t,e,n){var r=t("jxt");t("./message");var i=t("./presence");t("./iq");var o="http://jabber.org/protocol/muc";n.MUCJoin=r.define({name:"joinMuc",namespace:o,element:"x",fields:{password:r.subText(o,"password"),history:{get:function(){var t={},e=r.find(this.xml,this._NS,"history");if(!e.length)return{};e=e[0];var n=e.getAttribute("maxchars")||"",i=e.getAttribute("maxstanas")||"",o=e.getAttribute("seconds")||"",a=e.getAttribute("since")||"";n&&(t.maxchars=parseInt(n,10)),i&&(t.maxstanzas=parseInt(i,10)),o&&(t.seconds=parseInt(o,10)),a&&(t.since=new Date(a))},set:function(t){var e=r.find(this.xml,this._NS,"history");if(e.length)for(var n=0;nt&&(t=-t,i="+"),e=t/60,r=t%60,i+=(10>e?"0":"")+e+":"+(10>r?"0":"")+r):i=t,n.setSubText(this.xml,this._NS,"tzo",i)}}}});n.extend(i,o)},{"./iq":35,"./util":52,jxt:77}],52:[function(t,e,n){var r=t("jxt"),i=t("../jid"),o="http://www.w3.org/XML/1998/namespace";n.langAttribute=r.field(function(t){return t.getAttributeNS(o,"lang")||""},function(t,e){t.setAttributeNS(o,"lang",e)}),n.jidAttribute=r.field(function(t,e){return new i(r.getAttribute(t,e))},function(t,e,n){r.setAttribute(t,e,(n||"").toString())}),n.jidSub=r.field(function(t,e,n){return new i(r.getSubText(t,e,n))},function(t,e,n,i){r.setSubText(t,e,n,(i||"").toString())}),n.b64Text=r.field(function(t){return t.textContent&&"="!=t.textContent?atob(t.textContent):""},function(t,e){t.textContent=btoa(e)||"="}),n.dateAttribute=r.field(function(t,e){return new Date(r.getAttribute(t,e)||Date.now())},function(t,e,n){n&&r.setAttribute(t,e,n.toISOString())}),n.dateSub=r.field(function(t,e,n){return new Date(r.getSubText(t,e,n)||Date.now())},function(t,e,n,i){i&&r.setSubText(t,e,n,i.toISOString())}),n.numberAttribute=r.field(function(t,e,n){return parseInt(r.getAttribute(t,e,n),10)},function(t,e,n){r.setAttribute(t,e,n.toString())}),n.numberSub=r.field(function(t,e,n,i){return parseInt(r.getSubText(t,e,n,i),10)},function(t,e,n,i){r.setSubText(t,e,n,i.toString())})},{"../jid":3,jxt:77}],53:[function(t,e){var n=t("jxt"),r=t("./iq"),i="jabber:iq:version",o=e.exports=n.define({name:"version",namespace:i,element:"query",fields:{name:n.subText(i,"name"),version:n.subText(i,"version"),os:n.subText(i,"os")}});n.extend(r,o)},{"./iq":35,jxt:77}],54:[function(t){var e=t("jxt"),n=t("./iq");e.add(n,"visible",e.boolSub("urn:xmpp:invisible:0","visible")),e.add(n,"invisible",e.boolSub("urn:xmpp:invisible:0","invisible"))},{"./iq":35,jxt:77}],55:[function(t,e){function n(){function t(t){var e=[n.streamStart,t,n.streamEnd].join("");return e}function e(t){for(var e=n.parser.parseFromString(t,"application/xml").childNodes,r=0;r'].join(" "))}),n.on("raw:incoming",function(i){var o,s;if(i=i.trim(),i=i.replace(/^(\s*<\?.*\?>\s*)*/,""),""!==i){if(i.match(n.streamEnd))return n.disconnect();if(n.hasStream)try{o=new a({},e(t(i)))}catch(u){return n.disconnect()}else{var c=i.match(/^<(\S+:)?(\S+) /);n.streamStart=i,n.streamEnd="",s=!1;try{o=new a({},e(i+n.streamEnd))}catch(u){try{o=new a({},e(i)),s=!0}catch(f){return n.disconnect()}}n.hasStream=!0,n.stream=o,n.emit("stream:start",o)}r.each(o._extensions,function(t){t.lang||(t.lang=n.stream.lang),("message"===t._name||"presence"===t._name||"iq"===t._name)&&(n.sm.handle(t),n.emit("stanza",t)),n.emit(t._eventname||t._name,t),n.emit("stream:data",t),t.id&&n.emit("id:"+t.id,t)}),s&&n.emit("stream:end")}})}var r=t("underscore"),i=t("wildemitter"),o=t("async"),a=t("./stanza/stream");t("./stanza/message"),t("./stanza/presence"),t("./stanza/iq");var s=t("./sm");t("node-uuid"),n.prototype=Object.create(i.prototype,{constructor:{value:n}}),n.prototype.connect=function(t){var e=this;e.config=t,e.hasStream=!1,e.streamStart='',e.streamEnd="",e.parser=new DOMParser,e.serializer=new XMLSerializer,e.conn=new WebSocket(t.wsURL,"xmpp"),e.conn.onerror=function(t){return t.preventDefault(),e.emit("disconnected",e),!1},e.conn.onclose=function(){e.emit("disconnected",e)},e.conn.onopen=function(){e.sm.started=!1,e.emit("connected",e)},e.conn.onmessage=function(t){e.emit("raw:incoming",t.data)}},n.prototype.disconnect=function(){this.conn&&(this.hasStream&&(this.conn.send(""),this.emit("raw:outgoing",""),this.emit("stream:end")),this.hasStream=!1,this.conn.close(),this.stream=void 0,this.conn=void 0,this.sm.failed())},n.prototype.restart=function(){var t=this;t.hasStream=!1,t.send(["'].join(" "))},n.prototype.send=function(t){this.sendQueue.push(t)},e.exports=n},{"./sm":22,"./stanza/iq":35,"./stanza/message":37,"./stanza/presence":39,"./stanza/stream":48,async:56,"node-uuid":82,underscore:96,wildemitter:97}],56:[function(e,n){var r=e("__browserify_process");!function(){function e(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var s=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n=t.length&&r(null))}))})},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){var i=l(e);i.apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var i=0,o=0,a=0;!function s(){if(i>=e.length)return r();for(;t>a&&o=e.length?r():s())})}()}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},h=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(n))}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},m=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){i[t.index]=r,e(n)})},function(t){r(t,i)})};a.map=p(m),a.mapSeries=d(m),a.mapLimit=function(t,e,n,r){return g(e)(t,n,r)};var g=function(t){return h(t,m)};a.reduce=function(t,e,n,r){a.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){r(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=u(t,function(t){return t}).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var v=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.filter=p(v),a.filterSeries=d(v),a.select=a.filter,a.selectSeries=a.filterSeries;var y=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.reject=p(y),a.rejectSeries=d(y);var b=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};a.detect=p(b),a.detectSeries=d(b),a.some=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r()})},function(){n(!1)})},a.any=a.some,a.every=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t||(n(!1),n=function(){}),r()})},function(){n(!0)})},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){if(t)return n(t);var r=function(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0};n(null,u(e.sort(r),function(t){return t.value}))})},a.auto=function(t,e){e=e||function(){};var n=f(t);if(!n.length)return e(null);var r={},i=[],o=function(t){i.unshift(t)},u=function(t){for(var e=0;ee;e++)t[e].apply(null,arguments)}])))};return i.memo=n,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.map(r,e,n)},a.timesSeries=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.mapSeries(r,e,n)},a.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var e=this,n=Array.prototype.slice.call(arguments),r=n.pop();a.reduce(t,n,function(t,n,r){n.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,n){r.apply(e,[t].concat(n))})}};var E=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=p(E),a.applyEachSeries=d(E),a.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()},"undefined"!=typeof t&&t.amd?t([],function(){return a}):"undefined"!=typeof n&&n.exports?n.exports=a:i.async=a}()},{__browserify_process:69}],57:[function(t,e){function n(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}function r(t,e){return void 0===e?""+e:"number"!=typeof e||!isNaN(e)&&isFinite(e)?"function"==typeof e||e instanceof RegExp?e.toString():e:e.toString()}function i(t,e){return"string"==typeof t?t.length=0;i--)if(o[i]!=a[i])return!1;for(i=o.length-1;i>=0;i--)if(r=o[i],!s(t[r],e[r]))return!1;return!0}function l(t,e){return t&&e?e instanceof RegExp?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function p(t,e,n,r){var i;"string"==typeof n&&(r=n,n=null);try{e()}catch(a){i=a}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),t&&!i&&o("Missing expected exception"+r),!t&&l(i,n)&&o("Got unwanted exception"+r),t&&i&&n&&!l(i,n)||!t&&i)throw i}var h=t("util"),d=t("buffer").Buffer,m=Array.prototype.slice,g=e.exports=a;g.AssertionError=function(t){this.name="AssertionError",this.message=t.message,this.actual=t.actual,this.expected=t.expected,this.operator=t.operator;var e=t.stackStartFunction||o;Error.captureStackTrace&&Error.captureStackTrace(this,e)},h.inherits(g.AssertionError,Error),g.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",i(JSON.stringify(this.actual,r),128),this.operator,i(JSON.stringify(this.expected,r),128)].join(" ")},g.fail=o,g.ok=a,g.equal=function(t,e,n){t!=e&&o(t,e,n,"==",g.equal)},g.notEqual=function(t,e,n){t==e&&o(t,e,n,"!=",g.notEqual)},g.deepEqual=function(t,e,n){s(t,e)||o(t,e,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(t,e,n){s(t,e)&&o(t,e,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(t,e,n){t!==e&&o(t,e,n,"===",g.strictEqual)},g.notStrictEqual=function(t,e,n){t===e&&o(t,e,n,"!==",g.notStrictEqual)},g.throws=function(){p.apply(this,[!0].concat(m.call(arguments)))},g.doesNotThrow=function(){p.apply(this,[!1].concat(m.call(arguments)))},g.ifError=function(t){if(t)throw t}},{buffer:61,util:59}],58:[function(t,e,n){function r(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;ni;i++)r[i].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(a(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:s,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var n=this;return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(a(n)){var i=r(n,e);if(0>i)return this;n.splice(i,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]},o.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?"function"==typeof t._events[e]?1:t._events[e].length:0}},{__browserify_process:69}],59:[function(t,e,n){function r(t){return Array.isArray(t)||"object"==typeof t&&"[object Array]"===Object.prototype.toString.call(t)}function i(t){"object"==typeof t&&"[object RegExp]"===Object.prototype.toString.call(t)}function o(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)}t("events"),n.isArray=r,n.isDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)},n.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},n.print=function(){},n.puts=function(){},n.debug=function(){},n.inspect=function(t,e,u,c){function f(t,u){if(t&&"function"==typeof t.inspect&&t!==n&&(!t.constructor||t.constructor.prototype!==t))return t.inspect(u);switch(typeof t){case"undefined":return p("undefined","undefined");case"string":var c="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return p(c,"string");case"number":return p(""+t,"number");case"boolean":return p(""+t,"boolean")}if(null===t)return p("null","null");var h=a(t),d=e?s(t):h;if("function"==typeof t&&0===d.length){if(i(t))return p(""+t,"regexp");var m=t.name?": "+t.name:"";return p("[Function"+m+"]","special")}if(o(t)&&0===d.length)return p(t.toUTCString(),"date");var g,v,y;if(r(t)?(v="Array",y=["[","]"]):(v="Object",y=["{","}"]),"function"==typeof t){var b=t.name?": "+t.name:"";g=i(t)?" "+t:" [Function"+b+"]"}else g="";if(o(t)&&(g=" "+t.toUTCString()),0===d.length)return y[0]+g+y[1];if(0>u)return i(t)?p(""+t,"regexp"):p("[Object]","special");l.push(t);var x=d.map(function(e){var n,i;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?i=t.__lookupSetter__(e)?p("[Getter/Setter]","special"):p("[Getter]","special"):t.__lookupSetter__(e)&&(i=p("[Setter]","special"))),h.indexOf(e)<0&&(n="["+e+"]"),i||(l.indexOf(t[e])<0?(i=null===u?f(t[e]):f(t[e],u-1),i.indexOf("\n")>-1&&(i=r(t)?i.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+i.split("\n").map(function(t){return" "+t}).join("\n"))):i=p("[Circular]","special")),"undefined"==typeof n){if("Array"===v&&e.match(/^\d+$/))return i;n=JSON.stringify(""+e),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=p(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=p(n,"string"))}return n+": "+i});l.pop();var w=0,_=x.reduce(function(t,e){return w++,e.indexOf("\n")>=0&&w++,t+e.length+1},0);return x=_>50?y[0]+(""===g?"":g+"\n ")+" "+x.join(",\n ")+" "+y[1]:y[0]+g+" "+x.join(", ")+" "+y[1]}var l=[],p=function(t,e){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return r?"["+n[r][0]+"m"+t+"["+n[r][1]+"m":t};return c||(p=function(t){return t}),f(t,"undefined"==typeof u?2:u)},n.log=function(){},n.pump=null;var a=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},s=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.hasOwnProperty.call(t,n)&&e.push(n);return e},u=Object.create||function(t,e){var n;if(null===t)n={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var r=function(){};r.prototype=t,n=new r,n.__proto__=t}return"undefined"!=typeof e&&Object.defineProperties&&Object.defineProperties(n,e),n};n.inherits=function(t,e){t.super_=e,t.prototype=u(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(t){if("string"!=typeof t){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return t}}),s=i[r];o>r;s=i[++r])a+=null===s||"object"!=typeof s?" "+s:" "+n.inspect(s);return a}},{events:58}],60:[function(t,e,n){n.readIEEE754=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,f=-7,l=n?0:i-1,p=n?1:-1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=p,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(h?-1:1);a+=Math.pow(2,r),o-=c}return(h?-1:1)*a*Math.pow(2,o-r)},n.writeIEEE754=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?o-1:0,d=r?-1:1,m=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),e+=a+l>=1?p/u:p*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+h]=255&s,h+=d,s/=256,i-=8);for(a=a<0;t[n+h]=255&a,h+=d,a/=256,c-=8);t[n+h-d]|=128*m}},{}],61:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);this.parent=this,this.offset=0;var o;if("number"==typeof n)this.length=i(e),this.offset=n;else{switch(o=typeof t){case"number":this.length=i(t);break;case"string":this.length=r.byteLength(t,e);break;case"object":this.length=i(t.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(a(t))for(var s=0;st?0:t}function o(t){return(Array.isArray||function(t){return"[object Array]"=={}.toString.apply(t)})(t)}function a(t){return o(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function s(t){return 16>t?"0"+t.toString(16):t.toString(16)}function u(t){for(var e=[],n=0;ni&&!(i+n>=e.length||i>=t.length);)e[i+n]=t[i],i++;return i}function p(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function h(t,e,n,r){var i=0;return r||(I.ok("boolean"==typeof n,"missing or invalid endian"),I.ok(void 0!==e&&null!==e,"missing offset"),I.ok(e+1=t.length?0:(n?(i=t[e]<<8,e+1=t.length?0:(n?(e+1>>0):(e+2>>0)),i)}function m(t,e,n,r){var i,o;return r||(I.ok("boolean"==typeof n,"missing or invalid endian"),I.ok(void 0!==e&&null!==e,"missing offset"),I.ok(e+1=0,"specified a negative value for writing an unsigned value"),I.ok(e>=t,"value is larger than maximum value for type"),I.ok(Math.floor(t)===t,"value has a fractional component")}function x(t,e,n,r,i){i||(I.ok(void 0!==e&&null!==e,"missing value"),I.ok("boolean"==typeof r,"missing or invalid endian"),I.ok(void 0!==n&&null!==n,"missing offset"),I.ok(n+1>>8*(r?1-o:o)}function w(t,e,n,r,i){i||(I.ok(void 0!==e&&null!==e,"missing value"),I.ok("boolean"==typeof r,"missing or invalid endian"),I.ok(void 0!==n&&null!==n,"missing offset"),I.ok(n+3>>8*(r?3-o:o)}function _(t,e,n){I.ok("number"==typeof t,"cannot write a non-number as a number"),I.ok(e>=t,"value larger than maximum allowed value"),I.ok(t>=n,"value smaller than minimum allowed value"),I.ok(Math.floor(t)===t,"value has a fractional component")}function E(t,e,n){I.ok("number"==typeof t,"cannot write a non-number as a number"),I.ok(e>=t,"value larger than maximum allowed value"),I.ok(t>=n,"value smaller than minimum allowed value")}function S(t,e,n,r,i){i||(I.ok(void 0!==e&&null!==e,"missing value"),I.ok("boolean"==typeof r,"missing or invalid endian"),I.ok(void 0!==n&&null!==n,"missing offset"),I.ok(n+1=0?x(t,e,n,r,i):x(t,65535+e+1,n,r,i)}function j(t,e,n,r,i){i||(I.ok(void 0!==e&&null!==e,"missing value"),I.ok("boolean"==typeof r,"missing or invalid endian"),I.ok(void 0!==n&&null!==n,"missing offset"),I.ok(n+3=0?w(t,e,n,r,i):w(t,4294967295+e+1,n,r,i)}function k(e,n,r,i,o){o||(I.ok(void 0!==n&&null!==n,"missing value"),I.ok("boolean"==typeof i,"missing or invalid endian"),I.ok(void 0!==r&&null!==r,"missing offset"),I.ok(r+3t||t>=this.length)throw new Error("oob");return this[t]},r.prototype.set=function(t,e){if(0>t||t>=this.length)throw new Error("oob");return this[t]=e},r.byteLength=function(t,e){switch(e||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return u(t).length;case"ascii":case"binary":return t.length;case"base64":return f(t).length;default:throw new Error("Unknown encoding")}},r.prototype.utf8Write=function(t,e,n){return r._charsWritten=l(u(t),this,e,n)},r.prototype.asciiWrite=function(t,e,n){return r._charsWritten=l(c(t),this,e,n)},r.prototype.binaryWrite=r.prototype.asciiWrite,r.prototype.base64Write=function(t,e,n){return r._charsWritten=l(f(t),this,e,n)},r.prototype.base64Slice=function(){var e=Array.prototype.slice.apply(this,arguments);return t("base64-js").fromByteArray(e)},r.prototype.utf8Slice=function(){for(var t=Array.prototype.slice.apply(this,arguments),e="",n="",r=0;rr;r++)if(t[r]=s(this[r]),r==n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.hexSlice=function(t,e){var n=this.length;(!t||0>t)&&(t=0),(!e||0>e||e>n)&&(e=n);for(var r="",i=t;e>i;i++)r+=s(this[i]);return r},r.prototype.toString=function(t,e,n){if(t=String(t||"utf8").toLowerCase(),e=+e||0,"undefined"==typeof n&&(n=this.length),+n==e)return"";switch(t){case"hex":return this.hexSlice(e,n);case"utf8":case"utf-8":return this.utf8Slice(e,n);case"ascii":return this.asciiSlice(e,n);case"binary":return this.binarySlice(e,n);case"base64":return this.base64Slice(e,n);case"ucs2":case"ucs-2":return this.ucs2Slice(e,n);default:throw new Error("Unknown encoding")}},r.prototype.hexWrite=function(t,e,n){e=+e||0;var i=this.length-e;n?(n=+n,n>i&&(n=i)):n=i;var o=t.length;if(o%2)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;n>a;a++){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))throw new Error("Invalid hex string");this[e+a]=s}return r._charsWritten=2*a,a},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var i=r;r=e,e=n,n=i}e=+e||0;var o=this.length-e;switch(n?(n=+n,n>o&&(n=o)):n=o,r=String(r||"utf8").toLowerCase()){case"hex":return this.hexWrite(t,e,n);case"utf8":case"utf-8":return this.utf8Write(t,e,n);case"ascii":return this.asciiWrite(t,e,n);case"binary":return this.binaryWrite(t,e,n);case"base64":return this.base64Write(t,e,n);case"ucs2":case"ucs-2":return this.ucs2Write(t,e,n);default:throw new Error("Unknown encoding")}},r.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new r(this,e-t,+t)},r.prototype.copy=function(t,e,n,r){var i=this;if(n||(n=0),(void 0===r||isNaN(r))&&(r=this.length),e||(e=0),n>r)throw new Error("sourceEnd < sourceStart");if(r===n)return 0;if(0==t.length||0==i.length)return 0;if(0>e||e>=t.length)throw new Error("targetStart out of bounds");if(0>n||n>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-ea;a++)I.ok("undefined"!=typeof this[a],"copying undefined buffer bytes!"),o.push(this[a]);for(var a=e;an)throw new Error("end < start");if(n===e)return 0;if(0==this.length)return 0;if(0>e||e>=this.length)throw new Error("start out of bounds");if(0>n||n>this.length)throw new Error("end out of bounds");for(var r=e;n>r;r++)this[r]=t},r.isBuffer=function(t){return t instanceof r||t instanceof r},r.concat=function(t,e){if(!o(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===t.length)return new r(0);if(1===t.length)return t[0];if("number"!=typeof e){e=0;for(var n=0;n=n.length?void 0:n[t]},r.prototype.readUInt16LE=function(t,e){return h(this,t,!1,e)},r.prototype.readUInt16BE=function(t,e){return h(this,t,!0,e)},r.prototype.readUInt32LE=function(t,e){return d(this,t,!1,e)},r.prototype.readUInt32BE=function(t,e){return d(this,t,!0,e)},r.prototype.readInt8=function(t,e){var n,r=this;return e||(I.ok(void 0!==t&&null!==t,"missing offset"),I.ok(t=r.length?void 0:(n=128&r[t],n?-1*(255-r[t]+1):r[t])},r.prototype.readInt16LE=function(t,e){return m(this,t,!1,e)},r.prototype.readInt16BE=function(t,e){return m(this,t,!0,e)},r.prototype.readInt32LE=function(t,e){return g(this,t,!1,e)},r.prototype.readInt32BE=function(t,e){return g(this,t,!0,e)},r.prototype.readFloatLE=function(t,e){return v(this,t,!1,e)},r.prototype.readFloatBE=function(t,e){return v(this,t,!0,e)},r.prototype.readDoubleLE=function(t,e){return y(this,t,!1,e)},r.prototype.readDoubleBE=function(t,e){return y(this,t,!0,e)},r.prototype.writeUInt8=function(t,e,n){var r=this;n||(I.ok(void 0!==t&&null!==t,"missing value"),I.ok(void 0!==e&&null!==e,"missing offset"),I.ok(e=0?r.writeUInt8(t,e,n):r.writeUInt8(255+t+1,e,n)},r.prototype.writeInt16LE=function(t,e,n){S(this,t,e,!1,n)},r.prototype.writeInt16BE=function(t,e,n){S(this,t,e,!0,n)},r.prototype.writeInt32LE=function(t,e,n){j(this,t,e,!1,n)},r.prototype.writeInt32BE=function(t,e,n){j(this,t,e,!0,n)},r.prototype.writeFloatLE=function(t,e,n){k(this,t,e,!1,n)},r.prototype.writeFloatBE=function(t,e,n){k(this,t,e,!0,n)},r.prototype.writeDoubleLE=function(t,e,n){A(this,t,e,!1,n)},r.prototype.writeDoubleBE=function(t,e,n){A(this,t,e,!0,n)}},{"./buffer_ieee754":60,assert:57,"base64-js":62}],62:[function(t,e){!function(){"use strict";function t(t){var e,n,i,o,a,s;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(a=t.indexOf("="),a=a>0?t.length-a:0,s=[],i=a>0?t.length-4:t.length,e=0,n=0;i>e;e+=4,n+=3)o=r.indexOf(t[e])<<18|r.indexOf(t[e+1])<<12|r.indexOf(t[e+2])<<6|r.indexOf(t[e+3]),s.push((16711680&o)>>16),s.push((65280&o)>>8),s.push(255&o);return 2===a?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,s.push(255&o)):1===a&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,s.push(255&o>>8),s.push(255&o)),s}function n(t){function e(t){return r[63&t>>18]+r[63&t>>12]+r[63&t>>6]+r[63&t]}var n,i,o,a=t.length%3,s="";for(n=0,o=t.length-a;o>n;n+=3)i=(t[n]<<16)+(t[n+1]<<8)+t[n+2],s+=e(i);switch(a){case 1:i=t[t.length-1],s+=r[i>>2],s+=r[63&i<<4],s+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],s+=r[i>>10],s+=r[63&i>>4],s+=r[63&i<<2],s+="="}return s}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports.toByteArray=t,e.exports.fromByteArray=n}()},{}],63:[function(t,e,n){function r(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var n in t)e(t[n],n)}var o=t("buffer").Buffer,a=t("./sha"),s=t("./sha256"),u=t("./rng"),c=t("./md5"),f={sha1:{hex:a.hex_sha1,base64:a.b64_sha1,binary:a.str_sha1},sha256:{hex:s.hex_sha256,base64:s.b64_sha256,binary:s.str_sha256},md5:{hex:c.hex_md5,base64:c.b64_md5,binary:c.bin_md5}},l={sha1:{hex:a.hex_hmac_sha1,base64:a.b64_hmac_sha1,binary:a.str_hmac_sha1},sha256:{hex:s.hex_hmac_sha256,base64:s.b64_hmac_sha256,binary:s.str_hmac_sha256},md5:{hex:c.hex_hmac_md5,base64:c.b64_hmac_md5,binary:c.bin_hmac_md5}};n.createHash=function(t){t=t||"sha1",f[t]||r("algorithm:",t,"is not yet supported");var e="",n=f[t];return{update:function(t){return e+=t,this},digest:function(i){i=i||"binary";var o;(o=n[i])||r("encoding:",i,"is not yet supported for algorithm",t);var a=o(e);return e=null,a}}},n.createHmac=function(t,e){l[t]||r("algorithm:",t,"is not yet supported"),"string"!=typeof e&&(e=e.toString("binary"));var n="",i=l[t];return{update:function(t){return n+=t,this},digest:function(o){o=o||"binary";var a;(a=i[o])||r("encoding:",o,"is not yet support for algorithm",t);var s=a(e,n);return n=null,s}}},n.randomBytes=function(t,e){if(!e||!e.call)return new o(u(t));try{e.call(this,void 0,new o(u(t)))}catch(n){e(n)}},i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(t){n[t]=function(){r("sorry,",t,"is not implemented yet")}})},{"./md5":64,"./rng":65,"./sha":66,"./sha256":67,buffer:61}],64:[function(t,e,n){function r(t){return x(c(y(t),t.length*S))}function i(t){return w(c(y(t),t.length*S))}function o(t){return b(c(y(t),t.length*S))}function a(t,e){return x(m(t,e))}function s(t,e){return w(m(t,e))}function u(t,e){return b(m(t,e))}function c(t,e){t[e>>5]|=128<>>9<<4)+14]=e;for(var n=1732584193,r=-271733879,i=-1732584194,o=271733878,a=0;a16&&(n=c(n,t.length*S));for(var r=Array(16),i=Array(16),o=0;16>o;o++)r[o]=909522486^n[o],i[o]=1549556828^n[o];var a=c(r.concat(y(e)),512+e.length*S);return c(i.concat(a),640)}function g(t,e){var n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16);return r<<16|65535&n}function v(t,e){return t<>>32-e}function y(t){for(var e=Array(),n=(1<>5]|=(t.charCodeAt(r/S)&n)<>5]>>>r%32&n);return e}function x(t){for(var e=_?"0123456789ABCDEF":"0123456789abcdef",n="",r=0;r<4*t.length;r++)n+=e.charAt(15&t[r>>2]>>8*(r%4)+4)+e.charAt(15&t[r>>2]>>8*(r%4));return n}function w(t){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",r=0;r<4*t.length;r+=3)for(var i=(255&t[r>>2]>>8*(r%4))<<16|(255&t[r+1>>2]>>8*((r+1)%4))<<8|255&t[r+2>>2]>>8*((r+2)%4),o=0;4>o;o++)n+=8*r+6*o>32*t.length?E:e.charAt(63&i>>6*(3-o));return n}var _=0,E="=",S=8;n.hex_md5=r,n.b64_md5=i,n.bin_md5=o,n.hex_hmac_md5=a,n.b64_hmac_md5=s,n.bin_hmac_md5=u},{}],65:[function(t,e){!function(){var t,n,r=this;if(t=function(t){for(var e,e,n=new Array(t),r=0;t>r;r++)0==(3&r)&&(e=4294967296*Math.random()),n[r]=255&e>>>((3&r)<<3);return n},r.crypto&&crypto.getRandomValues){var i=new Uint32Array(4);n=function(t){var e=new Array(t);crypto.getRandomValues(i);for(var n=0;t>n;n++)e[n]=255&i[n>>2]>>>8*(3&n);return e}}e.exports=n||t}()},{}],66:[function(t,e,n){function r(t){return v(c(m(t),t.length*w))}function i(t){return y(c(m(t),t.length*w))}function o(t){return g(c(m(t),t.length*w))}function a(t,e){return v(p(t,e))}function s(t,e){return y(p(t,e))}function u(t,e){return g(p(t,e))}function c(t,e){t[e>>5]|=128<<24-e%32,t[(e+64>>9<<4)+15]=e;for(var n=Array(80),r=1732584193,i=-271733879,o=-1732584194,a=271733878,s=-1009589776,u=0;uy;y++){n[y]=16>y?t[u+y]:d(n[y-3]^n[y-8]^n[y-14]^n[y-16],1);var b=h(h(d(r,5),f(y,i,o,a)),h(h(s,n[y]),l(y)));s=a,a=o,o=d(i,30),i=r,r=b}r=h(r,c),i=h(i,p),o=h(o,m),a=h(a,g),s=h(s,v)}return Array(r,i,o,a,s)}function f(t,e,n,r){return 20>t?e&n|~e&r:40>t?e^n^r:60>t?e&n|e&r|n&r:e^n^r}function l(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function p(t,e){var n=m(t);n.length>16&&(n=c(n,t.length*w));for(var r=Array(16),i=Array(16),o=0;16>o;o++)r[o]=909522486^n[o],i[o]=1549556828^n[o];var a=c(r.concat(m(e)),512+e.length*w);return c(i.concat(a),672)}function h(t,e){var n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16);return r<<16|65535&n}function d(t,e){return t<>>32-e}function m(t){for(var e=Array(),n=(1<>5]|=(t.charCodeAt(r/w)&n)<<32-w-r%32;return e}function g(t){for(var e="",n=(1<>5]>>>32-w-r%32&n);return e}function v(t){for(var e=b?"0123456789ABCDEF":"0123456789abcdef",n="",r=0;r<4*t.length;r++)n+=e.charAt(15&t[r>>2]>>8*(3-r%4)+4)+e.charAt(15&t[r>>2]>>8*(3-r%4));return n}function y(t){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",r=0;r<4*t.length;r+=3)for(var i=(255&t[r>>2]>>8*(3-r%4))<<16|(255&t[r+1>>2]>>8*(3-(r+1)%4))<<8|255&t[r+2>>2]>>8*(3-(r+2)%4),o=0;4>o;o++)n+=8*r+6*o>32*t.length?x:e.charAt(63&i>>6*(3-o));return n}n.hex_sha1=r,n.b64_sha1=i,n.str_sha1=o,n.hex_hmac_sha1=a,n.b64_hmac_sha1=s,n.str_hmac_sha1=u;var b=0,x="=",w=8},{}],67:[function(t,e,n){function r(t){return E(w(_(t),t.length*l))}function i(t){return S(w(_(t),t.length*l))}function o(t){return c(w(_(t),t.length*l))}function a(t,e){return E(j(t,e))}function s(t,e){return S(j(t,e))}function u(t,e){return c(j(t,e))}function c(t){for(var e="",n=(1<>5]>>>32-l-r%32&n);return e}n.hex_sha256=r,n.b64_sha256=i,n.str_sha256=o,n.hex_hmac_sha256=a,n.b64_hmac_sha256=s,n.str_hmac_sha256=u;var f=0,l=8,p=function(t,e){var n=(65535&t)+(65535&e),r=(t>>16)+(e>>16)+(n>>16);return r<<16|65535&n},h=function(t,e){return t>>>e|t<<32-e},d=function(t,e){return t>>>e},m=function(t,e,n){return t&e^~t&n},g=function(t,e,n){return t&e^t&n^e&n},v=function(t){return h(t,2)^h(t,13)^h(t,22)},y=function(t){return h(t,6)^h(t,11)^h(t,25)},b=function(t){return h(t,7)^h(t,18)^d(t,3)},x=function(t){return h(t,17)^h(t,19)^d(t,10)},w=function(t,e){var n,r,i,o,a,s,u,c,f,l,h,d,w=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),_=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),E=new Array(64); t[e>>5]|=128<<24-e%32,t[(e+64>>9<<4)+15]=e;for(var f=0;fl;l++)E[l]=16>l?t[l+f]:p(p(p(x(E[l-2]),E[l-7]),b(E[l-15])),E[l-16]),h=p(p(p(p(c,y(a)),m(a,s,u)),w[l]),E[l]),d=p(v(n),g(n,r,i)),c=u,u=s,s=a,a=p(o,h),o=i,i=r,r=n,n=p(h,d);_[0]=p(n,_[0]),_[1]=p(r,_[1]),_[2]=p(i,_[2]),_[3]=p(o,_[3]),_[4]=p(a,_[4]),_[5]=p(s,_[5]),_[6]=p(u,_[6]),_[7]=p(c,_[7])}return _},_=function(t){for(var e=Array(),n=(1<>5]|=(t.charCodeAt(r/l)&n)<<24-r%32;return e},E=function(t){for(var e=f?"0123456789ABCDEF":"0123456789abcdef",n="",r=0;r<4*t.length;r++)n+=e.charAt(15&t[r>>2]>>8*(3-r%4)+4)+e.charAt(15&t[r>>2]>>8*(3-r%4));return n},S=function(t){var e,n,r,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o="",a=4*t.length,s="=";for(e=0;a>e;e+=3)for(r=(255&t[e>>2]>>8*(3-e%4))<<16|(255&t[e+1>>2]>>8*(3-(e+1)%4))<<8|255&t[e+2>>2]>>8*(3-(e+2)%4),n=0;4>n;n+=1)o+=8*e+6*n<=32*t.length?i.charAt(63&r>>6*(3-n)):s;return o},j=function(t,e){var n=_(t);n.length>16&&(n=w(n,t.length*l));for(var r=Array(16),i=Array(16),o=0;16>o;o++)r[o]=909522486^n[o],i[o]=1549556828^n[o];var a=w(r.concat(_(e)),512+e.length*l);return w(i.concat(a),768)}},{}],68:[function(t,e){t=function(t,e,n,r){function i(r){if(!n[r]){if(!e[r]){if(t)return t(r);throw new Error("Cannot find module '"+r+"'")}var o=n[r]={exports:{}};e[r][0](function(t){var n=e[r][1][t];return i(n?n:t)},o,o.exports)}return n[r].exports}for(var o=0;o=0;i--)if(o[i]!=a[i])return!1;for(i=o.length-1;i>=0;i--)if(r=o[i],!s(t[r],e[r]))return!1;return!0}function l(t,e){return t&&e?e instanceof RegExp?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function p(t,e,n,r){var i;"string"==typeof n&&(r=n,n=null);try{e()}catch(a){i=a}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),t&&!i&&o("Missing expected exception"+r),!t&&l(i,n)&&o("Got unwanted exception"+r),t&&i&&n&&!l(i,n)||!t&&i)throw i}var h=t("util"),d=t("buffer").Buffer,m=Array.prototype.slice,g=e.exports=a;g.AssertionError=function(t){this.name="AssertionError",this.message=t.message,this.actual=t.actual,this.expected=t.expected,this.operator=t.operator;var e=t.stackStartFunction||o;Error.captureStackTrace&&Error.captureStackTrace(this,e)},h.inherits(g.AssertionError,Error),g.AssertionError.prototype.toString=function(){return this.message?[this.name+":",this.message].join(" "):[this.name+":",i(JSON.stringify(this.actual,r),128),this.operator,i(JSON.stringify(this.expected,r),128)].join(" ")},g.AssertionError.__proto__=Error.prototype,g.fail=o,g.ok=a,g.equal=function(t,e,n){t!=e&&o(t,e,n,"==",g.equal)},g.notEqual=function(t,e,n){t==e&&o(t,e,n,"!=",g.notEqual)},g.deepEqual=function(t,e,n){s(t,e)||o(t,e,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(t,e,n){s(t,e)&&o(t,e,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(t,e,n){t!==e&&o(t,e,n,"===",g.strictEqual)},g.notStrictEqual=function(t,e,n){t===e&&o(t,e,n,"!==",g.notStrictEqual)},g.throws=function(){p.apply(this,[!0].concat(m.call(arguments)))},g.doesNotThrow=function(){p.apply(this,[!1].concat(m.call(arguments)))},g.ifError=function(t){if(t)throw t}},{util:2,buffer:3}],2:[function(t,e,n){function r(t){return t instanceof Array||Array.isArray(t)||t&&t!==Object.prototype&&r(t.__proto__)}function i(t){return t instanceof RegExp||"object"==typeof t&&"[object RegExp]"===Object.prototype.toString.call(t)}function o(t){if(t instanceof Date)return!0;if("object"!=typeof t)return!1;var e=Date.prototype&&s(Date.prototype),n=t.__proto__&&s(t.__proto__);return JSON.stringify(n)===JSON.stringify(e)}t("events"),n.isArray=r,n.isDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)},n.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},n.print=function(){},n.puts=function(){},n.debug=function(){},n.inspect=function(t,e,u,c){function f(t,u){if(t&&"function"==typeof t.inspect&&t!==n&&(!t.constructor||t.constructor.prototype!==t))return t.inspect(u);switch(typeof t){case"undefined":return p("undefined","undefined");case"string":var c="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return p(c,"string");case"number":return p(""+t,"number");case"boolean":return p(""+t,"boolean")}if(null===t)return p("null","null");var h=a(t),d=e?s(t):h;if("function"==typeof t&&0===d.length){if(i(t))return p(""+t,"regexp");var m=t.name?": "+t.name:"";return p("[Function"+m+"]","special")}if(o(t)&&0===d.length)return p(t.toUTCString(),"date");var g,v,y;if(r(t)?(v="Array",y=["[","]"]):(v="Object",y=["{","}"]),"function"==typeof t){var b=t.name?": "+t.name:"";g=i(t)?" "+t:" [Function"+b+"]"}else g="";if(o(t)&&(g=" "+t.toUTCString()),0===d.length)return y[0]+g+y[1];if(0>u)return i(t)?p(""+t,"regexp"):p("[Object]","special");l.push(t);var x=d.map(function(e){var n,i;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?i=t.__lookupSetter__(e)?p("[Getter/Setter]","special"):p("[Getter]","special"):t.__lookupSetter__(e)&&(i=p("[Setter]","special"))),h.indexOf(e)<0&&(n="["+e+"]"),i||(l.indexOf(t[e])<0?(i=null===u?f(t[e]):f(t[e],u-1),i.indexOf("\n")>-1&&(i=r(t)?i.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+i.split("\n").map(function(t){return" "+t}).join("\n"))):i=p("[Circular]","special")),"undefined"==typeof n){if("Array"===v&&e.match(/^\d+$/))return i;n=JSON.stringify(""+e),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=p(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=p(n,"string"))}return n+": "+i});l.pop();var w=0,_=x.reduce(function(t,e){return w++,e.indexOf("\n")>=0&&w++,t+e.length+1},0);return x=_>50?y[0]+(""===g?"":g+"\n ")+" "+x.join(",\n ")+" "+y[1]:y[0]+g+" "+x.join(", ")+" "+y[1]}var l=[],p=function(t,e){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return r?"["+n[r][0]+"m"+t+"["+n[r][1]+"m":t};return c||(p=function(t){return t}),f(t,"undefined"==typeof u?2:u)},n.log=function(){},n.pump=null;var a=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},s=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.hasOwnProperty.call(t,n)&&e.push(n);return e},u=Object.create||function(t,e){var n;if(null===t)n={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var r=function(){};r.prototype=t,n=new r,n.__proto__=t}return"undefined"!=typeof e&&Object.defineProperties&&Object.defineProperties(n,e),n};n.inherits=function(t,e){t.super_=e,t.prototype=u(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(t){if("string"!=typeof t){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return t}}),s=i[r];o>r;s=i[++r])a+=null===s||"object"!=typeof s?" "+s:" "+n.inspect(s);return a}},{events:4}],5:[function(t,e,n){n.readIEEE754=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,f=-7,l=n?0:i-1,p=n?1:-1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=p,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(h?-1:1);a+=Math.pow(2,r),o-=c}return(h?-1:1)*a*Math.pow(2,o-r)},n.writeIEEE754=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?o-1:0,d=r?-1:1,m=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),e+=a+l>=1?p/u:p*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+h]=255&s,h+=d,s/=256,i-=8);for(a=a<0;t[n+h]=255&a,h+=d,a/=256,c-=8);t[n+h-d]|=128*m}},{}],6:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(t,e,n){!function(t){function e(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;no;o++)r[o].apply(this,n);return!0}return!1},r.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(i(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:o,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){var n=this;return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},r.prototype.removeListener=function(t,n){if("function"!=typeof n)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var r=this._events[t];if(i(r)){var o=e(r,n);if(0>o)return this;r.splice(o,1),0==r.length&&delete this._events[t]}else this._events[t]===n&&delete this._events[t];return this},r.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},r.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}}(t("__browserify_process"))},{__browserify_process:6}],"buffer-browserify":[function(t,e){e.exports=t("q9TxCC")},{}],q9TxCC:[function(t,e,n){function r(t){this.length=t}function i(t){return 16>t?"0"+t.toString(16):t.toString(16)}function o(t){for(var e=[],n=0;ni&&!(i+n>=e.length||i>=t.length);)e[i+n]=t[i],i++;return i}function c(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function f(t){return t=~~Math.ceil(+t),0>t?0:t}function l(t,e,n){if(!(this instanceof l))return new l(t,e,n);var i;if("number"==typeof n)this.length=f(e),this.parent=t,this.offset=n;else{switch(i=typeof t){case"number":this.length=f(t);break;case"string":this.length=l.byteLength(t,e);break;case"object":this.length=f(t.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new r(this.length),this.offset=0):((!N||N.length-N.used=t.length?0:(n?(i=t.parent[t.offset+e]<<8,e+1=t.length?0:(n?(e+1>>0):(e+2>>0)),i)}function g(t,e,n,r){var i,o;return r||(C.ok("boolean"==typeof n,"missing or invalid endian"),C.ok(void 0!==e&&null!==e,"missing offset"),C.ok(e+1=0,"specified a negative value for writing an unsigned value"),C.ok(e>=t,"value is larger than maximum value for type"),C.ok(Math.floor(t)===t,"value has a fractional component")}function w(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+1>>8*(r?1-o:o)}function _(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+3>>8*(r?3-o:o)}function E(t,e,n){C.ok("number"==typeof t,"cannot write a non-number as a number"),C.ok(e>=t,"value larger than maximum allowed value"),C.ok(t>=n,"value smaller than minimum allowed value"),C.ok(Math.floor(t)===t,"value has a fractional component")}function S(t,e,n){C.ok("number"==typeof t,"cannot write a non-number as a number"),C.ok(e>=t,"value larger than maximum allowed value"),C.ok(t>=n,"value smaller than minimum allowed value")}function j(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+1=0?w(t,e,n,r,i):w(t,65535+e+1,n,r,i)}function k(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+3=0?_(t,e,n,r,i):_(t,4294967295+e+1,n,r,i)}function A(e,n,r,i,o){o||(C.ok(void 0!==n&&null!==n,"missing value"),C.ok("boolean"==typeof i,"missing or invalid endian"),C.ok(void 0!==r&&null!==r,"missing offset"),C.ok(r+3r;r++)if(t[r]=i(this[r]),r==n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.hexSlice=function(t,e){var n=this.length;(!t||0>t)&&(t=0),(!e||0>e||e>n)&&(e=n);for(var r="",o=t;e>o;o++)r+=i(this[o]);return r},r.prototype.toString=function(t,e,n){if(t=String(t||"utf8").toLowerCase(),e=+e||0,"undefined"==typeof n&&(n=this.length),+n==e)return"";switch(t){case"hex":return this.hexSlice(e,n);case"utf8":case"utf-8":return this.utf8Slice(e,n);case"ascii":return this.asciiSlice(e,n);case"binary":return this.binarySlice(e,n);case"base64":return this.base64Slice(e,n);case"ucs2":case"ucs-2":return this.ucs2Slice(e,n);default:throw new Error("Unknown encoding")}},r.prototype.hexWrite=function(t,e,n){e=+e||0;var i=this.length-e;n?(n=+n,n>i&&(n=i)):n=i;var o=t.length;if(o%2)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;n>a;a++){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))throw new Error("Invalid hex string");this[e+a]=s}return r._charsWritten=2*a,a},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var i=r;r=e,e=n,n=i}e=+e||0;var o=this.length-e;switch(n?(n=+n,n>o&&(n=o)):n=o,r=String(r||"utf8").toLowerCase()){case"hex":return this.hexWrite(t,e,n);case"utf8":case"utf-8":return this.utf8Write(t,e,n);case"ascii":return this.asciiWrite(t,e,n);case"binary":return this.binaryWrite(t,e,n);case"base64":return this.base64Write(t,e,n);case"ucs2":case"ucs-2":return this.ucs2Write(t,e,n);default:throw new Error("Unknown encoding")}},r.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new l(this,e-t,+t)},r.prototype.copy=function(t,e,n,r){for(var i=[],o=n;r>o;o++)C.ok("undefined"!=typeof this[o],"copying undefined buffer bytes!"),i.push(this[o]);for(var o=e;othis.length)throw new Error("oob");if(e>n)throw new Error("oob");for(var r=e;n>r;r++)this[r]=t},n.SlowBuffer=r,n.Buffer=l,l.poolSize=8192;var N;l.isBuffer=function(t){return t instanceof l||t instanceof r},l.concat=function(t,e){if(!Array.isArray(t))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===t.length)return new l(0);if(1===t.length)return t[0];if("number"!=typeof e){e=0;for(var n=0;nr;r++)if(t[r]=i(this.parent[r+this.offset]),r==n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},l.prototype.get=function(t){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]},l.prototype.set=function(t,e){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]=e},l.prototype.write=function(t,e,n,i){if(isFinite(e))isFinite(n)||(i=n,n=void 0);else{var o=i;i=e,e=n,n=o}e=+e||0;var a=this.length-e;n?(n=+n,n>a&&(n=a)):n=a,i=String(i||"utf8").toLowerCase();var s;switch(i){case"hex":s=this.parent.hexWrite(t,this.offset+e,n);break;case"utf8":case"utf-8":s=this.parent.utf8Write(t,this.offset+e,n);break;case"ascii":s=this.parent.asciiWrite(t,this.offset+e,n);break;case"binary":s=this.parent.binaryWrite(t,this.offset+e,n);break;case"base64":s=this.parent.base64Write(t,this.offset+e,n);break;case"ucs2":case"ucs-2":s=this.parent.ucs2Write(t,this.offset+e,n);break;default:throw new Error("Unknown encoding")}return l._charsWritten=r._charsWritten,s},l.prototype.toString=function(t,e,n){switch(t=String(t||"utf8").toLowerCase(),"undefined"==typeof e||0>e?e=0:e>this.length&&(e=this.length),"undefined"==typeof n||n>this.length?n=this.length:0>n&&(n=0),e+=this.offset,n+=this.offset,t){case"hex":return this.parent.hexSlice(e,n);case"utf8":case"utf-8":return this.parent.utf8Slice(e,n);case"ascii":return this.parent.asciiSlice(e,n);case"binary":return this.parent.binarySlice(e,n);case"base64":return this.parent.base64Slice(e,n);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(e,n);default:throw new Error("Unknown encoding")}},l.byteLength=r.byteLength,l.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(e>n)throw new Error("end < start");if(n===e)return 0;if(0==this.length)return 0;if(0>e||e>=this.length)throw new Error("start out of bounds");if(0>n||n>this.length)throw new Error("end out of bounds");return this.parent.fill(t,e+this.offset,n+this.offset)},l.prototype.copy=function(t,e,n,r){var i=this;if(n||(n=0),r||(r=this.length),e||(e=0),n>r)throw new Error("sourceEnd < sourceStart");if(r===n)return 0;if(0==t.length||0==i.length)return 0;if(0>e||e>=t.length)throw new Error("targetStart out of bounds");if(0>n||n>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");return r>this.length&&(r=this.length),t.length-ethis.length)throw new Error("oob");if(t>e)throw new Error("oob");return new l(this.parent,e-t,+t+this.offset)},l.prototype.utf8Slice=function(t,e){return this.toString("utf8",t,e)},l.prototype.binarySlice=function(t,e){return this.toString("binary",t,e)},l.prototype.asciiSlice=function(t,e){return this.toString("ascii",t,e)},l.prototype.utf8Write=function(t,e){return this.write(t,e,"utf8")},l.prototype.binaryWrite=function(t,e){return this.write(t,e,"binary")},l.prototype.asciiWrite=function(t,e){return this.write(t,e,"ascii")},l.prototype.readUInt8=function(t,e){var n=this;return e||(C.ok(void 0!==t&&null!==t,"missing offset"),C.ok(t=n.length?void 0:n.parent[n.offset+t]},l.prototype.readUInt16LE=function(t,e){return d(this,t,!1,e)},l.prototype.readUInt16BE=function(t,e){return d(this,t,!0,e)},l.prototype.readUInt32LE=function(t,e){return m(this,t,!1,e)},l.prototype.readUInt32BE=function(t,e){return m(this,t,!0,e)},l.prototype.readInt8=function(t,e){var n,r=this;return e||(C.ok(void 0!==t&&null!==t,"missing offset"),C.ok(t=r.length?void 0:(n=128&r.parent[r.offset+t],n?-1*(255-r.parent[r.offset+t]+1):r.parent[r.offset+t])},l.prototype.readInt16LE=function(t,e){return g(this,t,!1,e)},l.prototype.readInt16BE=function(t,e){return g(this,t,!0,e)},l.prototype.readInt32LE=function(t,e){return v(this,t,!1,e)},l.prototype.readInt32BE=function(t,e){return v(this,t,!0,e)},l.prototype.readFloatLE=function(t,e){return y(this,t,!1,e)},l.prototype.readFloatBE=function(t,e){return y(this,t,!0,e)},l.prototype.readDoubleLE=function(t,e){return b(this,t,!1,e)},l.prototype.readDoubleBE=function(t,e){return b(this,t,!0,e)},l.prototype.writeUInt8=function(t,e,n){var r=this;n||(C.ok(void 0!==t&&null!==t,"missing value"),C.ok(void 0!==e&&null!==e,"missing offset"),C.ok(e=0?r.writeUInt8(t,e,n):r.writeUInt8(255+t+1,e,n)},l.prototype.writeInt16LE=function(t,e,n){j(this,t,e,!1,n)},l.prototype.writeInt16BE=function(t,e,n){j(this,t,e,!0,n)},l.prototype.writeInt32LE=function(t,e,n){k(this,t,e,!1,n)},l.prototype.writeInt32BE=function(t,e,n){k(this,t,e,!0,n)},l.prototype.writeFloatLE=function(t,e,n){A(this,t,e,!1,n)},l.prototype.writeFloatBE=function(t,e,n){A(this,t,e,!0,n)},l.prototype.writeDoubleLE=function(t,e,n){I(this,t,e,!1,n)},l.prototype.writeDoubleBE=function(t,e,n){I(this,t,e,!0,n)},r.prototype.readUInt8=l.prototype.readUInt8,r.prototype.readUInt16LE=l.prototype.readUInt16LE,r.prototype.readUInt16BE=l.prototype.readUInt16BE,r.prototype.readUInt32LE=l.prototype.readUInt32LE,r.prototype.readUInt32BE=l.prototype.readUInt32BE,r.prototype.readInt8=l.prototype.readInt8,r.prototype.readInt16LE=l.prototype.readInt16LE,r.prototype.readInt16BE=l.prototype.readInt16BE,r.prototype.readInt32LE=l.prototype.readInt32LE,r.prototype.readInt32BE=l.prototype.readInt32BE,r.prototype.readFloatLE=l.prototype.readFloatLE,r.prototype.readFloatBE=l.prototype.readFloatBE,r.prototype.readDoubleLE=l.prototype.readDoubleLE,r.prototype.readDoubleBE=l.prototype.readDoubleBE,r.prototype.writeUInt8=l.prototype.writeUInt8,r.prototype.writeUInt16LE=l.prototype.writeUInt16LE,r.prototype.writeUInt16BE=l.prototype.writeUInt16BE,r.prototype.writeUInt32LE=l.prototype.writeUInt32LE,r.prototype.writeUInt32BE=l.prototype.writeUInt32BE,r.prototype.writeInt8=l.prototype.writeInt8,r.prototype.writeInt16LE=l.prototype.writeInt16LE,r.prototype.writeInt16BE=l.prototype.writeInt16BE,r.prototype.writeInt32LE=l.prototype.writeInt32LE,r.prototype.writeInt32BE=l.prototype.writeInt32BE,r.prototype.writeFloatLE=l.prototype.writeFloatLE,r.prototype.writeFloatBE=l.prototype.writeFloatBE,r.prototype.writeDoubleLE=l.prototype.writeDoubleLE,r.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":5,"base64-js":7}],7:[function(t,e){!function(){"use strict";function t(t){var e,n,i,o,a,s;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(a=t.indexOf("="),a=a>0?t.length-a:0,s=[],i=a>0?t.length-4:t.length,e=0,n=0;i>e;e+=4,n+=3)o=r.indexOf(t[e])<<18|r.indexOf(t[e+1])<<12|r.indexOf(t[e+2])<<6|r.indexOf(t[e+3]),s.push((16711680&o)>>16),s.push((65280&o)>>8),s.push(255&o);return 2===a?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,s.push(255&o)):1===a&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,s.push(255&o>>8),s.push(255&o)),s}function n(t){function e(t){return r[63&t>>18]+r[63&t>>12]+r[63&t>>6]+r[63&t]}var n,i,o,a=t.length%3,s="";for(n=0,o=t.length-a;o>n;n+=3)i=(t[n]<<16)+(t[n+1]<<8)+t[n+2],s+=e(i);switch(a){case 1:i=t[t.length-1],s+=r[i>>2],s+=r[63&i<<4],s+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],s+=r[i>>10],s+=r[63&i>>4],s+=r[63&i<<2],s+="="}return s}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports.toByteArray=t,e.exports.fromByteArray=n}()},{}],8:[function(t,e,n){n.readIEEE754=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,f=-7,l=n?0:i-1,p=n?1:-1,h=t[e+l];for(l+=p,o=h&(1<<-f)-1,h>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=p,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(h?-1:1);a+=Math.pow(2,r),o-=c}return(h?-1:1)*a*Math.pow(2,o-r)},n.writeIEEE754=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?o-1:0,d=r?-1:1,m=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),e+=a+l>=1?p/u:p*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+h]=255&s,h+=d,s/=256,i-=8);for(a=a<0;t[n+h]=255&a,h+=d,a/=256,c-=8);t[n+h-d]|=128*m}},{}],3:[function(t,e,n){function r(t){this.length=t}function i(t){return 16>t?"0"+t.toString(16):t.toString(16)}function o(t){for(var e=[],n=0;ni&&!(i+n>=e.length||i>=t.length);)e[i+n]=t[i],i++;return i}function c(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function f(t){return t=~~Math.ceil(+t),0>t?0:t}function l(t,e,n){if(!(this instanceof l))return new l(t,e,n);var i;if("number"==typeof n)this.length=f(e),this.parent=t,this.offset=n;else{switch(i=typeof t){case"number":this.length=f(t);break;case"string":this.length=l.byteLength(t,e);break;case"object":this.length=f(t.length);break;default:throw new Error("First argument needs to be a number, array or string.")}if(this.length>l.poolSize?(this.parent=new r(this.length),this.offset=0):((!N||N.length-N.used>>0):(i=t.parent[t.offset+e+2]<<16,i|=t.parent[t.offset+e+1]<<8,i|=t.parent[t.offset+e],i+=t.parent[t.offset+e+3]<<24>>>0),i}function g(t,e,n,r){var i,o;return r||(C.ok("boolean"==typeof n,"missing or invalid endian"),C.ok(void 0!==e&&null!==e,"missing offset"),C.ok(e+1=0,"specified a negative value for writing an unsigned value"),C.ok(e>=t,"value is larger than maximum value for type"),C.ok(Math.floor(t)===t,"value has a fractional component")}function w(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+1>>8,t.parent[t.offset+n+1]=255&e):(t.parent[t.offset+n+1]=(65280&e)>>>8,t.parent[t.offset+n]=255&e)}function _(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+3>>24,t.parent[t.offset+n+1]=255&e>>>16,t.parent[t.offset+n+2]=255&e>>>8,t.parent[t.offset+n+3]=255&e):(t.parent[t.offset+n+3]=255&e>>>24,t.parent[t.offset+n+2]=255&e>>>16,t.parent[t.offset+n+1]=255&e>>>8,t.parent[t.offset+n]=255&e)}function E(t,e,n){C.ok("number"==typeof t,"cannot write a non-number as a number"),C.ok(e>=t,"value larger than maximum allowed value"),C.ok(t>=n,"value smaller than minimum allowed value"),C.ok(Math.floor(t)===t,"value has a fractional component")}function S(t,e,n){C.ok("number"==typeof t,"cannot write a non-number as a number"),C.ok(e>=t,"value larger than maximum allowed value"),C.ok(t>=n,"value smaller than minimum allowed value")}function j(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+1=0?w(t,e,n,r,i):w(t,65535+e+1,n,r,i)}function k(t,e,n,r,i){i||(C.ok(void 0!==e&&null!==e,"missing value"),C.ok("boolean"==typeof r,"missing or invalid endian"),C.ok(void 0!==n&&null!==n,"missing offset"),C.ok(n+3=0?_(t,e,n,r,i):_(t,4294967295+e+1,n,r,i)}function A(e,n,r,i,o){o||(C.ok(void 0!==n&&null!==n,"missing value"),C.ok("boolean"==typeof i,"missing or invalid endian"),C.ok(void 0!==r&&null!==r,"missing offset"),C.ok(r+3r;r++)if(t[r]=i(this[r]),r==n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.hexSlice=function(t,e){var n=this.length;(!t||0>t)&&(t=0),(!e||0>e||e>n)&&(e=n);for(var r="",o=t;e>o;o++)r+=i(this[o]);return r},r.prototype.toString=function(t,e,n){if(t=String(t||"utf8").toLowerCase(),e=+e||0,"undefined"==typeof n&&(n=this.length),+n==e)return"";switch(t){case"hex":return this.hexSlice(e,n);case"utf8":case"utf-8":return this.utf8Slice(e,n);case"ascii":return this.asciiSlice(e,n);case"binary":return this.binarySlice(e,n);case"base64":return this.base64Slice(e,n);case"ucs2":case"ucs-2":return this.ucs2Slice(e,n);default:throw new Error("Unknown encoding")}},r.prototype.hexWrite=function(t,e,n){e=+e||0;var i=this.length-e;n?(n=+n,n>i&&(n=i)):n=i;var o=t.length;if(o%2)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;n>a;a++){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))throw new Error("Invalid hex string");this[e+a]=s}return r._charsWritten=2*a,a},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var i=r;r=e,e=n,n=i}e=+e||0;var o=this.length-e;switch(n?(n=+n,n>o&&(n=o)):n=o,r=String(r||"utf8").toLowerCase()){case"hex":return this.hexWrite(t,e,n);case"utf8":case"utf-8":return this.utf8Write(t,e,n);case"ascii":return this.asciiWrite(t,e,n);case"binary":return this.binaryWrite(t,e,n);case"base64":return this.base64Write(t,e,n);case"ucs2":case"ucs-2":return this.ucs2Write(t,e,n);default:throw new Error("Unknown encoding")}},r.prototype.slice=function(t,e){if(void 0===e&&(e=this.length),e>this.length)throw new Error("oob");if(t>e)throw new Error("oob");return new l(this,e-t,+t)},r.prototype.copy=function(t,e,n,r){for(var i=[],o=n;r>o;o++)C.ok("undefined"!=typeof this[o],"copying undefined buffer bytes!"),i.push(this[o]);for(var o=e;or;r++)if(t[r]=i(this.parent[r+this.offset]),r==n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},l.prototype.get=function(t){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]},l.prototype.set=function(t,e){if(0>t||t>=this.length)throw new Error("oob");return this.parent[this.offset+t]=e},l.prototype.write=function(t,e,n,i){if(isFinite(e))isFinite(n)||(i=n,n=void 0);else{var o=i;i=e,e=n,n=o}e=+e||0;var a=this.length-e;n?(n=+n,n>a&&(n=a)):n=a,i=String(i||"utf8").toLowerCase();var s;switch(i){case"hex":s=this.parent.hexWrite(t,this.offset+e,n);break;case"utf8":case"utf-8":s=this.parent.utf8Write(t,this.offset+e,n);break;case"ascii":s=this.parent.asciiWrite(t,this.offset+e,n);break;case"binary":s=this.parent.binaryWrite(t,this.offset+e,n);break;case"base64":s=this.parent.base64Write(t,this.offset+e,n);break;case"ucs2":case"ucs-2":s=this.parent.ucs2Write(t,this.offset+e,n);break;default:throw new Error("Unknown encoding")}return l._charsWritten=r._charsWritten,s},l.prototype.toString=function(t,e,n){switch(t=String(t||"utf8").toLowerCase(),"undefined"==typeof e||0>e?e=0:e>this.length&&(e=this.length),"undefined"==typeof n||n>this.length?n=this.length:0>n&&(n=0),e+=this.offset,n+=this.offset,t){case"hex":return this.parent.hexSlice(e,n);case"utf8":case"utf-8":return this.parent.utf8Slice(e,n);case"ascii":return this.parent.asciiSlice(e,n);case"binary":return this.parent.binarySlice(e,n);case"base64":return this.parent.base64Slice(e,n);case"ucs2":case"ucs-2":return this.parent.ucs2Slice(e,n);default:throw new Error("Unknown encoding")}},l.byteLength=r.byteLength,l.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw new Error("value is not a number");if(e>n)throw new Error("end < start");if(n===e)return 0;if(0==this.length)return 0;if(0>e||e>=this.length)throw new Error("start out of bounds");if(0>n||n>this.length)throw new Error("end out of bounds");return this.parent.fill(t,e+this.offset,n+this.offset)},l.prototype.copy=function(t,e,n,r){var i=this;if(n||(n=0),r||(r=this.length),e||(e=0),n>r)throw new Error("sourceEnd < sourceStart");if(r===n)return 0;if(0==t.length||0==i.length)return 0;if(0>e||e>=t.length)throw new Error("targetStart out of bounds");if(0>n||n>=i.length)throw new Error("sourceStart out of bounds");if(0>r||r>i.length)throw new Error("sourceEnd out of bounds");return r>this.length&&(r=this.length),t.length-ethis.length)throw new Error("oob");if(t>e)throw new Error("oob");return new l(this.parent,e-t,+t+this.offset)},l.prototype.utf8Slice=function(t,e){return this.toString("utf8",t,e)},l.prototype.binarySlice=function(t,e){return this.toString("binary",t,e)},l.prototype.asciiSlice=function(t,e){return this.toString("ascii",t,e)},l.prototype.utf8Write=function(t,e){return this.write(t,e,"utf8")},l.prototype.binaryWrite=function(t,e){return this.write(t,e,"binary")},l.prototype.asciiWrite=function(t,e){return this.write(t,e,"ascii")},l.prototype.readUInt8=function(t,e){var n=this;return e||(C.ok(void 0!==t&&null!==t,"missing offset"),C.ok(t=0?r.writeUInt8(t,e,n):r.writeUInt8(255+t+1,e,n)},l.prototype.writeInt16LE=function(t,e,n){j(this,t,e,!1,n)},l.prototype.writeInt16BE=function(t,e,n){j(this,t,e,!0,n)},l.prototype.writeInt32LE=function(t,e,n){k(this,t,e,!1,n)},l.prototype.writeInt32BE=function(t,e,n){k(this,t,e,!0,n)},l.prototype.writeFloatLE=function(t,e,n){A(this,t,e,!1,n)},l.prototype.writeFloatBE=function(t,e,n){A(this,t,e,!0,n)},l.prototype.writeDoubleLE=function(t,e,n){I(this,t,e,!1,n)},l.prototype.writeDoubleBE=function(t,e,n){I(this,t,e,!0,n)},r.prototype.readUInt8=l.prototype.readUInt8,r.prototype.readUInt16LE=l.prototype.readUInt16LE,r.prototype.readUInt16BE=l.prototype.readUInt16BE,r.prototype.readUInt32LE=l.prototype.readUInt32LE,r.prototype.readUInt32BE=l.prototype.readUInt32BE,r.prototype.readInt8=l.prototype.readInt8,r.prototype.readInt16LE=l.prototype.readInt16LE,r.prototype.readInt16BE=l.prototype.readInt16BE,r.prototype.readInt32LE=l.prototype.readInt32LE,r.prototype.readInt32BE=l.prototype.readInt32BE,r.prototype.readFloatLE=l.prototype.readFloatLE,r.prototype.readFloatBE=l.prototype.readFloatBE,r.prototype.readDoubleLE=l.prototype.readDoubleLE,r.prototype.readDoubleBE=l.prototype.readDoubleBE,r.prototype.writeUInt8=l.prototype.writeUInt8,r.prototype.writeUInt16LE=l.prototype.writeUInt16LE,r.prototype.writeUInt16BE=l.prototype.writeUInt16BE,r.prototype.writeUInt32LE=l.prototype.writeUInt32LE,r.prototype.writeUInt32BE=l.prototype.writeUInt32BE,r.prototype.writeInt8=l.prototype.writeInt8,r.prototype.writeInt16LE=l.prototype.writeInt16LE,r.prototype.writeInt16BE=l.prototype.writeInt16BE,r.prototype.writeInt32LE=l.prototype.writeInt32LE,r.prototype.writeInt32BE=l.prototype.writeInt32BE,r.prototype.writeFloatLE=l.prototype.writeFloatLE,r.prototype.writeFloatBE=l.prototype.writeFloatBE,r.prototype.writeDoubleLE=l.prototype.writeDoubleLE,r.prototype.writeDoubleBE=l.prototype.writeDoubleBE},{assert:1,"./buffer_ieee754":8,"base64-js":9}],9:[function(t,e){!function(){"use strict";function t(t){var e,n,i,o,a,s;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(a=t.indexOf("="),a=a>0?t.length-a:0,s=[],i=a>0?t.length-4:t.length,e=0,n=0;i>e;e+=4,n+=3)o=r.indexOf(t[e])<<18|r.indexOf(t[e+1])<<12|r.indexOf(t[e+2])<<6|r.indexOf(t[e+3]),s.push((16711680&o)>>16),s.push((65280&o)>>8),s.push(255&o);return 2===a?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,s.push(255&o)):1===a&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,s.push(255&o>>8),s.push(255&o)),s}function n(t){function e(t){return r[63&t>>18]+r[63&t>>12]+r[63&t>>6]+r[63&t]}var n,i,o,a=t.length%3,s="";for(n=0,o=t.length-a;o>n;n+=3)i=(t[n]<<16)+(t[n+1]<<8)+t[n+2],s+=e(i);switch(a){case 1:i=t[t.length-1],s+=r[i>>2],s+=r[63&i<<4],s+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],s+=r[i>>10],s+=r[63&i>>4],s+=r[63&i<<2],s+="="}return s}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports.toByteArray=t,e.exports.fromByteArray=n}()},{}]},{},[]),e.exports=t("buffer-browserify")},{}],69:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],70:[function(t,e){function n(t,e){return o.init(this,e,t)}var r=t("./vendor/lodash"),i=t("async"),o=t("jxt"),a=t("xhr"),s=new DOMParser;n.prototype={constructor:{value:n},NS:"http://docs.oasis-open.org/ns/xri/xrd-1.0",EL:"XRD",toString:o.toString,toJSON:o.toJSON,get subject(){return o.getSubText(this.xml,this.NS,"Subject")},get expires(){return new Date(o.getSubText(this.xml,this.NS,"Expires"))},get aliases(){return o.getMultiSubText(this.xml,this.NS,"Alias")},get properties(){var t={},e=o.find(this.xml,this.NS,"Property");return r.each(e,function(e){var n=o.getAttribute(e,"type");t[n]=e.textContent}),t},get links(){var t=[],e=o.find(this.xml,this.NS,"Link");return r.each(e,function(e){var n={rel:o.getAttribute(e,"rel"),href:o.getAttribute(e,"href"),type:o.getAttribute(e,"type"),template:o.getAttribute(e,"template"),titles:o.getSubLangText(e,this.NS,"Title","default"),properties:{}},i=o.find(e,this.NS,"Property");r.each(i,function(t){var e=o.getAttribute(t,"type");n.properties[e]=t.textContent}),t.push(n)}),t}},e.exports=function(t,e){"string"==typeof t&&(t={host:t}),t=r.extend({ssl:!0,json:!0},t);var o=t.ssl?"https://":"http://";i.parallel({json:function(e){return t.json?(a({uri:o+t.host+"/.well-known/host-meta.json"},function(t,n,r){if(t)return e();try{e("completed",JSON.parse(r))}catch(i){e(null,{})}}),void 0):e(null,{})},xrd:function(e){a({uri:o+t.host+"/.well-known/host-meta"},function(t,r){if(t)return e(null,{});try{var i=s.parseFromString(r.body,"application/xml").childNodes[0],o=new n({},i);e("completed",o.toJSON())}catch(a){e(null,{})}})}},function(t,n){if(t){if(Object.keys(n.json).length)return e(!1,n.json);if(Object.keys(n.xrd).length)return e(!1,n.xrd)}e("no-host-meta",{})})}},{"./vendor/lodash":76,async:56,jxt:71,xhr:73}],71:[function(t,e,n){var r=t("./vendor/lodash"),i=new XMLSerializer,o="http://www.w3.org/XML/1998/namespace",a={},s={},u={},c=n.find=function(t,e,n){var i=t.querySelectorAll(n);return r.filter(i,function(n){return n.namespaceURI===e&&n.parentNode==t})};n.findOrCreate=function(t,e,n){var r=c(t,e,n);if(r.length)return r[0];var i=document.createElementNS(e,n);return t.appendChild(i),i},n.init=function(t,e,n){return t.xml=e||document.createElementNS(t.NS,t.EL),t.xml.parentNode&&t.xml.parentNode.namespaceURI===t.NS||t.xml.setAttribute("xmlns",t.NS),t._extensions={},r.each(t.xml.childNodes,function(e){var n=e.namespaceURI+"|"+e.localName,r=s[n];if(void 0!==r){var i=r.prototype._name;t._extensions[i]=new r(null,e),t._extensions[i].parent=t}}),r.extend(t,n),t},n.getSubText=function(t,e,n){var r=c(t,e,n);if(!r)return"";for(var i=0;i=0?Object.keys(r).length>0&&(e[t]=r):i.indexOf("Array")>=0?r.length>0&&(e[t]=r):r&&(e[t]=r)}return e},n.extend=function(t,e){var i=t.prototype.NS+"|"+t.prototype.EL,o=e.prototype._name,a=e.prototype.NS+"|"+e.prototype.EL;s[a]=e,u[a]||(u[a]={}),u[i]||(u[i]={}),u[i][o]=e,t.prototype.__defineGetter__(o,function(){if(!this._extensions[o]){var t=n.find(this.xml,e.prototype.NS,e.prototype.EL);t.length?this._extensions[o]=new e(null,t[0]):(this._extensions[o]=new e,this.xml.appendChild(this._extensions[o].xml)),this._extensions[o].parent=this}return this._extensions[o]}),t.prototype.__defineSetter__(o,function(t){var e=this[o];r.extend(e,t)})},n.topLevel=function(t){var e=t.prototype.NS+"|"+t.prototype.EL;s[e]=t,a[e]=t},n.build=function(t){var e=a[t.namespaceURI+"|"+t.localName];return e?new e(null,t):void 0},n.XML_NS=o,n.TOP_LEVEL_LOOKUP=a,n.LOOKUP_EXT=u,n.LOOKUP=s},{"./vendor/lodash":72}],72:[function(e,n,r){var i=self;!function(e){function o(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function a(t){t.length=0,y.lengthk;k++)r+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(r+="||(!v[m]&&r[m]!==y[m])"),r+="){"+t.f+"}";r+="}"}return(t.b||Y.nonEnumArgs)&&(r+="}"),r+=t.c+";return C",e=e("i,j,l,n,o,q,t,u,y,z,w,G,H,J",n+r+"}"),s(t),e(C,U,D,f,Z,d,ee,u,z,q,K,T,R,J)}function f(t){return J.call(t)==S}function l(t,e,n,r,i,s){var c=n===x;if("function"==typeof n&&!c){n=u.createCallback(n,r,2);var h=n(t,e);if("undefined"!=typeof h)return!!h}if(t===e)return 0!==t||1/t==1/e;var d=typeof t,m=typeof e;if(t===t&&(!t||"function"!=d&&"object"!=d)&&(!e||"function"!=m&&"object"!=m))return!1;if(null==t||null==e)return t===e;if(m=J.call(t),d=J.call(e),m==S&&(m=O),d==S&&(d=O),m!=d)return!1;switch(m){case A:case I:return+t==+e;case N:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case L:case T:return t==e+""}if(d=m==j,!d){if(D.call(t,"__wrapped__")||D.call(e,"__wrapped__"))return l(t.__wrapped__||t,e.__wrapped__||e,n,r,i,s);if(m!=O||!Y.nodeClass&&(o(t)||o(e)))return!1;var m=!Y.argsObject&&f(t)?Object:t.constructor,g=!Y.argsObject&&f(e)?Object:e.constructor;if(!(m==g||p(m)&&m instanceof m&&p(g)&&g instanceof g))return!1}for(g=!i,i||(i=y.pop()||[]),s||(s=y.pop()||[]),m=i.length;m--;)if(i[m]==t)return s[m]==e;var v=0,h=!0;if(i.push(t),s.push(e),d){if(m=t.length,v=e.length,h=v==t.length,!h&&!c)return h;for(;v--;)if(d=m,g=e[v],c)for(;d--&&!(h=l(t[d],g,n,r,i,s)););else if(!(h=l(t[v],g,n,r,i,s)))break;return h}return re(e,function(e,o,a){return D.call(a,o)?(v++,h=D.call(t,o)&&l(t[o],e,n,r,i,s)):void 0}),h&&!c&&re(t,function(t,e,n){return D.call(n,e)?h=-1<--v:void 0}),g&&(a(i),a(s)),h}function p(t){return"function"==typeof t}function h(t){return!(!t||!q[typeof t])}function d(t){return"string"==typeof t||J.call(t)==T}function m(t,e,n){var r=[];if(e=u.createCallback(e,n),Z(t)){n=-1;for(var i=t.length;++n3&&typeof a[c-2]=='function'){var d=u.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),f:"C[m]=d?d(C[m],r[m]):r[m]"}),re=c($,F,{i:!1});p(/x/)&&(p=function(t){return"function"==typeof t&&"[object Function]"==J.call(t)}),u.assign=X,u.createCallback=function(t,e,n){if(null==t)return v;var r=typeof t;if("function"!=r){if("object"!=r)return function(e){return e[t]};var i=ee(t);return function(e){for(var n=i.length,r=!1;n--&&(r=l(e[i[n]],t[i[n]],x)););return r}}return"undefined"==typeof e||_&&!_.test(P.call(t))?t:1===n?function(n){return t.call(e,n)}:2===n?function(n,r){return t.call(e,n,r)}:4===n?function(n,r,i,o){return t.call(e,n,r,i,o)}:function(n,r,i){return t.call(e,n,r,i)}},u.filter=m,u.forEach=g,u.forIn=re,u.keys=ee,u.each=g,u.extend=X,u.select=m,u.identity=v,u.isArguments=f,u.isArray=Z,u.isEqual=l,u.isFunction=p,u.isObject=h,u.isString=d,u.VERSION="1.3.1","function"==typeof t&&"object"==typeof t.amd&&t.amd?(e._=u,t(function(){return u})):B&&!B.nodeType?M?(M.exports=u)._=u:B._=u:e._=u}(this)},{}],73:[function(t,e){function n(t,e){function n(){4===f.readyState&&i()}function i(){var t=null,n=f.statusCode=f.status,r=f.body=f.response||f.responseText||f.responseXML;if(0===n||n>=400&&600>n){var i=f.responseText||a[String(f.status).charAt(0)];t=new Error(i),t.statusCode=f.status}if(m)try{r=f.body=JSON.parse(r)}catch(o){}e(t,f,r)}function c(t){e(t,f)}"string"==typeof t&&(t={uri:t}),t=t||{},e=o(e);var f;t.cors?(f=new u,f.withCredentials=!0):f=new s;var l=f.url=t.uri,p=f.method=t.method||"GET",h=t.body||t.data,d=f.headers=t.headers||{},m=!1;return"json"in t&&(m=!0,d["Content-Type"]="application/json",h=JSON.stringify(t.json)),f.onreadystatechange=n,f.onload=i,f.onerror=c,f.onprogress=function(){},f.ontimeout=r,f.open(p,l),f.timeout="timeout"in t?t.timeout:5e3,f.setRequestHeader&&Object.keys(d).forEach(function(t){f.setRequestHeader(t,d[t])}),f.send(h),f}function r(){}var i=t("global/window"),o=t("once"),a={0:"Internal XMLHttpRequest Error",4:"4xx Client Error",5:"5xx Server Error"},s=i.XMLHttpRequest||r,u="withCredentials"in new s?i.XMLHttpRequest:i.XDomainRequest; diff --git a/clientapp/models/contact.js b/clientapp/models/contact.js index 6ee69d7..f7167f5 100644 --- a/clientapp/models/contact.js +++ b/clientapp/models/contact.js @@ -201,7 +201,7 @@ module.exports = HumanModel.define({ results.forEach(function (result) { result = result.toJSON(); var msg = result.mam.forwarded.message; - + if (!msg.id) { msg.id = uuid.v4(); } @@ -221,6 +221,7 @@ module.exports = HumanModel.define({ var message = new Message(msg); message.archivedId = result.mam.id; + message.acked = true; self.addMessage(message, false); }); diff --git a/clientapp/models/message.js b/clientapp/models/message.js index 560edcc..70944c3 100644 --- a/clientapp/models/message.js +++ b/clientapp/models/message.js @@ -45,6 +45,7 @@ module.exports = HumanModel.define({ deps: ['created'], fn: function () { if (this.created) { + console.log(this.created); var month = this.created.getMonth(); var day = this.created.getDate(); var hour = this.created.getHours(); @@ -59,6 +60,12 @@ module.exports = HumanModel.define({ } return undefined; } + }, + pending: { + deps: ['acked'], + fn: function () { + return !this.acked; + } } }, session: { @@ -71,7 +78,7 @@ module.exports = HumanModel.define({ if (this.from.full !== msg.from.full) return false; delete msg.id; - + this.set(msg); this._created = Date.now(); this.edited = true; diff --git a/clientapp/models/messages.js b/clientapp/models/messages.js index 8975916..3ebac12 100644 --- a/clientapp/models/messages.js +++ b/clientapp/models/messages.js @@ -6,14 +6,5 @@ var Message = require('./message'); module.exports = BaseCollection.extend({ type: 'messages', - model: Message, - comparator: function (msg1, msg2) { - if (msg1.created < msg2.created) { - return -1; - } - if (msg1.created > msg2.created) { - return 1; - } - return 0; - } + model: Message }); diff --git a/clientapp/views/message.js b/clientapp/views/message.js index 46d9f66..1fc0a87 100644 --- a/clientapp/views/message.js +++ b/clientapp/views/message.js @@ -14,7 +14,7 @@ module.exports = HumanView.extend({ classBindings: { mine: '.message', receiptReceived: '.message', - acked: '.message', + pending: '.message', delayed: '.message', edited: '.message' }, diff --git a/public/css/app/chat.styl b/public/css/app/chat.styl index d6680c7..b90d1f7 100644 --- a/public/css/app/chat.styl +++ b/public/css/app/chat.styl @@ -108,6 +108,9 @@ .timestamp:before content: 'edited ' + &.pending + background-color: red + .body display: inline word-break: break-word diff --git a/public/css/otalk.css b/public/css/otalk.css index 2acdba5..39832a3 100644 --- a/public/css/otalk.css +++ b/public/css/otalk.css @@ -723,6 +723,9 @@ h4 { .messages .message.edited .timestamp:before { content: 'edited '; } +.messages .message.pending { + background-color: #f00; +} .messages .message .body { display: inline; word-break: break-word;