/*1358176997,178142527*/

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

/** js/clientnotifs/models/NotificationURI.js */
__d("NotificationURI",["URI"],function(a,b,c,d,e,f){














var g=b('URI'),

h=
{localize:function(i){
i=g(i);
if(!i.isFacebookURI())
return i.toString();


var j=i.getSubdomain();
return i.
getUnqualifiedURI().
getQualifiedURI().
setSubdomain(j).
toString();}};



e.exports=h;});

/** js/desktop/auth/fbdesktop-plugin.js */
__d("legacy:fbdesktop-plugin",["FBDesktopPlugin"],function(a,b,c,d){



a.FbDesktopPlugin=b('FBDesktopPlugin');},

3);

/** js/lib/bind.js */
__d("legacy:bind",["bind"],function(a,b,c,d){



a.bind=b('bind');},

3);

/** js/growth/friend_browser/FriendBrowserCheckboxController.js */











function FriendBrowserCheckboxController(){}

copyProperties(FriendBrowserCheckboxController,

{instances:{},
getInstance:function(a){
return this.instances[a];}});



copyProperties(FriendBrowserCheckboxController.prototype,

{init:function(a,b,c){
FriendBrowserCheckboxController.instances[a]=this;
this._id=a;
this._simplified=c;

this._form=b;
this._contentGrid=DOM.find(b,'.friendBrowserCheckboxContentGrid');
this._loadingIndicator=
DOM.find(b,'.friendBrowsingCheckboxContentLoadingIndicator');
this._checkboxResults=DOM.find(b,'.friendBrowserCheckboxResults');
this._contentPager=DOM.find(b,'.friendBrowserCheckboxContentPager');




this.numGetNewRequests=0;


this.queuedRequests={};
Event.listen(this._form,'submit',this.onFormSubmit.bind(this));},



addTypeahead:function(a,b){
a.subscribe('select',this.onHubSelect.bind(this,a,b));
if(this._simplified)
a.subscribe
('unselect',
this.onHubSelect.bind(this,a,b));},




onFormSubmit:function(){
this.getNew(true);
return false;},


addSelector:function(a){
a.subscribe('change',this.getNew.bind(this,false));},


onHubSelect:function(a,b,event,c){
if(this._simplified){
this.getNew(true);
return;}


if(!((event=='select')&&c.selected))
return;



var d=this.buildNewCheckbox
(b,
c.selected.text,
c.selected.uid),
e=DOM.find(this._form,'.checkboxes_'+b);
DOM.appendContent(e.firstChild,d);


var f=
DOM.scry(a.getElement(),'input[type="button"]');
if(f&&f[0])
f[0].click();



this.getNew(true);},


buildNewCheckbox:function(a,b,c){
var d=a+'_ids_'+c,
e=a+'_ids[]',


f=DOM.create
('input',
{id:d,
type:'checkbox',
value:c,
name:e,
checked:true});
Event.listen
(f,
'click',
bind(this,'getNew',false));
var g=DOM.create
('td',
null,
f);
CSS.addClass(g,'vTop');
CSS.addClass(g,'hLeft');


var h=DOM.create
('label',
null,
b),
i=DOM.create
('td',
null,
h);
CSS.addClass(i,'vMid');
CSS.addClass(i,'hLeft');


var j=DOM.create('tr');
j.appendChild(g);
j.appendChild(i);

return j;},





showMore:function(){

var a=DOM.scry(this._contentPager,'.friendBrowserMorePager')[0];

if(!a)
return false;


if(CSS.hasClass(a,'async_saving'))
return false;



var b=this.numGetNewRequests,

c=Form.serialize(this._form);
c.show_more=true;
var d=new AsyncRequest().
setURI('/ajax/growth/friend_browser/checkbox.php').
setData(c).
setHandler(bind(this,function(e){
this.showMoreHandler(e,b);})).

setStatusElement(a).
send();},


showMoreHandler:function(a,b){

if(b==this.numGetNewRequests){
var c=a.payload;
DOM.appendContent
(this._contentGrid,
c.results);
this.updatePagerAndExtraData(c.pager,c.extra_data);}},






getNew:function(a){


this.numGetNewRequests++;
var b=this.numGetNewRequests;


CSS.addClass
(this._checkboxResults,
'friendBrowserCheckboxContentOnload');


if(ge('friendBrowserCI'))
CSS.addClass($('friendBrowserCI'),'friendBrowserCheckboxContentOnload');



CSS.show(this._loadingIndicator);


var c=Form.serialize(this._form);
c.used_typeahead=a;
new AsyncRequest().
setURI('/ajax/growth/friend_browser/checkbox.php').
setData(c).
setHandler(bind(this,function(d){
this.getNewHandler(d,b);})).

send();},


getNewHandler:function(a,b){

if(b==this.numGetNewRequests){
var c=a.payload;


DOM.setContent
(this._contentGrid,
c.results);


CSS.removeClass
(this._checkboxResults,
'friendBrowserCheckboxContentOnload');


if(ge('friendBrowserCI'))
CSS.hide($('friendBrowserCI'));



CSS.hide(this._loadingIndicator);


this.updatePagerAndExtraData(c.pager,c.extra_data);}},



updatePagerAndExtraData:function(a,b){
DOM.setContent(this._contentPager,a);
this.setupOnVisible();
DOM.replace(this._form.elements.extra_data,b);},


setupOnVisible:function(){
var a=DOM.scry(this._contentPager,'.friendBrowserMorePager')[0];


if(a&&this._id!='jewel'){
this._onVisible&&this._onVisible.remove();

this._onVisible=new OnVisible
(a,
bind(this,'showMore'),
false,
1000);}}});

/** js/help/contextual_search.js */
__d("ContextualHelpSearchController",["Event","AsyncRequest","DOM","CSS","Focus","Input","copyProperties"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('AsyncRequest'),
i=b('DOM'),
j=b('CSS'),
k=b('Focus'),
l=b('Input'),

m=b('copyProperties'),

n=350;

function o(){
this._token=null;
this._timerID=0;
this._lastQuery=null;

this.typing_listener=null;
this.clear_listener=null;
this.async_request=null;}


m(o.prototype,

{init:
function(p,
q,
r,
s,
t){

this.loader=p;
this.search_box=q;
this.topics_area=r;
this.results_area=s;
this.clear_button=t;

this.typing_listener=g.listen
(this.search_box,
'keyup',
this.setTimer.bind(this));


this.clear_listener=g.listen
(this.clear_button,
'click',
this.clearResults.bind(this));


k.set(this.search_box);},


source:'contextual_help',

clearResults:function(){
this.show(this.topics_area);
this._lastQuery='';
l.reset(this.search_box);
k.set(this.search_box);
if(this.async_request!==null){
this.async_request.abort();
this.async_request=null;}

j.addClass(this.clear_button,'hidden_elem');},


update:function(){
var p=l.getValue(this.search_box);
if(p===this._lastQuery)
return;


this._lastQuery=p;

if(p===''){
this.clearResults();
return;}


this.show(this.loader);
var q=
{query:p,
width:this._width||n,
source:this.source};

this.async_request=new h('/help/ajax/search/').
setData(q).
setHandler(function(r){
this._update(r);}.
bind(this));
this.async_request.send();},


_update:function(p){
this.async_request=null;
var q=p.getPayload().results;
i.setContent(this.results_area,q);
this.show(this.results_area);

if(l.getValue(this.search_box)===''){
this.clearResults();}else 

j.removeClass(this.clear_button,'hidden_elem');},



setTimer:function(){
if(this._timerID!==0)
clearTimeout(this._timerID);

this._timerID=setTimeout(this.update.bind(this),300);

if(this.async_request!=null){
this.async_request.abort();
this.async_request=null;}},



show:function(p){
var q=[this.loader,this.topics_area,this.results_area];
for(var r=0;r<q.length;r++)
j.addClass(q[r],'hidden_elem');

j.removeClass(p,'hidden_elem');}});




e.exports=o;});

/** js/home/HomeRightColumnRemindersController.js */
__d("HomeRightColumnRemindersController",["Event","ContextualDialogX","DOM","Run","throttle"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('ContextualDialogX'),
i=b('DOM'),
j=b('Run'),

k=b('throttle'),

l=[],
m;

function n(){
l.forEach(function(q){
q.remove();});

l=[];}


function o(){

for(var q=0;q<m.length;q++){
var r=h.getInstance(m[q]);
r.hide();}}



var p=
{init:function(){
m=i.scry(document,'div.fbRemindersContent');

j.onLeave(n);

l=
[g.listen(window,'resize',k(o)),
g.listen(window,'scroll',k(o))];}};




e.exports=p;});

/** js/jewel/RequestsJewel.js */






















function RequestsJewel(){}

copyProperties(RequestsJewel,
{instance:null,
getInstance:function(){
return this.instance;}});



copyProperties(RequestsJewel.prototype,
{init:function(a,b,c){
RequestsJewel.instance=this;
this.countNew=0;
this.jewel=a;
this.jewelFlyoutCase=a.getRoot();
this.jewelFlyout=ge('fbRequestsFlyout');
this.newCountSpan=ge('newRequestCount');
this.folder=b;
this.doNewMarkRead=c;
this.openTimestamp=0;
this._requestList={};
this._requestCount=0;

var d=ge('requestsMarkReadButton');
if(d)
Event.listen(d,'click',this._markRead.shield(this));


this.jewel.subscribe('marked-seen',this._markSeenCallback.shield(this));
this.jewel.subscribe('closed',this._clearNewItems.shield(this));
this.jewel.subscribe('updated',this._updateCount.bind(this));
this.jewel.subscribe('opened',this._openHandler.bind(this));


LinkController.registerHandler(this._handleLink.bind(this));

Arbiter.subscribe
(ChannelConstants.getArbiterType('jewel_requests_add'),
this._addRequest.bind(this));

Arbiter.subscribe
(ChannelConstants.getArbiterType('jewel_requests_remove_old'),
this._removeOldRequest.bind(this));

Arbiter.subscribe
(ChannelConstants.getArbiterType('friend_requests_seen'),
this._markSeenFromMessage.bind(this));





Event.listen(this.jewelFlyout,'submit',function(e){
var f=Parent.byClass(e.getTarget(),'objectListItem');
if(f){
CSS.removeClass(f,'jewelItemNew');
CSS.addClass(f,'jewelItemResponded');


this.pageInCollapsedRequests();}}.

bind(this));

this.setupScroll();

return this;},


setupScroll:function(){

var a=DOM.scry(this.jewelFlyout,'.uiScrollableAreaWrap')[0];
if(a){
this._scrollableWrap=a;
this._lastLinkPosition=0;
this._scrollListener=Event.listen
(a,
'scroll',
this._handleScroll.bind(this),
Event.Priority._BUBBLE);}},




fromDom:function(){
DOM.scry(this.jewelFlyout,'.jewelItemList li.objectListItem').
forEach(function(a){
var b=a.getAttribute('id');
if(b){
var c=this._parseIDToInts(b);
if(c.requester)
this._requestList[c.requester]=b;

++this._requestCount;}}.

bind(this));
this._conditionShowEmptyMessage();},







_parseID:function(a){
var b=a.match(/^(\d+)_(\d+)/);
return (b)?{requester:b[1],type:b[2]}:undefined;},


_parseIDToInts:function(a){
var b=a?this._parseID(a):undefined,

c;
if(b&&b.requester){
c=parseInt(b.requester,10);
if(isNaN(c))
c=undefined;}



var d;
if(b&&b.type){
d=parseInt(b.type,10);
if(isNaN(d))
d=undefined;}



return {requester:c,type:d};},


_handleLink:function(a,event){
var b=Parent.byClass(a,'jewelItemNew');
if(b&&
Parent.byClass(b,'fbRequestList')&&
Parent.byClass(b,'beeperEnabled')){
var c=this._parseID(b.id);


c&&this._markSeenCallback(c.requester,c.type);


Arbiter.inform('jewel/count-updated',
{jewel:'requests',
count:--this.countNew});



CSS.removeClass(b,'jewelItemNew');}

return true;},


_handleScroll:function(){


var a=DOM.scry(this._scrollableWrap,'.uiMorePager');



if(!a||(ge('fbRequestsJewelManualPager')&&a.length<2))
return;

var b=a.pop();

if(b){


var c=Vector2.getElementPosition(b,'viewport').y;
if(c>0)
CSS.addClass
(Parent.byClass(this._scrollableWrap,'uiScrollableArea'),
'contentAfter');



var d=DOM.find(b,'a');
if(!d)
return;


var e=Vector2.getElementPosition(d,'viewport').y;
if(e==this._lastLinkPosition)
return;


var f=
Vector2.getElementPosition(this._scrollableWrap,'viewport').y+
Vector2.getElementDimensions(this._scrollableWrap).y;
if(e-300<f&&e>0){
this._lastLinkPosition=e;


var g=d.getAttribute('ajaxify');
if(g){
new AsyncRequest(g).
setRelativeTo(d).
setStatusElement(Parent.byClass(d,'stat_elem')).
send();}else 

FriendBrowserCheckboxController.getInstance('jewel').showMore();}}},





_addRequest:function(a,b){
if(!b)
return;


var c=b.obj.from,
d=b.obj.suggester,

e=this._parseIDToInts(this._requestList[c]).type,
f=e===19&&!d;



if(!f&&(e||this.jewel.isOpen()))
return;


if(ge('fbRequestsJewelLoading')){

new AsyncRequest().setURI('/ajax/requests/loader/').send();}else{

var g=this._onMarkupCallback.bind(this,c,!!d),
h={from:c};
if(d)
h.suggester=d;


new AsyncRequest().
setURI('/ajax/friends/jewel/request_markup').
setData(h).
setHandler(g).
send();}},



_onMarkupCallback:function(a,b,c){
var d=c.getPayload();
if(!d)
return;


var e=this._requestList[a],
f=this._parseIDToInts(e).type;


if(f===19&&!b){
var g=e&&ge(e);
g&&DOM.replace(g,d.markup);}else{

var h=DOM.scry(this.jewelFlyout,'.fbRequestList .uiList')[0];
if(!h)
return;


DOM.prependContent(h,d.markup);

var i={jewel:'requests',count:++this.countNew};
Arbiter.inform('jewel/count-updated',i);

++this._requestCount;
this._conditionShowEmptyMessage();}


this._requestList[a]=d.item_id;},


_removeOldRequest:function(a,b){



if(!b||this.jewel.isOpen()||ge('fbRequestsJewelLoading')!==null)
return;


var c=this._requestList[b.obj.from],
d=c&&ge(c);
if(d){
CSS.hasClass(d,'jewelItemNew')&&
Arbiter.inform('jewel/count-updated',
{jewel:'requests',
count:--this.countNew});


if(!CSS.hasClass(d,'jewelItemResponded')){


DOM.remove(d);
delete this._requestList[b.obj.from];
--this._requestCount;
this._conditionShowEmptyMessage();}}},




pageInCollapsedRequests:function(){
var a=ge('fbRequestsJewelManualPager');

if(a){

var b=DOM.scry(a,'.uiMorePagerPrimary')[0];
if(b.style&&b.style.display!='none')


setTimeout(function(){b.click();},100);}},




_markRead:function(){
this.jewel.markSeen();
this._clearNewItems();},


_markSeenCallback:function(a,b){
var c=DOM.scry(this.jewelFlyout,'li');


new AsyncSignal('/ajax/gigaboxx/endpoint/UpdateLastSeenTime.php',
{folder:this.folder,
first_item:c[0].id}).
send();


var d=typeof a!='undefined'&&typeof b!='undefined'?
{requester:a,type:b}:
{};
this.doNewMarkRead&&
new AsyncSignal('/ajax/requests/mark_read/',d).send();},


_markSeenFromMessage:function(a,b){
Arbiter.inform
('jewel/count-updated',
{jewel:'requests',
count:0});},



_removeRequest:function(a,b){
var c=b.obj.item_id;

if(c){
var d=ge(c),
e=d&&CSS.hasClass(d,'jewelItemNew');
d?
DOM.remove(d):
false;


e&&Arbiter.inform('jewel/count-updated',
{jewel:'requests',
count:--this.countNew});}},





_clearNewItems:function(a,b){
DOM.scry(this.jewel.root,'li.jewelItemNew').forEach(function(c){
CSS.removeClass(c,'jewelItemNew');});},



_updateCount:function(a,b){
this.countNew=b.count;
CSS.conditionClass(this.jewelFlyout,'beeperUnread',this.countNew>0);
CSS.conditionClass
(this.jewelFlyoutCase,
'showRequests',
this.countNew>0);

if(this.newCountSpan){
var c=this.countNew==1?
tx._("{num} NEW REQUEST",{num:this.countNew}):
tx._("{num} NEW REQUESTS",{num:this.countNew});
DOM.setContent(this.newCountSpan,c);}},



_conditionShowEmptyMessage:function(){

DOM.scry(this.jewelFlyout,'li.empty').forEach(function(a){
CSS.conditionShow(a,this._requestCount<=0);}.
bind(this));},


_openHandler:function(){
var a=DOM.scry(this.jewelFlyout,'.uiScrollableArea')[0];
if(ge('fbRequestsJewelLoading')){


var b=Date.now();
if(this.openTimestamp+5000<b){
this.openTimestamp=b;
new AsyncRequest().setURI('/ajax/requests/loader/').send();}}


a&&ScrollableArea.poke(a);}});

