/*1358462605,173213487*/

if (self.CavalryLogger) { CavalryLogger.start_js(["nXc7\/"]); }

/** js/lib/event/SystemEvents.js */
__d("SystemEvents",["Arbiter","Env","ErrorUtils","UserAgent","copyProperties"],function(a,b,c,d,e,f){




var g=b('Arbiter'),
h=b('Env'),
i=b('ErrorUtils'),
j=b('UserAgent'),

k=b('copyProperties'),




































l=new g(),


m=[],n=1000;
setInterval(function(){
for(var w=0;w<m.length;w++)
m[w]();},

n,false);






function o(){
return (/c_user=(\d+)/.test(document.cookie)&&RegExp.$1)||0;}



var p=h.user,


q=navigator.onLine;


function r(){
if(!q){
q=true;
l.inform(l.ONLINE,q);}}


function s(){
if(q){
q=false;
l.inform(l.ONLINE,q);}}



if(j.ie()){
if(j.ie()>=8){



window.attachEvent('onload',function(){
document.body.ononline=r;
document.body.onoffline=s;});}else 



m.push(function(){
(navigator.onLine?r:s)();});}else


if(window.addEventListener)
if(!j.chrome()){
window.addEventListener('online',r,false);
window.addEventListener('offline',s,false);}




var t=p;
m.push(function(){
var w=o();
if(t!=w){
l.inform(l.USER,w);
t=w;}});




var u=Date.now();
function v(){
var w=Date.now(),
x=w-u,
y=x<0||x>10000;

u=w;


if(y)
l.inform(l.TIME_TRAVEL,x);


return y;}

m.push(v);


m.push(function(){
if(window.onerror!=i.onerror)









window.onerror=i.onerror;});



a.SystemEvents=e.exports=k(l,

{USER:'SystemEvents/USER',
ONLINE:'SystemEvents/ONLINE',
TIME_TRAVEL:'SystemEvents/TIME_TRAVEL',








isPageOwner:function(w){
return (w||o())==p;},






isOnline:function(){


return j.chrome()||q;},










checkTimeTravel:v});},


3);

/** js/channel2/ChannelSubdomain.js */
__d("ChannelSubdomain",["Cookie","JSLogger"],function(a,b,c,d,e,f){


var g=b('Cookie'),
h=b('JSLogger'),

i=h.create('channel'),


j=7,


k=null;












function l(o,p){
var q=null,


r=m(),s;



o--;

var t=Math.min(32,j*o);
t=Math.max(t,1);
var u=false;
for(var v=0;v<32;v++){
s=(v+p)%t;
if(!(r&(1<<s))){
u=true;
break;}}



if(u){
k=s;
q=k%j;


g.set('sub',r|(1<<k));}else{





k=-1;
q=null;
i.error('subdomain_overflow',{slot:k,max:o});}


return q;}





function m(){
var o=g.get('sub')||0;
o=parseInt(o,10);
return isNaN(o)?0:o;}


function n(){
if(k!==null&&k>=0){
var o=m()&~(1<<k);
if(o){
g.set('sub',o);}else 

g.clear('sub');}}




e.exports=
{allocate:l,
clear:n};});

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










































var g=b('ErrorUtils'),

h=
{_apis:{},

_dispatch:function(i){
var j;

try{i=JSON.parse(i);}catch(
k){
throw new Error('DocRPC unparsable dispatch: "'+i+'"');}


if(h._apis.hasOwnProperty(i.api)){
var l=h._apis[i.api];
if(l[i.method])
j=g.applyWithGuard(l[i.method],l,i.args);}




if(j===undefined)
j=null;


return JSON.stringify(j);},








publish:function(i,j){
h._apis[j]=i;},









proxy:function(i,j,k){





var l={};

k.forEach(function(m){
l[m]=function(){
var n=
{api:j,
method:m,
args:Array.prototype.slice.call(arguments)},


o;

try{if(i.closed)
throw new Error('DocRPC window closed');

o=i.DocRPC._dispatch(JSON.stringify(n));}catch(
p){
g.reportError(p);
return;}


if(typeof(o)=='string')

try{o=JSON.parse(o);}catch(
p){
throw new Error('DocRPC '+j+'.'+m+
' unparsable return: "'+o+'"');}


return o;};});



return l;}};





e.exports=a.DocRPC=h;});

/** js/channel2/ChannelTransport.js */
__d("ChannelTransport",["copyProperties","bind","AjaxRequest","URI","JSLogger","DocRPC","ChannelConstants"],function(a,b,c,d,e,f){



var g=b('copyProperties'),
h=b('bind'),
i=b('AjaxRequest'),
j=b('URI'),
k=b('JSLogger'),
l=b('DocRPC'),
m=b('ChannelConstants'),













n=k.create('channel');


function o(){
return (1048576*Math.random()|0).toString(36);}


function p(x,y){
var z=x.subdomain;

z=z===null?'':(z+'-');

var aa=new j(y).
setDomain(z+x.host+'.facebook.com').
setPort(x.port).
setSecure(j().isSecure());

return aa;}



function q(x){
var y=
{partition:x.partition,
cb:o()},

z=p(x,'/p').setQueryData(y);
n.log('start_p',{uri:z.toString()});

var aa=new i('GET',z);
if(i.supportsCORS())
aa.xhr.withCredentials=true;


var ba=function(ca){
n.log('finish_p',{xhr:ca.toJSON?ca.toJSON():ca});};

aa.timeout=x.P_TIMEOUT;
aa.onError=aa.onSuccess=ba;
aa.send();}



function r(x,y,z){
var aa=new Image(),
ba=0,

ca=function(fa){
aa.abort();
return fa?y():z();};


aa.onload=function(){
n.log('ping_ok',{duration:Date.now()-ba});
ca(true);};

aa.onerror=function(){
q(x);
ca(false);};


var da=setTimeout(aa.onerror,10000,false);


aa.abort=function(){
if(da){
clearTimeout(da);
da=null;}

aa.onload=aa.onerror=null;};



var ea=
{partition:x.partition,
cb:o()};

ba=Date.now();
aa.src=p(x,'/ping').setQueryData(ea);

return aa;}



function s(x,y,z,aa){
var ba=new Date(),
ca=(ba-x.userActive)/1000|0;
if(ca<0)
n.warn('idle_regression',
{idleTime:ca,
now:ba.getTime(),
userActive:x.userActive});



var da=
{channel:x.user_channel,
seq:x.seq,
partition:x.partition,
clientid:x.sessionID,
cb:o(),
idle:ca};

if(ca<60)
da.state='active';

if(x.streamingCapable){
da.mode='stream';
da.format='json';}

if(x.profile)
da.profile=x.profile;

var ea=p(x,'/pull').setQueryData(da),

fa=new i('GET',ea);
if(i.supportsCORS())
fa.xhr.withCredentials=true;

fa.timeout=x.streamingCapable?
x.STREAMING_TIMEOUT:x.LONGPOLL_TIMEOUT;
fa.onJSON=y;
fa.onSuccess=z;
fa.onError=function(){


var ga=(this.status==12002&&
this._time>=x.MIN_12002_TIMEOUT)||
(this.status==504&&this._time>=x.MIN_504_TIMEOUT),
ha=ga?z:aa;

return ha&&ha.apply(this,arguments);};

fa.send();
x.inStreaming=x.streamingCapable;

return fa;}






function t(x){
this.manager=x;
(this.init&&this.init());}









function u(x){

t.apply(this,arguments);}


g(u.prototype,
{logName:'CORS',




enterState:function(x,y){

if(this._request){

this._request.abort();
this._request=null;}


if(x=='init')


setTimeout
(h(this.manager,'exitState',
{status:m.OK,
stateId:y.stateId}),

3000,
false);




if(!/pull|ping/.test(x))
return;


var z=this.manager;

if(x=='ping'){
this._request=r(y,
h(z,'exitState',
{status:m.OK,
stateId:y.stateId}),

h(z,'exitState',
{status:m.ERROR,
stateId:y.stateId}));}else


if(x=='pull')
this._request=s(y,
h(z,'_processTransportData',y.stateId),
h(z,'exitState',
{status:m.OK,stateId:y.stateId}),
h(z,'exitState',
{status:m.ERROR,stateId:y.stateId}));}});









function v(x){
n.log('iframe_init_constructor');

t.apply(this,arguments);


this._iframe=document.createElement('iframe');
this._iframe.style.display='none';
document.body.appendChild(this._iframe);


l.publish(this,'outerTransport');}


g(v.prototype,
{logName:'iframe',






_initIframe:function(x){
n.log('iframe_init_start');


window.onchanneliframeready=function(){
n.log('iframe_resources');
return x.resources;};



window.onchanneliframeloaded=function(){
n.log('iframe_loaded');};


if(x){
this._iframeURI=p(x,x.path);
if(x.bustIframe){
var y=
{partition:x.partition,
cb:o()};

this._iframeURI.setQueryData(y);}}else 


this._iframeURI='about:blank';


this._iframeProxy=null;



try{this._iframe.contentWindow.location.replace(this._iframeURI);
n.log('iframe_uri_set');}catch(
z){


n.error('iframe_uri_set_error',z);
this.exitState
({status:m.ERROR,
stateId:x.stateId},
z+'');}},






enterState:function(x,y){
if(x=='init'){
this._initIframe(y);}else
if(/idle|ping|pull/.test(x)){

if(this._iframeProxy){
this._iframeProxy.enterState.apply(this._iframeProxy,arguments);}else
if(x!='idle')
this.exitState
({status:m.ERROR,
stateId:y.stateId},
'iframe not yet loaded');}else

if(x=='shutdown')
this._initIframe();},






_processTransportData:function(){
this.manager._processTransportData.apply(this.manager,arguments);},





exitState:function(x){

if(this.manager.state=='init'&&x.status==m.OK)

this._iframeProxy=l.proxy
(this._iframe.contentWindow,
'innerTransport',
['enterState'],
(this._iframeURI+'').replace(/iframe.*/,''));





if(/ping|pull/.test(this.manager.state)&&!this._iframeProxy)
return;


this.manager.exitState.apply(this.manager,arguments);}});







function w(){

this.init=this.init.bind(this);


t.apply(this,arguments);}


g(w.prototype,
{logName:'iframe(inner)',

init:function(){

l.publish(this,'innerTransport');







try{var y=l.proxy(window.parent,'outerTransport',
['_processTransportData','exitState'],
top.DocRPC.origin);

g(this,y);




this.exitState({status:m.OK,stateId:1e+06});}catch(
x){
n.error('iframe_inner_init_error',x);}},







enterState:function(x,y){

if(this._request){
this._request.abort();
this._request=null;}


if(x=='ping'){
this._request=r(y,
h(this,'exitState',
{status:m.OK,
stateId:y.stateId}),

h(this,'exitState',
{status:m.ERROR,
stateId:y.stateId}));}else


if(x=='pull')
this._request=s(y,
h(this,'_processTransportData',y.stateId),
h(this,'exitState',
{status:m.OK,stateId:y.stateId}),
h(this,'exitState',
{status:m.ERROR,stateId:y.stateId}));}});





e.exports=
{getURI:p,
Transport:t,
CORSTransport:u,
IframeTransport:v,
IframeInnerTransport:w};});

/** js/channel2/MovingStat.js */
__d("MovingStat",[],function(a,b,c,d,e,f){





































function g(h){
h=h||60000;
var i={t:new Date(),count:0,v:0},
j=i,k=0,l=0;


function m(){
var n=new Date()-h;
while(j&&j.next&&j.t<n){
k-=j.v;
l-=j.count;
j=j.next;}}



this.add=function(n){
k+=n;
l++;

var o=new Date();
if(o-i.t<1000){

i.v+=n;
i.count++;}else{

i.next={t:o,v:n,count:1};
i=i.next;
m();}};



this.tally=function(n){
n=n||1000;
m();

return {sum:k,
count:l,
timeAverage:k*n/h};};}




e.exports=g;});

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























var g,h={},i=


{_:'%',
A:'%2',
B:'000',
C:'%7d',
D:'%7b%22',
E:'%2c%22',
F:'%22%3a',
G:'%2c%22ut%22%3a1',
H:'%2c%22bls%22%3a',
I:'%2c%22n%22%3a%22%',
J:'%22%3a%7b%22i%22%3a0%7d',
K:'%2c%22pt%22%3a0%2c%22vis%22%3a',
L:'%2c%22ch%22%3a%7b%22h%22%3a%22',
M:'%7b%22v%22%3a2%2c%22time%22%3a1',
N:'.channel%22%2c%22sub%22%3a%5b',
O:'%2c%22sb%22%3a1%2c%22t%22%3a%5b',
P:'%2c%22ud%22%3a100%2c%22lc%22%3a0',
Q:'%5d%2c%22f%22%3anull%2c%22uct%22%3a',
R:'.channel%22%2c%22sub%22%3a%5b1%5d',
S:'%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a',
T:'%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a',
U:'%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a',
V:'%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a',
W:'%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a',
X:'%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1',
Y:'%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a',
Z:'%2c%22sb%22%3a1%2c%22t%22%3a%5b%5d%2c%22f%22%3anull%2c%22uct%22%3a0%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a'};


(function(){

var k=[];
for(var l in i){h[i[l]]=l;k.push(i[l]);}
k.reverse();
g=new RegExp(k.join("|"),'g');})
();

var j=
{encode:function(k){
return encodeURIComponent(k).
replace(/([_A-Z])|%../g,function(l,m){
return m?'%'+m.charCodeAt(0).toString(16):l;}).

toLowerCase().
replace(g,function(l){return h[l];});},

decode:function(k){
return decodeURIComponent(k.replace(/[_A-Z]/g,function(l){
return i[l];}));}};




e.exports=j;});

/** js/presence/PresenceUtil.js */
__d("PresenceUtil",["Cookie","Env","randomInt","tx"],function(a,b,c,d,e,f){



var g=b('Cookie'),
h=b('Env'),

i=b('randomInt'),
j=b('tx'),


k=i(0,4294967295)+1,

l=

{checkMaintenanceError:function(m){
if(m.getError()==1356007)
return true;

return false;},


getErrorDescription:function(m){
var n=m.getError(),
o=m.getErrorDescription();
if(!o)
o="An error occurred.";

if(n==1357001)
o="Your session has timed out. Please log in.";

return o;},






getSessionID:function(){
return k;},





hasUserCookie:function(){
return h.user===g.get('c_user');}};




e.exports=l;});

/** js/presence/PresenceCookieManager.js */
__d("PresenceCookieManager",["Cookie","Dcode","ErrorUtils","Env","JSLogger","PresenceUtil","URI","PresenceInitialData"],function(a,b,c,d,e,f){















var g=b('Cookie'),
h=b('Dcode'),
i=b('ErrorUtils'),
j=b('Env'),
k=b('JSLogger'),
l=b('PresenceUtil'),
m=b('URI'),

n=b('PresenceInitialData'),

o=n.cookieVersion,
p=n.dictEncode,
q='presence',

r={},
s=null,
t=null,
u=k.create('presence_cookie');

function v(){

try{var z=g.get(q);


if(s!==z){
s=z;
t=null;

if(z&&z.charAt(0)=='E')
z=h.decode(z.substring(1));


if(z)
t=JSON.parse(z);}



if(t&&
(!t.user||
t.user===j.user))
return t;}catch(

y){


u.warn('getcookie_error');}

return null;}


function w(){
return parseInt(new Date().getTime()/1000,10);}


var x=


{register:function(y,z){
r[y]=z;},




store:function(){

var y=v();

if(y&&y.v&&o<y.v)
return;



var z=
{v:o,
time:w(),
user:j.user};


for(var aa in r)
z[aa]=i.applyWithGuard
(r[aa],
r,
[y&&y[aa]],
function(ea){
ea.presence_subcookie=aa;});



var ba=JSON.stringify(z);

if(p)
ba='E'+h.encode(ba);



if(l.hasUserCookie()){
var ca=ba.length;
if(ca>1024)
u.warn('big_cookie',ca);




var da=m.getRequestURI(false).isSecure()&&!!g.get('csm');
g.set(q,ba,null,null,da);}},





clear:function(){
g.clear(q);},



getSubCookie:function(y){
var z=v();
if(!z)
return null;

return z[y];}};



e.exports=x;});

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








function g(h,i){
return setInterval(h,i,false);}


e.exports=g;});

/** js/presence/PresenceState.js */
__d("PresenceState",["Arbiter","ErrorUtils","JSLogger","PresenceCookieManager","copyProperties","debounceAcrossTransitions","setIntervalAcrossTransitions","PresenceInitialData"],function(a,b,c,d,e,f){










var g=b('Arbiter'),
h=b('ErrorUtils'),
i=b('JSLogger'),
j=b('PresenceCookieManager'),

k=b('copyProperties'),
l=b('debounceAcrossTransitions'),
m=b('setIntervalAcrossTransitions'),

n=b('PresenceInitialData'),

o=n.cookiePollInterval||2000,

p=[],
q=[],

r=null,
s=null,
t=0,
u=null,


v=0,


w=['sb2','t2','lm2','uct2','tr','tw','at','wml'],

x=i.create('presence_state');

function y(){
return j.getSubCookie('state');}


function z(){

t=Date.now();
j.store();


da(s);}


var aa=l(z,0);

function ba(ia){
if(typeof ia=='undefined'||isNaN(ia)||
ia==Number.POSITIVE_INFINITY||ia==Number.NEGATIVE_INFINITY)
ia=0;

return ia;}


function ca(ia){
var ja={};
if(ia){
w.forEach(function(ma){ja[ma]=ia[ma];});

if(t<ia.ut)

x.error('new_cookie',{cookie_time:ia.ut,
local_time:t});}




ja.ut=t;


for(var ka=0,la=p.length;ka<la;ka++)
h.applyWithGuard(p[ka],null,[ja]);


s=ja;
return s;}


function da(ia){

v++;
t=ba(ia.ut);


if(!r)
r=m(ga,o);


s=ia;
if(u===null)
u=ia;



for(var ja=0,ka=q.length;ja<ka;ja++)
h.applyWithGuard(q[ja],null,[ia]);


v--;}





function ea(ia){
if(ia&&ia.ut)
if(t<ia.ut){

return true;}else
if(ia.ut<t)

x.error('old_cookie',{cookie_time:ia.ut,
local_time:t});



return false;}







function fa(){
var ia=y();
if(ea(ia))
s=ia;


return s;}





function ga(){
var ia=y();
if(ea(ia))
da(ia);}






j.register
('state',
ca);


g.subscribe(i.DUMP_EVENT,function(ia,ja){
ja.presence_state=
{initial:k({},u),
state:k({},s),
update_time:t,
sync_paused:v,
poll_time:o};});



(function(){
var ia=fa();

if(ia){
da(ia);}else{



x.debug('no_cookie_initial');
da(ca());
return;}})

();

var ha=

{doSync:function(ia){

if(v)
return;


if(ia){



z();}else 



aa();},




registerStateStorer:function(ia){
p.push(ia);},

registerStateLoader:function(ia){
q.push(ia);},


get:function(){
return fa();},


getInitial:function(){
return u;},


verifyNumber:ba};


e.exports=ha;},

3);

