(void0==m.Ember||void0==m.App||void0==App.EmoticonsController||void0==App.Room?6E4<=d?this.log('Twitch API not detected in "'+location.toString()+'". Aborting.'):setTimeout(this.init.bind(this,b,(d||0)+b),b):this.setup())};c.prototype.setup=function(){this.alive&&(this.log("Hooking Ember application."),this.modify_room(),this.modify_viewers(),this.modify_emotes(),this.modify_lines(),this.log("Loading data."),this.load_donors(),this.load_emotes("global"),document.body||(this.listen_dom=this.listen_dom.bind(this),
"<br>"));d=d.split("\n");for(vara=0;a<d.length;a++)b.addMessage({style:"ffz admin",from:"FFZ",message:d[a]})};c.prototype.run_command=function(b,d){vara=(d.substr(5)||"list").split(" "),g=a.shift().toLowerCase();this.log("Got FFZ Command: "+g+" "+JSON.stringify(a));(a=(g=c.commands[g])?g.bind(this)(b,a):"No such sub-command.")&&this._msg(b,a)};c.commands.help=function(b,d){if(d&&0<d.length){vara=c.commands[d[0].toLowerCase()];returna?a&&void0==a.help?"No help available for: "+d[0]:a.help:"No such sub-command: "+
d[0]}varg=[];for(ainc.commands)c.commands.hasOwnProperty(a)?g.push(a):!1;return"Available sub-commands are: "+g.join(", ")};c.commands.help.help="Usage: /ffz help [command]\nList available commands, or show help for a specific command.";c.commands.log=function(b,d){vara="FrankerFaceZ Session Log\n\n"+this._log.join("\n"),a=a+"\n\n--------------------------------------------------------------------------------\nInternal State\n\nChannels:\n",g;for(ginthis.channels)if(this.channels.hasOwnProperty(g)){varc=
"",g,c=this.has_bttv;d&&0<d.length&&(g=d.join(" ").toLowerCase());c&&(a+='<table style="width:100%">');for(varfinthis.collections){if(!this.collections.hasOwnProperty(f))return;if(g?-1!==f.toLowerCase().indexOf(g):"FFZ Global Emotes"!==f){vara=c?a+('<thead><th colspan="2">'+f+"</th></thead><tbody>"):a+(f+"\n"),e=this.collections[f],l;for(line)if(e.hasOwnProperty(l)){vark=e[l],n=k.text;c?a+='<tr style="line-height:'+k.image.height+'px"><td>'+n+"</td><td>"+k.image.html+"</td></tr>":(n=n[0]+"\u200b"+
n.substr(1),a+=" "+n+" = "+k.text+"\n")}c&&(a+="</tbody>")}}c&&(a+="</table>");return-1===a.indexOf(c?"<td>":"\u200b")?"There are no available FFZ channel emoticons. If this is in error, please try the /ffz reload command.":"The following emotes are available:\n"+a};c.commands.list.help="Usage: /ffz list [global]\nList available FFZ emoticons. Use the global parameter to list ALL FFZ emoticons, or filter for a specific set.";c.commands.global=function(b,d){returnc.commands.list.bind(this)(b,["global"])};
c.commands.global.help="Usage: /ffz global\nShorthand for /ffz list global. List ALL FFZ emoticons, including FFZ global emoticons.";c.commands.reload=function(b,d){for(varainthis.channels)this.channels.hasOwnProperty(a)&&this.channels[a]&&this.load_emotes(a,!0);this.load_emotes("global");this.load_donors();return"Attempting to reload FFZ data from the server."};c.commands.reload.help="Usage: /ffz reload\nAttempt to reload FFZ emoticons and donors.";c.commands.inject=function(b,d){if(!d||1!==d.length)return"/ffz inject requires exactly 1 argument.";
vara=d[0].split("/").pop().split("?").shift().split("#").shift();this._msg(b,'Attempting to load test emoticons from imgur album "'+a+'"...');varc="https://api.imgur.com/3/album/"+a;m.localStorage&&localStorage.removeItem("ffz_"+c);this.get(c,this.do_imgur.bind(this,b,a),1,{Accept:"application/json",Authorization:"Client-ID e48d122e3437051"},5)};c.commands.inject.help="Usage: /ffz inject [album-id]\nLoads emoticons from an imgur album for testing. album-id can simply be the album URL. Ex: /ffz inject http://imgur.com/a/v4aZr";
c.prototype.do_imgur=function(b,d,a){if(void0===a)returnthis._msg(b,"An error occurred communicating with Imgur.");if(!a)returnthis._msg(b,"The named album does not exist or is private.");a=JSON.parse(a).data;a=a.images;for(varg="",h=0;h<a.length;h++){varf=a[h],e=f.title?f.title:d+(h+1),l=18<f.height?(f.height-18)/-2:0,k=f.description?f.description.trim().split(/(?:\W*\n\W*)+/):void0,n="";if(k)for(varq=0;q<k.length;q++)if("css: "===k[q].substr(0,5).toLowerCase()){n=k[q].substr(5);break}g+=
".imgur-"+d+"-"+(h+1)+' {content: "'+e+'"; background-image: url("'+f.link+'"); height: '+f.height+"px; width: "+f.width+"px; margin: "+l+"px 0px; "+n+"}\n"}a=this.process_css("imgur-"+d,"FFZ Global Emotes - Imgur Album: "+d,g);this._msg(b,"Loaded "+a+" emoticons from Imgur.");this._msg(b,c.commands.list.bind(this)(b,[d]))};c.prototype.find_bttv=function(b,d){if(this.alive){if(m.BTTVLOADED)returnthis.setup_bttv();void0===d&&this.log("BetterTTV not yet loaded. Waiting...");6E4<=d?this.log('BetterTTV not detected in "'+
b))})})};c.prototype.modify_viewers=function(){this._modify_viewers(App.Room.Viewers)};c.prototype._modify_emotes=function(b){vard=this;b.reopen({_emoticons:b.emoticons||[],init:function(){this._super();d.alive&&d.get_manager(this)},emoticons:Ember.computed(function(a,b){1<arguments.length&&(this._emoticons=b,d.log("Twitch standard emoticons loaded."));returnd.alive?_.union(this._emoticons,d.emoticons):this._emoticons})})};c.prototype.modify_emotes=function(){this._modify_emotes(App.EmoticonsController);
b)||0)}}r||!f||void0!==a&&null!==a&&e-f>a?(this.log("Resource expired. Fetching: "+b),this.do_get(b,d,0,c,h)):this.getting[b]=!1}};c.prototype.do_get=function(b,d,a,c,h){functionf(){vare=(a||0)+1;if(!h||e<=h)returnsetTimeout(k.do_get.bind(k,b,d,e,c,h),1E3),!0}if(this.alive){vare=newXMLHttpRequest;e.open("GET",b);if(c)for(varlinc)c.hasOwnProperty(l)&&e.setRequestHeader(l,c[l]);vark=this;e.addEventListener("error",function(a){if(!f()){k.getting[b]=!1;try{d(void0)}catch(c){k.log("Error in callback: "+
c)}}},!1);e.addEventListener("load",function(a){if(200===e.status){if(a=e.responseText,m.localStorage){varc=localStorage.getItem("ffz_last_"+b),g=e.getResponseHeader("Last-Modified");if(c&&c==g){k.log("Resource not modified: "+b);localStorage.setItem("ffz_age_"+b,(newDate).getTime());k.getting[b]=!1;return}localStorage.setItem("ffz_last_"+b,g)}}else{if(304===e.status){k.log("Resource not modified: "+b);m.localStorage&&localStorage.setItem("ffz_age_"+b,(newDate).getTime());k.getting[b]=!1;return}if(404===
e.status)a=null;else{if(f())return;a=void0}}m.localStorage&&void0!==a&&(localStorage.setItem("ffz_"+b,JSON.stringify(a)),localStorage.setItem("ffz_age_"+b,(newDate).getTime()));k.getting[b]=!1;try{d(a)}catch(h){k.log("Error in callback: "+h)}},!1);e.send()}elsethis.getting[b]=!1};m.ffz=newc}})(this.unsafeWindow||window,window.chrome?!0:!1);