/** js/jewel/modules/JewelX.js */
__d("JewelX",["Event","Arbiter","ArbiterMixin","CSS","DOM","HTML","Keys","TabIsolation","Toggler","copyProperties","emptyFunction","reportData"],function(a,b,c,d,e,f){




var g=b('Event'),

h=b('Arbiter'),
i=b('ArbiterMixin'),
j=b('CSS'),
k=b('DOM'),
l=b('HTML'),
m=b('Keys'),
n=b('TabIsolation'),
o=b('Toggler'),

p=b('copyProperties'),
q=b('emptyFunction'),
r=b('reportData'),








s=function(t,u){

t&&u&&this.init(t,u);};


p(s,
{_instancesByName:{},
_resizeListener:null});


p(s.prototype,i,



{init:function(t,u){
this.name=u.name;
this.root=t;
this.countNew=0;
this.initialCount=0;
this.escHandler=null;

s._instancesByName[this.name]=this;

var v=k.find(t,'.jewelFlyout'),
w=new n(v);


o.listen('show',this.root,function(x){
this._logFirstClick();
this.hasNew()&&this.markSeen();
this.reset();
this.inform('opened');
h.inform('layer_shown',{type:'Jewel'});
w.enable();

this.setupEvents();}.
bind(this));


o.listen('hide',this.root,function(x,y){
this.hasNew()&&this.markSeen();
this.reset();
this.inform('closed');
h.inform('layer_hidden',{type:'Jewel'});
w.disable();
this.removeEvents();}.
bind(this));


h.subscribe('jewel/count-updated',function(x,y){
y.jewel==this.name&&this.update(y);}.
bind(this));
h.subscribe('jewel/count-initial',function(x,y){
y.jewel==this.name&&this.setInitial(y);}.
bind(this));
h.subscribe('jewel/reset',function(x,y){
y.jewel==this.name&&this.reset();}.
bind(this));

s._resizeListener=s._resizeListener||(function(){

var x=null;
return g.listen(window,'resize',function(){
clearTimeout(x);
x=
h.inform.bind(h,'jewel/resize').
defer(100,false);});})

();},






getRoot:function(){
return this.root;},






hasNew:function(){
return j.hasClass(this.root,'hasNew');},






isOpen:function(){
return j.hasClass(this.root,'openToggler');},





reset:function(){
j.removeClass(this.root,'hasNew');},






setContent:function(t){
var u=k.find(this.root,'ul.jewelItemList');
k.setContent(u,l(t));},






update:function(t){

this.countNew=t.count;
var u=k.find(this.root,'span.jewelCount span');
k.setContent(u,this.countNew);



var v=isNaN(this.countNew)||this.countNew>0;
j.conditionClass(this.root,'hasNew',v);

if(v){
var w=(''+this.countNew).length;
j.conditionClass(this.root,'hasCountSmall',w===1);
j.conditionClass(this.root,'hasCountMedium',w===2);
j.conditionClass(this.root,'hasCountLarge',w>2);}


this.inform('updated',t);},


setInitial:function(t){
this.initialCount=t;},





setupEvents:function(){
this.escHandler=g.listen
(document.documentElement,
'keydown',
function(t){
if(t.keyCode===m.ESC&&this.isOpen())
o.hide(this.root);}.

bind(this));},





removeEvents:function(){
if(this.escHandler)
this.escHandler.remove();},



markSeen:function(){

h.inform('jewel/count-updated',
{jewel:this.name,
count:0},

h.BEHAVIOR_STATE);

this.inform('marked-seen');},


_logFirstClick:function(){
this._logFirstClick=q;
r('jewel_click',{gt:
{count:this.countNew,
initial:this.initialCount,
jewel:this.name}});}});




e.exports=s;});

/** js/modules/UserNoOp.js */
__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;});

/** js/lib/event/user_action.js */
__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);

/** js/lib/util/Poller.js */
__d("legacy:Poller",["Poller"],function(a,b,c,d){



a.Poller=b('Poller');},

3);

/** js/lib/util/user_activity.js */
__d("legacy:user-activity",["UserActivity"],function(a,b,c,d){


a.UserActivity=a.UserActivity||b('UserActivity');},

3);

/** js/logging/banzai/BanzaiODS.js */
__d("BanzaiODS",["Banzai"],function(a,b,c,d,e,f){


var g=b('Banzai');

















function h(){
var j={};












function k(l,m,n,o){

var p=j[l]||(j[l]={}),
q=p[m]||(p[m]=[0]);


if(n===undefined)n=1;
if(o===undefined)o=1;




n=Number(n);
o=Number(o);


if(!isFinite(n)||!isFinite(o))








return;



q[0]+=n;


if(arguments.length>=4){
if(!q[1])q[1]=0;
q[1]+=o;}}







return {bumpEntityKey:function(l,m,n){
k(l,m,n);},






bumpFraction:function(l,m,n,o){
k(l,m,n,o);},


flush:function(l){
for(var m in j)
g.post('ods:'+m,j[m]);

j={};}};}




var i=h();
i.create=h;


g.subscribe(g.SEND,i.flush);

e.exports=i;});

/** js/logging/BanzaiODS-legacy.js */
__d("legacy:BanzaiODS",["BanzaiODS"],function(a,b,c,d){


a.BanzaiODS=b('BanzaiODS');},

3);

/** js/logging/logger.js */
__d("legacy:JSLogger",["JSLogger"],function(a,b,c,d){


a.JSLogger=b('JSLogger');},

3);

/** js/mercury/clients/jewel/controls/MercuryJewelCountControl.js */
__d("MercuryJewelCountControl",["Arbiter","MercuryConstants","DOM","MercuryServerRequests","MercuryThreadInformer","MercuryUnseenState","copyProperties","tx"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('MercuryConstants'),
i=b('DOM'),
j=b('MercuryServerRequests'),
k=b('MercuryThreadInformer'),
l=b('MercuryUnseenState'),

m=b('copyProperties'),
n=b('tx'),

o,
p,
q,

r=function(t){



if(t||q.isOpen())
l.markAsSeen();},



s=function(t,u){
o=t;
p=i.find(o,'#mercurymessagesCountValue');

q=u;

this.render();

j.subscribe('model-update-completed',function(v,w){
r(false);});

k.subscribe('unseen-updated',this.render.bind(this));



q.subscribe('marked-seen',r.shield(this,true));};


m(s.prototype,
{render:function(){
var t='';
if(l.exceedsMaxCount()){
t=n._("{count}+",
{count:h.MercuryThreadlistConstants.MAX_UNSEEN_COUNT});}else 


t=l.getUnseenCount().toString();




g.inform
('jewel/count-updated',
{jewel:'mercurymessages',count:t},
g.BEHAVIOR_STATE);}});




e.exports=s;});

/** js/mercury/clients/jewel/controls/MercuryJewelThreadlistControl.js */
__d("MercuryJewelThreadlistControl",["ArbiterMixin","MercuryConfig","MercuryConstants","CSS","DOM","Event","JSLogger","MercuryOrderedThreadlist","Parent","MercuryJewelTemplates","MercuryThreadInformer","MercuryThreadMetadataRenderer","MercuryThreads","MercuryUnreadState","copyProperties","csx","cx","throttle","tx"],function(a,b,c,d,e,f){



var g=b('ArbiterMixin'),
h=b('MercuryConfig'),
i=b('MercuryConstants'),
j=b('CSS'),
k=b('DOM'),
l=b('Event'),
m=b('JSLogger'),
n=b('MercuryOrderedThreadlist').get(),
o=b('Parent'),
p=b('MercuryJewelTemplates'),
q=b('MercuryThreadInformer'),
r=b('MercuryThreadMetadataRenderer'),
s=b('MercuryThreads').get(),
t=b('MercuryUnreadState').get(),

u=b('copyProperties'),
v=b('csx'),
w=b('cx'),
x=b('throttle'),
y=b('tx'),

z=m.create('mercury_jewel');

function aa(ha,ia){
this._contentArea=k.scry(ha,'.scrollable')[0]||ha;
this._contentElement=
k.find(this._contentArea,'.jewelContent');
this._loadingElement=
k.find(this._contentArea,'.jewelLoading');
this._uiList=
k.find(this._contentArea,'.jewelItemList');
this._loadMoreButton=k.find(this._contentArea,
"._8y5");
this._loadMoreLink=k.find(this._contentArea,
"a._8y6");

this._currentFolder=i.MessagingTag.INBOX;
if(h.OtherFolderJewelGK){
this._jewelFolderLinks=[];
this._jewelFolderLinks[i.MessagingTag.INBOX]=
k.find(ia,"._1sde");
this._jewelFolderLinks[i.MessagingTag.OTHER]=
k.find(ia,"._1sdf");

this._jewelFolderCounts=[];
this._jewelFolderCounts[i.MessagingTag.INBOX]=
k.find(ia,"._1sdg");
this._jewelFolderCounts[i.MessagingTag.OTHER]=
k.find(ia,"._1sdh");
fa.bind(this)();

l.listen
(this._jewelFolderLinks[i.MessagingTag.INBOX],
'click',
ea.bind(this,i.MessagingTag.INBOX));
l.listen
(this._jewelFolderLinks[i.MessagingTag.OTHER],
'click',
ea.bind(this,i.MessagingTag.OTHER));}




this._curCount=[];
this._curCount[i.MessagingTag.INBOX]=
i.MercuryThreadlistConstants.JEWEL_THREAD_COUNT+1;
this._curCount[i.MessagingTag.OTHER]=
i.MercuryThreadlistConstants.JEWEL_THREAD_COUNT+1;

this._isFolderLoaded=[];
this._isFolderLoaded[i.MessagingTag.INBOX]=false;
this._isFolderLoaded[i.MessagingTag.OTHER]=false;

this._folderIsLoading=[];
this._folderIsLoading[i.MessagingTag.INBOX]=false;
this._folderIsLoading[i.MessagingTag.OTHER]=false;

q.subscribe('threadlist-updated',this.render.bind(this));

if(h.OtherFolderJewelGK)
q.subscribe('unread-updated',fa.bind(this));


this.render();
z.bump('opened_threadlist_'+this._currentFolder);

l.listen
(this._contentArea,'scroll',x(ba,50,this));
l.listen
(this._loadMoreLink,'click',this.renderMoreThreads.bind(this));}


u(aa,
{EVENT_THREADS_LOADED:'threads-loaded',
EVENT_THREADS_RENDERED:'threads-rendered'});


u(aa.prototype,g);
u(aa.prototype,

{render:function(){
k.empty(this._contentElement);
j.show(this._loadingElement);
j.hide(this._loadMoreButton);



var ha=k.create('div');
k.appendContent(this._contentElement,ha);


n.getThreadlist
(i.MercuryThreadlistConstants.RECENT_THREAD_OFFSET,
this._curCount[this._currentFolder],
this._currentFolder,
this.renderThreads.bind(this,ha),
true);},



renderThreads:function(ha,ia){
this.inform(aa.EVENT_THREADS_LOADED);
if(ia.length){
ia.forEach(function(ja){
var ka=
p[':fb:mercury:jewel:threadlist-row'].build();

s.getThreadMeta(ja,function(la){
r.renderCoreThreadlist
(la,
ka,
this.renderSingleThread.bind(this),
{show_unread_count:true});}.

bind(this));

k.appendContent(ha,ka.getRoot());}.
bind(this));}else 


k.setContent(this._uiList,this.renderEmptyThreadlist());

j.hide(this._loadingElement);
j.conditionShow
(this._loadMoreButton,
!this._isFolderLoaded[this._currentFolder]);

this.inform(aa.EVENT_THREADS_RENDERED);},


renderSingleThread:function(ha,ia){
if(ia.unread_count>0)
j.addClass(ha.getRoot(),'jewelItemNew');

r.renderTitanLink
(ia.thread_id,
ha.getNode('link'));


l.listen(ha.getRoot(),'mouseover',function(event){
var ja=ha.getRoot();
if(!o.byClass(ja,'notifNegativeBase'))
j.addClass(ja,'selected');});



l.listen(ha.getRoot(),'mouseout',function(event){
j.removeClass(ha.getRoot(),'selected');});},



renderMoreThreads:function(){
j.addClass(this._loadMoreButton,'async_saving');
this._folderIsLoading[this._currentFolder]=true;
var ha=this._curCount[this._currentFolder]+
i.MercuryThreadlistConstants.JEWEL_MORE_COUNT;
n.getThreadlist
(i.MercuryThreadlistConstants.RECENT_THREAD_OFFSET,
ha+1,
this._currentFolder,
da.bind(this,ha,this._currentFolder),
true,
i.MercuryAPIArgsSource.JEWEL);},



renderEmptyThreadlist:function(){
return k.create('li',{className:'empty'},"No messages");}});



function ba(){
if(!this._isFolderLoaded[this._currentFolder]&&
!this._folderIsLoading[this._currentFolder]&&
ca.bind(this)())
this.renderMoreThreads();}



function ca(){
return this._contentArea.scrollTop+this._contentArea.clientHeight>=
this._contentArea.scrollHeight-1;}


function da(ha,ia,ja){
this._curCount[ia]=ha;
if(!this._isFolderLoaded[ia]&&
ja.length<this._curCount[ia]+1)
this._isFolderLoaded[ia]=true;

this._folderIsLoading[ia]=false;
j.removeClass(this._loadMoreButton,'async_saving');
this.render();}


function ea(ha){
if(this._currentFolder!=ha){
z.bump('opened_threadlist_'+ha);

j.addClass(this._jewelFolderLinks[ha],
"_1sdd");
j.removeClass(this._jewelFolderLinks[this._currentFolder],
"_1sdd");
this._currentFolder=ha;
this.render();}}



function fa(){
ga.bind(this)(i.MessagingTag.INBOX);
ga.bind(this)(i.MessagingTag.OTHER);}


function ga(ha){
var ia;
if(t.exceedsMaxCount(ha)){
ia=i.MercuryThreadlistConstants.MAX_UNREAD_COUNT;}else 

ia=t.getUnreadCount(ha);

var ja=this._jewelFolderCounts[ha];
if(ia>0){
if(ia==
i.MercuryThreadlistConstants.MAX_UNREAD_COUNT)
ia+='+';

k.setContent(ja,y._("({unread_count})",
{unread_count:ia}));}else 

k.setContent(ja,'');}



e.exports=aa;});