/** js/channel2/ChannelManager.js */
__d("ChannelManager",["Event","function-extensions","AjaxRequest","Arbiter","AsyncRequest","ChannelConstants","ChannelSubdomain","ChannelTransport","Env","FBAjaxRequest","JSLogger","MovingStat","PresenceCookieManager","PresenceState","PresenceUtil","Run","SystemEvents","URI","UserActivity","copyProperties","createArrayFrom","ChannelInitialData"],function(a,b,c,d,e,f){



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

var h=b('AjaxRequest'),
i=b('Arbiter'),
j=b('AsyncRequest'),
k=b('ChannelConstants'),
l=b('ChannelSubdomain'),
m=b('ChannelTransport'),
n=b('Env'),
o=b('FBAjaxRequest'),
p=b('JSLogger'),
q=b('MovingStat'),
r=b('PresenceCookieManager'),
s=b('PresenceState'),
t=b('PresenceUtil'),
u=b('Run'),
v=b('SystemEvents'),
w=b('URI'),
x=b('UserActivity'),

y=b('copyProperties'),
z=b('createArrayFrom'),

aa=c('ChannelInitialData'),












ba,

ca=p.create('channel'),
da=null;

function ea(qa){
da=qa;}














var fa=
{idle:
{ok:'init!'},

init:
{ok:'pull!',
error:'reconnect',

sys_online:'init',
sys_timetravel:'init'},

pull:
{ok:'pull!',
error:'ping',
error_missing:'pull',
error_msg_type:'pull',



refresh_0:'reconnect',
refresh_110:'reconnect',
refresh_111:'pull',
refresh_112:'pull',
refresh_113:'pull',
refresh_117:'reconnect'},

ping:
{ok:'pull!',
error:'ping',
error_stale:'reconnect!'},

reconnect:
{ok:'init!',
error:'reconnect',
sys_online:'reconnect',
sys_timetravel:'reconnect'},

shutdown:

{},



_all:
{error_max:'shutdown!',
error_shutdown:'shutdown!',




sys_owner:'reconnect',
sys_nonowner:'idle!',
sys_online:'ping',
sys_offline:'idle!',
sys_timetravel:'ping'}},




ga=
{userActive:Date.now(),
sessionID:(Math.random()*2147483648|0).toString(16),


streamingCapable:false,


inStreaming:false,







LONGPOLL_TIMEOUT:60000,
STREAMING_TIMEOUT:60000,


P_TIMEOUT:30000,


IFRAME_LOAD_TIMEOUT:30000,


MIN_RETRY_INTERVAL:5000,
MAX_RETRY_INTERVAL:30000,


MIN_12002_TIMEOUT:9000,
MIN_504_TIMEOUT:20000,



STALL_THRESHOLD:180000,



JUMPSTART_THRESHOLD:90000,


MIN_INIT_PROBE_DELAY:3000,



INIT_PROBE_DELAY_RANDOMIZE_RANGE:12000,


PROBE_DELAY:60000,


PROBE_HEARTBEATS_INTERVAL_LOW:1000,
PROBE_HEARTBEATS_INTERVAL_HIGH:3000,


STREAMING_EXIT_STATE_ON_CONTINUE:false},



ha=1,


ia={},


ja=0;




function ka(qa){
return qa.toLowerCase().replace(/[^0-9a-z]+/g,'_');}






function la(){
return j.lastSuccessTime?
Math.round((Date.now()-j.lastSuccessTime)/1000):-1;}





function ma(){
var qa={};


if(ba.getConfig('host'))

qa[ba.getConfig('user_channel')]=
ba.getConfig('seq',0);


return qa;}





function na(){

var qa=Date.now(),
ra=Date.now(),
sa={total:0},
ta='idle',
ua=false;


v.subscribe
([v.USER,v.ONLINE,v.TIME_TRAVEL],
function(xa,ya){



pa(true);
ra=null;



ba.lastPullTime=Date.now();

var za;
switch(xa){
case v.USER:

za=v.isPageOwner()?k.SYS_OWNER:
k.SYS_NONOWNER;
break;

case v.ONLINE:

za=ya?k.SYS_ONLINE:
k.SYS_OFFLINE;
break;

case v.TIME_TRAVEL:

za=k.SYS_TIMETRAVEL;
break;}


ba.exitState({status:za,stateId:ha});});




var va=function(xa,ya){
var za=Date.now(),ab;

if(ya){

qa=za;
ab=ya.nextState||ya.state;}else 


ab=ta;



v.checkTimeTravel();

if(ra){

var bb=Math.round((za-ra)/1000);
if(bb>0){
sa[ta]=(sa[ta]||0)+bb;
sa.total+=bb;}}


ta=ab;
ra=za;

if(!xa){

sa.lastSuccessTime=la();
sa.online=v.isOnline();
ca.log('rollup',sa);}};



i.subscribe(k.ON_ENTER_STATE,va);


setInterval(va,60000,false);


i.subscribe(p.DUMP_EVENT,function(xa,ya){
ya.channelRollup=sa;});


var wa=function(){

if(ba.isShutdown()||ba.shouldIdle())
return;




v.checkTimeTravel();



var xa=Date.now()-(ba.lastPullTime||n.start);
if(!ua&&xa>ga.STALL_THRESHOLD){
var ya=la();
ca.error('stall',
{lastSuccessTime:ya,
rollupState:ta});

ua=true;}



var za=Date.now()-qa;
if(ba.state=='pull'&&
za>ga.JUMPSTART_THRESHOLD){
qa=null;
ca.warn('jumpstart',
{state:ba.state,dormant:za});
ba.enterState('init');}};



setInterval(wa,10000,false);}







function oa(){
var qa=Date.now(),



ra=1;

function sa(){
setTimeout(sa,ra*1000,false);
var xa=ba.state;



if(xa=='idle'&&ba.shouldIdle())
return;



ca.bump('conn_t',ra);
if(xa=='pull')

ca.bump('conn_t_pull',ra);}


sa();



var ta=[15,30,60,120,240],
ua=false,va=false;
function wa(xa){
setTimeout
(function(){
ca.rate('pullenter_'+xa,ua);
ca.rate('pullexit_'+xa,va);},

xa*1000,false);}


while(ta.length)
wa(ta.shift());



i.subscribe(k.ON_ENTER_STATE,function(xa,ya){
if(ya.state=='pull')
ua=true;

qa=Date.now();});



i.subscribe(k.ON_EXIT_STATE,function(xa,ya){
if(ya.state!='pull'||!qa)
return;



var za='other';
if(ya.status==k.OK){
va=true;
za='ok';}else
if(ya.xhr&&ya.xhr.errorType){

za=/ar:(\w+)/.test(ya.xhr.errorType)&&RegExp.$1;}else
if(/^sys_/.test(ya.status))

return;



var ab=(Date.now()-qa)/1000;

if(ab<0){


return;}else
if(ab>3600)


ab=3600;



ca.bump('conn_num');
ca.bump('conn_exit',ab);


ca.bump('conn_num_'+za);
ca.bump('conn_exit_'+za,ab);});}








function pa(qa){
if(qa){
ja=0;
ia={};}else 

ja++;}



ba=

{state:'idle',


nextState:null,


lastPullTime:Date.now(),


heartbeats:[],


setTestCallback:ea,




init:function(qa){

this.init=function(){};


if(typeof(x)!='undefined'){
x.subscribe
(function(){
ga.userActive=Date.now();}.
bind(this));}else 


ca.error('user_activity_undefined');



r.register('ch',ma);


var ra=this.getConfig('max_conn',2),
sa=Math.floor(Math.random()*32);
ga.subdomain=l.allocate(ra,sa);


if(typeof window.onpageshow!='undefined'){
g.listen(window,'pagehide',l.clear);}else 

u.onUnload(l.clear);



this._transportRate=new q(30000);


var ta=(h.supportsCORS()&&!ga.forceIframe)?
'CORSTransport':'IframeTransport';
this.transport=new m[ta](this);


if(qa)
this.enterState.apply(this,arguments);



i.subscribe(p.DUMP_EVENT,
function(event,va){
va.transportRate=this._transportRate.tally();
va.transportType=ta;
va.transportVersion=2;}.
bind(this));


na();

oa();

if(ba.getConfig('tryStreaming')&&
ba.getConfig('host')&&
h.supportsCORS()&&
!ga.forceIframe){


var ua=ga.MIN_INIT_PROBE_DELAY+
Math.random()*ga.INIT_PROBE_DELAY_RANDOMIZE_RANGE;
setTimeout(this._probeTest,ua,false);}},







configure:function(){
var qa=z(arguments);
ca.log('configure',qa);

qa.forEach(y.bind(null,ga));
i.inform(k.ON_CONFIG,this);},





getConfig:function(qa,ra){
return qa in ga?ga[qa]:ra;},





isShutdown:function(){
return this.state=='shutdown';},





shouldIdle:function(){
return !(v.isPageOwner()&&v.isOnline());},







_sendIframeError:function(qa){
var ra=new j().
setURI('/ajax/presence/reconnect.php').
setData({reason:qa,fb_dtsg:n.fb_dtsg}).
setOption('suppressErrorHandlerWarning',true).
setOption('retries',1).
setMethod('GET').
setReadOnly(true).
setAllowCrossPageTransition(true);
ra.specifiesWriteRequiredParams()&&ra.send();},





























_getDelay:function(){
var qa=Math.min(ga.MIN_RETRY_INTERVAL*Math.pow(2,
Math.max(0,ja-1)),ga.MAX_RETRY_INTERVAL);


return qa*(.75+Math.random()/2)|0;},
















enterState:function(){
if(this._inEnterState)
ca.warn('enterstate_recursion');


this._inEnterState=true;






try{this._enterState.apply(this,arguments);
this._inEnterState=false;}catch(
qa){
this._inEnterState=false;
throw qa;}},



_enterState:function(qa){
var ra=0,
sa=z(arguments);


if(this.isShutdown())
return;




if(qa!='idle!'&&this.shouldIdle())
return;



ha++;
ga.stateId=ha;


clearTimeout(this._deferredTransition);
this._deferredTransition=null;




this.transport.enterState('idle');
this.state='idle';
this.nextState=null;

if(/!$/.test(qa)){


var ta=this._transportRate.tally().timeAverage,
ua=ba.getConfig('MAX_CHANNEL_STATES_PER_SEC',1);
if(ta>=ua){
if(!this._throttled){

this._throttled=true;
ca.warn('throttled');}

ca.bump('throttle');
ra=1000/ua;}}else

if(!(/#$/.test(qa)))



ra=this._getDelay();



qa=qa.replace(/\W*$/,'');

if(!fa[qa])

throw new Error('invalid state:'+qa);



var va;


if(ra<=0){
va={state:qa};

this._transportRate.add(1);
this.state=qa;


var wa=this['_enter_'+this.state];
if(wa){
sa.shift();
wa.apply(this,sa);}



if(/init|idle|pull|ping/.test(this.state)){

if(ga.streamingCapable&&/pull/.test(this.state))
this.heartbeats=[];

this.transport.enterState(this.state,ga);
if(this.state=='ping'){
va.url=m.getURI(ga).toString();
va.port=ga.port||'undefined';}}}else{




this.state='idle';
this.nextState=qa;
va=
{state:this.state,
delay:ra,
nextState:qa};


sa[0]=qa+'#';
this._deferredTransition=(function(){
this._deferredTransition=null;
this.enterState.apply(this,sa);}).
bind(this).defer
(ra,
false);}



if(/pull/.test(qa)){
va.client_id=ga.sessionID;
va.streaming=ga.inStreaming;}



ca.log('enter_'+this.state,va);
i.inform(k.ON_ENTER_STATE,va);},









exitState:function(qa,ra){
var sa=qa.stateId,
ta=qa.status;








if(this.isShutdown()||sa<ha)
return;


var ua=z(arguments),va=this.state;
ua[0]=qa.status;


var wa={state:va,status:ta};
if(/pull/.test(va)){
wa.client_id=ga.sessionID;
wa.streaming=ga.inStreaming;}



if(/ping/.test(va)&&ta!=k.OK)
wa.url=m.getURI(ga).toString();


if(this.nextState)
wa.nextState=this.nextState;

if(ra&&ra.errorType){


wa.xhr=ra.toJSON?ra.toJSON():ra;


delete wa.xhr.json;}



if(ra&&ra.json){
if(ra.json.t)
wa.t=ra.json.t;

if(ra.json.reason)
wa.reason=ra.json.reason;

if(ra.json.seq)
wa.seq=ra.json.seq;}



ca.log('exit_'+va,wa);
i.inform(k.ON_EXIT_STATE,wa);


var xa=this['_exit_'+va];
if(xa)
ta=xa.apply(this,ua)||ta;



if(ta!=k.OK){
pa();
ia[va]=(ia[va]||0)+1;}







var ya=fa[this.nextState||va][ta]||
fa._all[ta],
za=ya&&ya.replace(/!*$/,'');
if(!za){






ca.error('terminal_transition',wa);
this._shutdownHint=k.HINT_INVALID_STATE;
ya='shutdown!';}



this._lastState=va;
this._lastStatus=ta;
this.enterState(ya);},







_processTransportData:function(qa,ra){
var sa=ra.json,ta=sa.t;


if('s' in sa){
sa.seq=sa.s;
delete sa.s;}



var ua=ga.seq;
if('seq' in sa){
ga.seq=sa.seq;
s.doSync();}



switch(ta){
case 'continue':



if(ga.inStreaming&&this.heartbeats.length<1){
ga.streamingCapable=false;
ca.log('switch_to_longpoll');
setTimeout(this._probeTest,ga.PROBE_DELAY,false);}


pa(true);

if(!ga.inStreaming||
ga.STREAMING_EXIT_STATE_ON_CONTINUE)
this.exitState({status:k.OK,stateId:qa});

break;

case 'refresh':
case 'refreshDelay':
this.exitState
({status:'refresh_'+(sa.reason||0),stateId:qa},
ra);

break;

case 'fullReload':



r.clear();

ca.log('invalid_history');
i.inform(k.ON_INVALID_HISTORY);
this.exitState
({status:k.ERROR_MISSING,stateId:qa},
ra);

break;

case 'msg':
var va,wa,xa,ya;
pa(true);

wa=sa.ms;
xa=ga.seq-wa.length;


for(va=0;va<wa.length;va++,xa++)
if(xa>=ua){
ya=wa[va];
if(ya.type){
ca.debug('message',{type:ya.type});
i.inform(k.getArbiterType(ya.type),
{obj:ya});}}else 


ca.warn
('seq_regression',
{seq:xa,last_seq:ua,messages:wa.length});



break;

case 'heartbeat':
if(ga.inStreaming){
var za=Date.now();
if(this.heartbeats.length>0){
var ab=za-
this.heartbeats[this.heartbeats.length-1];
ca.log
('heartbeat_interval',

{client_id:ga.sessionID,
interval:ab});}



this.heartbeats.push(za);}

break;


default:ca.error('unknown_msg_type',{type:ta});
break;
}},






_enter_init:function(){
if(ia.init>=ba.getConfig('MAX_INIT_FAILS',2))
return this.exitState.bind(this,
{status:k.ERROR_MAX,
stateId:ha}).
defer();


this._initTimer=this.exitState.bind(this,
{status:k.ERROR,
stateId:ha},
'timeout').
defer(ga.IFRAME_LOAD_TIMEOUT,false);},


_enter_reconnect:function(qa){
var ra=ha;


if(!t.hasUserCookie()){
ca.warn('no_user_cookie');
(function(){
ba._shutdownHint=k.HINT_AUTH;
ba.exitState
({status:k.ERROR_SHUTDOWN,
stateId:ra});}).

defer();
return;}



var sa={reason:qa,fb_dtsg:n.fb_dtsg};



if(n.fb_isb)
sa.fb_isb=n.fb_isb;




if(da)
da(sa);


var ta=new o('GET',
'/ajax/presence/reconnect.php',
sa);


ta.onSuccess=(function(){
ba.configure(ta.json);


r.store();

this.exitState({status:k.OK,stateId:ra});}).
bind(this);

ta.onError=(function(){

var ua=ta.json&&ta.json.error;

if(ta.errorType==h.TRANSPORT_ERROR||
ta.errorType==h.PROXY_ERROR)
this._shutdownHint=k.HINT_CONN;
if(ua&&ua==1356007){
this._shutdownHint=k.HINT_MAINT;}else
if(ua==1357001||
ua==1357004||
ua==1348009){
this._shutdownHint=k.HINT_AUTH;}else 

this._shutdownHint=null;


this.exitState
({status:this._shutdownHint?k.ERROR_SHUTDOWN:
k.ERROR,
stateId:ra},
ta);}).
bind(this);

ta.send();},


_enter_shutdown:function(){
i.inform(k.ON_SHUTDOWN,{reason:this._shutdownHint});},






_exit_init:function(qa){

if(this._initTimer)
this._initTimer=clearTimeout(this._initTimer);


if(qa==k.ERROR_MAX)

this._sendIframeError(k.reason_IFrameLoadGiveUp);},



_exit_pull:function(qa){
if(qa==k.OK)

this.lastPullTime=Date.now();},



_exit_ping:function(qa){
if(qa==k.OK){
var ra=Date.now()-(this.lastPullTime||n.start);
if(ra>ga.STALL_THRESHOLD)
return k.ERROR_STALE;}},







_probeTest:function(){

ga.streamingCapable=false;

var qa=[],

ra=
{mode:'stream',
format:'json'},


sa=new w('/probe').
setDomain(ga.host+'.facebook.com').
setPort(ga.port).
setSecure(w().isSecure()).
setQueryData(ra),

ta=new h('GET',sa);
ta.onJSON=function(ua,va){
if(ua&&ua.json&&ua.json.t==='heartbeat'){
qa.push(Date.now());
if(qa.length>=2){
var wa=qa[1]-qa[0];
if(wa>=ga.PROBE_HEARTBEATS_INTERVAL_LOW&&
wa<=ga.PROBE_HEARTBEATS_INTERVAL_HIGH){
ga.streamingCapable=true;
ca.log('switch_to_streaming');}

ca.log('probe_ok',{time:wa});}}};




ta.onSuccess=function(ua){
if(qa.length!=2){
ga.streamingCapable=false;
ca.error('probe_error',{error:'beats.length = '+qa.length});}};



ta.onError=function(ua){
ga.streamingCapable=false;
ca.error('probe_error',ua);};


ca.log('probe_request');
ta.send();}};




e.exports=ba;





if(aa.serverInitialized==null){
ba.configure(aa.channelConfig);

if(/shutdown/.test(aa.state))
ba._shutdownHint=k[aa.reason];

ba.init(aa.state,aa.reason);}});

/** js/channel2/ChannelConnection.js */
__d("ChannelConnection",["Arbiter","copyProperties","ChatConfig","Run","SystemEvents","ChannelConstants","ChannelManager","JSLogger"],function(a,b,c,d,e,f){













var g=b('Arbiter'),
h=b('copyProperties'),
i=b('ChatConfig'),
j=b('Run'),
k=b('SystemEvents'),

l=b('ChannelConstants'),
m=b('ChannelManager'),

n=b('JSLogger'),

o=n.create('channel_connection'),

p=null,
q=null,
r=null,
s=null,











t=0,

u=h(new g(),
{CONNECTED:'chat-connection/connected',
RECONNECTING:'chat-connection/reconnecting',
SHUTDOWN:'chat-connection/shutdown',

MUTE_WARNING:'chat-connection/mute',
UNMUTE_WARNING:'chat-connection/unmute'});





function v(){
if(q){
clearTimeout(q);
q=null;}}






function w(){
v();

o.log('unmute_warning');
u.inform(u.UNMUTE_WARNING);}









function x(ba){
v();

q=w.defer(ba,false);

o.log('mute_warning',{time:ba});
u.inform(u.MUTE_WARNING);}


function y(){
if(r){
clearTimeout(r);
r=null;}}









function z(ba,ca){
y();
if(ba===l.ON_ENTER_STATE&&
(ca.nextState||ca.state)==='pull'){

if(s!==u.CONNECTED){
o.log('connected');
var da=!s;
s=u.CONNECTED;
t=0;
u.inform(u.CONNECTED,{init:da});}}else

if(ba===l.ON_ENTER_STATE&&
((ca.nextState||ca.state)==='ping'||
(!ca.nextState&&ca.state==='idle'))){


r=(function(){
var ea=null;
if(!(ca.state==='idle'&&!ca.nextState))
ea=(ca.delay||0);

o.log('reconnecting',{delay:ea});


if(u.disconnected())
o.log('reconnecting_ui',{delay:ea});

s=u.RECONNECTING;
(ca.state==='idle')&&t++;
if(t>1){
u.inform(u.RECONNECTING,ea);}else
if(!ca.nextState&&ca.state==='idle')


z(ba,ca);}).

defer(500,false);}else
if(ba===l.ON_SHUTDOWN){
o.log('shutdown',{reason:ca.reason});
s=u.SHUTDOWN;
t=0;
u.inform(u.SHUTDOWN,ca.reason);}}






function aa(ba){
if(m.state==='ping'||m.isShutdown())
return;


o.log('reconnect',{now:ba});



u.inform(u.RECONNECTING,0);

if(!!ba){
if(p!==null){
clearTimeout(p);
p=null;}

m.enterState('ping!');}else
if(!p)
p=setTimeout
(function(){
m.enterState('ping!');
p=null;},

i.get('channel_manual_reconnect_defer_msec'),
false);}






if(m.isShutdown()){
z
(l.ON_SHUTDOWN,
m._shutdownHint);}else 


z
(l.ON_ENTER_STATE,

{state:m.state,
nextState:m.nextState,
delay:0});




g.subscribe
([l.ON_ENTER_STATE,l.ON_SHUTDOWN],
z);


k.subscribe(k.TIME_TRAVEL,function(){
aa();
x(i.get('mute_warning_time_msec'));});


j.onBeforeUnload(y,false);

h(u,






{disconnected:function(){

return s===u.SHUTDOWN||
(s===u.RECONNECTING&&
!q&&
t>1);},





isShutdown:function(){
return s===u.SHUTDOWN;},








reconnect:aa,







unmuteWarning:w});



e.exports=u;});

/** js/chat/AvailableListConstants.js */
__d("AvailableListConstants",[],function(a,b,c,d,e,f){




var g=


{ON_AVAILABILITY_CHANGED:'buddylist/availability-changed',
ON_UPDATE_ERROR:'buddylist/update-error',
ON_UPDATED:'buddylist/updated',
ON_CHAT_NOTIFICATION_CHANGED:'chat-notification-changed',


OFFLINE:0,
IDLE:1,
ACTIVE:2,
MOBILE:3,

LEGACY_OVERLAY_OFFLINE:-1,
LEGACY_OVERLAY_ONLINE:0,
LEGACY_OVERLAY_IDLE:1,








legacyStatusMap:
{'0':2,
'1':1,
'-1':0,
'2':3},








reverseLegacyStatusMap:
{0:-1,
1:1,
2:0,
3:2}};





window.AvailableListConstants=e.exports=g;},

3);

/** js/chat/ChatFavoriteList.js */
__d("ChatFavoriteList",["array-extensions","AsyncRequest","emptyFunction"],function(a,b,c,d,e,f){



b('array-extensions');
var g=b('AsyncRequest'),
h=b('emptyFunction'),

i=false,
j=[],
k=[],
l=false;

function m(){
var q=j.join(',');
new g('/ajax/chat/favorite_list.php').
setData({favorite_list:q}).
setHandler(h).
setErrorHandler(h).
send();}


function n(q){
return q.toString();}


function o(q){
if(j.length!=q.length)
return true;

for(var r=0;r<q.length;r++)
if(j[r]!==q[r].toString())
return true;


return false;}


var p=
{isEditMode:function(){
var q=null;
d(['ChatSidebar'],function(r){
q=r;});


return i&&q&&q.isEnabled();},


toggleEditMode:function(){
i=!i;
if(i)
k=j.slice();},



get:function(){
if(i){
return k.slice();}else 

return j.slice();},



isFavored:function(q){
return k.contains(q.toString());},


init:function(q){
j=q.slice().map(n);},


toggleID:function(q){
if(!i)
return;

q=q.toString();
var r=k.indexOf(q);
if(r>=0){

k.splice(r,1);}else 


k.push(q);

l=true;},


hasChanged:function(){
if(l){
l=false;
return true;}

return false;},


updateList:function(q){
if(!i)
return;

k=q.map(n);},


save:function(){
if(o(k)){
j=k;
m();}}};




e.exports=p;});

/** js/chat/PresencePrivacy.js */
__d("PresencePrivacy",["hasArrayNature","Arbiter","AsyncRequest","ChannelConstants","copyProperties","Env","JSLogger","PresenceUtil","PresencePrivacyInitialData"],function(a,b,c,d,e,f){




var g=b('hasArrayNature'),
h=b('Arbiter'),
i=b('AsyncRequest'),
j=b('ChannelConstants'),
k=b('copyProperties'),
l=b('Env'),
m=b('JSLogger'),
n=b('PresenceUtil'),
o=b('PresencePrivacyInitialData'),


p='/ajax/chat/privacy/settings.php',
q='/ajax/chat/privacy/online_policy.php',
r='/ajax/chat/privacy/visibility.php',

s='friend_visibility',
t='visibility',
u='online_policy',


v=k({},o.privacyData),
w=o.visibility,
x=k({},o.privacyData),
y=w,
z=o.onlinePolicy,
aa=z,
ba=[],
ca=false;

function da(){
return m.create('blackbird');}



var ea=k(new h(),
{WHITELISTED:1,
BLACKLISTED:-1,
UNLISTED:0,

ONLINE:1,
OFFLINE:0,

ONLINE_TO_WHITELIST:0,
ONLINE_TO_BLACKLIST:1});


function fa(ra){
var sa;
for(sa in ra){
var ta=ra[sa];

if(sa==l.user){
da().error('set_viewer_visibility');
throw new Error("Invalid to set current user's visibility");}



switch(ta){
case ea.WHITELISTED:
case ea.BLACKLISTED:
case ea.UNLISTED:
break;

default:da().error
('set_invalid_friend_visibility',
{id:sa,value:ta});
throw new Error("Invalid state: "+ta);
}}


for(sa in ra)
v[sa]=ra[sa];

ea.inform('privacy-changed');}


function ga(ra,sa){
var ta={};
ta[ra]=sa;
fa(ta);}


function ha(ra){

switch(ra){
case ea.ONLINE:
case ea.OFFLINE:
break;

default:da().error('set_invalid_visibility',{value:ra});
throw new Error("Invalid visibility: "+ra);
}

w=ra;
ea.inform('privacy-changed');
ea.inform('privacy-user-presence-changed');


h.inform('chat/visibility-changed',{sender:this});}


function ia(ra){

switch(ra){
case ea.ONLINE_TO_WHITELIST:
case ea.ONLINE_TO_BLACKLIST:
break;

default:throw new Error("Invalid default online policy: "+ra);
}

z=ra;
ea.inform('privacy-user-presence-changed');
ea.inform('privacy-changed');}


function ja(ra,sa){
ca=true;
ra.send();}








function ka(ra,sa){
ba.push({request:ra,data:sa});
if(!ca){
var ta=ba.shift();
ja(ta.request,ta.data);}}



function la(ra,sa){
var ta=ra.type;

if(ta===s){

var ua=sa.payload.user_availabilities;
if(!g(ua)){
ea.inform
('privacy-availability-changed',
{user_availabilities:ua});
for(var va in ra.settings)
x[va]=ra.settings[va];}}else{



if(ta===t){

y=ra.visibility;}else
if(ta===u)

aa=ra.online_policy;

ea.inform('privacy-user-presence-response');}


da().log
('set_update_response',
{data:ra,response:sa});}


function ma(ra,sa){
if(w!==y)
ha(y);

if(z!==aa)
ia(aa);


k(v,x);
ea.inform('privacy-changed');
ba=[];

da().log
('set_error_response',
{data:ra,response:sa});}


function na(ra){
ca=false;
if(ba.length>0){
var sa=ba.shift();
ja(sa.request,sa.data);}}



function oa(ra,sa){
if(n!=null){



var ta=ra.getData();
ta.window_id=n.getSessionID();
ra.setData(ta);}


ra.
setHandler(la.bind(this,sa)).
setErrorHandler(ma.bind(this,sa)).
setTransportErrorHandler(ma.bind(this,sa)).
setFinallyHandler(na.bind(this)).
setAllowCrossPageTransition(true);

return ra;}


function pa(ra,sa,ta){
return oa
(new i(ra).setData(sa),
ta);}



function qa(ra,sa){
var ta=sa.obj;
if(ta.viewer_id!=l.user){
da().error
('invalid_viewer_for_channel_message',
{type:ra,data:sa});
throw new Error("Viewer got from the channel is not the real viewer");}



if(ta.window_id===n.getSessionID())
return;


var ua=ta.data;
if(ta.event=='access_control_entry'){
ua.target_ids.forEach(function(wa){
ga(wa,ua.setting);

x[wa]=ua.setting;});}else{


if(ta.event=='visibility_update'){
var va=!!ua.visibility?
ea.ONLINE:
ea.OFFLINE;
ha(va);
y=va;}else
if(ta.event=='online_policy_update'){
ia(ua.online_policy);
aa=ua.online_policy;}

ea.inform('privacy-user-presence-response');}


da().log('channel_message_received',{data:sa.obj});}


k(ea,
{WHITELISTED:1,
BLACKLISTED:-1,
UNLISTED:0,

ONLINE:1,
OFFLINE:0,

ONLINE_TO_WHITELIST:0,
ONLINE_TO_BLACKLIST:1,

init:function(ra,sa,ta){
},

setVisibility:function(ra){

y=w;
ha(ra);



var sa={visibility:ra},
ta=
{type:t,
visibility:ra},


ua=
pa(r,sa,ta);
ka(ua,ta);

da().log('set_visibility',{data:sa});

return ra;},


getVisibility:function(){
return w;},


setOnlinePolicy:function(ra){
aa=z;
ia(ra);




var sa={online_policy:ra},
ta=
{type:u,
online_policy:ra},


ua=
pa(q,sa,ta);
ka(ua,ta);

da().log('set_online_policy',{data:sa});

return ra;},


getOnlinePolicy:function(){
return z;},


getFriendVisibility:function(ra){
return v[ra]||ea.UNLISTED;},


allows:function(ra){
if(this.getVisibility()===ea.OFFLINE)
return false;


var sa=this.getOnlinePolicy();
return sa===ea.ONLINE_TO_WHITELIST?
v[ra]==ea.WHITELISTED:
v[ra]!=ea.BLACKLISTED;},





setFriendsVisibility:function(ra,sa){
if(ra.length>0){
var ta={};

for(var ua=0;ua<ra.length;ua++){
var va=ra[ua];
x[va]=v[va];
ta[va]=sa;}

fa(ta);





var wa=sa;
if(wa==ea.UNLISTED)

wa=x[ra[0]];



var xa=
{users:ra,
setting:sa,
setting_type:wa},

ya=
{type:s,
settings:ta},


za=
pa(p,xa,ya);
ka(za,ya);

da().log('set_friend_visibility',{data:xa});}


return sa;},





setFriendVisibilityMap:function(ra,sa){
for(var ta in ra)
x[ta]=v[ta];

fa(ra);

var ua=
{type:s,
settings:ra};

ka
(oa(sa,ua),
ua);


da().log
('set_friend_visibility_from_map',
{data:ra});},






allow:function(ra){
if(this.allows(ra)){
da().error('allow_already_allowed');
throw new Error
("allow() should only be called for users that "+
"are not already allowed");}

if(this.getVisibility()===ea.OFFLINE){
da().error('allow_called_while_offline');
throw new Error
("allow() should only be called when the user is already online");}


var sa=
this.getOnlinePolicy()===ea.ONLINE_TO_WHITELIST?
ea.WHITELISTED:ea.UNLISTED;
return this.setFriendsVisibility([ra],sa);},




disallow:function(ra){
if(!this.allows(ra)){
da().error('disallow_already_disallowed');
throw new Error
("disallow() should only be called for users that "+
"are not already disallowed");}

if(this.getVisibility()===ea.OFFLINE){
da().error('disallow_called_while_offline');
throw new Error
("disallow() should only be called when the user is already online");}


var sa=
this.getOnlinePolicy()===ea.ONLINE_TO_BLACKLIST?
ea.BLACKLISTED:ea.UNLISTED;
return this.setFriendsVisibility([ra],sa);},


getBlacklist:function(){
var ra=[];
for(var sa in v)
if(v[sa]===ea.BLACKLISTED)
ra.push(sa);


return ra;},


getWhitelist:function(){
var ra=[];
for(var sa in v)
if(v[sa]===ea.WHITELISTED)
ra.push(sa);


return ra;},





getMapForTest:function(){
return v;},


setMapForTest:function(ra){
v=ra;}});



ea.inform('privacy-changed');
ea.inform('privacy-user-presence-changed');

da().log
('initialized',
{visibility:w,policy:z});

h.subscribe
(j.getArbiterType('privacy_changed'),
qa.bind(this));


h.subscribe(j.ON_CONFIG,function(ra,sa){
var ta=sa.getConfig('visibility',null);
if(ta!==null&&
typeof(ta)!=='undefined'){
var ua=ta?
ea.ONLINE:ea.OFFLINE;
ha(ua);
da().log('config_visibility',{vis:ua});}}.

bind(this));

a.PresencePrivacy=e.exports=ea;},

3);

/** js/chat/ChatVisibility.js */
__d("ChatVisibility",["Arbiter","JSLogger","PresencePrivacy"],function(a,b,c,d,e,f){




var g=b('Arbiter'),
h=b('JSLogger'),
i=b('PresencePrivacy'),

j=
{isOnline:function(){
return i.getVisibility()===i.ONLINE;},


hasBlackbirdEnabled:function(){
return this.isVisibleToMostFriends()||this.isVisibleToSomeFriends();},



isVisibleToMostFriends:function(){
return i.getOnlinePolicy()===
i.ONLINE_TO_BLACKLIST&&
i.getBlacklist().length>0;},



isVisibleToSomeFriends:function(){
return i.getOnlinePolicy()===
i.ONLINE_TO_WHITELIST&&
i.getWhitelist().length>0;},







goOnline:function(k){
if(i.getVisibility()===i.OFFLINE){
h.create('blackbird').log('chat_go_online');
i.setVisibility(i.ONLINE);

g.inform('chat-visibility/go-online');}

k&&k();},


goOffline:function(k){
if(i.getVisibility()===i.ONLINE){
h.create('blackbird').log('chat_go_offline');
i.setVisibility(i.OFFLINE);

g.inform('chat-visibility/go-offline');}

k&&k();},


toggleVisibility:function(){
if(j.isOnline()){
j.goOffline();}else 

j.goOnline();}};





a.ChatVisibility=e.exports=j;},

3);

/** js/chat/LastMobileActiveTimes.js */
__d("LastMobileActiveTimes",["tx"],function(a,b,c,d,e,f){




var g=b('tx'),

h=0,
i={};

function j(n){

if(!h||!n)
return '';


var o=h-n,
p=Math.floor(o/60),
q=Math.floor(p/60),
r=Math.floor(q/24);
if(p<=1){
return g._("{count}m",{count:1});}else
if(p<60){
return g._("{count}m",{count:p});}else
if(q<24){
return g._("{count}h",{count:q});}else
if(r<3){
return g._("{count}d",{count:r});}else 

return '';}



function k(n,o){
i[n]=o;}


function l(n){
if(n in i){
return i[n];}else 

return 0;}



var m=
{update:function(n,o){
h=o/1000;
for(var p in n)
k(p,n[p]);},



getShortDisplay:function(n){
return j(l(n));}};



e.exports=m;});

/** js/modules/Poller.js */
__d("Poller",["ArbiterMixin","AsyncRequest","Cookie","Env","copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('ArbiterMixin'),
h=b('AsyncRequest'),
i=b('Cookie'),
j=b('Env'),

k=b('copyProperties'),
l=b('emptyFunction');


































function m(p){
this._config=k
({clearOnQuicklingEvents:true,
setupRequest:l,
interval:null,
maxRequests:Infinity,
dontStart:false},
p);





if(!this._config.dontStart)
this.start();}



m.MIN_INTERVAL=2000;

k(m.prototype,g,




{start:function(){
if(this._polling)
return this;

this._requests=0;
setTimeout(this.request.bind(this),0);
return this;},




stop:function(){
this._cancelRequest();
return this;},






mute:function(){
this._muted=true;
return this;},





resume:function(){
if(this._muted){
this._muted=false;
if(!this._handle&&this._polling)
return this.request();}


return this;},






skip:function(){
this._skip=true;
return this;},





reset:function(){
return this.
stop().
start();},









request:function(){
this._cancelRequest();
this._polling=true;

if(!o())
return this._done();


if(this._muted)
return this;


if(++this._requests>this._config.maxRequests)
return this._done();


var p=new h(),
q=false;

p.setInitialHandler(function(){
return !q;});


this._cancelRequest=function(){
q=true;
this._cleanup();}.
bind(this);

p.setFinallyHandler(n.bind(this));

















p.setInitialHandler=l;
p.setFinallyHandler=l;


this._config.setupRequest(p,this);



if(this._skip){
this._skip=false;


n.bind(this).defer();}else 

p.send();

return this;},


isPolling:function(){
return this._polling;},

isMuted:function(){
return this._muted;},

setInterval:function(p){
if(p){
this._config.interval=p;
this.start();}},


getInterval:function(){
return this._config.interval;},


_cleanup:function(){
if(this._handle)
clearTimeout(this._handle);

this._handle=null;
this._cancelRequest=l;
this._polling=false;},

_done:function(){
this._cleanup();
this.inform('done',{sender:this});
return this;},

_config:null,
_requests:0,
_muted:false,
_polling:false,
_skip:false,






_cancelRequest:l});


function n(){

if(this._polling&&(this._requests<this._config.maxRequests)){
var p=this._config.interval;
p=
typeof p==='function'?
p(this._requests):
p;
this._handle=this.request.bind(this).defer



((p>m.MIN_INTERVAL)?
p:
m.MIN_INTERVAL,
this._config.clearOnQuicklingEvents);}else{


this._cleanup();
this.inform('done',{sender:this});}}



function o(){
return j.user==i.get('c_user');}


e.exports=m;});

/** js/presence/ServerTime.js */
__d("ServerTime",["PresenceInitialData"],function(a,b,c,d,e,f){













var g=b('PresenceInitialData'),

h;

function i(k){
h=Date.now()-k;}


i(g.serverTime);

var j=






{get:function(){
return Date.now()-h;},


getSkew:function(){
return h;},






update:function(k){
i(k);}};




e.exports=j;});

/** js/chat/AvailableList.js */
__d("AvailableList",["function-extensions","Arbiter","ArbiterMixin","AsyncRequest","AvailableListConstants","ChannelConstants","ChatConfig","ChatFavoriteList","ChatVisibility","Env","JSLogger","LastMobileActiveTimes","Poller","PresencePrivacy","PresenceUtil","ServerTime","ShortProfiles","UserActivity","copyProperties","createObjectFrom","debounceAcrossTransitions","emptyFunction","ChannelImplementation","AvailableListInitialData"],function(a,b,c,d,e,f){



b('function-extensions');

var g=b('Arbiter'),
h=b('ArbiterMixin'),
i=b('AsyncRequest'),
j=b('AvailableListConstants'),
k=b('ChannelConstants'),
l=b('ChatConfig'),
m=b('ChatFavoriteList'),
n=b('ChatVisibility'),
o=b('Env'),
p=b('JSLogger'),
q=b('LastMobileActiveTimes'),
r=b('Poller'),
s=b('PresencePrivacy'),
t=b('PresenceUtil'),
u=b('ServerTime'),
v=b('ShortProfiles'),
w=b('UserActivity'),

x=b('copyProperties'),
y=b('createObjectFrom'),
z=b('debounceAcrossTransitions'),
aa=b('emptyFunction'),

ba=c('ChannelImplementation').instance,
ca=c('AvailableListInitialData'),


da=5,
ea='/ajax/chat/buddy_list.php',
fa=5000,
ga=1800000,

ha=0,
ia=0,
ja=false,

ka=ca.pollInterval,
la=ca.lazyPollInterval,
ma=ca.lazyThreshold,

na=0,

oa=Date.now(),
pa=0,

qa=false,
ra={},
sa=false,
ta={},
ua=null,

va={},
wa={},

xa=p.create('available_list'),

ya=x({},j,h);



ya.subscribe

([j.ON_AVAILABILITY_CHANGED,
j.ON_UPDATE_ERROR,
j.ON_UPDATED],

function(qb,rb){g.inform(qb,rb);});


function za(qb){
var rb=qb||w.isActive(ma);
return n.isOnline()?
(rb?ka:la):
null;}


function ab(){
ya.inform(j.ON_AVAILABILITY_CHANGED);}


var bb=z
(ab,
0);


function cb(qb,rb,sb,tb){
if(qb==o.user)



return;



switch(rb){
case j.OFFLINE:
case j.IDLE:
case j.ACTIVE:
case j.MOBILE:
break;




default:return;
}

var ub=ya.get(qb)!=rb;

if(sb){



va[qb]=u.get();
wa[qb]=tb;}

ra[qb]=rb;

if(ub){
ha++;
bb();}}



function db(qb){
pa=Date.now();
ta=y(qb);

ha++;
bb();}


function eb(){
if(qa)
ya.inform(j.ON_UPDATED,ya);}



function fb(qb){
if(t.checkMaintenanceError(qb))
return;

ia++;
ja=false;

if(ia>=da)

ya.inform(j.ON_UPDATE_ERROR);}



function gb(qb){
var rb=qb.getPayload(),
sb=rb.buddy_list;
if(!sb){
fb(qb);
return;}


u.update(rb.time);
na=u.get();

ia=0;
ja=false;

if(sb.mobile_friends!=null)
db(sb.mobile_friends);


var tb=sb.userInfos;
if(tb)
v.setMulti(tb);



mb();

sa=sb.userIsIdle;

var ub=sb.nowAvailableList;
ub&&kb(ub);

var vb=sb.last_active_times;
vb&&q.update(vb,rb.time);

if(sb.chatNotif!==undefined){
ua=sb.chatNotif;
ya.inform
(j.ON_CHAT_NOTIFICATION_CHANGED,
ua);}




lb();

eb();
bb();}


function hb(qb){
if(ba.isShutdown()||!n.isOnline()){
ya._poller.stop();
return;}


oa=Date.now();

var rb=false;
if(Date.now()-pa>ga)
rb=true;


ja=true;

var sb=v.getCachedProfileIDs().join(",");

qb.
setHandler(gb).
setErrorHandler(fb).
setOption('suppressErrorAlerts',true).
setOption('retries',1).
setData
({user:o.user,



cached_user_info_ids:sb,
fetch_mobile:rb}).

setURI(ea).
setAllowCrossPageTransition(true);}


function ib(qb){
var rb=qb.payload.availability||{};

for(var sb in rb)
cb(sb,rb[sb],true,'mercury_tabs');}



function jb(qb){
var rb=ya.getDebugInfo(qb),
sb=(rb.presence==j.ACTIVE),
tb=
new i('/ajax/mercury/tabs_presence.php').
setData({target_id:qb,
to_online:sb,
presence_source:rb.overlaySource,
presence_time:rb.overlayTime}).

setHandler(ib).
setErrorHandler(aa).
setAllowCrossPageTransition(true).
send();}


function kb(qb){
for(var rb in qb)
cb(rb,qb[rb].a,false,null);

qa=true;}


function lb(qb){
var rb=za(qb);
xa.debug('update_poller',rb);
ya._poller&&
ya._poller.setInterval(rb);}


function mb(){
qa=false;
ra={};
wa={};
va={};
ha++;}


function nb(){
mb();
oa=0;
pa=0;
sa=false;
ua=null;
ta={};
ab();}


function ob(){
lb();
if(ba.disconnected()){
nb();}else
if(!qa)
ya.update();}



function pb(qb,rb){


rb.chat_config=l.getDebugInfo();
rb.available_list_debug_info={};
ya.getAvailableIDs().forEach(function(sb){
rb.available_list_debug_info[sb]=ya.getDebugInfo(sb);});

rb.available_list_poll_interval=ya._poller&&
ya._poller.getInterval();}



x(ya,







{get:function(qb){
if(qb==o.user)


return n.isOnline()?
j.ACTIVE:j.OFFLINE;


var rb=j.OFFLINE;
if(qb in ra)
rb=ra[qb];


if(!s.allows(qb))


rb=j.OFFLINE;


if(rb==j.OFFLINE)
if(ta[qb])
rb=j.MOBILE;



return rb;},


updateForID:function(qb){
jb(qb);},







getWebChatNotification:function(){
return ua;},





isUserIdle:function(){
return sa;},






isReady:function(){
return qa;},







set:function(qb,rb,sb){
cb(qb,rb,true,null,sb);},





update:function(){
if(Date.now()-oa<fa){


!ja&&eb.defer();
return;}

ya._poller&&ya._poller.request();},








getRev:function(){
return ha;},





isIdle:function(qb){
return ya.get(qb)==j.IDLE;},





getOnlineIDs:function(){
var qb,rb=[];
for(qb in ra)
if(ya.get(qb)===j.ACTIVE)
rb.push(qb);



return rb;},





getAvailableIDs:function(){
var qb=ya.getOnlineIDs(),
rb;

for(rb in ta){
if(ra[rb])

continue;

qb.push(rb);}


return qb;},






getOnlineCount:function(){
return ya.getOnlineIDs().length;},


getDebugInfo:function(qb){
var rb;
if(window.ShortProfiles){
var sb=v.getNow(qb);
if(sb)
rb=sb.name;}




return {id:qb,
presence:ra[qb],
overlaySource:wa[qb],
overlayTime:va[qb],
overlaySource:wa[qb],
mobile:ta[qb],
name:rb};}});







na=ca.updateTime;
kb(ca.availableList);

if(ca.mobileFriends)
db(ca.mobileFriends);


if(ca.lastActiveTimes)
q.update(ca.lastActiveTimes,na);


if(ca.favoriteList)
m.init(ca.favoriteList);


ua=ca.chatNotif;

ya._poller=new r
({interval:za(),
setupRequest:hb,
clearOnQuicklingEvents:false});



lb(true);

g.subscribe(p.DUMP_EVENT,pb);


w.subscribe(function(qb,rb){
if(rb.idleness>ka){
xa.debug('update_activity');
ya.update();}});



s.subscribe('privacy-changed',ab);

s.subscribe
('privacy-availability-changed',
function(qb,rb){
for(var sb in rb.user_availabilities)
this.set(sb,rb.user_availabilities[sb]);}.

bind(ya));

s.subscribe
('privacy-user-presence-response',
ya.update);

ba.subscribe
([ba.CONNECTED,
ba.RECONNECTING,
ba.SHUTDOWN,
ba.MUTE_WARNING,
ba.UNMUTE_WARNING],
ob);


g.subscribe
(k.getArbiterType('buddylist_overlay'),
function(qb,rb){
var sb=rb.obj.overlay;
for(var tb in sb)
ya.set(tb,sb[tb].a,sb[tb].s||'channel');});





a.AvailableList=e.exports=ya;});

/** js/chat/Chat.js */
__d("Chat",["Arbiter","AsyncSignal"],function(a,b,c,d,e,f){









var g=b('Arbiter'),
h=b('AsyncSignal');

function i(m,n,o){

if(n&&
n=='ordered_list'||
n=='more_online_friends'||
n=='online_friends'||
n=='typeahead'){
var p=
{target:m,
source:n,
sorted_list:o};

new h('/ajax/chat/ct.php',p).send();}}



var j=
{buddyListNub:'buddylist-nub/initialized',
sidebar:'sidebar/initialized'};


function k(m,n){
g.subscribe
(j[m],
function(event,o){
n(o);});}




var l=







{openTab:function(m,n,o,p,q){

if(window.External&&
window.External.Chat&&
window.External.Chat.openWindow)
window.External.Chat.openWindow(m);

i(m,p,q);

d(['MercuryThreads'],function(r){


if(!o||o=='friend'){
var s=r.get().getCanonicalThreadToUser(m);
g.inform('chat/open-tab',{thread_id:s.thread_id});}});},




openBuddyList:function(){
k('buddyListNub',function(m){
m.show();
k('sidebar',function(n){
n.enable();});});},




closeBuddyList:function(){
k('buddyListNub',function(m){
m.hide();});},



toggleSidebar:function(){
k('sidebar',function(m){
m.toggle();});},








goOnline:function(m){

d(['ChatVisibility'],function(n){
n.goOnline(m);});},






isOnline:function(){
var m=null;
d(['ChatVisibility'],function(n){
m=n;});


return m&&m.isOnline();}};




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

3);

/** js/chat/ChatOptions.js */
__d("ChatOptions",["Arbiter","ChannelConstants","JSLogger","PresenceUtil","copyProperties","ChatOptionsInitialData"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('ChannelConstants'),
i=b('JSLogger'),
j=b('PresenceUtil'),
k=b('copyProperties'),

l=i.create('chat_options'),

m={};

(function(){
var o=b('ChatOptionsInitialData');
for(var p in o){
var q=o[p];
m[p]=!!q;}})

();

var n=k(new g(),

{getSetting:function(o){
return m[o];},


setSetting:function(o,p,q){
if(this.getSetting(o)==p)

return;


if(q){
q='from_'+q;
l.log(q,{name:o,
new_value:p,
old_value:this.getSetting(o)});}


m[o]=!!p;

g.inform('chat/option-changed',
{name:o,
value:p});}});





g.subscribe
(h.getArbiterType('setting'),
function(o,p){
var q=p.obj;

if(q.window_id===j.getSessionID())
return;

n.setSetting(q.setting,!!q.value,'channel');});



g.subscribe(i.DUMP_EVENT,function(o,p){
p.chat_options=m;});



e.exports=n;});

/** js/chat/OrderedFriendsList.js */
__d("OrderedFriendsList",["array-extensions","Arbiter","createArrayFrom","ShortProfiles","copyProperties","InitialChatFriendsList"],function(a,b,c,d,e,f){



b('array-extensions');

var g=b('Arbiter'),
h=b('createArrayFrom'),
i=b('ShortProfiles'),

j=b('copyProperties'),







k=[],
l={},

m=j(new g(),







{contains:function(n){
return n in l;},










compare:function(n,o){

var p=m.getRank(n),
q=m.getRank(o);
if(p!==q)
return p-q;



var r=i.getNow(n),
s=i.getNow(o),
t=((r||{}).name||'~').toLowerCase(),
u=((s||{}).name||'~').toLowerCase();
if(t!==u)
return t<u?-1:1;


return 0;},





getList:function(){
var n=h(k);






n=n.filter(function(o){
var p=window.ShortProfiles&&i.getNow(o);
return !p||p.type=="friend";});


return n;},









getRank:function(n){
return n in l?l[n]:k.length;},


isReady:function(){
return true;}});



(function(){
var n=b('InitialChatFriendsList');
k=n.list.length?n.list:[];
k.forEach(function(o,p){l[o]=p;});


m.inform('initialized',{},g.BEHAVIOR_PERSISTENT);})
();

e.exports=a.OrderedFriendsList||m;});

/** js/chat/typeahead/ChatTypeaheadBehavior.js */
__d("ChatTypeaheadBehavior",["Chat","ChatFavoriteList","CSS","DOM","Rect","copyProperties","tx"],function(a,b,c,d,e,f){





var g=b('Chat'),
h=b('ChatFavoriteList'),
i=b('CSS'),
j=b('DOM'),
k=b('Rect'),

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






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


l(n.prototype,

{_subscriptions:null,

enable:function(){
var o=this._typeahead;

this._subscriptions=

[o.subscribe('focus',function(){
o.getData().refreshData();}),



o.subscribe('blur',function(p){
o.getCore().reset();}),



o.subscribe('respond',function(p,q){
if(q.value&&q.value===o.getCore().getValue()){
if(!q.results.length){
var r=j.create('div',
{className:'noResults'},
"Friend not found.");
j.setContent(o.getView().getElement(),r);}


i.addClass(o.getElement(),'hasValue');}}),



o.subscribe('reset',function(){

i.removeClass(o.getElement(),'hasValue');}),



o.subscribe('select',function(p,q){
if(h.isEditMode()){
h.toggleID(q.selected.uid);}else 

g.openTab
(q.selected.uid,
q.selected.text,
q.selected.type,
'typeahead');}),




o.subscribe('highlight',function(p,q){
if(q.index>=0){
var r=o.getView().getItems()[q.index];
if(r){




var s=new k(r),
t=r.offsetParent,
u=s.boundWithin(new k(t)).getPositionVector();
s.getPositionVector().sub(u).scrollElementBy(t);}}})];},






disable:function(){
this._subscriptions.forEach(function(o){
this._typeahead.unsubscribe(o);}.
bind(this));
this._subscriptions=null;}});




e.exports=n;});

/** js/chat/typeahead/ChatTypeaheadCore.js */
__d("ChatTypeaheadCore",["Event","function-extensions","Class","Keys","TypeaheadCore","copyProperties","emptyFunction"],function(a,b,c,d,e,f){



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

var h=b('Class'),
i=b('Keys'),
j=b('TypeaheadCore'),

k=b('copyProperties'),
l=b('emptyFunction');

function m(n){
this.parent.construct(this,n);}


h.extend(m,j);

k(m.prototype,



{handleTab:l,




keydown:function(event){
var n=g.getKeyCode(event);


if(n===i.ESC){

this.reset.shield(this).defer();
return event.kill();}


return this.parent.keydown(event);}});



e.exports=m;});

/** js/chat/typeahead/ChatTypeaheadDataSource.js */
__d("ChatTypeaheadDataSource",["Arbiter","AvailableListConstants","Class","DataSource","Env","JSLogger","OrderedFriendsList","Run","ShortProfiles","copyProperties"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('AvailableListConstants'),
i=b('Class'),
j=b('DataSource'),
k=b('Env'),
l=b('JSLogger'),
m=b('OrderedFriendsList'),
n=b('Run'),
o=b('ShortProfiles'),

p=b('copyProperties');

function q(r){
this.parent.construct(this,r);
this.persistOnRefresh=r.persistOnRefresh!==false;
this.showOfflineUsers=!!r.showOfflineUsers;

this._jslog=l.create('chat_typeahead');
this._jslog.log('created');}


i.extend(q,j);

p(q.prototype,
{init:function(){
this._jslog.log('init');

this.parent.init();

var r=g.subscribe
(h.ON_AVAILABILITY_CHANGED,
this._update.shield(this));
this._update();

if(!this.persistOnRefresh)
n.onLeave(function(){
r.unsubscribe();});},




bootstrap:function(){
this._jslog.log('bootstrap');
this.parent.bootstrap();

if(this.showOfflineUsers){
this._jslog.log('show_offline_users');
this._jslog.log('ensured_short_profiles');

if(o.hasAll()){
this._update();}else{

this._jslog.log('fetch_all_short_profiles');
o.fetchAll();


this.inform('activity',{activity:true});

var r=o.subscribe('updated',function(){
this.inform('activity',{activity:false});
this._update();}.
bind(this));

if(!this.persistOnRefresh)
n.onLeave(function(){
o.unsubscribe(r);});}}},















_update:function(){
d(['AvailableList'],function(r){

var s=this.value;

this.dirty();


var t=o.getCachedProfileIDs(),
u=t.filter(function(w){
var x=o.getNow(w);
return x.type==='friend';});

u.sort(m.compare);


var v=[];
u.forEach(function(w){
if(w==k.user)
return;


var x=r.get(w);



if(!this.showOfflineUsers&&x!==r.ACTIVE)
return;


var y=o.getNow(w);

v.push
({uid:w,
text:y.name,
tokens:y.additionalName,
localized_text:y.name,
additional_text:y.additionalName,
photo:y.thumbSrc,
availability:x,
type:y.type});}.

bind(this));

if(v.length)
this.addEntries(v);



this.value=s;
if(s)
this.respond(s,this.buildUids(s,[],this._exclusions),true);}.


bind(this));},


refreshData:function(){
d(['AvailableList'],function(r){
r.update();}.
bind(this));}});




e.exports=q;});

/** js/chat/typeahead/ChatTypeaheadRenderer.js */
__d("ChatTypeaheadRenderer",["AvailableListConstants","ChatFavoriteList","CSS","DOM","PresencePrivacy","LastMobileActiveTimes","cx"],function(a,b,c,d,e,f){



var g=b('AvailableListConstants'),
h=b('ChatFavoriteList'),
i=b('CSS'),
j=b('DOM'),
k=b('PresencePrivacy'),
l=b('LastMobileActiveTimes'),

m=b('cx');

function n(o,p){
var q='offline';
switch(o.availability){
case g.ACTIVE:
q='active';
break;
case g.IDLE:
q='idle';
break;
case g.MOBILE:
q='mobile';
break;}


if(!k.allows(o.uid))
q='invis';


var r=[],

s=h.isEditMode(),
t=h.isFavored(o.uid);
if(s){
var u=j.create
('span',
{className:"_42fw"});

i.addClass
(u,
t?
"_42fx":
"_42fy");

r.push(u);}

if(o.photo)
r.push(j.create('img',{alt:'',src:o.photo}));


if(!s){
r.push(j.create('i',{className:q}));
if(q=='mobile'){
var v=l.getShortDisplay(o.uid);
r.push(j.create('span',{className:'time'},[v]));}}



if(o.text)
r.push(j.create('span',{className:'text'},[o.text]));

return j.create('li',{className:'clearfix '+q},r);}


e.exports=n;});

/** js/chat/typeahead/LegacyChatTypeaheadBehavior.js */
__d("legacy:ChatTypeaheadBehavior",["ChatTypeaheadBehavior"],function(a,b,c,d){



var e=b('ChatTypeaheadBehavior');

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


3);

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




var g=b('copyProperties'),






h=
{memory:k,
localstorage:i,
sessionstorage:j};






function i(){
this._store=a.localStorage;}





i.available=function(){
return !!a.localStorage;};


g(i.prototype,



{keys:function(){
var m=[];
for(var n=0;n<this._store.length;n++)
m.push(this._store.key(n));

return m;},





get:function(m){
return this._store.getItem(m);},





set:function(m,n){
this._store.setItem(m,n);},





remove:function(m){
this._store.removeItem(m);},





clear:function(){
this._store.clear();}});






function j(){
this._store=a.sessionStorage;}





j.available=function(){
return !!a.sessionStorage;};


g(j.prototype,



{keys:function(){
var m=[];
for(var n=0;n<this._store.length;n++)
m.push(this._store.key(n));

return m;},





get:function(m){
return this._store.getItem(m);},





set:function(m,n){
this._store.setItem(m,n);},





remove:function(m){
this._store.removeItem(m);},





clear:function(){
this._store.clear();}});






function k(){
this._store={};}





k.available=function(){
return true;};


g(k.prototype,



{keys:function(){
return Object.keys(this._store);},





get:function(m){
if(this._store[m]===undefined)
return null;

return this._store[m];},





set:function(m,n){
this._store[m]=n;},





remove:function(m){
if(m in this._store)
delete this._store[m];},






clear:function(){
this._store={};}});


























function l(m,n){

this._key_prefix=n||'_cs_';
this._magic_prefix='_@_';



if(m=='AUTO'||!m)
for(var o in h){
var p=h[o];
if(p.available()){
m=o;
break;}}



if(m)
if(!h[m]||
!h[m].available()){





this._backend=new k();}else 

this._backend=new h[m]();}




g(l,
{getAllStorageTypes:function(){
return Object.keys(h);}});



g(l.prototype,





{keys:function(){

var m=[];

if(this._backend){

var n=this._backend.keys();
for(var o=0;o<n.length;o++)
if(n[o].substr(0,this._key_prefix.length)==this._key_prefix)
m.push(n[o].substr(this._key_prefix.length));


return m;}


return m;},









set:function(m,n){
if(this._backend){
if(typeof n=='string'){
n=this._magic_prefix+n;}else 

n=JSON.stringify(n);

this._backend.set(this._key_prefix+m,n);}},










get:function(m,n){
var o;
if(this._backend){
o=this._backend.get(this._key_prefix+m);



if(o!==null){
if(o.substr(0,this._magic_prefix.length)==this._magic_prefix){
o=o.substr(this._magic_prefix.length);}else 


try{o=JSON.parse(o);}catch(
p){
o=undefined;}}else 




o=undefined;}



if(o===undefined&&n!==undefined){
o=n;
if(this._backend){
var q;
if(typeof o=='string'){
q=this._magic_prefix+o;}else 

q=JSON.stringify(o);

this._backend.set(this._key_prefix+m,q);}}



return o;},






remove:function(m){
if(this._backend)
this._backend.remove(this._key_prefix+m);}});





e.exports=l;});

/** js/desktop/auth/FBDesktopPlugin.js */
__d("FBDesktopPlugin",["CacheStorage","DOM","Env","FBDesktopDetect","URI","Style"],function(a,b,c,d,e,f){




var g=b('CacheStorage'),
h=b('DOM'),
i=b('Env'),
j=b('FBDesktopDetect'),
k=b('URI'),
l=b('Style'),

m=new g('localstorage','_socialfox_'),

n=
{_plugin:'_not_checked',

arbiterInform:function(o,p){
var q=JSON.stringify({name:o,payload:p});
this._transmitCommand('arbiterinform',q);},


bringToFront:function(){
this._transmitCommand('bringtofront');},


dock:function(){
this._transmitCommand('dock');},


getPlugin:function(){
if(this._plugin==='_not_checked'){
this._plugin=null;
if(j.isPluginInstalled()){
var o=h.create('object',
{id:'kiwi_plugin',
type:j.mimeType});






l.set(o,'width',0);
l.set(o,'height',0);
var p=h.create('div',{},o);
l.set(p,'width',0);
l.set(p,'height',0);
document.body.appendChild(p);

this._plugin=o;}}



return this._plugin;},


getUserID:function(){
var o=this.getPlugin();
return o&&
'getUserID' in o&&
o.getUserID();},


getVersion:function(){
var o=this.getPlugin();
return o&&'getVersion' in o&&o.getVersion();},


isAppRunning:function(){
var o=this.getPlugin();
return o&&
'isAppRunning' in o&&
o.isAppRunning();},


launchApp:function(){
var o=this.getPlugin();
return o&&
'launchApp' in o&&
o.launchApp();},


login:function(o,p){
if(p&&o&&o.length>0){
var q=this.getPlugin();
if(q){
this._transmitCommand('relogin\n'+o+'\n'+p);
return;}}},











logout:function(o){
o=o||"0";
var p=this.getPlugin();
if(p)
p.logout(o);},





recheck:function(){
if(this._plugin===null)
this._plugin='_not_checked';},



shouldSuppressBeeper:function(){
return this.isAppRunning();},


shouldSuppressMessages:function(){
if(m&&m.get('connected'))
return true;


var o=this.getUserID();
if(o){
return o===i.user;}else 


return this.isAppRunning();},



shouldSuppressSidebar:function(){
var o=this.getPlugin(),
p=
o&&
'isAppDocked' in o&&
o.isAppDocked(),

q=
m&&
m.get('active')==='true';

return p||q;},


transferAuthToken:function(o,p){
if(o&&o.length>0){
var q=this.getPlugin();
if(q){
q.setAccessToken(o,p);
var r=setInterval(function(){
q.setAccessToken(o,p);},
500);
setTimeout(function(){clearInterval(r);},10*1000);}}



if(this.redirectHome)
window.location.href=k().setPath().toString();},






_transmitCommand:function(o,p){
p=p||'';
var q=this.getPlugin();
if(q&&'transmitCommand' in q)
q.transmitCommand(o,p);}};




e.exports=n;});

/** js/home/AppRequestReminders.js */
__d("AppRequestReminders",["AsyncRequest","CSS","DOM","ge"],function(a,b,c,d,e,f){



var g=b('AsyncRequest'),
h=b('CSS'),
i=b('DOM'),
j=b('ge'),

k=0,
l={},
m=1,
n=j('OtherAppReqReminder'),

o=function(u,v,w){
l[v]=
{node:u,
seq:m++,
reqCount:w};},



p=function(u){
k=u;},


q=function(u){
return u.id.split('_')[1];},


r=function(u){
var v=j(u),
w=v.nextSibling;

if(w!==n){
h.show(w);
k-=l[q(w)].reqCount;}

s(k);},


s=function(u){

new g().
setURI('/ajax/reminders/update_count.php').
setData({new_count:u}).
setMethod('POST').
send();},


t=function(u,v){

if(n&&v&&u>0){
i.setContent(j('OtherAppReqLabel'),v);}else
if(n){

h.hide(n);}else 


h.hide(j('OtherAppReqReminder'));};



f.initNode=o;
f.handleRemove=r;
f.updateCount=t;
f.setTotalOtherCount=p;});

/** js/lib/ui/ModalMask.js */
__d("ModalMask",["DOM"],function(a,b,c,d,e,f){




var g=b('DOM'),

h=null,
i=0,




j=

{show:function(){
i++;

if(!h){
h=g.create('div',{id:'modalMaskOverlay'});
g.appendContent(document.body,h);}},



hide:function(){
if(i){
i--;
if(!i&&h){
g.remove(h);
h=null;}}}};





e.exports=j;});

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


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

3);

/** js/mercury/callback_manager/RangedCallbackManager.js */
__d("RangedCallbackManager",["CallbackManagerController","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){







var g=b('CallbackManagerController'),
h=b('copyProperties'),
i=b('createObjectFrom'),














j=
function(k,
l,
m){

this._resources=[];
this._reachedEndOfArray=false;
this._error=false;
this._existingIDs={};
this._controller=new g
(this._constructCallbackArg.bind(this));


this._getValueHandler=k;
this._compareValuesHandler=l;
this._skipOnStrictHandler=m;};


h(j.prototype,

















{executeOrEnqueue:function(k,l,m,n){
return this._controller.executeOrEnqueue
({start:k,limit:l},
m,
{strict:!!n});},









unsubscribe:function(k){
this._controller.unsubscribe(k);},






getUnavailableResources:function(k){
var l=this._controller.getRequest(k),
m=[];


if(l&&!this._reachedEndOfArray){
var n=l.request,
o=this._filterForStrictResults(l.options),
p=n.start+n.limit;
for(var q=o.length;q<p;q++)
m.push(q);}


return m;},







addResources:function(k){
k.forEach(function(l){

if(!this._existingIDs[l]){
this._existingIDs[l]=true;
this._resources.push(l);
this._error=null;}}.

bind(this));

this.resortResources();
this._controller.runPossibleCallbacks();},








addResourcesWithoutSorting:function(k,l){
var m=this._resources.slice(0,l);
m=m.concat(k);
m=m.concat(this._resources.slice(l));

this._resources=m;
h
(this._existingIDs,
i(k,true));


this._error=null;
this._controller.runPossibleCallbacks();},






removeResources:function(k){
k.forEach(function(l){
if(this._existingIDs[l]){
this._existingIDs[l]=false;
this._resources.remove(l);}}.

bind(this));},





removeAllResources:function(){
this._resources=[];
this._existingIDs={};},






resortResources:function(){
this._resources=this._resources.sort(function(k,l){
return this._compareValuesHandler
(this._getValueHandler(k),
this._getValueHandler(l));}.

bind(this));},








setReachedEndOfArray:function(){
if(!this._reachedEndOfArray){
this._reachedEndOfArray=true;
this._error=null;
this._controller.runPossibleCallbacks();}},






hasReachedEndOfArray:function(){
return this._reachedEndOfArray;},









setError:function(k){
if(this._error!==k){
this._error=k;
this._controller.runPossibleCallbacks();}},







getError:function(k,l,m){
var n=this._filterForStrictResults({strict:m});
return k+l>n.length?this._error:null;},





hasResource:function(k){
return this._existingIDs[k];},






getResourceAtIndex:function(k){
return this._resources[k];},





getAllResources:function(){
return this._resources.concat();},


getCurrentArraySize:function(){
return this._resources.length;},


_filterForStrictResults:function(k){
var l=this._resources;

if(k&&k.strict&&this._skipOnStrictHandler)
l=l.filter(this._skipOnStrictHandler);


return l;},






_constructCallbackArg:function(k,l){
var m=this._filterForStrictResults(l);

if(!this._reachedEndOfArray&&
!this._error&&
k.start+k.limit>m.length){
return false;}else{

var n=m.slice(k.start,k.start+k.limit),




o=k.start+k.limit>m.length?
this._error:
null;
return [n,o];}},



getElementsUntil:function(k){
var l=[];
for(var m=0;m<this._resources.length;m++){
var n=this._getValueHandler(this._resources[m]);
if(this._compareValuesHandler(n,k)>0)
break;


l.push(this._resources[m]);}


return l;}});



e.exports=j;});

/** js/mercury/clients/chat/ChatBehavior.js */
__d("ChatBehavior",["Arbiter","AvailableList","AvailableListConstants","ChatConfig","copyProperties","MercuryConstants","ChatSidebarCalloutData"],function(a,b,c,d,e,f){





var g=b('Arbiter'),
h=b('AvailableList'),
i=b('AvailableListConstants'),
j=b('ChatConfig'),

k=b('copyProperties'),

l=
b('MercuryConstants').ChatNotificationConstants,
m=
b('ChatSidebarCalloutData').isShown,

n=h.getWebChatNotification(),
o=m,
p=true,

q=k(new g(),
{ON_CHANGED:'changed',





notifiesUserMessages:function(){
return n!==l.NO_USER_MESSAGE_NOTIFICATION;},







ignoresRemoteTabRaise:function(){
return o;},






showsTabUnreadUI:function(){
if(j.get('web_messenger_suppress_tab_unread'))
return p;


return true;}});




function r(){
q.inform(q.ON_CHANGED);}


h.subscribe
(i.ON_CHAT_NOTIFICATION_CHANGED,
function(){
var s=n,
t=h.getWebChatNotification();
n=t;
if(s!=t)
r();});




g.subscribe
('chat/set_does_page_occlude_tabs',
function(s,t){
o=!!t;
r();});



g.subscribe
('chat/set_show_tab_unread_ui',
function(s,t){
p=!!t;
r();});



e.exports=q;});

/** js/mercury/utils/TimestampConverter.js */
__d("TimestampConverter",["JSLogger"],function(a,b,c,d,e,f){



var g=b('JSLogger'),

h=g.create('timestamp_converter');

function i(k){
return (typeof(k)=='string')&&k.length>6;}


var j=




{convertActionIDToTimestamp:function(k){
if(i(k)){
var l=k.slice(0,-6);
return parseInt(l,10);}},










maxValidActionID:function(k,l){
if(!i(k))






return l;


if(!i(l))
return k;


return this.isGreaterThan(k,l)?
k:
l;},







isGreaterThan:function(k,l){
if(!i(k)||!i(l))
return false;


return this.convertActionIDToTimestamp(k)>
this.convertActionIDToTimestamp(l);}};



e.exports=j;});

/** js/mercury/utils/MercuryIDs.js */
__d("MercuryIDs",[],function(a,b,c,d,e,f){



function g(i){
return typeof i==='string'&&i.indexOf(':')!==-1;}


var h=

{isValid:function(i){
if(!i)
return false;

return g(i);},


isValidThreadID:function(i){
if(!h.isValid(i))
return false;


var j=h.tokenize(i);
switch(j.type){
case 'user':
case 'group':
case 'thread':
case 'root':
case 'pending':
return true;

default:return false;
}},


tokenize:function(i){
if(!this.isValid(i))
throw 'bad_id_format';


var j=i.indexOf(':');

return {type:i.substr(0,j),
value:i.substr(j+1)};}};





e.exports=h;});

/** js/mercury/utils/MercuryAssert.js */
__d("MercuryAssert",["MercuryIDs"],function(a,b,c,d,e,f){



var g=b('MercuryIDs');

e.exports=

{isParticipantID:function(h){
if(!g.isValid(h))
throw 'bad_participant_id';},



allParticipantIDs:function(h){
h.forEach(this.isParticipantID);},


isUserParticipantID:function(h){
var i=g.tokenize(h);

if(i.type!='fbid')
throw 'bad_user_id';},



isEmailParticipantID:function(h){
var i=g.tokenize(h);

if(i.type!='email')
throw 'bad_email_id';},



allThreadID:function(h){
h.forEach(this.isThreadID);},


isThreadID:function(h){
if(!g.isValid(h))
throw 'bad_thread_id';}};});

/** js/mercury/models/MercuryMessageIDs.js */
__d("MercuryMessageIDs",["KeyedCallbackManager"],function(a,b,c,d,e,f){



var g=b('KeyedCallbackManager'),

h=new g(),

i=
{getServerIDs:function(j,k){
var l=j.filter(function(n){

return n.indexOf('mail.projektitan.com')!==-1;}),


m=function(n){
var o=j.map(function(p){

return n[p]?n[p]:p;});

k(o);};


return h.executeOrEnqueue(l,m);},


addServerID:function(j,k){
h.setResource(j,k);}};



e.exports=i;});

/** js/mercury/reliability/MessagingReliabilityLogger.js */
__d("MessagingReliabilityLogger",["function-extensions","PresenceUtil","MercuryServerDispatcher","MessagingReliabilityLoggerInitialData","isEmpty","setTimeoutAcrossTransitions"],function(a,b,c,d,e,f){
















b('function-extensions');

var g=b('PresenceUtil'),
h=b('MercuryServerDispatcher'),

i=b('MessagingReliabilityLoggerInitialData'),
j=b('isEmpty'),
k=b('setTimeoutAcrossTransitions'),

l='/ajax/mercury/client_reliability.php',
m=60000;

function n(t,u){
var v=
{app:i.app,
categories:JSON.stringify(t)};



if(!j(u))
v.extra=JSON.stringify(u);


return v;}



function o(t,u,v,w){
if(t[u]===undefined)
t[u]={};

if(t[u][v]===undefined)
t[u][v]=0;


t[u][v]+=w;}




function p(t,u,v,w){
if(t[u]===undefined)
t[u]={};

if(t[u][v]===undefined)
t[u][v]=[];


for(var x=0;x<w.length;++x)
t[u][v].push(w[x]);}



function q(t,u){
if((t&&!t.categories)||
(u&&!u.categories))



return;


var v=t?JSON.parse(t.categories):{},
w=t&&t.extra?
JSON.parse(t.extra):{},

x=JSON.parse(u.categories),
y=u.extra?
JSON.parse(u.extra):{};

for(var z in x){
var aa=x[z],
ba=y[z];

for(var ca in aa){
o
(v,
z,
ca,
aa[ca]);


if(ba!==undefined){
var da=ba[ca];
if(da!==undefined)
p
(w,
z,
ca,
da);}}}






return n(v,w);}


var r={};
r[l]=
{mode:h.BATCH_SUCCESSIVE_PIGGYBACK_ON_ERROR,
batch_function:q};

h.registerEndpoints(r);

var s=








{addEntry:function(t,u,v){

if(!i.enabled)
return;


var w={};
o(w,t,u,1);


var x={};
if(v!==undefined)
p(x,t,u,[v]);


h.trySend
(l,
n(w,x));}};







(function t(){
s.addEntry
('page_event',
'active',
g.getSessionID());

k(t,m);})
();

e.exports=s;});

/** js/mercury/models/MercuryThreadInformer.js */
__d("MercuryThreadInformer",["Arbiter","copyProperties","MercuryAssert"],function(a,b,c,d,e,f){








































var g=b('Arbiter'),
h=b('copyProperties'),

i=b('MercuryAssert'),

j={},
k={},
l={},
m=false,
n=false,
o=false,
p={},
q={},
r={},
s=0;

function t(){
if(!s){
var v=j,
w=k,
x=l,
y=m,
z=n,
aa=o,
ba=p,
ca=q,
da=r;

j={};
k={};
l={};
m=false;
n=false;
o=false;
p={};
q={};
r={};

var ea=Object.keys(w);
if(ea.length||y)
u.inform('threadlist-updated',ea);


if(ea.length)

u.inform('threads-updated',w);


for(var fa in x){
u.inform('thread-read-changed',x);
break;}


for(var fa in v){
u.inform('threads-deleted',v);
break;}


if(z)
u.inform('unseen-updated',null);


if(aa)
u.inform('unread-updated',null);


for(fa in ba){
u.inform('messages-received',ba);
break;}


for(fa in ca){
u.inform('messages-reordered',ca);
break;}


for(fa in da){
u.inform('messages-updated',da);
break;}}}




var u=h(new g(),
{updatedThread:function(v){
k[v]=true;
t();},


deletedThread:function(v){
j[v]=true;
t();},


updatedThreadlist:function(){
m=true;
t();},


updatedUnseenState:function(){
n=true;
t();},


updatedUnreadState:function(){
o=true;
t();},


changedThreadReadState:function(v,w,x){
if(!l[v]||
l[v].timestamp<x)
l[v]=
{mark_as_read:w,
timestamp:x};



t();},


receivedMessage:function(v){
i.isThreadID(v.thread_id);

var w=v.thread_id;

if(!p[w])
p[w]=[];


p[w].push(v);
u.updatedThread(w);},


reorderedMessages:function(v,w){
q[v]={source:w};
t();},


updatedMessage:function(v,w,x){
if(!r[v])
r[v]={};


r[v][w]={source:x};
t();},


synchronizeInforms:function(v){
s++;

try{v();}catch(
w){

throw w;}finally{

s--;
t();}},



listen:function(v,w){
return u.subscribe('threads-updated',function(x,y){
if(y[v])
w(v);});}});





e.exports=u;});

/** js/mercury/models/MercuryServerRequests.js */
__d("MercuryServerRequests",["Arbiter","AsyncResponse","MercuryConstants","TimestampConverter","JSLogger","KeyedCallbackManager","MercuryAssert","MercuryIDs","MercuryMessageIDs","MessagingReliabilityLogger","MercuryServerDispatcher","MercuryThreadInformer","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){






var g=b('Arbiter'),
h=b('AsyncResponse'),
i=b('MercuryConstants'),
j=b('TimestampConverter'),
k=b('JSLogger'),
l=b('KeyedCallbackManager'),
m=b('MercuryAssert'),
n=b('MercuryIDs'),
o=b('MercuryMessageIDs'),
p=b('MessagingReliabilityLogger'),
q=b('MercuryServerDispatcher'),
r=b('MercuryThreadInformer'),

s=b('copyProperties'),
t=b('createObjectFrom'),

u=i.MercuryGenericConstants,

v=0,

w=k.create('mercury_server'),


x=new l(),


y=new l(),


z=[],

aa={},
ba={},

ca=
i.MercuryAPIArgsSource&&i.MercuryAPIArgsSource.MERCURY,

da=i.MercurySendMessageTimeout;

function ea(bb){



if(bb)
v=j.maxValidActionID(v,bb);}



function fa(bb){
var cb=bb.thread_id,
db=x.getResource(cb);


if(!db){
if(bb.canonical_fbid){
db='user:'+bb.canonical_fbid;}else
if(bb.root_message_threading_id)
db='root:'+bb.root_message_threading_id;






db=db||'thread:'+cb;

ga(cb,db);}


bb.thread_id=db;}


function ga(bb,cb){
x.setResource(bb,cb);
y.setResource(cb,bb);
ba[bb]=cb;}


function ha(bb,cb){
var db=y.executeOrEnqueue(bb,cb),
eb=y.getUnavailableResources(db),

fb=ya.tokenizeThreadID(bb);




if(eb.length&&fb.type!='root')
ya.fetchThreadData(eb);}



function ia(bb){
return y.getResource(bb);}


function ja(bb){
return !!x.getResource(bb);}


function ka(bb){
var cb=x.getResource(bb);
if(typeof cb=='undefined')
w.warn
('no_client_thread_id',
{server_id:bb});


return cb;}


function la(bb,cb){
x.executeOrEnqueue(bb,cb);
ya.ensureThreadIsFetched(bb);}


function ma(bb,cb){
if(bb.action_type!=i.MercuryActionType.SEND_MESSAGE)
return;


var db=bb.client_thread_id;
if(!db)
db=ka(bb.thread_id);




var eb=null;
if(db)
eb=n.tokenize(db).type;










p.addEntry
('send_'+eb,
cb,
bb.thread_id+','+bb.message_id);}



function na(bb){
return bb.getError()?'_'+bb.getError():'';}


function oa(bb){
var cb=null;
switch(bb.status){
case i.MercuryActionStatus.SUCCESS:

cb='success';
break;
case i.MercuryActionStatus.FAILED_UNKNOWN_REASON:

cb='confirmed_error';
break;
case i.MercuryActionStatus.UNABLE_TO_CONFIRM:



cb='confirm_error';
break;




default:return;
}

ma(bb,cb);}


function pa(bb){

(bb.message_counts||[]).forEach(function(kb){
ea(kb.last_action_id);});



(bb.threads||[]).forEach(function(kb){
fa(kb);


delete aa[kb.thread_id];
delete aa[ia(kb.thread_id)];
ea(kb.last_action_id);});



(bb.ordered_threadlists||[]).forEach(function(kb){
kb.thread_ids=kb.thread_ids.map(ka);});



bb.actions=bb.actions||[];
bb.actions.forEach(function(kb){
oa(kb);



if(kb.status&&
kb.status!=i.MercuryActionStatus.SUCCESS&&
!kb.thread_id){
kb.thread_id=kb.client_thread_id;
return;}




if(kb.action_type==i.MercuryActionType.SEND_MESSAGE&&
kb.client_thread_id&&
kb.client_thread_id!=u.PENDING_THREAD_ID)
ga(kb.thread_id,kb.client_thread_id);







kb.server_thread_id=kb.thread_id;
kb.thread_id=ja(kb.thread_id)?
ka(kb.thread_id):
null;
ea(kb.action_id);});



if(bb.end_of_history){
var cb=[];

for(var db=0;db<bb.end_of_history.length;db++){
var eb=bb.end_of_history[db];

if(eb.type=='user'){
cb.push('user:'+eb.id);}else
if(eb.type=='thread'&&ja(eb.id))
cb.push(ka(eb.id));}



bb.end_of_history=cb;}



if(bb.roger){
var fb={};
for(var gb in bb.roger){
var hb=x.getResource(gb);
if(hb){
var ib=bb.roger[gb];

fb[hb]={};

for(var jb in ib)
fb[hb]['fbid:'+jb]=ib[jb];}}




bb.roger=fb;}}



function qa(){
if(z&&z.length){
var bb=z[0];
z=z.slice(1);
ya.handleUpdate(bb);}}



function ra(bb,cb){
var db=s({},bb),
eb;

if(cb.threads){
if(!db.threads)
db.threads={};

for(eb in cb.threads)

db.threads[eb]=Object.keys
(t((db.threads[eb]||[]).concat
(cb.threads[eb])));}





if(cb.messages){
if(!db.messages)
db.messages={};

for(eb in cb.messages){
if(!db.messages[eb])
db.messages[eb]={};

for(var fb in cb.messages[eb])
if(db.messages[eb][fb]){
db.messages[eb][fb]=ua
(db.messages[eb][fb],
cb.messages[eb][fb]);}else 


db.messages[eb][fb]=cb.messages[eb][fb];}}





db.client=bb.client||cb.client;

return db;}


function sa(bb,cb){
var db=s
(t(bb.folders,true),
t(cb.folders,true)),

eb=bb.client||cb.client;
return {folders:Object.keys(db),client:eb};}







function ta(bb,cb){
for(var db in cb)
if(bb[db]&&typeof bb[db]==='object'){
bb[db]=ua
(bb[db],
cb[db]);}else

if(cb[db]&&typeof cb[db]==='object'){
var eb={};
s(eb,cb[db]);
bb[db]=eb;}



return bb;}





function ua(bb,cb){
var db=bb.offset<cb.offset?
bb.offset:
cb.offset,
eb=bb.offset+bb.limit,
fb=cb.offset+cb.limit,
gb=(eb>fb)?
eb:
fb,
hb=gb-db;


return {offset:db,
limit:hb};}



function va(bb,cb){
var db=bb.client||cb.client,
eb={ids:{},client:db};
s(eb.ids,bb.ids);
s(eb.ids,cb.ids);
return eb;}







function wa(bb,cb){
var db={},
eb,
fb=bb.client||cb.client;
delete bb.client;
delete cb.client;


for(eb in bb)

s
(db,
t(bb[eb],eb));



for(eb in cb)
s
(db,
t(cb[eb],eb));




var gb={client:fb};
for(var hb in db){
eb=db[hb];
if(!gb[eb])
gb[eb]=[];

gb[eb].push(hb);}


return gb;}


function xa(bb,cb){
var db=bb.client||cb.client,
eb=t(bb.ids,true),
fb=t(cb.ids,true),
gb=s(eb,fb);
return {ids:Object.keys(gb),client:db};}


var ya=s(new g(),
{tokenizeThreadID:function(bb){
m.isThreadID(bb);
return n.tokenize(bb);},







getServerThreadID:function(bb,cb){
m.isThreadID(bb);
ha(bb,cb);},


getClientThreadID:function(bb,cb){
la(bb,cb);},


getClientThreadIDNow:function(bb){
return ka(bb);},


getServerThreadIDNow:function(bb){
return ia(bb);},











convertThreadIDIfAvailable:function(bb){
var cb=x.getResource(bb);

if(cb===undefined){
return bb;}else 

return cb;},







canLinkExternally:function(bb){
m.isThreadID(bb);

var cb=ya.tokenizeThreadID(bb);
return (cb.type=='user')||
!!ia(bb);},













fetchThreadlistInfo:function(bb,cb,db,eb,fb){
db=db||i.MessagingTag.INBOX;
fb=fb||ca;
var gb=eb?q.IMMEDIATE:null,
hb={client:fb};
hb[db]=
{offset:bb,
limit:cb,
filter:eb};


q.trySend('/ajax/mercury/threadlist_info.php',hb,gb);},


fetchUnseenThreadIDs:function(bb,cb){
cb=cb||ca;



ya.fetchThreadlistInfo
(i.MercuryThreadlistConstants.RECENT_THREAD_OFFSET,
i.MercuryThreadlistConstants.JEWEL_THREAD_COUNT,
bb,
null,
cb);},



fetchUnreadThreadIDs:function(bb,cb){
cb=cb||ca;
q.trySend
('/ajax/mercury/unread_threads.php',
{folders:[bb],client:cb});},



fetchMissedMessages:function(bb,cb){
cb=cb||ca;
q.trySend
('/ajax/mercury/thread_sync.php',

{last_action_id:v,
folders:bb,
client:cb});},




fetchThreadData:function(bb,cb){
cb=cb||ca;
m.allThreadID(bb);











var db={threads:{},client:cb},
eb=[],
fb=[],
gb=[];

bb.forEach(function(ib){
if(aa[ib])
return;


aa[ib]=true;

var jb=ia(ib);
if(jb){
fb.push(jb);
db.threads.thread_ids=fb;}else{

var kb=ya.tokenizeThreadID(ib);
if(kb.type=='user'){
eb.push(kb.value);
db.threads.user_ids=eb;}else
if(kb.type=='group'){
gb.push(kb.value);
db.threads.group_ids=gb;}else
if(kb.type=='thread'){
fb.push(kb.value);
db.threads.thread_ids=fb;}else
if(kb.type!='root'&&
kb.type!='pending')

throw new Error('Unknown thread type',kb);}});




ya.inform("fetch-thread-data",db);

for(var hb in db.threads){
q.trySend('/ajax/mercury/thread_info.php',db);
break;}},






ensureThreadIsFetched:function(bb,cb){
cb=cb||ca;
if(!x.getResource(bb)&&
!aa[bb]){
aa[bb]=true;
q.trySend
('/ajax/mercury/thread_info.php',
{threads:{thread_ids:[bb]},client:cb});}},













fetchThreadMessages:function(bb,cb,db,eb,fb){
m.isThreadID(bb);
fb=fb||ca;
var gb,
hb,




ib=ya.tokenizeThreadID(bb),
jb=ia(bb),
kb=false;
if(jb&&ib.type!='group'){
hb='thread_ids';
gb=jb;}else{

gb=ib.value;
switch(ib.type){
case 'user':
hb='user_ids';
kb=true;
break;
case 'group':
hb='group_ids';
break;
case 'thread':
hb='thread_ids';
break;}}


var lb={messages:{},threads:{},client:fb};
if(hb){
lb.messages[hb]={};
lb.messages[hb][gb]=
{offset:cb,
limit:db};


if(kb)



lb.threads[hb]=[gb];


q.trySend
('/ajax/mercury/thread_info.php',
lb,
eb);}else 


ha(bb,function(mb){
lb.messages.thread_ids={};
lb.messages.thread_ids[mb]=
{offset:cb,
limit:db};

q.trySend
('/ajax/mercury/thread_info.php',
lb,
eb);});},





handleThreadInfoError:function(bb){
var cb=bb.getRequest().getData(),



db=[];
if(cb.messages){

for(var eb in cb.messages.thread_ids)
db.push(za
(ka(eb)));


for(var fb in cb.messages.user_ids)
db.push(za('user:'+fb));

for(var gb in cb.messages.group_ids)
db.push(za('group:'+gb));}



if(db.length)
ya.handleUpdate

({actions:db,
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});







if(cb.threads&&
(cb.threads.user_ids||
cb.threads.group_ids||
cb.threads.thread_ids)&&
!cb.is_retry){


if(cb.messages)
delete cb.messages;


w.log('retry_thread',cb);
cb.is_retry=true;
q.trySend
('/ajax/mercury/thread_info.php',
cb);}},




markFolderAsRead:function(bb){

q.trySend
('/ajax/mercury/mark_folder_as_read.php',
{folder:bb});



var cb=
[{action_type:i.MercuryGlobalActionType.MARK_ALL_READ,
action_id:null,
folder:bb}];


ya.handleUpdate
({global_actions:cb,
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_READ_STATUS});},



changeThreadReadStatus:function(bb,cb,db){
m.isThreadID(bb);

ha(bb,function(fb){
var gb={ids:{}};
gb.ids[fb]=cb;


q.trySend
('/ajax/mercury/change_read_status.php',
gb);});



var eb=
[{action_type:i.MercuryActionType.CHANGE_READ_STATUS,
action_id:null,
thread_id:bb,
mark_as_read:cb,
folder:db}];




ya.handleUpdate
({actions:eb,
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_READ_STATUS});},



changeThreadArchivedStatus:function(bb,cb){
m.isThreadID(bb);

ha(bb,function(fb){

var gb={ids:{}};
gb.ids[fb]=cb;
q.trySend
('/ajax/mercury/change_archived_status.php',
gb);});




var db=
{action_type:i.MercuryActionType.CHANGE_ARCHIVED_STATUS,
action_id:null,
thread_id:bb,
archived:cb},

eb=
{actions:[db],
from_client:true,
payload_source:
i.MercuryPayloadSource.CLIENT_CHANGE_ARCHIVED_STATUS};

ya.handleUpdate(eb);},


changeThreadFolder:function(bb,cb){
m.isThreadID(bb);


ha(bb,function(fb){
var gb={};
gb[cb]=[fb];
q.trySend
('/ajax/mercury/move_thread.php',
gb);});




var db=
{action_type:i.MercuryActionType.CHANGE_FOLDER,
action_id:null,
thread_id:bb,
new_folder:cb},

eb=
{actions:[db],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_FOLDER};

ya.handleUpdate(eb);},


changeMutingOnThread:function(bb,cb){
m.isThreadID(bb);

ha(bb,function(fb){
q.trySend
('/ajax/mercury/change_mute_thread.php',
{thread_id:fb,
mute_settings:cb,
payload_source:i.MercuryAPIArgsSource.MERCURY});});



var db=
{action_type:i.MercuryActionType.CHANGE_MUTE_SETTINGS,
action_id:null,
thread_id:bb,
mute_settings:cb},

eb=
{actions:[db],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_MUTE_SETTINGS};

ya.handleUpdate(eb);},


markThreadSpam:function(bb){
m.isThreadID(bb);

ha(bb,function(eb){
q.trySend
('/ajax/mercury/mark_spam.php',
{id:eb});});




var cb=
{action_type:i.MercuryActionType.CHANGE_FOLDER,
action_id:null,
thread_id:bb,
new_folder:i.MessagingTag.SPAM},

db=
{actions:[cb],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_FOLDER};

ya.handleUpdate(db);},


markMessagesSpam:function(bb,cb){
o.getServerIDs(cb||[],function(eb){
q.trySend
('/ajax/mercury/mark_spam_messages.php',
{message_ids:eb});});






var db=
{action_type:i.MercuryActionType.DELETE_MESSAGES,
action_id:null,
thread_id:bb,
message_ids:cb};

ya.handleUpdate
({actions:[db],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_DELETE_MESSAGES});},



unmarkThreadSpam:function(bb){
m.isThreadID(bb);

ha(bb,function(eb){
q.trySend
('/ajax/mercury/unmark_spam.php',
{id:eb});});




var cb=
{action_type:i.MercuryActionType.CHANGE_FOLDER,
action_id:null,
thread_id:bb,
new_folder:i.MessagingTag.INBOX},

db=
{actions:[cb],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CHANGE_FOLDER};

ya.handleUpdate(db);},


deleteThread:function(bb){
m.isThreadID(bb);


ha(bb,function(eb){
var fb={ids:[eb]};
q.trySend
('/ajax/mercury/delete_thread.php',
fb);});




var cb=
{action_type:i.MercuryActionType.DELETE_THREAD,
action_id:null,
thread_id:bb},

db=
{actions:[cb],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_DELETE_THREAD};

ya.handleUpdate(db);},


deleteMessages:function(bb,cb,db){


o.getServerIDs(cb||[],function(fb){
q.trySend
('/ajax/mercury/delete_messages.php',
{message_ids:fb});});




var eb;
if(db){


eb=
{action_type:i.MercuryActionType.DELETE_THREAD,
action_id:null,
thread_id:bb};}else 


eb=
{action_type:i.MercuryActionType.DELETE_MESSAGES,
action_id:null,
thread_id:bb,
message_ids:cb};


ya.handleUpdate
({actions:[eb],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_DELETE_MESSAGES});},







clearChat:function(bb,cb,db){
m.isThreadID(bb);


q.trySend
('/ajax/chat/settings.php',
{clear_history_id:cb});


var eb=
[{action_type:i.MercuryActionType.CLEAR_CHAT,
action_id:null,
thread_id:bb,
clear_time:db}];


ya.handleUpdate
({actions:eb,
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_CLEAR_CHAT});},



_batchThreadRead:function(bb,cb){
var db={};
s(db,bb.ids);
s(db,cb.ids);
var eb=bb.client||cb.client;
return {ids:db,client:eb};},


sendNewMessage:function(bb,cb){
cb=cb||ca;


o.getServerIDs(bb.forward_message_ids||[],function(eb){
var fb=ya.tokenizeThreadID(bb.thread_id),
gb=fb.type,
hb=s({},bb);
hb.forward_message_ids=eb;

if((gb=='root'&&fb.value==hb.message_id)||
(gb=='user'&&!ia(bb.thread_id))||
(bb.thread_id==u.PENDING_THREAD_ID)){







hb.client_thread_id=hb.thread_id;
hb.thread_id=null;
ya._sendNewMessageToServer(hb,cb);}else 



ha(hb.thread_id,function(ib){
hb.thread_id=ib;
ya._sendNewMessageToServer(hb);});});





if(bb.thread_id!=u.PENDING_THREAD_ID){
var db=
{actions:[s({},bb)],
from_client:true,
payload_source:i.MercuryPayloadSource.CLIENT_SEND_MESSAGE};

ya.handleUpdate(db);}},



_sendNewMessageToServer:function(bb,cb){
cb=cb||ca;
q.trySend
('/ajax/mercury/send_messages.php',
{message_batch:[bb],client:cb});},



_batchMessageSend:function(bb,cb){
var db=bb.client||cb.client;

return {client:db,
message_batch:bb.message_batch.concat(cb.message_batch)};},





requestMessageConfirmation:function(bb,cb){


cb=cb||ca;
var db={},
eb={};
for(var fb in bb){
var gb=ia(fb);

if(gb){
db[gb]=bb[fb];}else{



var hb=bb[fb];
for(var ib=0;ib<hb.length;ib++)
eb[hb[ib]]=fb;}}




var jb=Object.keys(db),

kb=Object.keys(eb);
if(jb.length||kb.length)
q.trySend
('/ajax/mercury/confirm_messages.php',
{thread_message_map:db,
local_messages:eb,
client:cb});},





handleMessageConfirmError:function(bb){
var cb=bb.getRequest().getData().thread_message_map,
db=bb.getRequest().getData().local_messages;
if(!cb&&!db)

return;




var eb=[];
for(var fb in cb){
var gb=cb[fb];
gb.forEach(function(jb){
eb.push
({action_type:i.MercuryActionType.SEND_MESSAGE,
client_message_id:jb,
message_id:jb,
client_thread_id:null,
thread_id:fb,
status:i.MercuryActionStatus.UNABLE_TO_CONFIRM});});}




for(var hb in db){
var ib=db[hb];
eb.push
({action_type:i.MercuryActionType.SEND_MESSAGE,
client_message_id:hb,
message_id:hb,
client_thread_id:ib,
thread_id:null,
status:i.MercuryActionStatus.UNABLE_TO_CONFIRM});}



if(eb.length)
ya.handleUpdate
({actions:eb,
payload_source:i.MercuryPayloadSource.CLIENT_HANDLE_ERROR});},




markSeen:function(){


var bb=
j.convertActionIDToTimestamp(v);


q.trySend
('/ajax/mercury/mark_seen.php',
{seen_timestamp:bb});},


_batchMarkSeen:function(bb,cb){

return cb;},


handleRoger:function(bb){
var cb=bb.tid?
x.getResource(bb.tid):
('user:'+bb.reader);




if(cb){
var db={};
db[cb]={};
db[cb]['fbid:'+bb.reader]=bb.time;
ya.inform('update-roger',db);}},










handleUpdateWaitForThread:function(bb,cb,db){

db=db||ca;
var eb=x.getResource(cb);
if(eb){
ya.handleUpdate(bb);
return;}


x.executeOrEnqueue
(cb,
function(){
z.push(bb);});



if(!aa[cb]){
aa[cb]=true;
q.trySend
('/ajax/mercury/thread_info.php',
{threads:{thread_ids:[cb]},client:db});}},






handleUpdate:function(bb){
w.debug('handle_update',
{payload:bb,
from_client:bb.from_client});


for(var cb in bb){
r.synchronizeInforms(function(){
if(!bb.from_client){
pa(bb);
ya.inform('payload-preprocessed',bb);}





ya.inform('update-thread-ids',ba);
ba={};

ya.inform('update-participants',bb);
ya.inform('update-threads',bb);



ya.inform('update-unread',bb);
ya.inform('update-threadlist',bb);

ya.inform('update-messages',bb);
ya.inform('update-unseen',bb);

ya.inform('update-typing-state',bb);

ya.inform('update-roger',bb.roger);



ya.inform('model-update-completed',null);

qa();});


break;}},





_handleSendMessageErrorCommon:
function(bb,
cb,
db,
eb){
w.debug
('handle_send_message_error_common',
{reliability_error_status:db,
request_error_status:cb});

var fb=bb.getData(),
gb=fb.message_batch,

hb=gb.map(function(jb){

return {action_type:i.MercuryActionType.SEND_MESSAGE,
client_message_id:jb.message_id,
message_id:jb.message_id,
client_thread_id:jb.client_thread_id,
thread_id:jb.thread_id,
status:cb,
error_data:eb};});



hb.forEach(function(jb){
ma(jb,db);});



var ib=
{actions:hb,
payload_source:i.MercuryPayloadSource.CLIENT_HANDLE_ERROR};




ya.handleUpdate(ib);},


handleSendMessageError:function(bb){
var cb=bb.getPayload(),
db=null,
eb=null;
if(cb&&cb.error_payload){





db=i.MercuryActionStatus.UNCONFIRMED;
eb='send_error';}else{




db=i.MercuryActionStatus.ERROR;
eb=
'request_error'+na(bb);}



var fb=bb.error;
if(fb===1404074||
fb===1404099)
h.verboseErrorHandler(bb);



var gb=/<.*>/.test(bb.getErrorDescription())?
bb.getErrorSummary():
bb.getErrorDescription();
ya._handleSendMessageErrorCommon
(bb.getRequest(),
db,
eb,

{type:i.MercuryErrorType.SERVER,
code:bb.getError(),
description:gb,
is_transient:bb.isTransient()});},




handleSendMessageTransportError:function(bb){


ya._handleSendMessageErrorCommon
(bb.getRequest(),
i.MercuryActionStatus.ERROR,
'transport_error'+na(bb),

{type:i.MercuryErrorType.TRANSPORT,
code:bb.getError(),
is_transient:true});},




handleSendMessageTimeout:function(bb){

ya._handleSendMessageErrorCommon
(bb,
i.MercuryActionStatus.ERROR,
'transport_timeout',
{type:i.MercuryErrorType.TIMEOUT,is_transient:true});},



getLastActionID:function(){
return v;}});



function za(bb){

return {action_type:i.MercuryActionType.LOG_MESSAGE,
thread_id:bb,
message_id:bb,
timestamp:Date.now(),
timestamp_absolute:'',
timestamp_relative:'',
is_unread:false,
source:i.MercurySourceType.UNKNOWN,
log_message_type:i.MercuryLogMessageType.SERVER_ERROR,
log_message_data:{}};}




var ab=ya.handleUpdate;

q.registerEndpoints
({'/ajax/mercury/thread_sync.php':
{mode:q.IDEMPOTENT,
handler:ab},

'/ajax/mercury/thread_info.php':
{mode:q.BATCH_DEFERRED_MULTI,
batch_function:ra,
handler:ab,
error_handler:ya.handleThreadInfoError},

'/ajax/mercury/mark_folder_as_read.php':
{mode:q.IMMEDIATE,
handler:ab},

'/ajax/mercury/change_read_status.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:ya._batchThreadRead,
handler:ab},

'/ajax/mercury/send_messages.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:ya._batchMessageSend,
batch_size_limit:i.MessagingConfig.SEND_BATCH_LIMIT,
handler:ab,
error_handler:ya.handleSendMessageError,
transport_error_handler:
ya.handleSendMessageTransportError,
timeout:da,
timeout_handler:ya.handleSendMessageTimeout,
connection_retries:i.MessagingConfig.SEND_CONNECTION_RETRIES},

'/ajax/mercury/mark_seen.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:ya._batchMarkSeen,
handler:ab},

'/ajax/mercury/confirm_messages.php':
{mode:q.IMMEDIATE,
handler:ab,
error_handler:ya.handleMessageConfirmError},

'/ajax/mercury/threadlist_info.php':
{mode:q.BATCH_SUCCESSIVE_UNIQUE,
batch_function:ta,
handler:ab},

'/ajax/mercury/mark_spam.php':
{mode:q.IMMEDIATE,
handler:ab},

'/ajax/mercury/mark_spam_messages.php':
{mode:q.IMMEDIATE,
handler:ab},

'/ajax/mercury/unmark_spam.php':
{mode:q.IMMEDIATE,
handler:ab},

'/ajax/mercury/unread_threads.php':
{mode:q.BATCH_SUCCESSIVE_UNIQUE,
batch_function:sa,
handler:ab},

'/ajax/chat/settings.php':
{mode:q.IMMEDIATE},

'/ajax/mercury/change_archived_status.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:va,
handler:ab},

'/ajax/mercury/delete_thread.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:xa,
handler:ab},

