!function(D,t,u){"use strict";ips.controller.register("bim.chatbox.free",{lmn1:!1,lmn2:!1,lmn3:!1,lmn4:!1,lmn5:!1,lmn6:!0,lmn7:0,lmn8:/\bhttps?:\/\/\S+/gi,lmn9:/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;\(\)]*[-A-Z0-9+&@#\/%=~_|])(\.jpg|\.png|\.gif|\.webp)/gi,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])|\uD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]|\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:["‘"],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 t=this;1!=ips.getSetting("chatbox_topStyle")&&D("#chatcontent img").imagesLoaded(function(t){D("#chatboxWrap").scrollTop(D("#chatboxWrap").prop("scrollHeight"))}),this.scope.find('[data-action="toggleSound"] .fa').replaceWith(D("<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(){t.lmn15=new Howl({src:ips.getSetting("baseURL")+"applications/bimchatbox/interface/sounds/message.mp3",autoplay:!1})}),this.scope.find("#elChatbox").prepend(ips.templates.render("core.editor.emoticons",{id:"elEmoticons_chatbox",editor:"chatboxForm"})),this.scope.find("#elEmoticons_chatbox").click(function(){t.scope.find("#elChatbox").trigger("contentChange",[D("#elChatbox")]),D(".ipsNavBar_primary").css("zIndex",1e3)}),"ltr"==document.dir?this.scope.find(".bimcb_chatInput").css({"padding-right":D(".cbItems").width()+15+"px"}):this.scope.find(".bimcb_chatInput").css({"padding-left":D(".cbItems").width()+15+"px"}),this.loop(!0)},loop:function(D){var t=this;1==D&&clearTimeout(t.lmn4);var u=ips.getSetting("chatbox_conf_interval")>1e4?ips.getSetting("chatbox_conf_interval"):1e4;t.getMessages(function(){t.lmn4=setTimeout(function(){t.loop(!0)},u)})},getMessages:function(t){if(this.lmn3)return!1;if(this.lmn1)return!1;if(this.lmn1=!0,1!=ips.getSetting("chatbox_topStyle"))var u=this.lmn7>0?this.lmn7:D("#chatcontent").children().last().attr("id");else u=this.lmn7>0?this.lmn7:D("#chatcontent").children().first().attr("id");var e=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{dataType:"json",data:{lastID:u||0,loadMoreMode:0}}).done(function(a){if("error"==a.type)ips.ui.alert.show({message:a.message});else if(D("#chatcontent").hasClass("ipsLoading")&&D("#chatcontent").removeClass("ipsLoading"),a.content&&u!=a.lastID){if(1!=ips.getSetting("chatbox_topStyle")){if(D("#chatboxWrap").scrollTop()+D("#chatboxWrap").innerHeight()-D("#chatboxWrap").prop("scrollHeight")>=-30)var i=1;D("#chatcontent").append(e._chatRow(a.content)),"1"==i&&D("#chatcontent img").imagesLoaded(function(t){D("#chatboxWrap").scrollTop(D("#chatboxWrap").prop("scrollHeight"))})}else D("#chatcontent").prepend(e._chatRow(a.content));var n=D("#chatcontent .chat_row").length-ips.getSetting("chatbox_maxMSG");n>0&&D("#chatcontent .chat_row:nth"+(1!=ips.getSetting("chatbox_topStyle")?"":"-last")+"-child(-n+"+n+")").remove(),!ips.getSetting("chatbox_soundEnabled")||e.lmn6||e.lmn2||e.lmn15.play(),e.lmn7=a.lastID,e.lmn6=!1,e.lmn2=!1}e.lmn1=!1,"function"==typeof t&&t()}).fail(function(){e.disconnect()})},loadMore:function(t){if(this.lmn1)return!1;if(this.lmn1=!0,1==ips.getSetting("chatbox_topStyle"))var u=D("#chatcontent").children().last().attr("id");else u=D("#chatcontent").children().first().attr("id");var e=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{type:"post",dataType:"json",data:{lastID:u||0,loadMoreMode:1}}).done(function(t){if("error"==t.type)ips.ui.alert.show({message:t.message});else if(1==e.lmn5&&e.connected(),t.content)if(1==ips.getSetting("chatbox_topStyle"))D("#chatcontent").append(e._chatRow(t.content)),D("#chatboxWrap").animate({scrollTop:D("#"+t.lastID).position().top},1e3);else{var u=D("#chatcontent").height()+D("#chatboxWrap").height()-90;D("#chatcontent").prepend(e._chatRow(t.content)),D("#chatcontent img").imagesLoaded(function(t){var e=D("#chatcontent").height();D("#chatboxWrap").animate({scrollTop:e-u},1e3)})}else ips.ui.alert.show({message:ips.getString("chatbox_error_noolder")});e.lmn1=!1}).fail(function(){e.disconnect()})},disconnect:function(){clearTimeout(self.lmn4);var t=ips.getString("chatbox_disconnect");return this.lmn5=!0,D("#btnConnect").attr("disabled",!1),D("#btnConnect").html(ips.getString("chatbox_reconnect")),D(".cbDisconnect").length||(D(".bimcb_chatArea").hide(),D("#chatcontent").prepend(ips.templates.render("chatbox._disconnected")),D("#chatBoxForm").prepend(ips.templates.render("chatbox._disconnectedMSG",{msg:t,btn:ips.getString("chatbox_reconnect")}))),!1},connect:function(){return D("#btnConnect").attr("disabled",!0),D("#btnConnect").html('<i class="fa fa-refresh fa-spin"></i> '+ips.getString("chatbox_connecting")),this.lmn1=!1,this.loop("true"),!1},connected:function(){return this.lmn5=!1,D(".bimcb_chatArea").show(),D(".cbDisconnect").remove(),D(".cbDisconnectMSG").remove(),!1},chat:function(t){if(this.lmn3)return!1;this.lmn2=!0;var u=this,e=u._escapeHTML(D('[name="txt"]').val());return ips.getSetting("chatbox_maxEmoticons")>0&&u._countEmoticons()>ips.getSetting("chatbox_maxEmoticons")?(ips.ui.alert.show({message:ips.getString("chatbox_error_toomanyemo",{num:ips.getSetting("chatbox_maxEmoticons")})}),!1):(u._toggleForm("off"),ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=chat",{type:"post",dataType:"json",data:{txt:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(t){"error"==t.type?ips.ui.alert.show({message:t.message}):(D('[name="txt"]').val(""),u.loop(!0))}).always(function(){u._toggleForm("on")}),!1)},_chatRow:function(D){for(var t=D.split("~~||~~"),u="",e=0;e<t.length;e++)u+=this._chatDetail(t[e]);return u},_chatDetail:function(D){var t=D.split("~~#~~");if(t[0])var u=ips.templates.render("chatbox.row",{id:t[0],memberID:t[1],memberName:t[2],memberNameFormat:t[3],memberPhoto:t[4],memberUrl:t[5],message:this._parseEmoticonsAndBbcode(t[6]),time:this._getChatTime(t[7]),canEdit:t[8],canDelete:t[9],callme:-1!=t[6].indexOf("@"+ips.getSetting("chatbox_myname"))?1:0});return u},_countEmoticons:function(){var t,u=D('[name="txt"]').val().split(" "),e=0;for(t=0;t<u.length;++t){u[t]in ips.getSetting("chatbox_Emoticons")&&e++}return e},_parseEmoticonsAndBbcode:function(D){var u=this;D=D.replace(/(\r\n|\n|\r)/gm,""),D=(D=(D=u._parseForContent(D)).replace(this.lmn11,function(D){return u.lmn12.indexOf(D)<0?"twemoji"==ips.getSetting("emoji_style")?"<img class='chatboxEmoji' src='"+("https://twemoji.maxcdn.com/2/72x72/"+u._emojiUnicode(D)+".png")+"'>":"<span class='chatboxEmoji'>"+D+"</span>":D})).replace("!","&#33;"),t.each(ips.getSetting("chatbox_Emoticons"),function(t,e){var a="$1<img src='"+t+"'>$2",i=u._escapeRegex(e);i=i.replace("<","&lt;").replace(">","&gt;");for(var n=new RegExp("(^|\\s)"+i+"(\\s|$)","gi");D.match(n);)D=D.replace(n,a)});var e={},a=0;return t.each(ips.getSetting("badwords"),function(i,n){var o=null,s=null;for(t.isUndefined(i.swop)&&(i.swop="#####"),o=i.m_exact?new RegExp("(^|\\b|\\s)"+u._escapeRegex(n)+"(\\b|!|\\?|\\.|,|$)","gi"):new RegExp(u._escapeRegex(n),"gi");s=o.exec(D);)null!==s&&(i.m_exact?e["__BW"+a+"__"]=s[1]+i.swop+s[2]:e["__BW"+a+"__"]=i.swop,D=D.replace(s[0],"__BW"+a+"__"),a++)}),t.each(e,function(t,u){D=D.replace(u,t)}),D},_emojiUnicode:function(D){var t;return 1===D.length&&(t=D.charCodeAt(0)),(t=1024*(D.charCodeAt(0)-55296)+(D.charCodeAt(1)-56320)+65536)<0&&(t=D.charCodeAt(0)),t.toString("16")},_escapeRegex:function(D){if(!this._sRE){this._sRE=new RegExp("(\\"+["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^"].join("|\\")+")","g")}return D.replace(this._sRE,"\\$1")},_escapeHTML:function(D){var t=document.createElement("div");return t.appendChild(document.createTextNode(D)),encodeURIComponent(t.innerHTML)},_parseForContent:function(t){1==ips.getSetting("chatbox_imgPost")&&D.trim(t).match(this.lmn9)&&(t=t.replace(this.lmn9,function(D){return ips.templates.render("chatbox.parsedImage",{url:D})})),1==ips.getSetting("chatbox_videoPost")&&D.trim(t).match(this.lmn10)&&(t=t.replace(this.lmn10,function(D){var t=/embed\//i.test(D)?D.split(/embed\//)[1].split('"')[0]:D.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0],u="https://img.youtube.com/vi/"+t+"/mqdefault.jpg";return ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:t,img:u})}));var u=0,e=this;return t=t.replace(this.lmn8,function(D){var a=t.indexOf(D,u),i=D;return"src='"!==t.substring(a,a-5)&&'srcset="'!==t.substring(a,a-8)&&(i='<a href="'+(D=D.replace(/&amp;/g,"&"))+'" target="_blank" class="chatboxLink" rel="noopener noreferrer">'+e.truncateURL(D,60)+"</a>"),u=a+D.length,i})},truncateURL:function(D,t,u){if(D.length<=t)return D;var e=t-(u=u||"...").length,a=Math.ceil(e/2),i=Math.floor(e/2);return D.substr(0,a)+u+D.substr(D.length-i)},_toggleForm:function(t){"off"==t?(D('[name="txt"]').prop("disabled",!0),D('[id="chat_button"]').prop("disabled",!0)):(D('[name="txt"]').prop("disabled",!1),D('[id="chat_button"]').prop("disabled",!1),D('[name="txt"]').focus())},_getChatTime:function(D){var t=new Date,u=parseInt(D)?parseInt(D):parseInt((new Date).getTime());t.setTime(1e3*u);var e=t.getHours(),a=t.getMinutes()+"",i=t.getDate(),n=t.getYear(),o=ips.getString("chatbox_month_"+t.getMonth()),s=new Date,c=s.getDate(),r=s.getYear(),l=ips.getString("chatbox_month_"+t.getMonth());return 1==a.length&&(a="0"+a),t=ips.getSetting("chatbox_24h")?e+":"+a:e>12?e-12+":"+a+" "+ips.getString("chatbox_time_pm"):0==e?"12:"+a+" "+ips.getString("chatbox_time_am"):12==e?e+":"+a+" "+ips.getString("chatbox_time_pm"):e+":"+a+" "+ips.getString("chatbox_time_am"),t=i==c&&o==l&&n==r?ips.getString("chatbox_today")+" "+t:i+" "+o+" "+t},editMSG:function(t){var u=this,e=D(t.currentTarget).attr("data-id");return this.lmn3?(D("#chatraw_"+e).html(this._parseEmoticonsAndBbcode(D("#editmsg_"+e).val())),D('[data-action="editMSGButton"][data-id="'+e+'"]').html('<i class="fa fa-pencil-square"></i>'),this.lmn3=!1,this._toggleForm("on"),!1):(ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=edit&id="+e,{type:"post",dataType:"json",data:{id:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(t){if("error"==t.type)ips.ui.alert.show({message:t.message});else{var a=ips.templates.render("chatbox.editForm",{id:e,content:t.content});D("#chatraw_"+e).html(a),D('[data-action="editMSGButton"][data-id="'+e+'"]').html(ips.getString("chatbox_cancel")).attr("_title",ips.getString("chatbox_cancel")),u.lmn3=!0,u._toggleForm("off")}}),!1)},saveMSG:function(t,u){if(13==t.which){var e=this;u=u>0?u:D(t.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:u,txt:e._escapeHTML(D("#editmsg_"+u).val()),csrfKey:ips.getSetting("csrfKey")}}).done(function(t){"error"==t.type?ips.ui.alert.show({message:t.message}):(ips.ui.flashMsg.show(t.message),D("#chatraw_"+u).html(e._parseEmoticonsAndBbcode(t.txt)),D('[data-action="editMSGButton"][data-id="'+u+'"]').html('<i class="fa fa-pencil-square"></i>'),e.lmn3=!1,e._toggleForm("on"),e.loop(!0))}),!1}},remove:function(t){if(!confirm(ips.getString("confirmDelete")))return!1;var u=ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=delete",e=D(t.currentTarget).attr("data-id");return ips.getAjax()(u,{type:"post",dataType:"json",data:{id:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(t){"error"==t.type?ips.ui.alert.show({message:t.message}):(ips.ui.flashMsg.show(t.message),D("#"+e).remove())}),!1},mention:function(t){var u=D(t.currentTarget).attr("data-member"),e=D('[name="txt"]').val()+" @"+u+" ";return D('[name="txt"]').val(e),D('[name="txt"]').focus(),!1},toggleSound:function(t){t.preventDefault(),this.scope.find('[data-action="toggleSound"] .fa').replaceWith(D("<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(t){this.stopPlayingVideos();var u=D(t.currentTarget).attr("data-videoSource"),e=D(t.currentTarget).attr("data-videoId");return ips.ui.dialog.create({fixed:!1,size:"medium",url:"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=playvideo",forceReload:!0,ajax:{type:"post",data:{source:u,id:e}}}).show(),!1},playVideoInIframe:function(t){this.stopPlayingVideos();var u=D(t.currentTarget).closest(".cbVideo"),e="//www.youtube.com/embed/"+D(t.currentTarget).attr("data-videoId")+"?autoplay=1";return u.html(ips.templates.render("chatbox.videoIframe",{play:e})),!1},stopPlayingVideos:function(){D(".cbVideoContainer").each(function(){var t=D(this).find(".cbPlayer");if(0!==t.length){var u=t.attr("src"),e=/embed\//i.test(u)?u.split(/embed\//)[1].split('"')[0]:u.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0],a="//img.youtube.com/vi/"+(e=e.replace("?autoplay=1",""))+"/mqdefault.jpg";D(this).html(ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:e,img:a}))}})},focusChatInput:function(){"cmd"!=ips.getSetting("chatbox_giphy")&&"both"!=ips.getSetting("chatbox_giphy")||(this.lmn14=setInterval(t.bind(this.checkTyping,this),700))},blurChatInput:function(){clearInterval(this.lmn14)},checkTyping:function(){var t=D('[name="txt"]').val();t!=this.lmn13&&(0==t.indexOf("/giphy ")?(this.lmn13=t,0!=t.indexOf("/giphy ")||"cmd"!=ips.getSetting("chatbox_giphy")&&"both"!=ips.getSetting("chatbox_giphy")||this.cmdMedia("giphy")):D(".chatboxMedia").is(":visible")&&(D(".chatboxMedia").empty(),D(".chatboxMedia").hide()))},cmdMedia:function(t){var u=this,e=u.lmn13.substring(t.length+2);this._ajax&&this._ajax.abort&&this._ajax.abort(),D(".chatboxMedia").is(":visible")||D(".chatboxMedia").show(),D(".chatboxMedia").empty(),D(".chatboxMedia").addClass("ipsLoading");this._ajax=ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=giphyCMD",{data:{q:e},type:"post"}).done(function(t){D(".chatboxMedia").html(t),D(document).trigger("contentChange",[u.scope.find(".chatboxMedia")])}).always(function(){D(".chatboxMedia").removeClass("ipsLoading")})},bimGiphy:function(){var D=ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=chatbox",u=ips.utils.db.get("bimgiphy_gif","recent"),e=null;return t.isArray(u)&&(e=JSON.stringify(u)),ips.ui.dialog.create({fixed:!1,size:"medium",title:ips.getString("bim_giphy"),url:D,forceReload:!0,ajax:{type:"post",data:{recent:e}}}).show(),!1}})}(jQuery,_),function(D,t,u){"use strict";ips.controller.mixin("bim.chatbox.free.emoji","core.global.editor.emoticons",!0,function(){this.before("insertEmoji",function(t){if("chatboxForm"==this.editorID){var u=D(t.currentTarget).attr("data-emoji"),e=null;if(u.indexOf("custom-")>=0)e=D(t.currentTarget).find("img").attr("title");else{var a=D(t.currentTarget).find(".ipsEmoji");e=a.attr("src")&&null!=a.attr("src")?a.attr("alt"):D(t.currentTarget).find(".ipsEmoji").html()}var i=D('[data-controller="bim.chatbox.free"]').find('[name="txt"]'),n=i.val()+" "+e;i.val(n).focus(),ips.utils.emoji.logUse(u)}}),this.after("setup",function(){if(["ipsviet.com"].indexOf(document.domain)>-1)return!1;var t="<div id='cbCopyright' class='ipsType ipsType_center ipsType_small ipsType_light ipsPad_half'>";t+="Chatbox "+ips.getSetting("chatbox_version")+" by <a href='https://ipsviet.com' target=_blank>IPSViet.com</a>",t+="</div>",D('[data-controller="bim.chatbox.manage"]').length&&D('[data-controller="bim.chatbox.manage"]').find("#cbCopyright").length<=0&&D('[data-controller="bim.chatbox.manage"]').append(t),D("#elEmoticons_chatbox_menu").find("#cbCopyright").length<=0&&D("#elEmoticons_chatbox_menu .ipsMenu_footerBar").append(t),D("#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>");;