/** js/mercury/clients/jewel/MercuryJewel.js */
__d("MercuryJewel",["MercuryChannelHandler","MercuryJewelCountControl","DOM","MercuryJewelThreadlistControl","MercuryServerRequests","userAction"],function(a,b,c,d,e,f){



b('MercuryChannelHandler');

var g=b('MercuryJewelCountControl'),
h=b('DOM'),
i=b('MercuryJewelThreadlistControl'),
j=b('MercuryServerRequests'),
k=b('userAction'),

l=false;

function m
(q,
r,
s,
t){



j.handleUpdate(t);

var u=new g(r,s),

v=
h.find(q,'#MercuryJewelThreadList');

if(s.getRoot()&&s.isOpen()){
n.call(this,v,q);}else 

s.subscribe
('opened',
n.bind(this,v,q));}




e.exports=m;

function n(q,r){
this._ua=k('messages').uai('click','jewel');
this._listenForLoad=this._listenForRender=true;

if(!l){
var s=
new i(q,r);
s.subscribe
(i.EVENT_THREADS_LOADED,
o.bind(this));

s.subscribe
(i.EVENT_THREADS_RENDERED,
p.bind(this));

l=true;}}



function o(){
if(this._listenForLoad){
this._ua.add_event('loaded');
this._listenForLoad=false;}}



function p(){
if(this._listenForRender){
this._ua.add_event('rendered');
this._listenForRender=false;}}});

/** js/messaging/MessagingEvents.js */
__d("MessagingEvents",["array-extensions","Arbiter","ChannelConstants","copyProperties","isEmpty"],function(a,b,c,d,e,f){








b('array-extensions');

var g=b('Arbiter'),
h=b('ChannelConstants'),
i=b('copyProperties'),
j=b('isEmpty'),

k={},

l=new g();





function m(n){

if(!j(k))
return;



for(var o in n)
l.inform('count/'+o,n[o]);}





l.subscribe('mark-as-read',function(n,o){
(o.tids||o.chat_ids||[]).forEach(function(p){

p=''+p;

if(!(p in k)){

k[p]=true;



var q=function(){
l.unsubscribe(r);
clearTimeout(s);
delete k[p];},



r=l.subscribe('read',function(t,u){
if((u.tids||[]).contains(p)||
(u.chat_ids||[]).contains(p))
q();}),





s=q.defer(60000);}});});





g.subscribe
(h.getArbiterType('messaging'),
function(n,o){
var p=i({},o.obj),
event=p.event||'';
delete p.type;
delete p.event;
l.inform(event,p);


if('unread_counts' in p){
var q=p.unread_counts;
m
({unread:q.inbox,
other_unseen:q.other});}});






g.subscribe
(h.getArbiterType('inbox'),
function(n,o){
var p=i(o.obj);
delete p.type;


m(p);});



a.MessagingEvents=e.exports=l;},

3);

/** js/mercury/clients/titan_integration/TitanLeftNav.js */
__d("TitanLeftNav",["CounterDisplay","MessagingEvents"],function(a,b,c,d,e,f){



var g=b('CounterDisplay'),
h=b('MessagingEvents'),

i=
{initialize:function(){
h.subscribe('count/other_unseen',function(j,k){
g.setCount('other_unseen',k);});}};




e.exports=i;});

/** js/modules/AccessibleMenu.js */
__d("AccessibleMenu",["Event","CSS","DOM","Keys","TabbableElements","Toggler"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('CSS'),
i=b('DOM'),
j=b('Keys'),
k=b('TabbableElements'),
l=b('Toggler'),

m,
n,
o;

function p(){
var x=i.scry(m,'a[rel="toggle"]')[0];
x&&x.focus();
l.getInstance(m).hide();}


function q(x){
if(!x)
return false;


h.removeClass(x,'selected');
x.setAttribute('aria-selected','false');}


function r(x){
if(!x)
return false;


h.addClass(x,'selected');
x.setAttribute('aria-selected','true');

var y=k.find(x);
if(y[0])
y[0].focus();}



function s(x){
var y=i.scry(m,'.selected')[0],
z=n.indexOf(y)+x,
aa=n[z];

if(!aa)
return false;


q(y);
r(aa);}


function t(x){
if(!l.isShown()||l.getActive()!==m)
return true;


var y=g.getKeyCode(x);

switch(y){
case j.TAB:
s(x.shiftKey?-1:1);
g.prevent(x);
break;
case j.ESC:
p();
g.prevent(x);
break;
case j.UP:
case j.DOWN:
s(y===j.UP?-1:1);
g.prevent(x);
break;}}



function u(x,y){
m=y.getActive();
n=i.scry(m,'[role="menuitem"]');

if(!o)
o=g.listen
(document.documentElement,
'keydown',
t);}




function v(){
if(l.getActive()==m)
q(i.scry(m,'.selected')[0]);}



var w=
{init:function(x){
l.listen('show',x,u);
l.listen('hide',x,v);}};



e.exports=w;});

/** js/modules/DoublyLinkedListMap.js */
__d("DoublyLinkedListMap",["copyProperties"],function(a,b,c,d,e,f){







var g=b('copyProperties');

function h(){

this._head=null;

this._tail=null;








this._nodes={};
this._nodeCount=0;}


g(h.prototype,






{get:function(i){
return this._nodes[i]?this._nodes[i].data:null;},
















_insert:function(i,j,k,l){

k&&!this._nodes[k]&&(k=null);



var m=(k&&this._nodes[k])||
(l?this._head:this._tail),
n={data:j,key:i,next:null,prev:null};


if(m){

this.remove(i);

if(l){
n.prev=m.prev;
m.prev&&(m.prev.next=n);
m.prev=n;
n.next=m;}else{

n.next=m.next;
m.next&&(m.next.prev=n);
m.next=n;
n.prev=m;}}




n.prev===null&&(this._head=n);
n.next===null&&(this._tail=n);
this._nodes[i]=n;
this._nodeCount++;

return this;},












insertBefore:function(i,j,k){
return this._insert(i,j,k,true);},












insertAfter:function(i,j,k){
return this._insert(i,j,k,false);},










prepend:function(i,j){
return this.insertBefore(i,j,this._head&&this._head.key);},










append:function(i,j){
return this.insertAfter(i,j,this._tail&&this._tail.key);},









remove:function(i){
var j=this._nodes[i];
if(j){

var k=j.next,
l=j.prev;
k&&(k.prev=l);
l&&(l.next=k);
this._head===j&&(this._head=k);
this._tail===j&&(this._tail=l);
delete this._nodes[i];
this._nodeCount--;}

return this;},













find:function(i){
for(var j=this._head;j;j=j.next)
if(i(j.data))
return j.key;


return null;},


















reduce:function(i,j){
for(var k=this._head;k;k=k.next)
j=i(k.data,j);

return j;},








exists:function(i){
return !!this._nodes[i];},







isEmpty:function(){
return !this._head;},





reset:function(){
this._head=null;
this._tail=null;
this._nodes={};
this._nodeCount=0;},





map:function(i){
for(var j=this._head;j;j=j.next)
i(j.data);},



getCount:function(){
return this._nodeCount;},


getHead:function(){
return this._head&&this._head.data;},


getTail:function(){
return this._tail&&this._tail.data;},


getNext:function(i){
var j=this._nodes[i];
if(j&&j.next)
return j.next.data;

return null;},


getPrev:function(i){
var j=this._nodes[i];
if(j&&j.prev)
return j.prev.data;

return null;}});



e.exports=h;});

/** js/modules/LongQueryCacheBehavior.js */
__d("LongQueryCacheBehavior",["copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('copyProperties'),
h=b('emptyFunction'),
i=0;





function j(k){
this.dataSource=k.getData();}


g(j.prototype,

{enable:function(){
this.dataSource.subscribe('beforeQuery',function(k,l){
this._queryExactMatch=
!l.local_only&&l.value.length>=i;}.
bind(this.dataSource));},


disable:h});


g(j,
{setLength:function(k){
i=k;}});



e.exports=j;});

/** js/modules/SkipQueryCacheTimeoutBehavior.js */
__d("SkipQueryCacheTimeoutBehavior",["copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('copyProperties'),
h=b('emptyFunction'),
i=0;





function j(k){
this.dataSource=k.getData();}


g(j.prototype,

{enable:function(){
this.dataSource.subscribe('beforeQuery',function(k,l){
this._queryExactMatch=
!l.local_only&&l.time_waited<i;}.
bind(this.dataSource));},


disable:h});


g(j,
{setTimeout:function(k){
i=k;}});



e.exports=j;});

/** js/modules/UseQueryCacheTimeoutBehavior.js */
__d("UseQueryCacheTimeoutBehavior",["copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('copyProperties'),
h=b('emptyFunction'),
i=0;





function j(k){
this.dataSource=k.getData();}


g(j.prototype,

{enable:function(){
this.dataSource.subscribe('beforeQuery',function(k,l){
this._queryExactMatch=
!l.local_only&&l.time_waited>=i;}.
bind(this.dataSource));},


disable:h});


g(j,
{setTimeout:function(k){
i=k;}});



e.exports=j;});

/** js/notifications/modules/NotificationCounter.js */
__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;});

/** js/notifications/NotificationCounter-legacy.js */
__d("legacy:notifications-counter",["NotificationCounter"],function(a,b,c,d){



a.NotificationCounter=b('NotificationCounter');},

3);

/** js/notifications/experiments/negativeFeedback/notif_xlist.js */
__d("legacy:notif-xlist",["NotifXList"],function(a,b,c,d){



a.NotifXList=b('NotifXList');},

3);

/** js/notifications/experiments/negativeFeedback/xbutton.js */











function NegativeNotif(a,b){
copyProperties(this,b);

this.owner=a;

this.xLink=DOM.find(this.obj,'.notif_x');
this.confirmingMsg=DOM.find(this.obj,'.confirmingMsg');
this.mainLink=DOM.find(this.obj,'.notifMainLink');
this.userXClicked=false;
this.userUnsubscribed=false;

Event.listen(this.xLink,'click',this.xClick.bind(this));


if(CSS.hasClass(this.obj,'first_receipt')&&
CSS.hasClass($('jewelContainer'),'notifGentleAppReceipt'))

this.gentleFirstReceiptHoverEventHandler=Event.listen
(this.obj,
'mouseover',
this.gentleFirstReceiptNotifHover.bind(this));}




copyProperties(NegativeNotif.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 a=this.xLink.getAttribute('data-gt'),
b=a?{gt:JSON.parse(a)}:{};
user_action('xbutton',this.xLink,event).uai('click');
click_ref_action('click',this.xLink,event,null,b);

return false;},








gentleFirstReceiptNotifHover:function(event){

event.stop();


var a=
DOM.find(this.obj,'.first_receipt_no_button'),
b=
DataStore.get(a,'notif_fr_prompt');
Tooltip.set
(a,
b,
'above',
'center');

Tooltip.show(a);
this._gentleFirstReceiptTooltipFadeIn();


if(!this.gentleFirstReceiptUnhoverEventHandler){
this.hoverTime=new Date();
this.gentleFirstReceiptUnhoverEventHandler=Event.listen
(document.documentElement,
'mouseover',
this.gentleFirstReceiptNotifUnhover.bind(this));}


if(!this.gentleFirstReceiptNoClickEventHandler)
this.gentleFirstReceiptNoClickEventHandler=Event.listen
(a,
'click',
this.gentleFirstReceiptNoClick.bind(this));},










gentleFirstReceiptNotifUnhover:function(event){

if(Parent.byClass(event.getTarget(),'uiContextualLayer')||
Parent.byClass(event.getTarget(),'uiScrollableAreaTrack'))
return false;



var a=new Date();
if(this.hoverTime&&
a-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 b=this;
setTimeout(function(){
b._gentleFirstReceiptUIFadeAway();},
this.GENTLE_FRUI_DELAY_FADE_TIME);

this._sendFirstReceiptYesToServer();},









gentleFirstReceiptNoClick:function(event){
this._removeGentleFirstReceiptListeners();},






restore:function(){
if(this.owner.notifXList.newNotifExist(this.id)){
this.owner.notifXList.resumeInsert(this.id);}else 

this.owner.notifXList.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;
CSS.hide(this.confirmingMsg);
this._notifMainLinkShowUp(DOM.find(this.obj,'.confirmedMsg'));
this._adjustContainer(this.obj);},


onUndid:function(){
this.userXClicked=false;
this.userUnsubscribed=false;
this.restore();
CSS.show(this.confirmingMsg);
this._notifMainLinkFadeAway(DOM.find(this.obj,'.confirmedMsg'));
DOM.remove(DOM.find(this.obj,'.confirmedMsg'));},


onMarkedSpam:function(){
DOM.remove(DOM.find(this.obj,'.confirmedMsg'));

this._fadeAway(DOM.find(this.obj,'.spamMsg'));},


onFirstReceiptYes:function(){
this._hideFirstReceiptDiv();

this._fadeAway(DOM.find(this.obj,'.firstConfirmedMsg'));},


onFirstReceiptNo:function(){
this._hideFirstReceiptDiv();


CSS.hide(this.confirmingMsg);
this._activateX();
new AsyncRequest().
setURI('/ajax/notifications/negative_req.php').
setData({request_type:'turn_off',notification_id:this.id}).
send();},





_sendFirstReceiptYesToServer:function(){
new AsyncRequest().
setURI('/ajax/notifications/negative_req.php').
setData({request_type:'first_receipt_yes',notification_id:this.id}).
send();},





_gentleFirstReceiptTooltipFadeIn:function(){
if(this._gentleFirstReceiptTooltipAlreadyFadedIn)return;

var a=DOM.find
(document.documentElement,
'.uiLayer .uiContextualLayer .uiTooltipX');


animation(a).
from('opacity','0').
to('opacity','1').
duration(this.GENTLE_FRUI_FADE_DURATION_FAST).
go();

this._gentleFirstReceiptTooltipAlreadyFadedIn=true;},





_gentleFirstReceiptTooltipFadeAway:function(){
if(!this._gentleFirstReceiptTooltipAlreadyFadedIn)return;

var a=DOM.find
(document.documentElement,
'.uiLayer .uiContextualLayer .uiTooltipX'),




b=Parent.byClass(a,'uiLayer'),
c=b.cloneNode(true);
DOM.insertAfter(b,c);

animation(c).
from('opacity','1').
to('opacity','0').
duration(this.GENTLE_FRUI_FADE_DURATION_FAST).
ondone(function(){
DOM.remove(c);}).

go();

this._gentleFirstReceiptTooltipAlreadyFadedIn=false;},





_gentleFirstReceiptXButtonFadeAway:function(){
var a=DOM.find(this.obj,'.first_receipt_no_button');
animation(a).
from('opacity','1').
to('opacity','0').
duration(this.GENTLE_FRUI_FADE_DURATION_FAST).
hide().
go();


CSS.addClass(this.obj,'show_original_x');},







_gentleFirstReceiptUIFadeAway:function(){
var a=this.obj;


this.new_label=DOM.find(this.obj,'.notif_new_label');
animation(this.new_label).
to('opacity','0').
duration(this.GENTLE_FRUI_FADE_DURATION_SLOW).
ondone(function(){
CSS.removeClass(a,'first_receipt');}).

go();




if(!CSS.hasClass(this.obj,'jewelItemNew'))
animation(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(){



CSS.addClass(this.obj,'forPushSafety');
this.userXClicked=true;

this.owner.notifXList.userXClick(this.id);

this._notifMainLinkFadeAway(this.mainLink);
this._buttonFadeAway(this.xLink);

if(CSS.shown(this.confirmingMsg))
this._confirmingMsgShowUp(this.confirmingMsg);

this._adjustContainer(this.obj);},






_hideFirstReceiptDiv:function(){
CSS.removeClass(this.obj,'first_receipt');
CSS.hide(DOM.find(this.obj,'.first_receipt_div'));},








_fadeAway:function(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
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(a){
animation(a).
to('opacity','0').
blind().
duration(this.X_OUT_DURATION).
checkpoint().
hide().
duration(this.X_OUT_DURATION_SHORT).
go();}});

/** js/notifications/modules/NotificationList.js */
__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},
"No new notifications");



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;});

