'use strict';!function($,_,canCreateDiscussions){ips.controller.register("bim.chatbox.free",{lmn1:false,lmn2:false,lmn3:false,lmn4:false,lmn5:false,lmn6:true,lmn7:0,lmn8:/\bhttps?:\/\/\S+/gi,lmn9:/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;\(\)]*[-A-Z0-9+&@#\/%=~_|])(\.jpg|\.png|\.gif|\.webp)/ig,lmn10:/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,lmn11:/\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\u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6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g,lmn12:["\u2018"],lmn13:"",lmn14:null,lmn15:null,initialize:function(){this.on("click",'[data-action="toggleSound"]',this.toggleSound);this.on("click",'[data-action="mention"]',this.mention);this.on("click",'[data-action="connect"]',this.connect);this.on("click",'[data-action="chat"]',this.chat);this.on("submit",'[data-action="chatform"]',this.chat);this.on("keypress",'[data-action="saveMSG"]',this.saveMSG);this.on("click",'[data-action="remove"]',this.remove);this.on("dblclick",'[data-action="editMSG"]',this.editMSG);this.on("click",'[data-action="editMSGButton"]',this.editMSG);this.on("click",'[data-action="loadMore"]',this.loadMore);this.on("click",'[data-action="playVideoInPopup"]',this.playVideoInPopup);this.on("click",'[data-action="playVideoInIframe"]',this.playVideoInIframe);this.on("click",'[data-action="bimGiphy"]',this.bimGiphy);this.on("focus",".bimcb_chatInput",this.focusChatInput);this.on("blur",".bimcb_chatInput",this.blurChatInput);this.setup();},setup:function(){var data=this;if(1!=ips.getSetting("chatbox_topStyle")){$("#chatcontent img").imagesLoaded(function(canCreateDiscussions){$("#chatboxWrap").scrollTop($("#chatboxWrap").prop("scrollHeight"));});}
this.scope.find('[data-action="toggleSound"] .fa').replaceWith($("<i/>").addClass("fa").addClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-up":"fa-volume-off"));ips.loader.get(["core/interface/howler/howler.core.min.js"]).then(function(){data.lmn15=new Howl({src:ips.getSetting("baseURL")+"applications/bimchatbox/interface/sounds/message.mp3",autoplay:false});});this.scope.find("#elChatbox").prepend(ips.templates.render("core.editor.emoticons",{id:"elEmoticons_chatbox",editor:"chatboxForm"}));this.scope.find("#elEmoticons_chatbox").click(function(){data.scope.find("#elChatbox").trigger("contentChange",[$("#elChatbox")]);$(".ipsNavBar_primary").css("zIndex",1E3);});if("ltr"==document.dir){this.scope.find(".bimcb_chatInput").css({"padding-right":$(".cbItems").width()+15+"px"});}else{this.scope.find(".bimcb_chatInput").css({"padding-left":$(".cbItems").width()+15+"px"});}
this.loop(true);},loop:function(body){var that=this;if(true==body){clearTimeout(that.lmn4);}
var autoHide=ips.getSetting("chatbox_conf_interval")>1E4?ips.getSetting("chatbox_conf_interval"):1E4;that.getMessages(function(){that.lmn4=setTimeout(function(){that.loop(true);},autoHide);});},getMessages:function(callback){if(this.lmn3||this.lmn1){return false;}
if(this.lmn1=true,1!=ips.getSetting("chatbox_topStyle")){var version=this.lmn7>0?this.lmn7:$("#chatcontent").children().last().attr("id");}else{version=this.lmn7>0?this.lmn7:$("#chatcontent").children().first().attr("id");}
var result=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{dataType:"json",data:{lastID:version||0,loadMoreMode:0}}).done(function(response){if("error"==response.type){ips.ui.alert.show({message:response.message});}else{if($("#chatcontent").hasClass("ipsLoading")&&$("#chatcontent").removeClass("ipsLoading"),response.content&&version!=response.lastID){if(1!=ips.getSetting("chatbox_topStyle")){if($("#chatboxWrap").scrollTop()+$("#chatboxWrap").innerHeight()-$("#chatboxWrap").prop("scrollHeight")>=-30){var i=1;}
$("#chatcontent").append(result._chatRow(response.content));if("1"==i){$("#chatcontent img").imagesLoaded(function(canCreateDiscussions){$("#chatboxWrap").scrollTop($("#chatboxWrap").prop("scrollHeight"));});}}else{$("#chatcontent").prepend(result._chatRow(response.content));}
var n=$("#chatcontent .chat_row").length-ips.getSetting("chatbox_maxMSG");if(n>0){$("#chatcontent .chat_row:nth"+(1!=ips.getSetting("chatbox_topStyle")?"":"-last")+"-child(-n+"+n+")").remove();}
if(!(!ips.getSetting("chatbox_soundEnabled")||result.lmn6||result.lmn2)){result.lmn15.play();}
result.lmn7=response.lastID;result.lmn6=false;result.lmn2=false;}}
result.lmn1=false;if("function"==typeof callback){callback();}}).fail(function(){result.disconnect();});},loadMore:function(type){if(this.lmn1){return false;}
if(this.lmn1=true,1==ips.getSetting("chatbox_topStyle")){var data_phone_number=$("#chatcontent").children().last().attr("id");}else{data_phone_number=$("#chatcontent").children().first().attr("id");}
var self=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{type:"post",dataType:"json",data:{lastID:data_phone_number||0,loadMoreMode:1}}).done(function(data){if("error"==data.type){ips.ui.alert.show({message:data.message});}else{if(true==self.lmn5&&self.connected(),data.content){if(1==ips.getSetting("chatbox_topStyle")){$("#chatcontent").append(self._chatRow(data.content));$("#chatboxWrap").animate({scrollTop:$("#"+data.lastID).position().top},1E3);}else{var scrollHeight=$("#chatcontent").height()+$("#chatboxWrap").height()-90;$("#chatcontent").prepend(self._chatRow(data.content));$("#chatcontent img").imagesLoaded(function(canCreateDiscussions){var rowSelectedPosition=$("#chatcontent").height();$("#chatboxWrap").animate({scrollTop:rowSelectedPosition-scrollHeight},1E3);});}}else{ips.ui.alert.show({message:ips.getString("chatbox_error_noolder")});}}
self.lmn1=false;}).fail(function(){self.disconnect();});},disconnect:function(){clearTimeout(self.lmn4);var bigLogStr=ips.getString("chatbox_disconnect");return this.lmn5=true,$("#btnConnect").attr("disabled",false),$("#btnConnect").html(ips.getString("chatbox_reconnect")),$(".cbDisconnect").length||($(".bimcb_chatArea").hide(),$("#chatcontent").prepend(ips.templates.render("chatbox._disconnected")),$("#chatBoxForm").prepend(ips.templates.render("chatbox._disconnectedMSG",{msg:bigLogStr,btn:ips.getString("chatbox_reconnect")}))),false;},connect:function(){return $("#btnConnect").attr("disabled",true),$("#btnConnect").html('<i class="fa fa-refresh fa-spin"></i> '+ips.getString("chatbox_connecting")),this.lmn1=false,this.loop("true"),false;},connected:function(){return this.lmn5=false,$(".bimcb_chatArea").show(),$(".cbDisconnect").remove(),$(".cbDisconnectMSG").remove(),false;},chat:function(res){if(this.lmn3){return false;}
this.lmn2=true;var self=this;var txt=self._escapeHTML($('[name="txt"]').val());return ips.getSetting("chatbox_maxEmoticons")>0&&self._countEmoticons()>ips.getSetting("chatbox_maxEmoticons")?(ips.ui.alert.show({message:ips.getString("chatbox_error_toomanyemo",{num:ips.getSetting("chatbox_maxEmoticons")})}),false):(self._toggleForm("off"),ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=chat",{type:"post",dataType:"json",data:{txt:txt,csrfKey:ips.getSetting("csrfKey")}}).done(function(response){if("error"==response.type){ips.ui.alert.show({message:response.message});}else{$('[name="txt"]').val("");self.loop(true);}}).always(function(){self._toggleForm("on");}),false);},_chatRow:function(clusterShardData){var keywordResults=clusterShardData.split("~~||~~");var pix_color="";var i=0;for(;i<keywordResults.length;i++){pix_color=pix_color+this._chatDetail(keywordResults[i]);}
return pix_color;},_chatDetail:function(clusterShardData){var objIDs=clusterShardData.split("~~#~~");if(objIDs[0]){var t=ips.templates.render("chatbox.row",{id:objIDs[0],memberID:objIDs[1],memberName:objIDs[2],memberNameFormat:objIDs[3],memberPhoto:objIDs[4],memberUrl:objIDs[5],message:this._parseEmoticonsAndBbcode(objIDs[6]),time:this._getChatTime(objIDs[7]),canEdit:objIDs[8],canDelete:objIDs[9],callme:-1!=objIDs[6].indexOf("@"+ips.getSetting("chatbox_myname"))?1:0});}
return t;},_countEmoticons:function(){var layer_i;var crossfilterable_layers=$('[name="txt"]').val().split(" ");var e=0;layer_i=0;for(;layer_i<crossfilterable_layers.length;++layer_i){if(crossfilterable_layers[layer_i]in ips.getSetting("chatbox_Emoticons")){e++;}}
return e;},_parseEmoticonsAndBbcode:function(text){var self=this;text=text.replace(/(\r\n|\n|\r)/gm,"");text=(text=(text=self._parseForContent(text)).replace(this.lmn11,function(callback){return 0>self.lmn12.indexOf(callback)?"twemoji"!=ips.getSetting("emoji_style")?"<span class='chatboxEmoji'>"+callback+"</span>":"<img class='chatboxEmoji' src='https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/"+self._emojiUnicode(callback)+".png'>":callback;})).replace("!","&#33;");_.each(ips.getSetting("chatbox_Emoticons"),function(canCreateDiscussions,searchTerm){var fncWrap="$1<img src='"+canCreateDiscussions+"'>$2";var escapedTerm=self._escapeRegex(searchTerm);var regex=RegExp("(^|\\s)"+(escapedTerm=escapedTerm.replace("<","&lt;").replace(">","&gt;"))+"(\\s|$)","gi");for(;text.match(regex);){text=text.replace(regex,fncWrap);}});var leaves={};var toMixId=0;return _.each(ips.getSetting("badwords"),function(pattern,blue){var commandsRegex=null;var matches=null;if(_.isUndefined(pattern.swop)){pattern.swop="#####";}
commandsRegex=pattern.m_exact?RegExp("(^|\\b|\\s)"+self._escapeRegex(blue)+"(\\b|!|\\?|\\.|,|$)","gi"):RegExp(self._escapeRegex(blue),"gi");for(;matches=commandsRegex.exec(text);){if(null!==matches){if(pattern.m_exact){leaves["__BW"+toMixId+"__"]=matches[1]+pattern.swop+matches[2];}else{leaves["__BW"+toMixId+"__"]=pattern.swop;}
text=text.replace(matches[0],"__BW"+toMixId+"__");toMixId++;}}}),_.each(leaves,function(u,t){text=text.replace(t,u);}),text;},_emojiUnicode:function(object){var default_favicon;return 1===object.length&&(default_favicon=object.charCodeAt(0)),(default_favicon=(object.charCodeAt(0)-55296)*1024+(object.charCodeAt(1)-56320)+65536)<0&&(default_favicon=object.charCodeAt(0)),default_favicon.toString("16");},_escapeRegex:function(value){return this._sRE||(this._sRE=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^)","g")),value.replace(this._sRE,"\\$1");},_escapeHTML:function(text){var elm=document.createElement("div");return elm.appendChild(document.createTextNode(text)),encodeURIComponent(elm.innerHTML);},_parseForContent:function(s){if(1==ips.getSetting("chatbox_imgPost")&&$.trim(s).match(this.lmn9)){s=s.replace(this.lmn9,function(logErrorUrl){return ips.templates.render("chatbox.parsedImage",{url:logErrorUrl});});}
if(1==ips.getSetting("chatbox_videoPost")&&$.trim(s).match(this.lmn10)){s=s.replace(this.lmn10,function(pattid){var CAPTURE_ID=/embed\//i.test(pattid)?pattid.split(/embed\//)[1].split('"')[0]:pattid.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];return ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:CAPTURE_ID,img:"https://img.youtube.com/vi/"+CAPTURE_ID+"/mqdefault.jpg"});});}
var startIndex=0;var harps=this;return s=s.replace(this.lmn8,function(url){var index=s.indexOf(url,startIndex);var canURL=url;return"src='"!==s.substring(index,index-5)&&'srcset="'!==s.substring(index,index-8)&&(canURL='<a href="'+(url=url.replace(/&amp;/g,"&"))+'" target="_blank" class="chatboxLink" rel="noopener noreferrer">'+harps.truncateURL(url,60)+"</a>"),startIndex=index+url.length,canURL;});},truncateURL:function(url,maxLength,type){if(url.length<=maxLength){return url;}
var remaining=maxLength-(type=type||"...").length;return url.substr(0,Math.ceil(remaining/2))+type+url.substr(url.length-Math.floor(remaining/2));},_toggleForm:function(onOff){if("off"==onOff){$('[name="txt"]').prop("disabled",true);$('[id="chat_button"]').prop("disabled",true);}else{$('[name="txt"]').prop("disabled",false);$('[id="chat_button"]').prop("disabled",false);$('[name="txt"]').focus();}},_getChatTime:function(val){var date=new Date;var durationSecond=parseInt(val)?parseInt(val):parseInt((new Date).getTime());date.setTime(1E3*durationSecond);var DATASETS_BASE=date.getHours();var id=date.getMinutes()+"";var k=date.getDate();var n=date.getYear();var v=ips.getString("chatbox_month_"+date.getMonth());var lastMod=new Date;var prevent_sleep=lastMod.getDate();var onKeyboardShow=lastMod.getYear();var undefined=ips.getString("chatbox_month_"+date.getMonth());return 1==id.length&&(id="0"+id),date=ips.getSetting("chatbox_24h")?DATASETS_BASE+":"+id:DATASETS_BASE>12?DATASETS_BASE-12+":"+id+" "+ips.getString("chatbox_time_pm"):0==DATASETS_BASE?"12:"+id+" "+ips.getString("chatbox_time_am"):12==DATASETS_BASE?DATASETS_BASE+":"+id+" "+ips.getString("chatbox_time_pm"):DATASETS_BASE+":"+id+" "+ips.getString("chatbox_time_am"),date=k==prevent_sleep&&v==undefined&&n==onKeyboardShow?ips.getString("chatbox_today")+" "+date:k+" "+v+" "+date;},editMSG:function(event){var msgdiv=this;var todo_id=$(event.currentTarget).attr("data-id");return this.lmn3?($("#chatraw_"+todo_id).html(this._parseEmoticonsAndBbcode($("#editmsg_"+todo_id).val())),$('[data-action="editMSGButton"][data-id="'+todo_id+'"]').html('<i class="fa fa-pencil-square"></i>'),this.lmn3=false,this._toggleForm("on"),false):(ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=edit&id="+todo_id,{type:"post",dataType:"json",data:{id:todo_id,csrfKey:ips.getSetting("csrfKey")}}).done(function(response){if("error"==response.type){ips.ui.alert.show({message:response.message});}else{var formattedChosenQuestion=ips.templates.render("chatbox.editForm",{id:todo_id,content:response.content});$("#chatraw_"+todo_id).html(formattedChosenQuestion);$('[data-action="editMSGButton"][data-id="'+todo_id+'"]').html(ips.getString("chatbox_cancel")).attr("_title",ips.getString("chatbox_cancel"));msgdiv.lmn3=true;msgdiv._toggleForm("off");}}),false);},saveMSG:function(event,i){if(13==event.which){var self=this;i=i>0?i:$(event.currentTarget).attr("data-id");return ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=saveMSG",{type:"post",dataType:"json",data:{id:i,txt:self._escapeHTML($("#editmsg_"+i).val()),csrfKey:ips.getSetting("csrfKey")}}).done(function(data){if("error"==data.type){ips.ui.alert.show({message:data.message});}else{ips.ui.flashMsg.show(data.message);$("#chatraw_"+i).html(self._parseEmoticonsAndBbcode(data.txt));$('[data-action="editMSGButton"][data-id="'+i+'"]').html('<i class="fa fa-pencil-square"></i>');self.lmn3=false;self._toggleForm("on");self.loop(true);}}),false;}},remove:function(event){if(!confirm(ips.getString("confirmDelete"))){return false;}
var readReqCb=ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=delete";var imgId=$(event.currentTarget).attr("data-id");return ips.getAjax()(readReqCb,{type:"post",dataType:"json",data:{id:imgId,csrfKey:ips.getSetting("csrfKey")}}).done(function(response){if("error"==response.type){ips.ui.alert.show({message:response.message});}else{ips.ui.flashMsg.show(response.message);$("#"+imgId).remove();}}),false;},mention:function(options){var member=$(options.currentTarget).attr("data-member");var encodedPW=$('[name="txt"]').val()+" @"+member+" ";return $('[name="txt"]').val(encodedPW),$('[name="txt"]').focus(),false;},toggleSound:function(event){event.preventDefault();this.scope.find('[data-action="toggleSound"] .fa').replaceWith($("<i/>").addClass("fa").addClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-off":"fa-volume-up").removeClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-up":"fa-volume-off"));ips.setSetting("chatbox_soundEnabled",!ips.getSetting("chatbox_soundEnabled"));ips.utils.db.set("chatbox","sounds",ips.getSetting("chatbox_soundEnabled"));},playVideoInPopup:function(event){this.stopPlayingVideos();var existingSynapseBloodhound=$(event.currentTarget).attr("data-videoSource");var CAPTURE_ID=$(event.currentTarget).attr("data-videoId");return ips.ui.dialog.create({fixed:false,size:"medium",url:"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=playvideo",forceReload:true,ajax:{type:"post",data:{source:existingSynapseBloodhound,id:CAPTURE_ID}}}).show(),false;},playVideoInIframe:function(event){this.stopPlayingVideos();var jQFooter=$(event.currentTarget).closest(".cbVideo");var mp3="//www.youtube.com/embed/"+$(event.currentTarget).attr("data-videoId")+"?autoplay=1";return jQFooter.html(ips.templates.render("chatbox.videoIframe",{play:mp3})),false;},stopPlayingVideos:function(){$(".cbVideoContainer").each(function(){var u=$(this).find(".cbPlayer");if(0!==u.length){var t=u.attr("src");var charmId=/embed\//i.test(t)?t.split(/embed\//)[1].split('"')[0]:t.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];var heroImage="//img.youtube.com/vi/"+(charmId=charmId.replace("?autoplay=1",""))+"/mqdefault.jpg";$(this).html(ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:charmId,img:heroImage}));}});},focusChatInput:function(){if("cmd"==ips.getSetting("chatbox_giphy")||"both"==ips.getSetting("chatbox_giphy")){this.lmn14=setInterval(_.bind(this.checkTyping,this),700);}},blurChatInput:function(){clearInterval(this.lmn14);},checkTyping:function(){var related_node_ids=$('[name="txt"]').val();if(related_node_ids!=this.lmn13){if(0!=related_node_ids.indexOf("/giphy ")){if($(".chatboxMedia").is(":visible")){$(".chatboxMedia").empty();$(".chatboxMedia").hide();}
return;}
if(this.lmn13=related_node_ids,0==related_node_ids.indexOf("/giphy ")&&("cmd"==ips.getSetting("chatbox_giphy")||"both"==ips.getSetting("chatbox_giphy"))){this.cmdMedia("giphy");return;}}},cmdMedia:function(inRevIdx){var t=this;var queryStr2=t.lmn13.substring(inRevIdx.length+2);if(this._ajax&&this._ajax.abort){this._ajax.abort();}
if(!$(".chatboxMedia").is(":visible")){$(".chatboxMedia").show();}
$(".chatboxMedia").empty();$(".chatboxMedia").addClass("ipsLoading");this._ajax=ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=giphyCMD",{data:{q:queryStr2},type:"post"}).done(function(usersLayoutTemplate){$(".chatboxMedia").html(usersLayoutTemplate);$(document).trigger("contentChange",[t.scope.find(".chatboxMedia")]);}).always(function(){$(".chatboxMedia").removeClass("ipsLoading");});},bimGiphy:function(){var requestOrUrl=ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=chatbox";var result=ips.utils.db.get("bimgiphy_gif","recent");var data=null;return _.isArray(result)&&(data=JSON.stringify(result)),ips.ui.dialog.create({fixed:false,size:"medium",title:ips.getString("bim_giphy"),url:requestOrUrl,forceReload:true,ajax:{type:"post",data:{recent:data}}}).show(),false;}});}(jQuery,_),function($,dtill,canCreateDiscussions){ips.controller.mixin("bim.chatbox.free.emoji","core.global.editor.emoticons",true,function(){this.before("insertEmoji",function(event){if("chatboxForm"==this.editorID){var value=$(event.currentTarget).attr("data-emoji");var name=null;if(value.indexOf("custom-")>=0){name=$(event.currentTarget).find("img").attr("title");}else{var $subElement=$(event.currentTarget).find(".ipsEmoji");name=$subElement.attr("src")&&void 0!=$subElement.attr("src")?$subElement.attr("alt"):$(event.currentTarget).find(".ipsEmoji").html();}
var $part=$('[data-controller="bim.chatbox.free"]').find('[name="txt"]');var html=$part.val()+" "+name;$part.val(html).focus();ips.utils.emoji.logUse(value);}});this.after("setup",function(){if(["ipsviet.com"].indexOf(document.domain)>-1){return false;}
var lineNumber="<div id='cbCopyright' class='ipsType ipsType_center ipsType_small ipsType_light ipsPad_half'>";lineNumber=lineNumber+("Chatbox "+ips.getSetting("chatbox_version")+" by <a href='https://ipsviet.com' target=_blank>IPSViet.com</a>");lineNumber=lineNumber+"</div>";if($('[data-controller="bim.chatbox.manage"]').length&&$('[data-controller="bim.chatbox.manage"]').find("#cbCopyright").length<=0){$('[data-controller="bim.chatbox.manage"]').append(lineNumber);}
if($("#elEmoticons_chatbox_menu").find("#cbCopyright").length<=0){$("#elEmoticons_chatbox_menu .ipsMenu_footerBar").append(lineNumber);}
$("#cbCopyright").css({display:"block","font-size":"10px",visibility:"visible"});});});}(jQuery,_),ips.templates.set("chatbox.row"," <li class='ipsDataItem chat_row {{#callme}}ipsDataItem_new{{/callme}}' id='{{id}}'>\t<div class='ipsPad_half {{#memberPhoto}}ipsPhotoPanel ipsPhotoPanel_tiny{{/memberPhoto}} ipsClearfix'>\t\t{{#memberPhoto}}\t\t\t<a href='{{memberUrl}}' class='ipsUserPhoto ipsUserPhoto_tiny' id='ips_uid_{{memberID}}'>\t\t\t\t<img src='{{memberPhoto}}' alt=''>\t\t\t</a>\t\t{{/memberPhoto}}\t\t<div>\t\t\t<a href='#' data-action='mention' data-member='{{memberName}}'>{{{memberNameFormat}}}</a>\t\t\t<span class='ipsPos_right'>\t\t\t\t<span class='ipsType_small ipsType_light'>{{time}}</span>\t\t\t\t{{#canEdit}}<a href='#' data-action='editMSGButton' data-id='{{id}}'><i class='fa fa-pencil-square'></i></a>{{/canEdit}}\t\t\t\t{{#canDelete}}<a href='#' data-action='remove' data-id='{{id}}'><i class='fa fa-minus-square'></i></a>{{/canDelete}}\t\t\t</span>\t\t\t<div class='ipsList_inline' id='chatraw_{{id}}' data-id='{{id}}' {{#canEdit}}data-action='editMSG'{{/canEdit}}>{{{message}}}</div>\t\t</div>\t</div></li>"),ips.templates.set("chatbox.parsedImage"," <a href='{{url}}' class='ipsImage ipsThumb_small' data-ipslightbox>\t<img src='{{url}}' class='cbImg'></a>"),ips.templates.set("chatbox.parsedVideo"," <div class='cbVideoContainer'>\t<div class='cbVideo ipsSpacer_both ipsSpacer_half'>\t\t<img src='{{img}}'>\t\t<a href='#' data-action='playVideoInIframe' data-videoId='{{id}}'></a>\t</div>\t<a class='cbVideoPopupOpen' title='{{#lang}}cb_expandPlayer{{/lang}}' data-action='playVideoInPopup' data-videoSource='{{source}}' data-videoId='{{id}}'>\t\t<i class='fa fa-window-maximize' aria-hidden='true'></i>&nbsp;&nbsp;{{#lang}}cb_expandPlayer{{/lang}}\t</a></div>"),ips.templates.set("chatbox.videoIframe"," <iframe class='cbPlayer' width='200' height='113' src='{{play}}' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>"),ips.templates.set("chatbox._disconnected"," <div class='cbDisconnect'></div>"),ips.templates.set("chatbox._disconnectedMSG"," <div class='ipsPad_half ipsType_warning cbDisconnectMSG'><i class='fa fa-exclamation-triangle'></i> {{msg}} <a href='#' class='ipsButton ipsButton_primary ipsButton_verySmall' id='btnConnect' data-action='connect'>{{btn}}</a></div>"),ips.templates.set("chatbox.editForm"," <textarea type='text' class='bimcb_editform' id='editmsg_{{id}}' data-action='saveMSG' data-id='{{id}}' autocomplete='off'>{{content}}</textarea>");;