'/ajax/mercury/delete_messages.php':
{mode:q.IMMEDIATE,
handler:ab},

'/ajax/mercury/move_thread.php':
{mode:q.BATCH_SUCCESSIVE,
batch_function:wa,
handler:ab},

'/ajax/mercury/change_mute_thread.php':
{mode:q.IMMEDIATE,
handler:ab}});



e.exports=ya;});

/** js/mercury/utils/MercuryFolders.js */
__d("MercuryFolders",["array-extensions","MercuryConstants"],function(a,b,c,d,e,f){



b('array-extensions');

var g=b('MercuryConstants'),

h=
[g.MessagingTag.INBOX,
g.MessagingTag.OTHER,
g.MessagingTag.ACTION_ARCHIVED,
g.MessagingTag.SPAM],


i=
{getSupportedFolders:function(){
return h.concat();},


isSupportedFolder:function(j){
return h.contains(j);},


getFromMeta:function(j){
var k=j.folder;
if(j.is_archived)
k=g.MessagingTag.ACTION_ARCHIVED;


return k;}};



e.exports=i;});

/** js/mercury/utils/MercuryAttachment.js */
__d("MercuryAttachment",["MercuryConstants","startsWith"],function(a,b,c,d,e,f){



var g=b('MercuryConstants'),

h=b('startsWith'),




i=





{getAttachIconClass:function(j){
switch(j){
case g.MercuryAttachmentContentType.PHOTO:
return 'MercuryPhotoIcon';
case g.MercuryAttachmentContentType.VIDEO:
return 'MercuryVideoIcon';
case g.MercuryAttachmentContentType.MUSIC:
return 'MercuryMusicIcon';
case g.MercuryAttachmentContentType.VOICE:
return 'MercuryVoiceIcon';
case g.MercuryAttachmentContentType.TEXT:
return 'MercuryTextIcon';
case g.MercuryAttachmentContentType.MSWORD:
return 'MercuryMSWordIcon';
case g.MercuryAttachmentContentType.MSXLS:
return 'MercuryMSXLSIcon';
case g.MercuryAttachmentContentType.MSPPT:
return 'MercuryMSPPTIcon';}

return 'MercuryDefaultIcon';},






getAttachIconClassByMime:function(j){
if(h(j,'image')){
return 'MercuryPhotoIcon';}else
if(h(j,'video')){
return 'MercuryVideoIcon';}else
if(h(j,'audio')){
return 'MercuryMusicIcon';}else
if(h(j,'text/plain')){
return 'MercuryTextIcon';}else 

return 'MercuryDefaultIcon';},






getAttachTypeByMime:function(j){
if(h(j,'image')){
return g.MercuryAttachmentContentType.PHOTO;}else
if(h(j,'video')){
return g.MercuryAttachmentContentType.VIDEO;}else
if(h(j,'audio')){
return g.MercuryAttachmentContentType.MUSIC;}else
if(h(j,'text/plain')){
return g.MercuryAttachmentContentType.TEXT;}else 

return g.MercuryAttachmentContentType.UNKNOWN;},







convertRaw:function(j){
var k=[];
for(var l=0;l<j.length;l++){
var m=j[l];
if(m.filename){
var n={};
n.attach_type=g.MercuryAttachmentType.FILE;
n.name=m.filename;
n.icon_type=i.getAttachTypeByMime(m.filetype);
n.url='';
k.push(n);}}


return k;}};



e.exports=i;});