/** js/notifications/notifications_list.js */
__d("legacy:notifications-list",["NotificationList"],function(a,b,c,d){



a.NotificationList=b('NotificationList');},

3);

/** js/notifications/base_notifications.js */



















































function Notifications(a){
this.updateTime=a.updateTime||Date.now();
this.update_period=a.updatePeriod||60000;
this.latest_notif_time=a.latestNotif||0;
this.latest_read_notif_time=a.latestReadNotif||0;
this.cache_version=a.cacheVersion||0;

this.notifReceivedType=a.notifReceivedType||'notification';
this.wrapperID=a.wrapperID||'notificationsWrapper';
this.contentID=a.contentID||'jewelNotifs';

this.shouldLogImpressions=a.shouldLogImpressions||false;
this.allowDesktopNotifications=a.allowDesktopNotifications||false;
this.logAutoShutOffImpression=true;


this.useInfiniteScroll=a.useInfiniteScroll||false;
this.unseenVsUnread=a.unseenVsUnread||false;

this.scrollableAreaNode=null;
this.firstReceiptMap={};
this.user=Env.user;
this.queuedNotifications=[];

this.timeElement='small.time';

this.ua=new UserNoOp();

this._init();}


Notifications.BEEPS_EXPIRED='beeper/beeps_expired';
Notifications.BEEPER_APPID=30729425562;
Notifications.BEEPER_REF='beeper';

copyProperties(Notifications.prototype,

{TIME_TRAVEL:'time_travel',
ONLINE:'online',
SCROLL_OFF_TINY:'scroll_off_tiny',
INACTIVE_REFRESH:'inactive_refresh',

_init:function(){
this.ignoreBeeps=false;
this.cookieName='notifications_'+this.user;
this.beepsExpiredToken=null;
this.updateCheckCount=0;

this.fetchListeners=[];
this.currentFetchRequest=null;

this.wrapper=ge(this.wrapperID);
this.content=ge(this.contentID);
this.jewelFlyout=ge('fbNotificationsFlyout');
this.footer=DOM.find(this.jewelFlyout,'.jewelFooter');
this.loadingIndicator=ge(this.contentID+'_loading_indicator');

this.NOTIF_JEWEL_REF='notif_jewel';
this.notifLogger=JSLogger.create('notifications');


NotificationCounter.init();

this.alertList=new NotificationList(this.content,this._getListParams());
this._updateCount();


window.MinNotifications&&
MinNotifications.fetchSent()&&
(this.fetch=emptyFunction);


Arbiter.subscribe
(ChannelConstants.getArbiterType(this.notifReceivedType),
this._handleNotificationMsg.bind(this));
Arbiter.subscribe
(ChannelConstants.getArbiterType('notifications_read'),
this._handleNotificationsReadMsg.bind(this));
Arbiter.subscribe
(ChannelConstants.getArbiterType('notifications_seen'),
this._handleNotificationsSeenMsg.bind(this));
Arbiter.subscribe
('jewel/resize',
this._hideOverflow.shield(this));

this.alertList.subscribe(NotificationList.UNREAD_COUNT_CHANGE_TYPE,
this._updateCount.bind(this));

this._poller=new Poller
({interval:this.update_period,
setupRequest:this._update.bind(this),
clearOnQuicklingEvents:false});


if(this.wrapper)
this.countSpan=DOM.find(this.wrapper,'span.jewelCount span');


this.initializeEvents();

this.fromDom();

if(this.useInfiniteScroll){


this._autoLoadNotifIndex=1;




this._truncate=false;
this.alertList.subscribe(NotificationList.INSERTION_TYPE,
this._handleInsert.bind(this));}},



_getListParams:function(){





return {shouldBlockAnimation:function(a){
return this.isNotifJewelOpen();}.
bind(this),
unseenVsUnread:this.unseenVsUnread};},






fromDom:function(){
this.ignoreBeeps=true;

this.alertList.fromDom();

window.MinNotifications&&
MinNotifications.fetched()&&
this.alertList.isEmpty()&&
this.alertList.showNoNotifications();

this.ignoreBeeps=false;},


initializeEvents:function(){
var a=this.alertList.ITEM_TAG,
b=null;
Event.listen(this.content,
{mouseover:function(event){
var d=event.getTarget();
b=Parent.byTag(d,a);
if(b&&d!=b)
if(Parent.byClass(b,'notifNegativeBase')){
CSS.addClass(b,'notifHover');}else 

CSS.addClass(b,'selected');},



mouseout:function(event){
b&&CSS.removeClass(b,'selected');
b&&CSS.removeClass(b,'notifHover');
b=null;},

mousedown:this.onContentMouseDown.bind(this)});


Event.listen(this.wrapper,'mouseover',this.onMouseOver.bind(this));



Toggler.listen('show',this.wrapper,this.onClick.bind(this));
Toggler.listen('hide',this.wrapper,this.onHide.bind(this));
this.shouldLogImpressions&&
Toggler.listen('show',this.wrapper,this._logImpression.bind(this));




var c=function(d){
this._poller.request();
this.notifLogger.bump(d);}.
bind(this);



SystemEvents.subscribe
(SystemEvents.TIME_TRAVEL,
c.curry(this.TIME_TRAVEL));



SystemEvents.subscribe(SystemEvents.ONLINE,function(d,e){
e&&c(this.ONLINE);});



INACTIVE_REFRESH_MS=1000*60*60;
UserActivity.subscribe(function(d,e){
(e.idleness>INACTIVE_REFRESH_MS)&&c(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=
DOM.scry(this.jewelFlyout,'div.uiScrollableAreaWrap')[0];


this._morePagerLink=DOM.find(this.jewelFlyout,'.notifMorePager a');



this._morePager=Parent.byClass(this._morePagerLink,'notifMorePager')||
this._morePagerLink;

this._infiniteScrollNotif=null;




this.afterFirstFetch=false;
this.animate=false;


if(window.MinNotifications&&MinNotifications.fetched()){
this.afterFirstFetch=true;
CSS.show(this._morePager);}},



_initializeScrollEvents:function(){
Event.listen(this._scrollArea,'scroll',
throttle(this._handleScroll.bind(this)));



Event.listen(this._morePagerLink,'success',function(a){
this.fetchHandler(a.getData().response);}.
bind(this));},






_updateScrollDataStructures:function(){
var a=this.alertList.getIds(),
b=Math.max(0,a.length-this._autoLoadNotifIndex);
this._infiniteScrollNotif=this.alertList.getDomObj(a[b]);
this._annotateMorePagerURI();},







_annotateMorePagerURI:function(){
this._morePagerLink.setAttribute
('ajaxify',
new URI(this._morePagerLink.getAttribute('ajaxify')).addQueryData
({earliest_time:this.alertList.getEarliestNotifTime()}));},



onContentMouseDown:function(event){

var a=Parent.byTag(event.getTarget(),this.alertList.ITEM_TAG),
b=a&&NotificationList.getIdFromDom(a);
if(b&&this.alertList.isUnreadId(b))
this.markRead(true,[b]);

if(Banzai.isEnabled('notifications'))
BanzaiODS.bumpEntityKey('notifications','click');},







onMouseOver:function(event){



if(CSS.hasClass(event.getTarget(),"jewelButton"))
this.ua=user_action('notifs',event.target,event,{mode:'DEDUP'}).
uai('mouseover','jewel').
add_event('hover');


this.fetch();},





onClick:function(){


window.ArbiterMonitor&&this.fetch!=emptyFunction&&
Arbiter.registerCallback(emptyFunction,['notifs/fetched']);




this.ua.add_event('show');
this.fetch();
this.markRead(true);
this._hideOverflow();
if(this.scrollableAreaNode){
var a=ScrollableArea.getInstance(this.scrollableAreaNode);
a&&a.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(a){
this._displayNotification(a.type,a.data);},
this);


this.queuedNotifications.length=0;},





_handleScroll:function(){
if(this._checkInfiniteScroll()){


this._autoLoadNotifIndex=5;
this._sendFetchRequest(this._morePager);}},



_handleInsert:function(a,b){


if(b.is_new)
this._newDataFromInsert=true;

this._updateScrollDataStructures();},






_checkInfiniteScroll:function(){
if(this._infiniteScrollNotif&&this._scrollArea){
var a=Vector2.getElementPosition(this._infiniteScrollNotif).y,
b=
Vector2.getElementPosition(this._scrollArea).y+
Vector2.getElementDimensions(this._scrollArea).y;
return a<b;}

return false;},


_initNotifNegativeFeedback:function(){
this.notifXList=null;

this.notifXList=window.NotifXList;
this.notifXList.init(this);
this.alertList.setFilterFn
(this.notifXList.filterStoreClicked);


Toggler.listen('hide',$(this.wrapperID),function(){
for(var a in this.negativeNotifs)
if(a)
this.negativeNotifs[a] instanceof NegativeNotif&&
this.negativeNotifs[a].reset();}.


bind(this));

Arbiter.subscribe
('notif/negativeCancel',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].restore();}.
bind(this));


Arbiter.subscribe
('notif/negativeConfirmed',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].onTurnedOff();
this.alertList.toggleNotifsSimilarTo(b.id,true,true);

this._hideOverflow();

this._handleScroll();}.
bind(this));


Arbiter.subscribe
('notif/negativeUndid',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].onUndid();
this.alertList.toggleNotifsSimilarTo(b.id,false,true);


this._hideOverflow();}.
bind(this));


Arbiter.subscribe
('notif/negativeMarkedSpam',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].onMarkedSpam();}.
bind(this));


Arbiter.subscribe
('notif/negativeFirstReceiptYes',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].onFirstReceiptYes();
this.alertList.toggleNotifsSimilarTo(b.id,false,true);}.
bind(this));


Arbiter.subscribe
('notif/negativeFirstReceiptNo',
function(a,b){
this.negativeNotifs[b.id]&&
this.negativeNotifs[b.id].onFirstReceiptNo();
this.alertList.toggleNotifsSimilarTo(b.id,false,true);}.
bind(this));





this.alertList.subscribe
(NotificationList.INSERTION_TYPE,function(a,b){
this._updateFirstReceipt(b);
var c=DOM.scry(b.obj,'.notif_x');
if(c.length==1)
this.negativeNotifs[b.id]=new NegativeNotif(this,b);}.

bind(this));},









_sendIDs:function(a,b,c){
var d=c||{};
for(var e=0;e<a.length;++e)
d['alert_ids['+e+']']=a[e];

new AsyncSignal(URI(b).getQualifiedURI().toString(),d).send();},


_waitForFetch:function(a){
return this.currentFetchRequest&&
this.fetchListeners.push(a.bind(this));},





_logImpression:function(){
var a=this.alertList.getIds();


if(a.length===0&&this._waitForFetch(this._logImpression))
return;

this.logImpressionIds(a,this.NOTIF_JEWEL_REF);},







logImpressionIds:function(a,b){
this.shouldLogImpressions&&
this._sendIDs(a,'/ajax/notifications/impression.php',{ref:b});},















markRead:function(a,b){
var c=!hasArrayNature(b);



b=c?
this.alertList.getUnseenIds():
b.filter(this.alertList.isUnreadId.bind(this.alertList));


if(b.length){
a&&this._sendIDs
(b,
'/ajax/notifications/mark_read.php',
{seen:c?1:0});


if(ge('jewelNoticeMessage')&&this.logAutoShutOffImpression){

new AsyncSignal('/ajax/notifications/auto_shutoff_seen.php').send();
this.logAutoShutOffImpression=false;}




var d=a;
c?this.alertList.markSeen(b):
this.alertList.markRead(b,d);}




c&&this._waitForFetch(this.markRead.bind(this,a));},






markAllRead:function(){
var a=this.alertList.getUnreadIds();
this.markRead(true,a);},







_updateErrorHandler:function(a){
},


_updateURI:'/ajax/presence/update.php',

