(https?:\/\/clips.twitch.tv\/([a-z]+)).*')}}}var c={"<":"<",">":">",'"':""","'":"'"};return n.map(function(e){return c[e]?c[e]:e}).join("")}(e.message,e.emotes||{});var s=function(e){var t=0;return{message:e.split(" ").map(function(e){var n=e.trim().toLowerCase();return te[n]?(t+=1,te[n]):e}).join(" "),count:t}}(e.message);e.message=s.message,r=r.replace(/[A-Z][a-z]+[A-Z][a-z]+/g,function(){return s.count+=1,""}).replace(/(?:[\xA9\xAE\u2122\u23E9-\u23EF\u23F3\u23F8-\u23FA\u24C2\u25B6\u2600-\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDE51\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFF]|\uD83E[\uDD00-\uDDFF])/g,function(){return s.count+=1,""}).trim().replace(/\s+/g," ").replace(/[^a-z .,:]/gi,"");var a,l,u,f,p;if(Object.keys(w).forEach(function(t){if(!(n>5)||w[t].critical){var a=w[t].check(r,e.user,n,e.emotes,e,s.count,e.message);0,a>0?o.push(t):a<0&&i.push(t),n+=a}}),e.message=(a=e.message,l=a,u=/([^"]|^)(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,f=/(^|[^\/])(www\.[\S]+(\b|$))/gim,p=/(youtube.com|youtu.be)\/[^ ]{4,}( |$)/gi,a.match(u)?l=a.replace(u,' $2'):a.match(f)?l=l.replace(f,'$1 $2'):a.match(p)&&(l=l.replace(p,function(e){return''+e+""})),l),re[e.user.toLowerCase()]&&(e.friend=!0),e.message.match(W)&&(e.highlighted=!0),n<5?(e.good=!0,e.reasons=i):(e.good=!1,e.reasons=o),e.user.match(/(Donator|Subscriber)/i)&&(e.good=!0),!e.previewVideos)return t(e);!function(e,t){var n=/>(http.*)?(youtube.*v=(.{11})|youtu.be\/(.{11})).*"+r.title+' <'}),t(e)};ne[o]?i(ne[o]):c({url:"https://noembed.com/embed?url=http%3A//www.youtu.be/"+o,dataType:"json",success:i,error:function(){t(e)}})}else t(e)}(e.message,function(n){if(e.message=n,e.message.match(Q)){var r=e.message.match(Q)[2];c({url:"https://clips.twitch.tv/api/v1/clips/"+r,dataType:"json",success:function(n){e.message=e.message.replace(Q,function(e,t){return">Twitch Clip: "+n.title+" ("+n.views+" views, "+d.formatTimeAgo(new Date(n.created_at))+')<'}),t(e)},error:function(){t(e)}})}else t(e)})}var ie=function(o){function i(t){M(this,i);var n=B(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));n.state={banPanel:null,settings:n.getSettings(),paused:!1,ignoreChit:!1,showSettings:!1,subscriberOnly:!1,connected:!1,showScroll:{chatGood:!1,chatBad:!1},messages:{good:[],bad:[]}},n.youtubeChatInstance=null,n.getSettings(),W=new RegExp("@?"+ee(n.props.channel)+"(,|:| |$|')","i"),n.maxMessages=100,n.handleMessage=n.handleMessage.bind(n),n.resize=n.resize.bind(n),n.saveSettings=n.saveSettings.bind(n),n.toggleSetting=n.toggleSetting.bind(n),n.updateSetting=n.updateSetting.bind(n),n.toggleSubOnly=n.toggleSubOnly.bind(n),n.handleResize=n.handleResize.bind(n),n.scrollToBottom=n.scrollToBottom.bind(n),n.updateBanWords=n.updateBanWords.bind(n),n.updateKillWords=n.updateKillWords.bind(n),n.updateYoutubeId=n.updateYoutubeId.bind(n),n.setupStreamlabs=n.setupStreamlabs.bind(n),n.updateStreamlabsApi=n.updateStreamlabsApi.bind(n),n.streamlabEvent=n.streamlabEvent.bind(n),n.pause=n.pause.bind(n),n.unpause=n.unpause.bind(n),n.banUser=n.banUser.bind(n),n.banWord=n.banWord.bind(n),n.showBanPanel=n.showBanPanel.bind(n),n.badges=e.badges||{},n.chatHeight={},n.streamlabsClient=null,n.setupStreamlabs(),n.totals={good:0,bad:1},n.manualScroll={chatGood:!1,chatBad:!1};var r=n.twitch=n.twitch=new tmi.client({options:{debug:!1,clientId:"jzkbprff40iqj646a697cyrvl0zt2m6"},connection:{secure:!0,reconnect:!0},channels:["#"+n.props.channel]});r.connect(),n.isConnected=!1,r.on("connected",function(e){n.setState(function(e){return{connected:!0}}),r.join("")}),r.on("disconnected",function(e){n.setState(function(e){return{connected:!1}}),r.join("")}),e.location.hash.match(/silent/)||r.on("message",n.handleMessage),r.on("subscription",function(e,t,r){n.streamlabsClient||n.handleMessage(e,{"display-name":"Subscriber",emotes:{},id:t+" subscribed"+Date.now(),user:"Subscriber",subscriber:!0},t+" just subscribed "+(r.prime?" with Twitch Prime":""))});var o=!1;if(r.on("join",function(e,t){o||(o=!0,n.handleMessage(e,{"display-name":"Info",emotes:{},id:e+" joined"+Date.now(),user:"Info"},"Joined "+e))}),r.on("resub",function(e,t,r){n.streamlabsClient||n.handleMessage(e,{"display-name":"Subscriber",emotes:{},id:t+" resubscribed",user:"Subscriber",subscriber:!0},t+" subscribed for "+r+" months in a row!")}),c({url:"https://cbenni.com/api/badges/"+n.props.channel,dataType:"json",success:function(t){e.badges=n.badges=t.badge_sets}}),c({url:"https://api.twitch.tv/kraken/users?login="+n.props.channel,dataType:"json",success:function(e){var t=0;try{t=e.users[0]._id}catch(e){}c({url:"https://api.twitch.tv/kraken/users/"+t+"/follows/channels?offset=0&limit=100",dataType:"json",success:function(e){e.follows.forEach(function(e){re[e.channel.name.toLowerCase()]=!0})}})}}),n.props.channel.toLowerCase()===q){var s,a=n;!function e(){(s=new WebSocket("wss://www."+q+".gg/ws")).onmessage=function(e){var t=e.data;if("MSG"===t.substr(0,3)){var n=JSON.parse(t.replace(/^MSG /,"")),r=-1!==n.features.indexOf("subscriber");a.handleMessage(q,{"display-name":n.nick,emotes:{},id:"d-"+n.nick+"-"+n.timestamp,subscriber:r,badges:{subscriber:r?"0":void 0},user:n.nick,color:"#59aeea"},n.data)}else if("BROADCAST"==t.substr(0,9)){var o=JSON.parse(t.replace(/^[^ ]+ /,""));a.handleMessage(null,{"display-name":"Donator",emotes:{},id:q+"-donate-"+Date.now(),user:"Donator",subscriber:!0},o.data)}else if("JOIN"==t.substr(0,4)){var i=JSON.parse(t.replace(/^[^ ]+ /,""));Z[i.nick.toLowerCase()]=!0}else if("QUIT"==t.substr(0,4)){var s=JSON.parse(t.replace(/^[^ ]+ /,""));delete Z[s.nick.toLowerCase()]}else if("NAMES"==t.substr(0,5)){JSON.parse(t.replace(/^[^ ]+ /,"")).users.forEach(function(e){Z[e.nick.toLowerCase()]=!0})}},s.onclose=function(t){a.handleMessage(q,{"display-name":"Info",emotes:{},id:q+" joined"+Date.now(),user:"Info"},"Disconnected from "+q+".gg chat"),setTimeout(function(){s.close(),e()},5e3)},s.onopen=function(e){a.handleMessage(q,{"display-name":"Info",emotes:{},id:q+" joined"+Date.now(),user:"Info"},"Joined "+q+".gg chat")},s.onerror=function(t){a.handleMessage(q,{"display-name":"Info",emotes:{},id:q+" joined"+Date.now(),user:"Info"},"Recieved error from "+q+".gg chat"),setTimeout(function(){s.close(),e()},5e3)}}(),["Dravewin","INFESTINY","FIDGETLOL","Hhhehhehe","GameOfThrows","WORTH","FeedNathan","Abathur","LUL","Heimerdonger","SoSad","DURRSTINY","SURPRISE","NoTears","OverRustle","DuckerZ","Kappa","Klappa","DappaKappa","BibleThump","AngelThump","FrankerZ","BasedGod","OhKrappa","SoDoge","WhoahDude","MotherFuckinGame","DaFeels","UWOTM8","CallCatz","CallChad","DatGeoff","Disgustiny","FerretLOL","Sippy","DestiSenpaii","Nappa","DAFUK","AYYYLMAO","DANKMEMES","MLADY","SOTRIGGERED","MASTERB8","NOTMYTEMPO","LIES","LeRuse","YEE","SWEATSTINY","PEPE","CheekerZ","SpookerZ","SLEEPSTINY","PICNIC","Memegasm","WEEWOO","KappaRoss","ASLAN","DJAslan","TRUMPED","BASEDWATM8","BERN","HmmStiny","PepoThink","FeelsAmazingMan","FeelsBadMan","FeelsGoodMan","OhMyDog","Wowee","haHAA","POTATO","NOBULLY","ChibiDesti","gachiGASM","SUESTINY","GODSTINY","REE","Blubstiny","monkaS","Depresstiny","Shekels","AUTISTINY","nathanD","nathanDank","nathanF","nathanNotears","nathanPepe","nathanRustle","nathanTowel","nathanWat","nathanThinking","nathanYee","nathanWeeb"].forEach(function(e){te[e.toLowerCase()]='
'+e+"
"})}var l=function(e){e.emotes.forEach(function(t){var n=e.urlTemplate.replace("{{id}}",t.id).replace("{{image}}","1x");te[t.code.toLowerCase()]=''})};return c({url:"https://api.betterttv.net/2/channels/"+n.props.channel,dataType:"json",success:l}),c({url:"https://api.betterttv.net/2/emotes",dataType:"json",success:l}),c({url:"https://api.frankerfacez.com/v1/room/"+n.props.channel,dataType:"json",success:function(e){e.sets&&Object.keys(e.sets).forEach(function(t){var n=e.sets[t].emoticons;n&&n.length&&n.forEach(function(e){var t=e.name,n=e.urls[1];te[t.toLowerCase()]=''})})}}),n}return F(i,o),U(i,[{key:"setupStreamlabs",value:function(){var e=this;if(this.state.settings.streamlabsApi&&!this.streamlabsClient){var t=this.state.settings.streamlabsApi;this.streamlabsClient=io("https://sockets.streamlabs.com?token="+t),this.streamlabsClient.on("event",this.streamlabEvent),this.streamlabsClient.on("connect",function(t){e.handleMessage("streamlabs",{"display-name":"Info",emotes:{},id:"streamlabs-connected"+Date.now(),user:"Info"},"Connected to StreamLabs")}),this.streamlabsClient.on("disconnect",function(t){e.handleMessage("streamlabs",{"display-name":"Info",emotes:{},id:"streamlabs-connected"+Date.now(),user:"Info"},'Lost connection to StreamLabs, make sure you have entered the correct "Socket API Token" which you can find in the "API settings -> API Tokens" section on the StreamLabs website.'),e.streamlabsClient.removeListener("event",e.streamlabEvent),e.streamlabsClient=null}),this.streamlabsClient.on("error",function(e){})}}},{key:"getSettings",value:function(){var e={};try{e=JSON.parse(n.settings)}catch(e){}return{size:e.size||30,fontSize:e.fontSize||100,subOnly:e.subOnly||!1,hideEmotes:e.hideEmotes||!1,hideBadges:e.hideBadges||!1,showVideoPreview:e.showVideoPreview||!1,darkTheme:null==e.darkTheme||e.darkTheme,hideSubscriptions:e.hideSubscriptions||!1,forceTopBottomLayout:e.forceTopBottomLayout||!1,previewVideos:null==e.previewVideos||e.previewVideos,hideReason:null==e.hideReason||e.hideReason,bannedWords:e.bannedWords||"sellout",killWords:e.killWords||"nigger faggot kys whore",streamlabsApi:e.streamlabsApi||"",youtubeId:e.youtubeId||""}}},{key:"handleResize",value:function(){this.scrollToBottom(),this.forceUpdate(),this.maxHeightVideo=t.min(555,.4*e.innerHeight),this.windowAspectRatio=e.innerWidth/e.innerHeight}},{key:"scrollToBottom",value:function(){var e=this;this.manualScroll.chatGood||(this.refs.chatGood.scrollTop=1e5),this.manualScroll.chatBad||(this.refs.chatBad.scrollTop=1e5),this.setState(function(t){return t.showScroll=e.manualScroll,{showScroll:t.showScroll}})}},{key:"componentDidMount",value:function(){var t=this,r=this;k("Dashboard").componentDidMount(this),e.document.title=this.props.channel+" - ChitChat",setTimeout(function(){t.updateBanWords(),t.updateKillWords(),t.scrollToBottom(),t.updateYoutubeId()},100),r.lastSettingsUpdate=n.lastSettingsUpdate,r.settingsReload=setInterval(function(){n.lastSettingsUpdate&&r.lastSettingsUpdate!==n.lastSettingsUpdate&&(r.lastSettingsUpdate=n.lastSettingsUpdate,t.setState(function(e){return{settings:t.getSettings()}}))},100),["chatGood","chatBad"].forEach(function(e){var n=function(n){var r=t.refs[e].clientHeight;t.chatHeight[e]-(t.refs[e].scrollTop+r)<1?t.setState(function(n){return t.manualScroll[e]=!1,n.showScroll[e]=!1,{showScroll:n.showScroll}}):t.setState(function(n){return t.manualScroll[e]=!0,n.showScroll[e]=!0,{showScroll:n.showScroll}})};t.refs[e].addEventListener("mousewheel",n),t.refs[e].addEventListener("DOMMouseScroll",n),t.refs[e].addEventListener("touchmove",n)}),e.addEventListener("resize",this.handleResize),e.addEventListener("keydown",this.pause),e.addEventListener("keyup",this.unpause)}},{key:"pause",value:function(e){"Shift"!==e.key||this.state.paused||this.setState(function(e){return{paused:!0}})}},{key:"unpause",value:function(e){"Shift"===e.key&&this.setState(function(e){return{paused:!1}})}},{key:"banUser",value:function(e){this.setState(function(e){return{banPanel:null}})}},{key:"banWord",value:function(e){var t=this;this.setState(function(e){return{banPanel:null}},function(){t.updateKillWords(null,e)})}},{key:"showBanPanel",value:function(e){}},{key:"componentWillUnmount",value:function(){k("Dashboard").componentWillUnmount(this),this.twitch.removeListener("message",this.handleMessage),this.twitch.disconnect(),this.twitch.ws.close(),this.youtubeChatInstance&&this.youtubeChatInstance.destroy(),clearTimeout(self.settingsReload),this.streamlabsClient&&this.streamlabsClient.removeListener("event",this.streamlabEvent),e.removeEventListener("resize",this.handleResize),e.removeEventListener("keydown",this.pause),e.removeEventListener("keyup",this.unpause)}},{key:"streamlabEvent",value:function(e){var t=this;Array.isArray(e)||(e=[e]),e.forEach(function(e){var n=e.message[0]||{};switch(e.type){case"subscription":t.handleMessage(null,{"display-name":"Subscriber",emotes:{},id:"streamlabs-sub-"+Date.now(),user:"Subscriber",subscriber:!0},n.name+" has subscribed for "+n.months+"months: "+n.message);break;case"donation":t.handleMessage(null,{"display-name":"Donator",emotes:{},id:"streamlabs-donate-"+Date.now(),user:"Donator",subscriber:!0},n.from+" donated "+n.formatted_amount+": "+n.message);break;case"bits":t.handleMessage(null,{"display-name":"Donator",emotes:{},id:"streamlabs-donate-"+Date.now(),user:"Donator",subscriber:!0},n.name+" donated "+n.amount+"bits: "+n.message)}})}},{key:"saveSettings",value:function(){n.settings=JSON.stringify(this.state.settings),n.lastSettingsUpdate=Date.now(),this.forceUpdate(),this.scrollToBottom(),this.setupStreamlabs()}},{key:"handleMessage",value:function(e,t,n){var r=this;if(!this.state.paused&&!V.test(n)){var o=t["display-name"]||t.username;Z[o.toLowerCase()]=!0;var i=this.state.settings;oe({user:o,channel:e,message:n,emotes:t.emotes,debug:!1,data:t,previewVideos:i.previewVideos},function(e){if(e.raw=n,e.good){if(r.totals.good+=1,r.state.settings.subOnly&&!t.subscriber)return;r.setState(function(t){return r.state.messages.good.push(e),r.state.messages.good.length>r.maxMessages&&(r.state.messages.good=r.state.messages.good.slice(r.state.messages.good.length-r.maxMessages)),{messages:r.state.messages}})}else if(!r.state.ignoreChit){if(r.totals.bad+=1,r.state.settings.subOnly&&!t.subscriber)return;r.setState(function(t){return r.state.messages.bad.push(e),r.state.messages.bad.length>r.maxMessages&&(r.state.messages.bad=r.state.messages.bad.slice(r.state.messages.bad.length-r.maxMessages)),{messages:r.state.messages}})}})}}},{key:"toggleSubOnly",value:function(){var e=this;this.setState(function(t){return e.state.settings.subOnly=!e.state.settings.subOnly,e.state.settings.subOnly&&(e.state.messages.good=e.state.messages.good.filter(function(e){return e.data.subscriber}),e.state.messages.bad=e.state.messages.bad.filter(function(e){return e.data.subscriber})),{size:e.state.settings,messages:e.state.messages}},this.saveSettings)}},{key:"toggleSetting",value:function(e){var t=this;return function(){t.setState(function(n){return t.state.settings[e]=!t.state.settings[e],{settings:t.state.settings}},t.saveSettings)}}},{key:"updateSetting",value:function(e){var t=this;return function(n){var r=n.target.value;t.setState(function(n){return t.state.settings[e]=r,{settings:t.state.settings}},t.saveSettings)}}},{key:"resize",value:function(n){var o=this;/iPad|iPhone|iPod/.test(navigator.userAgent)&&!e.MSStream||n.preventDefault();var i=function(n){n.preventDefault();var r=void 0;r="touchmove"===n.type?n.touches[0].clientY:n.clientY;var i=0;o.refs.video&&(i=o.refs.video.clientHeight),r-=i,o.setState(function(n){var s=t.max(32,r-20)/(e.innerHeight-i)*100;return o.state.settings.size=s,{size:o.state.settings}},o.saveSettings)},s=function e(t){"mouseout"===t.type&&"HTML"!==t.toElement.nodeName||(r.removeEventListener("mousemove",i),r.removeEventListener("mouseup",e),r.removeEventListener("mouseout",e),r.removeEventListener("touchmove",i),r.removeEventListener("touchend",e))};r.addEventListener("mousemove",i),r.addEventListener("mouseup",s),r.addEventListener("mouseout",s),r.addEventListener("touchmove",i),r.addEventListener("touchend",s)}},{key:"componentDidUpdate",value:function(e){var t=this;this.chatHeight.chatGood||this.handleResize(),["chatGood","chatBad"].forEach(function(e){t.chatHeight[e]=t.refs[e+"Inner"].clientHeight}),["chatGood","chatBad"].forEach(function(e){var n=t.refs[e].clientHeight;t.chatHeight[e],t.refs[e].scrollTop;"chatBad"===e&&!t.state.ignoreChit&&t.refs.badContainer.clientHeight<50?t.setState(function(e){return t.state.messages.bad=[],{messages:t.state.messages,ignoreChit:!0}}):t.state.ignoreChit&&"chatBad"===e&&t.refs.badContainer.clientHeight>50&&t.setState(function(e){return{ignoreChit:!1}}),t.state.showScroll[e]||(t.manualScroll[e]=!0,t.refs[e].scrollTop=1e5,t.manualScroll[e]=!1)})}},{key:"updateBanWords",value:function(e){var t=this,n=e?e.target.value:this.state.settings.bannedWords;this.setState(function(e){return t.state.settings.bannedWords=n,{settings:t.state.settings}},function(){t.saveSettings();var e=n.split(" ").map(ee).join("|")||"x0x0x0x0x0x0x0x0x0x00x0x0x0x0x";H=new RegExp("( |^)("+e+")( |\\.|,|$)","i")})}},{key:"updateKillWords",value:function(t,n){var r=this;n&&(this.state.settings.killWords+=" "+n);var o=t?t.target.value:this.state.settings.killWords;this.setState(function(e){return r.state.settings.killWords=o,{settings:r.state.settings}},function(){r.saveSettings();var t=o.split(" ").map(ee).join("|")||"x0x0x0x0x0x0x0x0x0x00x0x0x0x0x";V=new RegExp("( |^)("+t+")( |\\.|,|$)","i"),e.globalFlush=!0,r.setState(function(e){return r.state.messages.good=r.state.messages.good.filter(function(e){return!V.test(e.raw)}),r.state.messages.bad=r.state.messages.bad.filter(function(e){return!V.test(e.raw)}),{messages:r.state.messages}},function(){e.globalFlush=!1})})}},{key:"updateYoutubeId",value:function(e){var t=this,n=this,r=e?e.target.value:this.state.settings.youtubeId;this.setState(function(e){return t.state.settings.youtubeId=r,{settings:t.state.settings}},function(){t.saveSettings(),n.youtubeChatInstance&&n.youtubeChatInstance.destroy(),n.youtubeChatInstance=new class extends EventEmitter{constructor(e,t){super(),this.id=e,this.key=t,this.nextPageToken="",this.getLive(),this.interval=null,this.dead=!1,this.fetching=!1}destroy(){this.dead=!0,clearInterval(this.interval)}getLive(){const e=24===this.id.length?"id":"forUsername",t=`https://www.googleapis.com/youtube/v3/channels?part=contentDetails&${e}=${this.id}&key=${this.key}`;this.request(t,e=>{const t="https://www.googleapis.com/youtube/v3/search?eventType=live&part=id"+`&channelId=${e.items[0].id}`+"&type=video"+`&key=${this.key}`;this.request(t,e=>{e.items[0]?(this.liveId=e.items[0].id.videoId,this.getChatId()):this.emit("error",`Can not find a live YouTube session for ${this.id} (reload page to retry).`)})})}getChatId(){if(!this.liveId)return this.emit("error","YouTube live id is invalid.");const e="https://www.googleapis.com/youtube/v3/videos?part=liveStreamingDetails"+`&id=${this.liveId}`+`&key=${this.key}`;this.request(e,e=>{e.items.length?(this.chatId=e.items[0].liveStreamingDetails.activeLiveChatId,this.emit("ready")):this.emit("error",`Can not find chat id for ${this.liveId}.`)})}getChat(e){if(!this.chatId)return this.emit("error","Chat id is invalid.");const t="https://www.googleapis.com/youtube/v3/liveChat/messages"+`?liveChatId=${this.chatId}`+"&part=id,snippet,authorDetails&maxResults=2000"+(this.nextPageToken?`&pageToken=${this.nextPageToken}`:"")+`&key=${this.key}`;this.request(t,e)}request(e,t){this.dead||c({url:e,method:"GET",json:!0,success:e=>{if(!this.dead)try{t(JSON.parse(e))}catch(e){}},error:e=>{t()}})}listen(e){let t=!0;const n=()=>{this.fetching||(this.fetching=!0,this.getChat(e=>{if(this.fetching=!1,!e)return;this.nextPageToken=e.nextPageToken;const n=e.items||[];if(n.length<1)return;const r=new Date(n[0].snippet.publishedAt).getTime();n.forEach(e=>{const n=new Date(e.snippet.publishedAt).getTime()-r;t?this.emit("chat",e):setTimeout(()=>{this.emit("chat",e)},n)}),t=!1}))};n(),this.interval=setInterval(n,e)}stop(){clearInterval(this.interval)}}(r,"AIzaSyArRY2Imuaj5iiLko-vjsm_SFoMNrb_tfk"),n.youtubeChatInstance.on("ready",function(){n.handleMessage(q,{"display-name":"Info",emotes:{},id:r+" joined"+Date.now(),user:"Info"},"Joined "+r+" YouTube chat"),n.youtubeChatInstance.listen(5e3)}),n.youtubeChatInstance.on("error",function(e){n.handleMessage(q,{"display-name":"Info",emotes:{},id:e+Date.now(),user:"Info",error:!0},e)}),n.youtubeChatInstance.on("chat",function(e){var t=e.authorDetails.displayName,r=e.snippet.displayMessage;n.handleMessage(q,{"display-name":t,emotes:{},id:e.etag,subscriber:!1,youtube:!0,badges:{subscriber:void 0},user:t,color:"#59aeea"},r)}),n.youtubeChatInstance.on("error",function(e){})})}},{key:"updateStreamlabsApi",value:function(e){var t=this,n=e?e.target.value:this.state.settings.streamlabsApi;this.setState(function(e){return t.state.settings.streamlabsApi=n,{settings:t.state.settings}},function(){t.saveSettings()})}},{key:"render",value:function(){var e=this,t=this.state.settings,n={Dashboard:!0};n.dark=this.state.settings.darkTheme;var r=[];t.hideEmotes&&r.push(".emoticon, .chat-emote {display: none !important;}"),t.hideBadges&&r.push(".badge {display: none !important;}"),t.hideSubscriptions&&r.push(".Message.newSub {display: none;}"),t.hideReason&&r.push(".Message .reasons {display: none !important;}");var o=0;return this.refs.video&&(o=this.refs.video.clientHeight+"px"),"100"!==t.fontSize&&r.push(".Message .badge, .Message .emoticon {zoom: "+(t.fontSize/100).toFixed(2)+";}"),this.windowAspectRatio>.8&&!t.forceTopBottomLayout&&(n.wideChat=!0),n.paused=this.state.paused,L("div",{className:ue(n),onClick:this.advance,style:{top:o}},this.state.settings.showVideoPreview?L("div",{className:"video",ref:"video",style:{maxHeight:this.maxHeightVideo}},L("div",{className:"aspect"}),L("iframe",{src:"https://player.twitch.tv/?channel="+this.props.channel+"&muted=true",frameBorder:"0",scrolling:"no"})):null,L("style",null,r.join("\n")),this.state.connected?null:L("div",{className:"connectLoading"},L("div",{class:"cssload-box-loading"})),L("div",{className:"chatContainer bad",ref:"badContainer",style:{fontSize:t.fontSize+"%",height:t.size+"%"}},L("div",{className:"title"},L("ul",{className:"settings"},L("li",{className:"setting"},L("button",{onClick:function(){e.setState({showSettings:!0})}},"Settings"))),L("span",{className:"paneTitle"},"Chit ",this.state.ignoreChit?"(Off) ":"",L("small",null,(this.totals.bad/(this.totals.good+this.totals.bad)*100).toFixed(1),"%"))),this.state.showScroll.chatBad?L("div",{className:"scrollHelp",onClick:function(){e.manualScroll.chatBad=!1,e.scrollToBottom()}},"Jump to new messages"):null,L("div",{className:"innerScroll",ref:"chatBad"},L("div",{className:"inner",ref:"chatBadInner"},this.state.messages.bad.map(function(t){return L(ae,{showBanPanel:e.showBanPanel,badges:e.badges,key:t.data.id,data:t})})))),L("div",{className:"chatContainer good",style:{fontSize:t.fontSize+"%",height:100-t.size+"%"}},L("div",{className:"title",onMouseDown:this.resize,onTouchStart:this.resize},L("div",{className:"resize"},L("div",null),L("div",null),L("div",null),L("div",null),L("div",null)),L("span",{className:"paneTitle"},"Chat",L("small",null," ",(this.totals.good/(this.totals.good+this.totals.bad)*100).toFixed(1),"%"))),this.state.showScroll.chatGood?L("div",{className:"scrollHelp",onClick:function(){e.manualScroll.chatGood=!1,e.scrollToBottom()}},"Jump to new messages"):null,L("div",{className:"innerScroll",ref:"chatGood"},L("div",{className:"inner",ref:"chatGoodInner"},this.state.messages.good.map(function(t){return L(ae,{showBanPanel:e.showBanPanel,badges:e.badges,key:t.data.id,data:t})})))),this.state.showSettings?L("div",{className:"appSettings"},L("div",{className:"title"},L("button",{className:"exit",onClick:function(){e.setState({showSettings:!1})}},"Close settings"),L("span",{className:"paneTitle"},"Settings")),L("ul",{className:"settings"},L("li",{className:"settings "+(t.subOnly?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Star.svg"}),L("span",{className:"label"},"Only sub messages"),L("input",{type:"checkbox",checked:t.subOnly,onChange:this.toggleSubOnly}),L("span",null))),L("li",{className:"settings "+(t.hideEmotes?"unChecked":"checked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Smiley.svg"}),L("span",{className:"label"},"Show emotes"),L("input",{type:"checkbox",checked:!t.hideEmotes,onChange:this.toggleSetting("hideEmotes")}),L("span",null))),L("li",{className:"settings "+(t.hideBadges?"unChecked":"checked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Badge.svg"}),L("span",{className:"label"},"Show badges"),L("input",{type:"checkbox",checked:!t.hideBadges,onChange:this.toggleSetting("hideBadges")}),L("span",null))),L("li",{className:"settings "+(t.showVideoPreview?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Video.svg"}),L("span",{className:"label"},"Show video preview"),L("input",{type:"checkbox",checked:t.showVideoPreview,onChange:this.toggleSetting("showVideoPreview")}),L("span",null))),L("li",{className:"settings "+(t.darkTheme?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Theme.svg"}),L("span",{className:"label"},"Dark theme"),L("input",{type:"checkbox",checked:t.darkTheme,onChange:this.toggleSetting("darkTheme")}),L("span",null))),L("li",{className:"settings "+(t.hideSubscriptions?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Announcement.svg"}),L("span",{className:"label"},"Hide sub messages"),L("input",{type:"checkbox",checked:t.hideSubscriptions,onChange:this.toggleSetting("hideSubscriptions")}),L("span",null))),L("li",{className:"settings "+(t.hideReason?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/NoSpam.svg"}),L("span",{className:"label"},"Hide spam reason"),L("input",{type:"checkbox",checked:t.hideReason,onChange:this.toggleSetting("hideReason")}),L("span",null))),L("li",{className:"settings "+(t.forceTopBottomLayout?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Layout.svg"}),L("span",{className:"label"},"Force top/bottom layout"),L("input",{type:"checkbox",checked:t.forceTopBottomLayout,onChange:this.toggleSetting("forceTopBottomLayout")}),L("span",null))),L("li",{className:"settings "+(t.previewVideos?"checked":"unChecked")},L("label",null,L(ce,{class:"icon",src:"/img/icons/Video.svg"}),L("span",{className:"label"},"Preview clips/YouTube"),L("input",{type:"checkbox",checked:t.previewVideos,onChange:this.toggleSetting("previewVideos")}),L("span",null))),L("li",{className:"setting"},L("label",null,L(ce,{class:"icon",src:"/img/icons/FontSize.svg"}),L("span",{className:"label"},"Font size: ",t.fontSize,"%"),L("input",{type:"range",value:t.fontSize,min:"50",max:"200",step:"1",onChange:this.updateSetting("fontSize")}))),L("li",{className:"setting"},L("label",null,L(ce,{class:"icon",src:"/img/icons/Youtube.svg"}),L("span",{className:"label"},"Youtube channel id"),L("input",{type:"text",value:t.youtubeId,onChange:this.updateYoutubeId,placeholder:"24 character channel id or channel name"}))),L("li",{className:"setting"},L("label",null,L("span",{className:"label wide"},"Banned words (totally removes any messages containing these words)"),L("textarea",{type:"text",className:"blurred",value:t.killWords,onChange:this.updateKillWords}))),L("li",{className:"setting"},L("label",null,L("span",{className:"label wide"},"Tiresome words (flags them as tiresome)"),L("textarea",{type:"text",value:t.bannedWords,onChange:this.updateBanWords}))),L("li",{className:"setting"},L("label",null,L("span",{className:"label wide"},L("strong",null,"Donation and sub messages"),L("br",null),"Streamlabs Socket API Token ",L("br",null),'(Access this in the "API Settings" section on streamlabs.com, it is a 208 character long text)'),L("input",{type:"text",value:t.streamlabsApi,onChange:this.updateStreamlabsApi}))))):null,this.state.banPanel?L("div",{className:"banPanel"},L("div",{className:"user",onClick:function(){e.banUser(e.state.banPanel.user)}},"Hide username: ",this.state.banPanel.user),L("div",{className:"banWords"},"Ban words:"),L("ul",{className:"words"},Array.from(new Set(this.state.banPanel.raw.split(" "))).map(function(t){return L("li",{onClick:function(){e.banWord(t)}},t)}))):null)}}]),i}(React.Component);U=function(){function e(e,t){for(var n=0;n