/** js/mercury/models/MercuryParticipants.js */
__d("MercuryParticipants",["MercuryConstants","Env","MercuryAssert","MercuryIDs","MercuryServerRequests","ShortProfiles","copyProperties","getObjectValues","tx"],function(a,b,c,d,e,f){



var g=b('MercuryConstants'),
h=b('Env'),
i=b('MercuryAssert'),
j=b('MercuryIDs'),
k=b('MercuryServerRequests'),
l=b('ShortProfiles'),

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

p='fbid:'+h.user,
q={},
r={},

s=function(w){
w=u(w);

if(!q[w.id]){
q[w.id]=m({},w);
if(w.vanity)
r[w.vanity]=w.id;}};




function t(w){
i.isEmailParticipantID(w);

var x=j.tokenize(w),
y=x.value;


return {gender:g.MercuryParticipantsConstants.UNKNOWN_GENDER,
href:null,
id:w,
image_src:g.MercuryParticipantsConstants.EMAIL_IMAGE,
name:y,
short_name:y,
employee:false,
call_promo:false};}









function u(w){
var x=w.type===g.MercuryParticipantTypes.USER||
w.type===g.MercuryParticipantTypes.FRIEND;

if(!x)
return w;


if(!w.name&&!w.href&&!w.vanity){
var y="Facebook User";

w.name=y;
w.short_name=y;}


return w;}


var v=
{user:p,

getIDFromVanityOrFBID:function(w){
if(!w)
return;

if(r[w])
return r[w];

if(w.match('^\\d+$'))

return v.getIDForUser(w);},



getNow:function(w){
return q[w];},


get:function(w,x){
i.isParticipantID(w);

v.getMulti([w],function(y){
x(y[w]);});},








getMulti:function(w,x){
i.allParticipantIDs(w);

var y={},
z={};
w.forEach(function(ba){
if(q[ba]){
y[ba]=
m({},q[ba]);}else{

var ca=j.tokenize(ba);
if(ca.type=='fbid'){
var da=ca.value;
z[ba]=da;}else
if(ca.type=='email')
y[ba]=t(ba);}});




var aa=n(z);
if(aa.length){
l.getMulti(aa,function(ba){
for(var ca in z){
var da=z[ca],
ea=ba[da];

y[ca]=
{gender:ea.gender,
href:ea.uri,
id:ca,
image_src:ea.thumbSrc,
name:ea.name,
short_name:ea.firstName,
employee:ea.employee,
call_promo:ea.showVideoPromo,
type:ea.type,
vanity:ea.vanity};


s(y[ca]);}


x(y);});}else 


x(y);},






getUserID:function(w){
if(!j.isValid(w))
return null;


var x=j.tokenize(w);
if(x.type!='fbid')
return null;


return x.value;},


getIDForUser:function(w){
return 'fbid:'+w;},


addParticipants:function(w){
w.forEach(s);}};




k.subscribe('update-participants',function(w,x){
v.addParticipants(x.participants||[]);});


e.exports=v;});

