/*1360668682,173217823*/

if (self.CavalryLogger) { CavalryLogger.start_js(["+1rQQ"]); }

__d("legacy:fbdesktop-plugin",["FBDesktopPlugin"],function(a,b,c,d){a.FbDesktopPlugin=b('FBDesktopPlugin');},3);
__d("UserNoOp",["copyProperties"],function(a,b,c,d,e,f){var g=b('copyProperties'),h=function(){},i=function(){return this;};g(h.prototype,{add_event:i,add_data:i,uai:i,uai_fallback:i});e.exports=h;});
__d("legacy:UserAction",["UserNoOp","userAction","reportData","clickRefAction"],function(a,b,c,d){a.UserNoOp=b('UserNoOp');a.user_action=b('userAction');a.report_data=b('reportData');a.click_ref_action=b('clickRefAction');},3);
__d("legacy:Poller",["Poller"],function(a,b,c,d){a.Poller=b('Poller');},3);
__d("legacy:user-activity",["UserActivity"],function(a,b,c,d){a.UserActivity=a.UserActivity||b('UserActivity');},3);
__d("legacy:BanzaiODS",["BanzaiODS"],function(a,b,c,d){a.BanzaiODS=b('BanzaiODS');},3);
__d("NotificationCounter",["Arbiter","DocumentTitle","JSLogger"],function(a,b,c,d,e,f){var g=b('Arbiter'),h=b('DocumentTitle'),i=b('JSLogger'),j={messages:0,notifications:0,requests:0},k={init:function(){g.subscribe('update_title',this._handleUpdate.bind(this));g.subscribe('jewel/count-updated',this._handleCountUpdate.bind(this));},getCount:function(){var l=0;for(var m in j){var n=Number(j[m]);if(typeof j[m]=='string'&&isNaN(n))return j[m];if(isNaN(n)||n<0){i.create('jewels').error('bad_count',{jewel:m,count:j[m]});continue;}l+=n;}return l;},updateTitle:function(){var l=this.getCount(),m=h.get();m=l?'('+l+') '+m:m;h.set(m,true);},_handleCountUpdate:function(l,m){j[m.jewel]=m.count;this.updateTitle();},_handleUpdate:function(l,m){this.updateTitle();}};e.exports=k;});
__d("legacy:notifications-counter",["NotificationCounter"],function(a,b,c,d){a.NotificationCounter=b('NotificationCounter');},3);
__d("NegativeNotif",["Animation","AsyncRequest","CSS","DataStore","DOM","Event","Parent","Tooltip","NotifXList","$","clickRefAction","copyProperties","userAction"],function(a,b,c,d,e,f){var g=b('Animation'),h=b('AsyncRequest'),i=b('CSS'),j=b('DataStore'),k=b('DOM'),l=b('Event'),m=b('Parent'),n=b('Tooltip'),o=b('NotifXList'),p=b('$'),q=b('clickRefAction'),r=b('copyProperties'),s=b('userAction');function t(u,v){r(this,v);this.owner=u;this.xLink=k.find(this.obj,'.notif_x');this.confirmingMsg=k.find(this.obj,'.confirmingMsg');this.mainLink=k.find(this.obj,'.notifMainLink');this.userXClicked=false;this.userUnsubscribed=false;l.listen(this.xLink,'click',this.xClick.bind(this));if(i.hasClass(this.obj,'first_receipt')&&i.hasClass(p('jewelContainer'),'notifGentleAppReceipt'))this.gentleFirstReceiptHoverEventHandler=l.listen(this.obj,'mouseover',this.gentleFirstReceiptNotifHover.bind(this));}r(t.prototype,{FADE_AWAY_DURATION:2500,X_OUT_DURATION:100,X_OUT_DURATION_SHORT:2,GENTLE_FRUI_MIN_HOVER_DURATION:500,GENTLE_FRUI_FADE_DURATION_FAST:200,GENTLE_FRUI_FADE_DURATION_SLOW:2500,GENTLE_FRUI_DELAY_FADE_TIME:60000,xClick:function(event){this._activateX();var u=this.xLink.getAttribute('data-gt'),v=u?{gt:JSON.parse(u)}:{};s('xbutton',this.xLink,event).uai('click');q('click',this.xLink,event,null,v);return false;},gentleFirstReceiptNotifHover:function(event){event.stop();var u=k.find(this.obj,'.first_receipt_no_button'),v=j.get(u,'notif_fr_prompt');n.set(u,v,'above','center');n.show(u);this._gentleFirstReceiptTooltipFadeIn();if(!this.gentleFirstReceiptUnhoverEventHandler){this.hoverTime=new Date();this.gentleFirstReceiptUnhoverEventHandler=l.listen(document.documentElement,'mouseover',this.gentleFirstReceiptNotifUnhover.bind(this));}if(!this.gentleFirstReceiptNoClickEventHandler)this.gentleFirstReceiptNoClickEventHandler=l.listen(u,'click',this.gentleFirstReceiptNoClick.bind(this));},gentleFirstReceiptNotifUnhover:function(event){if(m.byClass(event.getTarget(),'uiContextualLayer')||m.byClass(event.getTarget(),'uiScrollableAreaTrack'))return false;var u=new Date();if(this.hoverTime&&u-this.hoverTime<this.GENTLE_FRUI_MIN_HOVER_DURATION){this.gentleFirstReceiptUnhoverEventHandler.remove();this.gentleFirstReceiptUnhoverEventHandler=null;this._gentleFirstReceiptTooltipAlreadyFadedIn=false;return;}this._removeGentleFirstReceiptListeners();this._gentleFirstReceiptTooltipFadeAway();this._gentleFirstReceiptXButtonFadeAway();var v=this;setTimeout(function(){v._gentleFirstReceiptUIFadeAway();},this.GENTLE_FRUI_DELAY_FADE_TIME);this._sendFirstReceiptYesToServer();},gentleFirstReceiptNoClick:function(event){this._removeGentleFirstReceiptListeners();},restore:function(){if(o.newNotifExist(this.id)){o.resumeInsert(this.id);}else o.removeNotif(this.id);this._confirmingMsgFadeAway(this.confirmingMsg);this._notifMainLinkShowUp(this.mainLink);this._buttonShowUp(this.xLink);this._adjustContainer(this.obj);},reset:function(){if(this.userXClicked&&!this.userUnsubscribed){this.userXClicked=false;this.restore();}},onTurnedOff:function(){this.userUnsubscribed=true;i.hide(this.confirmingMsg);this._notifMainLinkShowUp(k.find(this.obj,'.confirmedMsg'));this._adjustContainer(this.obj);},onUndid:function(){this.userXClicked=false;this.userUnsubscribed=false;this.restore();i.show(this.confirmingMsg);this._notifMainLinkFadeAway(k.find(this.obj,'.confirmedMsg'));k.remove(k.find(this.obj,'.confirmedMsg'));},onMarkedSpam:function(){k.remove(k.find(this.obj,'.confirmedMsg'));this._fadeAway(k.find(this.obj,'.spamMsg'));},onFirstReceiptYes:function(){this._hideFirstReceiptDiv();this._fadeAway(k.find(this.obj,'.firstConfirmedMsg'));},onFirstReceiptNo:function(){this._hideFirstReceiptDiv();i.hide(this.confirmingMsg);this._activateX();new h().setURI('/ajax/notifications/negative_req.php').setData({request_type:'turn_off',notification_id:this.id}).send();},_sendFirstReceiptYesToServer:function(){new h().setURI('/ajax/notifications/negative_req.php').setData({request_type:'first_receipt_yes',notification_id:this.id}).send();},_gentleFirstReceiptTooltipFadeIn:function(){if(this._gentleFirstReceiptTooltipAlreadyFadedIn)return;var u=k.find(document.documentElement,'.uiLayer .uiContextualLayer .uiTooltipX');new g(u).from('opacity','0').to('opacity','1').duration(this.GENTLE_FRUI_FADE_DURATION_FAST).go();this._gentleFirstReceiptTooltipAlreadyFadedIn=true;},_gentleFirstReceiptTooltipFadeAway:function(){if(!this._gentleFirstReceiptTooltipAlreadyFadedIn)return;var u=k.find(document.documentElement,'.uiLayer .uiContextualLayer .uiTooltipX'),v=m.byClass(u,'uiLayer'),w=v.cloneNode(true);k.insertAfter(v,w);new g(w).from('opacity','1').to('opacity','0').duration(this.GENTLE_FRUI_FADE_DURATION_FAST).ondone(function(){k.remove(w);}).go();this._gentleFirstReceiptTooltipAlreadyFadedIn=false;},_gentleFirstReceiptXButtonFadeAway:function(){var u=k.find(this.obj,'.first_receipt_no_button');new g(u).from('opacity','1').to('opacity','0').duration(this.GENTLE_FRUI_FADE_DURATION_FAST).hide().go();i.addClass(this.obj,'show_original_x');},_gentleFirstReceiptUIFadeAway:function(){var u=this.obj;this.new_label=k.find(this.obj,'.notif_new_label');new g(this.new_label).to('opacity','0').duration(this.GENTLE_FRUI_FADE_DURATION_SLOW).ondone(function(){i.removeClass(u,'first_receipt');}).go();if(!i.hasClass(this.obj,'jewelItemNew'))new g(this.obj).from('backgroundColor','#ECEFF5').to('backgroundColor','#FFFFFF').duration(this.GENTLE_FRUI_FADE_DURATION_SLOW).go();},_removeGentleFirstReceiptListeners:function(){if(this.gentleFirstReceiptHoverEventHandler)this.gentleFirstReceiptHoverEventHandler.remove();if(this.gentleFirstReceiptUnhoverEventHandler)this.gentleFirstReceiptUnhoverEventHandler.remove();if(this.gentleFirstReceiptNoClickEventHandler)this.gentleFirstReceiptNoClickEventHandler.remove();},_activateX:function(){i.addClass(this.obj,'forPushSafety');this.userXClicked=true;o.userXClick(this.id);this._notifMainLinkFadeAway(this.mainLink);this._buttonFadeAway(this.xLink);if(i.shown(this.confirmingMsg))this._confirmingMsgShowUp(this.confirmingMsg);this._adjustContainer(this.obj);},_hideFirstReceiptDiv:function(){i.removeClass(this.obj,'first_receipt');i.hide(k.find(this.obj,'.first_receipt_div'));},_fadeAway:function(u){new g(u).from('backgroundColor','#FFF9D7').to('backgroundColor','#FFFFFF').duration(this.FADE_AWAY_DURATION).checkpoint().to('opacity','0').blind().duration(this.X_OUT_DURATION).checkpoint().to('height','0px').to('paddingTop','0px').to('paddingBottom','0px').blind().hide().duration(this.X_OUT_DURATION).go();},_adjustContainer:function(u){new g(u).by('height','0px').duration(this.X_OUT_DURATION).checkpoint().by('height','0px').duration(this.X_OUT_DURATION_SHORT).checkpoint().to('height','auto').duration(this.X_OUT_DURATION).go();},_notifMainLinkShowUp:function(u){new g(u).duration(this.X_OUT_DURATION).checkpoint().to('height','auto').to('paddingTop','4px').to('paddingBottom','4px').blind().show().duration(this.X_OUT_DURATION_SHORT).checkpoint().to('opacity','1').blind().duration(this.X_OUT_DURATION).go();},_confirmingMsgShowUp:function(u){new g(u).duration(this.X_OUT_DURATION).checkpoint().to('height','auto').to('paddingTop','10px').to('paddingBottom','10px').blind().show().duration(this.X_OUT_DURATION_SHORT).checkpoint().to('opacity','1').blind().duration(this.X_OUT_DURATION).go();},_notifMainLinkFadeAway:function(u){new g(u).to('opacity','0').blind().duration(this.X_OUT_DURATION).checkpoint().to('height','0px').to('paddingTop','0px').to('paddingBottom','0px').blind().hide().duration(this.X_OUT_DURATION_SHORT).go();},_confirmingMsgFadeAway:function(u){new g(u).to('opacity','0').blind().duration(this.X_OUT_DURATION).checkpoint().to('height','0px').to('paddingTop','0px').to('paddingBottom','0px').blind().duration(this.X_OUT_DURATION_SHORT).go();},_buttonShowUp:function(u){new g(u).duration(this.X_OUT_DURATION).checkpoint().show().duration(this.X_OUT_DURATION_SHORT).checkpoint().to('opacity','1').blind().duration(this.X_OUT_DURATION).go();},_buttonFadeAway:function(u){new g(u).to('opacity','0').blind().duration(this.X_OUT_DURATION).checkpoint().hide().duration(this.X_OUT_DURATION_SHORT).go();}});e.exports=t;});
__d("NotificationList",["Animation","ArbiterMixin","CSS","DOM","DoublyLinkedListMap","HTML","NotificationURI","$","copyProperties","ge","isEmpty","tx","hasArrayNature"],function(a,b,c,d,e,f){var g=b('Animation'),h=b('ArbiterMixin'),i=b('CSS'),j=b('DOM'),k=b('DoublyLinkedListMap'),l=b('HTML'),m=b('NotificationURI'),n=b('$'),o=b('copyProperties'),p=b('ge'),q=b('isEmpty'),r=b('tx'),s=b('hasArrayNature'),t="0",u="1",v="2";function w(z){return z==u||z==v;}function x(z){return z==u;}function y(z,aa){this._list=new k();this._filter_func=null;this.unseenCount=0;this.contentRoot=z;this.noItemsElement=null;this.ITEM_TAG='li';this.ITEM_CLASS='notification';this.NO_ITEMS_ID='jewelNoNotifications';this.NO_ITEMS_CLASS='empty';this.compare=aa.compare||this.compare;this.shouldBlockAnimation=aa.shouldBlockAnimation||null;this.unseenVsUnread=aa.unseenVsUnread||false;this.animations={};}o(y,{ITEM_UNREAD_CLASS:'jewelItemNew',MARK_READ_TYPE:'mark_read',UNREAD_COUNT_CHANGE_TYPE:'unread_count_change',INSERTION_TYPE:'insert',REMOVAL_TYPE:'remove',getIdFromDom:function(z){return z.getAttribute('id').replace('notification_','');},localizeUrls:function(z){j.scry(z,'a').forEach(function(aa){aa.href=m.localize(aa.href);});}});o(y.prototype,h,{FADE_DURATION:250,RESIZE_DURATION:200,_getField:function(z,aa){var ba=this._list.get(z);return ba&&ba[aa];},getDomObj:function(z){return this._getField(z,'obj');},fromDom:function(){var z=this.ITEM_TAG+'.'+this.ITEM_CLASS,aa=j.scry(this.contentRoot,z);for(var ba=0;ba<aa.length;++ba){var ca=aa[ba],da=y.getIdFromDom(ca);this.insert(da,ca.getAttribute('data-notiftime'),null);}},compare:function(z,aa){return z.time<aa.time||(z.time===aa.time&&z.id<aa.id);},insert:function(z,aa,ba,ca,da,ea){var fa=u,ga=0,ha=this._list.exists(z),ia=ea&&this._list.exists(ea),ja=null,ka;if(ha||ia)if(!(ca&&ba)){return false;}else{if(this._filter_func){ka={notif_id:z,notif_time:aa,notif_markup:ba,replace:ca,ignoreUnread:da,notif_alt_id:ea};if(this._filter_func(ka))return false;}fa=this._getField(z,'readness');ga=this._getField(z,'time');if(ga>aa)return false;ja=ha?z:ea;this._remove(ja);}var la=(ba&&l(ba).getRootNode())||n('notification_'+z),ma=Math.max(aa,ga),na=la.getAttribute('data-readness');if(!this.unseenVsUnread&&v==na)na=t;ka={id:z,obj:la,time:ma,readness:na,app_id:la.getAttribute('data-appid')};this._insert(ka);y.localizeUrls(la);this.noItemsElement&&i.hide(this.noItemsElement);if(x(na)){da&&!w(fa)&&this.markRead([z]);this.unseenCount=this.getUnseenIds().length;this.inform(y.UNREAD_COUNT_CHANGE_TYPE);}var oa=!ja||ga<ma||(na&&!fa&&!da);this.inform(y.INSERTION_TYPE,{id:z,is_new:oa,obj:la,replaced_id:ja,time:ma});return true;},showNoNotifications:function(){if(null==this.noItemsElement)this.noItemsElement=p(this.NO_ITEMS_ID);if(null==this.noItemsElement){this.noItemsElement=j.create(this.ITEM_TAG,{id:this.NO_ITEMS_ID,className:this.NO_ITEMS_CLASS},"Aucune nouvelle notification");j.appendContent(this.contentRoot,this.noItemsElement);}i.show(this.noItemsElement);},_insert:function(z){this._list.remove(z.id);var aa=null;this._list.find(function(ca){var da=this.compare(ca,z);!da&&(aa=ca.id);return da;}.bind(this));var ba=this.getDomObj(aa);if(ba){this._list.insertAfter(z.id,z,aa);j.insertAfter(ba,z.obj);}else{this._list.prepend(z.id,z);j.prependContent(this.contentRoot,z.obj);}},_remove:function(z){var aa=this._getField(z,'obj');if(!aa)return false;this.inform(y.REMOVAL_TYPE,{id:z});this._list.remove(z);j.remove(aa);this.isEmpty()&&this.showNoNotifications();return true;},getUnreadIds:function(){return this._list.reduce(function(z,aa){w(z.readness)&&aa.push(z.id);return aa;},[]);},getUnseenIds:function(){return this._list.reduce(function(z,aa){x(z.readness)&&aa.push(z.id);return aa;},[]);},getIds:function(){return this._list.reduce(function(z,aa){aa.push(z.id);return aa;},[]);},isUnreadId:function(z){var aa=this.getDomObj(z);return w(this._getField(z,'readness'))||(aa&&i.hasClass(aa,y.ITEM_UNREAD_CLASS));},isUnseenId:function(z){return x(this._getField(z,'readness'));},markRead:function(z,aa){z=z?z.filter(this.isUnreadId.bind(this)):this.getUnreadIds();var ba=false;for(var ca=0;ca<z.length;ca++){var da=this._list.get(z[ca]);if(da){if(this._setReadness(z[ca],t))ba=true;if(aa){this._markReadInDom(z[ca],da.obj);}else this.animateMarkRead(da.obj);}}if(ba){this.unseenCount=this.getUnseenIds().length;this.inform(y.UNREAD_COUNT_CHANGE_TYPE);}},markSeen:function(z){if(!s(z))return;if(!this.unseenVsUnread){this.markRead(z);return;}z=z.filter(this.isUnseenId.bind(this));var aa=false;for(var ba=0;ba<z.length;ba++)if(this._setReadness(z[ba],v))aa=true;if(aa){this.unseenCount=this.getUnseenIds().length;this.inform(y.UNREAD_COUNT_CHANGE_TYPE);}},_setReadness:function(z,aa){var ba=this._list.get(z);if(!ba||ba.readness==aa)return false;if(ba.readness==t&&aa==v)return false;ba.readness=aa;ba.obj.setAttribute('data-readness',aa);return true;},_markReadInDom:function(z,aa){if(!this.isUnreadId(z))return;var ba=n(aa);if(ba){this.stopAnimation(z);i.removeClass(ba,y.ITEM_UNREAD_CLASS);}},animateMarkRead:function(z){if(!i.hasClass(z,y.ITEM_UNREAD_CLASS))return;var aa=y.getIdFromDom(z),ba=this._markReadInDom.bind(this,aa,z);if(i.hasClass(z,'fbJewelBeep')){ba();return;}if(this.shouldBlockAnimation&&this.shouldBlockAnimation(z))return;ba.defer(10000);},stopAnimation:function(z){z in this.animations&&this.animations[z].stop();delete this.animations[z];return true;},insertMany:function(z,aa){if('object'==typeof z&&!q(z)){for(var ba in z){var ca=z[ba];this.insert(ba,ca.time,ca.markup,true,aa,ca.alt_id||null);}this.noItemsElement&&i.hide(this.noItemsElement);}else this.isEmpty()&&this.showNoNotifications();},isEmpty:function(){return this._list.isEmpty();},getEarliestNotifTime:function(){return this._list.isEmpty()?0:Math.min.apply(null,this.getIds().map(function(z){return this._getField(z,'time');}.bind(this)));},setFilterFn:function(z){this._filter_func=z;},toggleNotifsSimilarTo:function(z,aa,ba){var ca=this._getField(z,'app_id');if(ca){var da=this.getIds();for(var ea=0;ea<da.length;++ea)if(ca==this._getField(da[ea],'app_id')){var fa=this.getDomObj(da[ea]);if(z!=da[ea])aa?this._hideWithAnimation(fa):this._showWithAnimation(fa);var ga=j.scry(fa,'.first_receipt_div');if(ga.length==1)if(ba){i.hide(ga[0]);i.removeClass(fa,'first_receipt');}else{i.show(ga[0]);i.addClass(fa,'first_receipt');}}}},_hideWithAnimation:function(z){g(z).to('opacity','0').blind().duration(this.FADE_DURATION).checkpoint().to('height','0px').to('paddingTop','0px').to('paddingBottom','0px').blind().hide().duration(this.RESIZE_DURATION).go();},_showWithAnimation:function(z){g(z).to('height','auto').to('paddingTop','auto').to('paddingBottom','auto').blind().show().duration(this.RESIZE_DURATION).checkpoint().to('opacity','1').blind().duration(this.FADE_DURATION).go();}});e.exports=y;});
__d("Notifications",["Animation","Arbiter","AsyncRequest","AsyncSignal","Banzai","BanzaiODS","Bootloader","ChannelConstants","CSS","DOM","Env","Event","JSLogger","NegativeNotif","NotificationCounter","NotificationList","NotifXList","Parent","Poller","ScrollableArea","Style","SystemEvents","Toggler","URI","UserActivity","UserNoOp","Vector","$","copyProperties","emptyFunction","ge","hasArrayNature","isEmpty","throttle","userAction"],function(a,b,c,d,e,f){var g=b('Animation'),h=b('Arbiter'),i=b('AsyncRequest'),j=b('AsyncSignal'),k=b('Banzai'),l=b('BanzaiODS'),m=b('Bootloader'),n=b('ChannelConstants'),o=b('CSS'),p=b('DOM'),q=b('Env'),r=b('Event'),s=b('JSLogger'),t=b('NegativeNotif'),u=b('NotificationCounter'),v=b('NotificationList'),w=b('NotifXList'),x=b('Parent'),y=b('Poller'),z=b('ScrollableArea'),aa=b('Style'),ba=b('SystemEvents'),ca=b('Toggler'),da=b('URI'),ea=b('UserActivity'),fa=b('UserNoOp'),ga=b('Vector'),ha=b('$'),ia=b('copyProperties'),ja=b('emptyFunction'),ka=b('ge'),la=b('hasArrayNature'),ma=b('isEmpty'),na=b('throttle'),oa=b('userAction');function pa(qa){this.updateTime=qa.updateTime||Date.now();this.update_period=qa.updatePeriod||60000;this.latest_notif_time=qa.latestNotif||0;this.latest_read_notif_time=qa.latestReadNotif||0;this.cache_version=qa.cacheVersion||0;this.notifReceivedType=qa.notifReceivedType||'notification';this.wrapperID=qa.wrapperID||'notificationsWrapper';this.contentID=qa.contentID||'jewelNotifs';this.shouldLogImpressions=qa.shouldLogImpressions||false;this.allowDesktopNotifications=qa.allowDesktopNotifications||false;this.logAutoShutOffImpression=true;this.useInfiniteScroll=qa.useInfiniteScroll||false;this.unseenVsUnread=qa.unseenVsUnread||false;this.scrollableAreaNode=null;this.firstReceiptMap={};this.user=q.user;this.queuedNotifications=[];this.timeElement='small.time';this.ua=new fa();this._init();}ia(pa.prototype,{TIME_TRAVEL:'time_travel',ONLINE:'online',SCROLL_OFF_TINY:'scroll_off_tiny',INACTIVE_REFRESH:'inactive_refresh',_init:function(){this.cookieName='notifications_'+this.user;this.updateCheckCount=0;this.fetchListeners=[];this.currentFetchRequest=null;this.wrapper=ka(this.wrapperID);this.content=ka(this.contentID);this.jewelFlyout=ka('fbNotificationsFlyout');this.footer=p.find(this.jewelFlyout,'.jewelFooter');this.loadingIndicator=ka(this.contentID+'_loading_indicator');this.NOTIF_JEWEL_REF='notif_jewel';this.notifLogger=s.create('notifications');u.init();this.alertList=new v(this.content,this._getListParams());this._updateCount();a.MinNotifications&&a.MinNotifications.fetchSent()&&(this.fetch=ja);h.subscribe(n.getArbiterType(this.notifReceivedType),this._handleNotificationMsg.bind(this));h.subscribe(n.getArbiterType('notifications_read'),this._handleNotificationsReadMsg.bind(this));h.subscribe(n.getArbiterType('notifications_seen'),this._handleNotificationsSeenMsg.bind(this));h.subscribe('jewel/resize',this._hideOverflow.shield(this));this.alertList.subscribe(v.UNREAD_COUNT_CHANGE_TYPE,this._updateCount.bind(this));this._poller=new y({interval:this.update_period,setupRequest:this._update.bind(this),clearOnQuicklingEvents:false});if(this.wrapper)this.countSpan=p.find(this.wrapper,'span.jewelCount span');this.initializeEvents();this.fromDom();if(this.useInfiniteScroll){this._autoLoadNotifIndex=1;this._truncate=false;this.alertList.subscribe(v.INSERTION_TYPE,this._handleInsert.bind(this));}},_getListParams:function(){return {shouldBlockAnimation:function(qa){return this.isNotifJewelOpen();}.bind(this),unseenVsUnread:this.unseenVsUnread};},fromDom:function(){this.alertList.fromDom();a.MinNotifications&&a.MinNotifications.fetched()&&this.alertList.isEmpty()&&this.alertList.showNoNotifications();},initializeEvents:function(){var qa=this.alertList.ITEM_TAG,ra=null;r.listen(this.content,{mouseover:function(event){var ua=event.getTarget();ra=x.byTag(ua,qa);if(ra&&ua!=ra)if(x.byClass(ra,'notifNegativeBase')){o.addClass(ra,'notifHover');}else o.addClass(ra,'selected');},mouseout:function(event){ra&&o.removeClass(ra,'selected');ra&&o.removeClass(ra,'notifHover');ra=null;},mousedown:this.onContentMouseDown.bind(this)});r.listen(this.wrapper,'mouseover',this.onMouseOver.bind(this));ca.listen('show',this.wrapper,this.onClick.bind(this));ca.listen('hide',this.wrapper,this.onHide.bind(this));this.shouldLogImpressions&&ca.listen('show',this.wrapper,this._logImpression.bind(this));var sa=function(ua){this._poller.request();this.notifLogger.bump(ua);}.bind(this);ba.subscribe(ba.TIME_TRAVEL,sa.curry(this.TIME_TRAVEL));ba.subscribe(ba.ONLINE,function(ua,va){va&&sa(this.ONLINE);});var ta=1000*60*60;ea.subscribe(function(ua,va){(va.idleness>ta)&&sa(this.INACTIVE_REFRESH);}.bind(this));this.negativeNotifs={};this._initNotifNegativeFeedback();if(this.useInfiniteScroll){this._setupScroll();this._initializeScrollEvents();this._updateScrollDataStructures.bind(this).defer();this._hideOverflow();}},_setupScroll:function(){this._scrollArea=p.scry(this.jewelFlyout,'div.uiScrollableAreaWrap')[0];this._morePagerLink=p.find(this.jewelFlyout,'.notifMorePager a');this._morePager=x.byClass(this._morePagerLink,'notifMorePager')||this._morePagerLink;this._infiniteScrollNotif=null;this.afterFirstFetch=false;this.animate=false;if(a.MinNotifications&&a.MinNotifications.fetched()){this.afterFirstFetch=true;o.show(this._morePager);}},_initializeScrollEvents:function(){r.listen(this._scrollArea,'scroll',na(this._handleScroll.bind(this)));r.listen(this._morePagerLink,'success',function(qa){this.fetchHandler(qa.getData().response);}.bind(this));},_updateScrollDataStructures:function(){var qa=this.alertList.getIds(),ra=Math.max(0,qa.length-this._autoLoadNotifIndex);this._infiniteScrollNotif=this.alertList.getDomObj(qa[ra]);this._annotateMorePagerURI();},_annotateMorePagerURI:function(){this._morePagerLink.setAttribute('ajaxify',new da(this._morePagerLink.getAttribute('ajaxify')).addQueryData({earliest_time:this.alertList.getEarliestNotifTime()}));},onContentMouseDown:function(event){var qa=x.byTag(event.getTarget(),this.alertList.ITEM_TAG),ra=qa&&v.getIdFromDom(qa);if(ra&&this.alertList.isUnreadId(ra))this.markRead(true,[ra]);if(k.isEnabled('notifications'))l.bumpEntityKey('notifications','click');},onMouseOver:function(event){if(o.hasClass(event.getTarget(),"jewelButton"))this.ua=oa('notifs',event.target,event,{mode:'DEDUP'}).uai('mouseover','jewel').add_event('hover');this.fetch();},onClick:function(){a.ArbiterMonitor&&this.fetch!=ja&&h.registerCallback(ja,['notifs/fetched']);this.ua.add_event('show');this.fetch();this.markRead(true);this._hideOverflow();if(this.scrollableAreaNode){var qa=z.getInstance(this.scrollableAreaNode);qa&&qa.poke();}},onHide:function(){this.animate=false;this.animation&&this.animation.stop();this.ua.add_event('hide');this.markRead(true);this._dequeueNotifications();},_dequeueNotifications:function(){this.queuedNotifications.forEach(function(qa){this._displayNotification(qa.type,qa.data);},this);this.queuedNotifications.length=0;},_handleScroll:function(){if(this._checkInfiniteScroll()){this._autoLoadNotifIndex=5;this._sendFetchRequest(this._morePager);}},_handleInsert:function(qa,ra){if(ra.is_new)this._newDataFromInsert=true;this._updateScrollDataStructures();},_checkInfiniteScroll:function(){if(this._infiniteScrollNotif&&this._scrollArea){var qa=ga.getElementPosition(this._infiniteScrollNotif).y,ra=ga.getElementPosition(this._scrollArea).y+ga.getElementDimensions(this._scrollArea).y;return qa<ra;}return false;},_initNotifNegativeFeedback:function(){w.init(this);this.alertList.setFilterFn(w.filterStoreClicked);ca.listen('hide',ha(this.wrapperID),function(){for(var qa in this.negativeNotifs)if(qa)this.negativeNotifs[qa] instanceof t&&this.negativeNotifs[qa].reset();}.bind(this));h.subscribe('notif/negativeCancel',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].restore();}.bind(this));h.subscribe('notif/negativeConfirmed',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].onTurnedOff();this.alertList.toggleNotifsSimilarTo(ra.id,true,true);this._hideOverflow();this._handleScroll();}.bind(this));h.subscribe('notif/negativeUndid',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].onUndid();this.alertList.toggleNotifsSimilarTo(ra.id,false,true);this._hideOverflow();}.bind(this));h.subscribe('notif/negativeMarkedSpam',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].onMarkedSpam();}.bind(this));h.subscribe('notif/negativeFirstReceiptYes',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].onFirstReceiptYes();this.alertList.toggleNotifsSimilarTo(ra.id,false,true);}.bind(this));h.subscribe('notif/negativeFirstReceiptNo',function(qa,ra){this.negativeNotifs[ra.id]&&this.negativeNotifs[ra.id].onFirstReceiptNo();this.alertList.toggleNotifsSimilarTo(ra.id,false,true);}.bind(this));this.alertList.subscribe(v.INSERTION_TYPE,function(qa,ra){this._updateFirstReceipt(ra);var sa=p.scry(ra.obj,'.notif_x');if(sa.length==1)this.negativeNotifs[ra.id]=new t(this,ra);}.bind(this));},_sendIDs:function(qa,ra,sa){var ta=sa||{};for(var ua=0;ua<qa.length;++ua)ta['alert_ids['+ua+']']=qa[ua];new j(da(ra).getQualifiedURI().toString(),ta).send();},_waitForFetch:function(qa){return this.currentFetchRequest&&this.fetchListeners.push(qa.bind(this));},_logImpression:function(){var qa=this.alertList.getIds();if(qa.length===0&&this._waitForFetch(this._logImpression))return;this.logImpressionIds(qa,this.NOTIF_JEWEL_REF);},logImpressionIds:function(qa,ra){this.shouldLogImpressions&&this._sendIDs(qa,'/ajax/notifications/impression.php',{ref:ra});},markRead:function(qa,ra){var sa=!la(ra);ra=sa?this.alertList.getUnseenIds():ra.filter(this.alertList.isUnreadId.bind(this.alertList));if(ra.length){qa&&this._sendIDs(ra,'/ajax/notifications/mark_read.php',{seen:sa?1:0});if(ka('jewelNoticeMessage')&&this.logAutoShutOffImpression){new j('/ajax/notifications/auto_shutoff_seen.php').send();this.logAutoShutOffImpression=false;}var ta=qa;sa?this.alertList.markSeen(ra):this.alertList.markRead(ra,ta);}sa&&this._waitForFetch(this.markRead.bind(this,qa));},markAllRead:function(){var qa=this.alertList.getUnreadIds();this.markRead(true,qa);},_updateErrorHandler:function(qa){},_updateURI:'/ajax/presence/update.php',_update:function(qa){qa.setHandler(this._handleUpdate.bind(this)).setOption('suppressErrorAlerts',true).setErrorHandler(this._updateErrorHandler.bind(this)).setData({notif_latest:this.latest_notif_time,notif_latest_read:this.latest_read_notif_time}).setURI(this._updateURI).setAllowCrossPageTransition(true);},_handleUpdate:function(qa){var ra=qa.payload.notifications;if(!ra.no_change){this.updateTime=qa.payload.time;this.latest_notif_time=ra.latest_notif;this.latest_read_notif_time=ra.latest_read_notif;this._updateDisplay();this.alertList.insertMany(ra.notifications);}},_updateDisplay:function(){if(!this.content)return;this._updateCount();},_updateCount:function(){h.inform('jewel/count-updated',{jewel:'notifications',count:this.alertList.unseenCount},h.BEHAVIOR_STATE);this._hideOverflow();},fetch:function(qa){this._sendFetchRequest(qa);},_getFetchQueryData:function(){var qa={time:this.latest_notif_time,user:this.user,version:this.cache_version,locale:q.locale};if(this.useInfiniteScroll)qa.earliest_time=this.alertList.getEarliestNotifTime();return qa;},_sendFetchRequest:function(qa){if(this.useInfiniteScroll){this._infiniteScrollNotif=null;this._newDataFromInsert=false;this._truncate=true;}var ra=da('/ajax/notifications/get.php'),sa=qa||this.loadingIndicator;if(this.currentFetchRequest)return true;this.ua.add_event('fetch');ra.setQueryData(this._getFetchQueryData());this.currentFetchRequest=new i().setURI(ra).setStatusElement(sa).setMethod('GET').setReadOnly(true).setTimeoutHandler(30000,this.fetchErrorHandler.bind(this)).setHandler(this.fetchHandler.bind(this)).setErrorHandler(this.fetchErrorHandler.bind(this)).setAllowCrossPageTransition(true);!this.currentFetchRequest.send()&&this.fetchErrorHandler();return true;},fetchErrorHandler:function(qa){this.currentFetchRequest=null;this.ua.add_event('fetch_error');this.loadingIndicator&&o.hide(this.loadingIndicator);this.useInfiniteScroll&&this._updateScrollDataStructures();},fetchHandler:function(qa){this.ua.add_event('fetch_success');var ra=qa.getPayload();this.alertList.insertMany(ra.notifications,true);this.loadingIndicator&&o.hide(this.loadingIndicator);this.loadingIndicator=null;this.currentFetchRequest=null;this.fetch=ja;if(this.fetchListeners){for(var sa=0;sa<this.fetchListeners.length;sa++)this.fetchListeners[sa]();this.fetchListeners=[];}a.ArbiterMonitor&&h.inform('notifs/fetched','',h.BEHAVIOR_STATE);var ta=ra.generated,ua=Math.round(Date.now()/1000);if(ua-ta>15)ta=ua;m.loadModules(['LiveTimer'],function(va){va.restart(ta);va.startLoop(0);});if(this.useInfiniteScroll){if(ma(ra.notifications)||!this._newDataFromInsert){this._noMoreNotifications();}else o.show(this._morePager);this._updateScrollDataStructures();if(this.isNotifJewelOpen()&&this.afterFirstFetch)this.animate=true;this.afterFirstFetch=true;}this._hideOverflow();},_noMoreNotifications:function(){o.hide(this._morePager);this.useInfiniteScroll=false;},_mergeNotification:function(qa,ra,sa,ta){var ua=!this.alertList.isUnreadId(qa);this.alertList.insert(qa,ra,sa,true,null,ta||null);this.latest_notif_time=0;if(ua)this._updateCount();var va=this.alertList.getDomObj(qa);if(va)m.loadModules(['LiveTimer'],function(wa){wa.addTimeStamps(va);});},_handleNotificationMsg:function(qa,ra){if(this.isNotifJewelOpen()){var sa={type:qa,data:ra};this.queuedNotifications.push(sa);}else this._displayNotification(qa,ra);},_displayNotification:function(qa,ra){var sa=ra.obj;if(typeof this.useDesktopNotifications=='undefined')this.useDesktopNotifications=this.allowDesktopNotifications&&window.webkitNotifications&&window.webkitNotifications.checkPermission()===0;if(this.useDesktopNotifications)m.loadModules(['DesktopNotifications'],function(ta){ta.addNotification(sa.alert_id);});if(sa.markup){this._mergeNotification(sa.alert_id,sa.time,sa.markup,sa.alt_id||null);}else this._poller.request();},_handleNotificationsReadMsg:function(qa,ra){var sa=ra.obj;this.markRead(false,sa.alert_ids);},_handleNotificationsSeenMsg:function(qa,ra){if(!this.unseenVsUnread){this._handleNotificationsReadMsg(qa,ra);return;}var sa=ra.obj;this.alertList.markSeen(sa.alert_ids);},_hideOverflow:function(){if(!this.isNotifJewelOpen())return;var qa=p.scry(ha('fbNotificationsList'),'.notification');this.scrollableAreaNode=this.scrollableAreaNode||p.scry(this.jewelFlyout,'.uiScrollableArea')[0];var ra=20,sa=o.hasClass(document.documentElement,'tinyViewport')&&!o.hasClass(document.body,'fixedBody');if(!qa.length||sa){aa.set(this.scrollableAreaNode,'height','100%');this.notifLogger.rate(this.SCROLL_OFF_TINY,sa);return;}var ta=this.scrollableAreaNode||qa[0],ua=ga.getViewportDimensions().y-ga.getElementPosition(ta,'viewport').y-ga.getElementDimensions(this.footer).y-5,va=ua,wa=0;for(;wa<qa.length&&va>0;++wa)if(o.shown(qa[wa]))va-=ga.getElementDimensions(qa[wa]).y;var xa=530,ya=Math.min(xa,ua-Math.max(va,0));if(va>=0&&ya<xa){if(!this.useInfiniteScroll){ya='100%';}else{if(this._truncate&&qa.length>=5)ya-=ra;ya+='px';}}else ya+='px';if(this.useInfiniteScroll&&this.animate&&ya!='100%'){this.animation&&this.animation.stop();this.animation=new g(this.scrollableAreaNode).to('height',ya).duration(200).go();}else{var za=z.getInstance(this.scrollableAreaNode);za&&za.showScrollbar.bind(za).defer();aa.set(this.scrollableAreaNode,'height',ya);}},_updateFirstReceipt:function(qa){var ra=qa.obj.getAttribute('data-appid'),sa=p.scry(qa.obj,'.first_receipt_div');if(ra&&sa.length==1){if(this.firstReceiptMap[ra]){if(qa.id!=this.firstReceiptMap[ra].id&&this.firstReceiptMap[ra].time>qa.time)return;o.removeClass(this.firstReceiptMap[ra].obj,'first_receipt');}this.firstReceiptMap[ra]=qa;o.addClass(qa.obj,'first_receipt');}},isNotifJewelOpen:function(){var qa=ca.getInstance(this.wrapper).getActive();return (qa===this.wrapper&&o.hasClass(qa,'openToggler'));}});e.exports=pa;});
__d("legacy:notif-xlist",["NotifXList"],function(a,b,c,d){a.NotifXList=b('NotifXList');},3);
__d("legacy:notif-experiment-negative-notif",["NegativeNotif"],function(a,b,c,d){a.NegativeNotif=b('NegativeNotif');},3);
__d("legacy:notifications-list",["NotificationList"],function(a,b,c,d){a.NotificationList=b('NotificationList');},3);
__d("legacy:livemessage",["LiveMessageReceiver"],function(a,b,c,d){a.LiveMessageReceiver=b('LiveMessageReceiver');},3);
__d("legacy:ScrollableArea",["ScrollableArea"],function(a,b,c,d){a.ScrollableArea=b('ScrollableArea');},3);