_update:function(a){
a.
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(a){
var b=a.payload.notifications;

if(!b.no_change){
this.updateTime=a.payload.time;
this.latest_notif_time=b.latest_notif;
this.latest_read_notif_time=b.latest_read_notif;

this._updateDisplayDelayed();

this.alertList.insertMany(b.notifications);}},









_updateDisplayDelayed:function(){
if(typeof Beeper!='undefined'){
this.beepsExpiredToken=
Arbiter.subscribe(Notifications.BEEPS_EXPIRED,
this._updateDisplay.bind(this));}else 

this._updateDisplay();},



_updateDisplay:function(){
if(!this.content)
return;


this._updateCount();

if(this.beepsExpiredToken)
this.beepsExpiredToken.unsubscribe();},



_updateCount:function(){
Arbiter.inform('jewel/count-updated',
{jewel:'notifications',count:this.alertList.unseenCount},
Arbiter.BEHAVIOR_STATE);
this._hideOverflow();},







fetch:function(a){
this._sendFetchRequest(a);},


_getFetchQueryData:function(){
var a=
{time:this.latest_notif_time,
user:this.user,
version:this.cache_version,
locale:Env.locale};

if(this.useInfiniteScroll)
a.earliest_time=this.alertList.getEarliestNotifTime();

return a;},


_sendFetchRequest:function(a){
if(this.useInfiniteScroll){

this._infiniteScrollNotif=null;


this._newDataFromInsert=false;



this._truncate=true;}


var b=URI('/ajax/notifications/get.php'),
c=a||this.loadingIndicator;



if(this.currentFetchRequest)
return true;


this.ua.add_event('fetch');

b.setQueryData(this._getFetchQueryData());



this.currentFetchRequest=new AsyncRequest().
setURI(b).
setStatusElement(c).
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(a){
this.currentFetchRequest=null;
this.ua.add_event('fetch_error');

this.loadingIndicator&&CSS.hide(this.loadingIndicator);


this.useInfiniteScroll&&this._updateScrollDataStructures();},









fetchHandler:function(a){
this.ua.add_event('fetch_success');
var b=a.getPayload();

this.alertList.insertMany(b.notifications,true);
this.loadingIndicator&&CSS.hide(this.loadingIndicator);
this.loadingIndicator=null;
this.currentFetchRequest=null;
this.fetch=emptyFunction;


if(this.fetchListeners){
for(var c=0;c<this.fetchListeners.length;c++)
this.fetchListeners[c]();

this.fetchListeners=[];}


window.ArbiterMonitor&&
Arbiter.inform('notifs/fetched','',Arbiter.BEHAVIOR_STATE);



var d=b.generated,
e=Math.round(Date.now()/1000);
if(e-d>15)
d=e;



Bootloader.loadComponents('live-timer',
function(){LiveTimer.restart(d);LiveTimer.startLoop(0);});


if(this.useInfiniteScroll){



if(is_empty(b.notifications)||!this._newDataFromInsert){
this._noMoreNotifications();}else 


CSS.show(this._morePager);

this._updateScrollDataStructures();



if(this.isNotifJewelOpen()&&this.afterFirstFetch)
this.animate=true;

this.afterFirstFetch=true;}


this._hideOverflow();},


_noMoreNotifications:function(){
CSS.hide(this._morePager);
this.useInfiniteScroll=false;},










_mergeNotification:function(a,b,
c,d){
var e=!this.alertList.isUnreadId(a);
this.alertList.insert(a,b,c,
true,null,d||null);



this.latest_notif_time=0;

if(e)
this._updateCount();



var f=this.alertList.getDomObj(a);
if(f)
Bootloader.loadComponents('live-timer',function(){
LiveTimer.addTimeStamps(f);});},




_handleNotificationMsg:function(a,b){


if(this.isNotifJewelOpen()){


var c=
{type:a,
data:b};

this.queuedNotifications.push(c);}else 


this._displayNotification(a,b);},



_displayNotification:function(a,b){
var c=b.obj;

if(typeof this.useDesktopNotifications=='undefined')


this.useDesktopNotifications=
this.allowDesktopNotifications&&
window.webkitNotifications&&
window.webkitNotifications.checkPermission()===0;


if(this.useDesktopNotifications)
Bootloader.loadComponents
('desktop-notifications',
function(){
DesktopNotifications.addNotification(c.alert_id);});



if(c.markup){
this._mergeNotification(c.alert_id,c.time,c.markup,
c.alt_id||null);}else 


this._poller.request();},



_handleNotificationsReadMsg:function(a,b){
var c=b.obj;
if(typeof Beeper!='undefined')
Beeper.getInstance().markRead(false,c.alert_ids);


this.markRead(false,c.alert_ids);},


_handleNotificationsSeenMsg:function(a,b){
if(!this.unseenVsUnread){
this._handleNotificationsReadMsg(a,b);
return;}


var c=b.obj;
if(typeof Beeper!='undefined')
Beeper.getInstance().markRead(false,c.alert_ids);

this.alertList.markSeen(c.alert_ids);},








_hideOverflow:function(){

if(!this.isNotifJewelOpen())
return;


var a=DOM.scry($('fbNotificationsList'),'.notification');
this.scrollableAreaNode=this.scrollableAreaNode||
DOM.scry(this.jewelFlyout,'.uiScrollableArea')[0];


var b=20,

c=
CSS.hasClass(document.documentElement,'tinyViewport')&&
!CSS.hasClass(document.body,'fixedBody');



if(!a.length||c){

Style.set(this.scrollableAreaNode,'height','100%');
this.notifLogger.rate(this.SCROLL_OFF_TINY,c);
return;}





var d=this.scrollableAreaNode||a[0],

e=
Vector2.getViewportDimensions().y-
Vector2.getElementPosition(d,'viewport').y-
Vector2.getElementDimensions(this.footer).y-
5,
f=e,
g=0;


for(;g<a.length&&f>0;++g)
if(CSS.shown(a[g]))
f-=Vector2.getElementDimensions(a[g]).y;





var h=530,
i=Math.min
(h,
e-Math.max(f,0));



if(f>=0&&i<h){


if(!this.useInfiniteScroll){
i='100%';}else{




if(this._truncate&&a.length>=5)
i-=b;

i+='px';}}else 



i+='px';




if(this.useInfiniteScroll&&this.animate&&i!='100%'){

this.animation&&this.animation.stop();
this.animation=animation(this.scrollableAreaNode).
to('height',i).
duration(200).
go();}else{

var j=ScrollableArea.getInstance(this.scrollableAreaNode);
j&&
j.showScrollbar.bind(j).defer();
Style.set(this.scrollableAreaNode,'height',i);}},
















_updateFirstReceipt:function(a){
var b=a.obj.getAttribute('data-appid'),
c=DOM.scry(a.obj,'.first_receipt_div');


if(b&&c.length==1){
if(this.firstReceiptMap[b]){


if(a.id!=this.firstReceiptMap[b].id&&
this.firstReceiptMap[b].time>a.time)
return;


CSS.removeClass(this.firstReceiptMap[b].obj,'first_receipt');}

this.firstReceiptMap[b]=a;
CSS.addClass(a.obj,'first_receipt');}},






isNotifJewelOpen:function(){


var a=Toggler.getInstance(this.wrapper).getActive();
return (a===this.wrapper&&
CSS.hasClass(a,'openToggler'));}});



var OriginalNotifications=Notifications;

/** js/pages/voice/voice_bar.js */
__d("PagesVoiceBar",["$","Arbiter","AsyncRequest","CSS","ChannelConstants","DOM","PageTransitions"],function(a,b,c,d,e,f){



var g=b('$'),
h=b('Arbiter'),
i=b('AsyncRequest'),
j=b('CSS'),
k=b('ChannelConstants'),
l=b('DOM'),
m=b('PageTransitions'),

n='PagesVoiceBar/toggle',
o='PagesVoiceBar/initialized',
p='PagesVoiceBar/switchVoice',
q='page_transition',
r='pages_voice_bar_sync',

s=null,
t=null,
u=false,
v=false;

function w(){
v=!v;
j.conditionClass(document.body,'hasVoiceBar',v);}


function x(da,ea){
new i('/ajax/pages/switch_voice.php').
setData(ea).
setHandler(function(fa){
ba();}).

send();}


function y(){
s=null;}


function z(da,ea){
if(ea.obj.profile_id&&ea.obj.profile_id==s)
ba();}



function aa(da){
h.subscribe(o,da);}


function ba(){


m.getNextURI().go();}


var ca=
{initVoiceBar:function(){
if(u)
return;


t=g('pagesVoiceBarContent');
v=j.hasClass(document.body,'hasVoiceBar');

h.subscribe(n,w);
h.subscribe(p,x);
h.subscribe(q,y);
h.subscribe
(k.getArbiterType(r),
z);

u=true;


h.inform(o,null,h.BEHAVIOR_STATE);},

update:function(da,ea){
aa(function(){
s=ea;
l.setContent(t,da);});}};




e.exports=ca;});

/** js/privacy/modules/lite/PrivacyLiteFlyout.js */
__d("PrivacyLiteFlyout",["Event","function-extensions","Animation","Arbiter","ArbiterMixin","AsyncRequest","CSS","DOM","Ease","Parent","Selector","Style","Toggler","copyProperties","cx","csx","ge"],function(a,b,c,d,e,f){



var g=b('Event');
b('function-extensions');

var h=b('Animation'),
i=b('Arbiter'),
j=b('ArbiterMixin'),
k=b('AsyncRequest'),
l=b('CSS'),
m=b('DOM'),
n=b('Ease'),
o=b('Parent'),
p=b('Selector'),
q=b('Style'),
r=b('Toggler'),

s=b('copyProperties'),
t=b('cx'),
u=b('csx'),
v=b('ge'),

w='PrivacyLiteFlyout/expandingSection',

x={},
y={};

function z(ea,fa,ga){
var ha=fa?0:ea.offsetHeight;
q.set(ea,'height',ha+'px');
q.set(ea,'overflow','hidden');
l.show(ea);
var ia=fa?ea.scrollHeight:0,
ja=m.getID(ea);
x[ja]&&x[ja].stop();
x[ja]=new h(ea).
to('height',ia).
ondone(function(){
x[ja]=null;
q.set(ea,'height','');
q.set(ea,'overflow','');
ia||l.hide(ea);
ga();}).

duration(Math.abs(ia-ha)*1.5).
ease(n.sineOut).
go();}


var aa=null,
ba=false,
ca=false,

da=s


({loadBody:function(ea){
if(!ba&&v('fbPrivacyLiteFlyoutLoading')){
ba=true;



if(!ea)
ea=false;


new k('/ajax/privacy/privacy_lite/loader').
setData({from_megaphone:ea}).
send();}},



renderBody:function(ea){
var fa=v('fbPrivacyLiteFlyoutLoading');
if(fa){
m.replace(fa,ea);
da.inform('load',null,i.BEHAVIOR_STATE);}},



hideCleanup:function(ea){

i.inform(w);


var fa=m.scry
(ea,
"._2va0").
forEach
(function(ga){
l.removeClass(ga,"_2va0");});},




registerFlyoutToggler:function(ea,fa){
aa=fa;
var ga=r.createInstance(ea);
ga.setSticky(false);
r.listen
(['show','hide'],
fa,
function(ha){
da.inform(ha);
ca=ha==='show';
if(!ca){
da.hideCleanup(ea);
ga.hide();}});},





registerReminderFlyout:function(ea){
if(ca)
return;

ea.setOffsetY
(o.byClass(ea.getContext(),'hasSmurfbar')?15:-5);

da.subscribe('show',function(){
ea.hide();});

ea.show();},


isFlyoutVisible:function(){
return aa&&r.getActive()===aa;},


exists:function(){
return !!m.scry(document.body,"._91j")[0];},


setFlyoutVisible:function(ea){
ea?r.show(aa):r.hide(aa);},


showSection:function(ea){
var fa=y[ea],
ga=fa.chevron,
ha=fa.sublist_container;

i.inform(w,ga);
if(da.inform('expand',ea)!==false){
l.removeClass(ga,"_9or");
l.addClass(ga,"_9os");
z(ha,true,function(){
da.inform('expanded',ea);});}},




hideSection:function(ea,fa,ga){
var ha=y[ea],
ia=ha.chevron,
ja=ha.sublist_container;

if(ga===ia)
return;

if(da.inform('collapse',ea)!==false){
l.addClass(ia,"_9or");
l.removeClass(ia,"_9os");
z(ja,false,function(){
da.inform('collapsed',ea);});}},




toggleSection:function(ea){
var fa=y[ea].chevron;



r.getInstance(fa).hide();
if(l.hasClass(fa,"_9or")){
da.showSection(ea);


new k('/ajax/privacy/privacy_lite/log_section_expand').
setData({section:ea}).
send();}else 

da.hideSection(ea);},



registerSection:function(ea,fa){
y[ea]=fa;

i.subscribe
(w,
da.hideSection.curry(ea));


g.listen
(fa.section_block,
'click',
da.toggleSection.curry(ea));},



registerInlineHelpOnAudienceChange:function(ea,fa,ga){
p.subscribe('select',function(ha,ia){
if(ia.selector!=ea)
return;


l.addClass(fa,"_2va0");

if(ga)

new k('/ajax/privacy/privacy_lite/kill_intro').send();});},




registerInlineHelpXOutOnClick:function(ea,fa){

g.listen
(ea,
'click',
l.addClass.curry
(fa,
"_9p0"));},




registerBlockUnhideOnFocus:function(ea,fa){
g.listen
(ea,
'focus',
l.show.curry(fa));},



registerMessageFilterSettingOnClick:function(ea,fa){
var ga=m.find(ea,"._fv0");

g.listen
(ea,
'click',
function(){
if(ga.checked)
new k('/ajax/mercury/change_filtering_type.php').
setData
({filtering_type:fa,
source:'privacy_lite'}).

send();});}},




j);

e.exports=da;});

/** js/privacy/modules/lite/PrivacyLiteFlyoutHelp.js */
__d("PrivacyLiteFlyoutHelp",["Event","Arbiter","ContextualHelpSearchController","CSS","DOM","Parent","copyProperties","cx"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('Arbiter'),
i=b('ContextualHelpSearchController'),
j=b('CSS'),
k=b('DOM'),
l=b('Parent'),

m=b('copyProperties'),
n=b('cx'),

o,
p;

function q
(r,
s,
t,
u,
v){


this._width=315;

p=k.find(s,'input');

var w=k.create('div');

this.init(r,p,w,t,u);

o=l.byClass(s,"_8-a");
g.listen(v,'click',this._hideSearch.bind(this));

h.subscribe
('PrivacyLiteFlyout/expandingSection',
this._hideSearch.bind(this));}



q.registerShow=function(r){
g.listen(r,'click',function(){
j.addClass(o,"_aw6");
p.focus();});};



m
(q.prototype,
new i(),

{source:'privacy_shortcuts',

_hideSearch:function(){
this.clearResults();
j.removeClass(o,"_aw6");},



show:function(r){
if(r===this.topics_area){
j.removeClass(o,"_aw7");
return;}else
if(r===this.loader){
j.addClass(o,"_aw7");
j.hide(this.results_area);}else 

j.hide(this.loader);

j.show(r);}});



e.exports=q;});

/** js/ui/layer/behaviors/LayerSlowlyFadeOnShow.js */
__d("LayerSlowlyFadeOnShow",["Class","LayerFadeOnShow","emptyFunction"],function(a,b,c,d,e,f){



var g=b('Class'),
h=b('LayerFadeOnShow'),

i=b('emptyFunction');

function j(k){
this.parent.construct(this,k);}


g.extend(j,h);

j.prototype._getDuration=i.thatReturns(500);

e.exports=j;});

/** js/privacy/modules/lite/PrivacyLiteNUXController.js */
__d("PrivacyLiteNUXController",["AsyncRequest","CSS","Event","LayerSlowlyFadeOnShow","Locale","ModalMask","PageTransitions","Parent","PrivacyLiteFlyout","Toggler","$","copyProperties","cx"],function(a,b,c,d,e,f){



var g=b('AsyncRequest'),
h=b('CSS'),
i=b('Event'),
j=b('LayerSlowlyFadeOnShow'),
k=b('Locale'),
l=b('ModalMask'),
m=b('PageTransitions'),
n=b('Parent'),
o=b('PrivacyLiteFlyout'),
p=b('Toggler'),

q=b('$'),
r=b('copyProperties'),
s=b('cx'),

t=
"_3oye",
u="_1luv",

v=[],

w=

{bootload:function(){


},

init:function(y){
if(!w.initialized)
r(this,
{dialog:y.dialog,
sectionID:y.sectionID,
subsectionID:y.subsectionID,
initialized:true,
tourStarted:false});






if(y.showOnExpand){
w._attachFlyoutListener();}else 

w._detachFlyoutListener();},






startTourFromAnywhere:function(){
w._startTour(false);},





startTourFromMegahone:function(){
w._startTour(true);},


_startTour:function(y){
if(w.tourStarted)
return;

w.tourStarted=true;


w._detachFlyoutListener();


new g('/ajax/privacy/privacy_lite/log_nux_imp').
setData({from_megaphone:y}).
send();

l.show();

h.conditionClass
(w.dialog.getRoot(),
t,
y);



if(!y)
w._maskListener=i.listen
(q('modalMaskOverlay'),
'click',
w._cleanup);




p.setSticky(true);


setTimeout(w._showFlyout);


m.registerHandler(function(){
w._cleanup();


o.setFlyoutVisible(false);},
10);},


_showFlyout:function(){
o.loadBody(true);
o.setFlyoutVisible(true);

w._initDialog();

x('load',w._showTour);},


_showTour:function(){
o.showSection(w.sectionID);

x('expanded',function(y,z){
if(z===w.sectionID)
w.dialog.
setContext(q(w.subsectionID)).
setOffsetY(20).
show();});



x(['collapse','hide'],w._cleanup);},


_initDialog:function(){
var y=w.dialog.getRoot(),
z=w.dialog.getContent();

h.addClass(y,"_1luy");
h.conditionClass(y,"_3qz8",k.isRTL());
h.addClass(z,"_1luz");

w.dialog.enableBehavior(j);


i.listen(y,'click',function(event){
if(n.byClass(event.getTarget(),u))
w._cleanup();});},




_attachFlyoutListener:function(){
if(!w.flyoutSubscription)
if(o.isFlyoutVisible()){
w.startTourFromAnywhere();}else 

w.flyoutSubscription=
o.subscribe
('show',
w.startTourFromAnywhere);},





_detachFlyoutListener:function(){
if(w.flyoutSubscription){
w.flyoutSubscription.unsubscribe();
w.flyoutSubscription=null;}},



_cleanup:function(){
if(!w.tourStarted)
return;

w.tourStarted=false;
p.setSticky(false);
l.hide();
w.dialog.hide();
while(v.length)
v.pop().unsubscribe();

if(w._maskListener){
w._maskListener.remove();
w._maskListener=null;}}};









function x(y,z){
v.push(o.subscribe(y,z));}


e.exports=w;});

