!function(a,b,c,d){a.fn.chatroom=function(b){var c=a.extend(!0,{},a.fn.chatroom.settings,b),e=c.className,f=c.namespace,g=c.selector,h=c.error;return a(this).each(function(){var b,i,j,k,l,m,n,o=a(this),p=o.find(g.expandButton),q=o.find(g.userListButton),r=o.find(g.userList),s=(o.find(g.room),o.find(g.userCount)),t=o.find(g.log),u=(o.find(g.message),o.find(g.messageInput)),v=o.find(g.messageButton),w=o.data("module"),x="",y={};n={width:{log:t.width(),userList:r.outerWidth()},initialize:function(){return Pusher===d&&n.error(h.pusher),c.key===d||c.channelName===d?(n.error(h.key),!1):c.endpoint.message||c.endpoint.authentication?(m=new Pusher(c.key),Pusher.channel_auth_endpoint=c.endpoint.authentication,b=m.subscribe(c.channelName),b.bind("pusher:subscription_succeeded",n.user.list.create),b.bind("pusher:subscription_error",n.error),b.bind("pusher:member_added",n.user.joined),b.bind("pusher:member_removed",n.user.left),b.bind("update_messages",n.message.receive),a.each(c.customEvents,function(a,c){b.bind(a,c)}),q.on("click."+f,n.event.toggleUserList),p.on("click."+f,n.event.toggleExpand),u.on("keydown."+f,n.event.input.keydown).on("keyup."+f,n.event.input.keyup),v.on("mouseenter."+f,n.event.hover).on("mouseleave."+f,n.event.hover).on("click."+f,n.event.submit),t.animate({scrollTop:t.prop("scrollHeight")},400),o.data("module",n).addClass(e.loading),void 0):(n.error(h.endpoint),!1)},refresh:function(){q.removeClass(e.active),n.width={log:t.width(),userList:r.outerWidth()},q.hasClass(e.active)&&n.user.list.hide(),o.data("module",n)},user:{updateCount:function(){c.userCount&&(y=o.data("users"),k=0,a.each(y,function(){k++}),s.html(c.templates.userCount(k)))},joined:function(b){y=o.data("users"),"anonymous"!=b.id&&y[b.id]===d&&(y[b.id]=b.info,c.randomColor&&b.info.color===d&&(b.info.color=c.templates.color(b.id)),x=c.templates.userList(b.info),b.info.isAdmin?a(x).prependTo(r):a(x).appendTo(r),c.partingMessages&&(t.append(c.templates.joined(b.info)),n.message.scroll.test()),n.user.updateCount())},left:function(a){y=o.data("users"),a!==d&&"anonymous"!==a.id&&(delete y[a.id],o.data("users",y),r.find("[data-id="+a.id+"]").remove(),c.partingMessages&&(t.append(c.templates.left(a.info)),n.message.scroll.test()),n.user.updateCount())},list:{create:function(b){y={},b.each(function(a){"anonymous"!==a.id&&"undefined"!==a.id&&(c.randomColor&&a.info.color===d&&(a.info.color=c.templates.color(a.id)),x=a.info.isAdmin?c.templates.userList(a.info)+x:x+c.templates.userList(a.info),y[a.id]=a.info)}),o.data("users",y).data("user",y[b.me.id]).removeClass(e.loading),r.html(x),n.user.updateCount(),a.proxy(c.onJoin,r.children())()},show:function(){t.animate({width:n.width.log-n.width.userList},{duration:c.speed,easing:c.easing,complete:n.message.scroll.move})},hide:function(){t.stop().animate({width:n.width.log},{duration:c.speed,easing:c.easing,complete:n.message.scroll.move})}}},message:{scroll:{test:function(){l=t.prop("scrollHeight")-t.height(),Math.abs(t.scrollTop()-l)0&&(console.groupCollapsed(b),console.table?console.table(performance):a.each(performance,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),performance=[]}},invoke:function(b,c,e){var f,g;return c=c||queryArguments,e=element||e,"string"==typeof b&&w!==d&&(b=b.split(/[\. ]/),f=b.length-1,a.each(b,function(b,c){a.isPlainObject(w[c])&&b!=f?w=w[c]:w[c]!==d?g=w[c]:n.error(h.method)})),a.isFunction(g)?g.apply(e,c):g||!1}},methodInvoked?(w===d&&n.initialize(),invokedResponse=n.invoke(query)):(w!==d&&n.destroy(),n.initialize())}),invokedResponse?invokedResponse:this},a.fn.chatroom.settings={name:"Chat",debug:!1,namespace:"chat",channel:"present-chat",onJoin:function(){},onMessage:function(){},onExpand:function(){},onContract:function(){},customEvents:{},partingMessages:!1,userCount:!0,randomColor:!0,speed:300,easing:"easeOutQuint",scrollArea:9999,endpoint:{message:!1,authentication:!1},error:{method:"The method you called is not defined",endpoint:"Please define a message and authentication endpoint.",key:"You must specify a pusher key and channel.",pusher:"You must include the Pusher library."},className:{expand:"expand",active:"active",hover:"hover",down:"down",loading:"loading"},selector:{userCount:".actions .message",userListButton:".actions .list.button",expandButton:".actions .expand.button",room:".room",userList:".room .list",log:".room .log",message:".room .log .message",author:".room log .message .author",messageInput:".talk input",messageButton:".talk .send.button"},templates:{userCount:function(a){return a+" users in chat"},color:function(){var a=["#000000","#333333","#666666","#999999","#CC9999","#CC6666","#CC3333","#993333","#663333","#CC6633","#CC9966","#CC9933","#999966","#CCCC66","#99CC66","#669933","#669966","#33A3CC","#336633","#33CCCC","#339999","#336666","#336699","#6666CC","#9966CC","#333399","#663366","#996699","#993366","#CC6699"];return a[Math.floor(Math.random()*a.length)]},message:function(a){var b="";return a.user.isAdmin?(a.user.color="#55356A",b+='
',b+=''):b+='
',b+="

",b+=a.user.color!==d?''+a.user.name+": ":''+a.user.name+": ",b+=""+a.text+"

"+"
"},joined:function(a){return typeof a.name!==d?'
'+a.name+" has joined the chat.
":!1},left:function(a){return typeof a.name!==d?'
'+a.name+" has left the chat.
":!1},userList:function(a){var b="";return a.isAdmin&&(a.color="#55356A"),b+='
'+'
'+' '+"
",b+=a.color!==d?'

'+a.name+"

":'

'+a.name+"

",b+="
"}}}}(jQuery,window,document);