/*1358292647,178142559*/

if (self.CavalryLogger) { CavalryLogger.start_js(["z6ddB"]); }

__d("NotificationConstants",[],function(a,b,c,d,e,f){e.exports={PayloadSourceType:{UNKNOWN:0,USER_ACTION:1,LIVE_SEND:2,ENDPOINT:3,INITIAL_LOAD:4}};});
__d("NotificationTokens",["Env"],function(a,b,c,d,e,f){var g=b('Env'),h={tokenizeIDs:function(i){return i.map(function(j){return g.user+':'+j;});},untokenizeIDs:function(i){return i.map(function(j){return j.split(':')[1];});}};e.exports=h;});
__d("NotificationUpdates",["Arbiter","ChannelConstants","NotificationConstants","NotificationTokens","LiveTimer","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){var g=b('Arbiter'),h=b('ChannelConstants'),i=b('NotificationConstants'),j=b('NotificationTokens'),k=b('LiveTimer'),l=b('copyProperties'),m=b('createObjectFrom'),n={},o={},p={},q={},r={},s=[],t=0;function u(){if(t)return;var y=n,z=o,aa=p,ba=q,ca=r;n={};o={};p={};q={};r={};if(Object.keys(y).length)w('notifications-updated',y);if(Object.keys(z).length)w('beeps-updated',z);if(Object.keys(aa).length)w('seen-state-updated',aa);if(Object.keys(ba).length)w('read-state-updated',ba);if(Object.keys(ca).length)w('hidden-state-updated',ca);s.pop();}function v(){if(s.length)return s[s.length-1];return i.PayloadSourceType.UNKNOWN;}function w(event,y){x.inform(event,{updates:y,source:v()});}g.subscribe(h.getArbiterType('notification_json'),function(y,z){var aa=Date.now(),ba=z.obj.nodes;if(ba){ba.forEach(function(ca){ca.receivedTime=aa;});x.handleUpdate(i.PayloadSourceType.LIVE_SEND,{nodes:z.obj.nodes});}});g.subscribe(h.getArbiterType('notifications_seen'),function(y,z){var aa=j.tokenizeIDs(z.obj.alert_ids);x.handleUpdate(i.PayloadSourceType.LIVE_SEND,{seenState:m(aa)});});g.subscribe(h.getArbiterType('notifications_read'),function(y,z){var aa=j.tokenizeIDs(z.obj.alert_ids);x.handleUpdate(i.PayloadSourceType.LIVE_SEND,{readState:m(aa)});});var x=l(new g(),{handleUpdate:function(y,z){if(Object.keys(z).length)this.synchronizeInforms(function(){s.push(y);var aa=l({payloadsource:v()},z);this.inform('update-notifications',aa);this.inform('update-seen',aa);this.inform('update-read',aa);this.inform('update-hidden',aa);}.bind(this));if(z.servertime)k.restart(z.servertime);},didUpdateNotifications:function(y){l(n,m(y));u();},didUpdateBeeps:function(y){l(o,m(y));u();},didUpdateSeenState:function(y){l(p,m(y));u();},didUpdateReadState:function(y){l(q,m(y));u();},didUpdateHiddenState:function(y){l(r,m(y));u();},synchronizeInforms:function(y){t++;try{y();}catch(z){throw z;}finally{t--;u();}}});e.exports=x;});
__d("NotificationBeeps",["NotificationConstants","NotificationUpdates"],function(a,b,c,d,e,f){var g=b('NotificationConstants'),h=b('NotificationUpdates'),i=g.PayloadSourceType.LIVE_SEND,j={};h.subscribe('update-notifications',function(l,m){if(m.payloadsource!==i)return;var n=m.nodes;if(n&&n.length){var o=[];n.forEach(function(p){var q=p.alert_id,r=q+'-'+p.receivedTime;j[q]={notificationID:q,beepID:r,actors:p.actors,icon:p.icon,link:p.url,text:p.unaggregatedTitle||p.title,timestamp:p.timestamp,receivedTime:p.receivedTime,sound:!!p.sound,tracking:p.tracking};o.push(r);});h.didUpdateBeeps(o);}});var k={getBeeps:function(){return j;}};e.exports=k;});
__d("supportsCSSAnimation",[],function(a,b,c,d,e,f){var g=null;function h(){if(g===null){var i=document.createElement('div');if(i.style.animationName)return (g=true);var j=['Webkit','Moz','O','ms'];for(var k=0;k<j.length;k++)if(typeof i.style[j[k]+'AnimationName']!=='undefined')return (g=true);g=false;}return g;}e.exports=h;});
__d("NotificationBeeperItem",["ReactDOM","Animation","CloseButton","ImageBlock","Layout","NotificationURI","React","ReactTextWithEntities","Timestamp","cx","setTimeoutAcrossTransitions","supportsCSSAnimation"],function(a,b,c,d,e,f){var g=b('ReactDOM'),h=b('Animation'),i=b('CloseButton'),j=b('ImageBlock'),k=b('Layout'),l=b('NotificationURI'),m=b('React'),n=b('ReactTextWithEntities'),o=b('Timestamp'),p=b('cx'),q=b('setTimeoutAcrossTransitions'),r=b('supportsCSSAnimation'),s={};s._3soc=true;function t(v,w){return g.span({className:"fwb",children:v});}var u=m.createComponent({getInitialState:function(){return {hidden:false,fadedIn:false,flashing:false};},_onClick:function(){this.props.onClickItem([this.props.beep.notificationID]);},_onHide:function(){this.updateState({hidden:true});},onDomReady:function(){var v;if(r()){v=this.createStateUpdater({fadedIn:true});}else v=function(){new h(this.refs.item.getDOMNode()).from('top','-30px').from('opacity','0').to('top','0px').to('opacity','1').duration(200).ondone(this.createStateUpdater({fadedIn:true})).go();}.bind(this);q(v,50);this.props.onInserted(this.props.beep);},propTrigger:function(v){if(v.beep.beepID!=this.props.beep.beepID){var w;if(r()){w=this.createStateUpdater({flashing:false});}else w=function(){new h(this.refs.inner.getDOMNode()).from('opacity','0').to('opacity','1').duration(200).ondone(this.createStateUpdater({flashing:false})).go();}.bind(this);q(w,50);return {flashing:true};}},render:function(){var v=this.props.beep,w={};w._3sod=true;w._3soe=this.state.fadedIn;w._3sof=this.state.hidden;var x={};if(this.state.fadedIn){x._3sog=this.state.flashing;x._3soh=!this.state.flashing;}var y=v.icon.uri,z=v.link?l.localize(v.link):'#';return (g.li({classSet:w,ref:"item",'data-gt':v.tracking,children:g.div({classSet:x,ref:"inner",children:[i({classSet:s,onClick:this._onHide.bind(this),size:k.size.small}),g.a({href:z,onClick:this._onClick.bind(this),className:"_3soi",children:j({className:"_3soj",children:[g.img({src:v.actors[0].profile_picture.uri,className:"_3sok"}),g.div({className:"_3sol",children:[n({interpolator:t,ranges:v.text.ranges,aggregatedranges:v.text.aggregated_ranges,text:v.text.text}),j({className:"_3som",children:[g.img({src:y}),o({time:v.timestamp.time,text:v.timestamp.text,verbose:v.timestamp.verbose})]})]})]})})]})}));}});e.exports=u;});
__d("NotificationSound",["Sound","copyProperties"],function(a,b,c,d,e,f){var g=b('Sound'),h=b('copyProperties'),i=5000;g.init(['audio/mpeg']);function j(k){this._soundPath=k;this._lastPlayed=0;}h(j.prototype,{play:function(k){if(!this._soundPath)return;var l=Date.now();if((l-this._lastPlayed)<i)return;this._lastPlayed=l;g.play(this._soundPath,k);}});e.exports=j;});
__d("NotificationBeeper",["ReactDOM","Animation","NotificationBeeperItem","NotificationSound","React","Style","createObjectFrom","cx","merge","setTimeoutAcrossTransitions"],function(a,b,c,d,e,f){var g=b('ReactDOM'),h=b('Animation'),i=b('NotificationBeeperItem'),j=b('NotificationSound'),k=b('React'),l=b('Style'),m=b('createObjectFrom'),n=b('cx'),o=b('merge'),p=b('setTimeoutAcrossTransitions'),q=5000,r=k.createComponent({getInitialState:function(){return {hovering:false,fading:false,paused:false,pendingBeeps:{},renderedBeeps:{},expiredBeeps:{}};},_onMouseEnter:function(){if(this.state.paused)return;this._hideWait&&clearTimeout(this._hideWait);if(this.state.fading){this._animation.stop();this._animation=null;l.set(this.refs.container.getDOMNode(),'opacity','0.96');}var s=o(this.state.renderedBeeps,this.state.pendingBeeps);this.props.onHover(Object.keys(s));this.updateState({hovering:true,fading:false,pendingBeeps:{},renderedBeeps:s});},_onMouseLeave:function(){if(this.state.paused)return;this._waitToHide(2000);this.updateState({hovering:false});},_onInsertedItem:function(s){if(!this.state.hovering)this._waitToHide();if(this.props.soundEnabled&&s.sound){if(!this._notifSound)this._notifSound=new j(this.props.soundPath);this._notifSound.play(s.beepID);}this.props.onImpression(s.notificationID);},_waitToHide:function(s){this._hideWait&&clearTimeout(this._hideWait);this._hideWait=p(this._hide.shield(this),s||q);},_hide:function(){this._animation&&this._animation.stop();this._animation=new h(this.refs.container.getDOMNode()).from('opacity','0.96').to('opacity','0').duration(1500).ondone(this._finishHide.bind(this)).go();this.updateState({fading:true});},_finishHide:function(){var s=Object.keys(this.state.renderedBeeps),t=s.map(function(v){return this.state.renderedBeeps[v].beepID;}.bind(this)),u=this.state.pendingBeeps;this.updateState({fading:false,pendingBeeps:{},renderedBeeps:{},expiredBeeps:o(this.state.expiredBeeps,m(t))});p(this.createStateUpdater({renderedBeeps:u}));l.set(this.refs.container.getDOMNode(),'opacity','0.96');},handleBeepChanges:function(s){var t=this.state.fading?this.state.pendingBeeps:this.state.renderedBeeps;Object.keys(s).reverse().forEach(function(u){var v=s[u],w=v.beepID;if(this.state.expiredBeeps[w])return;var x=this.state.renderedBeeps[u]||{};if(x.beepID!=w){delete t[u];t[u]=v;}}.bind(this));if(!this.state.paused)this._waitToHide();this.updateState({});},_togglePause:function(){if(!this.state.paused){this._animation&&this._animation.stop();this._hideWait&&clearTimeout(this._hideWait);}else this._waitToHide();this.updateState({paused:!this.state.paused});},render:function(){var s=this.state.renderedBeeps,t={};Object.keys(s).reverse().forEach(function(v){var w=s[v];t[v]=i({beep:w,onClickItem:this.props.onClickItem,onInserted:this._onInsertedItem.bind(this)});},this);var u=null;if(Object.keys(t).length&&this.props.canPause)u=g.li({className:"_a_g",onClick:this._togglePause.bind(this),children:this.state.paused?'Continue':'Pause [fb]'});return (g.ul({className:"_2a9",'data-gt':this.props.tracking,ref:"container",onMouseEnter:this._onMouseEnter.bind(this),onMouseLeave:this._onMouseLeave.bind(this),children:[t,u]}));}});e.exports=r;});
__d("NotificationImpressions",["AsyncSignal","NotificationTokens","URI"],function(a,b,c,d,e,f){var g=b('AsyncSignal'),h=b('NotificationTokens'),i=b('URI'),j='/ajax/notifications/impression.php';function k(l,m){var n={ref:m};h.untokenizeIDs(l).forEach(function(o,p){n['alert_ids['+p+']']=o;});new g(i(j).getQualifiedURI().toString(),n).send();}e.exports={log:k};});
__d("NotificationUserActions",["AsyncSignal","NotificationConstants","NotificationTokens","NotificationUpdates","URI","createObjectFrom"],function(a,b,c,d,e,f){var g=b('AsyncSignal'),h=b('NotificationConstants'),i=b('NotificationTokens'),j=b('NotificationUpdates'),k=b('URI'),l=b('createObjectFrom'),m=h.PayloadSourceType.USER_ACTION;function n(q){var r=k('/ajax/notifications/mark_read.php').getQualifiedURI().toString();new g(r,q).send();}function o(q){var r={};q.forEach(function(s,t){r['alert_ids['+t+']']=s;});return r;}var p={markNotificationsAsSeen:function(q){j.handleUpdate(m,{seenState:l(q)});var r=i.untokenizeIDs(q),s=o(r);s.seen=true;n(s);if(a.presenceNotifications)a.presenceNotifications.alertList.markSeen(r);},markNotificationsAsRead:function(q){j.handleUpdate(m,{readState:l(q)});var r=i.untokenizeIDs(q);n(o(r));if(a.presenceNotifications)a.presenceNotifications.markRead(false,r);},markNotificationsAsHidden:function(q){j.handleUpdate(m,{hiddenState:l(q)});},markNotificationsAsVisible:function(q){j.handleUpdate(m,{hiddenState:l(q,false)});}};e.exports=p;});
__d("NotificationBeeperController",["ReactDOM","DOM","NotificationBeeps","NotificationBeeper","NotificationImpressions","NotificationUpdates","NotificationUserActions","React","copyProperties","Arbiter","ChannelConstants"],function(a,b,c,d,e,f){var g=b('DOM'),h=b('NotificationBeeps'),i=b('NotificationBeeper'),j=b('NotificationImpressions'),k=b('NotificationUpdates'),l=b('NotificationUserActions'),m=b('React'),n=b('copyProperties'),o=b('Arbiter'),p=b('ChannelConstants'),q='beeper';function r(s,t){g.appendContent(document.body,s);this._root=s;this._unseenVsUnread=t.unseenVsUnread;this._canPause=t.canPause;this._soundEnabled=t.soundEnabled;this._soundPath=t.soundPath;this._shouldLogImpressions=t.shouldLogImpressions;this._trackingData=t.tracking;k.subscribe('beeps-updated',function(){this._beeper.handleBeepChanges(h.getBeeps());}.bind(this));o.subscribe(p.getArbiterType('notif_sound_pref_changed'),function(u,v){this._beeper.props.soundEnabled=v.obj.enabled;}.bind(this));this._render();}n(r.prototype,{_onItemsSeen:function(s){if(this._unseenVsUnread){l.markNotificationsAsSeen(s);}else this._onItemsRead(s);},_onItemsRead:function(s){l.markNotificationsAsRead(s);},_onImpression:function(s){if(this._shouldLogImpressions)j.log([s],q);},_render:function(){this._beeper=i({onImpression:this._onImpression.bind(this),onHover:this._onItemsSeen.bind(this),onClickItem:this._onItemsRead.bind(this),canPause:this._canPause,soundEnabled:this._soundEnabled,soundPath:this._soundPath,tracking:this._trackingData});m.renderOrUpdateComponent(this._beeper,this._root);}});e.exports=r;});
__d("initLiveMessageReceiver",["Arbiter","ChannelConstants","LiveMessageReceiver"],function(a,b,c,d,e,f){var g=b('Arbiter'),h=b('ChannelConstants'),i=b('LiveMessageReceiver');g.subscribe(h.getArbiterType('app_msg'),function(j,k){i.route(k.obj);});});