/** js/mercury/models/MercuryThreads.js */
__d("MercuryThreads",["Arbiter","MercuryConfig","MercuryConstants","TimestampConverter","Env","MercuryFolders","JSLogger","KeyedCallbackManager","MercuryAssert","MercuryAttachment","MercuryIDs","MercuryParticipants","MercuryServerRequests","MercuryThreadInformer","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){






















var g=b('Arbiter'),
h=b('MercuryConfig'),
i=b('MercuryConstants'),
j=b('TimestampConverter'),
k=b('Env'),
l=b('MercuryFolders'),
m=b('JSLogger'),
n=b('KeyedCallbackManager'),
o=b('MercuryAssert'),
p=b('MercuryAttachment'),
q=b('MercuryIDs'),
r=b('MercuryParticipants'),
s=b('MercuryServerRequests'),
t=b('MercuryThreadInformer'),

u=b('copyProperties'),
v=b('createObjectFrom'),

w=m.create('mercury_threads'),
x={};





function y(ka,la){
var ma=
v(ka.participants,true),
na=r.user;

la.forEach(function(oa){
if(ma[oa]!==true){
ka.participants.push(oa);

if(oa===na)
ka.is_subscribed=true;}});}









function z(ka,la){
ka.participants.remove(la);
if(la===r.user)
ka.is_subscribed=false;}






function aa(ka,la){
if(ka.participants[0]!=la){
ka.participants.remove(la);
ka.participants.unshift(la);}}



function ba(ka,la){

var ma=la.body,
na=la.subject,

oa='';
if(na){
na=na.toLowerCase();
if(ma.slice(0,na.length).toLowerCase()==na){


oa=ma;}else
if(ma){

oa=na+' \u00B7 '+ma;}else 


oa=na;}else 


oa=ma;


ka.snippet=oa;
ka.snippet_has_attachment=la.has_attachment;
if(la.raw_attachments&&
la.raw_attachments.length>0){
var pa=p.convertRaw
(la.raw_attachments);

ka.snippet_attachments=pa;}else 

ka.snippet_attachments=la.attachments;

ka.is_forwarded_snippet=!!la.forward_count;
ka.snippet_sender=la.author;}








function ca
(ka,
la){

if(!ka)
return false;


var ma=!ka.unread_count;
if(la==ma)
return false;


ka.unread_count=la?0:1;
t.updatedThread(ka.thread_id);

return true;}


function da(ka,la){
var ma=ka._threads.getAllResources();

for(var na in ma){
var oa=ma[na];
if(oa.folder==la){
oa.unread_count=0;

ka._threads.setResource(na,oa);
t.updatedThread(na);}}}




function ea(ka,la){
if(!ka||ka.chat_clear_time===la)
return false;


ka.chat_clear_time=la;

t.reorderedMessages(ka.thread_id);

return true;}






function fa(ka,la,ma){
var na=la.action_type;
if(na==i.MercuryActionType.USER_GENERATED_MESSAGE||
na==i.MercuryActionType.LOG_MESSAGE){
la.is_unread&&ka.unread_count++;
ka.message_count++;

ka.is_archived=false;}


switch(na){
case i.MercuryActionType.USER_GENERATED_MESSAGE:
aa(ka,la.author);

break;
case i.MercuryActionType.SEND_MESSAGE:
var oa=la.log_message_type;


if(oa==i.MercuryLogMessageType.THREAD_IMAGE)
ka.image_src=la.log_message_data.image?
la.log_message_data.image.preview_url:null;


ka.snippet_attachments=la.attachments;
break;
case i.MercuryActionType.LOG_MESSAGE:
var oa=la.log_message_type;
if(oa==i.MercuryLogMessageType.SUBSCRIBE){
y
(ka,
la.log_message_data.added_participants);}else

if(oa==i.MercuryLogMessageType.UNSUBSCRIBE){
z
(ka,
la.author);}else

if(oa==i.MercuryLogMessageType.THREAD_IMAGE){


if(!ma)
ka.image_src=la.log_message_data.image?
la.log_message_data.image.preview_url:null;}else

if(oa==i.MercuryLogMessageType.THREAD_NAME)
ka.name=la.log_message_data.name;


break;
case i.MercuryActionType.CHANGE_READ_STATUS:
if(la.timestamp)
t.changedThreadReadState
(ka.thread_id,la.mark_as_read,la.timestamp);



ca(ka,la.mark_as_read);
break;
case i.MercuryActionType.CLEAR_CHAT:
ea(ka,la.clear_time);
break;
case i.MercuryActionType.CHANGE_ARCHIVED_STATUS:
ka.is_archived=la.archived;
break;
case i.MercuryActionType.CHANGE_FOLDER:
ka.folder=la.new_folder;
break;
case i.MercuryActionType.DELETE_MESSAGES:
if(ma){


ka.snippet='...';
ka.snippet_has_attachment=false;
ka.snippet_attachments=null;
ka.snippet_sender=null;
ka.is_forwarded_snippet=false;
t.updatedThread(la.thread_id);}else 


if(la.message_ids)
ka.message_count=ka.message_count-
la.message_ids.length;


break;
case i.MercuryActionType.CHANGE_MUTE_SETTINGS:
if(h.MuteThreadsOnDesktopGK&&
la.mute_settings!==undefined){
var pa=r.user.split(":")[1]+'@facebook.com';
if(ka.mute_settings){
if(la.mute_settings){
ka.mute_settings[pa]=la.mute_settings;}else 

delete ka.mute_settings[pa];

t.updatedThread(ka.thread_id);}}


break;}






if(la.action_id)
ka.last_action_id=j.maxValidActionID
(la.action_id,
ka.last_action_id);}




function ga(ka){
var la=s.tokenizeThreadID(ka.thread_id);



if(la.type=='group'){
w.error('invalid_new_thread_message',ka);
return undefined;}


var ma=
{thread_id:ka.thread_id,
last_action_id:ka.action_id,
participants:ka.specific_to_list,
name:null,
snippet:ka.body,
snippet_has_attachment:false,
snippet_attachments:[],
snippet_sender:ka.author,
unread_count:0,
message_count:0,
image_src:null,
timestamp_absolute:ka.timestamp_absolute,
timestamp_relative:ka.timestamp_relative,
timestamp:ka.timestamp,
canonical_fbid:la.type=='user'?la.value:null,
is_canonical_user:la.type=='user',
is_canonical:ia(ka.specific_to_list),
is_subscribed:true,
root_message_threading_id:ka.message_id,
folder:i.MessagingTag.INBOX,
is_archived:false,
mode:i.MercuryThreadMode.TITAN_ORIGINATED};


return ma;}


function ha(ka){
this._fbid=ka;


this._threads=new n();

ja(this);}


u(ha.prototype,




{getThreadMetaNow:function(ka){
o.isThreadID(ka);
return this._threads.getResource(ka);},















getThreadMeta:function(ka,la,ma){
o.isThreadID(ka);

var na=this._threads.executeOrEnqueue(ka,la),
oa=this._threads.getUnavailableResources(na);

if(oa.length){


var pa=s.tokenizeThreadID(ka);
if(pa.type=='user'){

this.getCanonicalThreadToUser(pa.value);}else 

s.fetchThreadData(oa,ma);}



return na;},





unsubscribe:function(ka){
this._threads.unsubscribe(ka);},






changeThreadReadStatus:function(ka,la){
o.isThreadID(ka);
var ma=this._threads.getResource(ka);

if(ca(ma,la))
s.changeThreadReadStatus
(ka,
la,
l.getFromMeta(ma));},




changeThreadArchivedStatus:function(ka,la){
o.isThreadID(ka);
var ma=this._threads.getResource(ka);

if(ma.is_archived!=la){
ma.is_archived=la;
t.updatedThread(ma.thread_id);
s.changeThreadArchivedStatus
(ka,
la);}},




markThreadSpam:function(ka){
s.markThreadSpam(ka);},


unmarkThreadSpam:function(ka){
s.unmarkThreadSpam(ka);},



updateThreadMuteSetting:function(ka,la){
s.changeMutingOnThread(ka,la);},





changeFolder:function(ka,la){
o.isThreadID(ka);
var ma=this._threads.getResource(ka);

if(ma&&ma.folder!=la){
ma.folder=la;
t.updatedThread(ma.thread_id);
s.changeThreadFolder
(ka,
la);}},







deleteThread:function(ka){
o.isThreadID(ka);
s.deleteThread(ka);},






updateThreads:function(ka){
if(!ka||!ka.length)
return;


var la={};

ka.forEach(function(ma){
la[ma.thread_id]=ma;});



this._threads.addResourcesAndExecute(la);},


updateMetadataByActions:function(ka,la){
if(!ka||!ka.length)
return;


var ma={},
na={},
oa={};
for(var pa=0;pa<ka.length;pa++){
var qa=ka[pa];



if(qa.is_forward)
continue;


var ra=qa.action_type,
sa=qa.thread_id;
o.isThreadID(sa);
var ta=this.getThreadMetaNow(sa);


if(ra==i.MercuryActionType.LOG_MESSAGE&&
qa.log_message_type==
i.MercuryLogMessageType.SERVER_ERROR)
continue;





if(!ta&&!qa.action_id&&
ra==i.MercuryActionType.USER_GENERATED_MESSAGE){
ta=ga(qa);
this._threads.setResource(sa,ta);}




if(ta){
if(ra==i.MercuryActionType.DELETE_THREAD){
ta.message_count=0;



t.deletedThread(sa);
continue;}






var ua=!!qa.action_id;
if(ra==i.MercuryActionType.LOG_MESSAGE||
ra==i.MercuryActionType.USER_GENERATED_MESSAGE)
ua=!la;


if(qa.timestamp<=ta.timestamp&&ua)
continue;


if(!oa[sa])

oa[sa]=u({},ta);


fa(oa[sa],qa,la);

if(ra==i.MercuryActionType.USER_GENERATED_MESSAGE)
ma[sa]=qa;




if(ra==i.MercuryActionType.USER_GENERATED_MESSAGE||
ra==i.MercuryActionType.LOG_MESSAGE||
ra==i.MercuryActionType.SEND_MESSAGE)


if(qa&&qa.timestamp&&
(!na[sa]||
qa.timestamp>na[sa].timestamp))
na[sa]=qa;}}





for(var va in oa){
var wa=oa[va],



xa=ma[va];
if(xa)
ba(wa,xa);






var ya=na[va],
za=wa.timestamp;
if(ya&&ya.timestamp>za)
wa=u
(wa,

{timestamp_absolute:ya.timestamp_absolute,
timestamp_relative:ya.timestamp_relative,
timestamp:ya.timestamp});




this._threads.setResource(va,wa);}},







getCanonicalThreadToUser:function(ka,la,ma){
return this.getCanonicalThreadToParticipant
('fbid:'+ka,
la,
ma);},



getCanonicalThreadToParticipant:function(ka,
la,
ma){
var na=this.getThreadIDForParticipant(ka),
oa=this._threads.getResource(na);

if(typeof oa=='undefined'){
oa=this.createNewLocalThread
(na,
[r.user,ka],
la);



s.fetchThreadData([na],ma);}


return oa;},


getThreadIdForUser:function(ka){
return 'user:'+ka;},


getThreadIDForParticipant:function(ka){
var la=q.tokenize(ka);
return this.getThreadIdForUser(la.value);},








createNewLocalThread:function(ka,la,ma){
var na=this._threads.getResource(ka);
if(!na){
var oa=s.tokenizeThreadID(ka);
na=
{thread_id:ka,
last_action_id:null,
participants:la,
name:null,
snippet:'',
snippet_has_attachment:false,
snippet_sender:null,
unread_count:ma?ma:0,
message_count:0,
image_src:null,
timestamp_absolute:null,
timestamp_relative:null,
timestamp:null,
canonical_fbid:oa.type=='user'?oa.value:null,
is_canonical_user:oa.type=='user',
is_canonical:ia(la),
is_subscribed:true,
root_message_threading_id:null,
folder:i.MessagingTag.INBOX,
is_archived:false,
mode:i.MercuryThreadMode.TITAN_ORIGINATED};


this._threads.setResource(ka,na);}


return na;},


addParticipantsToThreadLocally:function(ka,la){
var ma=this._threads.getResource(ka);
if(ma){
y(ma,la);
t.updatedThread(ma.thread_id);}},



getCanonicalUserInThread:function(ka){
var la=s.tokenizeThreadID(ka);
return la.type=='user'?la.value:null;},


getCanonicalGroupInThread:function(ka){
var la=s.tokenizeThreadID(ka);
return la.type=='group'?la.value:null;},







isEmptyLocalThread:function(ka){
var la=this._threads.getResource(ka);
if(!la)
return false;


var ma=s.tokenizeThreadID(ka);
return ma.type=='root'&&!la.timestamp;},





canReply:function(ka){
var la=this._threads.getResource(ka);
return la&&
la.is_subscribed&&
la.mode!=i.MercuryThreadMode.OBJECT_ORIGINATED&&
(la.recipients_loadable||la.recipients_loadable===undefined);}});



u(ha,





{get:function(){
return ha.getForFBID(k.user);},





getForFBID:function(ka){
if(!x[ka])
x[ka]=new ha(ka);


return x[ka];}});



function ia(ka){
var la=ka.filter(function(ma){
return ma!=r.user;});



return la.length<=1;}


function ja(ka){
s.subscribe('update-threads',function(la,ma){

var na=(ma.actions||[]).filter(function(ra){
return ra.thread_id;});



ka.updateThreads(ma.threads);
ka.updateMetadataByActions(na,ma.from_client);
(ma.threads||[]).forEach(function(ra){
t.updatedThread(ra.thread_id);});



var oa=ma.global_actions||[];
for(var pa=0;pa<oa.length;pa++){
var qa=oa[pa];
if(qa.action_type==
i.MercuryGlobalActionType.MARK_ALL_READ)
da(ka,qa.folder);}});}





g.subscribe(m.DUMP_EVENT,function(ka,la){
la.messaging=la.messaging||{};
la.messaging.threads={};
for(var ma in x)
la.messaging.threads[ma]=
x[ma]._threads.dumpResources();});



e.exports=ha;});

/** js/mercury/models/MercuryUnreadState.js */
__d("MercuryUnreadState",["Arbiter","MercuryConstants","Env","MercuryFolders","JSLogger","KeyedCallbackManager","MercuryServerRequests","MercuryThreadInformer","MercuryThreads","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('MercuryConstants'),
i=b('Env'),
j=b('MercuryFolders'),
k=b('JSLogger'),
l=b('KeyedCallbackManager'),
m=b('MercuryServerRequests'),
n=b('MercuryThreadInformer'),
o=b('MercuryThreads').get(),

p=b('copyProperties'),
q=b('createObjectFrom'),



r=(j.getSupportedFolders()||[]).filter
(function(ja){
return ja!=h.MessagingTag.ACTION_ARCHIVED;}),



s={},


t='unread_thread_hash',
u='unseen_thread_list',

v=h.MercuryThreadlistConstants.MAX_UNREAD_COUNT,

w=k.create('mercury_unread_state');

function x(ja){
this._fbid=ja;


this._allReadTimestamp={};


this._threadReadTimestamp={};

this._initialUnreadCount={};
this._maxCount={};
this._unreadResources={};

r.forEach(function(ka){
this._initialUnreadCount[ka]=0;
this._maxCount[ka]=false;
this._unreadResources[ka]=new l();}.
bind(this));

m.subscribe('update-unread',function(ka,la){
ca(this,la);


var ma=la.global_actions||[];

for(var na=0;na<ma.length;na++){
var oa=ma[na];
if(oa.action_type==
h.MercuryGlobalActionType.MARK_ALL_READ)
fa(this,oa.folder,oa.timestamp);}}.


bind(this));

m.subscribe('update-thread-ids',function(ka,la){
ha(this,la);}.
bind(this));}


p(x.prototype,
{getUnreadCount:function(ja){
if(this.exceedsMaxCount(ja)){


w.error('unguarded_unread_count_fetch',{});
return 0;}


return ba(this,ja);},


exceedsMaxCount:function(ja){
return this._maxCount[ja]||
(ba(this,ja)>v);},


markFolderAsRead:function(ja){
if(this._maxCount[ja]||ba(this,ja)>0)
m.markFolderAsRead(ja);}});




p(x,





{get:function(){
return x.getForFBID(i.user);},





getForFBID:function(ja){
if(!s[ja])
s[ja]=new x(ja);


return s[ja];}});





function y(ja,ka,la){
ja._unreadResources[ka].setResource
(t,la);

ja._unreadResources[ka].setResource
(u,Object.keys(la));}



function z(ja,ka,la){
var ma=ja._unreadResources[ka].executeOrEnqueue
(t,
la),

na=ja._unreadResources[ka].getUnavailableResources(ma);

if(na.length)
m.fetchUnreadThreadIDs(ka);}



function aa(ja,ka){
return ja._unreadResources[ka].getResource(t);}


function ba(ja,ka){
var la=ja._unreadResources[ka].getResource(u);
if(la){
return la.length;}else 


return ja._initialUnreadCount[ka];}





function ca(ja,ka){
var la;

(ka.unread_thread_ids||[]).forEach(function(ma){
la=ma.folder;
if(!ia(la))
return;


var na=ga
(ma.thread_ids);



y
(ja,
la,
q(na,true));

if(na.length>v)
ja._maxCount[la]=true;


n.updatedUnreadState();});


(ka.message_counts||[]).forEach(function(ma){
if(ma.unread_count===undefined)
return;

la=ma.folder;


if(ma.unread_count>v){
ja._maxCount[la]=true;



y(ja,la,{});
n.updatedUnreadState();}else{

ja._initialUnreadCount[la]=ma.unread_count;



if(ja._initialUnreadCount[la]===0)
y(ja,la,{});


n.updatedUnreadState();}});



(ka.actions||[]).forEach(function(ma){



if(ma.is_forward)
return;


var na=h.MercuryActionType,



oa=ma.thread_id?
ma.thread_id:
ma.server_thread_id;

if(ma.action_type==na.DELETE_THREAD){
r.forEach(function(qa){
ea(ja,qa,oa);});}else

if(ma.action_type==na.CHANGE_ARCHIVED_STATUS||
ma.action_type==na.CHANGE_FOLDER){


var pa=o.getThreadMetaNow(ma.thread_id);
la=j.getFromMeta(pa);

if(ia(la)&&
pa.unread_count>0)
da(ja,la,oa);


r.forEach(function(qa){
if(qa!=la)
ea(ja,qa,oa);});}else{



la=ma.folder;
if(!ia(la))
return;


if(ma.action_type==na.CHANGE_READ_STATUS){
if(ma.mark_as_read){
ea(ja,la,oa,ma.timestamp);}else 

da(ja,la,oa,ma.timestamp);}else

if(ma.action_type==na.USER_GENERATED_MESSAGE||
ma.action_type==na.LOG_MESSAGE)


if(ma.is_unread)
da(ja,la,oa,ma.timestamp);}});}






function da(ja,ka,la,ma){

if(ja._maxCount[ka])
return;


z(ja,ka,function(na){
var oa=ja._allReadTimestamp[ka]||0,
pa=ja._threadReadTimestamp[la]||0,


qa=ma||Number.POSITIVE_INFINITY;

if(qa>=oa&&
qa>=pa&&
!na[la]){
na[la]=ma||0;
y(ja,ka,na);
n.updatedUnreadState();}});}




function ea(ja,ka,la,ma){

if(ja._maxCount[ka])
return;


z(ja,ka,function(na){
if(ma){
var oa=ja._threadReadTimestamp[la];
if(!oa||oa<ma)
ja._threadReadTimestamp[la]=ma;}



var pa=na[la];



if(ma&&
typeof pa=='number'&&
ma<pa)
return;


if(la in na){
delete na[la];
y(ja,ka,na);
n.updatedUnreadState();}});}




function fa(ja,ka,la){

ja._maxCount[ka]=false;
y(ja,ka,{});

ja._allReadTimestamp[ka]=
Math.max(ja._allReadTimestamp[ka]||0,la||0);

n.updatedUnreadState();}


function ga(ja){



return ja.map(m.convertThreadIDIfAvailable);}


function ha(ja,ka){
r.forEach(function(la){
var ma=aa(ja,la);


if(!ma)
return;


for(var na in ka){
var oa=ka[na];

if(ma[na]){

ma[oa]=
ma[na];
delete ma[na];}}





y(ja,la,ma);});}



function ia(ja){
return r.contains(ja);}


g.subscribe(k.DUMP_EVENT,function(ja,ka){
ka.messaging=ka.messaging||{};
ka.messaging.unread={};
ka.messaging.unread_max_count={};

for(var la in s){
ka.messaging.unread[la]={};
ka.messaging.unread_max_count[la]={};

r.forEach(function(ma){
ka.messaging.unread[la][ma]=p
({},
aa(s[la],ma));

ka.messaging.unread_max_count[la][ma]=
s[la]._maxCount[ma];});}});




e.exports=x;});

/** js/mercury/clients/leftnav/MercuryLeftNavCountControl.js */
__d("MercuryLeftNavCountControl",["Arbiter","MercuryConstants","CSS","DOM","MercuryThreadInformer","MercuryUnreadState","copyProperties"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('MercuryConstants'),
i=b('CSS'),
j=b('DOM'),
k=b('MercuryThreadInformer'),
l=b('MercuryUnreadState').get(),

m=b('copyProperties'),

n,
o,

p=function(q,r){
n=q;
o=r;

this.render();

this.listenerToken=
k.subscribe('unread-updated',this.render.bind(this));


this.subscriptions=
[g.subscribe('onload/exit',this.cleanup.bind(this))];};



m(p.prototype,
{render:function(){
var q=l.exceedsMaxCount
(h.MessagingTag.INBOX);


if(q){
j.setContent
(n,
h.MercuryThreadlistConstants.MAX_UNREAD_COUNT);}else{


var r=l.getUnreadCount
(h.MessagingTag.INBOX);



j.setContent(n,r.toString());


i.conditionClass
(n.parentNode,
'hidden_elem',
r<=0);}





j.setContent(o,q?'+':'');},


cleanup:function(){
this.subscriptions.forEach(g.unsubscribe);
k.unsubscribe(this.listenerToken);}});



e.exports=p;});