/** js/privacy/modules/viewas/ViewasChromeBar.js */
__d("ViewasChromeBar",["Event","Arbiter","AsyncRequest","CSS","DOM","Focus","ModalMask","PageTransitions","Parent","cx","csx"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('Arbiter'),
i=b('AsyncRequest'),
j=b('CSS'),
k=b('DOM'),
l=b('Focus'),
m=b('ModalMask'),
n=b('PageTransitions'),
o=b('Parent'),

p=b('cx'),
q=b('csx'),

r='ViewasChromeBar/initialized',

s=null,
t=false;

function u(x){
h.subscribe(r,x);}


function v(x){
j.addClass(x,"_7g7");
var y=k.find(x,"._7g0");
l.set(k.find(y,'.textInput'));}


var w=
{initChromeBar:function(x){
if(t)
return;


s=x;
t=true;

h.inform(r,null,h.BEHAVIOR_STATE);},


update:function(x,y){
u(function(){
k.setContent(s,x);
if(y)
new i('/ajax/privacy/glasgow/viewas_bar_flyout_open').send();});},




registerSpecificModeOnClick:function(x){
g.listen
(x,
'click',
v.curry
(o.byClass(x,"_7f-")));},




registerFlyoutModalMask:function(){
m.show();



n.registerHandler(m.hide,10);}};



e.exports=w;});

/** js/search/sponsored/TypeaheadSearchSponsoredUtils.js */
__d("TypeaheadSearchSponsoredUtils",[],function(a,b,c,d,e,f){






var g=












{prepareAndSortAds:function(h,i,j){
if(!i)
return [];


var k=[],
l=h.length,
m={};
for(var n=0;n<l;n++){
var o=h[n];
m[o.uid]=true;
if(o.s_categories)
o.s_categories.forEach(function(s){
m[s]=true;});}



for(var p in m)
if(i[p])

for(var q in i[p]){
var r=i[p][q];
if(j&&j.hasOwnProperty(r.uid))
continue;

k.push(r);}



k.sort(function(s,t){
return t.s_value-s.s_value;});

return k;},


isSelfPromoted:function(h){
return h.uid==h.s_target;},


isCategoryTargeted:function(h){
return h.selected_target_id!=h.s_target;},











selectAds:function(h,i,j,k){
var l=Math.min(k.maxNumberAds,
k.maxNumberRemovedResults+
k.maxNumberResultsAndAds-
h.length),
m=[],
n={},
o={},
p={},
q=-1,
r=false,
s=0,








t={};

for(var u=h.length-1;u>=0;--u){
var v=h[u];
t[v]=v;
if(i.hasOwnProperty(v))
i[v].forEach(function(z){
t[z]=v;});}




for(var u=0;u<j.length;u++){
if(m.length>=l){
for(var w=u;w<j.length;w++)
j[w].setDebugString&&j[w].setDebugString
('filtered: '+l+' ads already selected');

break;}




while(s+h.length>=
k.maxNumberResultsAndAds)
q=h.pop();

if(o.hasOwnProperty(q))
r=true;


var x=j[u];


if(r&&
!g.isSelfPromoted(x)){
x.setDebugString&&x.setDebugString
('filtered: last organic '+q+' is targeted');
continue;}


var y=t[x.s_target]||x.s_target;


x.selected_target_id=y;



if(!g.isSelfPromoted(x)&&
h.indexOf(String(x.uid))!=-1){
x.setDebugString&&x.setDebugString
('filtered: organic '+x.uid+
' targets another organic '+y);
continue;}



if(n.hasOwnProperty(x.s_account)){
x.setDebugString&&x.setDebugString
('filtered: ad account '+x.s_account+' already selected');
continue;}



if(p.hasOwnProperty(x.uid)){
x.setDebugString&&x.setDebugString
('filtered: ad promoted id '+x.uid+' already selected');
continue;}



if(h.indexOf(String(y))==-1)
if(!g.isSelfPromoted(x)||
y!=q){
x.setDebugString&&x.setDebugString
('filtered: targeted organic '+y+' will go away '+
'promoted id '+x.uid+' last organic '+q);
continue;}




x.setDebugString&&x.setDebugString('selected');
m.push(x);
n[x.s_account]=true;
o[y]=true;
p[x.uid]=true;
if(!g.isSelfPromoted(x))
++s;}


return m;},


hasTopResult:function(h,i,j){
if(h==null)
return false;

if(h.type=='user')
return false;

if(h.type=='grammar')
return false;

if(h.score>j.v0)
return true;

if(h.s_value>j.v3)
return true;

if(h.s_value>i.s_value)
return true;


var k=
g.isCategoryTargeted(i)?j.v4:
(h.bootstrapped?j.v1:j.v2);
if(k<i.s_value)
return false;

return true;},


setOrganicECPM:function(h,i){
if(h==null)
return;

for(var j=0;j<i.length;j++)
if(h.hasOwnProperty(i[j].uid))
i[j].s_value=h[i[j].uid];


return;},


buildResultIndices:function(h){

var i={},
j=h.length;
for(var k=0;k<j;k++)
i[h[k].uid]=k;

return i;},






getTopAdPosition:function(h,i,j){
if(h.length<1)
return null;

if(i.length<1)
return null;

if((h[0].type=='user')||(h[0].type=='grammar')){
for(var k=1;k<h.length;++k)
if(h[k].type!=h[0].type)

return k;



return h.length;}

if(g.hasTopResult
(h[0],i[0],j))

return 1;


return 0;}};



e.exports=g;});

/** js/search/sponsored/TypeaheadSearchSponsored.js */
__d("TypeaheadSearchSponsored",["Event","Arbiter","CSS","DOM","URI","copyProperties","TypeaheadSearchSponsoredUtils","tx"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('Arbiter'),
i=b('CSS'),
j=b('DOM'),
k=b('URI'),

l=b('copyProperties'),
m=b('TypeaheadSearchSponsoredUtils'),
n=b('tx');

function o(p){
this._typeahead=p;}


o.auctionOptions={};

o.query=null;

o.getOriginalOrganics=function(p){
return p.map(function(q){

return {uid:q.uid,
text:q.text,
type:o.getRealType(q),
source:q.bootstrapped?1:0,
index:q.index,
s_value:q.s_value||0,
s_categories:q.s_categories||[],
score:q.score};});};




o.setTopResult=function(p){
p[0].renderTypeOverride=true;
p[0].orig_render_type=p[0].render_type;
p[0].render_type='tophit';};








o.runAuction=
function(p,q,r,s){
if(p.length===0)
return p;

p=o.initResults(p);

var t;
if(!q){
t=o.bucketResults(p);
return t.results;}


var u=m.prepareAndSortAds(p,q,r),

v={},
w=p.map(function(ca){
if(ca.s_categories)
v[ca.uid]=ca.s_categories;

return String(ca.uid);}),

x=m.selectAds
(w,v,u,s);
if(x.length===0){
t=o.bucketResults(p);
return t.results;}


if(m.hasTopResult(p[0],x[0],s))
o.setTopResult(p);


var y=0;
for(var z=0;z<x.length;++z)
if(!m.isSelfPromoted(x[z]))
y++;


p.splice(s.maxNumberResultsAndAds-y,p.length);
var aa=o.bucketResults(p),

ba=o.rerankAds
(aa.results,x,aa.buckets,s);

return ba;};








o.bucketResults=function(p){
var q,r,s,t,

u=[],
v={};
r=p.length;
for(q=0;q<r;q++){
s=p[q];
t=s.render_type||s.type;
if(!v.hasOwnProperty(t)){
v[t]=u.length;
u.push([]);}

u[v[t]].push(s);}



var w=[],
x={};
r=u.length;
for(q=0;q<r;++q){
s=u[q][0];
t=s.render_type||s.type;
x[t]=w.length;
w=w.concat(u[q]);}

return {results:w,buckets:x};};















o.finalizeAd=function(p,q,r){
var s="Sponsored";

p.rankType=p.rankType||p.render_type||p.type;
if(m.isSelfPromoted(p)){
q.s_token=p.s_token;
q.message=p.s_message;
if(r.rerankingStrategy===0)
q.subtextOverride=q.subtext?
q.subtext+' \xB7 '+s:s;


if(p.path){
q.pathOverride=true;
q.orig_path=q.path;
q.path=p.path;}

q.is_self=true;}else{

p.message=p.s_message;
p.subtextOverride=null;
if(r.rerankingStrategy===0)
p.subtextOverride=p.subtext?
p.subtext+' \xB7 '+s:s;

if(r.debug){
if(!p.subtextOverride&&p.subtext)
p.subtextOverride=p.subtext;

if(p.subtextOverride){
p.subtextOverride+=' \xB7 (Debug: '+q.text+')';}else 

p.subtextOverride='(Debug: '+q.text+')';}




p.type=q.type;
p.render_type=q.render_type;
p.is_self=false;}};









o.promoteSelfPromotedResultToTop=
function(p,q,r,s){
var t=p[q];
if(q<r){
var u="Sponsored";
t.subtextOverride=t.subtext?
t.subtext+' \xB7 '+u:u;
return;}

if(q>r)
p.splice(r,0,p.splice(q,1)[0]);

t=p[r];

t.renderTypeOverride=true;
t.orig_render_type=t.render_type;
t.render_type='ownsection';};






o.insertAdToTop=function(p,
q,
r,
s){
p.splice(r,0,q);
q.render_type='ownsection';};





o.rerankMethod5=function(p,q,r){
if(r.rerankingStrategy!=5)
return;


var s=m.getTopAdPosition(p,q,r),
t=m.buildResultIndices(p);
for(var u=q.length-1;u>=0;u--){
var v=q[u],
w=t[v.selected_target_id],
x=p[w];
o.finalizeAd(v,x,r);

if(m.isSelfPromoted(v)){
o.promoteSelfPromotedResultToTop
(p,w,s,r);}else 

o.insertAdToTop(p,v,s,r);

t=m.buildResultIndices(p);}};






o.rerankAds=function(p,
q,
r,
s){
switch(s.rerankingStrategy){
case 5:
o.rerankMethod5(p,q,s);
break;




default:break;
}

return p.slice(0,s.maxNumberResultsAndAds);};






o.initResults=function(p){
var q=p.length;
for(var r=0;r<q;r++){
var s=p[r];
s.is_self=null;
s.s_token=null;
s.message=null;
s.subtextOverride=null;

if(s.pathOverride){
s.path=s.orig_path;
s.pathOverride=false;}


if(s.renderTypeOverride){
s.render_type=s.orig_render_type;
s.renderTypeOverride=false;}


s.rankType=s.rankType||s.render_type||s.type;}

return p;};



o.setAuctionOptions=function(p){
l(o.auctionOptions,p);};


o.getRealType=function(p){
if(p.renderTypeOverride)
return p.orig_render_type||p.type;

return p.render_type||p.type;};










o.hideAdResult=function(p,q){
h.inform('TypeaheadSearchSponsored/hideAdResult',
{uid:p,reason_dialog:q});};



o.undoHideAdResult=function(p){
h.inform('TypeaheadSearchSponsored/undoHideAdResult',{uid:p});};


o.Ad=function(){};

l(o.prototype,

{_dataSubscriptions:null,
_viewSubscriptions:null,
_globalSubscriptions:null,
_data:null,
_view:null,
_sponsoredEntries:null,
_hiddenSponsoredEntities:null,
_hideReasonDialog:null,
_sBootstrapID:null,
_organicECPM:null,

enable:function(){
this._data=this._typeahead.getData();
this._dataSubscriptions=
[this._data.subscribe('beginFetchHandler',function(p,q){
var r=q.response.getPayload();
if(r.s_entries){
this._sponsoredEntries=this._sponsoredEntries||{};
var s=r.s_entries.length;
for(var t=0;t<s;t++){
var u=new o.Ad();
l(u,r.s_entries[t]);
var v=u.s_target;
if(!this._sponsoredEntries[v])
this._sponsoredEntries[v]={};

this._sponsoredEntries[v][u.uid]=u;}

if(r.s_bootstrap_id)


this._sBootstrapID=r.s_bootstrap_id;

if(r.organic_s_value)
this._organicECPM=l
(this._organicECPM,r.organic_s_value);}}.


bind(this))];

if(o.auctionOptions.bootstrap)
this._dataSubscriptions.push
(this._data.subscribe('onload',function(p,q){
var r=l
(this.bootstrapData,
{no_cache:1,options:['sponsored']});

this.fetch(this.bootstrapEndpoint,r,{type:'sponsored'});}.
bind(this._data)));



this._view=this._typeahead.getView();
this._viewSubscriptions=
[this._view.subscribe('finalResultsReordering',function(p,q){
o.query=q.value;
m.setOrganicECPM(this._organicECPM,q.results);

var r=o.getOriginalOrganics
(q.results);



o.setAuctionOptions({maxNumberResultsAndAds:
Math.max(q.results.length,
(this._data&&this._data._maxResults)||
o.auctionOptions.maxNumberResultsAndAds)});


var s=o.runAuction
(q.results,
this._sponsoredEntries,
this._hiddenSponsoredEntities,
o.auctionOptions),



t=m.prepareAndSortAds
(q.results,this._sponsoredEntries,this._hiddenSponsoredEntities),
u=t.map(function(y){
return y.s_token;}),

v=[];
for(var w=0;w<s.length;w++){
var x=s[w];
if(x.s_token)
v.push
({position:w,
is_self:x.is_self});}




this._view.inform
('recordAfterReorder',

{organic:r,
tokens:u,
position_data:v,

s_bootstrap_id:this._sBootstrapID,
options:o.auctionOptions,
variant:o.auctionOptions.rerankingStrategy});



q.results=s;


this._data.inform
('recordAuctionState',

{sorted_ads:t,
organic:r,
auctionOptions:o.auctionOptions,
event_data:q});}.

bind(this)),


this._view.subscribe('highlight',function(p,q){
if(this._view.content)
j.scry(this._view.content,'a.report').forEach(i.hide);

if(!q.element||!q.selected||!q.selected.s_token)
return;

var r=j.scry(q.element,'a.report');
if(r.length){

i.show(r[0]);}else 

j.appendContent(q.element,
this._createHideAdLink(q.selected));}.

bind(this))];


this._globalSubscriptions=
[h.subscribe('TypeaheadSearchSponsored/hideAdResult',
function(p,q){
this._hiddenSponsoredEntities=this._hiddenSponsoredEntities||{};
this._hiddenSponsoredEntities[q.uid]=true;
this._hideReasonDialog=q.reason_dialog;
this._forceRefreshResults();}.
bind(this)),

h.subscribe('TypeaheadSearchSponsored/undoHideAdResult',
function(p,q){
if(this._hiddenSponsoredEntities)
delete this._hiddenSponsoredEntities[q.uid];

if(this._hideReasonDialog){
this._hideReasonDialog.hide();
this._hideReasonDialog=null;}

this._forceRefreshResults();}.
bind(this))];},



disable:function(){
this._dataSubscriptions.forEach(this._data.unsubscribe.bind(this._data));
this._dataSubscriptions=null;

this._viewSubscriptions.forEach(this._view.unsubscribe.bind(this._view));
this._viewSubscriptions=null;

this._globalSubscriptions.forEach(h.unsubscribe.bind(h));
this._globalSubscriptions=null;

this._data=null;
this._view=null;
this._sponsoredEntries=null;},




_forceRefreshResults:function(){
if(this._data&&this._data.value)
this._data.respond(this._data.value,
this._data.buildUids(this._data.value));},




_createHideAdLink:function(p){




var q=new k('/ajax/emu/end.php').
addQueryData
({eid:p.s_token,
f:0,
ui:'typeahead_'+p.s_token.replace('.','_'),
en:'fad_hide',
ed:'true',
a:1}).
toString(),
r=
{className:'report',
rel:'dialog-post',
href:'#',
ajaxify:q,
title:"Hide the ad"},

s=j.create('a',r);
g.listen(s,'mouseover',function(event){

this._view.index=-1;
this._view.highlight(-1,false);


event.kill();}.
bind(this));
return s;}});



e.exports=o;});

