You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
glowing-bear/min.js

2 lines
77 KiB

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";function m(){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}}m._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),e.useTotp&&t.push("totp="+e.totp),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.formatCompletion=function(e){var t=[];return e=m._mergeParams({id:null,position:-1},e),t.push(e.buffer),t.push(e.position),e.data&&t.push(e.data),m._formatCmd(e.id,"completion",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(){function g(t,e){var n=null;return e.some(function(e){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&(n=e,!0)}),n}function p(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||"on"===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?(m=p(n,h[1],u),{text:(l=r.endsWith(" ")?m+r:m+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=r.endsWith(" ")?m+r: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]})}}}])}(),function(){"use strict";document.addEventListener("deviceready",function(){void 0!==navigator.splashscreen&&navigator.splashscreen.hide()},!1);var h=angular.module("weechat",["ngRoute","localStorage","weechatModels","bufferResume","plugins","IrcUtils","ngSanitize","ngWebsockets","ngTouch"],["$compileProvider",function(e){h.compileProvider=e}]);h.config(["$compileProvider",function(e){"undefined"==typeof it&&"undefined"==typeof describe&&e.debugInfoEnabled(!1)}]),h.controller("WeechatCtrl",["$rootScope","$scope","$store","$timeout","$location","$log","models","bufferResume","connection","notifications","utils","settings",function(a,o,e,s,t,n,c,i,u,l,f,d){window.openBuffer=function(e){o.openBuffer(e),o.$apply()},o.command="",o.themes=["dark","light","black","dark-spacious","blue","base16-default","base16-light","base16-mocha","base16-ocean-dark","base16-solarized-dark","base16-solarized-light"],o.swipeStatus=1,d.setDefaults({theme:"dark",hostField:"localhost",port:9001,path:"weechat",ssl:"https:"===window.location.protocol,useTotp:!1,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,enableMathjax:!1,enableQuickKeys:!0,customCSS:"",currentlyViewedBuffers:{},iToken:"",iAlb:""}),!(o.settings=d).hostField&&d.host&&(d.hostField=d.host),a.countWatchers=function(){n.debug(a.$$watchersCount)},void 0!==document.hidden?(o.documentHidden="hidden",o.documentVisibilityChange="visibilitychange"):void 0!==document.webkitHidden?(o.documentHidden="webkitHidden",o.documentVisibilityChange="webkitvisibilitychange"):void 0!==document.mozHidden?(o.documentHidden="mozHidden",o.documentVisibilityChange="mozvisibilitychange"):void 0!==document.msHidden&&(o.documentHidden="msHidden",o.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&&!h.compileProvider.debugInfoEnabled()&&angular.reloadWithDebugInfo(),o.show_tls_warning=-1===["https:","file:"].indexOf(window.location.protocol)&&-1===["localhost","127.0.0.1","::1"].indexOf(window.location.hostname)&&!window.is_electron&&!f.isCordova(),a.isWindowFocused=function(){return void 0===o.documentHidden||!document[o.documentHidden]},void 0!==o.documentVisibilityChange&&document.addEventListener(o.documentVisibilityChange,function(){if(!document[o.documentHidden]){var e=c.getActiveBuffer();if(null!==e)c.getServerForBuffer(e).unread-=e.unread+e.notification,e.unread=0,e.notification=0,a.$emit("notificationChanged");a.$apply()}},!1),a.$on("nickListChanged",function(){o.updateShowNicklist()}),a.$on("activeBufferChanged",function(e,t){var n=c.getActiveBuffer(),i=n.lines.length-(2*o.lines_per_screen+10);if(0<i&&(n.lines.splice(0,i),n.requestedLines-=i,n.lastSeen-=i,n.allLinesFetched=!1),o.bufferlines=n.lines,o.nicklist=n.nicklist,n.nicklistRequested()?o.updateShowNicklist():u.requestNicklist(n.id,function(){o.updateShowNicklist(),a.scrollWithBuffer(!0)}),n.requestedLines<o.lines_per_screen){var r=o.lines_per_screen+10;r<t&&(r=Math.min(4*r,t)),o.fetchMoreLines(r).then(function(){s(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(){o.notifications=l.unreadCount("notification"),o.unread=l.unreadCount("unread")}),s(function(){a.scrollWithBuffer(!0)}),o.search="",o.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"})),o.notifications=l.unreadCount("notification"),o.unread=l.unreadCount("unread"),a.$on("notificationChanged",function(){l.updateTitle(),o.notifications=l.unreadCount("notification"),o.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(),c.reinitialize(),a.$emit("notificationChanged"),o.connectbutton="Connect",o.connectbuttonicon="glyphicon-chevron-right",i.reset()}),o.connectbutton="Connect",o.connectbuttonicon="glyphicon-chevron-right",o.getBuffers=c.getBuffers.bind(c),o.bufferlines={},o.nicklist={},o.activeBuffer=c.getActiveBuffer,a.connected=!1,a.waseverconnected=!1,a.userdisconnect=!1,a.reconnecting=!1,a.models=c,a.iterCandidate=null,d.savepassword?(o.$watch("password",function(){d.password=o.password}),d.addCallback("password",function(e){o.password=e}),o.password=d.password):d.password="",d.addCallback("savepassword",function(e){d.savepassword&&(d.setDefaults({password:o.password}),d.password=o.password)}),d.fontfamily||(f.isMobileUi()?d.fontfamily="sans-serif":d.fontfamily="Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace"),o.isSidebarVisible=function(){return"visible"===document.getElementById("content").getAttribute("sidebar-state")},o.swipeRight=function(){1===o.swipeStatus||(0===o.swipeStatus?o.showSidebar():-1===o.swipeStatus?(o.swipeStatus=0,o.updateShowNicklist()):(console.log("Weird swipe status:",o.swipeStatus),o.swipeStatus=0,o.updateShowNicklist(),o.hideSidebar()))},a.swipeLeft=function(){1===o.swipeStatus?o.hideSidebar():0===o.swipeStatus?(o.swipeStatus=-1,o.updateShowNicklist()||(o.swipeStatus=0)):-1===o.swipeStatus||(console.log("Weird swipe status:",o.swipeStatus),o.swipeStatus=0,o.updateShowNicklist(),o.hideSidebar())},o.showSidebar=function(){document.getElementById("sidebar").setAttribute("data-state","visible"),document.getElementById("content").setAttribute("sidebar-state","visible"),f.isMobileUi()&&_.each(document.getElementsByTagName("textarea"),function(e){s(function(){e.blur()})}),o.swipeStatus=1},a.hideSidebar=function(){f.isMobileUi()&&(document.getElementById("sidebar").setAttribute("data-state","hidden"),document.getElementById("content").setAttribute("sidebar-state","hidden")),o.swipeStatus=0},d.addCallback("autoconnect",function(e){!e||a.connected||a.sslError||a.securityError||a.errorMessage||o.connect()}),o.toggleSidebar=function(){f.isMobileUi()&&(o.isSidebarVisible()?o.hideSidebar():o.showSidebar())};function r(e){a.showJumpKeys?a.predicate="$jumpKey":a.predicate=e?"serverSortKey":"number"}d.addCallback("orderbyserver",r),a.refresh_filter_predicate=function(){r(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)}),o.setActiveBuffer=function(e,t){return f.isMobileUi()&&o.hideSidebar(),d.hotlistsync&&1<=c.version[0]&&u.sendHotlistClear(),c.setActiveBuffer(e,t)},o.openBuffer=function(e){var t=c.getActiveBuffer().fullName;if(t=t.substring(0,t.lastIndexOf(".")+1)+e,!o.setActiveBuffer(t,"fullName")){var n="join -noswitch";["#","&","+","!"].indexOf(e.charAt(0))<0&&(n="query",(1==c.version[0]&&2<=c.version[1]||1<c.version[1])&&(n+=" -noswitch")),u.sendMessage("/"+n+" "+e)}},o.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);o.lines_per_screen=r},o.calculateNumLines(),window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame,window.addEventListener("resize",_.debounce(function(){if(a.connected&&(f.isMobileUi()||(o.showSidebar(),o.updateShowNicklist()),o.calculateNumLines(),a.bufferBottom)){var e=function(){a.updateBufferBottom(!0)};s(e,500),window.requestAnimationFrame(e)}},100)),a.loadingLines=!1,o.fetchMoreLines=function(e){return e=e||o.lines_per_screen,u.fetchMoreLines(e)},o.infiniteScroll=function(){a.loadingLines||c.getActiveBuffer().allLinesFetched||o.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){function e(){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()}}var r=document.getElementById("bufferlines"),o=r.scrollHeight-r.clientHeight;s(e),window.requestAnimationFrame(e)},o.parseHost=function(){var e;a.hostInvalid=!1;null!==(e=/^([^:\/]*|\[.*\])$/.exec(d.hostField))?(d.host=e[1],d.path="weechat",a.portDisabled=!1):null!==(e=/^([^:]*|\[.*\]):(\d+)$/.exec(d.hostField))?(d.host=e[1],d.port=e[2],d.path="weechat",a.portDisabled=!0):null!==(e=/^([^:]*|\[.*\]):(\d*)\/(.+)$/.exec(d.hostField))?(d.host=e[1],d.port=e[2],d.path=e[3],a.portDisabled=!0):a.hostInvalid=!0},d.addCallback("useTotp",function(){d.useTotp&&(d.autoconnect=!1)}),o.parseTotp=function(){o.totpInvalid=!/^\d{4,10}$/.test(o.totp)},o.parseHash=function(){var n={};t.$$hash.split("&").map(function(e){var t=e.split("=");n[t[0]]=t[1]}),n.host&&(o.settings.host=n.host,o.settings.hostField=n.host),n.port&&(o.settings.port=parseInt(n.port)),n.path&&(o.settings.path=n.path,o.settings.hostField=o.settings.host+":"+o.settings.port+"/"+o.settings.path),n.password&&(o.password=n.password),n.autoconnect&&(o.settings.autoconnect="true"===n.autoconnect)},o.connect=function(){document.getElementById("audioNotificationInitializer").play(),l.requestNotificationPermission(),a.sslError=!1,a.securityError=!1,a.errorMessage=!1,a.bufferBottom=!0,o.connectbutton="Connecting",o.connectbuttonicon="glyphicon-refresh glyphicon-spin",u.connect(d.host,d.port,d.path,o.password,d.ssl,d.useTotp,o.totp),o.totp=""},o.disconnect=function(){o.connectbutton="Connect",o.connectbuttonicon="glyphicon-chevron-right",i.reset(),u.disconnect()},o.reconnect=function(){var e=c.getActiveBuffer().id;u.attemptReconnect(e,3e3)},o.showModal=function(e){document.getElementById(e).setAttribute("data-state","visible")},o.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")},o.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")}},o.hasUnread=function(e){return!(!o.search||""===o.search)||(d.onlyUnread?c.getActiveBuffer()===e||("core.weechat"===e.fullName||(d.orderbyserver&&"server"===e.type?0<c.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(o.search.toLowerCase())},d.addCallback("nonicklist",function(){o.updateShowNicklist(),a.connected&&a.bufferBottom&&s(function(){a.updateBufferBottom(!0)},500)}),d.addCallback("alwaysnicklist",function(){o.updateShowNicklist()}),o.showNicklist=!1,o.updateShowNicklist=function(){var e=c.getActiveBuffer();return e&&e.nicklistRequested()&&!e.isNicklistEmpty()?!f.isMobileUi()&&d.nonicklist||f.isMobileUi()&&!d.alwaysnicklist&&-1!==o.swipeStatus?!(o.showNicklist=!1):(o.showNicklist=!0,s(function(){f.changeClassStyle("favorite-font","fontFamily",d.fontfamily),f.changeClassStyle("favorite-font","fontSize",d.fontsize)},0),!0):o.showNicklist=!1},a.switchToActivityBuffer=function(){var e,t,n=_.sortBy(o.getBuffers(),"number");for(e in n)if(0<(t=n[e]).notification)return void o.setActiveBuffer(t.id);for(e in n)if(0<(t=n[e]).unread&&!t.hidden)return void o.setActiveBuffer(t.id)},a.toggleNicklist=function(){d.nonicklist=!d.nonicklist},a.switchToAdjacentBuffer=function(e){for(var t,n=_.sortBy(o.getBuffers(),a.predicate),i=c.getActiveBuffer(),r=n.indexOf(i)+e;0<=r&&r<n.length&&(!t||t.hidden);)t=n[r],r+=e;t&&o.setActiveBuffer(t.id)},o.handleSearchBoxKey=function(e){var t=e.keyCode?e.keyCode:e.charCode;if(27===t)e.preventDefault(),o.search="";else if(13===t){var n;e.preventDefault(),0<o.filteredBuffers.length&&(n=o.search_highlight_key?o.search_highlight_key:0,o.setActiveBuffer(o.filteredBuffers[n].id)),o.search=""}else 38===t?(e.preventDefault(),o.search_highlight_key&&0<o.search_highlight_key&&(o.search_highlight_key=o.search_highlight_key-1)):40===t||9===t?(e.preventDefault(),o.search_highlight_key=o.search_highlight_key+1):o.search_highlight_key=0},a.supports_formatting_date=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"!==e.name&&n.info("Browser does not support toLocaleDateString(), falling back to en-US"),"RangeError"===e.name}return n.info("Browser does not support toLocaleDateString(), falling back to en-US"),!1}(),window.onbeforeunload=function(e){null!==o.command&&""!==o.command?(e.preventDefault(),e.returnValue="Any unsent input will be lost. Are you sure that you want to quit?"):(a.connected&&o.disconnect(),f.isCordova()||o.favico.reset())},window.onhashchange=function(){o.parseHash()},o.init=function(){o.parseHost(),o.parseHash()}}]),h.config(["$routeProvider","$locationProvider",function(e,t){e.when("",{templateUrl:"index.html",controller:"WeechatCtrl"}),t.html5Mode({enabled:!0,requireBase:!1})}])}(),function(){"use strict";angular.module("weechat").factory("settings",["$store","$rootScope",function(r,o){var a=this;this.callbacks={},this.cache={};function n(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)}})}var 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){function i(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}var h=!1,m=[],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}if(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("conditionalLinkify",["$filter",function(n){return function(e,t){return!e||t?e:n("linky")(e,"_blank",{rel:"noopener noreferrer"})}}]),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={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","&":"&amp;","/":"&#x2F;"},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("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}}),e.filter("codify",function(){return function(e){return e.replace(/(^|\s)(```|`)([^`].*?)\2/g,function(e,t,n,i){return t+'<span class="hidden-bracket">'+n+"</span><code>"+i+'</code><span class="hidden-bracket">'+n+"</span>"})}})}(),function(){"use strict";angular.module("weechat").factory("handlers",["$rootScope","$log","models","plugins","notifications","bufferResume",function(l,c,f,s,u,a){function d(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)}}function h(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"))}}}function e(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)}function t(e){var t=e.objects[0].content,r="root";1==t.length&&f.getBuffer(t[0].pointers[0]).clearNicklist(),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)}}),l.$emit("nickListChanged")}var 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))},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,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);if(void 0!==r)m(r,t[n]);else{if("server"===(r=new f.Buffer(t[n])).type)f.registerServer(r);else 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)}},handleCompletion:function(e){return e.objects[0].content[0]}}}])}(),function(){"use strict";angular.module("weechat").factory("connection",["$rootScope","$log","handlers","models","settings","ngWebsockets",function(m,g,p,v,b,y){function n(e,t,n,i,r,o,a,s,c,u){m.passwordError=!1,_=[e,t,n,i,r,s];var l=r?"wss":"ws";-1!==e.indexOf(":")&&"["!==e[0]&&"]"!==e[e.length-1]&&(e="["+e+"]");var f=l+"://"+e+":"+t+"/"+n;g.debug("Connecting to URL: ",f);var d=function(e){r&&e&&1006===e.code&&void 0!==m.lastError&&Date.now()-m.lastError<1e3&&(m.sslError=!0,m.$apply())},h=function(){m.waseverconnected||m.errorMessage||(m.passwordError=!0,m.$apply())};k&&g.debug("Aborting connection (lock in use)"),k=!0;try{y.connect(f,w,{binaryType:"arraybuffer",onopen:function(){function t(){return y.send(weeChat.Protocol.formatHdata({path:"hotlist:gui_hotlist(*)",keys:[]}))}function n(){function e(e){return'\'<span class="cof-chat_time_delimiters cob-chat_time_delimiters coa-chat_time_delimiters">'+e+"</span>'"}var t=v.wconfig["weechat.look.buffer_time_format"],n="",i=e(":"),r="hh"+i+"mm"+i+"ss"+"'&nbsp;'a",o="HH"+i+"mm",a=o+i+"ss";n=-1<t.indexOf("%H")||-1<t.indexOf("%k")?-1<t.indexOf("%S")?a:o:-1<t.indexOf("%I")||-1<t.indexOf("%l")||-1<t.indexOf("%p")||-1<t.indexOf("%P")?-1<t.indexOf("%S")?r:"hh'<span class=\"cof-chat_time_delimiters cob-chat_time_delimiters coa-chat_time_delimiters\">:</span>'mm'&nbsp;'a":-1<t.indexOf("%r")?r:-1<t.indexOf("%T")?a:(t.indexOf("%R"),o);var s=[],c=Math.max(t.indexOf("%d"),t.indexOf("%e"));s.push([c,"dd"]);var u=t.indexOf("%m");s.push([u,"MM"]);var l=Math.max(t.indexOf("%y"),t.indexOf("%Y"));-1<t.indexOf("%y")?s.push([l,"yy"]):-1<t.indexOf("%Y")&&s.push([l,"yyyy"]),s.sort();for(var f=[],d=0;d<s.length;d++)-1!=s[d][0]&&f.push(s[d][1]);0<f.length&&(n=f.join(e("/"))+e("&nbsp;")+n),m.angularTimeFormat=n}var e;e=(e=i).replace(",","\\,"),y.send(weeChat.Protocol.formatInit({password:e,compression:s?"off":"zlib",useTotp:o,totp:a})),y.send(weeChat.Protocol.formatInfo({name:"version"})).then(function(e){p.handleVersionInfo(e),y.send(weeChat.Protocol.formatHdata({path:"buffer:gui_buffers(*)",keys:["local_variables,notify,number,full_name,short_name,title,hidden,type"]})).then(function(e){p.handleBufferInfo(e)}),t().then(function(e){p.handleHotlistInfo(e)}),b.hotlistsync&&setInterval(function(){m.connected&&t().then(function(e){p.handleHotlistInfo(e)})},6e4),S("weechat.look.buffer_time_format",function(){n()}),S("weechat.completion.nick_completer"),S("weechat.completion.nick_add_space"),y.send(weeChat.Protocol.formatSync({})),g.info("Connected to relay"),m.connected=!0,c&&c()},function(){h()})},onclose:function(e){g.info("Disconnected from relay"),m.$emit("relayDisconnect"),k=!1,m.userdisconnect||!m.waseverconnected?(d(e),m.userdisconnect=!1):C(e),h()},onmessage:function(){m.waseverconnected=!0},onerror:function(e){g.error("Relay error",e),k=!1,m.lastError=Date.now(),"error"===e.type&&1!==this.readyState&&(y.failCallbacks("error"),m.errorMessage=!0)}})}catch(e){k=!1,g.debug("Websocket caught DOMException:",e),m.lastError=Date.now(),m.errorMessage=!0,m.securityError=!0,m.$emit("relayDisconnect"),u&&u()}}function e(e){y.send(weeChat.Protocol.formatInput({buffer:v.getActiveBufferReference(),data:e}))}function t(e){y.send(weeChat.Protocol.formatInput({buffer:"core.weechat",data:e}))}var i,w=new weeChat.Protocol,_=[],k=!1,r=function(e,t){if(b.useTotp)g.info("Not reconnecting because totp will be expired.");else{g.info("Attempting to reconnect...");n(_[0],_[1],_[2],_[3],_[4],!1,"",_[5],function(){m.reconnecting=!1,v.setActiveBuffer(e),g.info("Sucessfully reconnected to relay")},function(){6e5<=t?(g.info("Failed to reconnect, giving up"),handleClose()):(g.info("Failed to reconnect, scheduling next attempt in",t/1e3,"seconds"),void 0!==i&&clearTimeout(i),i=setTimeout(function(){r(e,1.5*t)},t))})}},C=function(e){if(_.length<5)g.error("Cannot reconnect, connection information is missing");else{v.reinitialize(),m.reconnecting=!0,m.$apply();var t=v.getActiveBuffer().id;i=setTimeout(function(){r(t,3e3)},3e3)}},S=function(e,t){y.send(weeChat.Protocol.formatInfolist({name:"option",pointer:0,args:e})).then(function(e){p.handleConfValue(e),void 0!==t&&t()})};return{connect:n,disconnect:function(){g.info("Disconnecting from relay"),m.userdisconnect=!0,y.send(weeChat.Protocol.formatQuit());setTimeout(function(){y.disconnect(),y.failCallbacks("disconnection"),m.connected=!1,k=!1,m.$emit("relayDisconnect"),m.$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){g.debug("Fetching ",o," lines");var a=v.getActiveBuffer();return void 0===o&&(o=0),o=Math.max(o,2*a.requestedLines),m.loadingLines=!0,y.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;p.handleLineInfo(e,!0),a.lastSeen-=t,i<o&&(a.allLinesFetched=!0),m.loadingLines=!1;var r=!n&&0<=a.lastSeen;m.scrollWithBuffer(r,!0)})},requestNicklist:function(e,t){e&&y.send(weeChat.Protocol.formatNicklist({buffer:"0x"+e})).then(function(e){p.handleNicklist(e),void 0!==t&&t()})},attemptReconnect:r,requestCompletion:function(e,t,n){if(e)return y.send(weeChat.Protocol.formatCompletion({buffer:"0x"+e,position:t,data:n})).then(function(t){return new Promise(function(e){e(p.handleCompletion(t))})})}}}])}(),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();function n(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){function i(){0===r.scrollTop&&e.$apply(n.whenScrolled)}var r=t[0];t.bind("scroll",function(){_.debounce(i,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","$compile","connection","imgur","models","IrcUtils","settings","utils",function(w,k,e,r,i,C,o,S,s,x,t){var c,u,l,f,d,h,m;k.utils=t,k.inputChanged=function(){for(var e=/^(?:[\uD800-\uDBFF][\uDC00-\uDFFF])+$/,t=!(m=!0),n=k.getInputNode(),i=n.selectionStart,r=k.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&&(k.command=r.join(""),setTimeout(function(){n.setSelectionRange(i,i)}))},k.getInputNode=function(){return document.querySelector("textarea#"+k.inputId)},k.hideSidebar=function(){w.hideSidebar()},k.completeNick=function(){if(!(2==S.version[0]&&9<=S.version[1]||2<S.version[0])||!k.command.startsWith("/")){var e=k.getInputNode(),t=e.selectionStart,n=S.getActiveBuffer(),i=k.command||"",r=S.wconfig["weechat.completion.nick_completer"],o=S.wconfig["weechat.completion.nick_add_space"],a=s.completeNick(i,t,k.iterCandidate,n.getNicklistByTime(),r,o);k.iterCandidate=a.iterCandidate,k.command=a.text,setTimeout(function(){e.focus(),e.setSelectionRange(a.caretPos,a.caretPos)},0)}},k.completeCommand=function(e){if(!(S.version[0]<2||2==S.version[0]&&S.version[1]<9)&&k.command.startsWith("/")){m=!1;var a=k.getInputNode(),t=a.selectionStart,s=S.getActiveBuffer(),n=k.command||"",i=function(e){if(!m&&u&&u[0]){"backward"===e&&(h-=2)<0&&(h=u.length-1),u.length<=h&&(h=0);var t=k.command.substring(0,d-f.length),n=k.command.substring(d,k.command.length),i=u[h],r=l?" ":"";k.command=t+i+r+n;var o=t.length+i.length+r.length;setTimeout(function(){a.focus(),a.setSelectionRange(o,o)},0),1!==u.length?(h++,f=i+r,c=k.command+s.id,d=o):c=""}};n+s.id!==c?(c=n+s.id,C.requestCompletion(s.id,t,n).then(function(e){u=e.list,l=e.add_space,f=e.base_word,d=t,h=0}).then(function(){i(e)})):i(e)}},w.insertAtCaret=function(e){var t=k.getInputNode(),n=t.selectionStart,i=k.command.substring(0,n),r=k.command.substring(n,k.command.length);0<i.length&&" "!==i[i.length-1]&&(i+=" "),0<r.length&&" "!==r[0]&&(r=" ".concat(r)),k.command=i+e+r,setTimeout(function(){t.focus();var e=k.command.length-r.length;t.setSelectionRange(e,e),k.$apply()},0)},k.uploadImage=function(e,t){function n(e,t){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)};function n(e){var t=i('<div class="toast toast-short">Successfully deleted.</div>')(k)[0];document.body.appendChild(t),setTimeout(function(){document.body.removeChild(t)},5e3);var n=document.querySelector("[data-imgur-deletehash='"+e+"']");n&&document.body.removeChild(n)}k.imgurDelete=function(e){o.deleteImage(e,n)},k.sendMessage=function(){var e=S.getActiveBuffer();if(void 0!==k.command&&""!==k.command){e.addToHistory(k.command),_.each(k.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!"))&&C.sendMessage(e)}),"/buffer clear"!==k.command&&"/c"!==k.command||(r.debug("Clearing lines"),e.clear());var t=k.command.indexOf(" "),n=k.command.substr(0,t);if(0<=["/query","/join","/j","/q"].indexOf(n)){var i=k.command.substring(t+1);S.outgoingQueries.push(i)}k.command=""}x.hotlistsync&&1<=S.version[0]&&C.sendHotlistClear(),k.getInputNode().focus()},w.addMention=function(e){if(e.showHiddenBrackets){var t=e.prefix,n=t[t.length-1].text,i=S.getBuffer(e.buffer),r=i.queryNicklist(n);if("channel"===i.type&&!r){var o=document.createElement("div");o.className="toast toast-short",o.innerHTML=n+" has left the room",document.body.appendChild(o),setTimeout(function(){document.body.removeChild(o)},5e3)}var a=k.command||"",s=0===a.length;if(0<a.length){var c=a.trim();if(":"===c.charAt(c.length-1)){var u=c.lastIndexOf(" ")+1,l=c.slice(u,c.length-1),f=S.getActiveBuffer().getNicklistByTime();for(var d in f)if(f[d].name===l){a=a.slice(0,a.lastIndexOf(":"))+" ",s=!0;break}}" "!==a.charAt(a.length-1)&&(a+=" ")}a+=n,s&&(a+=": "),k.command=a,k.getInputNode().focus()}},w.handleKeyPress=function(e){if(!w.connected)return!0;var t=k.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=k.iterCandidate;if(k.iterCandidate=null,w.showJumpKeys){var u=function(){w.showJumpKeys=!1,w.jumpDecimal=void 0,k.$parent.search="",k.$parent.search_placeholder="Search",w.refresh_filter_predicate()};!e.altKey&&47<n&&n<58?void 0===w.jumpDecimal?(w.jumpDecimal=n-48,e.preventDefault(),k.$parent.search=w.jumpDecimal,w.refresh_filter_predicate()):(r=10*w.jumpDecimal+(n-48),k.$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,(k.$parent.search.length||k.$parent.onlyUnread)&&k.$parent.filteredBuffers.length?void 0!==(o=k.$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&&(k.$parent.setActiveBuffer(a[1]),e.preventDefault())),9===n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey)return e.preventDefault(),k.iterCandidate=c,k.completeNick(),k.completeCommand("forward"),!0;if(9===n&&!e.altKey&&!e.ctrlKey&&e.shiftKey)return e.preventDefault(),k.completeCommand("backward"),!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(k.command.length,k.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!==k.lastEscape&&Date.now()-k.lastEscape<=500&&C.disconnect(),k.lastEscape=Date.now(),!0}if(e.altKey&&(103===n||71===n))return e.preventDefault(),k.$parent.isSidebarVisible()||k.$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}),C.sendHotlistClearAll()}if(e.altKey&&(106===n||74===n))return e.preventDefault(),k.$parent.search="",k.$parent.search_placeholder="Number",w.showJumpKeys=!0;if("keydown"===e.type&&38===n&&document.activeElement===t)return(!k.command||(s=t.selectionStart,-1===k.command.slice(0,s).indexOf("\n")))&&(k.command=S.getActiveBuffer().getHistoryUp(k.command),setTimeout(function(){k.command&&t.setSelectionRange(k.command.length,k.command.length)},1),!0);if("keydown"===e.type&&40===n&&document.activeElement===t)return(!k.command||(s=t.selectionStart,-1===k.command.slice(s).indexOf("\n")))&&(k.command=S.getActiveBuffer().getHistoryDown(k.command),!0);if(13==n&&!e.shiftKey&&document.activeElement===t)return e.preventDefault(),k.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||k.$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(k.command.length,k.command.length);else if(85==n)k.command=k.command.slice(s),setTimeout(function(){t.setSelectionRange(0,0)});else if(75==n)k.command=k.command.slice(0,s),setTimeout(function(){t.setSelectionRange(k.command.length,k.command.length)});else{if(87!=n)return!1;var y=k.command.slice(0,s).replace(/\s+$/,"").lastIndexOf(" ")+1;k.command=k.command.slice(0,y)+k.command.slice(s,k.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},k.handleCompleteNickButton=function(e){return e.preventDefault(),k.completeNick(),k.completeCommand("forward"),setTimeout(function(){k.getInputNode().focus()},0),!0},k.inputPasted=function(e){if(e.clipboardData&&e.clipboardData.files&&e.clipboardData.files.length){e.stopPropagation(),e.preventDefault();for(var t=function(e,t){void 0!==e&&""!==e&&w.insertAtCaret(String(e));var n=i('<div class="toast toast-long" data-imgur-deletehash=\''+t+'\'>Image uploaded to Imgur. <a id="deleteImgur" ng-click="imgurDelete(\''+t+'\')" href="">Delete?</a></div>')(k)[0];document.body.appendChild(n),setTimeout(function(){document.body.removeChild(n)},15e3),console.log("An image was uploaded to imgur, delete it with $scope.imgurDelete('"+t+"')")},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){function o(e){var t=l(e);return e=s.setId(t.id,e),c.send(e),t.promise}function a(e){var t=s.parse(e.data);_.has(i,t.id)?(i[t.id].cb.resolve(t),delete i[t.id]):n.$emit("onMessage",t),n.$apply()}var s=null,c=null,i={},u=0,l=function(){var e=r.defer(),t=(1e3<(u+=1)&&(u=0),u);return i[t]={time:new Date,cb:e},e.id=t,e};return{send:o,sendAll:function(e){var t=[];for(var n in e){var i=o(e[n]);t.push(i)}return r.all(t)},connect:function(e,t,n){for(var i in c=new WebSocket(e),s=t,n)c[i]=n[i];c.onmessage="onmessage"in n?function(e){n.onmessage(e),a(e)}:a},disconnect:function(){c.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=[];function A(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=A,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=A(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||"other",v=0<=["channel","private"].indexOf(p),b=e.local_variables.plugin,y=e.local_variables.server,w="true"===e.local_variables.pinned,k=p&&"relay"===p,C=b+"."+y+("server"===p?"":"."+n);C=C.toLowerCase(),void 0!==e.notify&&(u=e.notify);for(var S="",x=0;x<a.length;++x)S+=a[x].text;var B=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())})})}},T=function(){return d.hasOwnProperty("root")};return{id:c,fullName:t,shortName:n,hidden:i,trimmedName:r,prefix:o,number:s,title:a,rtitle:S,lines:l,clear:function(){for(;0<l.length;)l.pop();f=0},requestedLines:f,addLine:function(e){l.push(e),B(e)},lastSeen:-1,unread:0,notification:0,notify:u,nicklist:d,addNick:function(e,t){T()&&(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}))},clearNicklist:function(){for(var e in d)"root"!==e&&delete d[e]},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:T,hideBufferLineTimes:k,pinned:w,queryNicklist:function(e){for(var t in d){var n=d[t].nicks;for(var i in n)if(n[i].name===e)return!0}return!1}}},this.BufferLine=function(e){var t=e.buffer,n=e.date,i=p("date")(n,"HH:mm"),r=p("date")(n,g.angularTimeFormat),o=A(e.prefix),a=e.tags_array,s=e.displayed,c=e.highlight,u=A(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+"/"+n.path,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";function s(e,t){return{contentForMessage:t,exclusive:!1,name:e}}function c(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}}var e=angular.module("plugins",[]),a=/(?:(?:https?|ftp):\/\/|www\.|ftp\.)\S*[^\s.;,(){}<>]/g;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(){function i(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)}var e=new s("Spotify music",function(e){function t(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"))}}var i=[];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+"&amp;color=ff6600&amp;auto_play=false&amp;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=document.createElement("link");t.href=e.stylesheet,t.setAttribute("rel","stylesheet"),document.head.appendChild(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("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")}}),new c("TikTok",function(e){if(e.match(/^https?:\/\/(?:www\.)?tiktok\.com\/@(?:.+)\/video\/(?:.+)\/?$|^https?:\/\/vm\.tiktok\.com\/[a-zA-Z1-9]{7}\/?$/i))return function(){var r=this.getElement();fetch("https://www.tiktok.com/oembed?url="+e).then(function(e){return e.json()}).then(function(e){var t=e.html.indexOf("<script "),n=e.html.substr(0,t);r.innerHTML=n,r.children[0].style.maxWidth="650px";var i=document.createElement("script");i.src="https://www.tiktok.com/embed.js",r.appendChild(i)})}})]}})}(),function(){"use strict";angular.module("weechat").factory("imgur",["$rootScope","settings",function(e,a){function s(e){38<=a.iToken.length?e.setRequestHeader("Authorization","Bearer "+a.iToken):e.setRequestHeader("Authorization","Client-ID 164efef8979cd4b")}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"),38<=a.iToken.length&&6<=a.iAlb.length&&r.append("album",a.iAlb);var o=new XMLHttpRequest;o.open("POST","https://api.imgur.com/3/image",!0),s(o),o.setRequestHeader("Accept","application/json"),o.onload=function(){if(n.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:"),e.data.deletehash):c()}else c()},"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)},c=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)}},deleteImage:function(e,t){var n=new XMLHttpRequest;n.open("DELETE","https://api.imgur.com/3/image/"+e,!0),s(n),n.setRequestHeader("Accept","application/json"),n.onload=function(){200===n.status?t(e):c()},n.send(null)}}}])}();
//# sourceMappingURL=min.js.map