/** js/mercury/clients/leftnav/MercuryLeftNav.js */
__d("MercuryLeftNav",["DOM","MercuryServerRequests","MercuryLeftNavCountControl"],function(a,b,c,d,e,f){



var g=b('DOM'),
h=b('MercuryServerRequests'),
i=b('MercuryLeftNavCountControl');

e.exports=function(j,k){

h.handleUpdate(k);


var l=g.scry(j,'span.countValue')[0],
m=g.scry(j,'span.maxCountIndicator')[0],
n=new i(l,m);};});

/** js/mercury/clients/web_messenger/permalinks/WebMessengerPermalinkConstants.js */
__d("WebMessengerPermalinkConstants",["URI"],function(a,b,c,d,e,f){



var g=b('URI'),

h=

{ARCHIVED_PATH:'/messages/archived',
BASE_PATH:'/messages',
OTHER_PATH:'/messages/other',
SPAM_PATH:'/messages/spam',

COMPOSE_POSTFIX_PATH:'/new',
SEARCH_POSTFIX_PATH:'/search',
TID_POSTFIX_PARTIAL_PATH:'/conversation-',





overriddenVanities:'(archived|other|spam|new|search|conversation-.*)',





getURIPathForThreadID:function(i,j){


return (j||h.BASE_PATH)+
h.TID_POSTFIX_PARTIAL_PATH+
g.encodeComponent(g.encodeComponent(i));},


getThreadIDFromURI:function(i){
var j=i.getPath().match
(h.BASE_PATH+'(/[^/]*)*'+
h.TID_POSTFIX_PARTIAL_PATH+'([^/]+)');

if(j){
var k=g.decodeComponent(g.decodeComponent(j[2]));
return k;}},






getURIPathForIDOrVanity:function(i,j){
if(i.match('^'+h.overriddenVanities+'$'))
i='.'+i;

return (j||h.BASE_PATH)+'/'+i;},


getUserIDOrVanity:function(i){
var j=i.match(h.BASE_PATH+'.*/([^/]+)/?$'),
k=j&&j[1],
l=h.overriddenVanities;
if(!k||k.match('^'+l+'$')){

return false;}else
if(k.match('^\\.'+l+'$')){
return k.substr(1);}else 


return k;}};




e.exports=h;});

/** js/mercury/emoji/MercuryEmoji.js */
__d("MercuryEmoji",["MercuryConfig","Emoji","Emote"],function(a,b,c,d,e,f){



var g=b('MercuryConfig'),
h=b('Emoji'),
i=b('Emote'),

j=
{htmlEmojiAndEmote:function(k,l){
if(g.MessagingDisplayEmojiGK){
return h.htmlEmojiAndEmote(k,l);}else 

return i.htmlEmote(k,l);}};




e.exports=j;});

/** js/mercury/errors/MercuryErrorInfo.js */
__d("MercuryErrorInfo",["MercuryConstants","tx"],function(a,b,c,d,e,f){



var g=b('MercuryConstants'),
h=b('tx'),

i=



{getMessage:function(j){
var k="This message failed to send.";
if(i.isConnectionError(j)){
k="Unable to connect to Facebook. This message failed to send. ";}else
if(j.description)
k=j.description;


return k;},





isConnectionError:function(j){
if(j&&j.type==g.MercuryErrorType.TRANSPORT)
return j.code===1001||
j.code===1004||
j.code===1006;

return false;}};



e.exports=i;});

/** js/mercury/models/MercuryChannelHandler.js */
__d("MercuryChannelHandler",["Arbiter","ChannelConstants","MercuryConfig","MercuryConstants","MessagingReliabilityLogger","MercuryParticipants","PresenceUtil","MercuryServerRequests","MercuryThreadInformer","copyProperties"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('ChannelConstants'),
i=b('MercuryConfig'),
j=b('MercuryConstants'),
k=b('MessagingReliabilityLogger'),
l=b('MercuryParticipants'),
m=b('PresenceUtil'),
n=b('MercuryServerRequests'),
o=b('MercuryThreadInformer'),

p=b('copyProperties');

function q(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
!ga.obj.message){
k.addEntry('channel_receive','invalid_data');
return;}


var ha=ga.obj.message,

ia=
{author:ha.mercury_author_id,
author_email:ha.mercury_author_email,
body:ha.body,
subject:ha.subject,
has_attachment:ha.has_attachment,
attachments:ha.attachments,
html_body:ha.html_body,
thread_id:ha.tid,
message_id:ha.mid,
coordinates:ha.mercury_coordinates,
spoof_warning:ha.mercury_spoof_warning,
source:ha.mercury_source,
source_tags:ha.mercury_source_tags,
threading_id:ha.threading_id,
timestamp:ha.timestamp,
timestamp_absolute:ha.timestamp_absolute,
timestamp_relative:ha.timestamp_relative,
timestamp_time_passed:ha.timestamp_time_passed,
action_type:j.MercuryActionType.USER_GENERATED_MESSAGE,
is_unread:ha.is_unread,
action_id:ha.action_id,
is_forward:false,
forward_count:ha.forward_count||ha.forward,
forward_message_ids:ha.forward_msg_ids,
location_text:ha.location_text,
folder:ga.obj.folder},

ja=[p({},ia)];
ja=ja.concat(ha.forward_actions||[]);
var ka=j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE;
n.handleUpdateWaitForThread
({actions:ja,payload_source:ka},
ha.tid);




if(!ha.is_unread&&ha.mercury_author_id===l.user){
var la={};
la[ha.tid]=ga.obj.folder;

r
(h.getArbiterType('messaging'),
{obj:
{event:j.MessagingEventTypes.READ,
tids:[ha.tid],
folder_info:la,
timestamp:ha.timestamp}});}




k.addEntry
('channel_receive',
'success',

[ia.thread_id,
ia.message_id,
m.getSessionID()]);}




function r(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
!ga.obj.tids)
return;


var ha=[],

ia=ga.obj.event==j.MessagingEventTypes.READ;
ga.obj.tids.forEach(function(ja){
ha.push
({action_type:j.MercuryActionType.CHANGE_READ_STATUS,
action_id:null,
thread_id:ja,
mark_as_read:ia,
timestamp:ga.obj.timestamp||0,
folder:ga.obj.folder_info[ja]});});



n.handleUpdate
({actions:ha,
payload_source:j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});}



function s(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
!ga.obj.tids)
return;


var ha=[];
ga.obj.tids.forEach(function(ia){
ha.push
({action_type:j.MercuryActionType.DELETE_THREAD,
action_id:null,
thread_id:ia});});



n.handleUpdate
({actions:ha,
payload_source:j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});}



function t(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
!ga.obj.tids||
!ga.obj.mids)
return;


var ha=ga.obj.tids[0],
ia=
{action_type:j.MercuryActionType.DELETE_MESSAGES,
action_id:null,
thread_id:ha,
message_ids:ga.obj.mids};


n.handleUpdate
({actions:[ia],
threads:[ga.obj.updated_thread],
payload_source:j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});}



function u(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
!ga.obj.folder)
return;


var ha=
{action_type:j.MercuryGlobalActionType.MARK_ALL_READ,
action_id:ga.obj.action_id,
folder:ga.obj.folder};


n.handleUpdate
({global_actions:[ha]});}



function v(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj.tids)
return;


var ha=j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE;
ga.obj.tids.forEach(function(ia){
var ja=
{action_type:j.MercuryActionType.CHANGE_ARCHIVED_STATUS,
action_id:null,
thread_id:ia,
archived:ga.obj.state};


n.handleUpdateWaitForThread
({actions:[p({},ja)],payload_source:ha},
ia);});}




function w(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj.tids)
return;


var ha=j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE,
ia;
ga.obj.tids.forEach(function(ja){
if(ga.obj.event==j.MessagingEventTypes.TAG){
ia=ga.obj.tag;}else 

ia=ga.obj.marked_as_spam?
j.MessagingTag.SPAM:
j.MessagingTag.INBOX;


var ka=
{action_type:j.MercuryActionType.CHANGE_FOLDER,
action_id:null,
thread_id:ja,
new_folder:ia};

n.handleUpdateWaitForThread
({actions:[p({},ka)],payload_source:ha},
ja);});}




function x(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj.tag)
return;


switch(ga.obj.tag){
case j.MessagingTag.ACTION_ARCHIVED:
v(fa,ga);
break;
case j.MessagingTag.INBOX:
case j.MessagingTag.OTHER:
w(fa,ga);
break;}}



function y(fa,ga){
if(fa!=h.getArbiterType('inbox')||
!ga.obj||
!ga.obj.seen_timestamp)
return;


n.handleUpdate
({message_counts:
[{seen_timestamp:ga.obj.seen_timestamp,
folder:j.MessagingTag.INBOX}],

unseen_thread_ids:
[{thread_ids:[],
folder:j.MessagingTag.INBOX}],

payload_source:j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});}



function z(fa,ga){
if(fa!=h.getArbiterType('mercury')||
!ga.obj)
return;


o.synchronizeInforms(function(){
var ha=ga.obj,
ia=[];
(ha.actions||[]).forEach(function(ja){
var ka=
j.MercuryActionType.USER_GENERATED_MESSAGE;

if(ja.action_type==j.MercuryActionType.LOG_MESSAGE){


var la=
j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE;
n.handleUpdateWaitForThread
({actions:[p({},ja)],
payload_source:la},
ja.thread_id);}else

if(ja.action_type!=ka)


ia.push(ja);});



ha.actions=ia;
ha.payload_source=
j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE;
n.handleUpdate(ha);});}



function aa(fa,ga){
n.handleRoger(ga.obj);}


function ba(fa,ga){
if(fa!=h.getArbiterType('messaging')||
!ga.obj||
ga.obj.mute_settings===undefined||
!ga.obj.thread_id)
return;


var ha=j.MercuryActionType.CHANGE_MUTE_SETTINGS,
ia=
[{action_type:ha,
action_id:null,
thread_id:ga.obj.thread_id,
mute_settings:ga.obj.mute_settings}];


n.handleUpdate
({actions:ia,
payload_source:j.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE});}



function ca(fa,ga){
switch(ga.obj.event){
case j.MessagingEventTypes.DELIVER:
q(fa,ga);
break;
case j.MessagingEventTypes.READ:
case j.MessagingEventTypes.UNREAD:
r(fa,ga);
break;
case j.MessagingEventTypes.READ_ALL:
u(fa,ga);
break;
case j.MessagingEventTypes.DELETE:
s(fa,ga);
break;
case j.MessagingEventTypes.DELETE_MESSAGES:
t(fa,ga);
break;
case j.MessagingEventTypes.TAG:
x(fa,ga);
break;
case j.MessagingEventTypes.REPORT_SPAM:
w(fa,ga);
break;
case j.MessagingEventTypes.READ_RECEIPT:
aa(fa,ga);
break;
case j.MessagingEventTypes.CHANGE_MUTE_SETTINGS:
if(i.MuteThreadsOnDesktopGK)
ba(fa,ga);

break;}}



var da=[],

ea=
{turnOn:function(){
if(!da.length){
var fa=
{mercury:z,
messaging:ca,
inbox:y};


for(var ga in fa)
da.push(g.subscribe
(h.getArbiterType(ga),
fa[ga]));}},





turnOff:function(){
if(da.length){
da.forEach(g.unsubscribe);
da=[];}}};




ea.turnOn();

e.exports=ea;});

/** js/mercury/models/MercuryMessages.js */
__d("MercuryMessages",["Arbiter","AsyncRequest","MercuryConstants","Env","JSLogger","KeyedCallbackManager","MercuryAssert","MercuryConfig","MercuryIDs","MercuryMessageIDs","MercuryParticipants","PresenceUtil","RangedCallbackManager","MercuryServerDispatcher","MercuryServerRequests","MercuryThreadInformer","MercuryThreads","copyProperties","debounce","randomInt","tx"],function(a,b,c,d,e,f){





























































var g=b('Arbiter'),
h=b('AsyncRequest'),
i=b('MercuryConstants'),
j=b('Env'),
k=b('JSLogger'),
l=b('KeyedCallbackManager'),
m=b('MercuryAssert'),
n=b('MercuryConfig'),
o=b('MercuryIDs'),
p=b('MercuryMessageIDs'),
q=b('MercuryParticipants'),
r=b('PresenceUtil'),
s=b('RangedCallbackManager'),
t=b('MercuryServerDispatcher'),
u=b('MercuryServerRequests'),
v=b('MercuryThreadInformer'),
w=b('MercuryThreads').get(),

x=b('copyProperties'),
y=b('debounce'),
z=b('randomInt'),
aa=b('tx'),

ba=i.MercuryGenericConstants,


ca={},


da={},


ea={},




fa={},

ga={};


function ha(ya){
var za=ya;
if(fa[ya])
za=fa[ya];


return ca[za];}








var ia=new l();

function ja(ya,za){

if(za.status===undefined)
za.status=i.MercuryActionStatus.UNSENT;



za.timestamp_absolute="Today";


za.message_id=za.message_id||
ya.generateNewClientMessageID(za.timestamp);

var ab=q.user;

za.specific_to_list=za.specific_to_list||[];

if(za.specific_to_list.length&&
za.specific_to_list.indexOf(ab)===-1)

za.specific_to_list.push(ab);


if(!za.thread_id){


if(za.specific_to_list.length==1){


za.thread_id='user:'+j.user;}else
if(za.specific_to_list.length==2){
var bb=za.specific_to_list[0]==ab?
za.specific_to_list[1]:
za.specific_to_list[0];






if(o.tokenize(bb).type=='email'){
za.thread_id=ba.PENDING_THREAD_ID;}else 

za.thread_id=w.getThreadIDForParticipant(bb);}





za.thread_id=za.thread_id||'root:'+za.message_id;}


if(!za.specific_to_list.length){
var cb=u.tokenizeThreadID(za.thread_id);
if(cb.type=='user')



za.specific_to_list=
['fbid:'+cb.value,
ab];}}













function ka
(ya,
za,
ab){

var bb=
ua(za)?[i.MercuryMessageSourceTags.CHAT]:[],
cb=Date.now(),
db=Date.format
(n['24h_times']?'H:i':'g:ia',
Math.floor(cb/1000)),

eb=
{action_type:ya,
thread_id:ab,
author:q.user,
author_email:null,
coordinates:null,
timestamp:cb,
timestamp_absolute:(new Date(cb)).toLocaleDateString(),
timestamp_relative:db,
timestamp_time_passed:i.MercuryTimePassed.TODAY,
is_unread:false,
is_cleared:false,
is_forward:false,
is_filtered_content:false,
spoof_warning:false,
source:za,
source_tags:bb};


return eb;}


function la(ya){



switch(ya){
case i.MercuryPayloadSource.UNKNOWN:
case i.MercuryPayloadSource.SERVER_INITIAL_DATA:
case i.MercuryPayloadSource.SERVER_FETCH_THREAD_INFO:
case i.MercuryPayloadSource.SERVER_THREAD_SYNC:
return true;}


return false;}








function ma(ya){
return ya&&ya.substr(0,6)==='server';}


function na(ya,za){
if(!ya._threadsToMessages[za])
ya._threadsToMessages[za]=new s
(function(ab){
return ha(ab).timestamp;},

function(ab,bb){
return bb-ab;});




return ya._threadsToMessages[za];}


g.subscribe(k.DUMP_EVENT,function(ya,za){
var ab={};
for(var bb in ca){
var cb=ca[bb],
db=cb.thread_id;
ab[db]=ab[db]||{};
ab[db][cb.message_id]=
{action_type:cb.action_type,
author:cb.author,
is_unread:cb.is_unread,
timestamp:cb.timestamp};}



za.messaging=za.messaging||{};
za.messaging.local_message_ids=x({},fa);
za.messaging.messages=ab;});


function oa(ya,za,ab){
za.forEach(function(bb){
var cb=na(ya,bb);
cb.setReachedEndOfArray();






v.reorderedMessages(bb,ab);});}



function pa(ya){
this._fbid=ya;




this._failedHistoryFetchThreads={};



this._threadsToMessages={};






this._titanMessagesCount={};





this._localTitanMessagesCount={};

u.subscribe('update-messages',function(za,ab){
var bb=(ab.actions||[]).filter(function(db){
var eb=db.action_type;
return (db.is_forward||db.thread_id)&&
(eb==i.MercuryActionType.LOG_MESSAGE||
eb==i.MercuryActionType.USER_GENERATED_MESSAGE||
eb==i.MercuryActionType.SEND_MESSAGE||
eb==i.MercuryActionType.CLEAR_CHAT||
eb==i.MercuryActionType.DELETE_THREAD||
eb==i.MercuryActionType.DELETE_MESSAGES);}),



cb=la(ab.payload_source);

if(ma(ab.payload_source))
bb.forEach(function(db){
if(!db.is_forward){
var eb=w.getThreadMetaNow(db.thread_id);
if(eb)



db.is_cleared=db.timestamp<eb.chat_clear_time;}});





this.handleUpdates
(bb,
cb,
ab.payload_source,
ab.from_client);


if(ab.end_of_history)
oa
(this,
ab.end_of_history,
ab.payload_source);}.


bind(this));}


x(pa.prototype,







{getMessagesFromIDs:function(ya){
return (ya||[]).
map(ha).
filter(function(za){return za;});},









hasLoadedNMessages:function(ya,za){
var ab=na(this,ya);

return ab.hasReachedEndOfArray()||
ab.getCurrentArraySize()>=za;},









hasLoadedExactlyNMessages:function(ya,za){
var ab=na(this,ya);

return ab.getCurrentArraySize()==za;},














getThreadMessagesRangeImmediately:function(ya,
za,
ab,
bb,
cb){
return this.getThreadMessagesRange
(ya,
za,
ab,
bb,
t.IMMEDIATE,
cb);},
















getThreadMessagesRange:function(ya,
za,
ab,
bb,
cb,
db){
var eb=na(this,ya),

fb=function(lb){
bb(qa(lb));},

gb=eb.executeOrEnqueue
(za,
ab,
fb),

hb=eb.getUnavailableResources
(gb),





ib=this._failedHistoryFetchThreads[ya];

if(hb.length&&!ib){
















var jb=(this._titanMessagesCount[ya]||0)-
(this._localTitanMessagesCount[ya]||0),
kb=hb.length+
(this._localTitanMessagesCount[ya]||0);
u.fetchThreadMessages
(ya,
jb,
kb,
cb,
db);}else 




this._failedHistoryFetchThreads[ya]=false;


return gb;},









getThreadMessagesSinceTimestamp:function(ya,za){
var ab=na(this,ya),
bb=ab.getElementsUntil(za);

return qa(bb);},


hasLoadedAllMessages:function(ya){
return na(this,ya).hasReachedEndOfArray();},







getCurrentlyLoadedMessages:function(ya){
var za=na(this,ya).getAllResources();
return qa(za);},





unsubscribe:function(ya,za){
m.isThreadID(za);
var ab=na(this,za);
ab.unsubscribe(ya);},


addAttachmentData:function(ya,za,ab){
var bb=ha(ya);

if(bb){
var cb=bb.attachments.indexOf(za);

if(cb!=-1){
bb.attachments[cb]=ab;
v.updatedMessage
(bb.thread_id,
bb.message_id,
'attach');}}else{


if(!da[ya])
da[ya]=[];


da[ya].push({attach_key:za,data:ab});}},



handleUpdates:function(ya,za,ab,bb){
var cb,


db={},


eb={},

fb=i.MercuryActionStatus;

for(var gb=0;gb<ya.length;gb++){
var hb=ya[gb];




if(hb.is_forward||
ab==i.MercuryPayloadSource.SERVER_SEARCH){
if(!ca[hb.message_id]){
ca[hb.message_id]=hb;
va(hb);}

continue;}


var ib=hb.action_type;


if(ib==i.MercuryActionType.SEND_MESSAGE){
var jb=hb.client_message_id;


if(jb&&fa[jb]&&hb.status){
if(hb.status==fb.UNCONFIRMED){


if(!eb[hb.thread_id])
eb[hb.thread_id]=[];


eb[hb.thread_id].push
(hb.client_message_id);}else

if(!db[hb.thread_id])




db[hb.thread_id]=[];



var kb=ha(hb.client_message_id),
lb=kb.status;
kb.status=hb.status;





if(hb.status===fb.SUCCESS||hb.error_data)
kb.error_data=hb.error_data;




if(hb.status==fb.SUCCESS){
this.updateLocalMessage(hb,ab);
if(hb.client_thread_id==ba.PENDING_THREAD_ID){
kb.thread_id=hb.thread_id;
db[hb.thread_id].push(kb.message_id);
ia.setResource
(kb.message_id,
kb.thread_id);}}




if(typeof lb!='undefined'||
hb.status==fb.FAILED_UNKNOWN_REASON||
hb.status==fb.UNABLE_TO_CONFIRM||
hb.status==fb.SUCCESS||
hb.status==fb.ERROR)
v.updatedMessage
(hb.thread_id,
ha(hb.client_message_id).message_id,
ab);}






continue;}else
if(ib==i.MercuryActionType.DELETE_THREAD){

na(this,hb.thread_id).removeAllResources();
continue;}else
if(ib==i.MercuryActionType.DELETE_MESSAGES){


var mb=hb.message_ids.map(function(tb){
return ha(tb).message_id;});

cb=na(this,hb.thread_id);
cb.removeResources(mb);

v.reorderedMessages(hb.thread_id,ab);
continue;}else
if(ib==i.MercuryActionType.LOG_MESSAGE){
if(hb.log_message_type==
i.MercuryLogMessageType.SERVER_ERROR)
this._failedHistoryFetchThreads[hb.thread_id]=true;}else

if(ib==i.MercuryActionType.CLEAR_CHAT){

var nb=na(this,hb.thread_id).
getAllResources();
nb.map(ha).forEach(function(tb){
tb.is_cleared=true;});

continue;}




var ob=ha(hb.message_id);
if((hb.threading_id&&fa[hb.threading_id])||
(ob&&!ob.is_forward))
continue;


if(!db[hb.thread_id])
db[hb.thread_id]=[];


db[hb.thread_id].push(hb.message_id);
ca[hb.message_id]=hb;
va(hb);
if(hb.threading_id&&hb.threading_id!=hb.message_id)
p.addServerID(hb.threading_id,hb.message_id);


if(!za)



v.receivedMessage(hb);}




for(var pb in db){
cb=na(this,pb);
var qb=cb.getAllResources(),


rb=qb.filter(function(tb){
var ub=ca[tb];
return ub.action_type==i.MercuryActionType.LOG_MESSAGE&&
ub.log_message_type==i.MercuryLogMessageType.SERVER_ERROR;});

cb.removeResources(rb);

ra(this,pb,db[pb]);
if(bb)
sa
(this,
pb,
db[pb]);


if(za){



cb.addResources(db[pb]);
v.reorderedMessages(pb,ab);}else 




cb.addResourcesWithoutSorting
(db[pb].reverse(),
0);



v.updatedThread(pb);}



var sb=Object.keys(eb);
if(sb.length)
u.requestMessageConfirmation(eb);},



sendMessage:function(ya,za,ab){
za=za||Function.prototype;

ja(this,ya);


fa[ya.message_id]=ya.message_id;

if(ya.thread_id=='root:'+ya.message_id)






na(this,ya.thread_id).setReachedEndOfArray();


u.sendNewMessage(ya,ab);

if(ya.thread_id==ba.PENDING_THREAD_ID){
ca[ya.message_id]=ya;
return ia.executeOrEnqueue
(ya.message_id,
za);}else 


za(ya.thread_id);},



isFirstMessage:function(ya){
var za=na(this,ya.thread_id);
if(za.getCurrentArraySize()===0)
return false;

var ab=za.getResourceAtIndex
(za.getCurrentArraySize()-1),
bb=
ha(ab).message_id,
cb=
ha(ya.message_id).message_id;
return za.hasReachedEndOfArray()&&
bb==cb;},


unsubscribeSend:function(ya){
ia.unsubscribe(ya);},


resendMessage:function(ya,za){
var ab=x({},ya);
ab.status=i.MercuryActionStatus.RESENDING;
ab.timestamp=Date.now();
ab.message_id=ya.message_id;

ca[ya.message_id]=ab;
var bb=na(this,ya.thread_id);
bb.resortResources([ya.message_id]);


this.sendMessage(ab,null,za);



v.reorderedMessages
(ya.thread_id,
i.MercuryPayloadSource.CLIENT_SEND_MESSAGE);},



deleteMessages:function(ya,za){
if(za.length){
var ab=na(this,ya),
bb=
ab.getCurrentArraySize()==za.length&&
ab.hasReachedEndOfArray();

u.deleteMessages
(ya,
za,
bb);}},




markMessagesSpam:function(ya,za){
if(za.length){
var ab=na(this,ya),
bb=
ab.getCurrentArraySize()==za.length&&
ab.hasReachedEndOfArray();

if(bb){
u.markThreadSpam(ya);}else 

u.markMessagesSpam
(ya,
za);}},





updateLocalMessage:function(ya,za){
var ab=ya.message_id,
bb=ya.client_message_id;


fa[bb]=ab;
ca[ab]=ca[bb];
p.addServerID(bb,ab);



ca[bb]={};

var cb=ha(bb);



if(ya.timestamp)
cb.timestamp=ya.timestamp;



if(ya.attachments&&ya.attachments.length){
cb.raw_attachments=null;
cb.attachments=ya.attachments;
va(cb,ab);}


if(ya.log_message_data)
cb.log_message_data=ya.log_message_data;




if(ta(cb))
this._localTitanMessagesCount[cb.thread_id]--;},













constructUserGeneratedMessageObject:
function(ya,
za,
ab,
bb){

var cb=ka
(i.MercuryActionType.USER_GENERATED_MESSAGE,
za,
ab);

cb.body=ya;
cb.has_attachment=false;
cb.html_body=false;
cb.attachments=[];
cb.specific_to_list=bb||[];

return cb;},











constructLogMessageObject:
function(ya,
za,
ab,
bb){

var cb=ka
(i.MercuryActionType.LOG_MESSAGE,
ya,
za);

cb.log_message_type=ab;
cb.log_message_data=bb;

return cb;},


generateNewClientMessageID:function(ya){
var za=ya+':'+(z(0,4294967295)+1)+'-'+
r.getSessionID();
return '<'+za+'@mail.projektitan.com>';}});



x(pa,





{get:function(){
return pa.getForFBID(j.user);},





getForFBID:function(ya){
if(!ga[ya])
ga[ya]=new pa(ya);


return ga[ya];},










addAttachmentData:function(ya,za,ab,bb){
bb=bb||j.user;
pa.getForFBID(bb).addAttachmentData
(ya,
za,
ab);}});




function qa(ya){
var za=ya.map(ha);


return za.reverse();}


function ra(ya,za,ab){
var bb=ab.filter(function(cb){
return ta(ha(cb));});

if(!ya._titanMessagesCount[za])
ya._titanMessagesCount[za]=0;

ya._titanMessagesCount[za]+=bb.length;}


function sa(ya,za,ab){
var bb=ab.filter(function(cb){
return ta(ha(cb));});

if(!ya._localTitanMessagesCount[za])
ya._localTitanMessagesCount[za]=0;

ya._localTitanMessagesCount[za]+=bb.length;}


function ta(ya){
var za=ya.action_type;
if(za==i.MercuryActionType.USER_GENERATED_MESSAGE)
return true;


switch(ya.log_message_type){
case i.MercuryLogMessageType.SUBSCRIBE:
case i.MercuryLogMessageType.UNSUBSCRIBE:
case i.MercuryLogMessageType.SERVER_ERROR:
case i.MercuryLogMessageType.LIVE_LISTEN:
return false;

default:return true;
}}


function ua(ya){
switch(ya){
case i.MercurySourceType.CHAT_WEB:
case i.MercurySourceType.CHAT_JABBER:
case i.MercurySourceType.CHAT_IPHONE:
case i.MercurySourceType.CHAT_MEEBO:
case i.MercurySourceType.CHAT_ORCA:
case i.MercurySourceType.CHAT_TEST:
case i.MercurySourceType.CHAT:
case i.MercurySourceType.DESKTOP:
return true;

default:return false;
}}


function va(ya,za){
za=za||ya.message_id;
var ab=da[za];

if(ab){
ab.forEach(function(bb){
var cb=ya.attachments.indexOf(bb.attach_key);
if(cb!==-1)
ya.attachments[cb]=bb.data;});



delete da[za];}else
if(!ya.is_forward&&wa(ya)){
ea[za]=true;
xa();}}







function wa(ya){
if(!ya||!ya.attachments)
return false;


for(var za=0;za<ya.attachments.length;za++){
var ab=ya.attachments[za];

if(typeof ab==='string'&&
ab.indexOf(i.MercuryAttachmentType.SHARE)===0)
return true;}



var bb=ya.forward_message_ids||[];
for(za=0;za<bb.length;za++){
var cb=ha(bb[za]);

if(wa(cb))
return true;}



return false;}


var xa=y(function(){
var ya={};

for(var za in ea){
var ab=ha(za);

if(wa(ab))
ya[za]=true;}



var bb=Object.keys(ya);

if(bb.length)
new h('/ajax/mercury/attachments/fetch_shares.php').
setData({message_ids:bb}).
setAllowCrossPageTransition(true).
send();


ea={};},
0,this,true);

e.exports=pa;});

/** js/mercury/models/MercuryRoger.js */
__d("MercuryRoger",["ArbiterMixin","MercuryConstants","MercuryServerRequests","copyProperties"],function(a,b,c,d,e,f){



var g=b('ArbiterMixin'),
h=b('MercuryConstants'),
i=b('MercuryServerRequests'),

j=b('copyProperties'),

k={},

l=






{getSeenBy:function(m,n){
if(!m)
return [];


var o=[],

p=k[m.thread_id],
q=h.MercuryActionStatus.SUCCESS;
for(var r in p)
if(p[r]>m.timestamp&&
(m.status===undefined||m.status===q)&&
(!n||r!=m.author))
o.push(r);



return o;},


getSeenTimestamp:function(m,n){
var o=k[m];
return o?o[n]:null;}};



j(l,g);

i.subscribe('update-roger',function(m,n){
for(var o in n){
if(!k[o])
k[o]={};


for(var p in n[o]){
var q=k[o][p],
r=n[o][p];

if(!q||r>q)
k[o][p]=r;}}




if(n)
l.inform('state-changed',n);});



e.exports=l;});