/** js/search/sponsored/LegacySearchSponsoredTypeaheadBehavior.js */
__d("legacy:SearchSponsoredTypeaheadBehavior",["TypeaheadSearchSponsored"],function(a,b,c,d){



var e=b('TypeaheadSearchSponsored');

if(!a.TypeaheadBehaviors)a.TypeaheadBehaviors={};
a.TypeaheadBehaviors.searchSponsored=function(f){
f.enableBehavior(e);};},


3);

/** js/search/sponsored/LegacyTypeaheadSearchSponsored.js */
__d("legacy:TypeaheadSearchSponsored",["TypeaheadSearchSponsored"],function(a,b,c,d){



a.TypeaheadSearchSponsored=b('TypeaheadSearchSponsored');},

3);

/** js/search/typeahead/SearchDataSource.js */
__d("SearchDataSource",["Event","Arbiter","AsyncResponse","Class","DataSource","copyProperties","createArrayFrom"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('Arbiter'),
i=b('AsyncResponse'),
j=b('Class'),
k=b('DataSource'),

l=b('copyProperties'),
m=b('createArrayFrom');

function n(o){
this._token=o.token||'';
this._lazyonload=o.lazyonload===false?false:true;
this._extraTypes=o.extraTypes;
this._buckets=o.buckets;
this._noMultiFetch=o.noMultiFetch||false;
var p=o.maxResults||8;
this.parent.construct(this,o);
this._numResults={min:3,max:p};
this._minWebSugg=o.minWebSugg||1;

this._genTime=o.genTime;}


j.extend(n,k);

l(n.prototype,

{init:function(){
this.parent.init();

this._leanPayload=null;
this._bootstrapRequestsPending=0;
this._criticalOnly=true;
this._updateMaxResults();
g.listen(window,'resize',this._updateMaxResults.bind(this));},


dirty:function(){
this.parent.dirty();
this._fetchOnUseRequests=[];},







asyncErrorHandler:function(o){

if(window.Dialog&&window.Dialog.getCurrent()==null&&
o.getError()==1400003)
i.verboseErrorHandler(o);},







fetch:function(o,p,q){
q=q||{};
q.fetch_start=Date.now();
this.parent.fetch(o,p,q);},









fetchHandler:function(o,p){
var q=o.getPayload(),
r=l({fetch_end:Date.now()},p),

s=r.value?h.BEHAVIOR_EVENT:
h.BEHAVIOR_PERSISTENT;

this.inform('beginFetchHandler',{response:o});

if(p.type=='lean'){
this._leanPayload=q;
this._processLean();}else{

if(q.coeff2_ts)
r.coeff2_ts=q.coeff2_ts;


this.parent.fetchHandler(o,p);

if(p.bootstrap&&
!o.getRequest().getData().no_cache)
r.browserCacheHit=(q.timestamp<this._genTime);


if(p.bootstrap&&!q.no_data&&
this._bootstrapRequestsPending>0){


p.bootstrap=false;
--this._bootstrapRequestsPending;
!this._bootstrapRequestsPending&&this._bootstrapPostProcess();}


if(q.no_data||q.stale||q.token!==this._token){
var t=l({},o.getRequest().getData());



if(t.lazy){
delete t.lazy;
t.token=this._token;
this._fetchOnUse(t,p);}}}




this.inform('endpointStats',r,s);},


buildData:function(o){
var p=[],
q=[];

for(var r=0;r<o.length;r++){
var s=this.getEntry(o[r]);
if(s.type==='websuggestion'){
p.push(s);}else 

q.push(s);}



if(q.length>=this._maxResults)
return q.slice(0,this._maxResults);


return q.concat
(p.slice
(0,
Math.max
(this._maxResults-q.length,
this._minWebSugg)));},





shouldFetchMoreResults:function(o){
var p=0;
o.forEach(function(q){
if(q.type!=='websuggestion')
p++;}.

bind(this));
return p<this._maxResults;},







_bootstrapPostProcess:function(){
var o={time:Date.now()};
this.inform('bootstrapped',o,h.BEHAVIOR_PERSISTENT);
this._processLean();},






_processLean:function(){
if(this._leanPayload){
var o,
p=this._leanPayload.entries;
for(var q in p){
o=this.getEntry(q);
o&&(o.index=p[q]);}

this.setExclusions(this._leanPayload.blocked);
this._leanPayload=null;}},




















_updateMaxResults:function(){
var o=window.innerHeight||document.documentElement.clientHeight;
this.setMaxResults
(Math.max(this._numResults.min,
Math.min(this._numResults.max,
Math.ceil(2+((o-370)/56)))));},





_bootstrapFetch:function(o,p){
var q=l(p,this.bootstrapData);
if(this._criticalOnly&&this._lazyonload)
q.lazy=1;

this.fetch(this.bootstrapEndpoint,q,{bootstrap:true,type:o});
++this._bootstrapRequestsPending;},





_fetchOnUse:function(o,p){


for(var q in this.bootstrapData)
!o.hasOwnProperty(q)&&(o[q]=this.bootstrapData[q]);

if(this._criticalOnly){
this._fetchOnUseRequests.push({args:o,ctx:p});}else 

this.fetch(this.bootstrapEndpoint,o,p);},









_fetchLean:function(){
var o={no_cache:1};
o.options=m(o.options);
o.options.push('lean');

this._fetchOnUse(o,{type:'lean'});},





bootstrap:function(o){


if(!o){
this._criticalOnly=false;
this._flushFetchOnUseRequests();}


if(this._bootstrapped)return;

var p={filter:['event'],no_cache:1};
this._fetchOnUse(p,{type:'event'});

var q=['app','page','group','friendlist'];
q=q.concat(this._extraTypes||[]);

if(this._noMultiFetch){
q.push('user');
this._bootstrapFetch('user',{filter:q});}else{

this._bootstrapFetch('other',{filter:q});

if(this._buckets){
for(var r=0;r<this._buckets.length;++r){
var s={filter:['user'],buckets:this._buckets[r]};
this._bootstrapFetch('user',s);}}else 


this._bootstrapFetch('user',{filter:['user']});}


this._fetchLean();
this._bootstrapped=true;},


_flushFetchOnUseRequests:function(){
var o=this._fetchOnUseRequests.length;
for(var p=0;p<o;++p){
var q=this._fetchOnUseRequests[p];
this.fetch(this.bootstrapEndpoint,q.args,q.ctx);}

if(o>0)
this.inform('extra_bootstrap',{time:Date.now()},
h.BEHAVIOR_PERSISTENT);

this._fetchOnUseRequests=[];},


onLoad:function(o,p){
this.inform('onload',{time:Date.now()},h.BEHAVIOR_PERSISTENT);
if(o)
this.bootstrap.bind(this,p).defer();},







mergeUids:function(o,p,q,r){
var s=q[0]?this.getEntry(q[0]):null,
t=p[0]?this.getEntry(p[0]):null,

u=(s&&s.replace_results)?s:null;
u=(!u&&t&&t.replace_results)?
t:u;

var v=this.parent.mergeUids(o,p,q,r);

if(u){
this.inform('backend_topreplace',{});
return this.deduplicateByKey([u.uid].concat(v));}


return v;}});




e.exports=n;});

/** js/search/typeahead/LegacySearchDataSource.js */
__d("legacy:SearchDataSource",["SearchDataSource"],function(a,b,c,d){



a.SearchDataSource=b('SearchDataSource');},

3);

/** js/search/typeahead/SearchTypeaheadCore.js */
__d("SearchTypeaheadCore",["Event","function-extensions","Arbiter","Class","DOM","Input","Parent","TypeaheadCore","copyProperties"],function(a,b,c,d,e,f){



var g=b('Event');
b('function-extensions');

var h=b('Arbiter'),
i=b('Class'),
j=b('DOM'),
k=b('Input'),
l=b('Parent'),
m=b('TypeaheadCore'),

n=b('copyProperties');

function o(p){
this.parent.construct(this,p);}


i.extend(o,m);

n(o.prototype,
{init:function(p,q,r){
this.parent.init(p,q,r);

var s=l.byTag(r,'form'),
t=this.reset.bind(this);


h.subscribe('pre_page_transition',function(event,v){
var w=/^\/search/,
x=w.test(v.from.path),
y=w.test(v.to.path);
if(x&&!y)
t.defer();});



if(s){



var u=j.find(s,'input.search_sid_input');






g.listen(s,'submit',function(){


if(this.data&&this.data.queryData)
u.value=this.data.queryData.sid;

t.defer();}.
bind(this),g.Priority.URGENT);}},



select:function(){


this.reset();
this.element.focus();
(function(){this.element.blur();}).bind(this).defer();},


handleTab:function(event){
var p=this.view.getQuerySuggestion(this.value);
if(p){
k.setValue(this.element,p);
this.checkValue();
event.kill();}else 


this.parent.handleTab(event);}});





e.exports=o;});

/** js/search/typeahead/LegacySearchTypeaheadCore.js */
__d("legacy:SearchTypeaheadCore",["SearchTypeaheadCore"],function(a,b,c,d){



a.SearchTypeaheadCore=b('SearchTypeaheadCore');},

3);

/** js/search/typeahead/SearchTypeaheadView.js */
__d("SearchTypeaheadView",["Arbiter","ContextualTypeaheadView","Class","ContextualLayerUpdateOnScroll","copyProperties","DOM","goURI","MusicConstants","MusicEvents","tx","URI"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('ContextualTypeaheadView'),
i=b('Class'),
j=b('ContextualLayerUpdateOnScroll'),
k=b('copyProperties'),
l=b('DOM'),
m=b('goURI'),
n=b('MusicConstants'),
o=b('MusicEvents'),
p=b('tx'),
q=b('URI');

function r(s,t){
this.parent.construct(this,s,t);}


i.extend(r,h);

k(r.prototype,

{initializeLayer:function(){
this.parent.initializeLayer();

this.layer.setOffsetY(-1);
this.layer.enableBehavior(j);},


ignoreClick:function(event){
event.prevent();},


shouldShowSeeMore:true,





queryData:{init:'quick'},

render:function(s,t,u){
var v={results:t,value:s};



this.inform('finalResultsReordering',v);
return this.parent.render(s,v.results,u);},





buildBuckets:function(s,t){

var u=t.length;
this.setWebSuggLoggingParams(s,t);
t=this.parent.buildBuckets(s,t);
if(s&&this.shouldShowSeeMore)
t.push(this.buildSeeMore(s,u));

return t;},


buildSeeMore:function(s,t){
var u=t>0?
p._("See more results for {query}",{query:s}):
p._("See results for {query}",{query:s}),

v=t==1?
"Displaying top result":
p._("Displaying top {number} results",{number:t}),

w=
l.create('li',{className:'calltoaction'},
[l.create('a',{href:this.getSeeMoreEndpoint(s),rel:'ignore'},
[l.create('span',{className:'text'},
[l.create('span',{className:'seeMore'},
[u,
l.create('span',{className:'arrow'})]),

l.create('span',{className:'subtext'},[v])])])]);




w.setAttribute('aria-label',u);


return {uid:'search',
node:w,
search:true};},











searchPageQueryData:function(s){
return k({q:s},this.queryData||{});},


select:function(s){
var t=this.index,
u=this.results[t];
if(!u||u.type=='header')

return;


var v=this.items[t],
w=l.scry(v,'a')[0];

if(u.song){

if(w)
o.inform(n.MUSIC_BUTTON.ACTIVATE,w);



s&&this.inform('highlight',{index:t,selected:u});}else{

this.parent.select(s);

if(w&&w.href)
if(w.target=='_blank'){
window.open(w.href);}else 

m(w.href);}},





setSid:function(s){
this.queryData.tas=s;},


getSeeMoreEndpoint:function(s){
return q(this.seeMoreEndpoint).
addQueryData(this.searchPageQueryData(s)).
toString();},


show:function(){
if(!this.isVisible()){
g.inform('layer_shown',{type:'SearchTypeahead'});
this.parent.show();}},



hide:function(){
if(this.isVisible()){
g.inform('layer_hidden',{type:'SearchTypeahead'});
this.parent.hide();}},












getQuerySuggestion:function(s){
var t=this.results[this.index],
u=t&&t.type!='header'?
t.text.toLowerCase():'';
return u==s.toLowerCase()?'':u;},





setWebSuggLoggingParams:function(s,t){
var u=0,
v=0;

for(var w=0;w<t.length;w++)
if(t[w].type==='websuggestion'){
if(v===0)
v=w+1;

var x='FR'+(w-u)+'AS'+u,
y=w+1;
t[w].path+=
'&wssk='+x+
'&wssp='+y+
'&wspq='+encodeURIComponent(s);
t[w].path+='&wssrc='+t[w].websuggestion_source;
u++;}



var z=
'&wssc='+t.length+'-'+s.length+
'&wsbp='+u+'-'+v;
for(w=0;w<t.length;w++)
if(t[w].type==='websuggestion')
t[w].path+=z;}});






e.exports=r;});

/** js/search/typeahead/LegacySearchTypeaheadView.js */
__d("legacy:SearchTypeaheadView",["SearchTypeaheadView"],function(a,b,c,d){



a.SearchTypeaheadView=b('SearchTypeaheadView');},

3);

/** js/ui/xhp/typeahead/Typeahead.js */
__d("legacy:Typeahead",["Typeahead"],function(a,b,c,d){



a.Typeahead=b('Typeahead');},

3);

