|
|
var weechat;!function(){"use strict";var e=angular.module("localStorage",[]);function t(){this.storage=Object.create(null),this.keyIndex=[],Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.keyIndex.length}})}t.prototype.key=function(e){return this.keyIndex[e]},t.prototype.getItem=function(e){return e in this.storage?this.storage[e]:null},t.prototype.setItem=function(e,t){e in this.storage||this.keyIndex.push(e),this.storage[e]=t},t.prototype.clear=function(){this.storage=Object.create(null),this.keyIndex=[]},t.prototype.removeItem=function(e){if(e in storage){var t=this.keyIndex.indexOf(e);this.keyIndex.splice(t,1),delete this.storage[e]}},e.factory("$store",["$parse",function(i){var r=void 0===window.localStorage?void 0:window.localStorage,o=!(void 0===r||void 0===window.JSON);try{var e="eaf23ffe-6a8f-40a7-892b-4baf22d3ec75";r.setItem(e,1),r.removeItem(e)}catch(e){console.log("Warning: MobileSafari private mode detected. Switching to in-memory storage."),r=new t}o||console.log("Warning: localStorage is not supported");var a=function(t){var n;try{void 0===(n=JSON.parse(t))&&(n=t),"true"===n&&(n=!0),"false"===n&&(n=!1),parseFloat(n)!=n||angular.isObject(n)||(n=parseFloat(n))}catch(e){n=t}return n},s={set:function(e,t){o||console.log("Local Storage not supported");var n=JSON.stringify(t);return r.setItem(e,n),a(n)},get:function(e){if(!o)return null;var t=r.getItem(e);return a(t)},remove:function(e){return!!o&&(r.removeItem(e),!0)},enumerateKeys:function(){for(var e=[],t=0,n=r.length;t<n;++t)e.push(r.key(t));return e},bind:function(e,t,n){return void 0===n&&(n=""),void 0!==s.get(t)&&null!==s.get(t)||s.set(t,n),i(t).assign(e,s.get(t)),e.$watch(t,function(e){s.set(t,e)},!0),s.get(t)}};return s}])}(),function(e){"use strict";var m;(m=function(){this._types={chr:this._getChar,int:this._getInt,str:this._getString,inf:this._getInfo,hda:this._getHdata,ptr:this._getPointer,lon:this._getStrNumber,tim:this._getTime,buf:this._getString,arr:this._getArray,htb:this._getHashTable,inl:this._getInfolist},this._typesStr={chr:this._strDirect,str:this._strDirect,int:this._strToString,tim:this._strToString,ptr:this._strDirect}})._weeChatColorsNames=["default","black","darkgray","red","lightred","green","lightgreen","brown","yellow","blue","lightblue","magenta","lightmagenta","cyan","lightcyan","gray","white"],m._colorsOptionsNames=["separator","chat","chat_time","chat_time_delimiters","chat_prefix_error","chat_prefix_network","chat_prefix_action","chat_prefix_join","chat_prefix_quit","chat_prefix_more","chat_prefix_suffix","chat_buffer","chat_server","chat_channel","chat_nick","chat_nick_self","chat_nick_other","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","chat_host","chat_delimiters","chat_highlight","chat_read_marker","chat_text_found","chat_value","chat_prefix_buffer","chat_tags","chat_inactive_window","chat_inactive_buffer","chat_prefix_buffer_inactive_buffer","chat_nick_offline","chat_nick_offline_highlight","chat_nick_prefix","chat_nick_suffix","emphasis","chat_day_change"],m._getDefaultColor=function(){return{type:"weechat",name:"default"}},m._getDefaultAttributes=function(){return{name:null,override:{bold:!1,reverse:!1,italic:!1,underline:!1}}},m._getDefaultStyle=function(){return{fgColor:m._getDefaultColor(),bgColor:m._getDefaultColor(),attrs:m._getDefaultAttributes()}},m._cloneColor=function(e){var t={};for(var n in e)t[n]=e[n];return t},m._cloneAttrs=function(e){var t={};for(var n in t.name=e.name,t.override={},e.override)t.override[n]=e.override[n];return t},m._attrNameFromChar=function(e){var t={"*":"b","!":"r","/":"i",_:"u","":"b","":"r","":"i","":"u"};return e in t?t[e]:null},m._attrsFromStr=function(e){for(var t=m._getDefaultAttributes(),n=0;n<e.length;++n){var i=e.charAt(n);if("|"===i)return null;var r=m._attrNameFromChar(i);null!==r&&(t.override[r]=!0)}return t},m._getColorObj=function(e){if(2===e.length){var t=parseInt(e);return 16<t?m._getDefaultColor():{type:"weechat",name:m._weeChatColorsNames[t]}}var n=e.substring(1);return{type:"ext",name:parseInt(n).toString()}},m._getStyle=function(n){var i={fgColor:null,bgColor:null,attrs:null,text:n};return[{regex:/^(\d{2})/,fn:function(e){var t={},n=parseInt(e[1]);if(n>=m._colorsOptionsNames.length)return{fgColor:null,bgColor:null,attrs:null};var i=m._colorsOptionsNames[n];return t.fgColor={type:"option",name:i},t.bgColor=m._cloneColor(t.fgColor),t.attrs={name:i,override:{}},t}},{regex:/^@(\d{5})/,fn:function(e){return{fgColor:null,bgColor:null,attrs:null}}},{regex:/^F(?:([*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))/,fn:function(e){var t={bgColor:null};return e[2]?(t.attrs=m._attrsFromStr(e[1]),t.fgColor=m._getColorObj(e[2])):(t.attrs=m._attrsFromStr(e[3]),t.fgColor=m._getColorObj(e[4])),t}},{regex:/^B(\d{2}|@\d{5})/,fn:function(e){return{fgColor:null,bgColor:m._getColorObj(e[1]),attrs:null}}},{regex:/^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5})),(\d{2}|@\d{5})/,fn:function(e){var t={};return e[2]?(t.attrs=m._attrsFromStr(e[1]),t.fgColor=m._getColorObj(e[2])):(t.attrs=m._attrsFromStr(e[3]),t.fgColor=m._getColorObj(e[4])),t.bgColor=m._getColorObj(e[5]),t}},{regex:/^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,fn:function(e){return{fgColor:m._getColorObj(e[2]),bgColor:null,attrs:m._attrsFromStr(e[1])}}},{regex:/^E/,fn:function(e){var t={fgColor:{type:"option",name:"emphasis"}};return t.bgColor=m._cloneColor(t.fgColor),t.attrs={name:"emphasis",override:{}},t}}].some(function(e){var t=n.match(e.regex);return!!t&&((i=e.fn(t)).text=n.substring(t[0].length),!0)}),i},m.rawText2Rich=function(e){var t=e.split(/(\x19|\x1a|\x1b|\x1c)/);if(1===t.length)return[{attrs:m._getDefaultAttributes(),fgColor:m._getDefaultColor(),bgColor:m._getDefaultColor(),text:t[0]}];var u=m._getDefaultColor(),l=m._getDefaultColor(),f=m._getDefaultAttributes(),d=null,h=!0;return t.map(function(e){if(0===e.length)return null;var t=e.charCodeAt(0),n=e.charAt(0);if(25<=t&&t<=28)return 28===t&&(u=m._getDefaultColor(),l=m._getDefaultColor(),25!==d&&(f=m._getDefaultAttributes())),d=t,null;var i=e;if(25===d){var r=m._getStyle(e);null!==r.fgColor&&(u=r.fgColor),null!==r.bgColor&&(l=r.bgColor),null!==r.attrs&&(f=r.attrs),i=r.text}else if(26===d||27===d){var o=26===d;if("|"!==n){var a=m._attrNameFromChar(n);a&&(f.override[a]=o,i=e.substring(1))}}if(d=null,0===i.length)return null;if(h&&null===f.name){var s=!0;for(var c in f.override)if(f.override[c]){s=!1;break}s?f.override={}:h=!1}return{fgColor:m._cloneColor(u),bgColor:m._cloneColor(l),attrs:m._cloneAttrs(f),text:i}}).filter(function(e){return null!==e})},m._uia2s=function(t){if(!t.length||0===t[0])return"";try{var e=String.fromCharCode.apply(null,t);return decodeURIComponent(escape(e))}catch(e){for(var n="",i=0,r=t.length;i<r;i++)n+=t[i]<128?String.fromCharCode(t[i]):"?";return n}},m._mergeParams=function(e,t){for(var n in t)e[n]=t[n];return e},m._formatCmd=function(e,t,n){var i,r;return i=null!==e?"("+e+") ":"",i+=t,n.unshift(i),r=n.join(" "),(r+="\n").replace(/[\r\n]+$/g,"").split("\n"),r},m.formatInit=function(e){var t=[],n=[];return e=m._mergeParams({password:null,compression:"zlib"},e),t.push("compression="+e.compression),null!==e.password&&t.push("password="+e.password),n.push(t.join(",")),m._formatCmd(null,"init",n)},m.formatHdata=function(e){var t=[];return e=m._mergeParams({id:null,keys:null},e),t.push(e.path),null!==e.keys&&t.push(e.keys.join(",")),m._formatCmd(e.id,"hdata",t)},m.formatInfo=function(e){var t=[];return e=m._mergeParams({id:null},e),t.push(e.name),m._formatCmd(e.id,"info",t)},m.formatInfolist=function(e){var t=[];return e=m._mergeParams({id:null,pointer:null,args:null},e),t.push(e.name),null!==e.pointer&&t.push(e.pointer),null!==e.pointer&&t.push(e.args),m._formatCmd(e.id,"infolist",t)},m.formatNicklist=function(e){var t=[];return null!==(e=m._mergeParams({id:null,buffer:null},e)).buffer&&t.push(e.buffer),m._formatCmd(e.id,"nicklist",t)},m.formatInput=function(e){var t=[];return e=m._mergeParams({id:null},e),t.push(e.buffer),t.push(e.data),m._formatCmd(e.id,"input",t)},m._formatSyncDesync=function(e,t){var n=[];return null!==(t=m._mergeParams({id:null,buffers:null,options:null},t)).buffers&&(n.push(t.buffers.join(",")),null!==t.options&&n.push(t.options.join(","))),m._formatCmd(t.id,e,n)},m.formatSync=function(e){return m._formatSyncDesync("sync",e)},m.formatDesync=function(e){return m._formatSyncDesync("desync",e)},m.formatTest=function(e){return e=m._mergeParams({id:null},e),m._formatCmd(e.id,"test",[])},m.formatQuit=function(){return m._formatCmd(null,"quit",[])},m.formatPing=function(e){var t=[];return null!==(e=m._mergeParams({id:null,args:null},e)).args&&t.push(e.args.join(" ")),m._formatCmd(e.id,"ping",t)},m.prototype={_warnUnimplemented:function(e){console.log("Warning: "+e+" message parsing is not implemented")},_getType:function(){var e=this._getSlice(3);return e?m._uia2s(new Uint8Array(e)):null},_runType:function(e){return this._types[e].bind(this)()},_getStrNumber:function(){var e=this._getByte(),t=this._getSlice(e);return m._uia2s(new Uint8Array(t))},_strDirect:function(e){return e},_strToString:function(e){return e.toString()},_objToString:function(e,t){return this._typesStr[t].bind(this)(e)},_getInfo:function(){var e={};return e.key=this._getString(),e.value=this._getString(),e},_getHdata:function(){var e,t,n=this,i=[],r=this._getString(),o=this._getString().split(",");function a(){var t={};t.pointers=e.map(function(e){return n._getPointer()}),o.forEach(function(e){t[e[0]]=n._runType(e[1])}),i.push(t)}e=r.split("/"),t=this._getInt(),o=o.map(function(e){return e.split(":")});for(var s=0;s<t;s++)a();return i},_getPointer:function(){return this._getStrNumber()},_getTime:function(){var e=this._getStrNumber();return new Date(1e3*parseInt(e,10))},_getInt:function(){var e=new Uint8Array(this._getSlice(4));return(255&e[0])<<24|(255&e[1])<<16|(255&e[2])<<8|255&e[3]},_getByte:function(){return new Uint8Array(this._getSlice(1))[0]},_getChar:function(){return this._getByte()},_getString:function(){var e=this._getInt();if(0<e){var t=this._getSlice(e),n=new Uint8Array(t);return m._uia2s(n)}return""},_getHeader:function(){return{length:this._getInt(),compression:this._getByte()}},_getId:function(){return this._getString()},_getObject:function(){var e=this._getType();if(e)return{type:e,content:this._runType(e)}},_getHashTable:function(){var e,t,n,i={};e=this._getType(),t=this._getType(),n=this._getInt();for(var r=0;r<n;++r){var o=this._runType(e),a=this._objToString(o,e),s=this._runType(t);i[a]=s}return i},_getArray:function(){var e,t,n;e=this._getType(),t=this._getInt(),n=[];for(var i=0;i<t;i++)n.push(this._runType(e));return n},_getInfolist:function(){var e,t;this._getString(),e=this._getInt(),t=[];for(var n=0;n<e;n++){for(var i=this._getInt(),r=[],o=0;o<i;o++){var a={};a[this._getString()]=this._runType(this._getType()),r.push(a)}t.push(r)}return t},_getSlice:function(e){if(this.dataAt+e>this._data.byteLength)return null;var t=this._data.slice(this._dataAt,this._dataAt+e);return this._dataAt+=e,t},_setData:function(e){this._data=e},setId:function(e,t){return"("+e+") "+t},parse:function(e,t){this._setData(e),this._dataAt=0;var n=this._getHeader();if(n.compression){var i=new Uint8Array(e,5),r=new Zlib.Inflate(i).decompress();this._setData(r.buffer),this._dataAt=0}for(var o=this._getId(),a=[],s=this._getObject();s;)a.push(s),s=this._getObject();return{header:n,id:o,objects:a}}},e.Protocol=m}("undefined"==typeof exports?this.weeChat={}:exports),function(){"use strict";angular.module("IrcUtils",[]).service("IrcUtils",[function(){var g=function(t,e){var n=null;return e.some(function(e){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&(n=e,!0)}),n},p=function(e,t,n){for(var i=[],r=null,o=e.toLowerCase(),a=t.toLowerCase(),s=0;s<n.length;++s){var c=n[s].toLowerCase();0===c.indexOf(o)&&(i.push(n[s]),a===c&&(r=i.length-1))}return null===r||0===i.length?t:(++r===i.length&&(r=0),i[r])};return{completeNick:function(e,t,n,i,r,o){var a=null!==n;void 0===r&&(r=":");var s,c=void 0===o||!0===o?" ":"",u=(s=_(i).sortBy(function(e){return-e.spokeAt}),s=_(s).pluck("name")),l=e.substring(0,t),f=e.substring(t),d={text:e,caretPos:t,foundNick:null,iterCandidate:null},h=l.match(new RegExp("^([a-zA-Z0-9_\\\\\\[\\]{}^`|-]+)"+r+" $")),m=null;return h?a?{text:(l=(m=p(n,h[1],u))+r+" ")+f,caretPos:l.length,foundNick:m,iterCandidate:n}:d:(h=l.match(/^([a-zA-Z0-9_\\\[\]{}^`|-]+)$/))?null===(m=g(h[1],u))?d:(l=m+r+" "," "===f[0]&&(f=f.substring(1)),{text:l+f,caretPos:l.length,foundNick:m,iterCandidate:h[1]}):(h=l.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+) $/))?a?(m=p(n,h[2],u),{text:(l=h[1]+m+c)+f,caretPos:l.length,foundNick:m,iterCandidate:n}):d:(h=l.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+)$/))?null===(m=g(h[2],u))?d:(l=h[1]+m+c," "===f[0]&&(f=f.substring(1)),{text:l+f,caretPos:l.length,foundNick:m,iterCandidate:h[2]}):d}}}])}(),function(){"use strict";document.addEventListener("deviceready",function(){void 0!==navigator.splashscreen&&navigator.splashscreen.hide()},!1);var r=angular.module("weechat",["ngRoute","localStorage","weechatModels","bufferResume","plugins","IrcUtils","ngSanitize","ngWebsockets","ngTouch"],["$compileProvider",function(e){r.compileProvider=e}]);r.config(["$compileProvider",function(e){"undefined"==typeof it&&"undefined"==typeof describe&&e.debugInfoEnabled(!1)}]),r.controller("WeechatCtrl",["$rootScope","$scope","$store","$timeout","$log","models","bufferResume","connection","notifications","utils","settings",function(a,s,e,c,t,o,n,u,l,f,d){window.openBuffer=function(e){s.openBuffer(e),s.$apply()},s.command="",s.themes=["dark","light","black","dark-spacious","blue","base16-default","base16-light","base16-mocha","base16-ocean-dark","base16-solarized-dark","base16-solarized-light"],s.swipeStatus=1,d.setDefaults({theme:"dark",host:"localhost",port:9001,ssl:"https:"===window.location.protocol,savepassword:!1,autoconnect:!1,nonicklist:f.isMobileUi(),alwaysnicklist:!1,noembed:!0,onlyUnread:!1,hotlistsync:!0,orderbyserver:!0,useFavico:!f.isCordova(),soundnotification:!0,fontsize:"14px",fontfamily:f.isMobileUi()?"sans-serif":"Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace",readlineBindings:!1,enableJSEmoji:!f.isMobileUi(),enableMathjax:!1,enableQuickKeys:!0,customCSS:"",currentlyViewedBuffers:{}}),s.settings=d,a.countWatchers=function(){t.debug(a.$$watchersCount)},void 0!==document.hidden?(s.documentHidden="hidden",s.documentVisibilityChange="visibilitychange"):void 0!==document.webkitHidden?(s.documentHidden="webkitHidden",s.documentVisibilityChange="webkitvisibilitychange"):void 0!==document.mozHidden?(s.documentHidden="mozHidden",s.documentVisibilityChange="mozvisibilitychange"):void 0!==document.msHidden&&(s.documentHidden="msHidden",s.documentVisibilityChange="msvisibilitychange"),window.location.search.substring(1).split("&").forEach(function(e){var t=e.split("=");"debug"===t[0]&&-1!=["true","1"].indexOf(t[1])&&(a.debugMode=!0)}),a.debugMode&&!r.compileProvider.debugInfoEnabled()&&angular.reloadWithDebugInfo(),s.show_tls_warning="https:"!==window.location.protocol&&-1===["localhost","127.0.0.1","::1"].indexOf(window.location.hostname)&&!window.is_electron&&!f.isCordova(),window.is_electron&&(emojione.imageType="svg",emojione.sprites=!0,emojione.imagePathSVGSprites="./3rdparty/emojione.sprites.svg"),a.isWindowFocused=function(){return void 0===s.documentHidden||!document[s.documentHidden]},void 0!==s.documentVisibilityChange&&document.addEventListener(s.documentVisibilityChange,function(){if(!document[s.documentHidden]){var e=o.getActiveBuffer();if(null!==e)o.getServerForBuffer(e).unread-=e.unread+e.notification,e.unread=0,e.notification=0,a.$emit("notificationChanged");a.$apply()}},!1),a.$on("activeBufferChanged",function(e,t){var n=o.getActiveBuffer(),i=n.lines.length-(2*s.lines_per_screen+10);if(0<i&&(n.lines.splice(0,i),n.requestedLines-=i,n.lastSeen-=i,n.allLinesFetched=!1),s.bufferlines=n.lines,s.nicklist=n.nicklist,n.nicklistRequested()?s.updateShowNicklist():u.requestNicklist(n.id,function(){s.updateShowNicklist(),a.scrollWithBuffer(!0)}),n.requestedLines<s.lines_per_screen){var r=s.lines_per_screen+10;r<t&&(r=Math.min(4*r,t)),s.fetchMoreLines(r).then(function(){c(function(){var t=document.getElementById("bufferlines"),n=t.scrollHeight,i=function(){if(t){var e=t.scrollHeight;e!==n&&(a.updateBufferBottom(a.bufferBottom),n=e),setTimeout(i,500)}};a.updateBufferBottom(!0),a.scrollWithBuffer(!0),t.onscroll=_.debounce(function(){a.updateBufferBottom()},80),setTimeout(i,500)})})}l.updateTitle(n),setTimeout(function(){s.notifications=l.unreadCount("notification"),s.unread=l.unreadCount("unread")}),c(function(){a.scrollWithBuffer(!0)}),s.search="",s.search_placeholder="Search",f.isMobileUi()||setTimeout(function(){document.getElementById("sendMessage").focus()},0),d.hotlistsync&&n.fullName&&u.sendHotlistClear()}),f.isCordova()||(a.favico=new Favico({animation:"none"})),s.notifications=l.unreadCount("notification"),s.unread=l.unreadCount("unread"),a.$on("notificationChanged",function(){l.updateTitle(),s.notifications=l.unreadCount("notification"),s.unread=l.unreadCount("unread"),!f.isCordova()&&d.useFavico&&a.favico&&l.updateFavico()}),a.$on("relayDisconnect",function(){a.pageTitle="",a.notificationStatus="",l.cancelAll(),void 0!==window.plugin&&void 0!==window.plugin.notification&&void 0!==window.plugin.notification.local&&window.plugin.notification.local.cancelAll(),o.reinitialize(),a.$emit("notificationChanged"),s.connectbutton="Connect",s.connectbuttonicon="glyphicon-chevron-right",n.reset()}),s.connectbutton="Connect",s.connectbuttonicon="glyphicon-chevron-right",s.getBuffers=o.getBuffers.bind(o),s.bufferlines={},s.nicklist={},s.activeBuffer=o.getActiveBuffer,a.connected=!1,a.waseverconnected=!1,a.userdisconnect=!1,a.reconnecting=!1,a.models=o,a.iterCandidate=null,d.savepassword?(s.$watch("password",function(){d.password=s.password}),d.addCallback("password",function(e){s.password=e}),s.password=d.password):d.password="",d.addCallback("savepassword",function(e){d.savepassword&&(d.setDefaults({password:s.password}),d.password=s.password)}),a.wasMobileUi=!1,f.isMobileUi()&&(a.wasMobileUi=!0),d.fontfamily||(f.isMobileUi()?d.fontfamily="sans-serif":d.fontfamily="Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace"),s.isSidebarVisible=function(){return"visible"===document.getElementById("content").getAttribute("sidebar-state")},s.swipeRight=function(){1===s.swipeStatus||(0===s.swipeStatus?s.showSidebar():-1===s.swipeStatus?(s.swipeStatus=0,s.updateShowNicklist()):(console.log("Weird swipe status:",s.swipeStatus),s.swipeStatus=0,s.updateShowNicklist(),s.hideSidebar()))},a.swipeLeft=function(){1===s.swipeStatus?s.hideSidebar():0===s.swipeStatus?(s.swipeStatus=-1,s.updateShowNicklist()||(s.swipeStatus=0)):-1===s.swipeStatus||(console.log("Weird swipe status:",s.swipeStatus),s.swipeStatus=0,s.updateShowNicklist(),s.hideSidebar())},s.showSidebar=function(){document.getElementById("sidebar").setAttribute("data-state","visible"),document.getElementById("content").setAttribute("sidebar-state","visible"),f.isMobileUi()&&_.each(document.getElementsByTagName("textarea"),function(e){c(function(){e.blur()})}),s.swipeStatus=1},a.hideSidebar=function(){f.isMobileUi()&&(document.getElementById("sidebar").setAttribute("data-state","hidden"),document.getElementById("content").setAttribute("sidebar-state","hidden")),s.swipeStatus=0},d.addCallback("autoconnect",function(e){!e||a.connected||a.sslError||a.securityError||a.errorMessage||s.connect()}),s.toggleSidebar=function(){f.isMobileUi()&&(s.isSidebarVisible()?s.hideSidebar():s.showSidebar())};var i=function(e){a.showJumpKeys?a.predicate="$jumpKey":a.predicate=e?"serverSortKey":"number"};d.addCallback("orderbyserver",i),a.refresh_filter_predicate=function(){i(d.orderbyserver)},d.addCallback("useFavico",function(e){a.connected&&(f.isCordova()||(e?l.updateFavico():(a.favico.reset(),l.updateBadge(""))))}),d.addCallback("enableMathjax",function(e){f.isCordova()||!e||a.mathjax_init||(a.mathjax_init=!0,f.inject_css("https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css"),f.inject_script("https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"),f.inject_script("https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js"))}),d.addCallback("theme",function(e){var t=document.getElementById("themeCSS");t&&t.parentNode.removeChild(t),f.inject_css("css/themes/"+e+".css","themeCSS")}),d.addCallback("customCSS",function(e){var t=document.getElementById("custom-css-tag");t&&t.parentNode.removeChild(t);var n=document.createElement("style");n.type="text/css",n.id="custom-css-tag",n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n)}),d.addCallback("fontfamily",function(e){f.changeClassStyle("favorite-font","fontFamily",e)}),d.addCallback("fontsize",function(e){"number"==typeof e&&(e=e.toString()),e.match(/^[0-9]+$/)&&(e+="px"),f.changeClassStyle("favorite-font","fontSize",e)}),s.setActiveBuffer=function(e,t){return f.isMobileUi()&&s.hideSidebar(),1<=o.version[0]&&u.sendHotlistClear(),o.setActiveBuffer(e,t)},s.openBuffer=function(e){var t=o.getActiveBuffer().fullName;if(t=t.substring(0,t.lastIndexOf(".")+1)+e,!s.setActiveBuffer(t,"fullName")){var n="join -noswitch";["#","&","+","!"].indexOf(e.charAt(0))<0&&(n="query",(1==o.version[0]&&2<=o.version[1]||1<o.version[1])&&(n+=" -noswitch")),u.sendMessage("/"+n+" "+e)}},s.calculateNumLines=function(){for(var e=document.querySelectorAll(".bufferline"),t=0,n=0;0===t&&n<e.length;)t=e[n++].clientHeight;var i=document.querySelector("#bufferlines").clientHeight,r=Math.ceil(i/t+10);s.lines_per_screen=r},s.calculateNumLines(),window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame,window.addEventListener("resize",_.debounce(function(){if(a.connected&&(s.wasMobileUi&&!f.isMobileUi()&&(s.showSidebar(),s.updateShowNicklist()),s.wasMobileUi=f.isMobileUi(),s.calculateNumLines(),a.bufferBottom)){var e=function(){a.updateBufferBottom(!0)};c(e,500),window.requestAnimationFrame(e)}},100)),a.loadingLines=!1,s.fetchMoreLines=function(e){return e||(e=s.lines_per_screen),u.fetchMoreLines(e)},s.infiniteScroll=function(){a.loadingLines||(o.getActiveBuffer().allLinesFetched||s.fetchMoreLines())},a.updateBufferBottom=function(e){var t=document.getElementById("end-of-buffer"),n=document.getElementById("bufferlines");e&&t.scrollIntoView(),a.bufferBottom=t.offsetTop<=n.scrollTop+n.clientHeight},a.scrollWithBuffer=function(n,i){var r=document.getElementById("bufferlines"),o=r.scrollHeight-r.clientHeight,e=function(){var e=r.scrollTop;if((n||i)&&e<o||Math.abs(e-o)<3){var t=document.querySelector(".readmarker");if(n&&t)r.scrollTop=t.offsetTop-t.parentElement.scrollHeight+t.scrollHeight;else if(i)r.scrollTop=r.scrollHeight-r.clientHeight-o;else{document.getElementById("end-of-buffer").scrollIntoView()}a.updateBufferBottom()}};c(e),window.requestAnimationFrame(e)},s.connect=function(){l.requestNotificationPermission(),a.sslError=!1,a.securityError=!1,a.errorMessage=!1,a.bufferBottom=!0,s.connectbutton="Connecting",s.connectbuttonicon="glyphicon-refresh glyphicon-spin",u.connect(d.host,d.port,s.password,d.ssl)},s.disconnect=function(){s.connectbutton="Connect",s.connectbuttonicon="glyphicon-chevron-right",n.reset(),u.disconnect()},s.reconnect=function(){var e=o.getActiveBuffer().id;u.attemptReconnect(e,3e3)},s.showModal=function(e){document.getElementById(e).setAttribute("data-state","visible")},s.closeModal=function(e){(function(e,t){for(var n=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;e;){if(n.call(e,t))return e;e=e.parentElement}})(e.target,".gb-modal").setAttribute("data-state","hidden")},s.toggleAccordion=function(e){e.stopPropagation(),e.preventDefault();var t=e.target.parentNode.parentNode.parentNode;t.setAttribute("data-state","active"===t.getAttribute("data-state")?"collapsed":"active");var n=t.parentNode.children;for(var i in n){var r=n[i];1===r.nodeType&&r!==t&&r.setAttribute("data-state","collapsed")}},s.hasUnread=function(e){return!(!s.search||""===s.search)||(d.onlyUnread?o.getActiveBuffer()===e||("core.weechat"===e.fullName||(d.orderbyserver&&"server"===e.type?0<o.getServerForBuffer(e).unread:!!e.pinned||(0<e.unread&&!e.hidden||0<e.notification))):!e.hidden)},a.bufferlistfilter=function(e){if(a.showJumpKeys){if(void 0===a.jumpDecimal)return!0;var t=10*a.jumpDecimal,n=10*(a.jumpDecimal+1);return t<=e.$jumpKey&&e.$jumpKey<n}return-1!==e.fullName.toLowerCase().indexOf(s.search.toLowerCase())},d.addCallback("nonicklist",function(){s.updateShowNicklist(),a.connected&&a.bufferBottom&&c(function(){a.updateBufferBottom(!0)},500)}),d.addCallback("alwaysnicklist",function(){s.updateShowNicklist()}),s.showNicklist=!1,s.updateShowNicklist=function(){var e=o.getActiveBuffer();return!e||e.isNicklistEmpty()?s.showNicklist=!1:!f.isMobileUi()&&d.nonicklist?!(s.showNicklist=!1):f.isMobileUi()&&!d.alwaysnicklist&&-1!==s.swipeStatus?!(s.showNicklist=!1):s.showNicklist=!0},a.switchToActivityBuffer=function(){var e,t,n=_.sortBy(s.getBuffers(),"number");for(e in n)if(0<(t=n[e]).notification)return void s.setActiveBuffer(t.id);for(e in n)if(0<(t=n[e]).unread&&!t.hidden)return void s.setActiveBuffer(t.id)},a.toggleNicklist=function(){d.nonicklist=!d.nonicklist},a.switchToAdjacentBuffer=function(e){for(var t,n=_.sortBy(s.getBuffers(),a.predicate),i=o.getActiveBuffer(),r=n.indexOf(i)+e;0<=r&&r<n.length&&(!t||t.hidden);)t=n[r],r+=e;t&&s.setActiveBuffer(t.id)},s.handleSearchBoxKey=function(e){var t=e.keyCode?e.keyCode:e.charCode;if(27===t)e.preventDefault(),s.search="";else if(13===t){var n;e.preventDefault(),0<s.filteredBuffers.length&&(n=s.search_highlight_key?s.search_highlight_key:0,s.setActiveBuffer(s.filteredBuffers[n].id)),s.search=""}else 38===t?(e.preventDefault(),s.search_highlight_key&&0<s.search_highlight_key&&(s.search_highlight_key=s.search_highlight_key-1)):s.search_highlight_key=40===t||9===t?(e.preventDefault(),s.search_highlight_key+1):0},a.supports_formatting_date=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"!==e.name&&t.info("Browser does not support toLocaleDateString(), falling back to en-US"),"RangeError"===e.name}return t.info("Browser does not support toLocaleDateString(), falling back to en-US"),!1}(),window.onbeforeunload=function(e){null!==s.command&&""!==s.command?(e.preventDefault(),e.returnValue="Any unsent input will be lost. Are you sure that you want to quit?"):(a.connected&&s.disconnect(),f.isCordova()||s.favico.reset())},s.init=function(){if(window.location.hash){var e=atob(window.location.hash.substring(1));window.location.hash="";var t=e.split(":"),n=t[0],i=parseInt(t[1]),r=t[2],o=3<t.length;l.requestNotificationPermission(),a.sslError=!1,a.securityError=!1,a.errorMessage=!1,a.bufferBottom=!0,s.connectbutton="Connecting",s.connectbuttonicon="glyphicon-chevron-right",u.connect(n,i,r,o)}}}]),r.config(["$routeProvider",function(e){e.when("/",{templateUrl:"index.html",controller:"WeechatCtrl"})}])}(),function(){"use strict";angular.module("weechat").factory("settings",["$store","$rootScope",function(r,o){var a=this;this.callbacks={},this.cache={};var n=function(i){Object.defineProperty(a,i,{enumerable:!0,key:i,get:function(){return i in this.cache||(this.cache[i]=r.get(i)),this.cache[i]},set:function(e){this.cache[i]=e,r.set(i,e);for(var t=a.callbacks[i],n=0;void 0!==t&&n<t.length;n++)t[n](e);setTimeout(function(){o.$apply()},0)}})},e=r.enumerateKeys();for(var t in e){var i=e[t];n(i)}return this.addCallback=function(e,t,n){void 0===this.callbacks[e]?this.callbacks[e]=[t]:this.callbacks[e].push(t),setTimeout(function(){t(r.get(e))},0)},this.setDefaults=function(e){for(var t in e)null===r.get(t)&&(n(t),this[t]=e[t])},this}])}(),(weechat=angular.module("weechat")).factory("utils",function(){return{changeClassStyle:function(e,t,n){_.each(document.getElementsByClassName(e),function(e){e.style[t]=n})},getClassStyle:function(e,t){_.each(document.getElementsByClassName(e),function(e){return e.style[t]})},isMobileUi:function(){return document.body.clientWidth<968},isCordova:function(){return void 0!==window.cordova},inject_script:function(e){var t=document.createElement("script");t.type="text/javascript",t.src=e,document.getElementsByTagName("head")[0].appendChild(t)},inject_css:function(e,t){var n=document.createElement("link");n.rel="stylesheet",n.href=e,t&&(n.id=t),document.getElementsByTagName("head")[0].appendChild(n)}}}),(weechat=angular.module("weechat")).factory("notifications",["$rootScope","$log","models","settings","utils",function(n,t,f,s,d){var h=!1,m=[],i=function(e){e||(e="unread");var t=Object.keys(f.model.buffers),n=0;for(var i in t)n+=f.model.buffers[t[i]][e];return n},r=function(e){"function"==typeof setElectronBadge&&setElectronBadge(e)};return{requestNotificationPermission:function(){if(window.Notification&&Notification.requestPermission(function(e){t.info("Notification permission status: ",e),Notification.permission!==e&&(Notification.permission=e)}),void 0!==window.webkitNotifications){var e=window.webkitNotifications.checkPermission();0!==e&&(t.info("Notification permission status: ",0===e),window.webkitNotifications.requestPermission())}"serviceWorker"in navigator&&1!==window.is_electron&&(t.info("Service Worker is supported"),navigator.serviceWorker.register("serviceworker.js").then(function(e){t.info("Service Worker install:",e),h=!0}).catch(function(e){t.info("Service Worker err:",e)})),document.addEventListener("deviceready",function(){d.isCordova()&&void 0!==window.cordova.plugins&&void 0!==window.cordova.plugins.notification&&void 0!==window.cordova.plugins.notification.local&&window.cordova.plugins.notification.local.on("click",function(e){var t=JSON.parse(e.data);f.setActiveBuffer(t.buffer),window.focus(),window.cordova.plugins.notification.local.clear(e.id)})})},updateTitle:function(){var e=i("notification");n.notificationStatus=0<e?"("+e+") ":"";var t=f.getActiveBuffer();t&&(n.pageTitle=t.shortName+" | "+t.rtitle)},updateFavico:function(){if(!d.isCordova()){var e=i("notification");if(0<e)n.favico.badge(e,{bgColor:"#d00",textColor:"#fff"}),r(e);else{var t=i("unread");0===t?(n.favico.reset(),r("")):(n.favico.badge(t,{bgColor:"#5CB85C",textColor:"#ff0"}),r("•"))}}},updateBadge:r,createHighlight:function(e,t){var n="",i="",r=e.notification;if("private"===e.type)n=1<r?r.toString()+" private messages from ":"Private message from ",i=t.text;else{n=1<r?r.toString()+" highlights in ":"Highlight in ";for(var o="",a=0;a<t.prefix.length;a++)o+=t.prefix[a].text;i="<"+o+"> "+t.text}(function(e,t,n){if(h)navigator.serviceWorker.ready.then(function(e){e.showNotification(t,{body:n,icon:"assets/img/glowing_bear_128x128.png",vibrate:[200,100],tag:"gb-highlight-vib"})});else if("undefined"!=typeof Windows&&void 0!==Windows.UI&&void 0!==Windows.UI.Notifications){var i=Windows.UI.Notifications,r=i.ToastNotificationManager.createToastNotifier(),o=i.ToastTemplateType.toastText02,a=i.ToastNotificationManager.getTemplateContent(o),s=a.getElementsByTagName("text");s[0].appendChild(a.createTextNode(t)),s[1].appendChild(a.createTextNode(n));var c=new i.ToastNotification(a);c.onactivated=function(){f.setActiveBuffer(e.id),window.focus()},r.show(c)}else if("undefined"!=typeof Notification){var u=new Notification(t,{body:n,icon:"assets/img/favicon.png"});u.id=m.length,m.push(u),u.onshow=function(){setTimeout(function(){u.close()},15e3)},u.onclick=function(){f.setActiveBuffer(e.id),window.focus(),u.close()},u.onclose=function(){delete m[this.id]}}else if(d.isCordova()&&void 0!==window.cordova.plugins&&void 0!==window.cordova.plugins.notification&&void 0!==window.cordova.plugins.notification.local){var l=parseInt(e.id,16);window.cordova.plugins.notification.local.clear(l),window.cordova.plugins.notification.local.schedule({id:l,text:n,title:t,data:{buffer:e.id}})}})(e,n+=e.shortName+" ("+e.server+")",i),!d.isCordova()&&s.soundnotification&&(document.getElementById("soundNotification").innerHTML='<audio autoplay="autoplay"><source src="assets/audio/sonar.ogg" type="audio/ogg" /><source src="assets/audio/sonar.mp3" type="audio/mpeg" /></audio>')},cancelAll:function(){for(;0<m.length;){var e=m.pop();void 0!==e&&e.close()}},unreadCount:i}}]),function(){"use strict";var e=angular.module("weechat");e.filter("toArray",function(){return function(n,e){return n instanceof Object?e?Object.keys(n).map(function(e,t){return Object.defineProperties(n[e],{$key:{value:e},$idx:{value:t,configurable:!0}})}):Object.keys(n).map(function(e){return Object.defineProperty(n[e],"$key",{value:e})}):n}}),e.filter("irclinky",function(){return function(e){if(!e)return e;return e.replace(/(^|[\s,.:;?!"'()+@-\~%])(#+[^\x00\x07\r\n\s,:]*[a-z][^\x00\x07\r\n\s,:]*)/gim,'$1<a href="#" onclick="openBuffer(\'$2\');">$2</a>')}}),e.filter("inlinecolour",function(){return function(e){if(!e)return e;var t='$1$2 <div class="colourbox" style="background-color:$2"></div>';return e=(e=e.replace(/(^|[^&])(\#[0-9a-f]{6};?)(?!\w)/gim,t)).replace(/(.?)(rgba?\((?:\s*\d+\s*,){2}\s*\d+\s*(?:,\s*[\d.]+\s*)?\);?)/gim,t)}}),e.filter("DOMfilter",["$filter","$sce",function(i,r){var o=["irclinky"];return function(e,t){if(!e||!t)return e;var u=-1<o.indexOf(t),l=2<arguments.length?arguments[2]:null,f=3<arguments.length?arguments[3]:null,d=i(t),n=document.createElement("div");n.innerHTML=e;var h=function(e){if(3===e.nodeType){var t=(a=e.nodeValue,s={"<":"<",">":">",'"':""","'":"'","&":"&","/":"/"},a.replace(/[<>"'&\/]/g,function(e){return s[e]})),n=d(t,l,f);if(n!==t){var i=document.createElement("span");i.innerHTML=n;var r=e.parentNode,o=e.nextSibling;return r.removeChild(e),o?r.insertBefore(i,o):r.appendChild(i),i}}var a,s;if(null!=e)for(e=e.firstChild;e;){var c=null;u&&"A"===e.tagName||(c=h(e)),e=(c||e).nextSibling}};return h(n),r.trustAsHtml(n.innerHTML)}}]),e.filter("linksForCordova",["$sce",function(t){return function(e){return e=e.replace(/<a (rel="[a-z ]+"\s+)?(?:target="_[a-z]+"\s+)?href="([^"]+)"/gi,"<a $1 onClick=\"window.open('$2', '_system')\""),t.trustAsHtml(e)}}]),e.filter("getBufferQuickKeys",function(){return function(n,e){return e&&(void 0!==e.search&&e.search.length||e.onlyUnread?n.forEach(function(e,t){e.$quickKey=t<10?(t+1)%10:""}):_.map(n,function(e,t){return[e.number,e.$idx,t]}).sort(function(e,t){return e[0]-t[0]||e[1]-t[1]}).forEach(function(e,t){n[e[2]].$quickKey=t<10?(t+1)%10:"",void 0===n[e[2]].$jumpKey&&(n[e[2]].$jumpKey=t<99?t+1:"")})),n}}),e.filter("emojify",function(){return function(e,t){if(!0!==t||void 0===window.emojione)return e;return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)?emojione.unicodeToImage(e):e}}),e.filter("latexmath",function(){return function(e,t,n){return n&&"undefined"!=typeof katex&&(-1==e.indexOf("$$")&&-1==e.indexOf("\\[")&&-1==e.indexOf("\\(")||setTimeout(function(){var e=document.querySelector(t);renderMathInElement(e,{delimiters:[{left:"$$",right:"$$",display:!1},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})})),e}}),e.filter("prefixlimit",function(){return function(e,t){return isNaN(t)?e:t<=0?"":e&&e.length>t?(e=e.substring(0,t))+"+":e}})}(),function(){"use strict";angular.module("weechat").factory("handlers",["$rootScope","$log","models","plugins","notifications","bufferResume",function(l,c,f,s,u,a){var d=function(e,t,n,i){if(1!==e.bufferType&&(n.setHours(0,0,0,0),i.setHours(0,0,0,0),n.valueOf()!==i.valueOf())){t&&++e.lastSeen;var r=n;r.setDate(n.getDate()+1),r.setHours(0,0,0,0);var o="43";if(l.supports_formatting_date)o+=i.toLocaleDateString(window.navigator.language,{weekday:"long"});else{o+=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][i.getDay()]}var a={day:"numeric",month:"long"};if(i.getYear()!==n.getYear()&&(a.year="numeric"),o+=" (",l.supports_formatting_date)o+=i.toLocaleDateString(window.navigator.language,a);else{o+=["January","February","March","April","May","June","July","August","September","October","November","December"][i.getMonth()]+" "+i.getDate().toString(),"numeric"===a.year&&(o+=", "+i.getFullYear().toString())}if(r.valueOf()!==i.valueOf()){var s=Math.round((i-n)/864e5)+1;o+=s<0?1===(s*=-1)?", 1 day before":", "+s+" days before":", "+s+" days later"}o+=")";var c={buffer:e.id,date:i,prefix:"43─",tags_array:[],displayed:!0,highlight:0,message:o},u=new f.BufferLine(c);e.addLine(u)}},h=function(e,t){var n=new f.BufferLine(e),i=f.getBuffer(n.buffer);if(i.requestedLines++,n.displayed){if(0<i.lines.length){var r=new Date(i.lines[i.lines.length-1].date),o=new Date(n.date);d(i,t,r,o)}if(n=s.PluginManager.contentForMessage(n),i.addLine(n),t&&i.lastSeen++,i.active&&!t&&l.scrollWithBuffer(),!(t||i.active&&l.isWindowFocused())){var a=f.getServerForBuffer(i);1<i.notify&&_.contains(n.tags,"notify_message")&&!_.contains(n.tags,"notify_none")&&(i.unread++,a.unread++,l.$emit("notificationChanged")),(0!==i.notify&&n.highlight||_.contains(n.tags,"notify_private"))&&(i.notification++,a.unread++,u.createHighlight(i,n),l.$emit("notificationChanged"))}}},m=function(e,t){t.pointers[0]===e.id&&(e.shortName=t.short_name,e.trimmedName=e.shortName.replace(/^[#&+]/,""),e.title=t.title,e.number=t.number,e.hidden=t.hidden,f.getServerForBuffer(e).unread-=e.unread+e.notification,e.notification=0,e.unread=0,e.lastSeen=-1,void 0!==t.local_variables.type&&(e.type=t.local_variables.type,e.indent=0<=["channel","private"].indexOf(e.type)),void 0!==t.notify&&(e.notify=t.notify))},e=function(e){var t=e.objects[0].content[0],n=t.pointers[0],i=f.getBuffer(n),r=t.local_variables;void 0!==i&&void 0!==r&&(i.type=r.type,i.indent=0<=["channel","private"].indexOf(r.type),i.plugin=r.plugin,i.server=r.server,i.serverSortKey=i.plugin+"."+i.server+("server"===i.type?"":"."+i.shortName),i.pinned="true"===r.pinned)},t=function(e){var t=e.objects[0].content,r="root";t.forEach(function(e){var t=f.getBuffer(e.pointers[0]);if(1===e.group){var n=new f.NickGroup(e);r=n.name,t.nicklist[r]=n}else{var i=new f.Nick(e);t.addNick(r,i)}})},n={_buffer_closing:function(e){var t=e.objects[0].content[0].pointers[0];f.closeBuffer(t)},_buffer_line_added:function(e){e.objects[0].content.forEach(function(e){h(e,!1)})},_buffer_localvar_added:e,_buffer_localvar_removed:e,_buffer_localvar_changed:e,_buffer_moved:function(e){var t=e.objects[0].content[0],n=t.pointers[0],i=f.getBuffer(n),r=i.number,o=t.number;_.each(f.getBuffers(),function(e){e.number>r&&e.number<=o&&(e.number-=1),e.number<r&&e.number>=o&&(e.number+=1)}),i.number=o},_buffer_opened:function(e){var t=e.objects[0].content[0],n=new f.Buffer(t);"server"===n.type?f.registerServer(n):f.getServerForBuffer(n).unread+=n.unread+n.notification;f.addBuffer(n)},_buffer_title_changed:function(e){var t=e.objects[0].content[0],n=t.pointers[0],i=f.getBuffer(n);i.fullName=t.full_name,i.title=f.parseRichText(t.title),i.number=t.number,i.rtitle="";for(var r=0;r<i.title.length;++r)i.rtitle+=i.title[r].text},_buffer_type_changed:function(e){var t=e.objects[0].content[0];t.pointers[0].bufferType=t.type},_buffer_renamed:function(e){var t=e.objects[0].content[0],n=t.pointers[0],i=f.getBuffer(n);i.fullName=t.full_name,i.shortName=t.short_name,i.trimmedName=t.short_name.replace(/^[#&+]/,"")||(t.short_name?" ":null),i.prefix=0<=["#","&","+"].indexOf(t.short_name.charAt(0))?t.short_name.charAt(0):"";var r=f.outgoingQueries.indexOf(i.shortName);0<=r&&(f.outgoingQueries.splice(r,1),f.setActiveBuffer(i.id))},_buffer_hidden:function(e){var t=e.objects[0].content[0].pointers[0];f.getBuffer(t).hidden=!0},_buffer_unhidden:function(e){var t=e.objects[0].content[0].pointers[0];f.getBuffer(t).hidden=!1},_nicklist:t,_nicklist_diff:function(e){var o;e.objects[0].content.forEach(function(e){var t=f.getBuffer(e.pointers[0]),n=e._diff;if(1===e.group){if(void 0===(o=e.name)){var i=new f.NickGroup(e);t.nicklist[o]=i,o=i.name}}else{var r=new f.Nick(e);43===n?t.addNick(o,r):45===n?t.delNick(o,r):42===n&&t.updateNick(o,r)}})}};l.$on("onMessage",function(e,t){_.has(n,t.id)?n[t.id](t):c.debug("Unhandled event received: "+t.id)});return{handleVersionInfo:function(e){var t=e.objects[0].content.value;f.version=t.split(".").map(function(e){return parseInt(e)})},handleConfValue:function(e){for(var t=e.objects[0].content,n=0;n<t.length;n++){for(var i,r,o=t[n],a=0;a<o.length;a++){var s=o[a];s.full_name&&(i=s.full_name),s.value&&(r=s.value)}i&&r&&(c.debug('Setting wconfig "'+i+'" to value "'+r+'"'),f.wconfig[i]=r)}},handleEvent:function(e){_.has(n,e.id)&&n[e.id](e)},handleLineInfo:function(e,t){var n=e.objects[0].content.reverse();if(void 0===t&&(t=!0),n.forEach(function(e){h(e,t)}),0<e.objects[0].content.length){var i=e.objects[0].content[e.objects[0].content.length-1],r=f.getBuffer(i.buffer);if(0<r.lines.length){var o=new Date(r.lines[r.lines.length-1].date);d(r,!0,o,new Date)}}},handleHotlistInfo:function(e){_.each(f.getBuffers(),function(e){e.unread=0,e.notification=0}),_.each(f.getServers(),function(e){e.unread=0}),0<e.objects.length&&e.objects[0].content.forEach(function(e){var t=f.getBuffer(e.buffer);if(!t.active){t.unread=e.count[1],t.notification+=e.count[2],t.notification+=e.count[3];var n=_.reduce(e.count,function(e,t){return e+t},0);t.lastSeen=t.lines.length-1-n,f.getServerForBuffer(t).unread+=e.count[1]+e.count[2]+e.count[3]}});setTimeout(function(){l.$apply(),l.$emit("notificationChanged")})},handleNicklist:t,handleBufferInfo:function(e){for(var t=e.objects[0].content,n=0;n<t.length;n++){var i=t[n].pointers[0],r=f.getBuffer(i);void 0!==r?m(r,t[n]):("server"===(r=new f.Buffer(t[n])).type?f.registerServer(r):f.getServerForBuffer(r).unread+=r.unread+r.notification,f.addBuffer(r),a.shouldResume(r)&&f.setActiveBuffer(r.id))}if(!a.wasAbleToResume()){var o=t[0].pointers[0];f.setActiveBuffer(o)}}}}])}(),function(){"use strict";angular.module("weechat").factory("connection",["$rootScope","$log","handlers","models","ngWebsockets",function(p,f,d,v,h){var i,m=new weeChat.Protocol,g=[],b=!1,r=function(e,t,n,i,r,o,a){p.passwordError=!1,g=[e,t,n,i,r];var s=i?"wss":"ws";-1!==e.indexOf(":")&&"["!==e[0]&&"]"!==e[e.length-1]&&(e="["+e+"]");var c=s+"://"+e+":"+t+"/weechat";f.debug("Connecting to URL: ",c);var u=function(e){i&&e&&1006===e.code&&void 0!==p.lastError&&Date.now()-p.lastError<1e3&&(p.sslError=!0,p.$apply())},l=function(){p.waseverconnected||p.errorMessage||(p.passwordError=!0,p.$apply())};b&&f.debug("Aborting connection (lock in use)"),b=!0;try{h.connect(c,m,{binaryType:"arraybuffer",onopen:function(){var e,t=function(){return h.send(weeChat.Protocol.formatHdata({path:"hotlist:gui_hotlist(*)",keys:[]}))};(e=n,e=e.replace(",","\\,"),h.send(weeChat.Protocol.formatInit({password:e,compression:r?"off":"zlib"})),h.send(weeChat.Protocol.formatInfo({name:"version"}))).then(function(e){d.handleVersionInfo(e),h.send(weeChat.Protocol.formatHdata({path:"buffer:gui_buffers(*)",keys:["local_variables,notify,number,full_name,short_name,title,hidden,type"]})).then(function(e){d.handleBufferInfo(e)}),t().then(function(e){d.handleHotlistInfo(e)}),setInterval(function(){p.connected&&t().then(function(e){d.handleHotlistInfo(e)})},6e4),w("weechat.look.buffer_time_format",function(){!function(){var e=function(e){return'\'<span class="cof-chat_time_delimiters cob-chat_time_delimiters coa-chat_time_delimiters">'+e+"</span>'"},t=v.wconfig["weechat.look.buffer_time_format"],n="",i=e(":"),r="hh"+i+"mm",o="' 'a",a=r+o,s=r+i+"ss"+o,c="HH"+i+"mm",u=c+i+"ss";n=-1<t.indexOf("%H")||-1<t.indexOf("%k")?-1<t.indexOf("%S")?u:c:-1<t.indexOf("%I")||-1<t.indexOf("%l")||-1<t.indexOf("%p")||-1<t.indexOf("%P")?-1<t.indexOf("%S")?s:a:-1<t.indexOf("%r")?s:-1<t.indexOf("%T")?u:(t.indexOf("%R"),c);var l=[],f=Math.max(t.indexOf("%d"),t.indexOf("%e"));l.push([f,"dd"]);var d=t.indexOf("%m");l.push([d,"MM"]);var h=Math.max(t.indexOf("%y"),t.indexOf("%Y"));-1<t.indexOf("%y")?l.push([h,"yy"]):-1<t.indexOf("%Y")&&l.push([h,"yyyy"]),l.sort();for(var m=[],g=0;g<l.length;g++)-1!=l[g][0]&&m.push(l[g][1]);0<m.length&&(n=m.join(e("/"))+e(" ")+n),p.angularTimeFormat=n}()}),w("weechat.completion.nick_completer"),w("weechat.completion.nick_add_space"),h.send(weeChat.Protocol.formatSync({})),f.info("Connected to relay"),p.connected=!0,o&&o()},function(){l()})},onclose:function(e){f.info("Disconnected from relay"),p.$emit("relayDisconnect"),b=!1,p.userdisconnect||!p.waseverconnected?(u(e),p.userdisconnect=!1):y(e),l()},onmessage:function(){p.waseverconnected=!0},onerror:function(e){f.error("Relay error",e),b=!1,p.lastError=Date.now(),"error"===e.type&&1!==this.readyState&&(h.failCallbacks("error"),p.errorMessage=!0)}})}catch(e){b=!1,f.debug("Websocket caught DOMException:",e),p.lastError=Date.now(),p.errorMessage=!0,p.securityError=!0,p.$emit("relayDisconnect"),a&&a()}},o=function(e,t){f.info("Attempting to reconnect...");var n=g;r(n[0],n[1],n[2],n[3],n[4],function(){p.reconnecting=!1,v.setActiveBuffer(e),f.info("Sucessfully reconnected to relay")},function(){6e5<=t?(f.info("Failed to reconnect, giving up"),handleClose()):(f.info("Failed to reconnect, scheduling next attempt in",t/1e3,"seconds"),void 0!==i&&clearTimeout(i),i=setTimeout(function(){o(e,1.5*t)},t))})},y=function(e){if(g.length<5)f.error("Cannot reconnect, connection information is missing");else{v.reinitialize(),p.reconnecting=!0,p.$apply();var t=v.getActiveBuffer().id;i=setTimeout(function(){o(t,3e3)},3e3)}},e=function(e){h.send(weeChat.Protocol.formatInput({buffer:v.getActiveBufferReference(),data:e}))},t=function(e){h.send(weeChat.Protocol.formatInput({buffer:"core.weechat",data:e}))},w=function(e,t){h.send(weeChat.Protocol.formatInfolist({name:"option",pointer:0,args:e})).then(function(e){d.handleConfValue(e),void 0!==t&&t()})};return{connect:r,disconnect:function(){f.info("Disconnecting from relay"),p.userdisconnect=!0,h.send(weeChat.Protocol.formatQuit());setTimeout(function(){h.disconnect(),h.failCallbacks("disconnection"),p.connected=!1,b=!1,p.$emit("relayDisconnect"),p.$apply()})},sendMessage:e,sendCoreCommand:t,sendHotlistClear:function(){1<=v.version[0]?(e("/buffer set hotlist -1"),e("/input set_unread_current_buffer")):t("/buffer "+v.getActiveBuffer().fullName)},sendHotlistClearAll:function(){e("/input hotlist_clear")},fetchMoreLines:function(o){f.debug("Fetching ",o," lines");var a=v.getActiveBuffer();return void 0===o&&(o=0),o=Math.max(o,2*a.requestedLines),p.loadingLines=!0,h.send(weeChat.Protocol.formatHdata({path:"buffer:0x"+a.id+"/own_lines/last_line(-"+o+")/data",keys:[]})).then(function(e){var t=a.lines.length,n=0<=a.lastSeen;a.lines.length=0,a.requestedLines=0;var i=e.objects[0].content.length;d.handleLineInfo(e,!0),a.lastSeen-=t,i<o&&(a.allLinesFetched=!0),p.loadingLines=!1;var r=!n&&0<=a.lastSeen;p.scrollWithBuffer(r,!0)})},requestNicklist:function(e,t){e&&h.send(weeChat.Protocol.formatNicklist({buffer:"0x"+e})).then(function(e){d.handleNicklist(e),void 0!==t&&t()})},attemptReconnect:o}}])}(),function(){"use strict";angular.module("weechat").directive("fileChange",["$parse",function(r){return{restrict:"A",link:function(t,e,n){var i=r(n.fileChange);e[0].addEventListener("change",function(e){t.$apply(function(){i(t,{$event:e,files:e.target.files})})},!1)}}}])}(),function(){"use strict";angular.module("weechat").directive("imgurDrop",["connection","imgur","$rootScope",function(e,r,o){return{restrict:"A",link:function(e,t,n){var i=t[0];i.ondragover=function(){return this.classList.add("imgur-drop-hover"),!1},i.ondragend=function(){return this.classList.remove("imgur-drop-hover"),!1},i.ondrop=function(e){this.classList.remove("imgur-drop-hover");var t=e.dataTransfer.files;e.stopPropagation(),e.preventDefault();var n=function(e){void 0!==e&&""!==e&&o.insertAtCaret(String(e))};if(void 0!==t&&0<t.length)for(var i=0;i<t.length;i++)r.process(t[i],n)}}}}])}(),function(){"use strict";angular.module("weechat").directive("whenScrolled",function(){return function(e,t,n){var i=t[0],r=function(){0===i.scrollTop&&e.$apply(n.whenScrolled)};t.bind("scroll",function(){_.debounce(r,200)()})}})}(),function(){"use strict";angular.module("weechat").directive("inputBar",function(){return{templateUrl:"directives/input.html",scope:{inputId:"@inputId",command:"=command"},controller:["$rootScope","$scope","$element","$log","connection","imgur","models","IrcUtils","settings","utils",function(w,C,e,r,k,o,S,s,x,t){C.utils=t,C.inputChanged=function(){for(var e=/^(?:[\uD800-\uDBFF][\uDC00-\uDFFF])+$/,t=!1,n=C.getInputNode(),i=n.selectionStart,r=C.command.split(/(\s+)/),o=0;o<r.length;o++)if(/\s+/.test(r[o])||e.test(r[o]))r[o].length;else{var a=emojione.shortnameToUnicode(r[o]);e.test(a)&&(i=i-r[o].length+a.length,r[o]=a,t=!0),r[o].length}t&&(C.command=r.join(""),setTimeout(function(){n.setSelectionRange(i,i)}))},C.getInputNode=function(){return document.querySelector("textarea#"+C.inputId)},C.hideSidebar=function(){w.hideSidebar()},C.completeNick=function(){var e=C.getInputNode(),t=e.selectionStart,n=S.getActiveBuffer(),i=C.command||"",r=S.wconfig["weechat.completion.nick_completer"],o=S.wconfig["weechat.completion.nick_add_space"],a=s.completeNick(i,t,C.iterCandidate,n.getNicklistByTime(),r,o);C.iterCandidate=a.iterCandidate,C.command=a.text,setTimeout(function(){e.focus(),e.setSelectionRange(a.caretPos,a.caretPos)},0)},w.insertAtCaret=function(e){var t=C.getInputNode(),n=t.selectionStart,i=C.command.substring(0,n),r=C.command.substring(n,C.command.length);0<i.length&&" "!==i[i.length-1]&&(i+=" "),0<r.length&&" "!==r[0]&&(r=" ".concat(r)),C.command=i+e+r,setTimeout(function(){t.focus();var e=C.command.length-r.length;t.setSelectionRange(e,e),C.$apply()},0)},C.uploadImage=function(e,t){var n=function(e){void 0!==e&&""!==e&&w.insertAtCaret(String(e))};if(void 0!==t&&0<t.length)for(var i=0;i<t.length;i++)o.process(t[i],n)},C.sendMessage=function(){var e=S.getActiveBuffer();if(void 0!==C.command&&""!==C.command){e.addToHistory(C.command),_.each(C.command.split(/\r?\n/),function(e){("/quit"!==e&&0!==e.indexOf("/quit ")||window.confirm("Are you sure you want to quit WeeChat? This will prevent you from connecting with Glowing Bear until you restart WeeChat on the command line!"))&&k.sendMessage(e)}),"/buffer clear"!==C.command&&"/c"!==C.command||(r.debug("Clearing lines"),e.clear());var t=C.command.indexOf(" "),n=C.command.substr(0,t);if(0<=["/query","/join","/j","/q"].indexOf(n)){var i=C.command.substring(t+1);S.outgoingQueries.push(i)}C.command=""}1<=S.version[0]&&k.sendHotlistClear(),C.getInputNode().focus()},w.addMention=function(e){if(e.showHiddenBrackets){var t=e.prefix,n=t[t.length-1].text,i=C.command||"",r=0===i.length;if(0<i.length){var o=i.trim();if(":"===o.charAt(o.length-1)){var a=o.lastIndexOf(" ")+1,s=o.slice(a,o.length-1),c=S.getActiveBuffer().getNicklistByTime();for(var u in c)if(c[u].name===s){i=i.slice(0,i.lastIndexOf(":"))+" ",r=!0;break}}" "!==i.charAt(i.length-1)&&(i+=" ")}i+=n,r&&(i+=": "),C.command=i,C.getInputNode().focus()}},w.handleKeyPress=function(e){if(!w.connected)return!0;var t=C.getInputNode(),n=e.keyCode?e.keyCode:e.charCode,i=e.code;if(!!e.getModifierState&&e.getModifierState("AltGraph"))return!1;w.showQuickKeys=!1;var r,o,a,s,c=C.iterCandidate;if(C.iterCandidate=null,w.showJumpKeys){var u=function(){w.showJumpKeys=!1,w.jumpDecimal=void 0,C.$parent.search="",C.$parent.search_placeholder="Search",w.refresh_filter_predicate()};!e.altKey&&47<n&&n<58?void 0===w.jumpDecimal?(w.jumpDecimal=n-48,e.preventDefault(),C.$parent.search=w.jumpDecimal,w.refresh_filter_predicate()):(r=10*w.jumpDecimal+(n-48),C.$parent.setActiveBuffer(r,"$jumpKey"),e.preventDefault(),u()):u()}if(e.altKey&&!e.ctrlKey&&47<n&&n<58&&x.enableQuickKeys&&(48===n&&(n=58),r=n-48-1,(C.$parent.search.length||C.$parent.onlyUnread)&&C.$parent.filteredBuffers.length?void 0!==(o=C.$parent.filteredBuffers[r])&&(a=[o.number,o.id]):a=_.map(S.getBuffers(),function(e){return[e.number,e.id]}).sort(function(e,t){return e[0]-t[0]})[r],a&&(C.$parent.setActiveBuffer(a[1]),e.preventDefault())),9===n&&!e.altKey&&!e.ctrlKey)return e.preventDefault(),C.iterCandidate=c,C.completeNick(),!0;if(e.altKey&&!e.ctrlKey&&78===n)return e.preventDefault(),w.toggleNicklist(),!0;if(e.altKey&&(97===n||65===n))return e.preventDefault(),w.switchToActivityBuffer(),!0;if(e.altKey&&!e.ctrlKey&&(38===n||40===n)){e.preventDefault();var l=n-39;return w.switchToAdjacentBuffer(l),!0}if(e.altKey&&(76===n||108===n))return e.preventDefault(),t.focus(),t.setSelectionRange(C.command.length,C.command.length),!0;if(e.altKey&&(60===n||226===n||"IntlBackslash"===i)){var f=S.getPreviousBuffer();if(f)return S.setActiveBuffer(f.id),e.preventDefault(),!0}if(27===n){e.preventDefault();for(var d=document.querySelectorAll(".gb-modal"),h=0;h<d.length;h++)if("visible"===d[h].getAttribute("data-state"))return d[h].setAttribute("data-state","hidden"),!0;return void 0!==C.lastEscape&&Date.now()-C.lastEscape<=500&&k.disconnect(),C.lastEscape=Date.now(),!0}if(e.altKey&&(103===n||71===n))return e.preventDefault(),C.$parent.isSidebarVisible()||C.$parent.showSidebar(),setTimeout(function(){document.getElementById("bufferFilter").focus()}),!0;if(e.altKey&&!e.ctrlKey&&72===n){var m=S.getBuffers();_.each(m,function(e){e.unread=0,e.notification=0});var g=S.getServers();_.each(g,function(e){e.unread=0}),k.sendHotlistClearAll()}if(e.altKey&&(106===n||74===n))return e.preventDefault(),C.$parent.search="",C.$parent.search_placeholder="Number",w.showJumpKeys=!0;if("keydown"===e.type&&38===n&&document.activeElement===t)return s=t.selectionStart,-1===C.command.slice(0,s).indexOf("\n")&&(C.command=S.getActiveBuffer().getHistoryUp(C.command),setTimeout(function(){C.command&&t.setSelectionRange(C.command.length,C.command.length)},0),!0);if("keydown"===e.type&&40===n&&document.activeElement===t)return s=t.selectionStart,-1===C.command.slice(s).indexOf("\n")&&(C.command=S.getActiveBuffer().getHistoryDown(C.command),!0);if(13==n&&!e.shiftKey&&document.activeElement===t)return e.preventDefault(),C.sendMessage(),!0;var p,v,b=document.getElementById("bufferlines");if("keydown"===e.type&&33===n&&document.activeElement===t&&!e.ctrlKey&&!e.altKey&&!e.shiftKey){if(0===b.scrollTop)return w.loadingLines||C.$parent.fetchMoreLines(),!0;for(v=(p=b.querySelectorAll("tr")).length-1;0<=v;v--)if(p[v].offsetTop-b.scrollTop<b.clientHeight/2){p[v].scrollIntoView(!1);break}return!0}if("keydown"===e.type&&34===n&&document.activeElement===t&&!e.ctrlKey&&!e.altKey&&!e.shiftKey){for(p=b.querySelectorAll("tr"),v=0;v<p.length;v++)if(p[v].offsetTop-b.scrollTop>b.clientHeight/2){p[v].scrollIntoView(!0);break}return!0}if(x.readlineBindings&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&document.activeElement===t){if(s=t.selectionStart,65==n)t.setSelectionRange(0,0);else if(69==n)t.setSelectionRange(C.command.length,C.command.length);else if(85==n)C.command=C.command.slice(s),setTimeout(function(){t.setSelectionRange(0,0)});else if(75==n)C.command=C.command.slice(0,s),setTimeout(function(){t.setSelectionRange(C.command.length,C.command.length)});else{if(87!=n)return!1;var y=C.command.slice(0,s).replace(/\s+$/,"").lastIndexOf(" ")+1;C.command=C.command.slice(0,y)+C.command.slice(s,C.command.length),setTimeout(function(){t.setSelectionRange(y,y)})}return e.preventDefault(),!0}"keydown"!==e.type||18!==n||e.ctrlKey||e.shiftKey||!x.enableQuickKeys||(w.showQuickKeys=!0)},w.handleKeyRelease=function(e){if(18===e.keyCode)return void 0!==w.quickKeysTimer&&clearTimeout(w.quickKeysTimer),w.quickKeysTimer=setTimeout(function(){w.showQuickKeys&&(w.showQuickKeys=!1,w.$apply()),delete w.quickKeysTimer},1e3),!0},C.handleCompleteNickButton=function(e){return e.preventDefault(),C.completeNick(),setTimeout(function(){C.getInputNode().focus()},0),!0},C.inputPasted=function(e){if(e.clipboardData&&e.clipboardData.files&&e.clipboardData.files.length){e.stopPropagation(),e.preventDefault();for(var t=function(e){void 0!==e&&""!==e&&w.insertAtCaret(String(e))},n=0;n<e.clipboardData.files.length;n++)o.process(e.clipboardData.files[n],t);return!1}return!0}}]}})}(),function(){"use strict";angular.module("weechat").directive("plugin",["$rootScope","settings",function(o,e){return{templateUrl:"directives/plugin.html",scope:{plugin:"=data"},controller:["$scope",function(r){r.displayedContent="",r.plugin.visible=!e.noembed&&!r.plugin.nsfw,r.plugin.className="embed_"+r.plugin.$$hashKey.replace(":","_"),r.plugin.getElement=function(){return document.querySelector("."+r.plugin.className)},r.hideContent=function(){r.plugin.visible=!1},r.showContent=function(e){var t,n=r.plugin.getElement();if(r.plugin.content instanceof Function?n&&""!==n.innerHTML||setTimeout(function(){r.plugin.content()}):r.displayedContent=r.plugin.content,r.plugin.visible=!0,e){var i=o.bufferBottom;t=function(){o.updateBufferBottom(i)}}else t=function(){n&&void 0!==n.scrollIntoViewIfNeeded&&(n.scrollIntoViewIfNeeded(),o.updateBufferBottom())};setTimeout(t,500)},r.plugin.visible&&r.showContent(!0)}]}}])}(),function(){"use strict";angular.module("ngWebsockets",[]).factory("ngWebsockets",["$rootScope","$q",function(n,r){var o=null,a=null,i={},s=0,c=function(e){var t=u(e);return e=o.setId(t.id,e),a.send(e),t.promise},u=function(){var e=r.defer(),t=(1e3<(s+=1)&&(s=0),s);return i[t]={time:new Date,cb:e},e.id=t,e},l=function(e){var t=o.parse(e.data);_.has(i,t.id)?(i[t.id].cb.resolve(t),delete i[t.id]):n.$emit("onMessage",t);n.$apply()};return{send:c,sendAll:function(e){var t=[];for(var n in e){var i=c(e[n]);t.push(i)}return r.all(t)},connect:function(e,t,n){for(var i in a=new WebSocket(e),o=t,n)a[i]=n[i];a.onmessage="onmessage"in n?function(e){n.onmessage(e),l(e)}:l},disconnect:function(){a.close()},failCallbacks:function(e){for(var t in i)i[t].cb.reject(e)}}}])}(),function(){"use strict";angular.module("weechatModels",[]).service("models",["$rootScope","$filter","bufferResume",function(g,p,i){this.version=null,this.wconfig={},this.outgoingQueries=[];var T=function(e){var t=weeChat.Protocol.rawText2Rich(e),i={option:"cof-",weechat:"cwf-",ext:"cef-"},r={option:"cob-",weechat:"cwb-",ext:"ceb-"};return t.forEach(function(e){e.classes=[];var t,n=i[e.fgColor.type];for(t in e.classes.push(n+e.fgColor.name),n=r[e.bgColor.type],e.classes.push(n+e.bgColor.name),null!==e.attrs.name&&e.classes.push("coa-"+e.attrs.name),e.attrs.override)e.attrs.override[t]?e.classes.push("a-"+t):e.classes.push("a-no-"+t)}),t};function a(e,t){var n=["cwf-default"];if(t in e&&e[t]&&0<e[t].length){var i=e[t];if(i.match(/^weechat/)){var r=i.match(/[a-zA-Z0-9_]+$/)[0];n=["cof-"+r,"cob-"+r,"coa-"+r]}else{if(i.match(/^[a-zA-Z]+(:|$)/))n=["cwf-"+i.match(/^[a-zA-Z]+/)[0]];else if(i.match(/^[0-9]+(:|$)/)){n=["cef-"+i.match(/^[0-9]+/)[0]]}if(i.match(/:[a-zA-Z]+$/)){var o=i.match(/:[a-zA-Z]+$/)[0].substring(1);n.push("cwb-"+o)}else if(i.match(/:[0-9]+$/)){var a=i.match(/:[0-9]+$/)[0].substring(1);n.push("ceb-"+a)}}}return n}this.parseRichText=T,this.Buffer=function(e){var t=e.full_name,n=e.short_name,i=e.hidden,r=n.replace(/^[#&+]/,"")||(n?" ":null),o=0<=["#","&","+"].indexOf(n.charAt(0))?n.charAt(0):"",a=T(e.title),s=e.number,c=e.pointers[0],u=3,l=[],f=0,d={},h=[],m=0,g=e.type,p=e.local_variables.type,v=0<=["channel","private"].indexOf(p),b=e.local_variables.plugin,y=e.local_variables.server,w="true"===e.local_variables.pinned,C=b+"."+y+("server"===p?"":"."+n);C=C.toLowerCase(),void 0!==e.notify&&(u=e.notify);for(var k="",S=0;S<a.length;++S)k+=a[S].text;var x=function(e){var t=e.prefix;if(0!==t.length){var n=t[t.length-1].text;if(" *"===n){var i=e.text.match(/^(.+)\s/);i&&(n=i[1])}else if(""===n||"=!="===n)return;_.each(d,function(e){_.each(e.nicks,function(e){e.name===n&&(e.spokeAt=Date.now())})})}},B=function(){return d.hasOwnProperty("root")};return{id:c,fullName:t,shortName:n,hidden:i,trimmedName:r,prefix:o,number:s,title:a,rtitle:k,lines:l,clear:function(){for(;0<l.length;)l.pop();f=0},requestedLines:f,addLine:function(e){l.push(e),x(e)},lastSeen:-1,unread:0,notification:0,notify:u,nicklist:d,addNick:function(e,t){B()&&(t.spokeAt=Date.now(),d[e].nicks.push(t))},delNick:function(e,t){void 0!==(e=d[e])&&(e.nicks=_.filter(e.nicks,function(e){return e.name!==t.name}))},updateNick:function(e,t){if(void 0!==(e=d[e]))for(var n in e.nicks)if(e.nicks[n].name===t.name){e.nicks[n]=t;break}},getNicklistByTime:function(){var t=[];return _.each(d,function(e){_.each(e.nicks,function(e){t.push(e)})}),t.sort(function(e,t){return e.spokeAt<t.spokeAt}),t},serverSortKey:C,indent:v,bufferType:g,type:p,plugin:b,server:y,history:h,addToHistory:function(e){var t="";return m!==h.length&&(t=h.pop()),h.push(e),m=h.length,t},getHistoryUp:function(e){return m>=h.length&&h.push(e),m<=0||m>=h.length?e:h[--m]},getHistoryDown:function(e){return m===h.length?(void 0!==e&&""!==e&&(h.push(e),m++),""):m<0||m>h.length?e:(m++,0<h.length&&m==h.length-1?h.pop():h[m])},isNicklistEmpty:function(){for(var e in d)if("root"!==e)return!1;return!0},nicklistRequested:B,pinned:w}},this.BufferLine=function(e){var t=e.buffer,n=e.date,i=p("date")(n,"HH:mm"),r=p("date")(n,g.angularTimeFormat),o=T(e.prefix),a=e.tags_array,s=e.displayed,c=e.highlight,u=T(e.message),l=0<=a.indexOf("irc_privmsg")&&-1===a.indexOf("irc_action");c&&o.forEach(function(e){e.classes.push("highlight")});for(var f="",d=0;d<o.length;++d)f+=o[d].text;for(var h="",m=0;m<u.length;++m)h+=u[m].text;return{prefix:o,content:u,date:n,shortTime:i,formattedTime:r,buffer:t,tags:a,highlight:c,displayed:s,prefixtext:f,text:h,showHiddenBrackets:l}},this.Nick=function(e){var t,n=e.prefix,i=e.visible,r=e.name,o={name:a(t=e,"color"),prefix:a(t,"prefix_color")};return{prefix:n,visible:i,name:r,prefixClasses:o.prefix,nameClasses:o.name}},this.NickGroup=function(e){return{name:e.name,visible:e.visible,nicks:[]}},this.Server=function(){return{id:0,unread:0}};var r=null,o=null;this.model={buffers:{},servers:{}},this.registerServer=function(e){var t=e.plugin+"."+e.server;this.getServer(t).id=e.id},this.addBuffer=function(e){this.model.buffers[e.id]=e},this.getActiveBuffer=function(){return r},this.getActiveBufferReference=function(){return null!==this.version&&1<=this.version[0]?"0x"+r.id:r.fullName},this.getPreviousBuffer=function(){return o},this.setActiveBuffer=function(t,n){if(void 0===n&&(n="id"),o=this.getActiveBuffer(),void 0===(r="id"===n?this.model.buffers[t]:_.find(this.model.buffers,function(e){if(e[n]===t)return e})))return r=o,!1;o&&(o.active=!1,o.lastSeen=o.lines.length-1);var e=r.unread+r.notification;return this.getServerForBuffer(r).unread-=e,r.active=!0,r.unread=0,r.notification=0,g.$emit("activeBufferChanged",e),g.$emit("notificationChanged"),i.record(r),!0},this.getBuffers=function(){return this.model.buffers},this.reinitialize=function(){this.model.buffers={},this.model.servers={}},this.getBuffer=function(e){return this.model.buffers[e]},this.getServers=function(){return this.model.servers},this.getServer=function(e){return void 0===this.model.servers[e]&&(this.model.servers[e]=this.Server()),this.model.servers[e]},this.getServerForBuffer=function(e){var t=e.plugin+"."+e.server;return this.getServer(t)},this.closeBuffer=function(e){var t=this.getBuffer(e);if(void 0!==t){if(t.active){var n=_.keys(this.model.buffers)[0];this.setActiveBuffer(n)}delete this.model.buffers[e]}}}])}(),function(){"use strict";angular.module("bufferResume",[]).service("bufferResume",["settings",function(n){var e={},i=n.host+":"+n.port,r=!1;return e.record=function(e){var t=n.currentlyViewedBuffers;t[i]=e.id,n.currentlyViewedBuffers=t},e.shouldResume=function(e){var t=n.currentlyViewedBuffers[i];return!!t&&(r?void 0:t===e.id&&(r=!0))},e.wasAbleToResume=function(){return r},e.reset=function(){r=!1},e}])}(),function(){"use strict";var e=angular.module("plugins",[]),s=function(e,t){return{contentForMessage:t,exclusive:!1,name:e}},a=/(?:(?:https?|ftp):\/\/|www\.|ftp\.)\S*[^\s.;,(){}<>]/g,c=function(e,o){return{contentForMessage:function(e){for(var t=_.uniq(e.match(a)),n=[],i=0;t&&i<t.length;i++){var r=o(t[i]);r&&n.push(r)}return n},exclusive:!1,name:e}};e.service("plugins",["userPlugins","$sce",function(e,u){this.PluginManager=new function(){var s=[],c=new RegExp("nsfw","i");return{registerPlugins:function(e){for(var t=0;t<e.length;t++)s.push(e[t])},contentForMessage:function(i){i.metadata=[];for(var e=function(e,t,n){n&&(t+=" "+n),e instanceof Function||(e=u.trustAsHtml(e)),i.metadata.push({content:e,nsfw:r,name:t})},t=0;t<s.length;t++){var r=!1;i.text.match(c)&&(r=!0);var n=s[t].contentForMessage(i.text);if(n&&n!==[]){if(n instanceof Array)for(var o=n.length-1;0<=o;o--){var a=1==n.length?void 0:o+1;e(n[o],s[t].name,a)}else e(n,s[t].name);if(s[t].exclusive)break}}return i}}},this.PluginManager.registerPlugins(e.plugins)}]),e.factory("userPlugins",function(){var i=function(e,t){var n="jsonp_callback_"+Math.round(1e5*Math.random());window[n]=function(e){delete window[n],document.body.removeChild(i),t(e)};var i=document.createElement("script");i.src=e+(0<=e.indexOf("?")?"&":"?")+"callback="+n,document.body.appendChild(i)},e=new s("Spotify music",function(e){var i=[],t=function(e){for(var t=0;e&&t<e.length;t++){var n=angular.element("<iframe></iframe>").attr("src","//embed.spotify.com/?uri="+e[t]).attr("width","350").attr("height","80").attr("frameborder","0").attr("allowtransparency","true");i.push(n.prop("outerHTML"))}};return t(e.match(/spotify:track:[a-zA-Z-0-9]{22}/g)),t(e.match(/spotify:artist:[a-zA-Z-0-9]{22}/g)),t(e.match(/spotify:user:\w+:playlist:[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/track\/[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/artist\/[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/user\/\w+\/playlist\/[a-zA-Z-0-9]{22}/g)),i}),t=new c("YouTube video",function(e){var t=e.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i);if(t){var n="https://www.youtube.com/embed/"+t[1]+"?html5=1&iv_load_policy=3&modestbranding=1&rel=0";return angular.element("<iframe></iframe>").attr("src",n).attr("width","560").attr("height","315").attr("frameborder","0").attr("allowfullscreen","true").prop("outerHTML")}}),n=new s("Dailymotion video",function(e){var t=e.match(/dailymotion\.com\/.*video\/([^_?# ]+)/)||e.match(/dailymotion\.com\/.*#video=([^_& ]+)/)||e.match(/dai\.ly\/([^_?# ]+)/);if(t){var n="https://www.dailymotion.com/embed/video/"+t[1]+"?html&controls=html&startscreen=html&info=0&logo=0&related=0";return angular.element("<iframe></iframe>").attr("src",n).attr("width","480").attr("height","270").attr("frameborder","0").prop("outerHTML")}return null}),r=new s("AlloCine video",function(e){var t=e.match(/allocine\.fr\/videokast\/video-(\d+)/)||e.match(/allocine\.fr\/.*cmedia=(\d+)/);if(t){var n="http://www.allocine.fr/_video/iblogvision.aspx?cmedia="+t[1];return angular.element("<iframe></iframe>").attr("src",n).attr("width","480").attr("height","270").attr("frameborder","0").prop("outerHTML")}return null}),o=new c("image",function(n){if(n.match(/\.(bmp|gif|ico|jpeg|jpg|png|svg|svgz|tif|tiff|webp)(:(small|medium|large))?\b/i)){if(-1!=n.indexOf("^https?://fukung.net/v/"))n=n.replace(/.*\//,"http://media.fukung.net/imgs/");else if(n.match(/^http:\/\/(i\.)?imgur\.com\//i))n=n.replace(/^http:/,"https:");else if(n.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)){var e=document.createElement("a");e.href=n;for(var t=e.protocol+"//"+e.host+e.pathname+"?",i=e.search.substring(1).split("&"),r=!1,o=0;o<i.length;o++)"dl"===i[o].split("=")[0]&&(i[o]="dl=1",r=!0);r||i.push("dl=1"),n=t+i.join("&")}return function(){var e=this.getElement(),t=angular.element("<a></a>").attr("target","_blank").attr("href",n).append(angular.element("<img>").addClass("embed").attr("src",n));e.innerHTML=t.prop("outerHTML")}}}),a=new c("audio",function(n){if(n.match(/\.(flac|m4a|mid|midi|mp3|oga|ogg|ogx|opus|pls|spx|wav|wave|wma)\b/i))return function(){var e=this.getElement(),t=angular.element("<audio controls></audio>").addClass("embed").attr("width","560").append(angular.element("<source></source>").attr("src",n));e.innerHTML=t.prop("outerHTML")}});return{plugins:[t,n,r,o,new c("video",function(i){if(i.match(/\.(3gp|avi|flv|gifv|mkv|mp4|ogv|webm|wmv)\b/i))return i.match(/^http:\/\/(i\.)?imgur\.com\//i)&&(i=i.replace(/^http:/,"https:")),function(){var e,t=this.getElement(),n=angular.element("<video autoplay controls loop muted></video>").addClass("embed").attr("width","560");e=i.match(/^https:\/\/(i\.)?imgur\.com\/.*\.gifv/i)?(e=angular.element("<source></source>").attr("src",i.replace(/\.gifv\b/i,".webm")).attr("type","video/webm"),n.append(e),angular.element("<source></source>").attr("src",i.replace(/\.gifv\b/i,".mp4")).attr("type","video/mp4")):angular.element("<source></source>").attr("src",i),n.append(e),t.innerHTML=n.prop("outerHTML")}}),a,e,new c("cloud music",function(e){return e.match(/^https?:\/\/soundcloud\.com\//)?angular.element("<iframe></iframe>").attr("width","100%").attr("height","120").attr("scrolling","no").attr("frameborder","no").attr("src","https://w.soundcloud.com/player/?url="+e+"&color=ff6600&auto_play=false&show_artwork=true").prop("outerHTML"):e.match(/^https?:\/\/([a-z]+\.)?mixcloud\.com\//)?angular.element("<iframe></iframe>").attr("width","480").attr("height","60").attr("frameborder","0").attr("src","//www.mixcloud.com/widget/iframe/?feed="+e+"&mini=1&stylecolor=&hide_artwork=&embed_type=widget_standard&hide_tracklist=1&hide_cover=").prop("outerHTML"):void 0}),new c("Google Map",function(e){if(e.match(/^https?:\/\/maps\.google\./i)||e.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i))return angular.element("<iframe></iframe>").attr("width","450").attr("height","350").attr("frameborder","0").attr("scrolling","no").attr("marginheight","0").attr("src",e+"&output=embed").prop("outerHTML")}),new c("ascii cast",function(e){var t=e.match(/^https?:\/\/(?:www\.)?asciinema\.org\/a\/([0-9a-z]+)/i);if(t){var n=t[1];return function(){var e=this.getElement(),t=document.createElement("script");t.src="https://asciinema.org/a/"+n+".js",t.id="asciicast-"+n,t.async=!0,e.appendChild(t)}}}),new c("meteogram",function(o){var a=o.match(/^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/);if(a)return function(){var e=this.getElement(),t=a[1],n=a[2],i=a[a.length-1].slice(0,-1);o="http://www.yr.no/"+t+"/"+n+"avansert_meteogram.png";var r=angular.element("<img>").attr("src",o).attr("alt","Meteogram for "+i);e.innerHTML=r.prop("outerHTML")}}),new c("Gist",function(e){var t=e.match(/^(https:\/\/gist\.github\.com\/(?:.*?))[\/]?(?:\#.*)?$/i);if(t)return e=t[1]+".json",function(){var n=this.getElement();i(e,function(e){if(document.querySelectorAll('link[rel=stylesheet][href="'+e.stylesheet+'"]').length<1){var t='<link rel="stylesheet" href="'+e.stylesheet+'"></link>';document.getElementsByTagName("head")[0].innerHTML+=t}n.innerHTML='<div style="clear:both">'+e.div+"</div>"})}}),new c("Pastebin",function(e){var t=e.match(/^https?:\/\/pastebin\.com\/(raw\/)?([^.?]+)/i);if(t){var n="https://pastebin.com/embed_iframe/"+t[2];return angular.element("<iframe></iframe>").attr("src",n).attr("width","100%").attr("height","480").prop("outerHTML")}}),new c("Giphy",function(n){var e=n.match(/^https?:\/\/giphy\.com\/gifs\/.*-(.*)\/?/i);if(e){var i="https://media.giphy.com/media/"+e[1]+"/giphy.gif";return function(){var e=this.getElement(),t=angular.element("<a></a>").attr("target","_blank").attr("href",n).append(angular.element("<img>").addClass("embed").attr("src",i));e.innerHTML=t.prop("outerHTML")}}}),new c("Tweet",function(e){var t=e.match(/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i);if(t)return e="https://api.twitter.com/1/statuses/oembed.json?id="+t[2],function(){var r=this.getElement();i(e,function(e){var t=e.html.indexOf("<script "),n=e.html.substr(0,t);n=n.replace('<blockquote class="twitter-tweet">','<blockquote class="twitter-tweet" data-dnt="true">'),r.innerHTML=n;var i=document.createElement("script");i.src="https://platform.twitter.com/widgets.js",r.appendChild(i)})}}),new c("Vine",function(e){var t=e.match(/^https?:\/\/(www\.)?vine\.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i);if(t){var n="https://vine.co/v/"+t[2]+"/embed/simple?audio=1";return angular.element("<iframe></iframe>").addClass("vine-embed").attr("src",n).attr("width","600").attr("height","600").attr("frameborder","0").prop("outerHTML")+'<script async src="https://platform.vine.co/static/scripts/embed.js" charset="utf-8"><\/script>'}}),new c("Streamable video",function(e){var t=e.match(/^https?:\/\/streamable\.com\/s?\/?(.+)/);if(t){var n="https://streamable.com/s/"+t[1];return angular.element("<iframe></iframe>").attr("src",n).attr("width","480").attr("height","270").attr("frameborder","0").prop("outerHTML")}})]}})}(),function(){"use strict";angular.module("weechat").factory("imgur",["$rootScope",function(e){var i=function(e,t){var n=document.getElementById("imgur-upload-progress"),i=document.createElement("div");i.className="imgur-progress-bar",i.style.width="0",n.appendChild(i);var r=new FormData;r.append("image",e),r.append("type","base64");var o=new XMLHttpRequest;o.open("POST","https://api.imgur.com/3/image",!0),o.setRequestHeader("Authorization","Client-ID 164efef8979cd4b"),o.setRequestHeader("Accept","application/json"),o.onload=function(){if(i.parentNode.removeChild(i),200===o.status){var e=JSON.parse(o.responseText);e.data&&e.data.link?t&&"function"==typeof t&&t(e.data.link.replace(/^http:/,"https:")):a()}else a()},"upload"in o&&(o.upload.onprogress=function(e){if(e.lengthComputable){var t=e.loaded/e.total*100|0;i.style.width=t+"%"}}),o.send(r)},a=function(){e.uploadError=!0,e.$apply(),setTimeout(function(){e.uploadError=!1,e.$apply()},5e3)};return{process:function(e,n){if(e&&e.type.match(/image.*/)){var t=new FileReader;t.onload=function(e){var t=e.target.result.split(",")[1];i(t,n)},t.readAsDataURL(e)}}}}])}();
|