/** js/mercury/models/MercuryDelayedRoger.js */
__d("MercuryDelayedRoger",["ArbiterMixin","LiveTimer","MercuryConfig","MercuryConstants","MercuryMessages","MercuryRoger","MercuryThreadInformer","MercuryThreads","copyProperties","setTimeoutAcrossTransitions"],function(a,b,c,d,e,f){








var g=b('ArbiterMixin'),
h=b('LiveTimer'),
i=b('MercuryConfig'),
j=b('MercuryConstants'),
k=b('MercuryMessages').get(),
l=b('MercuryRoger'),
m=b('MercuryThreadInformer'),
n=b('MercuryThreads').get(),

o=b('copyProperties'),
p=b('setTimeoutAcrossTransitions'),


q={},


r={},

s=i['roger.seen_delay'],

t=o
({getSeenBy:function(x,y){
if(r[x])
return [];


if(!q[x]){
var z=n.getThreadMetaNow(x);



if(z)
q[x]=
{thread_id:x,
author:z.participants[0],
timestamp:z.timestamp};}




return l.getSeenBy(q[x],y);}},


g);

function u(x){
var y=false;

k.getThreadMessagesRange(x,0,1,function(z){
var aa=z[0];
if(!aa)
return;


var ba=aa.timestamp,






ca=j.MercuryActionStatus.SUCCESS;
if(aa.action_id||aa.status==ca)
ba-=h.getServerTimeOffset();


var da=t.getSeenBy(x);

if(r[x]){
clearTimeout(r[x]);
delete r[x];}


var ea=ba+s,
fa=ea-Date.now();

if(fa>0)
r[x]=p(function(){
delete r[x];
v(x);},
fa);


q[x]=aa;


var ga=t.getSeenBy(x);
if(da.length||ga.length)
y=true;});



return y;}


function v(x){
var y={};
y[x]=true;
t.inform('state-changed',y);}


function w(event,x){
var y={};

for(var z in x)
if(u(z))
y[z]=true;



for(var aa in y){
t.inform('state-changed',y);
break;}}



l.subscribe('state-changed',function(x,y){
for(var z in y)
!r[z]&&v(z);});



m.subscribe('messages-received',w);
m.subscribe('messages-reordered',w);
m.subscribe('messages-updated',w);

e.exports=t;});

/** js/mercury/utils/MercuryFilters.js */
__d("MercuryFilters",["array-extensions","MercuryConstants"],function(a,b,c,d,e,f){



b('array-extensions');

var g=b('MercuryConstants'),

h=
[g.MessagingTag.UNREAD],


i=



{ALL:'all',

getSupportedFilters:function(){
return h.concat();},


isSupportedFilter:function(j){
return h.contains(j);}};



e.exports=i;});

/** js/mercury/models/MercuryOrderedThreadlist.js */
__d("MercuryOrderedThreadlist",["MercuryConstants","copyProperties","Env","JSLogger","MercuryFilters","MercuryFolders","RangedCallbackManager","MercuryServerRequests","MercuryThreadInformer","MercuryThreads"],function(a,b,c,d,e,f){



var g=b('MercuryConstants'),
h=b('copyProperties'),
i=b('Env'),
j=b('JSLogger'),
k=b('MercuryFilters'),
l=b('MercuryFolders'),
m=b('RangedCallbackManager'),
n=b('MercuryServerRequests'),
o=b('MercuryThreadInformer'),
p=b('MercuryThreads').get(),

q=j.create('ordered_threadlist_model'),

r=
k.getSupportedFilters().concat([k.ALL]),
s=l.getSupportedFolders(),

t={};







function u(ea,fa,ga,ha){
var ia=[],
ja=false,
ka=false,
la=(fa||[]).filter(function(sa){

var ta=sa.filter||k.ALL;
return (sa.folder==ga||
(!sa.folder&&ga==g.MessagingTag.INBOX))&&
ta==ha;}),


ma=
ea._threadlistOrderMap[ga][ha].getAllResources(),
na;
la.forEach(function(sa){
ia=ia.concat(sa.thread_ids);

if(sa.error){



if(sa.end>ma.length)
ka=sa.error;}else{


var ta=sa.end-sa.start;
if(sa.thread_ids.length<ta)
ja=true;}



if(!na||sa.end>na)
na=sa.end;});



y(ea,ia,ga,ha);

if(ja){
ea._threadlistOrderMap[ga][ha].setReachedEndOfArray();}else
if(ka){
ea._threadlistOrderMap[ga][ha].setError(ka);}else{

var oa=
ea._threadlistOrderMap[ga][ha].getCurrentArraySize();
if(na&&oa<na){


var pa={},
qa=ma.concat(ia),
ra=qa.filter(function(sa){
var ta=pa[sa];
pa[sa]=true;
return ta;});





if(ra.length){
q.warn('duplicate_threads',
{folder:ga,
expected_final_size:na,
actual_final_size:oa,
duplicate_thread_ids:ra});





n.fetchThreadlistInfo
(na,
ra.length,
ga,
ha==k.ALL?null:ha);}}}}






function v(ea,fa){
s.forEach(function(ga){
r.forEach(function(ha){
u(ea,fa,ga,ha);});});}




function w(ea,fa){
var ga={};

s.forEach(function(ha){
ga[ha]={};
r.forEach(function(ia){
ga[ha][ia]=
{to_add:[],
to_remove:[],
to_remove_if_last_after_add:{}};});});




fa.forEach(function(ha){



if(ha.is_forward)
return;

var ia=ha.thread_id,
ja=z(ea,ia),
ka=aa(ia);






function la(){
ka.forEach(function(na){





ga[ja][na].to_add.push(ia);




if(!ea._threadlistOrderMap[ja][na].hasReachedEndOfArray()&&
!ea._threadlistOrderMap[ja][na].hasResource(ia))
ga[ja][na].to_remove_if_last_after_add[ia]=true;});}









function ma(na){

if(r.contains(na))
if(ka.contains(na)){

ga[ja][na].to_add.push(ia);}else 


ga[ja][na].to_remove.push(ia);}






if(!ja){



if(ha.action_type===g.MercuryActionType.CHANGE_FOLDER||
ha.action_type===
g.MercuryActionType.CHANGE_ARCHIVED_STATUS)
s.forEach(function(na){
if(na!==ja)
r.forEach(function(oa){
ea._threadlistOrderMap[na][oa].removeResources
([ia]);});});





return;}


switch(ha.action_type){
case g.MercuryActionType.DELETE_THREAD:
ka.forEach(function(na){
ga[ja][na].to_remove.push(ia);});

break;
case g.MercuryActionType.CHANGE_ARCHIVED_STATUS:
case g.MercuryActionType.CHANGE_FOLDER:

la();
break;
case g.MercuryActionType.CHANGE_READ_STATUS:
ma(g.MessagingTag.UNREAD);
break;
case g.MercuryActionType.USER_GENERATED_MESSAGE:
case g.MercuryActionType.LOG_MESSAGE:
ka.forEach(function(na){
if(ba(ea,ia,ja,na))
ga[ja][na].to_add.push(ia);});


break;}});



s.forEach(function(ha){
r.forEach(function(ia){
var ja=ea._threadlistOrderMap[ha][ia];

y(ea,ga[ha][ia].to_add,ha,ia);

for(var ka=ja.getCurrentArraySize()-1;ka>=0;ka--){
var la=ja.getResourceAtIndex(ka);
if(!ga[ha][ia].to_remove_if_last_after_add[la])



break;

ga[ha][ia].to_remove.push(la);}

ja.removeResources(ga[ha][ia].to_remove);});});}







function x(ea,fa){
var ga={};

s.forEach(function(ha){
ga[ha]={};
r.forEach(function(ia){
ga[ha][ia]=[];});});






fa.forEach(function(ha){
var ia=z(ea,ha.thread_id),
ja=aa(ha.thread_id);

if(ia)
ja.forEach(function(ka){
if(ba(ea,ha.thread_id,ia,ka))
ga[ia][ka].push(ha.thread_id);});});






s.forEach(function(ha){
r.forEach(function(ia){
if(ga[ha][ia].length>0)
y(ea,ga[ha][ia],ha,ia);});});}





function y(ea,fa,ga,ha){
ha=ha||k.ALL;
ea._threadlistOrderMap[ga][ha].addResources(fa);
s.forEach(function(ia){
if(ia!=ga)
ea._threadlistOrderMap[ia][ha].removeResources(fa);});}











function z(ea,fa){
var ga=p.getThreadMetaNow(fa),
ha=null;

if(!ga){
ha='No thread metadata';}else
if(!ga.folder)
ha='No thread folder';


if(ha){
var ia=
{error:ha,
tid:fa};

q.warn('no_thread_folder',ia);
return null;}


var ja=ga.folder;
if(ga.is_archived)



ja=g.MessagingTag.ACTION_ARCHIVED;

if(ea._threadlistOrderMap[ja]){
return ja;}else 




return null;}










function aa(ea){
var fa=p.getThreadMetaNow(ea),
ga=[k.ALL];

if(!fa){
var ha=
{error:'no_thread_metadata',
tid:ea};

q.warn('no_thread_metadata',ha);
return [];}



if(fa.unread_count)
ga.push(g.MessagingTag.UNREAD);


return ga;}


function ba(ea,fa,ga,ha){
var ia=p.getThreadMetaNow(fa);







return ia&&
ia.timestamp&&
z(ea,fa)==ga&&
aa(fa).contains(ha);}


function ca(ea){
this._fbid=ea;

this._threadlistOrderMap={};

s.forEach(function(fa){
this._threadlistOrderMap[fa]={};
r.forEach(function(ga){
this._threadlistOrderMap[fa][ga]=new m
(function(ha){





return p.getThreadMetaNow(ha).timestamp;},

function(ha,ia){
return ia-ha;},

n.canLinkExternally.bind(n));}.

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

n.subscribe('update-threadlist',function(fa,ga){
if(!da(ga))
return;


var ha=ga.ordered_threadlists;
if(ha&&ha.length){
v(this,ha);}else{

var ia=(ga.actions||[]).filter(function(ja){
return ja.thread_id;});


x(this,ga.threads||[]);
w(this,ia);}


o.updatedThreadlist();}.
bind(this));}


h(ca.prototype,












{getThreadlist:function(ea,fa,ga,ha,ia,ja){
return this.getFilteredThreadlist
(ea,
fa,
ga,
k.ALL,
ha,
ia,
ja);},



getFilteredThreadlist:
function(ea,
fa,
ga,
ha,
ia,
ja,
ka){
var la=this._threadlistOrderMap[ga][ha],
ma=la.executeOrEnqueue
(ea,
fa,
ia,
ja),

na=la.getUnavailableResources
(ma),

oa=la.getError(ea,fa,ja);



if(na.length||oa){



if(la.getCurrentArraySize()<ea){
var pa=
{start:ea,
limit:fa,
filter:ha,
resources_size:la.getCurrentArraySize()};

q.warn('range_with_gap',pa);}



la.setError(false);

n.fetchThreadlistInfo
(la.getCurrentArraySize(),
na.length,
ga,
ha==k.ALL?null:ha,
ka);}



return ma;},











getThreadlistUntilTimestamp:function(ea,fa,ga){
ga=ga||k.ALL;
return this._threadlistOrderMap[fa][ga].getElementsUntil(ea);},





unsubscribe:function(ea,fa,ga){
ga=ga||k.ALL;
this._threadlistOrderMap[fa][ga].unsubscribe(ea);}});



h(ca,





{get:function(){
return ca.getForFBID(i.user);},





getForFBID:function(ea){
if(!t[ea])
t[ea]=new ca(ea);


return t[ea];}});



function da(ea){
switch(ea.payload_source){
case g.MercuryPayloadSource.CLIENT_CHANGE_ARCHIVED_STATUS:
case g.MercuryPayloadSource.CLIENT_CHANGE_READ_STATUS:
case g.MercuryPayloadSource.CLIENT_CHANGE_FOLDER:
case g.MercuryPayloadSource.CLIENT_CHANNEL_MESSAGE:
case g.MercuryPayloadSource.CLIENT_DELETE_MESSAGES:
case g.MercuryPayloadSource.CLIENT_DELETE_THREAD:
case g.MercuryPayloadSource.CLIENT_SEND_MESSAGE:
case g.MercuryPayloadSource.SERVER_SEND_MESSAGE:
case g.MercuryPayloadSource.SERVER_CONFIRM_MESSAGES:
case g.MercuryPayloadSource.SERVER_FETCH_THREADLIST_INFO:
case g.MercuryPayloadSource.SERVER_THREAD_SYNC:
return true;
case g.MercuryPayloadSource.SERVER_INITIAL_DATA:




return ea.ordered_threadlists;

default:return false;
}}


e.exports=ca;});

/** js/mercury/models/MercuryUnseenState.js */
__d("MercuryUnseenState",["Arbiter","MercuryConstants","TimestampConverter","JSLogger","KeyedCallbackManager","MercuryServerRequests","MercuryThreadInformer","copyProperties","createObjectFrom"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('MercuryConstants'),
i=b('TimestampConverter'),
j=b('JSLogger'),
k=b('KeyedCallbackManager'),
l=b('MercuryServerRequests'),
m=b('MercuryThreadInformer'),

n=b('copyProperties'),
o=b('createObjectFrom'),

p=h.MercuryThreadlistConstants.MAX_UNSEEN_COUNT,

q=0,
r=0,
s=false,


t=new k(),
u='unseen_thread_hash',
v='unseen_thread_list',

w=j.create('mercury_unseen_state'),

x=
{getUnseenCount:function(){
if(x.exceedsMaxCount()){


w.error('unguarded_unseen_count_fetch',{});
return 0;}


return ba();},


exceedsMaxCount:function(){
return s||(ba()>p);},





markAsSeen:function(){
if(ba()>0||s){

l.markSeen();



da
(i.convertActionIDToTimestamp(l.getLastActionID()),
[]);}},




markThreadSeen:function(ka,la){
var ma={};
ma[ka]=null;
fa(ma,la);}};





function y(ka){
t.setResource(u,ka);
t.setResource
(v,Object.keys(ka));}



function z(ka){
var la=t.executeOrEnqueue
(u,
ka),

ma=t.getUnavailableResources(la);

if(ma.length)
l.fetchUnseenThreadIDs();}



function aa(){
return t.getResource(u);}


function ba(){
var ka=t.getResource(v);
if(ka){
return ka.length;}else 


return q;}





function ca(ka){
var la=ja(ka);

if(ka.unseen_thread_ids){
ka.unseen_thread_ids.forEach(function(wa){
if(wa.folder!=h.MessagingTag.INBOX)


return;


var xa=ha
(wa.thread_ids),




ya=r;
if(la&&la.seen_timestamp)
ya=la.seen_timestamp;



da(ya,xa);



if(la&&la.unseen_count>p)
s=true;});}else


if(la&&la.seen_timestamp){

r=la.seen_timestamp;

if(la.unseen_count>p){
s=true;



y({});}else{

q=la.unseen_count;



if(q===0)
y({});}}else{






if(s)
return;



var ma=ka.actions;

if(!ma||!(ma.length))
return;


var na={},
oa={};
for(var pa=0;pa<ma.length;pa++){
var qa=ma[pa];



if(qa.is_forward)
continue;


var ra=qa.action_type,
sa=qa.action_id,



ta=qa.thread_id?
qa.thread_id:
qa.server_thread_id,


ua=
qa.folder===undefined||
qa.folder==h.MessagingTag.INBOX;

if(!ua)
continue;


if(ra==h.MercuryActionType.USER_GENERATED_MESSAGE||
ra==h.MercuryActionType.LOG_MESSAGE){

var va=i.isGreaterThan
(sa,
na[ta]);

if(qa.is_unread&&
(!na[ta]||va))
na[ta]=sa;}else

if(ra==h.MercuryActionType.CHANGE_READ_STATUS&&
qa.mark_as_read)


oa[ta]=sa;}



ea(na);
fa(oa);}}



function da(ka,la){

var ma=aa();

if(ma===undefined||
ka>r||
s){
r=ka;
la=la||[];


if(la.length<=p)
s=false;





var na={},



oa=aa()||{};

for(var pa in oa)


if(oa[pa]!==true){
var qa=oa[pa];
if(ga(qa))
na[pa]=qa;}







var ra=n
(o(la,true),
na);


y(ra);
m.updatedUnseenState();}}







function ea(ka){

if(s)
return;


var la={},
ma=false;
for(var na in ka){
var oa=ka[na];



if(ga(oa)){
la[na]=oa;
ma=true;}}



if(!ma)
return;


z(function(pa){
for(var qa in la){
var ra=la[qa];

if(!pa[qa]&&ga(ra))
pa[qa]=la[qa];}




y(pa);
m.updatedUnseenState();});}



function fa(ka,la){
var ma=false;
for(var na in ka){
ma=true;
break;}


if(ma)
z(function(oa){
var pa=false;
for(var qa in ka){
var ra=ka[qa],

sa=i.isGreaterThan
(ra,
oa[qa]);

if(oa[qa]&&(!ra||sa)){
delete oa[qa];
pa=true;}}



if(pa){
y(oa);
m.updatedUnseenState();




if(la&&ba()===0)
l.markSeen();}});}






function ga(ka){
return i.convertActionIDToTimestamp(ka)>r;}




function ha(ka){



return ka.map(l.convertThreadIDIfAvailable);}


function ia(ka){
var la=aa();



if(!la)
return;


for(var ma in ka){
var na=ka[ma];

if(la[ma]){

la[na]=
la[ma];
delete la[ma];}}





y(la);}


function ja(ka){
var la=(ka.message_counts||[]);
for(var ma=0;ma<la.length;ma++)

if(la[ma].folder==h.MessagingTag.INBOX)
return la[ma];



return null;}


l.subscribe('update-unseen',function(ka,la){
ca(la);});


l.subscribe('update-thread-ids',function(ka,la){
ia(la);});


g.subscribe(j.DUMP_EVENT,function(ka,la){
la.messaging=la.messaging||{};
la.messaging.unseen=n({},aa());
la.messaging.unseen_max_count=s;
la.messaging.unseen_time=r;});


e.exports=x;});

/** js/mercury/renderers/raw/MercuryThreadMetadataRawRenderer.js */
__d("MercuryThreadMetadataRawRenderer",["Event","MercuryConfig","MercuryConstants","CSS","DOM","MercuryErrorInfo","MercuryStatusTemplates","Tooltip","URI","WebMessengerPermalinkConstants","tx"],function(a,b,c,d,e,f){


var g=b('Event'),

h=b('MercuryConfig'),
i=b('MercuryConstants'),
j=b('CSS'),
k=b('DOM'),
l=b('MercuryErrorInfo'),
m=b('MercuryStatusTemplates'),
n=b('Tooltip'),
o=b('URI'),
p=b('WebMessengerPermalinkConstants'),

q=b('tx');

e.exports=















{renderParticipantListWithNoThreadName:
function(r,
s,
t,
u,
v,
w){



var x=
{callback:true,
check_length:true,

show_unread_count:true};

w=w||{};
var y={};
for(var z in w)
if(x[z]){
y[z]=w[z];
delete w[z];}



var aa=t.map(function(fa){
return u[fa];}),


ba=this.renderRawParticipantList
(r,
aa,
t.length,
w);


ba=this.renderRawTitleWithUnreadCount
(ba,
y.show_unread_count?s.unread_count:0);


var ca=w.abbr_mode,
da={};
for(var ea in w)
da[ea]=w[ea];

da.abbr_mode=true;

v.forEach(function(fa){
var ga=v.length>1?
this._cloneIfDOMElement(ba):
ba;
k.setContent(fa,ga);
if(y.check_length&&
!ca&&
fa.scrollWidth>fa.clientWidth){
var ha=
this.renderRawParticipantList
(r,
aa,
t.length,
da),

ia=
this.renderRawTitleWithUnreadCount
(ha,
y.show_unread_count?s.unread_count:0);

k.setContent(fa,ia);}}.

bind(this));

y.callback&&y.callback(ba);},










renderRawParticipantList:
function(r,
s,
t,
u){



var v=
{abbr_mode:true,

last_separator_uses_and:true,



names_renderer:true};




u=u||{};











var w=null;
if(u.names_renderer){
w=u.names_renderer(s);}else 

w=s.map(function(z){return z.name;});


var x=null;
if(w.length===0){
x="No Participants";}else
if(w.length==1){
x=w[0];}else
if(w.length==2){
var y=
{participant1:w[0],
participant2:w[1]};

if(u.last_separator_uses_and){
x=q._("{participant1} and {participant2}",y);}else 

x=q._("{participant1}, {participant2}",y);}else

if(u.last_separator_uses_and){
if(u.abbr_mode){
x=q._("{participant1} and {others_link}",

{participant1:w[0],
others_link:this.renderRawParticipantCount
(r,

{render_subset:true,
count:t-1})});}else




if(w.length==3){
x=q._("{participant1}, {participant2} and {participant3}",
{participant1:w[0],
participant2:w[1],
participant3:w[2]});}else 


x=q._("{participant1}, {participant2} and {others_link}",

{participant1:w[0],
participant2:w[1],
others_link:this.renderRawParticipantCount
(r,

{render_subset:true,
count:t-2})});}else 






if(w.length==3){
x=q._("{participant1}, {participant2}, {participant3}",
{participant1:w[0],
participant2:w[1],
participant3:w[2]});}else 


x=q._("{participant1}, {participant2}, {participant3}, {others_link}",
{participant1:w[0],
participant2:w[1],
participant3:w[2],
others_link:this.renderRawParticipantCount
(r,

{render_subset:true,
count:t-3})});





if(Array.isArray(x))


x=k.create('span',{},x);

return x;},


renderRawTitleWithUnreadCount:function(r,s){
var t=r;
if(s&&s>1)
t=k.create('span',{},q._("{conversation_title} ({unread_count})",
{conversation_title:r,unread_count:s}));


return t;},











renderRawParticipantCount:function(r,s){
var t=s.render_subset,
u;

if(!t){
u=s.count>1?
q._("{num} people",{num:s.count}):
"1 person";}else 

u=s.count>1?
q._("{others_count} others",{others_count:s.count}):
"1 other";


return u;},







renderShortNames:function(r){
if(r.length==1)
return [r[0].name];

return r.map(function(s){
return s.short_name;});},




renderUserCanonicalTitanLink:function(r,s,t){



var u=new o().setSubdomain('www');
u.setPath('/messages/'+r.substr(r.indexOf(':')+1));
s.setAttribute('href',u.toString());

t&&t();},



renderTitanLinkWithServerID:function(r,s,t){
var u=new o().setSubdomain('www');
if(h.MessagesMercuryIntegrationGK){
u.setPath(p.getURIPathForThreadID
(r));}else{


u.setPath('/messages/');
u.setQueryData
({action:'read',
tid:r});}



s.setAttribute('href',u.toString());

t&&t();},


renderStatusIndicator:function(r,s,t){
var u=i.MercuryActionStatus,

v;
if(r==u.RESENDING){
v=this.renderResendIndicator();}else
if(r!==undefined&&
r!=u.UNSENT&&
r!=u.UNCONFIRMED&&
r!=u.SUCCESS)
v=this.renderErrorIndicator(s,t);


return v;},


renderResendIndicator:function(){
return m[':fb:mercury:resend-indicator'].render();},










renderErrorIndicator:function(r,s){
if(!r)
return null;


var t=m[':fb:mercury:error-indicator'].render(),
u=r.is_transient,

v=l.getMessage(r);
if(l.isConnectionError(r)){
v=q._("{message} Check your network connection or click to try again.",
{message:v});}else

if(u)
v=q._("{message} Click to send again.",
{message:v});



n.set(t,v,'above','center');


if(s&&u){
g.listen(t,'click',s);
j.addClass(t,'mercuryClickableErrorIndicator');}


return t;},


_cloneIfDOMElement:function(r){
if(r.cloneNode){
return r.cloneNode();}else 

return r;}};});

/** js/mercury/utils/MercurySeenByAll.js */
__d("MercurySeenByAll",["CSS","DataStore","DOM","MercuryParticipants","MercuryDelayedRoger","MercuryThreads"],function(a,b,c,d,e,f){







var g=b('CSS'),
h=b('DataStore'),
i=b('DOM'),
j=b('MercuryParticipants'),
k=b('MercuryDelayedRoger'),
l=b('MercuryThreads').get(),


m={},

n=
{updateOnSeenChange:function(p,q){
m[p.tagName]=true;
h.set(p,'thread-id',q.thread_id);
g.addClass(p,'seenByListener');
o(p,q);}};



function o(p,q){
var r=q.participants.filter(function(t){
return t!==j.user;}),


s=
q.participants.length>0&&
q.participants[0]===j.user;
g.conditionClass
(p,
'repliedLast',
s);

g.conditionClass
(p,
'seenByAll',
s&&
k.getSeenBy(q.thread_id).length===r.length);}



k.subscribe('state-changed',function(p,q){
for(var r in m){
var s=i.scry(document.body,r+'.seenByListener');
for(var t=0;t<s.length;t++){
var u=s[t],
v=h.get(u,'thread-id');
if(q[v])
l.getThreadMeta(v,function(w){
o(u,w);});}}});






e.exports=n;});

/** js/mercury/renderers/MercuryThreadMetadataRenderer.js */
__d("MercuryThreadMetadataRenderer",["MercuryConfig","MercuryConstants","CSS","DOM","HTML","MercuryImageTemplates","JSLogger","MercuryAttachment","MercuryEmoji","MercuryThreadMetadataRawRenderer","MercuryParticipants","MercurySeenByAll","MercuryServerRequests","MercuryThreadlistIconTemplates","MercuryThreads","Tooltip","URI","createArrayFrom","cx","tx"],function(a,b,c,d,e,f){



var g=b('MercuryConfig'),
h=b('MercuryConstants'),
i=b('CSS'),
j=b('DOM'),
k=b('HTML'),
l=b('MercuryImageTemplates'),
m=b('JSLogger'),
n=b('MercuryAttachment'),
o=b('MercuryEmoji'),
p=
b('MercuryThreadMetadataRawRenderer'),
q=b('MercuryParticipants'),
r=b('MercurySeenByAll'),
s=b('MercuryServerRequests'),
t=b('MercuryThreadlistIconTemplates'),
u=b('MercuryThreads').get(),
v=b('Tooltip'),
w=b('URI'),

x=b('createArrayFrom'),
y=b('cx'),
z=b('tx'),

aa=m.create('wm_timestamp');

e.exports=

{renderTimestamp:
function(da,ea,fa,ga){
if(ga){
if(!ea){
aa.warn('no_title');
ea=(new Date(ga)).toLocaleDateString();}

da.setAttribute('title',ea);

if(!fa){
aa.warn('no_display');
fa=Date.format
(g['24h_times']?'H:i':'g:ia',
Math.floor(ga/1000));}




j.setContent(da,fa);
i.show(da);}},



renderMessageSourceTags:function(da,ea,fa,ga){
var ha=h.MercuryMessageSourceTags,
ia='',
ja='',
ka='';

if(fa.contains(ha.MESSENGER)){
ia="Sent from Messenger";
ja=new w('/mobile/messenger');
ka="_9g";}else
if(fa.contains(ha.MOBILE)){
ia="Sent from Mobile";
ja=new w('/mobile/');
ka="_9j";}else
if(fa.contains(ha.CHAT)){
ia="Sent from chat";
ka="_9h";}else
if(fa.contains(ha.EMAIL)){
if(ga){
ia=z._("Sent from {email}",{email:ga});}else 

ia="Sent from email";

ka="_9i";}


if(ka){
v.set(da,ia);
i.addClass(ea,ka);
if(ja){
da.setAttribute('href',ja);}else 

da.removeAttribute('href');}else 


i.hide(da);},



renderMessageLocation:function(da,ea,fa){
var ga=w('/ajax/messaging/hovercard/map.php').
setQueryData(fa);
da.setAttribute('data-hovercard',ga);
i.removeClass
(da,
"_b9");

i.show(ea);},


renderSpoofWarning:function(da,ea,fa){
if(ea){
i.addClass(da,"_sa");
v.set
(da,
z._("Unable to confirm {name_or_email} as the sender.",{name_or_email:fa.name}));}},




renderChatSpoofWarning:function(da,ea,fa){
if(ea)
j.appendContent
(da,
z._("Unable to confirm {name_or_email} as the sender.",{name_or_email:fa.name}));},


















renderCoreThreadlist:
function(da,
ea,
fa,
ga,
ha){
ga=ga||{};

this.renderThreadImage
(da,
ea.getNode('image'));


ca
(da,
ea.getNode('name'),
ga);


if(da.folder&&ha)
ba
(ea.getNode('folderBadge'),
da.folder);



var ia=ea.getNode('timestamp');
this.renderTimestamp
(ia,
da.timestamp_absolute,
da.timestamp_relative,
da.timestamp);


this.renderSnippet
(da,ea.getNode('snippet'));


fa(ea,da);},









renderAndSeparatedParticipantList:
function(da,
ea,
fa){
fa=fa||{};
fa.last_separator_uses_and=true;
u.getThreadMeta(da,function(ga){
ca(ga,ea,fa);}.
bind(this));},







renderSnippet:function(da,ea){

var fa=j.create('span');
i.addClass(fa,'MercuryRepliedIndicator');
j.appendContent(ea,fa);
r.updateOnSeenChange(fa,da);







if(da.snippet_has_attachment)
if(!da.snippet&&da.snippet_attachments){
da.snippet_attachments.forEach(function(ja){
if(ja.attach_type!=h.MercuryAttachmentType.FILE)
return;

var ka=
n.getAttachIconClass(ja.icon_type),
la=
t[':fb:mercury:attachment-icon-text'].
build().getRoot();
if(ja.metadata&&ja.metadata.type=='fb_voice_message'){

j.appendContent
(la,
"Voice Message");}else 


j.appendContent(la,ja.name);

i.addClass(la,ka);
j.appendContent(ea,la);}.
bind(this));}else 

j.appendContent(ea,
j.create
('span',
{className:'MercuryAttachmentIndicator'}));






if(da.is_forwarded_snippet){
var ga;
if(da.snippet){
ga="Forwarded Message:";}else 

ga="Forwarded Message";



j.appendContent(ea,
j.create
('strong',
{className:'mercuryForwardedIndicator'},
ga));}




var ha=da.snippet;
if(ha)


if(ha.substr(0,4)=='?OTR'){

ha="[encrypted message]";}else 

ha=ha.replace(/\r\n|[\r\n]/g," ");






var ia=da.participants.length;
if(da.is_subscribed)
ia--;

if(da.snippet_sender&&
q.user!=da.snippet_sender&&
ia>1){
q.get(da.snippet_sender,function(ja){
if(ja.short_name)
ha=z._("{name}: {conversation_snippet}",
{name:ja.short_name,conversation_snippet:ha});

j.appendContent
(ea,
k(o.htmlEmojiAndEmote(ha)));});}else 



j.appendContent
(ea,
k(o.htmlEmojiAndEmote(ha)));},




renderTitanLink:function(da,ea,fa){
if(da.substr(0,da.indexOf(':'))=='user'){
p.renderUserCanonicalTitanLink
(da,
ea,
fa);}else 



s.getServerThreadID(da,function(ga){
p.renderTitanLinkWithServerID
(ga,
ea,
fa);});},










renderThreadImage:function(da,ea){
if(da.image_src){
this._renderThreadImageSingle(da.image_src,ea);
return;}


var fa=[],
ga=da.participants.filter(function(ha){
return ha!=q.user;});

if(!ga.length){
fa=[q.user];}else
if(ga.length==1){
fa=[ga[0]];}else{

fa=ga.slice(0,3);


if(fa.length==2)
fa.push(q.user);}



q.getMulti(fa,function(ha){
var ia=fa.map(function(ja){
return ha[ja];});

this.renderParticipantImages(ia,ea);}.
bind(this));},


renderParticipantImages:function(da,ea){
if(da.length>2){
this._renderThreadImageSplit(da,ea);}else 

this._renderThreadImageSingle
(da[0].image_src,
ea);},

















renderParticipantList:
function(da,
ea,
fa,
ga){
return p.renderRawParticipantList
(s.getServerThreadIDNow(da),
ea,
fa,
ga);},



renderThreadNameAndParticipantList:
function(da,
ea,
fa,
ga){
var ha=
p.renderRawParticipantList
(s.getServerThreadIDNow(da),
ea,
fa,
ga),

ia=u.getThreadMetaNow(da);
if(!ia.name)
return ha;

return z._("{conversation_name} [with {participant_list}]",

{conversation_name:ia.name,
participant_list:ha});},






















renderParticipantCount:function(da,ea){
return p.renderRawParticipantCount
(s.getServerThreadIDNow(da),
ea);},


_renderThreadImageSingle:function(da,ea){
var fa=
l[':fb:mercury:thread-image:single'].
build().getRoot();
fa.src=da;
j.setContent(ea,fa);},


_renderThreadImageSplit:function(da,ea){
var fa=
l[':fb:mercury:thread-image:split'].
build().
setNodeProperty('left','src',da[0].image_src).
setNodeProperty('topRight','src',da[1].image_src).
setNodeProperty('bottomRight','src',da[2].image_src);

j.setContent(ea,fa.getRoot());}};












function ba(da,ea){
x(da).forEach(function(fa){
j.setContent(fa,ea);});}











function ca(da,ea,fa){
ea=x(ea);


if(da.name){
var ga=p.renderRawTitleWithUnreadCount
(da.name,
fa.show_unread_count?da.unread_count:0);


ea.forEach(function(ia){
j.setContent(ia,ga);});


fa.callback&&fa.callback(ga);
return;}


var ha=da.participants;
if(da.participants.length>1)
ha=da.participants.filter(function(ia){
return ia!=q.user;});



q.getMulti(ha,function(ia){
p.renderParticipantListWithNoThreadName
(s.getServerThreadIDNow(da.thread_id),
da,
ha,
ia,
ea,
fa);}.
bind(this));}});

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



b('function-extensions');

var g=b('copyProperties');









function h(i){
this._isDirty=false;
this._obj=i;}


g(h.prototype,





{dirty:function(){
if(!this._isDirty){
this._isDirty=true;
this._doPaint.bind(this).defer();}},









_doPaint:function(){
this._isDirty=false;

this._obj.paint();}});




e.exports=h;});

/** js/messaging/modules/CounterDisplay.js */
__d("CounterDisplay",["Arbiter","CSS","DOM","RenderManager","Run","$","copyProperties"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('CSS'),
i=b('DOM'),
j=b('RenderManager'),
k=b('Run'),

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








function n(o,p,q,
r,s,t){
m(this,
{_name:o,
_valueNode:l(p),
_wrapperNode:l(q)||null,
_statusClass:s,
_rm:new j(this),
_arbiterSubscription:null,
_count:0});







var u=this._valueNode.firstChild;
if(u){
var v=parseInt(u.nodeValue,10);
if(!isNaN(v))
this._count=v;}



this._statusNode=r?l(r):null;

this._subscribeAll();

n.instances.push(this);




if(!t)

k.onLeave(this._destroy.bind(this),true);}



m(n,

{EVENT_TYPE_ADJUST:'CounterDisplay/adjust',
EVENT_TYPE_UPDATE:'CounterDisplay/update',

instances:[],










adjustCount:function(o,p){
g.inform(n.EVENT_TYPE_ADJUST+'/'+o,p);},








setCount:function(o,p){
g.inform(n.EVENT_TYPE_UPDATE+'/'+o,p);}});



m(n.prototype,





{_destroy:function(){
delete this._valueNode;
delete this._wrapperNode;
if(this._arbiterSubscription){
this._arbiterSubscription.unsubscribe();
delete this._arbiterSubscription;}

n.instances.remove(this);},










adjustCount:function(o){
this._count=Math.max(0,this._count+o);

this._rm.dirty();

return this;},








setCount:function(o){
this._count=Math.max(0,o);

this._rm.dirty();

return this;},


paint:function(){
i.setContent(this._valueNode,this._count);
this._toggleNodes();},


_toggleNodes:function(){
if(this._wrapperNode)
h.conditionClass(this._wrapperNode,'hidden_elem',this._count<=0);


if(this._statusClass&&this._statusNode)
h.conditionClass(this._statusNode,
this._statusClass,
this._count>0);},






_subscribeAll:function(){
var o=
[n.EVENT_TYPE_ADJUST+'/'+this._name,
n.EVENT_TYPE_UPDATE+'/'+this._name];


this._arbiterSubscription=g.subscribe(o,
this._onInform.bind(this),
g.SUBSCRIBE_NEW);},





_onInform:function(o,p){
p=parseInt(p);
if(isNaN(p))

return;


if(o.indexOf(n.EVENT_TYPE_ADJUST)!=-1){
this.adjustCount(p);}else
if(o.indexOf(n.EVENT_TYPE_UPDATE)!=-1){
this.setCount(p);}else 


return;


return;}});



e.exports=n;});

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



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

3);