/** js/search/typeahead/SearchTypeaheadRecorder.js */
__d("SearchTypeaheadRecorder",["Event","AsyncRequest","Keys","$","clickRefAction","copyProperties","userAction"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('AsyncRequest'),
i=b('Keys'),

j=b('$'),
k=b('clickRefAction'),
l=b('copyProperties'),
m=b('userAction');








function n(o){
this.init(o);
this.initEvents();}


l(n.prototype,

{_endPoint:'/ajax/typeahead/record_metrics.php',

init:function(o){
this.core=o.getCore();
this.data=o.getData();
this.view=o.getView();
this.element=this.core.getElement();
this.initTime=Date.now();
this._onloadTime=0;
this.initStartTime=j('search_first_focus').value;


this.bootstrapStats={bootstrapped:0};
this._reset();},





_reset:function(){

this.stats={};


this.avgStats={};


this.appendStats={};


this._backspacing=false;



this._topreplace=false;

this._inflightRequests={};


var o=Math.random().toString();
this.data.setQueryData({sid:o});
this.view.setSid(o);
this.recordStat('sid',o);},


initEvents:function(){
this.core.subscribe('focus',function(event){
if(!this.stats.session_start_time)
this.recordStat('session_start_time',Date.now());}.

bind(this));

this.core.subscribe('blur',function(event){
var o=Date.now();

for(var p in this._inflightRequests){
var q=this._inflightRequests[p],
r=o-q;
this.recordAvgStat('search_endpoint_ms_from_js',r);}


this.recordStat('session_end_time',o);
this.submit();}.
bind(this));

this.view.subscribe('select',function(o,p){
this.recordSelectInfo(p);}.
bind(this));

this.view.subscribe('render',function(o,p){
this.recordRender(p);}.
bind(this));

this.view.subscribe('recordAfterReorder',function(o,p){
this._reorderInfo=p;}.
bind(this));

this.data.subscribe('activity',function(o,p){
this.recordStat('pending_request',p.activity);}.
bind(this));

this.data.subscribe('beforeQuery',function(o,p){
if(!p.value){
this.query='';
this.results=[];
return;}

if(!this.stats.first_query_time)
this.recordStat('first_query_time',Date.now());

this.query=p.value;
this.recordCountStat('num_queries');}.
bind(this));

this.data.subscribe('queryEndpoint',function(o,p){
this.recordCountStat('num_search_ajax_requests');
this.recordAvgStat('endpoint_query_length',p.value.length);

this._inflightRequests[p.value]=Date.now();}.
bind(this));

this.data.subscribe('onload',function(o,p){
this._onloadTime=p.time;}.
bind(this));

this.data.subscribe('bootstrapped',function(o,p){
this.bootstrapStats.endTime=p.time;
this.bootstrapStats.bootstrapped=1;}.
bind(this));

this.data.subscribe('endpointStats',function(o,p){
var q=p.fetch_end-p.fetch_start;
if(p.value){
this.recordAvgStat('search_endpoint_ms_from_js',q);}else 

this.bootstrapStats[p.type]=q;

if(p.coeff2_ts)
this.bootstrapStats.coeff2_ts=p.coeff2_ts;

if(typeof p.browserCacheHit!='undefined')
this.recordCountStat(p.browserCacheHit?'bootstrap_cachehits':
'bootstrap_cachemisses');


if(this._inflightRequests[p.value])
delete this._inflightRequests[p.value];}.

bind(this));

this.data.subscribe('query',function(o,p){
this.recordAvgStat('num_results_from_cache',p.results.length);}.
bind(this));

this.data.subscribe('backend_topreplace',function(o,p){
if(false===this._topreplace){
this.recordStat("backend_topreplace",1);
this._topreplace=true;}}.

bind(this));

g.listen(this.element,'keydown',function(event){
if(g.getKeyCode(event)==i.BACKSPACE){
if(!this._backspacing&&this.query){
this._backspacing=true;
this.recordAppendStat('before_backspace_queries',this.query);}}else 


this._backspacing=false;}.

bind(this));},


recordStat:function(o,p){
this.stats[o]=p;},


recordCountStat:function(o){
var p=this.stats[o];
this.stats[o]=p?p+1:1;},


recordAvgStat:function(o,p){
if(this.avgStats[o]){
this.avgStats[o][0]+=p;
++this.avgStats[o][1];}else 

this.avgStats[o]=[p,1];},



recordAppendStat:function(o,p){
if(!this.appendStats.hasOwnProperty(o))
this.appendStats[o]=[];

this.appendStats[o].push(p);},


recordRender:function(o){
this.results=o.filter(function(p){
return p.uid!='search'&&
p.type!='header';});

if(this.results.length>0&&!this.stats.first_result_time)
this.recordStat('first_result_time',Date.now());},



recordSelectInfo:function(o){
var p=o.selected,

q=o.index-p.groupIndex-1,

r={href:p.path},
s=p.dataGT?{gt:JSON.parse(p.dataGT)}:{};

k('click',r,null,null,s);
m('search').uai('click');

if(p.uid=='search'){
this.recordStat('selected_search',1);}else{

var t=
p.rankType||p.render_type||p.type,
u=
(t=='friend'?'user':t);

this.recordStat('selected_'+u,1);
this.recordStat('selected_position',q);
this.recordStat('selected_type',t);
this.recordStat('selected_name_length',p.text.length);
this.recordStat('selected_id',p.uid);
this.recordStat('selected_degree',p.bootstrapped?1:2);}

if(p.type==='websuggestion'){
this.recordStat
('selected_memcached_websuggestion',
p.fromMemcache);

this.recordStat
('selected_websuggestion_source',
p.websuggestion_source);}



this.recordStat('selected_with_mouse',o.clicked?1:0);},





_dataToSubmit:function(){
this.recordStat('candidate_results',this.buildResults());
this.recordStat('query',this.query);
this.recordStat('init_time',this.initTime);
if(this.initStartTime){

this.recordStat('init_start_time',this.initStartTime);
this.recordStat('onload_time',this._onloadTime);
this.initStartTime=0;}

this.recordStat('bootstrapped',this.bootstrapStats.bootstrapped);
if(this.bootstrapStats.endTime){
this.recordStat('bootstrapped_time',this.bootstrapStats.endTime);
this.recordStat('user_bootstrap_ms',this.bootstrapStats.user);
this.recordStat('other_bootstrap_ms',this.bootstrapStats.other);
this.bootstrapStats.endTime=0;}

this.recordStat('coeff2_ts',this.bootstrapStats.coeff2_ts);
this.recordStat('max_results',this.data._maxResults);

if(this._reorderInfo){
var o=this._reorderInfo;
o.organic.forEach(function(s){
delete s.text;});

this.recordStat('s_count',o.position_data.length);
this.recordStat('s_bootstrap_id',o.s_bootstrap_id);
this.recordStat('s_organic_results',JSON.stringify(o.organic));
this.recordStat('s_candidate_tokens',JSON.stringify(o.tokens));
this.recordStat('s_positions',JSON.stringify(o.position_data));
this.recordStat('s_options',JSON.stringify(o.options));
this.recordStat('s_variant',JSON.stringify(o.variant));}


var p=this.stats;
for(var q in this.avgStats){
var o=this.avgStats[q];
p[q]=o[0]/o[1];}


for(var r in this.appendStats)
p[r]=JSON.stringify(this.appendStats[r]);

return p;},





buildResults:function(){
var o=(this.results||[]).map(function(p,q){
var r=p.rankType||p.render_type||p.type,
s=p.bootstrapped?1:0,
t=p.s_token||'';


if(typeof p.groupIndex=='number')
return [p.groupIndex,p.indexInGroup,p.uid,
r,s,t];

return [0,q,p.uid,r,s,t];});

return JSON.stringify(o);},





submit:function(){
var o=this._dataToSubmit();
if(Object.keys(o).length>0)
new h().
setURI(this._endPoint).
setMethod('POST').
setData({stats:o}).
setOption('handleErrorAfterUnload',true).
setErrorHandler(function(p){




o.retry=true;
new h().
setURI(this._endPoint).
setMethod('POST').
setData({stats:o}).
setOption('asynchronous',false).
send();}.
bind(this)).
send();

this._reset();}});



e.exports=n;});

/** js/search/typeahead/behaviors/TypeaheadSearchRecorderBasic.js */
__d("TypeaheadSearchRecorderBasic",["SearchTypeaheadRecorder","copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('SearchTypeaheadRecorder'),

h=b('copyProperties'),
i=b('emptyFunction');

function j(k){
this._typeahead=k;}


h(j.prototype,

{enable:function(){
new g(this._typeahead);},


disable:i});



e.exports=j;});

/** js/search/typeahead/behaviors/LegacySearchRecorderBasicTypeaheadBehavior.js */
__d("legacy:SearchRecorderBasicTypeaheadBehavior",["TypeaheadSearchRecorderBasic"],function(a,b,c,d){



var e=b('TypeaheadSearchRecorderBasic');

if(!a.TypeaheadBehaviors)a.TypeaheadBehaviors={};
a.TypeaheadBehaviors.searchRecorderBasic=function(f){
f.enableBehavior(e);};},


3);

/** js/ui/xhp/typeahead/renderers/SearchTypeaheadRenderer.js */
__d("SearchTypeaheadRenderer",["DOM","Env","MusicButtonManager","TypeaheadUtil"],function(a,b,c,d,e,f){




var g=b('DOM'),
h=b('Env'),
i=b('MusicButtonManager'),
j=b('TypeaheadUtil');







function k(l,m){
var n=[];

if(l.photo){
n.push
(g.create('img',{className:'photo',alt:'',src:l.photo}));
if(l.song){
n.push(g.create('span',{className:'playButton'}));
n.push(g.create('span',{className:'playLoader'}));}}



if(l.text&&l.type=='websuggestion'&&l.photo){
n.push(g.create('span',{className:'shiftedtext'},[l.text]));}else
if(l.text){
var o=l.alias,
p=this.value,
q=l.text,
r=[q];

if(o&&
j.isQueryMatch(p,o)&&
!j.isQueryMatch(p,q))
r.push
(g.create('span',{className:'alias'},[' \xB7 '+o]));



n.push(g.create('span',{className:'text'},r));}


if(l.category){
var s=[l.category];
if(l.is_external)
s.push(g.create('span',{className:'arrow'}));

var t=l.message?'preCategory':'category';
n.push(g.create('span',{className:t},s));}


if(l.message)
n.push(g.create('span',{className:'category'},[l.message]));


var u=l.subtextOverride||l.subtext;
if(u)
n.push(g.create('span',{className:'subtext'},[u]));


var v=l.classNames||l.type||'',
w=l.is_external?'_blank':'',
x=!l.song&&l.path||'';

if(x){
if(!(/^https?\:\/\//).test(x))
x=h.www_base+x.substr(1);

x+=(x.indexOf('?')>0?'&':'?')+'ref=ts&fref=ts';}


var y=
g.create('a',{href:x,rel:'ignore',target:w},n);

if(l.song){
y.id='mb_'+(Math.random()*1e+06|0);
i.addButton.curry
(l.song.provider,
y.id,
l.song.url,
l.song.context,
l.song.media_type).defer();
y.onclick=this.ignoreClick;}


var z=g.create('li',{className:v},[y]);
if(l.text)
z.setAttribute('aria-label',l.text);

return z;}


k.className='search';

e.exports=k;});

/** js/ui/xhp/typeahead/renderers/SearchTypeaheadRendererLegacy.js */
__d("legacy:SearchTypeaheadRenderer",["SearchTypeaheadRenderer"],function(a,b,c,d){



if(!a.TypeaheadRenderers)a.TypeaheadRenderers={};
a.TypeaheadRenderers.search=b('SearchTypeaheadRenderer');},

3);

/** js/search/typeahead/SearchBootloader.js */













void(0);

/** js/search/typeahead/behaviors/TypeaheadSearchFilter.js */
__d("TypeaheadSearchFilter",["Arbiter","copyProperties"],function(a,b,c,d,e,f){



var g=b('Arbiter'),

h=b('copyProperties');

function i(j){
this._typeahead=j;}


h(i.prototype,

{_subscription:null,

enable:function(){
var j=this._typeahead;
this._subscriptions=
[g.subscribe
('search/typeahead/updateFilter',
function(k,l){
if(l.filter_type=='web')
j.getView().queryData.form='FBKBFR';

j.getView().queryData.type=l.filter_type;}),


g.subscribe
('page_transition',
function(k,l){
if(j.getView().queryData.form)
delete j.getView().queryData.form;

delete j.getView().queryData.type;},

g.SUBSCRIBE_NEW)];},




disable:function(){
this._subscriptions.forEach(function(j){
j.unsubscribe();});

this._subscriptions=null;}});




e.exports=i;});

/** js/search/typeahead/behaviors/LegacySearchFilterTypeaheadBehavior.js */
__d("legacy:SearchFilterTypeaheadBehavior",["TypeaheadSearchFilter"],function(a,b,c,d){



var e=b('TypeaheadSearchFilter');

if(!a.TypeaheadBehaviors)a.TypeaheadBehaviors={};
a.TypeaheadBehaviors.initFilters=function(f){
f.enableBehavior(e);};},


3);

/** js/search/typeahead/behaviors/TypeaheadDetectQueryLocale.js */
__d("TypeaheadDetectQueryLocale",["copyProperties"],function(a,b,c,d,e,f){



var g=b('copyProperties');








function h(i){
this._typeahead=i;
this._data=i.getData();
this._queryCache=
{'':this._data.queryCache,
ja_JP:{},
zh_TW:{}};}



g(h.prototype,

{enable:function(){
this._previousLocale='';

this._reset=this._typeahead.subscribe('reset',
this._swapQueryCache.bind(this,''));

this._beforeQuery=this._data.subscribe('beforeQuery',function(i,j){
var k=j.value;

if(k===''){
this._swapQueryCache('');
return;}


var l=null,
m=k.charCodeAt(k.length-1);
if(12352<=m&&m<=12543){



l='ja_JP';}else
if(12544<=m&&m<=12735)

l='zh_TW';


this._swapQueryCache(l);}.
bind(this));},


disable:function(){
this._swapQueryCache('');
this._data.unsubscribe(this._beforeQuery);
this._typeahead.ubsubscribe(this._reset);},


_swapQueryCache:function(i){
if(i===null||i===this._previousLocale)
return;

this._data.queryCache=this._queryCache[i];
this._data.setQueryData({query_locale:i});
this._previousLocale=i;}});




e.exports=h;});

/** js/search/typeahead/behaviors/TypeaheadExcludeBootstrapFromQueryCache.js */
__d("TypeaheadExcludeBootstrapFromQueryCache",["copyProperties"],function(a,b,c,d,e,f){



var g=b('copyProperties');




function h(i){
this._data=i.getData();}


g(h.prototype,

{enable:function(){
this._buildingQueryCache=false;

this._buildQueryCache=this._data.subscribe('buildQueryCache',function(){
this._buildingQueryCache=true;}.
bind(this));

this._mergeUids=this._data.subscribe('mergeUids',function(i,j){
if(this._buildingQueryCache)
j.local_uids.splice(0,j.local_uids.length);}.

bind(this));

this._fetchComplete=this._data.subscribe('fetchComplete',function(){
this._buildingQueryCache=false;}.
bind(this));},


disable:function(){
this._data.unsubscribe(this._buildQueryCache);
this._data.unsubscribe(this._mergeUids);
this._data.unsubscribe(this._fetchComplete);}});




e.exports=h;});

/** js/ui/xhp/typeahead/behaviors/TypeaheadRegulateMemorializedUsers.js */
__d("TypeaheadRegulateMemorializedUsers",["copyProperties","TypeaheadUtil"],function(a,b,c,d,e,f){



var g=b('copyProperties'),
h=b('TypeaheadUtil');







function i(j){
this._typeahead=j;}


g(i.prototype,
{_filterRegistry:null,

_filter:function(j,k){

if(j.type!=='user'||!j.memorialized)
return true;




var l=h.parse(j.text).tokens;
if(l.length===1&&
h.isExactMatch(k,j.text))
return true;




var m=this._typeahead.getData().getTextToIndex(j),
n=h.parse(k).tokens;
return (n.length>1&&
h.isQueryMatch(k,m));},


enable:function(){
this._filterRegistry=
this._typeahead.getData().addFilter(this._filter.bind(this));},


disable:function(){
this._filterRegistry.remove();
this._filterRegistry=null;}});




e.exports=i;});

/** js/ui/xhp/typeahead/behaviors/LegacyRegulateMemorializedUsersTypeaheadBehavior.js */
__d("legacy:RegulateMemorializedUsersTypeaheadBehavior",["TypeaheadRegulateMemorializedUsers"],function(a,b,c,d){



var e=
b('TypeaheadRegulateMemorializedUsers');

if(!a.TypeaheadBehaviors)a.TypeaheadBehaviors={};
a.TypeaheadBehaviors.regulateMemorializedUsers=function(f){
f.enableBehavior(e);};},


3);
