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

3 lines
44 KiB

!function(){"use strict";var e=angular.module("localStorage",[]);e.factory("$store",["$parse",function(e){var t="undefined"==typeof window.localStorage?void 0:window.localStorage,n=!("undefined"==typeof t||"undefined"==typeof window.JSON),i={parseValue:function(e){var t;try{t=JSON.parse(e),void 0===t&&(t=e),"true"===t&&(t=!0),"false"===t&&(t=!1),parseFloat(t)!==t||angular.isObject(t)||(t=parseFloat(t))}catch(n){t=e}return t}},r={set:function(e,r){if(!n)try{return $.cookie(e,r),r}catch(e){console.log("Local Storage not supported, make sure you have the $.cookie supported.")}var o=JSON.stringify(r);return t.setItem(e,o),i.parseValue(o)},get:function(e){if(!n)try{return i.parseValue($.cookie(e))}catch(e){return null}var r=t.getItem(e);return i.parseValue(r)},remove:function(e){if(!n)try{return $.cookie(e,null),!0}catch(e){return!1}return t.removeItem(e),!0},bind:function(t,n,i){return void 0===i&&(i=""),(void 0===r.get(n)||null===r.get(n))&&r.set(n,i),e(n).assign(t,r.get(n)),t.$watch(n,function(e){r.set(n,e)},!0),r.get(n)}};return r}])}(),function(e){!function(){var t=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:function(){this._warnUnimplemented("infolist")}},this._typesStr={chr:this._strDirect,str:this._strDirect,int:this._strToString,tim:this._strToString,ptr:this._strDirect}};t._weeChatColorsNames=["default","black","darkgray","red","lightred","green","lightgreen","brown","yellow","blue","lightblue","magenta","lightmagenta","cyan","lightcyan","gray","white"],t._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"],t._getDefaultColor=function(){return{type:"weechat",name:"default"}},t._getDefaultAttributes=function(){return{name:null,override:{bold:!1,reverse:!1,italic:!1,underline:!1}}},t._getDefaultStyle=function(){return{fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),attrs:t._getDefaultAttributes()}},t._cloneColor=function(e){var t={};for(var n in e)t[n]=e[n];return t},t._cloneAttrs=function(e){var t={};t.name=e.name,t.override={};for(var n in e.override)t.override[n]=e.override[n];return t},t._attrNameFromChar=function(e){var t={"*":"b","!":"r","/":"i",_:"u","":"b","":"r","":"i","":"u"};return e in t?t[e]:null},t._attrsFromStr=function(e){for(var n=t._getDefaultAttributes(),i=0;i<e.length;++i){var r=e.charAt(i);if("|"===r)return null;var o=t._attrNameFromChar(r);null!==o&&(n.override[o]=!0)}return n},t._getColorObj=function(e){if(2===e.length){var n=parseInt(e);return n>16?t._getDefaultColor():{type:"weechat",name:t._weeChatColorsNames[n]}}var i=e.substring(1);return{type:"ext",name:parseInt(i).toString()}},t._getStyle=function(e){var n=[{regex:/^(\d{2})/,fn:function(e){var n={},i=parseInt(e[1]);if(i>43)return{fgColor:null,bgColor:null,attrs:null};var r=t._colorsOptionsNames[i];return n.fgColor={type:"option",name:r},n.bgColor=t._cloneColor(n.fgColor),n.attrs={name:r,override:{}},n}},{regex:/^@(\d{5})/,fn:function(){return{fgColor:null,bgColor:null,attrs:null}}},{regex:/^F(?:([*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))/,fn:function(e){var n={bgColor:null};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n}},{regex:/^B(\d{2}|@\d{5})/,fn:function(e){return{fgColor:null,bgColor:t._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 n={};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n.bgColor=t._getColorObj(e[5]),n}},{regex:/^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,fn:function(e){return{fgColor:t._getColorObj(e[2]),bgColor:null,attrs:t._attrsFromStr(e[1])}}},{regex:/^E/,fn:function(){var e={};return e.fgColor={type:"option",name:"emphasis"},e.bgColor=t._cloneColor(e.fgColor),e.attrs={name:"emphasis",override:{}},e}}],i={fgColor:null,bgColor:null,attrs:null,text:e};return n.some(function(t){var n=e.match(t.regex);return n?(i=t.fn(n),i.text=e.substring(n[0].length),!0):!1}),i},t.rawText2Rich=function(e){var n=e.split(/(\x19|\x1a|\x1b|\x1c)/);if(1===n.length)return[{attrs:t._getDefaultAttributes(),fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),text:n[0]}];var i=t._getDefaultColor(),r=t._getDefaultColor(),o=t._getDefaultAttributes(),a=null,c=!0;return n.map(function(e){if(0===e.length)return null;var n=e.charCodeAt(0),s=e.charAt(0);if(n>=25&&28>=n)return 28===n&&(i=t._getDefaultColor(),r=t._getDefaultColor(),25!==a&&(o=t._getDefaultAttributes())),a=n,null;var l=e;if(25===a){var u=t._getStyle(e);null!==u.fgColor&&(i=u.fgColor),null!==u.bgColor&&(r=u.bgColor),null!==u.attrs&&(o=u.attrs),l=u.text}else if(26===a||27===a){var f=26===a;if("|"!==s){var d=t._attrNameFromChar(s);d&&(o.override[d]=f,l=e.substring(1))}}if(a=null,0===l.length)return null;if(c&&null===o.name){var h=!0;for(var g in o.override)if(o.override[g]){h=!1;break}h?o.override={}:c=!1}return{fgColor:t._cloneColor(i),bgColor:t._cloneColor(r),attrs:t._cloneAttrs(o),text:l}}).filter(function(e){return null!==e})},t._uia2s=function(e){if(!e.length||0===e[0])return"";try{var t=String.fromCharCode.apply(null,e),n=decodeURIComponent(escape(t));return n}catch(t){for(var i="",r=0,o=e.length;o>r;r++)i+=e[r]<128?String.fromCharCode(e[r]):"?";return i}},t._mergeParams=function(e,t){for(var n in t)e[n]=t[n];return e},t.setId=function(e,t){return"("+e+") "+t},t._formatCmd=function(e,t,n){var i,r;return i=null!==e?"("+e+") ":"",i+=t,n.unshift(i),r=n.join(" "),r+="\n",r.replace(/[\r\n]+$/g,"").split("\n"),r},t.formatInit=function(e){var n={password:null,compression:"zlib"},i=[],r=[];return e=t._mergeParams(n,e),i.push("compression="+e.compression),null!==e.password&&i.push("password="+e.password),r.push(i.join(",")),t._formatCmd(null,"init",r)},t.formatHdata=function(e){var n={id:null,keys:null},i=[];return e=t._mergeParams(n,e),i.push(e.path),null!==e.keys&&i.push(e.keys.join(",")),t._formatCmd(e.id,"hdata",i)},t.formatInfo=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),i.push(e.name),t._formatCmd(e.id,"info",i)},t.formatNicklist=function(e){var n={id:null,buffer:null},i=[];return e=t._mergeParams(n,e),null!==e.buffer&&i.push(e.buffer),t._formatCmd(e.id,"nicklist",i)},t.formatInput=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),i.push(e.buffer),i.push(e.data),t._formatCmd(e.id,"input",i)},t._formatSyncDesync=function(e,n){var i={id:null,buffers:null,options:null},r=[];return n=t._mergeParams(i,n),null!==n.buffers&&(r.push(n.buffers.join(",")),null!==n.options&&r.push(n.options.join(","))),t._formatCmd(n.id,e,r)},t.formatSync=function(e){return t._formatSyncDesync("sync",e)},t.formatDesync=function(e){return t._formatSyncDesync("desync",e)},t.formatTest=function(e){var n={id:null},i=[];return e=t._mergeParams(n,e),t._formatCmd(e.id,"test",i)},t.formatQuit=function(){return t._formatCmd(null,"quit",[])},t.formatPing=function(e){var n={id:null,args:null},i=[];return e=t._mergeParams(n,e),null!==e.args&&i.push(e.args.join(" ")),t._formatCmd(e.id,"ping",i)},t.prototype={_warnUnimplemented:function(e){console.log("Warning: "+e+" message parsing is not implemented")},_getType:function(){var e=this._getSlice(3);return e?t._uia2s(new Uint8Array(e)):null},_runType:function(e){var t=this._types[e],n=t.bind(this);return n()},_getStrNumber:function(){var e=this._getByte(),n=this._getSlice(e);return t._uia2s(new Uint8Array(n))},_strDirect:function(e){return e},_strToString:function(e){return e.toString()},_objToString:function(e,t){var n=this._typesStr[t],i=n.bind(this);return i(e)},_getInfo:function(){var e={};return e.key=this._getString(),e.value=this._getString(),e},_getHdata:function(){function e(){var e={};e.pointers=t.map(function(){return i._getPointer()}),keys.forEach(function(t){e[t[0]]=i._runType(t[1])}),r.push(e)}var t,n,i=this,r=[],o=this._getString();keys=this._getString().split(","),t=o.split("/"),n=this._getInt(),keys=keys.map(function(e){return e.split(":")});for(var a=0;n>a;a++)e();return r},_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(){var e=new Uint8Array(this._getSlice(1));return e[0]},_getChar:function(){return this._getByte()},_getString:function(){var e=this._getInt();if(e>0){var n=this._getSlice(e),i=new Uint8Array(n);return t._uia2s(i)}return""},_getHeader:function(){var e=this._getInt(),t=this._getByte();return{length:e,compression:t}},_getId:function(){return this._getString()},_getObject:function(){var e=this,t=this._getType();return t?{type:t,content:e._runType(t)}:void 0},_getHashTable:function(){var e,t,n,i=this,r={};e=this._getType(),t=this._getType(),n=this._getInt();for(var o=0;n>o;++o){var a=i._runType(e),c=i._objToString(a,e),s=i._runType(t);r[c]=s}return r},_getArray:function(){var e,t,n,i=this;e=this._getType(),t=this._getInt(),n=[];for(var r=0;t>r;r++)n.push(i._runType(e));return n},_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},parse:function(e){var t=this;this._setData(e),this._dataAt=0;var n=this._getHeader();if(n.compression){var i=new Uint8Array(e,5),r=new Zlib.Inflate(i),o=r.decompress();this._setData(o.buffer),this._dataAt=0}for(var a=this._getId(),c=[],s=this._getObject();s;)c.push(s),s=t._getObject();var l={header:n,id:a,objects:c};return l}},e.Protocol=t}()}("undefined"==typeof exports?this.weeChat={}:exports);var IrcUtils={_ciNickList:function(e){var t=_(e).sortBy(function(e){return-e.spokeAt});return t=_(t).pluck("name")},_completeSingleNick:function(e,t){var n=null;return t.some(function(t){return 0===t.toLowerCase().search(e.toLowerCase())?(n=t,!0):!1}),n},_nextNick:function(e,t,n){for(var i=[],r=null,o=e.toLowerCase(),a=t.toLowerCase(),c=0;c<n.length;++c){var s=n[c].toLowerCase();0===s.search(o)&&(i.push(n[c]),a===s&&(r=i.length-1))}return null===r||0===i.length?t:(++r,r===i.length&&(r=0),i[r])},completeNick:function(e,t,n,i,r){var o=null!==n;null===r&&(r=":");var a=IrcUtils._ciNickList(i),c=e.substring(0,t),s=e.substring(t),l={text:e,caretPos:t,foundNick:null,iterCandidate:null},u=c.match(new RegExp("^([a-zA-Z0-9_\\\\\\[\\]{}^`|-]+)"+r+" $")),f=null;return u?o?(f=IrcUtils._nextNick(n,u[1],a),c=f+r+" ",{text:c+s,caretPos:c.length,foundNick:f,iterCandidate:n}):l:(u=c.match(/^([a-zA-Z0-9_\\\[\]{}^`|-]+)$/))?(f=IrcUtils._completeSingleNick(u[1],a),null===f?l:(c=f+r+" "," "===s[0]&&(s=s.substring(1)),{text:c+s,caretPos:c.length,foundNick:f,iterCandidate:u[1]})):(u=c.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+) $/))?o?(f=IrcUtils._nextNick(n,u[2],a),c=u[1]+f+" ",{text:c+s,caretPos:c.length,foundNick:f,iterCandidate:n}):l:(u=c.match(/^(.* )([a-zA-Z0-9_\\\[\]{}^`|-]+)$/),u?(f=IrcUtils._completeSingleNick(u[2],a),null===f?l:(c=u[1]+f+" "," "===s[0]&&(s=s.substring(1)),{text:c+s,caretPos:c.length,foundNick:f,iterCandidate:u[2]})):l)}},weechat=angular.module("weechat",["ngRoute","localStorage","weechatModels","plugins","ngSanitize","ngWebsockets","ngTouch"]);weechat.filter("toArray",function(){"use strict";return function(e){return e instanceof Object?Object.keys(e).map(function(t){return Object.defineProperty(e[t],"$key",{value:t})}):e}});var 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]})};weechat.filter("irclinky",["$filter",function(e){"use strict";return function(t,n){if(!t)return t;var i=e("linky")(t,n),r=/(^|[\s,.:;?!"'()+@-])(#+[a-z0-9-_]*[a-z][a-z0-9-_]*)/gim;return i=i.replace(r,'$1<a href="#" onclick="var $scope = angular.element(event.target).scope(); $scope.openBuffer(\'$2\'); $scope.$apply();">$2</a>')}}]),weechat.filter("inlinecolour",["$sce",function(e){"use strict";return function(t){if(!t)return t;var n=/(^|[^&])\#([0-9a-f]{6})($|[^\w'"])/gim,i='$1#$2 <div class="colourbox" style="background-color:#$2"></div> $3';return e.trustAsHtml(t.replace(n,i))}}]),weechat.factory("handlers",["$rootScope","$log","models","plugins",function(e,t,n,i){var r=function(e){var t=e.objects[0].content[0],i=t.pointers[0];n.closeBuffer(i)},o=function(t,r){var o=new n.BufferLine(t),a=n.getBuffer(o.buffer);a.requestedLines++,o.displayed&&(o=i.PluginManager.contentForMessage(o),a.addLine(o),r&&a.lastSeen++,a.active&&!r&&e.scrollWithBuffer(),r||a.active&&e.isWindowFocused()||(a.notify>1&&_.contains(o.tags,"notify_message")&&!_.contains(o.tags,"notify_none")&&(a.unread++,e.$emit("notificationChanged")),(0!==a.notify&&o.highlight||_.contains(o.tags,"notify_private"))&&(a.notification++,e.createHighlight(a,o),e.$emit("notificationChanged"))))},a=function(e){e.objects[0].content.forEach(function(e){o(e,!1)})},c=function(e){var t=e.objects[0].content[0],i=new n.Buffer(t);n.addBuffer(i)},s=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.fullName=t.full_name,r.title=t.title,r.number=t.number},l=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i);r.fullName=t.full_name,r.shortName=t.short_name},u=function(e){var t=e.objects[0].content[0],i=t.pointers[0],r=n.getBuffer(i),o=t.local_variables;void 0!==r&&void 0!==o&&(r.indent=["channel","private"].indexOf(o.type)>=0)},f=function(e,t){var n=e.objects[0].content.reverse();void 0===t&&(t=!0),n.forEach(function(e){o(e,t)})},d=function(e){if(0!==e.objects.length){var t=e.objects[0].content;t.forEach(function(e){var t=n.getBuffer(e.buffer);t.unread+=e.count[1],t.notification+=e.count[2],t.notification+=e.count[3];var i=_.reduce(e.count,function(e,t){return e+t},0);t.lastSeen=t.lines.length-1-i})}},h=function(e){var t=e.objects[0].content,i="root";t.forEach(function(e){var t=n.getBuffer(e.pointers[0]);if(1===e.group){var r=new n.NickGroup(e);i=r.name,t.nicklist[i]=r}else{var o=new n.Nick(e);t.addNick(i,o)}})},g=function(e){var t,i=e.objects[0].content;i.forEach(function(e){var i=n.getBuffer(e.pointers[0]),r=e._diff;if(1===e.group){if(t=e.name,void 0===t){var o=new n.NickGroup(e);i.nicklist[t]=o,t=o.name}}else{var a=new n.Nick(e);43===r?i.addNick(t,a):45===r?i.delNick(t,a):42===r&&i.updateNick(t,a)}})},m={_buffer_closing:r,_buffer_line_added:a,_buffer_localvar_added:u,_buffer_localvar_removed:u,_buffer_opened:c,_buffer_title_changed:s,_buffer_renamed:l,_nicklist:h,_nicklist_diff:g};e.$on("onMessage",function(e,n){_.has(m,n.id)?m[n.id](n):t.debug("Unhandled event received: "+n.id)});var v=function(e){_.has(m,e.id)&&m[e.id](e)};return{handleEvent:v,handleLineInfo:f,handleHotlistInfo:d,handleNicklist:h}}]),weechat.factory("connection",["$rootScope","$log","handlers","models","ngWebsockets",function(e,t,n,i,r){protocol=new weeChat.Protocol;var o=function(o,a,c,s,l){var u=s?"wss":"ws";-1!==o.indexOf(":")&&(o="["+o+"]");var f=u+"://"+o+":"+a+"/weechat";t.debug("Connecting to URL: ",f);var d=function(){var o=function(e){return r.send(weeChat.Protocol.formatInit({password:e,compression:l?"off":"zlib"})),r.send(weeChat.Protocol.formatInfo({name:"version"}))},a=function(){return r.send(weeChat.Protocol.formatHdata({path:"hotlist:gui_hotlist(*)",keys:[]}))},s=function(){return r.send(weeChat.Protocol.formatHdata({path:"buffer:gui_buffers(*)",keys:["local_variables,notify,number,full_name,short_name,title"]}))},u=function(){return r.send(weeChat.Protocol.formatSync({}))};o(c).then(function(){s().then(function(e){for(var t=e.objects[0].content,n=0;n<t.length;n++){var r=new i.Buffer(t[n]);i.addBuffer(r),0===n&&i.setActiveBuffer(r.id)}}),a().then(function(e){n.handleHotlistInfo(e)}),u(),t.info("Connected to relay"),e.connected=!0},function(){e.waseverconnected||(e.passwordError=!0)})},h=function(){e.waseverconnected=!0},g=function(n){t.info("Disconnected from relay"),failCallbacks("disconnection"),e.connected=!1,e.$emit("relayDisconnect"),s&&1006===n.code&&"undefined"!=typeof e.lastError&&Date.now()-e.lastError<1e3&&(e.sslError=!0),e.$apply()},m=function(n){t.error("Relay error",n),e.lastError=Date.now(),"error"===n.type&&1!==this.readyState&&(failCallbacks("error"),e.errorMessage=!0)};protocol.setId=function(e,t){return"("+e+") "+t};try{r.connect(f,protocol,{binaryType:"arraybuffer",onopen:d,onclose:g,onmessage:h,onerror:m})}catch(n){t.debug("Websocket caught DOMException:",n),e.lastError=Date.now(),e.errorMessage=!0,e.securityError=!0,e.$emit("relayDisconnect")}},a=function(){r.send(weeChat.Protocol.formatQuit())},c=function(e){r.send(weeChat.Protocol.formatInput({buffer:i.getActiveBuffer().fullName,data:e}))},s=function(e){r.send(weeChat.Protocol.formatInput({buffer:"core.weechat",data:e}))},l=function(e,t){e=e||null,r.send(weeChat.Protocol.formatNicklist({buffer:e})).then(function(e){n.handleNicklist(e),void 0!==t&&t()})},u=function(o){t.debug("Fetching ",o," lines");var a=i.getActiveBuffer();return void 0===o&&(o=0),o=Math.max(o,2*a.requestedLines),e.loadingLines=!0,r.send(weeChat.Protocol.formatHdata({path:"buffer:0x"+a.id+"/own_lines/last_line(-"+o+")/data",keys:[]})).then(function(t){var i=a.lines.length,r=a.lastSeen>=0&&i!==a.lines.length;a.lines.length=0,a.requestedLines=0;var c=t.objects[0].content.length;n.handleLineInfo(t,!0),r?a.lastSeen=a.lines.length-i-1:a.lastSeen-=i,o>c&&(a.allLinesFetched=!0),e.loadingLines=!1,e.scrollWithBuffer(!0)})};return{connect:o,disconnect:a,sendMessage:c,sendCoreCommand:s,fetchMoreLines:u,requestNicklist:l}}]),weechat.controller("WeechatCtrl",["$rootScope","$scope","$store","$timeout","$log","models","connection",function(e,t,n,i,r,o,a){e.countWatchers=function(){for(var t,n=[e],i=0;n.length>0;)t=n.pop(),t.$$watchers&&(i+=t.$$watchers.length),t.$$childHead&&n.push(t.$$childHead),t.$$nextSibling&&n.push(t.$$nextSibling);r.debug(i)},e.isMobileUi=function(){var e=968;return document.body.clientWidth<e},t.requestNotificationPermission=function(){if(window.Notification&&Notification.requestPermission(function(e){r.info("Notification permission status: ",e),Notification.permission!==e&&(Notification.permission=e)}),void 0!==window.webkitNotifications){var e=window.webkitNotifications.checkPermission();0!==e&&(r.info("Notification permission status: ",0===e),window.webkitNotifications.requestPermission())}},t.isinstalled=function(){return void 0===navigator.mozApps?!1:void(navigator.mozApps.getSelf().onsuccess=function(e){var t=e.target.result;return t?!0:!1})}(),function(){"undefined"!=typeof document.hidden?(t.documentHidden="hidden",t.documentVisibilityChange="visibilitychange"):"undefined"!=typeof document.webkitHidden?(t.documentHidden="webkitHidden",t.documentVisibilityChange="webkitvisibilitychange"):"undefined"!=typeof document.mozHidden?(t.documentHidden="mozHidden",t.documentVisibilityChange="mozvisibilitychange"):"undefined"!=typeof document.msHidden&&(t.documentHidden="msHidden",t.documentVisibilityChange="msvisibilitychange")}(),function(){window.location.search.substring(1).split("&").forEach(function(t){var n=t.split("=");return"debug"===n[0]&&-1!=["true","1"].indexOf(n[1])?void(e.debugMode=!0):void 0})}(),e.isWindowFocused=function(){if("undefined"==typeof t.documentHidden)return!0;var e=document[t.documentHidden];return!e},"undefined"!=typeof t.documentVisibilityChange&&document.addEventListener(t.documentVisibilityChange,function(){if(!document[t.documentHidden]){var n=o.getActiveBuffer();null!==n&&(n.unread=0,n.notification=0,e.$emit("notificationChanged")),e.$apply()}},!1),e.unreadCount=function(e){e||(e="unread");var t=Object.keys(o.model.buffers),n=0;for(var i in t)n+=o.model.buffers[t[i]][e];return n},e.updateTitle=function(){var t=e.unreadCount("notification");e.notificationStatus=t>0?"("+t+") ":"";var n=o.getActiveBuffer();n&&(e.pageTitle=n.shortName+" | "+n.title)},t.updateFavico=function(){var n=e.unreadCount("notification");if(n>0)t.favico.badge(n,{bgColor:"#d00",textColor:"#fff"});else{var i=e.unreadCount("unread");0===i?t.favico.reset():t.favico.badge(i,{bgColor:"#5CB85C",textColor:"#ff0"})}},e.$on("activeBufferChanged",function(n,r){var c=o.getActiveBuffer(),s=c.lines.length-r+5,l=c.lines.length-(2*t.lines_per_screen+10),u=Math.max(0,Math.min(s,l));if(c.lines.splice(0,u),c.requestedLines-=u,c.lastSeen-=u,t.bufferlines=c.lines,t.nicklist=c.nicklist,c.nicklistRequested()?t.showNicklist=t.updateShowNicklist():a.requestNicklist(c.fullName,function(){t.showNicklist=t.updateShowNicklist(),e.scrollWithBuffer(!0)}),c.requestedLines<t.lines_per_screen){var f=t.lines_per_screen+10;r>f&&(f=Math.min(4*f,r)),t.fetchMoreLines(f).then(function(){i(function(){var t=document.getElementById("bufferlines");e.originalBufferlinesPosition=t.scrollTop+t.scrollHeight})})}e.updateTitle(c),e.scrollWithBuffer(!0),t.hotlistsync&&c.fullName&&a.sendCoreCommand("/buffer "+c.fullName),t.search="",e.isMobileUi()||setTimeout(function(){document.getElementById("sendMessage").focus()},0)}),t.favico=new Favico({animation:"none"}),e.$on("notificationChanged",function(){e.updateTitle(),t.useFavico&&t.favico&&t.updateFavico()}),e.$on("relayDisconnect",function(){o.reinitialize(),e.$emit("notificationChanged"),t.connectbutton="Connect"}),t.connectbutton="Connect",t.getBuffers=o.getBuffers.bind(o),t.bufferlines={},t.nicklist={},t.activeBuffer=o.getActiveBuffer,e.connected=!1,e.waseverconnected=!1,e.models=o,e.iterCandidate=null,n.bind(t,"host","localhost"),n.bind(t,"port","9001"),n.bind(t,"proto","weechat"),n.bind(t,"ssl","https:"===window.location.protocol),n.bind(t,"savepassword",!1),t.savepassword&&n.bind(t,"password",""),n.bind(t,"autoconnect",!1);var c=!1,s=!1,l=!0;e.wasMobileUi=!1,e.isMobileUi()&&(c=!0,s=!0,e.wasMobileUi=!0),n.bind(t,"onlyUnread",!1),n.bind(t,"hotlistsync",!0),n.bind(t,"nonicklist",c),n.bind(t,"noembed",s),n.bind(t,"orderbyserver",!0),n.bind(t,"useFavico",!0),n.bind(t,"showtimestamp",l),n.bind(t,"showtimestampSeconds",!1),n.bind(t,"soundnotification",!1),n.bind(t,"fontfamily",getClassStyle("favorite-font","fontFamily")),n.bind(t,"fontsize",getClassStyle("favorite-font","fontSize")),n.bind(t,"readlineBindings",!1),t.fontfamily||(t.fontfamily=e.isMobileUi()?"sans-serif":"Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace"),e.auto_display_embedded_content=t.noembed===!1,t.isSidebarVisible=function(){return"visible"===document.getElementById("sidebar").getAttribute("sidebar-state")},t.showSidebar=function(){document.getElementById("sidebar").setAttribute("data-state","visible"),document.getElementById("content").setAttribute("sidebar-state","visible"),e.isMobileUi()&&_.each(document.getElementsByTagName("textarea"),function(e){e.blur()})},e.hideSidebar=function(){e.isMobileUi()&&(document.getElementById("sidebar").setAttribute("data-state","hidden"),document.getElementById("content").setAttribute("sidebar-state","hidden"))},t.$watch("autoconnect",function(){!t.autoconnect||e.connected||e.sslError||e.securityError||e.errorMessage||t.connect()}),t.toggleSidebar=function(){e.isMobileUi()&&(t.isSidebarVisible()?t.hideSidebar():t.showSidebar())},t.openNick=function(){e.isMobileUi()&&t.nonicklist&&(t.nonicklist=!1)},t.closeNick=function(){e.isMobileUi()&&(t.nonicklist||(t.nonicklist=!0))},t.$watch("noembed",function(){e.auto_display_embedded_content=t.noembed===!1}),t.$watch("orderbyserver",function(){e.predicate=t.orderbyserver?"serverSortKey":"number"}),t.$watch("useFavico",function(){e.connected&&(t.useFavico?t.updateFavico():t.favico.reset())}),t.$watch("fontfamily",function(){changeClassStyle("favorite-font","fontFamily",t.fontfamily)}),t.$watch("fontsize",function(){changeClassStyle("favorite-font","fontSize",t.fontsize)}),t.$watch("readlineBindings",function(){e.readlineBindings=t.readlineBindings}),t.setActiveBuffer=function(n,i){return e.isMobileUi()&&t.hideSidebar(),o.setActiveBuffer(n,i)},t.openBuffer=function(e){var n=o.getActiveBuffer().fullName;if(n=n.substring(0,n.lastIndexOf(".")+1)+e,!t.setActiveBuffer(n,"fullName")){var i="join";["#","&","+","!"].indexOf(e.charAt(0))<0&&(i="query"),a.sendMessage("/"+i+" "+e)}},t.calculateNumLines=function(){for(var e=document.querySelectorAll(".bufferline"),n=0,i=0;0===n&&i<e.length;)n=e[i++].clientHeight;var r=document.querySelector("#bufferlines").clientHeight,o=Math.ceil(r/n+10);t.lines_per_screen=o},t.calculateNumLines(),window.addEventListener("resize",_.debounce(function(){if(e.connected){t.wasMobileUi&&!t.isMobileUi()&&t.showSidebar(),t.wasMobileUi=t.isMobileUi(),t.calculateNumLines();var n=document.getElementById("bufferlines");e.originalBufferlinesPosition===n.scrollHeight+n.scrollTop&&i(function(){n.scrollTop=n.scrollHeight},100),e.originalBufferlinesPosition=n.scrollTop+n.scrollHeight}},100)),e.loadingLines=!1,t.fetchMoreLines=function(e){return e||(e=t.lines_per_screen),a.fetchMoreLines(e)},e.scrollWithBuffer=function(e){var t=document.getElementById("bufferlines"),n=t.scrollHeight-t.clientHeight,r=function(){var i=t.scrollTop;if(e&&n>i||Math.abs(i-n)<3){var r=document.querySelector(".readmarker");t.scrollTop=e&&r?r.offsetTop-r.parentElement.scrollHeight+r.scrollHeight:t.scrollHeight-t.clientHeight}};i(r),i(r,100),i(r,300),i(r,500)},t.connect=function(){t.requestNotificationPermission(),e.sslError=!1,e.securityError=!1,e.errorMessage=!1,t.connectbutton="Connecting ...",a.connect(t.host,t.port,t.password,t.ssl)},t.disconnect=function(){t.connectbutton="Connect",a.disconnect()},t.install=function(){if(void 0!==navigator.mozApps){var e=location.protocol+"//"+location.host+location.pathname.replace(/\/(index\.html)?$/,""),n=navigator.mozApps.install(e+"/manifest.webapp");n.onsuccess=function(){t.isinstalled=!0;var e=this.result;e.launch(),alert("Installation successful!")},n.onerror=function(){alert("Install failed, error: "+this.error.name)}}else alert("Sorry. Only supported in Firefox v26+")},t.showModal=function(e){document.getElementById(e).setAttribute("data-state","visible")},t.closeModal=function(e){function t(e,t){for(var n=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;e;){if(n.call(e,t))return e;e=e.parentElement}}t(e.target,".gb-modal").setAttribute("data-state","hidden")},t.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")}},e.createHighlight=function(e,n){var i="",r="",a=e.notification;if(["#","&","+","!"].indexOf(e.shortName.charAt(0))<0)i=a>1?a.toString()+" private messages from ":"Private message from ",r=n.text;else{i=a>1?a.toString()+" highlights in ":"Highlight in ";for(var c="",s=0;s<n.prefix.length;s++)c+=n.prefix[s].text;r="<"+c+"> "+n.text}i+=e.shortName,i+=e.fullName.replace(/irc.([^\.]+)\..+/," ($1)");var l=new Notification(i,{body:r,icon:"assets/img/favicon.png"}),u=15e3;if(l.onshow=function(){setTimeout(function(){l.close()},u)},l.onclick=function(){o.setActiveBuffer(e.id),window.focus(),l.close()},t.soundnotification){var f="assets/audio/sonar",d='<audio autoplay="autoplay"><source src="'+f+'.ogg" type="audio/ogg" /><source src="'+f+'.mp3" type="audio/mpeg" /></audio>';document.getElementById("soundNotification").innerHTML=d}},t.hasUnread=function(e){return t.search&&""!==t.search?!0:t.onlyUnread?o.getActiveBuffer()===e?!0:e.unread>0||e.notification>0:!0},t.$watch("nonicklist",function(){t.showNicklist=t.updateShowNicklist()}),t.showNicklist=!1,t.updateShowNicklist=function(){var e=o.getActiveBuffer();return e?t.nonicklist?!1:e.isNicklistEmpty()?!1:!0:!1},e.switchToActivityBuffer=function(){var e,n,i=_.sortBy(t.getBuffers(),"number");for(e in i)if(n=i[e],n.notification>0)return void t.setActiveBuffer(n.id);for(e in i)if(n=i[e],n.unread>0)return void t.setActiveBuffer(n.id)},e.toggleNicklist=function(){t.nonicklist=!t.nonicklist},t.handleSearchBoxKey=function(e){var n=e.keyCode?e.keyCode:e.charCode;27===n?(e.preventDefault(),t.search=""):13===n&&(e.preventDefault(),t.filteredBuffers.length>0&&o.setActiveBuffer(t.filteredBuffers[0].id),t.search="")},window.onbeforeunload=function(n){e.connected&&(n.preventDefault(),n.returnValue="You have an active connection to your WeeChat relay. Please disconnect using the button in the top-right corner or by double-tapping the Escape key."),t.favico.reset()}}]),weechat.config(["$routeProvider",function(e){e.when("/",{templateUrl:"index.html",controller:"WeechatCtrl"})}]),weechat.directive("plugin",["$rootScope",function(e){return{templateUrl:"directives/plugin.html",scope:{plugin:"=data"},controller:["$scope",function(t){t.displayedContent="",t.plugin.visible=e.auto_display_embedded_content,t.hideContent=function(){t.plugin.visible=!1},t.showContent=function(){t.plugin.content instanceof Function&&(t.plugin.content=t.plugin.content()),t.displayedContent=t.plugin.content,t.plugin.visible=!0;var e=function(){var e=document.querySelector(".embed_"+t.plugin.$$hashKey);e&&e.scrollIntoViewIfNeeded()};setTimeout(e,100)},t.plugin.visible&&t.showContent()}]}}]),weechat.directive("inputBar",function(){return{templateUrl:"directives/input.html",scope:{inputId:"@inputId"},controller:["$rootScope","$scope","$element","$log","connection","models",function(e,t,n,i,r,o){t.getInputNode=function(){return document.querySelector("textarea#"+t.inputId)},t.hideSidebar=function(){e.hideSidebar()},t.completeNick=function(){var e=t.getInputNode(),n=e.selectionStart,i=o.getActiveBuffer(),r=t.command||"",a=IrcUtils.completeNick(r,n,t.iterCandidate,i.getNicklistByTime(),":");t.iterCandidate=a.iterCandidate,t.command=a.text,setTimeout(function(){e.focus(),e.setSelectionRange(a.caretPos,a.caretPos)},0)},t.sendMessage=function(){var e=o.getActiveBuffer();void 0!==t.command&&""!==t.command&&(e.addToHistory(t.command),_.each(t.command.split(/\r?\n/),function(e){r.sendMessage(e)}),("/buffer clear"===t.command||"/c"===t.command)&&(i.debug("Clearing lines"),e.clear()),t.command=""),t.getInputNode().focus()},e.addMention=function(e){var n=e[e.length-1].text,i=t.command||"",r=0===i.length;if(i.length>0){var a=i.trim();if(":"===a.charAt(a.length-1)){var c=a.lastIndexOf(" ")+1,s=a.slice(c,a.length-1),l=o.getActiveBuffer().getNicklistByTime();for(var u in l)if(l[u].name===s){i=i.slice(0,i.lastIndexOf(":"))+" ",r=!0;break}}" "!==i.charAt(i.length-1)&&(i+=" ")}i+=n,r&&(i+=": "),t.command=i,t.getInputNode().focus()},e.handleKeyPress=function(n){if(!e.connected)return!0;var i=t.getInputNode(),a=n.keyCode?n.keyCode:n.charCode,c=t.iterCandidate;if(t.iterCandidate=null,n.altKey&&!n.ctrlKey&&a>47&&58>a){48===a&&(a=58);var s=a-48-1,l=Object.keys(o.getBuffers())[s];l&&(o.setActiveBuffer(l),n.preventDefault())}if(9===a&&!n.altKey&&!n.ctrlKey)return n.preventDefault(),t.iterCandidate=c,t.completeNick(),!0;if(n.altKey&&!n.ctrlKey&&78===a)return n.preventDefault(),e.toggleNicklist(),!0;if(n.altKey&&(97===a||65===a))return n.preventDefault(),e.switchToActivityBuffer(),!0;if(n.altKey&&(76===a||108===a))return n.preventDefault(),i.focus(),i.setSelectionRange(t.command.length,t.command.length),!0;
if(n.altKey&&(60===a||226===a)){var u=o.getPreviousBuffer();if(u)return o.setActiveBuffer(u.id),n.preventDefault(),!0}if(27===a){n.preventDefault();for(var f=document.querySelectorAll(".gb-modal"),d=0;d<f.length;d++)if("visible"===f[d].getAttribute("data-state"))return f[d].setAttribute("data-state","hidden"),!0;return"undefined"!=typeof t.lastEscape&&Date.now()-t.lastEscape<=500&&r.disconnect(),t.lastEscape=Date.now(),!0}if(n.altKey&&(103===a||71===a))return n.preventDefault(),document.getElementById("bufferFilter").focus(),!0;if("keydown"===n.type&&38===a)return t.command=o.getActiveBuffer().getHistoryUp(t.command),setTimeout(function(){t.command&&i.setSelectionRange(t.command.length,t.command.length)},0),!0;if("keydown"===n.type&&40===a)return t.command=o.getActiveBuffer().getHistoryDown(t.command),!0;if(13==a&&!n.shiftKey&&document.activeElement===i)return n.preventDefault(),t.sendMessage(),!0;if(e.readlineBindings&&n.ctrlKey&&!n.altKey&&!n.shiftKey&&document.activeElement===i){var h=i.selectionStart;if(65==a)i.setSelectionRange(0,0);else if(69==a)i.setSelectionRange(t.command.length,t.command.length);else if(85==a)t.command=t.command.slice(h),setTimeout(function(){i.setSelectionRange(0,0)});else if(75==a)t.command=t.command.slice(0,h),setTimeout(function(){i.setSelectionRange(t.command.length,t.command.length)});else{if(87!=a)return!1;var g=t.command.slice(0,h),m=g.lastIndexOf(" ")+1;t.command=t.command.slice(0,m)+t.command.slice(h,t.command.length),setTimeout(function(){i.setSelectionRange(m,m)})}return n.preventDefault(),!0}}}]}});var websockets=angular.module("ngWebsockets",[]);websockets.factory("ngWebsockets",["$rootScope","$q",function(e,t){this.protocol=null;var n=null,i={},r=0;failCallbacks=function(e){for(var t in i)i[t].cb.reject(e)};var o=function(){return r+=1,r>1e3&&(r=0),r},a=function(e){var t=c(e);return e=protocol.setId(t.id,e),n.send(e),t.promise},c=function(){var e=t.defer(),n=o();return i[n]={time:new Date,cb:e},e.id=n,e},s=function(e){var n=[];for(var i in e){var r=a(e[i]);n.push(r)}return t.all(n)},l=function(t){var n=protocol.parse(t.data);if(_.has(i,n.id)){var r=i[n.id];r.cb.resolve(n),delete i[n.id]}else e.$emit("onMessage",n);e.$apply()},u=function(e,t,i){n=new WebSocket(e),t=t;for(var r in i)n[r]=i[r];n.onmessage="onmessage"in i?function(e){i.onmessage(e),l(e)}:l},f=function(){n.close()};return{send:a,sendAll:s,connect:u,disconnect:f}}]);var models=angular.module("weechatModels",[]);models.service("models",["$rootScope","$filter",function(e,t){function n(e,t){if(t in e&&e[t]&&e[t].length>0){var n=e[t];if(n.match(/^weechat/)){var i=n.match(/[a-zA-Z0-9_]+$/)[0];return["cof-"+i,"cob-"+i,"coa-"+i]}if(n.match(/^[a-zA-Z]+$/))return["cwf-"+n];if(n.match(/^[0-9]+$/))return["cef-"+n]}return["cwf-default"]}function i(e){return{name:n(e,"color"),prefix:n(e,"prefix_color")}}this.Buffer=function(e){var t=e.full_name,n=e.short_name,i=e.title,r=e.number,o=e.pointers[0],a=3,c=[],s=0,l={},u=[],f=0,d=0,h=0,g=-1,m=t.replace(/^irc.server.(\w+)/,"irc.$1"),v=e.local_variables.type,p=["channel","private"].indexOf(v)>=0;void 0!==e.notify&&(a=e.notify);var b=function(e){c.push(e),k(e)},y=function(e,t){$()&&(t.spokeAt=Date.now(),l[e].nicks.push(t))},w=function(e,t){e=l[e],void 0!==e&&(e.nicks=_.filter(e.nicks,function(e){return e.name!==t.name}))},C=function(e,t){e=l[e];for(var n in e.nicks)if(e.nicks[n].name===t.name){e.nicks[n]=t;break}},k=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(l,function(e){_.each(e.nicks,function(e){e.name===n&&(e.spokeAt=Date.now())})})}},S=function(){var e=[];return _.each(l,function(t){_.each(t.nicks,function(t){e.push(t)})}),e.sort(function(e,t){return e.spokeAt<t.spokeAt}),e},x=function(e){var t="";return f!==u.length&&(t=u.pop()),u.push(e),f=u.length,t},N=function(e){if(f>=u.length&&u.push(e),0>=f||f>=u.length)return e;f--;var t=u[f];return t},B=function(e){return f===u.length?(void 0!==e&&""!==e&&(u.push(e),f++),""):0>f||f>u.length?e:(f++,u.length>0&&f==u.length-1?u.pop():u[f])},A=function(){for(var e in l)if("root"!==e)return!1;return!0},$=function(){return l.hasOwnProperty("root")},I=function(){for(;c.length>0;)c.pop();s=0};return{id:o,fullName:t,shortName:n,number:r,title:i,lines:c,clear:I,requestedLines:s,addLine:b,lastSeen:g,unread:h,notification:d,notify:a,nicklist:l,addNick:y,delNick:w,updateNick:C,getNicklistByTime:S,serverSortKey:m,indent:p,history:u,addToHistory:x,getHistoryUp:N,getHistoryDown:B,isNicklistEmpty:A,nicklistRequested:$}},this.BufferLine=function(e){function n(e){var t={option:"cof-",weechat:"cwf-",ext:"cef-"},n={option:"cob-",weechat:"cwb-",ext:"ceb-"};e.forEach(function(e){e.classes=[];var i=t[e.fgColor.type];e.classes.push(i+e.fgColor.name),i=n[e.bgColor.type],e.classes.push(i+e.bgColor.name),null!==e.attrs.name&&e.classes.push("coa-"+e.attrs.name);for(var r in e.attrs.override)val=e.attrs.override[r],e.classes.push(val?"a-"+r:"a-no-"+r)})}var i=e.buffer,r=e.date,o=t("date")(r,"HH:mm"),a=weeChat.Protocol.rawText2Rich(e.prefix);n(a);var c=e.tags_array,s=e.displayed,l=e.highlight,u=weeChat.Protocol.rawText2Rich(e.message);n(u),l&&a.forEach(function(e){e.classes.push("highlight")});for(var f="",d=0;d<u.length;++d)f+=u[d].text;return{prefix:a,content:u,date:r,shortTime:o,buffer:i,tags:c,highlight:l,displayed:s,text:f}},this.Nick=function(e){var t=e.prefix,n=e.visible,r=e.name,o=i(e);return{prefix:t,visible:n,name:r,prefixClasses:o.prefix,nameClasses:o.name}},this.NickGroup=function(e){var t=e.name,n=e.visible,i=[];return{name:t,visible:n,nicks:i}};var r=null,o=null;this.model={buffers:{}},this.addBuffer=function(e){this.model.buffers[e.id]=e},this.getActiveBuffer=function(){return r},this.getPreviousBuffer=function(){return o},this.setActiveBuffer=function(t,n){if(void 0===n&&(n="id"),o=this.getActiveBuffer(),r="id"===n?this.model.buffers[t]:_.find(this.model.buffers,function(e){return e[n]===t?e:void 0}),void 0===r)return r=o,!1;o&&(o.active=!1,o.lastSeen=o.lines.length-1);var i=r.unread+r.notification;return r.active=!0,r.unread=0,r.notification=0,e.$emit("activeBufferChanged",i),e.$emit("notificationChanged"),!0},this.getBuffers=function(){return this.model.buffers},this.reinitialize=function(){this.model.buffers={}},this.getBuffer=function(e){return this.model.buffers[e]},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]}}}]),plugins=angular.module("plugins",[]);var Plugin=function(e){return{contentForMessage:e,exclusive:!1,name:"additional content"}};plugins.service("plugins",["userPlugins","$sce",function(e,t){var n=new RegExp("nsfw","i"),i=function(){var e=[],i=function(t){for(var n=0;n<t.length;n++)e.push(t[n])},r=function(i){i.metadata=[];for(var r=function(e,n,r){r&&(n+=" "+r),e instanceof Function||(e=t.trustAsHtml(e)),i.metadata.push({content:e,nsfw:a,name:n})},o=0;o<e.length;o++){var a=!1;i.text.match(n)&&(a=!0);var c=e[o].contentForMessage(i.text);if(c&&c!==[]){if(c instanceof Array)for(var s=c.length-1;s>=0;s--){var l=1==c.length?void 0:s+1;r(c[s],e[o].name,l)}else r(c,e[o].name);if(e[o].exclusive)break}}return i};return{registerPlugins:i,contentForMessage:r}};this.PluginManager=new i,this.PluginManager.registerPlugins(e.plugins)}]),plugins.factory("userPlugins",function(){var e=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+(e.indexOf("?")>=0?"&":"?")+"callback="+n,document.body.appendChild(i)},t=RegExp(/(?:ftp|https?):\/\/\S*[^\s.;,(){}<>]/g),n=function(e){return function(n){for(var i=n.match(t),r=[],o=0;i&&o<i.length;o++){var a=e(i[o]);a&&r.push(a)}return r}},i=new Plugin(function(e){content=[];var t=function(e){for(var t=0;e&&t<e.length;t++){var n=e[t].substr(e[t].length-22,e[t].length);content.push('<iframe src="//embed.spotify.com/?uri=spotify:track:'+n+'" width="300" height="80" frameborder="0" allowtransparency="true"></iframe>')}};return t(e.match(/spotify:track:([a-zA-Z-0-9]{22})/g)),t(e.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g)),content});i.name="Spotify track";var r=new Plugin(function(e){for(var t=/(?:https?:\/\/)?(?:www\.)?(?:youtube.com|youtu.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9-]+)/gm,n=t.exec(e),i=[];null!==n;){var r=n[1],o="https://www.youtube.com/embed/"+r+"?html5=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0";i.push('<iframe width="560" height="315" src="'+o+'" frameborder="0" allowfullscreen frameborder="0"></iframe>'),n=t.exec(e)}return i});r.name="YouTube video";var o=new Plugin(function(e){var t=/dailymotion.com\/.*video\/([^_?# ]+)/,n=/dailymotion.com\/.*#video=([^_& ]+)/,i=/dai.ly\/([^_?# ]+)/,r=e.match(t)||e.match(n)||e.match(i);if(r){var o=r[1],a="https://www.dailymotion.com/embed/video/"+o+"?html&controls=html&startscreen=html&info=0&logo=0&related=0";return'<iframe frameborder="0" width="480" height="270" src="'+a+'"></iframe>'}return null});o.name="Dailymotion video";var a=new Plugin(function(e){var t=/allocine.fr\/videokast\/video-(\d+)/,n=/allocine.fr\/.*cmedia=(\d+)/,i=e.match(t)||e.match(n);if(i){var r=i[1],o="http://www.allocine.fr/_video/iblogvision.aspx?cmedia="+r;return'<iframe frameborder="0" width="480" height="270" src="'+o+'"></iframe>'}return null});a.name="AlloCine video";var c=new Plugin(n(function(e){{var t=!1;e.split(/[?&]/).forEach(function(e){e.match(/\.(png|gif|jpg|jpeg)$/i)&&(t=!0)})}return t?(-1!=e.indexOf("^https?://fukung.net/v/")?e=e.replace(/.*\//,"http://media.fukung.net/imgs/"):e.match(/^http:\/\/(i\.)?imgur\.com\//i)?e=e.replace(/http:/,""):e.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\/[^?]+$/i)&&(e+="?dl=1"),'<a target="_blank" href="'+e+'"><img class="embed" src="'+e+'"></a>'):void 0}));c.name="image";var s=new Plugin(n(function(e){return e.match(/^https?:\/\/soundcloud.com\//)?'<iframe width="100%" height="120" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url='+e+'&amp;color=ff6600&amp;auto_play=false&amp;show_artwork=true"></iframe>':e.match(/^https?:\/\/([a-z]+\.)?mixcloud.com\//)?'<iframe width="480" height="60" src="//www.mixcloud.com/widget/iframe/?feed='+e+'&mini=1&stylecolor=&hide_artwork=&embed_type=widget_standard&hide_tracklist=1&hide_cover=" frameborder="0"></iframe>':void 0}));s.name="cloud music";var l=new Plugin(n(function(e){return e.match(/^https?:\/\/maps\.google\./i)||e.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i)?'<iframe width="450" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+e+'&output=embed"></iframe>':void 0}));l.name="Google Map";var u=new Plugin(function(e){var t=/^https?:\/\/(www\.)?asciinema.org\/a\/(\d+)/,n=e.match(t);if(n){var i=n[3];return"<script type='text/javascript' src='https://asciinema.org/a/"+i+".js' id='asciicast-"+i+"' async></script>"}});u.name="ascii cast";var f=new Plugin(n(function(e){var t=/^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/,n=e.match(t);if(n){var i=n[1],r=n[2],o=n[n.length-1].slice(0,-1);return e="http://www.yr.no/"+i+"/"+r+"avansert_meteogram.png","<img src='"+e+"' alt='Meteogram for "+o+"' />"}}));f.name="meteogram";var d=new Plugin(n(function(t){var n=/^https:\/\/gist\.github.com\/[^.?]+/i,i=t.match(n);return i?(t=i[0]+".json",function(){var n=document.querySelector(".embed_"+this.$$hashKey);e(t,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>"})}):void 0}));d.name="Gist";var h=new Plugin(n(function(t){var n=/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i,i=t.match(n);return i?(t="https://api.twitter.com/1/statuses/oembed.json?id="+i[2],function(){var n=document.querySelector(".embed_"+this.$$hashKey);e(t,function(e){var t=e.html.indexOf("<script "),i=e.html.substr(0,t);i=i.replace('<blockquote class="twitter-tweet">','<blockquote class="twitter-tweet" data-dnt="true">'),n.innerHTML=i;var r=document.createElement("script");r.src="//platform.twitter.com/widgets.js",n.appendChild(r)})}):void 0}));return h.name="Tweet",{plugins:[r,o,a,c,i,s,l,u,f,d,h]}});
//# sourceMappingURL=min.map