/** js/messaging/MessagingLeftNavCount.js */










function startMessagingNavCountUpdater(a){
var b=FutureSideNav.getInstance().getNodeForKey('inbox');


if(!b)
return;



var c=FutureSideNav.getInstance().getNodeForKey('other'),
d=
DOM.scry(c,'span.count')[0],
e=
DOM.scry(d,'span.countValue')[0],
f=
DOM.scry(d,'span.maxCountIndicator')[0];

new CounterMaxDisplay('other_unseen',
e,
d,
null,
null,
true).
setMaxCounter(a,f);}








function CounterMaxDisplay(){
this._maxValue=null;
this._maxIndicatorNode=null;
var a=[this].concat($A(arguments));
return this.parent.construct.apply(this.parent,a);}


Class.extend(CounterMaxDisplay,'CounterDisplay');

copyProperties(CounterMaxDisplay.prototype,



{setMaxCounter:function(a,b){
this._maxValue=a;
this._maxIndicatorNode=b;},






paint:function(){
var a=this._maxValue&&this._count>this._maxValue,
b=a?this._maxValue:this._count;



if(this._maxIndicatorNode){
DOM.setContent(this._maxIndicatorNode,a?'+':'');}else
if(a)
b=b+'+';


DOM.setContent(this._valueNode,b);
this._toggleNodes();}});

/** js/modules/AsyncLayout.js */
__d("AsyncLayout",["AjaxPipeRequest","Arbiter","AsyncRequest","AsyncResponse","CSS","DOM","HTML","NavigationMessage","PageTransitions","URI","$","copyProperties","emptyFunction","ge","goURI"],function(a,b,c,d,e,f){



var g=b('AjaxPipeRequest'),
h=b('Arbiter'),
i=b('AsyncRequest'),
j=b('AsyncResponse'),
k=b('CSS'),
l=b('DOM'),
m=b('HTML'),
n=b('NavigationMessage'),
o=b('PageTransitions'),
p=b('URI'),

q=b('$'),
r=b('copyProperties'),
s=b('emptyFunction'),
t=b('ge'),
u=b('goURI');






function v(w){
this.canvasID=w;

if(t('rightCol'))
this.auxiliaryID='rightCol';

if(t('headerArea'))
this.headerID='headerArea';

if(t('toolbarContainer'))
this.toolbarID='toolbarContainer';

this.waitingForAux=false;

o.registerHandler(this.catchPageTransition.bind(this));

this.subscription=h.subscribe
(n.NAVIGATION_BEGIN,
this.onNavigate.bind(this));}



r(v.prototype,

{catchPageTransition:function(w){
this.subscription.unsubscribe();
return false;},


getCanvasID:function(w){
return w.sidecol?'contentCol':'contentArea';},


onNavigate:function(w,x){
var y=x.useAjaxPipe;
x=x.params;
if(x.endpoint){

if(this.request){
this.request.setFinallyHandler(s);
this.request.abort();}


if(this.sideRequest)
this.sideRequest.abort();


if(y){


this.request=new g().
setURI(x.endpoint).
setData(x).
setCanvasId(this.getCanvasID(x)).
setFinallyHandler(this.finallyHandler.bind(this)).
setErrorHandler(this.errorHandler.bind(this)).
setFirstResponseCallback(this.firstResponseCallback.bind(this)).
send();}else{

x.handled=true;

this.waitingForAux=x.sidecol;


var z=!!x.iframe,
aa=
new i().
setOption('useIframeTransport',z).
setURI(new p(x.endpoint)).
setReadOnly(true).
setMethod('GET').
setData(x).
setHandler(this.onResponse.bind(this)).
setErrorHandler(this.errorHandler.bind(this)).
setFinallyHandler(this.finallyHandler.bind(this));
this.request=aa;
aa.send();}}},




onSideResponse:function(w){
var x=w.getPayload();
if(x&&this.auxiliaryID)
this.receivedAux(x);},



receivedAux:function(w){
!this.waitingForAux;





this.waitingForAux=false;

l.setContent(q(this.auxiliaryID),m(w));},


onResponse:function(w){
var x=w.getPayload();
if(x.redirect){
u(x.redirect);}else{

var y=x.html||x;
l.setContent(q(this.canvasID),m(y));

if(x.side_html&&this.auxiliaryID)
this.receivedAux(x.side_html);


if(this.headerID&&!x.keep_header){
var z=q(this.headerID);
l.setContent(z,m(x.header_html||''));



k.conditionShow(z,x.header_html);}


if(x.toolbar_html&&this.toolbarID)
l.setContent(q(this.toolbarID),m(x.toolbar_html));


if(x.js)
(new Function(x.js))();


k.conditionClass
('contentCol',
'hasRightCol',
this.auxiliaryID&&!x.noRightSide);






var aa=t('rightCol');
if(aa&&x.noRightSide)
l.empty(aa);}



var ba=w.getRequest().getData();
h.inform(n.NAVIGATION_COMPLETED,ba.key);},


errorHandler:function(w){
j.verboseErrorHandler(w);
h.inform(n.NAVIGATION_FAILED);
this.request=null;},


firstResponseCallback:function(w){
window.scrollTo(0,0);
h.inform(n.NAVIGATION_FIRST_RESPONSE);},


finallyHandler:function(w){
this.request=null;
o.transitionComplete(true);
h.inform(n.NAVIGATION_COMPLETED);}});



e.exports=v;});

/** js/music/MusicButtonStore.js */
__d("MusicButtonStore",[],function(a,b,c,d,e,f){



var g={},

h=
{addButton:function(i,j){
g[i]=j;
return j;},


getButton:function(i){
return g[i];},


getButtons:function(){
return g;},


removeButton:function(i){
g[i]&&g[i].resetLoadingTimers();
delete g[i];}};



e.exports=h;});

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



var g=b('URI'),

h=
{DEBUG:false,


LIVE_LISTEN_MIN_SPOTIFY_VERSION:'spotify-0.6.6.0.g5a9eaca5',

enableDebug:function(){
this.DEBUG=true;},


sameURLs:function(i,j){
var k=/\/$/;
if(i&&j){

i=g(i);
j=g(j);
return i.getDomain()==j.getDomain()&&
i.getPath()==j.getPath();}

return false;},





greaterOrEqualToMinimumVersion:function(i,j){

var k=/(?:\d+\.)+/,
l=i.match(k)[0].split('.').slice(0,-1),
m=j.match(k)[0].split('.').slice(0,-1);
if(l.length!==m.length)
return false;







for(var n=0;n<m.length;n++)
if(+l[n]<+m[n]){
return false;}else
if(+l[n]>+m[n])
return true;




return true;},


sanitizeForProviders:function(i){
var j={};
for(var k in i)
if(this.ALLOWED_EXTERNAL_CONTEXT_PARAMS[k])
j[k]=i[k];


return j;},





OP:
{RESUME:'RESUME',
PAUSE:'PAUSE',
PLAY:'PLAY',
VERSION:'VERSION'},





STATUS_CHANGE_OP:
{STATUS:'STATUS',
LOGIN:'LOGIN',
REINFORM:'REINFORM'},



STATUS_CHANGE_EVENT:
{playing:'PLAY_STATE_CHANGED',
track:'TRACK_CHANGED'},




DIAGNOSTIC_EVENT:
{ALL_PAUSED:'ALL_PAUSED',
ALL_OFFLINE:'ALL_OFFLINE',
OFFLINE:'OFFLINE',
ONLINE:'ONLINE',
SEARCHING:'SEARCHING',
HIT:'HIT',
MISS:'MISS',
RESIGN:'RESIGN',
IFRAME_POLLING:'IFRAME_POLLING',
RELAUNCH:'RELAUNCH',
STATE_CHANGE:'STATE_CHANGE',
WRONG_VERSION:'WRONG_VERSION',
SERVICE_ERROR:'SERVICE_ERROR',
INCORRECT_ONLINE_STATE:'INCORRECT_ONLINE_STATE',
LOG_SEND_OP:'LOG_SEND_OP',
REQUEUE_OP:'REQUEUE_OP'},


ALLOWED_STATUS_PARAMS:
{playing:'playing',
track:'track',
context:'context',
client_version:'client_version',
start_time:'start_time',
expires_in:'expires_in',
open_graph_state:'open_graph_state'},


ALLOWED_EXTERNAL_CONTEXT_PARAMS:

{uri:true,
song:true,
radio_station:true,
album:true,
playlist:true,
musician:true,
song_list:true,
offset:true,
title:true,
request_id:true,
listen_with_friends:true,
needs_tos:true},


LIVE_LISTEN_OP:
{NOW_LEADING:'NOW_LEADING',
NOW_LISTENING:'NOW_LISTENING',
END_SESSION:'END_SESSION',
SONG_PLAYING:'SONG_PLAYING',
LISTENER_UPDATE:'LISTENER_UPDATE',
QUEUE_SESSION:'QUEUE_SESSION',
PLAY_ERROR:'PLAY_ERROR',
SESSION_UPDATED:'SESSION_UPDATED',
QUEUING_SESSION:'QUEUING_SESSION'},


MUSIC_BUTTON:
{ACTIVATE:'ACTIVATE'},


ERROR:
{1:'SERVICE_UNAVAILABLE_WITHOUT_PREMIUM',
2:'SERVICE_UNAVAILABLE_WITHOUT_PREMIUM_OR_WAIT',
3:'SERVICE_UNAVAILABLE_BILLING_ISSUE',
4:'SERVICE_UNAVAILABLE_TECHNICAL_ISSUE',
5:'AUDIO_AD_PLAYING',

99:'SERVICE_TEMPORARILY_UNAVAILABLE',

101:'SONG_UNAVAILABLE_WITHOUT_PURCHASE',
102:'SONG_UNAVAILABLE_WITHOUT_PREMIUM',
103:'SONG_UNAVAILABLE_INDEFINITELY'}};




e.exports=a.MusicConstants||h;});

/** js/music/MusicEvents.js */
__d("MusicEvents",["Arbiter"],function(a,b,c,d,e,f){







var g=b('Arbiter');



e.exports=a.MusicEvents=new g();});

/** js/music/MusicWaterfallLogger.js */
__d("MusicWaterfallLogger",["JSLogger"],function(a,b,c,d,e,f){



var g=b('JSLogger'),

h=g.create('music_waterfall'),

i=
{click:function(l){
j('click',l);},


musicLoadedFromClick:function(l){
j('music_loaded_from_click',l);},


playPause:function(l){
j('play_pause',l);}};



function j(l,m){
h.debug(l+'_debug',m);
h.bump(l);
h.bump(l+'_'+k(m));}


function k(l){
return l?
l.replace(/\.|-/g,'_'):
'';}


e.exports=i;});

/** js/music/MusicButton.js */
__d("MusicButton",["Bootloader","copyProperties","CSS","DOM","MusicButtonStore","MusicConstants","MusicEvents","MusicWaterfallLogger","Parent","Tooltip"],function(a,b,c,d,e,f){



var g=b('Bootloader'),
h=b('copyProperties'),
i=b('CSS'),
j=b('DOM'),
k=b('MusicButtonStore'),
l=b('MusicConstants'),
m=b('MusicEvents'),
n=b('MusicWaterfallLogger'),
o=b('Parent'),
p=b('Tooltip'),

q=

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

this.provider=r;
this.buttonElem=s;
this.url=t;
this.context=u||{};
this.mediaType=v;
this.setState(this.STATES.OFFLINE);
this.tooltip=w||'';

m.subscribe(l.MUSIC_BUTTON.ACTIVATE,
this.processClick.bind(this));};


h(q,
{tracksetableTypes:[]});


h(q.prototype,
{SHOW_LOADING_TIMEOUT:500,
HIDE_LOADING_TIMEOUT:4000,
RECENTLY_ONLINE_TIMEOUT:6000,


STATES:
{PLAYING:'music_playing',
PAUSED:'music_paused',
LOADING:'music_loading',
DISABLED:'music_disabled',
OFFLINE:'music_offline'},


setState:function(r){
if(r!==this.STATES.LOADING){
this.resetLoadingTimers();
this.previousState=this.state||r;}

if(r===this.STATES.PLAYING){
p.set(this.buttonElem,this.tooltip);}else 

p.set(this.buttonElem,'');


var s=this.buttonElem.parentNode;
this.state&&i.removeClass(s,this.state);
this.state=r;
i.addClass(s,this.state);},


isTracksetable:function(r){
return q.tracksetableTypes.indexOf(this.mediaType)!==-1;},


handleIncomingEvent:function(r,s){
clearTimeout(this._showLoadingTimer);
if(s&&s.provider&&
s.provider!=this.provider)
return;


switch(r){
case l.DIAGNOSTIC_EVENT.ONLINE:
case l.STATUS_CHANGE_EVENT.track:
case l.STATUS_CHANGE_EVENT.playing:
var t=s&&s.track&&s.track.uri,
u=s&&s.context&&s.context.uri;

if(s&&s.playing&&
(l.sameURLs(t,this.url)||
l.sameURLs(u,this.url))){
this.setState(this.STATES.PLAYING);}else
if(this.state===this.STATES.LOADING&&
(this.previousState===this.STATES.PAUSED||
this.previousState===this.STATES.OFFLINE)){



clearTimeout(this._attemptingPlayTimer);
this._attemptingPlayTimer=
this.setState.
bind(this,this.STATES.PAUSED).
defer(this.RECENTLY_ONLINE_TIMEOUT,false);}else
if(!this._attemptingPlayTimer)
this.setState(this.STATES.PAUSED);

break;
case l.DIAGNOSTIC_EVENT.OFFLINE:
this.setState(this.STATES.OFFLINE);
break;
case l.DIAGNOSTIC_EVENT.ALL_OFFLINE:
this.setState(this.STATES.OFFLINE);
break;}},



processClick:function(r,s){
if(s!=this.buttonElem){



if(this.state===this.STATES.LOADING)
this.previousState&&this.setState(this.previousState);

return;}


n.click(this.provider);


var t=this.isTracksetable()&&
o.byClass(this.buttonElem,'music_trackset_container'),
u=[];
if(t){
var v=t.getAttribute('data-trackset-title'),
w=this.provider,

x=j.scry(t,'.music_button');
for(var y=0;y<x.length;y++){
var z=k.getButton([x[y].id]);
if(z&&z.provider==w&&z.isTracksetable())

u.push(z.url);}}






if(!a.Music)
this.showLoading(true);


g.loadModules(['Music'],function(aa){
n.musicLoadedFromClick(this.provider);
var ba=(t&&u.length>1)?
aa.playPauseSongList
(this.provider,this.url,u,v,this.context):
aa.playPauseSong(this.provider,this.url,this.context);
this.showLoading(!ba);}.
bind(this));},


showLoading:function(r){
this.resetLoadingTimers();
this._hideLoadingTimer=
this._timeout.
bind(this,r).
defer(this.HIDE_LOADING_TIMEOUT,false);
this._showLoadingTimer=
this.setState.
bind(this,this.STATES.LOADING).
defer(this.SHOW_LOADING_TIMEOUT,false);},


resetLoadingTimers:function(){
clearTimeout(this._hideLoadingTimer);
clearTimeout(this._showLoadingTimer);
clearTimeout(this._attemptingPlayTimer);
this._attemptingPlayTimer=null;},


destroy:function(){
this.resetLoadingTimers();
this.buttonElem=null;},


_timeout:function(r){






a.Music&&a.Music.reInform([this.provider]);


if(!r&&this.state===this.STATES.LOADING)
this.setState(this.STATES.PAUSED);}});








e.exports=q;});

/** js/music/MusicButtonManager.js */
__d("MusicButtonManager",["Event","DOM","KeyedCallbackManager","Layer","MusicButton","MusicButtonStore","MusicConstants","MusicEvents","Parent","$","copyProperties","ge"],function(a,b,c,d,e,f){



var g=b('Event'),

h=b('DOM'),
i=b('KeyedCallbackManager'),
j=b('Layer'),
k=b('MusicButton'),
l=b('MusicButtonStore'),
m=b('MusicConstants'),
n=b('MusicEvents'),
o=b('Parent'),

p=b('$'),
q=b('copyProperties'),
r=b('ge'),



s=new i(),

t=null,
u={},

v=0;


function w(event){
var da=event.getTarget(),
ea=o.byClass(da,'music_button');

ea=ea||
(!event.getModifiers().any&&x(da));
if(!ea)
return;

return y(ea,event);}




function x(da){
var ea=o.byClass(da,'music_button_trigger')&&
o.byClass(da,'music_button_trigger_group');
if(ea){

var fa=h.scry(ea,'.music_button');
if(fa.length)
return fa[0];}


return null;}



function y(da,event){
event&&event.stop();
n.inform(m.MUSIC_BUTTON.ACTIVATE,da);
return false;}



function z(da){
a.Music&&a.Music.reInform(da);}



function aa(da,ea){
var fa=l.getButtons();
for(var ga in fa)
if(fa[ga].noGC||r(ga)){
fa[ga].handleIncomingEvent(da,ea);}else 



l.removeButton(ga);}




var ba=
{init:function(da){
if(t)
return;

t=true;
k.tracksetableTypes=da||[];
g.listen(document.body,'click',w);

n.subscribe

([m.STATUS_CHANGE_EVENT.playing,
m.STATUS_CHANGE_EVENT.track,
m.DIAGNOSTIC_EVENT.OFFLINE,
m.DIAGNOSTIC_EVENT.ALL_OFFLINE,
m.DIAGNOSTIC_EVENT.ONLINE],

aa);},



add:
function(da,
ea,
fa,
ga,
ha,
ia){

t||ba.init();

var ja=ea.id,
ka=l.getButton(ja);
if(ka)







return ka;


ka=l.addButton
(ja,
new k
(da,
ea,
fa,
q({button_id:ja},ga),
ha,
ia));





var la=o.byClass(ea,'uiOverlay');
if(la){
ka.noGC=true;

var ma=j.subscribe
('destroy',
function(na,oa){
if(h.contains(oa.getRoot(),ea)){
l.removeButton(ja);
j.unsubscribe(ma);}});}






if(da&&!u[da])
u[da]=function(){
var na=Object.keys(u);
na.length&&z(na);
u={};}.
defer();

return ka;},


addButton:
function(da,
ea,
fa,
ga,
ha,
ia){

if(!r(ea))






return;


var ja=p(ea);
return ba.add
(da,
ja,
fa,
ga,
ha,
ia);},



asyncAddMusicButton:function(da,ea){

da.setAttribute('id','music_button_'+v++);
ca(da,ea);},


tryAddButtonInDOM:function(da,ea){
var fa=r(da);
fa&&ca(fa,ea);},


addMusicData:
function(da,
ea,
fa,
ga,
ha,
ia){

s.setResource(da,
{provider:ea,
uri:fa,
context:ga,
media_type:ha,
tooltip:ia});}};




function ca(da,ea){
var fa=h.find(da,'a.button_anchor').getAttribute('href');

s.executeOrEnqueue(fa,function(ga){
return ba.add
(ga.provider,
da,
ga.uri,
ga.context,
ga.media_type,
ea?ga.tooltip:'');});}



e.exports=a.MusicButtonManager||ba;});

/** js/photos/bulk/BulkTagLoader.js */
__d("BulkTagLoader",["AsyncRequest","copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('AsyncRequest'),

h=b('copyProperties'),
i=b('emptyFunction'),

j=false;

function k(){}

h(k,

{loadForSet:function(l){
if(!j){
j=true;
new g('/ajax/photos/sets/tags_fetch.php').
setHandler(i).
setData({set:l}).
send();}},



loadForAlbum:function(l){
if(!j){
j=true;
new g('/ajax/photos/album/tags_fetch.php').
setHandler(i).
setData({fbid:l}).
send();}},



reset:function(){
j=false;}});




e.exports=k;});

/** js/presence/LiveMessageReceiver.js */
__d("LiveMessageReceiver",["Arbiter","AsyncRequest","ChannelConstants","copyProperties","emptyFunction"],function(a,b,c,d,e,f){



var g=b('Arbiter'),
h=b('AsyncRequest'),
i=b('ChannelConstants'),

j=b('copyProperties'),
k=b('emptyFunction');




































function l(m){
this.eventName=m;
this.subs=null;
this.handler=k;
this.shutdownHandler=null;

this.registered=false;



this.appId=1;}


j(l,
{getAppMessageType:function(m,n){
return 'live_message/'+m+':'+n;},








route:function(m){
var n=function(o){
var p=l.getAppMessageType
(m.app_id,
m.event_name);

g.inform
(p,
o,
g.BEHAVIOR_PERSISTENT);};



if(m.hasCapture){
new h().
setHandler(function(o){
n(o.getPayload());}).

setAllowCrossPageTransition(true).
handleResponse(m.response);}else 

n(m.response);}});




j(l.prototype,
{setAppId:function(m){
this.appId=m;
return this;},










setHandler:function(m){
this.handler=m;
this._dirty();
return this;},


setRestartHandler:k,









setShutdownHandler:function(m){
this.shutdownHandler=m.shield();
this._dirty();
return this;},


_dirty:function(){

if(this.registered){
this.unregister();
this.register();}},






register:function(){
var m=function(o,p){
return this.handler(p);}.
bind(this),

n=l.getAppMessageType
(this.appId,
this.eventName);


this.subs={};
this.subs.main=g.subscribe(n,m);
if(this.shutdownHandler)
this.subs.shut=g.subscribe
(i.ON_SHUTDOWN,
this.shutdownHandler);



this.registered=true;
return this;},






unregister:function(){
if(!this.subs)
return this;

for(var m in this.subs)
if(this.subs[m])
this.subs[m].unsubscribe();


this.subs=null;
this.registered=false;
return this;}});



e.exports=l;});

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



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

3);

/** js/reminders/ReminderStory.js */
__d("ReminderStory",["Event","DOMQuery"],function(a,b,c,d,e,f){



var g=b('Event'),
h=b('DOMQuery');

function i(j,k){
g.listen(j,'click',function(l){
k.show();});


k.subscribe('aftershow',function(){
var l=k.getRoot(),


m=h.scry(l,'.inlineReplyTextArea');



if(m.length>0)
m[0].focus();});}




e.exports=i;});

/** js/ui/xhp/typeahead/ClearableTypeahead.js */
__d("ClearableTypeahead",["Event"],function(a,b,c,d,e,f){



var g=b('Event'),

h=
{resetOnCloseButtonClick:function(i,j){
g.listen(j,'click',function(){
var k=i.getCore();



k.getElement().focus();
k.reset();});}};




e.exports=h;});

/** js/ui/xhp/typeahead/behaviors/TypeaheadShowLoadingIndicator.js */
__d("TypeaheadShowLoadingIndicator",["CSS","copyProperties"],function(a,b,c,d,e,f){



var g=b('CSS'),

h=b('copyProperties');

function i(j){
this._typeahead=j;}


h(i.prototype,
{_subscription:null,

enable:function(){
this._subscription=
this._typeahead.subscribe('loading',function(j,k){
g.conditionClass
(this._typeahead.getElement(),
'typeaheadLoading',
k.loading);

g.conditionClass
(this._typeahead.getView().getElement(),
'typeaheadViewLoading',
k.loading);}.

bind(this));},


disable:function(){
this._typeahead.unsubscribe(this._subscription);
this._subscription=null;}});




e.exports=i;});

/** js/ui/xhp/typeahead/behaviors/LegacyShowLoadingIndicatorTypeaheadBehavior.js */
__d("legacy:ShowLoadingIndicatorTypeaheadBehavior",["TypeaheadShowLoadingIndicator"],function(a,b,c,d){



var e=b('TypeaheadShowLoadingIndicator');

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


3);
