function fixed_layout_draggable(){const draggableDivs=document.querySelectorAll(".fixed_draggable_layout");let offsetX,offsetY,isDragging=!1,selectedDiv=null;function fixed_draggable_onStart(event){var target=event.target;if(target instanceof SVGElement){var className=target.getAttribute("class")}else{var className=target.className}
if(className==='close_window_icon'){return}
selectedDiv=event.target.closest('.fixed_draggable_layout');if(selectedDiv){const touch=event.touches?event.touches[0]:event;offsetX=touch.clientX-selectedDiv.getBoundingClientRect().left;offsetY=touch.clientY-selectedDiv.getBoundingClientRect().top;isDragging=!0;selectedDiv.style.cursor="grabbing";event.preventDefault()}}
function fixed_draggable_onMove(event){if(isDragging&&selectedDiv){const touch=event.touches?event.touches[0]:event;const newX=touch.clientX-offsetX;const newY=touch.clientY-offsetY;const maxX=window.innerWidth-selectedDiv.clientWidth;const maxY=window.innerHeight-selectedDiv.clientHeight;selectedDiv.style.left=Math.min(maxX,Math.max(0,newX))+"px";selectedDiv.style.top=Math.min(maxY,Math.max(0,newY))+"px"}}
function fixed_draggable_onEnd(){if(selectedDiv){isDragging=!1;selectedDiv.style.cursor="grab";selectedDiv=null}}
draggableDivs.forEach((div)=>{div.addEventListener("mousedown",fixed_draggable_onStart);div.addEventListener("touchstart",fixed_draggable_onStart);window.addEventListener("mousemove",fixed_draggable_onMove);window.addEventListener("touchmove",fixed_draggable_onMove);window.addEventListener("mouseup",fixed_draggable_onEnd);window.addEventListener("touchend",fixed_draggable_onEnd)})};var baseurl=$('base').eq(0).attr('href');var api_request_url=baseurl+'web_request/';var realtime_request_url=baseurl+'realtime_request/';var default_meta_title=decode_specialchars($("meta[name='default-title']").attr("content"));var meta_title_timeout=null;var user_typing_log_request=null;var user_typing_log_timeout=null;var users_typing_timeout=null;var exit_video_chat_on_change=!0;var current_video_chat_type=null;var current_video_chat_id=null;var user_csrf_token=null;var isVideoChatActive=!1;var search_on_change_of_input=!1;var user_login_session_id=WebStorage('get','login_session_id');var user_access_code=WebStorage('get','access_code');var user_session_time_stamp=WebStorage('get','session_time_stamp');var remove_login_session=WebStorage('get','remove_login_session');var blur_img_url=baseurl+'assets/files/defaults/image_thumb.jpg';var blur_img_url='data:image/jpeg;base64, ';var sw_registerations=[];var viewerjs;var current_logged_user_id;$(document).ready(function(){if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){if(system_variable('login_from_storage')==='true'){$('body').addClass('d-none');var current_site_url=$(location).attr('href');var url_divider=(current_site_url.indexOf('?')!==-1)?'&':'?';var user_login_register=current_site_url+url_divider;user_login_register=user_login_register+'login_session_id='+user_login_session_id+'&access_code='+user_access_code;user_login_register=user_login_register+'&session_time_stamp='+user_session_time_stamp;window.location.href=user_login_register}}
if($('.logged_in_user_id').length>0){current_logged_user_id=$('.logged_in_user_id').text()}});if(system_variable('exit_call_when_switching')==='no'){var exit_video_chat_on_change=!1}
if(system_variable('search_on_change_of_input')==='enable'){search_on_change_of_input=!0}
if($('meta[name="csrf-token"]').attr('content')!==undefined){user_csrf_token=$('meta[name="csrf-token"]').attr('content')}
var mobile_page_transitions=['animate__backInUp','animate__zoomInUp','animate__rotateInUpLeft'];var mobile_page_transition='animate__fadeInRightBig';$('.main').on('click',function(e){if(!$(e.target).parents('.switchuser').hasClass('switchuser')){$('.main .panel > .textbox > .box > .switchuser > .uslist').hide()}});function addCssFile(url){if($('link[rel="stylesheet"][href="'+url+'"]').length===0){var link=document.createElement('link');link.rel='stylesheet';link.type='text/css';link.href=url;document.head.appendChild(link)}}
$('.main').on('click',function(e){if($(window).width()<1200){if(!$(e.target).parents('.side_navigation').hasClass('side_navigation')){if($('.main .chat_page_container').hasClass('show_navigation')){toggle_side_navigation()}}}});function unicodeHash(inputString){const utf8Bytes=new TextEncoder().encode(inputString);let hash=0;for(const byte of utf8Bytes){hash+=byte}
return hash}
function handleImageError(imageElement){imageElement.src=blur_img_url}
$(document).ready(function(){$('body').on('contextmenu','img',function(e){return!1});if($('body').hasClass('right_click_disabled')){document.addEventListener("contextmenu",(event)=>{event.preventDefault()})}
var force_ios_lockdown=!1;if(force_ios_lockdown||isLockdown.isLockdownEnabled()){var lockdown_stylesheet=$('<link>',{rel:'stylesheet',type:'text/css',href:baseurl+'assets/css/chat_page/lockdown_stylesheet.css'});$('head').append(lockdown_stylesheet)}});$("body").on('click','.main .dropdown_button > .icon',function(evt){if($(window).width()>767.98){if($(evt.target).parents('.dropdown_list').length==0){$(this).parent().find(".dropdown_list > ul > li").first().trigger("click")}}});function registerServiceWorker(update_worker){var sw_location=baseurl+'service_worker.js';if(update_worker!==undefined){var sw_location=baseurl+'service_worker.js?v='+update_worker}
if('serviceWorker' in navigator){navigator.serviceWorker.register(sw_location).then(function(registration){if(update_worker!==undefined){registration.update();console.log('Service worker updated successfully:',registration)}else{console.log('Service worker registered successfully:',registration)}}).catch(function(error){console.log('Service worker registration failed:',error)})}else{console.log('Service workers are not supported.')}}
function show_dropdown(element){element.find(".dropdown_list").removeClass('reverse');element.find(".dropdown_list").show();var dropdown_box={bottom:552.6375122070312,height:225,left:641.4249877929688,right:764.6749877929688,top:327.63751220703125,width:123.25,x:641.4249877929688,y:327.63751220703125,};if(element.find(".dropdown_list").length>0){dropdown_box=element.find(".dropdown_list").get(0).getBoundingClientRect()}
var newtop=parseInt(element.find(".dropdown_list").height())-parseInt(dropdown_box.top);var isInViewport=(dropdown_box.top>=newtop&&dropdown_box.left>=0&&dropdown_box.bottom<=(element.parent('.boundary').innerHeight())&&dropdown_box.right<=(element.parents('.boundary').innerWidth()));if(dropdown_box.top<newtop){element.find(".dropdown_list").addClass('reverse')}else if(dropdown_box.bottom>(element.parent('.boundary').innerHeight())){element.find(".dropdown_list").addClass('reverse')}}
$("body").on('mouseenter','.main .dropdown_button',function(e){if($(window).width()>767.98){}});$("body").on('click','.main .side_navigation .menu_items li',function(e){if($(window).width()<767.98){if(!$(this).hasClass('has_child')){$('.main .chat_page_container').removeClass('show_navigation')}}});$(".main").on('click',function(e){if(!$(e.target).hasClass('dropdown_button')&&$(e.target).closest('.dropdown_button').length===0){$(".main .dropdown_list").hide();$('.main .toggle_message_toolbar > div > div.toggle_toolbar_button').removeClass('opened')}
if(!$(e.target).parents().hasClass('switch_user')){$('.main .chatbox > .header > .switch_user').removeClass('open')}
if(!$(e.target).hasClass('site_record_item')&&$(e.target).parents('.site_record_item').length==0){$(".main .aside > .site_records > .records > .list > li > div > .right > .options > span").hide()}
if(!$(e.target).hasClass('side_navigation_footer')&&$(e.target).parents('.side_navigation_footer').length==0){$(".main .side_navigation > .bottom.has_child").removeClass('show')}});$("body").on('click','.main .dropdown_button',function(e){var show_dropdown_list=!0;if($(this).hasClass('toggle_dropdown')){if($(this).find('.dropdown_list').is(':visible')){show_dropdown_list=!1}}
$(".main .dropdown_list").hide();if($(e.target).hasClass('hide_onClick')){show_dropdown_list=!1}
if(show_dropdown_list){show_dropdown($(this))}});function update_user_online_status(status){if(system_variable('realtime_mode')!=='websocket'){var update_user_online_status=baseurl+system_variable('authentication_page_url_path')+'/user_online_status/';if(status!==undefined&&status==='offline'){var update_data={offline:!0,}}else{var update_data={online:!0,}}
if(navigator.sendBeacon){navigator.sendBeacon(update_user_online_status,JSON.stringify(update_data))}}}
window.addEventListener('beforeunload',function(e){update_user_online_status('offline')});$(window).on("load",function(){update_user_online_status('online')});document.addEventListener("visibilitychange",function(){if($(window).width()<767.98){if(document.visibilityState==='hidden'){update_user_online_status('offline')}else if(document.visibilityState==='visible'){update_user_online_status('online')}}});$("body").on('mouseenter','.main .infotipbtn',function(e){$(this).find(".infotip").show()});$("body").on('mouseleave','.main .infotipbtn',function(e){$(".main .infotip").hide()});$("html").on("dragover",function(e){e.preventDefault();e.stopPropagation()});$("html").on("click",function(event){if($(event.target).attr('data-bs-toggle')===undefined||$(event.target).parent().hasClass('hide_tooltip_on_click')){$('.tooltip').remove()}});$("html").on("drop",function(e){e.preventDefault();e.stopPropagation()});$('.refresh_page').on('click',function(){var embed_url=system_variable('embed_url');if(embed_url.length>0){window.location.replace(embed_url)}else{location.reload(!0)}});function dhbrowser_chk(){try{var canvas=document.createElement('canvas');var gl=canvas.getContext('webgl')||canvas.getContext('experimental-webgl');if(!gl)return!0}catch(e){return!0}
if(navigator.plugins.length===0){return!0}
if(!navigator.mediaDevices){return!0}
if(navigator.webdriver){return!0}
var userAgent=navigator.userAgent;if(userAgent.includes('HeadlessChrome')){return!0}
if(screen.width<320||screen.height<320){return!0}
return!1}
$("body").on('focus','.copy_to_clipboard',function(e){var $this=$(this);$this.select();$this.keydown(function(event){if(event.keyCode!==17&&event.keyCode!==67&&event.keyCode!==91&&event.keyCode!==67){event.preventDefault()}});document.execCommand('copy')});jQuery(document).ready(function($){if(window.history&&window.history.pushState){if($(window).width()<800){$(window).on('popstate',function(){var hashLocation=location.hash;var load_blank_onexit=!1;var hashSplit=hashLocation.split("#!/");var hashName=hashSplit[1];if(hashName!==''){var hash=window.location.hash;if(hash===''){window.history.pushState('forward',null,'./#');if(load_blank_onexit&&$('.main .aside').hasClass('visible')){window.open('about:blank',"_self")}else{var go_to_back_trigger=!0;if(!$('.main .middle > .video_preview').hasClass('d-none')){$('.main .middle > .video_preview').removeClass('fixed_draggable_layout');$('.main .middle > .video_preview').addClass('d-none');$('.main .middle > .video_preview > div').html('');go_to_back_trigger=!1}
if($('.viewer-container.viewer-backdrop').length>0){viewer.destroy();go_to_back_trigger=!1}
if(go_to_back_trigger){open_column('first',!0)}}}}});window.history.pushState('forward',null,'./#')}}});$(window).on('load',function(){$('.preloader').fadeOut();$('body').removeClass('overflow-hidden');$('.site_sound_notification').addClass('d-none');var left_panel_content_on_page_load=$.trim($('.content_on_page_load > .left_panel_content_on_page_load').text());if($('.main .side_navigation .force_trigger_onload').length>0){$('.main .side_navigation .force_trigger_onload').trigger('click')}else if(left_panel_content_on_page_load!==''){left_panel_content_on_page_load='.load_'+left_panel_content_on_page_load;$('.main .side_navigation '+left_panel_content_on_page_load).trigger('click')}else if($('.main .side_navigation .load_groups').length>0){$('.main .side_navigation .load_groups').trigger('click')}else{$('.main .aside > .head > .icons > i.load_groups').trigger('click')}
if($(window).width()>770.98){var main_panel_content_on_page_load=$.trim($('.content_on_page_load > .main_panel_content_on_page_load').text());if(main_panel_content_on_page_load==='statistics'){$('.main .side_navigation .load_statistics').trigger('click')}else if(main_panel_content_on_page_load==='wallet'){$('.main .side_navigation .load_wallet_info').trigger('click')}else if(main_panel_content_on_page_load==='membership'){$('.main .side_navigation .load_membership_info').trigger('click')}}
if($(window).width()>1210){if($('.main .side_navigation').length>0){if(system_variable('show_side_navigation_on_load')==='yes'){toggle_side_navigation()}}}
var load_on_refresh=WebStorage('get','load_on_refresh');if(load_on_refresh!==undefined&&load_on_refresh!==null){load_on_refresh=JSON.parse(load_on_refresh)}
if(load_on_refresh!==null&&load_on_refresh.attributes!==undefined){WebStorage('remove','load_on_refresh');var load_on_refresh_element='<span ';$.each(load_on_refresh.attributes,function(attrkey,attrval){load_on_refresh_element=load_on_refresh_element+attrkey+'="'+attrval+'" '});load_on_refresh_element=load_on_refresh_element+'>on_refresh</span>';$('.load_on_refresh').html(load_on_refresh_element);$('.load_on_refresh > span').trigger('click')}else if($('.on_site_load > span').length>0){if($('.on_site_load > span').hasClass('load_profile_on_page_load')){if($(window).width()>1210){$('.on_site_load > span').trigger('click')}}else{$('.on_site_load > span').trigger('click')}}
$('.main .aside > .storage_files_upload_status').addClass('d-none');$('.main').fadeIn();$.getScript(baseurl+"assets/js/combined_js_chat_page_after_load.js");$('.lazy').Lazy()});function is_touch_device(){return("ontouchstart" in window||navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0)}
function isJSON(data){var IS_JSON=!0;try
{var json=$.parseJSON(data)}catch(err){IS_JSON=!1}
return IS_JSON}
function language_string(string_constant){var string_value='';if(string_constant!==undefined){string_value=$('.language_strings > .string_'+string_constant).text()}
return string_value}
function system_variable(variable,update_value){if(update_value===undefined){var result='';if(variable!==undefined){result=$('.system_variables > .variable_'+variable).text()}
return result}else{$('.system_variables > .variable_'+variable).text(update_value)}}
function change_browser_title(title,set_timeout=0){if(title!==undefined){title=$.trim(title);if(title.length>0){document.title=decode_specialchars(title);if(meta_title_timeout!==null){clearTimeout(meta_title_timeout)}
if(set_timeout==0){system_variable('current_title',title)}else{meta_title_timeout=setTimeout(function(){meta_title_timeout=null;var reset_title=system_variable('current_title');if(reset_title.length<0){reset_title=default_meta_title}
change_browser_title(reset_title)},set_timeout)}}}}
function timestamp_convertor(s){var h=Math.floor(s/3600);var tms="";s-=h*3600;var m=Math.floor(s/60);s-=m*60;s=Math.floor(s);if(h!=0){tms=h+":"+(m<10?'0'+m:m)+":"+(s<10?'0'+s:s)}else{tms=(m<10?'0'+m:m)+":"+(s<10?'0'+s:s)}
if(tms=='NaN:NaN:NaN'){tms="00:00"}
return tms}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null}
function eraseCookie(name){createCookie(name,"",-1)}
function isLocalStorageAvailable(){var test='test';try{localStorage.setItem(test,test);localStorage.removeItem(test);return!0}catch(e){return!1}}
function WebStorage(todo,name,value){if(isLocalStorageAvailable()&&typeof(Storage)!=="undefined"){if(todo=='get'){value=localStorage.getItem(name);if(value){return value}else{return null}}else if(todo=='set'){localStorage.setItem(name,value)}else if(todo=='remove'){localStorage.removeItem(name)}else if(todo=='clear'){localStorage.clear()}}else{console.log('No Web Storage Support');return null}}
function RandomString(len){var rdmString="";for(;rdmString.length<len;rdmString+=Math.random().toString(36).substr(2));return rdmString.substr(0,len)}
function abbreviateNumber(value){var newValue=value;if(value>=1000){var suffixes=["","k","m","b","t"];var suffixNum=Math.floor((""+value).length/3);var shortValue='';for(var precision=2;precision>=1;precision--){shortValue=parseFloat((suffixNum!=0?(value/Math.pow(1000,suffixNum)):value).toPrecision(precision));var dotLessShortValue=(shortValue+'').replace(/[^a-zA-Z 0-9]+/g,'');if(dotLessShortValue.length<=2){break}}
if(shortValue%1!=0)shortValue=shortValue.toFixed(1);newValue=shortValue+suffixes[suffixNum]}
return newValue}
$("body").on('click','.open_link',function(e){var web_address='';if($(this).attr('link')!==undefined){web_address=$(this).attr('link')}
if($(this).attr('autosync')!==undefined){if($('.main .chatbox > .info_box > .open_link').is(":visible")){if($('.main .chatbox > .info_box > .open_link').attr('link')!==undefined){web_address=$('.main .chatbox > .info_box > .open_link').attr('link')}}}
if(web_address.length>0){if($(this).attr('target')!==undefined){window.open(web_address,$(this).attr('target')).focus()}else{window.location=web_address}}});function on_image_load(image){image.parentElement.classList.add('image_loaded')}
$("body").on('click','.go_to_previous_page',function(e){if($(window).width()<780){if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}
if(video_preview!==undefined&&video_preview!==null){video_preview.pause()}
$('.main .middle > .group_headers').addClass('d-none');$('.main .middle > .group_headers > .header_content').html('')}
open_column('first',!0)});function open_column(column,loadPrevious){var animate=!0;if($(window).width()<=991&&$(window).width()>=770.98){loadPrevious=!1}
if(loadPrevious!==undefined&&loadPrevious){animate=!1;if($('.page_column.previous').length>0){var previous_column=$('.page_column.previous').attr('column');if($('.page_column.previous').hasClass('d-none')){previous_column='first'}else if(previous_column==='third'){previous_column='first'}
if(previous_column!==$('.page_column.visible').attr('column')){column=previous_column}}}
var current_column=$('.page_column.visible');$('.page_column').removeClass('previous');$('.page_column').removeClass('animate__animated '+mobile_page_transition+' animate__faster');if(current_column.length===0){current_column=$('.page_column[column="first"]');$('.page_column[column="first"]').removeClass('d-none');$('.page_column[column="first"]').addClass('visible')}
if(column!==undefined){if($(window).width()<=991&&$(window).width()>=770.98){if(column==='fourth'){$('.page_column[column="third"]').addClass('d-none');$('.page_column[column="first"]').addClass('d-none');$('.page_column[column="fourth"]').removeClass('d-none')}else if(column==='first'){$('.page_column[column="third"]').addClass('d-none');$('.page_column[column="fourth"]').addClass('d-none');$('.page_column[column="first"]').removeClass('d-none')}else if(column==='third'){$('.page_column[column="fourth"]').addClass('d-none');$('.page_column[column="first"]').addClass('d-none');$('.page_column[column="third"]').removeClass('d-none')}}
if($('.page_column.visible').attr('column')!=column&&animate){$('.page_column[column="'+column+'"]').addClass('animate__animated '+mobile_page_transition+' animate__faster')}
if(current_column.attr('column')==='third'||current_column.attr('column')==='fourth'){current_column=$('.page_column[column="first"]')}
current_column.addClass('previous');$('.page_column').removeClass('visible');$('.page_column[column="'+column+'"]').addClass('visible').removeClass('previous')}}
function open_module(moduleClass,parentClass,keepitOpen){if(parentClass===undefined){parentClass='body'}
if(keepitOpen===undefined){keepitOpen=!1}
if($(parentClass).find(moduleClass).hasClass('hidden')){$(parentClass).find('.module').addClass('hidden');$(parentClass).find(moduleClass).removeClass('hidden')}else if(!keepitOpen){$(parentClass).find('.module').addClass('hidden')}}
function close_module(moduleClass,parentClass){if(parentClass===undefined){parentClass='body'}
$(parentClass).find('.module').addClass('hidden')}
function loader_content($type='list'){var content='';if($type=='list'){for(let i=0;i<14;i++){content=content+'<li><div><span class="left">';content=content+'<span class="img"></span>';content=content+'</span><span class="center">';content=content+'<span class="title"></span>';content=content+'<span class="subtitle"></span>';content=content+'</span><span class="right"></span>';content=content+'</div></li>'}}
return content}
$('.no_form_submit').on('submit',function(event){event.preventDefault()});$('body').on('click','.openlink',function(e){var url=$(this).attr("url");var pattern=/^((http|https|ftp):\/\/)/;if(!pattern.test(url)){url=baseurl+url}
if($(this).attr('newtab')==undefined){window.location=url}else{window.open(url,'_blank')}
return!1});function randomColor(lum){var randomColor=Math.floor(Math.random()*16777215).toString(16);randomColor=String(randomColor).replace(/[^0-9a-f]/gi,'');if(randomColor.length<6){randomColor=randomColor[0]+randomColor[0]+randomColor[1]+randomColor[1]+randomColor[2]+randomColor[2]}
lum=lum||0;var rgb="#",c,i;for(i=0;i<3;i++){c=parseInt(randomColor.substr(i*2,2),16);c=Math.round(Math.min(Math.max(0,c+(c*lum)),255)).toString(16);rgb+=("00"+c).substr(c.length)}
return rgb}
$("body").on('click','.toggle_side_navigation',function(e){toggle_side_navigation()});function toggle_side_navigation(){$('.main .chat_page_container > .side_navigation').removeClass('animate__animated animate__slideInLeft animate__faster animate__slideInRight');if($('.main .chat_page_container').hasClass('show_navigation')){$('.main .chat_page_container').removeClass('show_navigation')}else{if($(window).width()<1200){if($('body').hasClass('ltr_language')){$('.main .chat_page_container > .side_navigation').addClass('animate__animated animate__slideInLeft animate__faster')}else{$('.main .chat_page_container > .side_navigation').addClass('animate__animated animate__slideInRight animate__faster')}}
$('.main .chat_page_container').addClass('show_navigation')}}
$("body").on('click','.download_file',function(e){if(!$(this).hasClass('processing')&&$(this).attr('download')!==undefined){$(this).addClass('processing');var element=$(this);var data={process:"download",validate:!0,download:$(this).attr('download')};data=$.extend(data,$(this).data());if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:data,async:!0,success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.error!=undefined){alert(decode_specialchars(data.error))}else if(data.download_link!=undefined){window.location.href=data.download_link}}else{console.log('ERROR : '+data)}
element.removeClass('processing')}).fail(function(qXHR,textStatus,errorThrown){element.removeClass('processing');console.log('ERROR : '+errorThrown)})}});$("body").on('click','.preview_image',function(e){$('#preview_image').removeAttr('id');var index=$(this).parent().parent().index();var prev_btn=next_btn=navbar=0;if($(this).parents('.files').length>0){$(this).parent().parent().parent().attr('id','preview_image')}else{$(this).attr('id','preview_image')}
if($(this).parent().parent().parent().find('li').length>1){navbar=1}
var image_data={title:0,navbar:navbar,toolbar:{zoomIn:{show:1,size:'large',},zoomOut:{show:1,size:'large',},oneToOne:0,play:0,prev:prev_btn,next:next_btn,rotateLeft:{show:1,size:'large',},reset:{show:1,size:'large',},rotateRight:{show:1,size:'large',},flipHorizontal:{show:1,size:'large',},flipVertical:{show:1,size:'large',},},hidden:function(){viewer.destroy()},url(image){return image.getAttribute("original")},};if($(this).attr('load_image')===undefined){var viewerjs=viewer=new Viewer(document.getElementById('preview_image'),image_data)}else{image_data.url='src';var load_image=new Image();load_image.src=$(this).attr('load_image');var viewerjs=viewer=new Viewer(load_image,image_data)}
viewer.view(index)
viewer.show()});$("body").on('click','.ask_confirmation',function(e){var column='first';if($(this).attr('column')===undefined||$(this).attr('column')==='first'){$('.main .aside > .site_records > .records').addClass('blur');$('.main .aside > .site_records > .records > .list > li').removeClass('selected');$('.main .aside > .site_records > .tools').addClass('d-none')}else{column=$(this).attr('column')}
var confirm_box=$('.main .page_column[column="'+column+'"] .confirm_box');var submit_button='<span class="api_request">'+$(this).attr('submit_button')+'</span>';confirm_box.find('.content > .btn.submit').html(submit_button);confirm_box.find('.content > .btn.cancel > span').replace_text($(this).attr('cancel_button'));confirm_box.find('.content > .text').replace_text($(this).attr('confirmation'));$(this).parents('li').addClass('selected');$.each($(this).data(),function(name,value){name='data-'+name;confirm_box.find('.content > .btn.submit > span').attr('column',column);confirm_box.find('.content > .btn.submit > span').attr(name,value)});if($(this).attr('multi_select')!==undefined){confirm_box.find('.content > .btn.submit > span').attr('multi_select',$(this).attr('multi_select'))}
if(column==='second'){confirm_box.find('.content > .btn.submit > span').attr('hide_element','.middle .confirm_box')}
confirm_box.find('.error').hide();confirm_box.removeClass('d-none');if(column==='fourth'){$('.main .info_panel').animate({scrollTop:0},500)}});$("body").on('click','.main .side_navigation .menu_items > li.has_child,.main .side_navigation > .bottom.has_child',function(event){if(!$(event.target).parent().parent().hasClass('child_menu')){if($(this).hasClass("show")){$(this).removeClass("show")}else{$(this).addClass("show")}}});$("body").on('click','.main .confirm_box > .content > .btn.cancel',function(e){var column='first';if($(this).attr('column')===undefined||$(this).attr('column')==='first'){$('.main .aside > .site_records > .records').removeClass('blur');$('.main .aside > .site_records > .records > .list > li').removeClass('selected');$('.main .aside > .site_records > .tools').removeClass('d-none');$('.main .aside > .site_records > .records > .loader').hide()}else{column=$(this).attr('column')}
var confirm_box=$('.main .page_column[column="'+column+'"] .confirm_box');confirm_box.find('.error').hide();confirm_box.addClass('d-none')});function typing_indicator(todo='log'){if(todo===undefined||todo==='log'){if(!$('.main .chatbox').hasClass('logged_user_typing_status')){$('.main .chatbox').addClass('logged_user_typing_status');var post_data={update:'typing_status',};if($('.main .chatbox').attr('group_id')!==undefined){post_data.group_id=$('.main .chatbox').attr('group_id')}else if($('.main .chatbox').attr('user_id')!==undefined){post_data.user_id=$('.main .chatbox').attr('user_id')}
if($('.main .chatbox > .header > .switch_user > .user_id > input').length>0){var send_as_user_id=$('.main .chatbox > .header > .switch_user > .user_id > input').val();if(send_as_user_id.length>0&&send_as_user_id!=='0'){post_data.send_as_user_id=send_as_user_id}}
if(user_csrf_token!==null){post_data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){post_data.login_session_id=user_login_session_id;post_data.access_code=user_access_code;post_data.session_time_stamp=user_session_time_stamp}
user_typing_log_request=$.ajax({type:'POST',url:api_request_url,data:post_data,async:!0,beforeSend:function(){if(user_typing_log_request!==null){user_typing_log_request.abort();user_typing_log_request=null}},success:function(data){}}).done(function(data){$('.main .chatbox').addClass('logged_user_typing_status')}).fail(function(qXHR,textStatus,errorThrown){$('.main .chatbox').removeClass('logged_user_typing_status')});if($('.main .chatbox').hasClass('logged_user_typing_status')){if(user_typing_log_timeout!==null){clearTimeout(user_typing_log_timeout)}
user_typing_log_timeout=setTimeout(function(){$('.main .chatbox').removeClass('logged_user_typing_status');user_typing_log_timeout=null},10000)}}}else if(todo==='reset'){if(user_typing_log_timeout!==null){clearTimeout(user_typing_log_timeout);user_typing_log_timeout=null}
whos_typing(null);$('.main .chatbox').removeClass('logged_user_typing_status')}}
function whos_typing(user_data){if(user_data!==undefined){if(users_typing_timeout!==null){clearTimeout(users_typing_timeout);users_typing_timeout=null}
if(user_data===null||user_data===''){$('.main .chatbox > .header > .heading > .whos_typing').attr('last_logged_user_id',0);$('.main .chatbox > .header > .heading > .whos_typing > ul').html('')}else{var users_typing='';$.each(user_data,function(key,user){users_typing+='<li>'+user+' '+language_string('is_typing')+'</li>'});$('.main .chatbox > .header > .heading > .whos_typing > ul').html(users_typing)}}
if($('.main .chatbox > .header > .heading > .whos_typing > ul').length>0){if($('.main .chatbox > .header > .heading > .whos_typing > ul > li.active').length===0){$('.main .chatbox > .header > .heading > .whos_typing > ul > li:first-child').addClass('active')}else{var $active=$('.main .chatbox > .header > .heading > .whos_typing > ul > li.active');if($active.next().length>0){var $next=$active.next()}else{var $next=$('.main .chatbox > .header > .heading > .whos_typing > ul > li:first-child')}
$next.addClass('active');if($('.main .chatbox > .header > .heading > .whos_typing > ul > li').length>1){$active.removeClass('active')}}
if(users_typing_timeout!==null){clearTimeout(users_typing_timeout)}
if($('.main .chatbox > .header > .heading > .whos_typing > ul > li').length>1){users_typing_timeout=setTimeout(function(){whos_typing();users_typing_timeout=null},2000)}}};var load_aside_request=null;$('.main .aside > .site_records > .records > .list').on('scroll',function(e){if($(this).scrollTop()+$(this).innerHeight()>=$(this)[0].scrollHeight-20){if(!$('.main .aside > .site_records > .current_record').hasClass('EndResults')&&!$('.main .aside > .site_records > .current_record').hasClass('loading')){$('.main .aside > .site_records > .current_record').addClass('loading');load_aside($('.main .aside > .site_records > .current_record'),1)}}});$("body").on("keyup",".main .aside > .site_records > .search > input",function(e){if(e.which==13||search_on_change_of_input){if($('.main .aside > .site_records > .current_record').attr('load')!==undefined){var search=$(this).val();if(search.length!=0||$('.main .aside > .site_records > .current_record').attr('null_search')!==undefined){$('.main .aside > .site_records .current_record_search_keyword').val(search);$('.main .aside > .site_records .current_record_offset').val('');load_aside($('.main .aside > .site_records > .current_record'),2,1)}else{$('.main .aside > .site_records .current_record_search_keyword').val('');if($('.main .aside > .site_records > .current_record > .title > .dropdown_button').length>0){$('.main .aside > .site_records > .current_record > .title > .dropdown_button > .dropdown_list > ul > li:nth-child(1)').trigger('click');$('.main .aside > .site_records > .current_record > .title > .dropdown_button > .dropdown_list').hide()}else{$('.main .aside > .site_records > .current_record > .title').trigger('click')}}}}});$("body").on("click",".main .aside > .site_records li.select_result",function(e){if($('.main .aside .selector.select_all').hasClass('d-none')){$(".main .aside > .site_records > .current_record .toggle_checkbox").trigger('click')}
if($(this).find('div > .selector > input').prop("checked")===!0){$(this).find('div > .selector > input').prop("checked",!1)}else{$(this).find('div > .selector > input').prop("checked",!0)}
$(this).find('div > .selector > input').trigger('change')});$('.main').on('click','.upload_storage_files',function(e){$('.main .aside > .storage_files_upload_status > .center > .files_attached').addClass('d-none');$('.main .aside > .storage_files_upload_status > .center > .files_attached > form > .storage_file_attachments').trigger('click')});$('.main .aside > .site_records').on('drop',function(e){e.stopPropagation();e.preventDefault();if($('.main .aside > .site_records > .current_record').attr('load')==='site_user_files'){if($('.main .aside > .site_records > .tools > .tool > span').hasClass('upload_storage_files')){var dropped_files=e.originalEvent.dataTransfer.files;var storage_uploader=$('.main .aside > .storage_files_upload_status > .center > .files_attached > form > .storage_file_attachments');$('.main .aside > .storage_files_upload_status > .center > .files_attached').addClass('d-none');storage_uploader.prop('files',dropped_files);storage_uploader.trigger('change')}}});$('.main .aside > .storage_files_upload_status > .center > .files_attached > form > .storage_file_attachments').change(function(e){if($(this).prop('files').length>0){$('.main .aside > .storage_files_upload_status').addClass('d-none');$('.main .aside > .storage_files_upload_status > .center > .progress > .progress-bar').css('width','0%');$('.main .aside > .storage_files_upload_status > .center > .text > span > .percentage').text('0%');$('.main .aside > .storage_files_upload_status > .center > .error > .message > span').html('');$('.main .aside > .storage_files_upload_status > .center > .error').hide();$('.main .aside > .storage_files_upload_status > .center > .progress').show();$('.main .aside > .storage_files_upload_status > .center > .text').show();var data=new FormData($(".storage_files_upload_status > .center > .files_attached > form")[0]);var file_attachments=$(".storage_files_upload_status > .center > .files_attached > form > .storage_file_attachments").get(0).files;for(var i=0;i<file_attachments.length;i++){data.append("file_attachments["+i+"]",file_attachments[i])}
if(user_csrf_token!==null){data.append("csrf_token",user_csrf_token)}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.append("login_session_id",user_login_session_id);data.append("access_code",user_access_code);data.append("session_time_stamp",user_session_time_stamp)}
var attached_files_size=0;$(this).each(function(){for(var i=0;i<this.files.length;i++){attached_files_size+=this.files[i].size}});attached_files_size=(attached_files_size/(1024*1024)).toFixed(2);$('.main .aside > .storage_files_upload_status').removeClass('d-none');$.ajax({type:'POST',url:api_request_url,xhr:function(){var xhr=new window.XMLHttpRequest();xhr.upload.addEventListener("progress",function(evt){if(evt.lengthComputable){var percentComplete=((evt.loaded/evt.total)*100);percentComplete=parseInt(percentComplete);$('.main .aside > .storage_files_upload_status > .center > .progress > .progress-bar').css('width',percentComplete+'%');$('.main .aside > .storage_files_upload_status > .center > .text > span > .percentage').text(percentComplete+'%')}},!1);return xhr},data:data,cache:!1,contentType:!1,processData:!1,async:!0,beforeSend:function(){},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.success){if(data.reload!==undefined&&$('.main .aside > .site_records > .current_record').attr('load')===data.reload){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');$(".main .aside > .site_records > .current_record > .title").trigger('click')}
$('.main .aside > .storage_files_upload_status').addClass('d-none')}else{$('.main .aside > .storage_files_upload_status > .center > .progress').hide();$('.main .aside > .storage_files_upload_status > .center > .text').hide();$('.main .aside > .storage_files_upload_status > .center > .error > .message > span').replace_text(data.error_message);$('.main .aside > .storage_files_upload_status > .center > .error').fadeIn();setTimeout(function(){$('.main .aside > .storage_files_upload_status').addClass('d-none')},3000)}}else{console.log('ERROR : '+data);$('.main .aside > .storage_files_upload_status').addClass('d-none')}}).fail(function(qXHR,textStatus,errorThrown){$('.main .aside > .storage_files_upload_status').addClass('d-none');console.log('ERROR : '+errorThrown)})}});$('body').on('click','.main .aside > .site_records > .records > .list > li > div > .center > .title',function(e){if($(window).width()<767.98){$('.tooltip.show').removeClass('show')}});$('.main').on('click','.load_aside',function(e){var force_load_aside=!1;if($(event.target).hasClass('load_aside')&&$(event.target).parent().hasClass('prevent_default')){force_load_aside=!0}
if(force_load_aside||!$(event.target).hasClass('prevent_default')&&!$(event.target).parent().hasClass('prevent_default')){open_module('.site_records','.main .aside',!0);open_column('first');load_aside($(this));if($(this).attr('hide_search_bar')!==undefined){$('.main .aside > .site_records > .search').addClass('d-none')}else{$('.main .aside > .site_records > .search').removeClass('d-none')}
$('.main .aside > .mini_audio_player').removeClass('d-none')}});function load_aside(load,append=0,skiptitle=0){if(load.attr('load')!==undefined){var offset=filter=sortby=search=0;var preloader_disabled=!1;if(load.attr('disable_preloader')!=undefined){preloader_disabled=!0;load.removeAttr('disable_preloader')}
$('.main .aside > .site_records > .records > .zero_results').addClass('d-none');$('.main .aside > .site_records > .records > .on_error').addClass('d-none');$('.main .aside > .site_records > .current_record').removeClass('EndResults');$('.main .aside > .site_records > .current_record').addClass('loading');if(append==0){if(load.attr('sort')==undefined){if(load.attr('filter')!==undefined){if(load.attr('skip_filter_title')===undefined){$('.main .aside > .site_records > .current_record > .title > div > .filter').replace_text('['+load.text()+']')}else{$('.main .aside > .site_records > .current_record > .title > div > .filter').replace_text('')}
filter=load.attr('filter')}else{$('.main .aside > .site_records > .current_record > .title > div > .filter').replace_text('')}}
if(load.attr('sort')!==undefined){$('.main .aside > .site_records > .current_record > .options > div.sort > span > span').replace_text(load.text());filter=$('.main .aside > .site_records .current_record_filter').val();sortby=load.attr('sort')}else{$('.main .aside > .site_records > .current_record > .options > div.sort > span > span').replace_text(language_string('sort'))}
if(load.attr('search')!==undefined){search=load.attr('search')}
if(!preloader_disabled){$('.main .aside > .site_records > .records > .list').html('').hide()}
if(skiptitle==0&&!preloader_disabled){$('.main .aside > .site_records > .current_record > .title > div > .text').replace_text(language_string('loading'))}
if(!preloader_disabled){$('.main .aside > .site_records > .current_record > .options > div > .dropdown_list > ul').html('');$('.main .aside > .site_records > .current_record > .options > div').addClass('d-none');$('.main .aside > .site_records > .tools > .tool').addClass('d-none')}
if(!preloader_disabled){$('.main .aside > .site_records > .current_record > .selector').addClass('d-none')}
$('.main .aside > .site_records > .current_record > .selector > input').prop('checked',!1);$('.main .aside > .site_records > .confirm_box > .error').hide();$('.main .aside > .site_records > .confirm_box').addClass('d-none');$('.main .aside > .site_records > .current_record').removeClass('d-none');$('.main .aside > .site_records > .records').removeClass('blur');if($('.main .aside > .site_records > .records > .loader > ul > li').length===0){$('.main .aside > .site_records > .records > .loader > ul').html(loader_content())}
$('.main .aside > .site_records > .records > .loader').removeClass('error');if(!preloader_disabled){$('.main .aside > .site_records > .records > .loader').show()}
$('.main .aside > .site_records > .search > input').val('');$('.main .aside > .site_records .current_record_filter').val(filter);$('.main .aside > .site_records .current_record_sort_by').val(sortby);$('.main .aside > .site_records .current_record_offset').val(offset);$('.main .aside > .site_records .current_record_search_keyword').val('');$('.main .aside > .site_records > .current_record').attr('load',load.attr('load'));$('.main .aside > .site_records > .current_record').removeAttr('null_search');$('.main .aside > .site_records .record_info > .data_attributes').html('');var append_data=load.data();$.each(append_data,function(index,data_item){if($('.main .aside > .site_records .record_info > .data_attributes > span').length===0){$('.main .aside > .site_records .record_info > .data_attributes').html('<span>Append Data</span>')}
var data_index='data-'+index;$('.main .aside > .site_records .record_info > .data_attributes > span').attr(data_index,append_data[index])})}else{offset=$('.main .aside > .site_records .current_record_offset').val();filter=$('.main .aside > .site_records .current_record_filter').val();sortby=$('.main .aside > .site_records .current_record_sort_by').val();search=$('.main .aside > .site_records .current_record_search_keyword').val();if(append==2){$('.main .aside > .site_records > .records > .loader').show()}}
var data={load:load.attr('load'),filter:filter,offset:offset,sortby:sortby,search:search,};if(load.attr('check_conversation_loaded')!=undefined){if($(".main .chatbox").attr('group_id')!==undefined&&$(".main .chatbox").attr('group_id')!=='all'){data.conversation_loaded=!0}else if($(".main .chatbox").attr('user_id')!==undefined&&$(".main .chatbox").attr('user_id')!=='all'){data.conversation_loaded=!0}}
if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
if($('.main .aside > .site_records .record_info > .data_attributes > span').length>0){data=$.extend(data,$('.main .aside > .site_records .record_info > .data_attributes > span').data())}
load_aside_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_aside_request!=null){load_aside_request.abort();load_aside_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);var list=filter=sort='';var totalitems=totalfilters=totalsortby=0;var content=data.content;var alloptions=data.options;var filters=data.filters;var sortby=data.sortby;var todo=data.todo;if(Object.keys(data).length>0){if(data.content!==undefined){totalitems=Object.keys(data.content).length}
if(data.filters!==undefined){totalfilters=Object.keys(data.filters).length}
if(data.sortby!==undefined){totalsortby=Object.keys(data.sortby).length}
if(data.loaded!==undefined){if(skiptitle==0){$('.main .aside > .site_records > .current_record > .title > div > .text').replace_text(data.loaded.title)}
if(data.loaded.offset!==undefined){$('.main .aside > .site_records .current_record_offset').val(data.loaded.offset)}
if(data.loaded.null_search!==undefined){$('.main .aside > .site_records > .current_record').attr('null_search',!0)}
if(data.multiple_select!==undefined&&data.multiple_select.title!==undefined){$('.main .aside > .site_records > .current_record > .options > div.toggle_checkbox').removeClass('d-none')}}
if(append===0&&data.todo!==undefined){$('.main .aside > .site_records > .tools > .todo').html('<span><i class="iconic_plus"></i></span>');$('.main .aside > .site_records > .tools > .todo > span').addClass(data.todo.class);$('.main .aside > .site_records > .tools > .todo > span').addClass("hide_tooltip_on_click");var todoattrs=data.todo.attributes;$('.main .aside > .site_records > .tools, .main .aside > .site_records > .tools > .todo').removeClass('d-none');$('.main .aside > .site_records > .tools > .todo > span > i').attr('title',data.todo.title);$('.main .aside > .site_records > .tools > .todo > span > i').attr('data-bs-toggle','tooltip');$('.main .aside > .site_records > .tools > .todo > span > i').attr('data-bs-placement','left');if(todoattrs!==undefined){$.each(todoattrs,function(key,val){$('.main .aside > .site_records > .tools > .todo > span').attr(key,val)})}}}
if(!preloader_disabled){if(append===0&&totalsortby>0){$.each(sortby,function(key,val){var attributes=sortby[key].attributes;sort=sort+'<li ';$.each(attributes,function(attrkey,attrval){sort=sort+attrkey+'="'+attributes[attrkey]+'" '});sort=sort+'class="'+sortby[key].class+'">'+sortby[key].sortby+'</li>'});$('.main .aside > .site_records > .current_record > .options > div.sort .dropdown_list > ul').html(sort);$('.main .aside > .site_records > .current_record > .options > div.sort').addClass('right');$('.main .aside > .site_records > .current_record > .options > div.sort').removeClass('d-none')}else if(append==0){$('.main .aside > .site_records > .current_record > .options > div.sort').removeClass('right');$('.main .aside > .site_records > .current_record > .options > div.sort').addClass('d-none')}}
if(append==0&&totalfilters>0){$.each(filters,function(key,val){var attributes=filters[key].attributes;filter=filter+'<li ';$.each(attributes,function(attrkey,attrval){filter=filter+attrkey+'="'+attributes[attrkey]+'" '});filter=filter+'class="'+filters[key].class+'">'+filters[key].filter+'</li>'});$('.main .aside > .site_records > .current_record > .title > div > .dropdown_list > ul').html(filter);$('.main .aside > .site_records > .current_record > .title > div').addClass('dropdown_button')}else if(append==0){$('.main .aside > .site_records > .current_record > .title > div > .dropdown_list > ul').html('');$('.main .aside > .site_records > .current_record > .title > div').removeClass('dropdown_button')}
if(data.multiple_select!==undefined&&data.multiple_select.title!==undefined){var icon_class='iconic_close';if(data.multiple_select.icon!==undefined){icon_class=data.multiple_select.icon}
$('.main .aside > .site_records > .tools > .multiple_selection').html('<span><i class="'+icon_class+'"></i><span>');$('.main .aside > .site_records > .tools > .multiple_selection > span > i').attr('data-bs-toggle','tooltip');$('.main .aside > .site_records > .tools > .multiple_selection > span > i').attr('data-bs-placement','left');$('.main .aside > .site_records > .tools > .multiple_selection > span > i').attr('title',data.multiple_select.title);if(data.multiple_select.attributes!==undefined){$.each(data.multiple_select.attributes,function(attrkey,attrval){$('.main .aside > .site_records > .tools > .multiple_selection > span').attr(attrkey,attrval)})}}
if(totalitems>0){$.each(content,function(key,val){var item_attributes='';if(content[key].attributes!==undefined){$.each(content[key].attributes,function(item_attr_key,item_attr_val){item_attributes=item_attributes+item_attr_key+'="'+item_attr_val+'" '})}
list=list+'<li class="site_record_item '+content[key].class+'" '+item_attributes+'> <div>';if(data.loaded!==undefined){if(data.multiple_select!==undefined&&data.multiple_select.title!==undefined){list=list+'<label class="selector prevent_default select_item d-none">';list=list+'<input type="checkbox" name="'+data.multiple_select.attributes.multi_select+'[]" value="'+content[key].identifier+'"/>';list=list+'<span class="checkmark"></span>';list=list+'</label>'}}
list=list+'<div class="left">';if(content[key].alphaicon!=undefined){list=list+'<span class="alphaicon">';if(content[key].title!=undefined&&content[key].title!=null){list=list+'<i>'+content[key].title.slice(0,1)+'</i>'}
list=list+'</span>'}else{list=list+'<img loading="lazy" onload="on_image_load(this)" src="'+content[key].image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';if(content[key].online_status!==undefined){list=list+'<span class="online_status '+content[key].online_status+'"></span>'}}
list=list+'</div>';list=list+'<div class="center">';list=list+'<span class="title">';list=list+'<span class="text" data-bs-toggle="tooltip" title="'+content[key].title+'">'+content[key].title+'</span>';list=list+'<span class="unread">';if(content[key].unread!==0){list=list+'<span unread="'+content[key].unread+'">'+content[key].unread+' '+language_string('new')+'</span>'}
list=list+'</span>';list=list+'</span>';list=list+'<span class="subtitle">';list=list+content[key].subtitle;if(content[key].icon!==0){list=list+'<i class="icon '+content[key].icon+'" data-bs-toggle="tooltip" title="'+content[key].icon_text+'"></i>'}
list=list+'</span>';list=list+'</div>';list=list+'<div class="right">';list=list+'<span class="options prevent_default">';if(alloptions!=undefined&&alloptions[key]!==undefined&&alloptions[key].length!=0){list=list+'<i class="iconic_three-dots"></i>';if(content[key].attributes!==undefined&&content[key].attributes.stopPropagation!==undefined){list=list+'<span><ul class="prevent_default">'}else{list=list+'<span><ul>'}
var options=alloptions[key];$.each(options,function(optkey,optval){var attributes=options[optkey].attributes;list=list+'<li ';$.each(attributes,function(attrkey,attrval){list=list+attrkey+'="'+attributes[attrkey]+'" '});list=list+'class="'+options[optkey].class+'">'+options[optkey].option+'</li>'});list=list+'</ul></span>'}
list=list+'</span></div>';list=list+'</div></li>'});if(append===1){$('.main .aside > .site_records > .records > .list').append(list).show()}else{if(!preloader_disabled){$('.main .aside > .site_records > .records > .list').css('opacity',0)}
$('.main .aside > .site_records > .records > .list').html(list).show()}
if(append===0&&load.attr('load')=='online'){update_wsocket_data()}
if(!$('.main .aside .selector.select_all').hasClass('d-none')){$('.main .aside .selector').removeClass('d-none')}}else{if(append==1){$('.main .aside > .site_records > .current_record').addClass('EndResults')}else{$('.main .aside > .site_records > .current_record > .selector').addClass('d-none');$('.main .aside > .site_records > .records > .zero_results').removeClass('d-none');$('.main .aside > .site_records > .records > .list').hide()}}
var tooltipTriggerList=[].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));var tooltipList=tooltipTriggerList.map(function(tooltipTriggerEl){return new bootstrap.Tooltip(tooltipTriggerEl)});$('.main .aside > .site_records > .current_record').removeClass('loading');$('.main .aside > .site_records > .records > .loader').removeClass('error').hide();if(!preloader_disabled){$('.main .aside > .site_records > .records > .list').animate({opacity:1},0)}}else{console.log('ERROR : '+data);if(!preloader_disabled&&append!==1){$('.main .aside > .site_records > .records > .list').html('');$('.main .aside > .site_records > .current_record').removeClass('loading');$('.main .aside > .site_records > .current_record > .title > div > .text').replace_text(language_string('error'));$('.main .aside > .site_records > .records > .on_error').removeClass('d-none');$('.main .aside > .site_records > .records > .loader').addClass('error').show()}}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){if(!preloader_disabled&&append!==1){$('.main .aside > .site_records > .records > .list').html('');$('.main .aside > .site_records > .current_record').removeClass('loading');$('.main .aside > .site_records > .records > .on_error').removeClass('d-none');$('.main .aside > .site_records > .current_record > .title > div > .text').replace_text(language_string('error'));$('.main .aside > .site_records > .records > .loader').addClass('error').show()}}})}}
$('body').on('click','.main .aside > .site_records > .current_record > .selector.select_all > input',function(e){$('.main .aside > .site_records > .records > .list > li > div > .selector.select_item > input').prop('checked',this.checked).change()});$('body').on('change','.main .aside > .site_records > .records > .list > li > div > .selector.select_item > input',function(e){if($(".main .aside > .site_records > .records > .list > li > div > .selector.select_item > input:checked").length>0){if($('.main .aside > .site_records > .tools').hasClass('d-none')){if($('.main .page_column[column="first"] .confirm_box').hasClass('d-none')){$('.main .aside > .site_records > .tools').removeClass('d-none')}}
$('.main .aside > .site_records > .tools > .multiple_selection').removeClass('d-none')}else{$('.main .aside > .site_records > .tools > .multiple_selection').addClass('d-none')}});$('body').on('click',".main .aside > .site_records > .records > .list > li",function(event){if(!$(event.target).hasClass('prevent_default')&&!$(event.target).parent().hasClass('prevent_default')){if(!$(this).find(".options > span").is(":visible")){$(".main .aside > .site_records > .records > .list > li > div > .right > .options > span").hide()}
if($(this).attr('stopPropagation')===undefined){$(this).find(".options").trigger('click')}}});$('body').on('click',".main .aside > .site_records > .current_record .toggle_checkbox",function(e){if($('.main .aside > .site_records > .records > .list > li > div > .selector').length>0){$('.main .aside > .site_records .selector').toggleClass('d-none')}
if($('.main .aside .selector.select_all').hasClass('d-none')){$('.main .aside .selector > input[type="checkbox"]').prop('checked',!1);$('.main .aside > .site_records > .tools > .multiple_selection').addClass('d-none')}});$('body').on('click',".main .aside > .site_records > .records > .list > li > div > .right > .options",function(e){if($(this).find("span").is(":visible")){$(".main .aside > .site_records > .records > .list > li > div > .right > .options > span").hide()}else{$(".main .aside > .site_records > .records > .list > li > div > .right > .options > span").hide();$(this).find("span").css('display','block')}});$("body").on('click','.main .aside > .site_records > .current_record > .title',function(e){if(!$('.main .aside > .site_records > .current_record').hasClass('loading')&&!$(this).find('div').hasClass('dropdown_button')||$(this).attr('disable_preloader')!==undefined){$('.main .aside > .site_records .record_info > .refresh_current_record').html('<span>Refresh</span>');$('.main .aside > .site_records .record_info > .refresh_current_record > span').addClass('load_aside');$('.main .aside > .site_records .record_info > .refresh_current_record > span').attr('load',$('.main .aside > .site_records > .current_record').attr('load'));if($(this).attr('filter_data')!==undefined){$('.main .aside > .site_records .record_info > .refresh_current_record > span').attr('filter','pending_approval');$('.main .aside > .site_records .record_info > .refresh_current_record > span').attr('skip_filter_title',!0)}
$(this).removeAttr('filter_data');if($('.main .aside > .site_records .record_info > .data_attributes > span').length>0){var append_data=$('.main .aside > .site_records .record_info > .data_attributes > span').data();$.each(append_data,function(index,data_item){var data_index='data-'+index;$('.main .aside > .site_records .record_info > .refresh_current_record > span').attr(data_index,append_data[index])})}
if($(this).attr('disable_preloader')!==undefined){$('.main .aside > .site_records .record_info > .refresh_current_record > span').attr('disable_preloader',!0)}
$('.main .aside > .site_records .record_info > .refresh_current_record > span').trigger('click')}});var video_preview=null;var group_header_contents=null;var load_group_header_request=null;var video_chat_available=!1;var videoChatStatusUpdateTimeoutId;var videoChatStatusUpdateRequest;var call_notification_timeout_id;var total_vc_users=0;var middle_panel_class=$('.main .middle').attr('class');function toggle_middle_full_screen(){if(!$('.main .middle').hasClass('middle_full_screen')){if($('.main .info_panel').hasClass('d-none')){$('.main .close_info_panel').trigger('click')}
if($('.main .formbox').hasClass('d-none')){$('.main .formbox > .bottom > span.cancel').trigger('click')}
if($('.main .chat_page_container').hasClass('show_navigation')){toggle_side_navigation()}
middle_panel_class=$('.main .middle').attr('class');$('.main .aside').addClass('d-none');$('.main .middle').attr('class','col-md-12 middle page_column col-lg-12 display_chat_alone middle_full_screen');$('.toggle_middle_full_screen > .svg_icon > svg:first').addClass('d-none');$('.toggle_middle_full_screen > .svg_icon > svg:eq(1)').removeClass('d-none')}else{$('.main .middle').attr('class',middle_panel_class);$('.main .aside').removeClass('d-none');$('.toggle_middle_full_screen > .svg_icon > svg:eq(1)').addClass('d-none');$('.toggle_middle_full_screen > .svg_icon > svg:first').removeClass('d-none')}}
$("body").on('click','.toggle_middle_full_screen',function(e){toggle_middle_full_screen()});$("body").on('click','.load_page',function(e){if(!$(this).hasClass('processing')){$(this).addClass('processing');open_column('second');var browser_title=default_meta_title;var browser_address_bar=baseurl;var element=$(this);if($(this).attr('loader')!==undefined){$($(this).attr('loader')).show()}
$('.main .middle > .content > div').addClass('d-none');$('.main .middle > .content > .custom_page').removeClass('d-none');$('.main .middle > .content > .custom_page > .page_content').hide();$('.main .middle > .content > .custom_page > .page_content > div').html('');var data={load:'custom_page_content',page_id:$(this).attr('page_id'),};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:data,async:!0,success:function(data){}}).done(function(data){if(data===''){location.reload(!0)}else if(isJSON(data)){data=$.parseJSON(data);if(data.browser_title!==undefined){browser_title=data.browser_title}
if(data.browser_address_bar!==undefined){browser_address_bar=data.browser_address_bar}
if(data.title!=undefined){$('.main .middle > .content > .custom_page > .header > .left > .title').replace_text(data.title)}
if(data.subtitle!=undefined){$('.main .middle > .content > .custom_page > .header > .left > .sub_title').replace_text(data.subtitle)}else{$('.main .middle > .content > .custom_page > .header > .left > .sub_title').replace_text('')}
if(data.page_content!=undefined){$('.main .middle > .content > .custom_page > .page_content > div').html(data.page_content);$('.main .middle > .content > .custom_page > .page_content').show()}}else{console.log('ERROR : '+data)}
if(element.attr('loader')!==undefined){$(element.attr('loader')).hide()}
element.removeClass('processing');change_browser_title(browser_title);history.pushState({},null,browser_address_bar)}).fail(function(qXHR,textStatus,errorThrown){if(element.attr('loader')!==undefined){$(element.attr('loader')).hide()}
element.removeClass('processing');console.log('ERROR : '+errorThrown)})}});$("body").on('click','.preview_pdf',function(e){var pdf_url=$(this).attr('pdf');generate_pdf_preview(pdf_url)});function generate_pdf_preview(pdf_url){if(new URL(pdf_url).hostname==='localhost'||new URL(pdf_url).hostname==='127.0.0.1'){console.log('The PDF URL is from localhost.')}else{pdf_url='https://docs.google.com/viewer?embedded=true&url='+pdf_url}
if($('#pdfModal').length===0){var content_modal='<div class="modal fade pdf_modal_box" id="pdfModal" tabindex="-1" role="dialog" aria-labelledby="pdfModalLabel" aria-hidden="true">'+'<div class="modal-dialog modal-dialog-centered" role="document">'+'<div class="modal-content">'+'<div class="modal-body">'+'<iframe src="'+pdf_url+'" width="100%" height="100%" style="border: none;"></iframe>'+'</div>'+'</div>'+'</div>'+'</div>';$('body').append(content_modal)}else{$('.pdf_modal_box .modal-body').html('<iframe src="'+pdf_url+'" width="100%" height="100%" style="border: none;"></iframe>')}
$('#pdfModal').modal('show')}
function fetch_user_info(user){return new Promise(function(resolve,reject){var data={fetch_info:!0,fetch:'site_user',user_id:user,};var userData={username:'unknown'};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:data,async:!0,success:function(data){if(isJSON(data)){userData=$.parseJSON(data);if(userData.username!==undefined){resolve(userData)}else{reject("Invalid User ID")}}else{reject("Invalid JSON format")}},error:function(qXHR,textStatus,errorThrown){console.log('ERROR : '+errorThrown);reject(errorThrown)}})})}
$("body").on('mouseenter','.main .chatbox > .header.view_info > .heading,.main .chatbox > .header.view_info > .image',function(e){if($(window).width()>767.98&&!$('.main .middle').hasClass('display_chat_alone')){$('.main .chatbox > .header > .heading > .subtitle').hide();$('.main .chatbox > .header > .heading > .whos_typing').hide();$('.main .chatbox > .header > .heading > .view_info').fadeIn()}});$("body").on('mouseleave','.main .chatbox > .header.view_info > .heading,.main .chatbox > .header.view_info > .image',function(e){if($(window).width()>767.98&&!$('.main .middle').hasClass('display_chat_alone')){$('.main .chatbox > .header > .heading > .view_info').hide();$('.main .chatbox > .header > .heading > .subtitle').fadeIn();$('.main .chatbox > .header > .heading > .whos_typing').fadeIn()}});$("body").on('click','.main .open_wallet_topup',function(e){$(".wallet_topup_modal .manage_wallet_buttons > button").eq(0).trigger('click');$('#walletTopUpModal').modal('show')});$("body").on('click','.wallet_topup_modal .manage_wallet_buttons > button',function(e){$(".wallet_topup_modal .modal-body>form .error").hide();var wallet_element=$(this).attr('element');$('.wallet_elements').hide();$('.wallet_elements.'+wallet_element+'_element').show()});$("body").on('click','.call_notification > .action-buttons > .action-button.reject_video_call',function(e){if(!$('.call_notification .call_ringtone')[0].paused){$('.call_notification .call_ringtone')[0].pause();$('.call_notification .call_ringtone')[0].currentTime=0}
var post_data={update:'video_chat_status',call_log_delete:!0};if($('.call_notification > .action-buttons > .action-button.attend_video_call').hasClass('audio_only_chat')){post_data.audio_only_chat=!0}
$.ajax({type:'POST',url:api_request_url,data:post_data,async:!0,success:function(response){setTimeout(function(){$('.call_notification').attr('current_call_id',0)},1000)},error:function(xhr,status,error){}});if(call_notification_timeout_id){clearTimeout(call_notification_timeout_id)}
$('.call_notification').addClass('d-none')});$("body").on('click','.call_notification > .action-buttons > .action-button.attend_video_call',function(e){if(call_notification_timeout_id){clearTimeout(call_notification_timeout_id)}
if(!$('.call_notification .call_ringtone')[0].paused){$('.call_notification .call_ringtone')[0].pause();$('.call_notification .call_ringtone')[0].currentTime=0}
$('.call_notification').addClass('d-none')});$("body").on('click','.main .middle > .video_chat_interface > .video_chat_container .toggle_video_chat_settings',function(e){$('.main .middle > .video_chat_interface > .video_chat_settings_box').removeClass('d-none')});$("body").on('click','.main .middle > .video_chat_interface > .video_chat_settings_box button.btn-close',function(e){$('.main .middle > .video_chat_interface > .video_chat_settings_box').addClass('d-none')});$("body").on('click','.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid > div',function(e){var flexItems=$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid > div');var itemCount=flexItems.length;if(!$(e.target).hasClass('get_info')){if(itemCount>=2||$('.main .middle > .video_chat_interface > .video_chat_container').hasClass('full_view_container')){$('.main .middle > .video_chat_interface > .video_chat_container').addClass('full_view_container');if($('.video_chat_container.full_view_container > .video_chat_full_view > div').length>0){$('.video_chat_container.full_view_container > .video_chat_full_view > div').appendTo('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid')}
$(this).appendTo('.main .middle > .video_chat_interface > .video_chat_container.full_view_container > .video_chat_full_view')}}});$("body").on('click','.video_chat_container.full_view_container > .video_chat_full_view > div',function(e){if(!$(e.target).hasClass('get_info')){if($('.video_chat_container.full_view_container > .video_chat_full_view > div').length>0){$('.video_chat_container.full_view_container > .video_chat_full_view > div').appendTo('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid')}
$('.main .middle > .video_chat_interface > .video_chat_container').removeClass('full_view_container')}});function initilazing_video_chat(){close_chat_header_window('all');$('.main .middle > .video_chat_interface > .video_chat_container').removeClass('full_view_container');if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}
if(audio_player!==undefined&&audio_player!==null){audio_player_handler('pause')}}
function call_notification_timeout(todo){if(todo=='start'){call_notification_timeout_id=setTimeout(function(){if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){if($('.main .chatbox').attr('user_id')!==undefined){current_video_caller_id=$('.main .chatbox').attr('user_id')}else{current_video_caller_id=0}}
if(!$('.call_notification .call_ringtone')[0].paused){$('.call_notification .call_ringtone')[0].pause();$('.call_notification .call_ringtone')[0].currentTime=0}
if(current_video_caller_id==0||current_video_caller_id!==$('.call_notification').attr('current_call_id')){$('.call_notification > .action-buttons > .action-button.reject_video_call').trigger('click')}
$('.call_notification').addClass('d-none')},25000)}else{if(!$('.call_notification .call_ringtone')[0].paused){$('.call_notification .call_ringtone')[0].pause();$('.call_notification .call_ringtone')[0].currentTime=0}
if(call_notification_timeout_id){clearTimeout(call_notification_timeout_id)}
$('.call_notification').addClass('d-none')}}
function arrange_video_chat_grid(){var flexItems=$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid > div');var itemCount=flexItems.length;$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid').removeClass('grid_one grid_two grid_three');if(itemCount>=10){$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid').addClass('grid_three')}else if(itemCount>=8){$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid').addClass('grid_two')}else if(itemCount>=5){$('.main .middle > .video_chat_interface > .video_chat_container > .video_chat_grid').addClass('grid_one')}}
function update_video_chat_status(){if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){var post_data={update:'video_chat_status',};if(current_video_chat_id!==null){if(current_video_chat_type==='group'){post_data.group_id=current_video_chat_id}else if(current_video_chat_type==='private_chat'){post_data.user_id=current_video_chat_id}}else if($('.main .chatbox').attr('group_id')!==undefined){post_data.group_id=$('.main .chatbox').attr('group_id')}else if($('.main .chatbox').attr('user_id')!==undefined){post_data.user_id=$('.main .chatbox').attr('user_id')}
if($('.main .middle > .video_chat_interface').hasClass('audio_only_chat')){post_data.audio_only_chat=!0}
videoChatStatusUpdateRequest=$.ajax({type:'POST',url:api_request_url,data:post_data,async:!0,beforeSend:function(){if(videoChatStatusUpdateRequest){videoChatStatusUpdateRequest.abort()}
if(videoChatStatusUpdateTimeoutId){clearTimeout(videoChatStatusUpdateTimeoutId)}},success:function(response){},error:function(xhr,status,error){},complete:function(){videoChatStatusUpdateTimeoutId=setTimeout(update_video_chat_status,30000)}})}}
function stop_update_video_chat_status(){if(videoChatStatusUpdateRequest){videoChatStatusUpdateRequest.abort()}
if(videoChatStatusUpdateTimeoutId){clearTimeout(videoChatStatusUpdateTimeoutId)}
var post_data={update:'video_chat_status',offline:!0};if(current_video_chat_id!==null){if(current_video_chat_type==='group'){post_data.group_id=current_video_chat_id}else if(current_video_chat_type==='private_chat'){post_data.user_id=current_video_chat_id}}else if($('.main .chatbox').attr('group_id')!==undefined){post_data.group_id=$('.main .chatbox').attr('group_id')}else if($('.main .chatbox').attr('user_id')!==undefined){post_data.user_id=$('.main .chatbox').attr('user_id');if($('.call_notification').attr('current_call_id')==$('.main .chatbox').attr('user_id')){return}}
post_data.total_vc_users=total_vc_users;if($('.main .middle > .video_chat_interface').hasClass('audio_only_chat')){post_data.audio_only_chat=!0}
$.ajax({type:'POST',url:api_request_url,data:post_data,async:!0,success:function(response){update_wsocket_data()},error:function(xhr,status,error){}})}
$("body").on('click','.toggle_search_messages',function(e){if($('.main .middle .search_messages').is(':visible')){$('.main .middle .search_messages').hide()}else{$('.main .chatbox > .header > .switch_user').removeClass('open');$('.main .middle .search_messages').fadeIn();$('.main .middle .search_messages > div > .search > div > input').trigger('focus')}});$("body").on('click','.main .middle > .video_preview .close_player',function(e){close_chat_header_window('video_preview')});$("body").on('click','.main .middle > .iframe_window .close_iframe_window',function(e){close_chat_header_window('iframe_window')});$("body").on('click','.main .middle > .group_headers .close_group_header',function(e){close_chat_header_window('group_header')});function close_chat_header_window(window){if(window==='video_preview'||window==='all'){$('.main .middle > .video_preview').removeClass('fixed_draggable_layout');$('.main .middle > .video_preview').addClass('d-none');$('.main .middle > .video_preview > div').html('');if($('.main .middle > .group_headers').hasClass('header_content_loaded')){$('.main .middle > .group_headers').removeClass('d-none');$('.main .middle > .group_headers > .header_content').html(group_header_contents)}}
if(window==='group_header'||window==='all'){group_header_contents=null;$('.main .middle > .group_headers > .header_content').html('');$('.main .middle > .group_headers').removeClass('header_content_loaded');$('.main .middle > .group_headers').addClass('d-none')}
if(window==='iframe_window'||window==='all'){$('.main .middle > .iframe_window').addClass('d-none');$('.main .middle > .iframe_window > div').html('');if($('.main .middle > .group_headers').hasClass('header_content_loaded')){$('.main .middle > .group_headers').removeClass('d-none');$('.main .middle > .group_headers > .header_content').html(group_header_contents)}}}
$("body").on('mouseenter','.main .chatbox > .contents > .chat_messages > ul > li > div >.right > .header > .tools > .timestamp',function(e){$('.main .chatbox > .contents > .date').hide();if($(this).parents('.message').find('.date').attr('message_sent_on')!==undefined){var message_sent_on=$(this).parents('.message').find('.date').attr('message_sent_on');$('.main .chatbox > .contents > .date > span').text(message_sent_on);$('.main .chatbox > .contents > .date').show()}});$("body").on('mouseleave','.main .chatbox > .contents > .chat_messages > ul > li > div >.right > .header > .tools > .timestamp',function(e){$('.main .chatbox > .contents > .date').hide()});function getYTPlaylistId(url){try{const urlObj=new URL(url);const isPlaylist=urlObj.hostname.includes('youtube.com')&&urlObj.pathname==='/playlist';const playlistId=urlObj.searchParams.get('list');return isPlaylist&&playlistId?playlistId:null}catch(e){return null}}
$("body").on('click','.preview_video',function(e){$('.main .middle > .iframe_window').addClass('d-none');$('.main .middle > .iframe_window > div').html('');$('.main .middle > .group_headers').addClass('d-none');$('.main .middle > .group_headers > .header_content').html('');$('.main .middle > .video_preview').addClass('d-none');$('.main .middle > .video_preview > div').html('');$('.main .middle > .video_preview').removeAttr("style");$('.main .middle > .video_preview').removeClass('fixed_draggable_layout');if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){$('.main .middle > .video_preview').addClass('fixed_draggable_layout')}
var content='';if($(this).attr('video_file')!==undefined){if($(this).attr('mime_type')===undefined){$(this).attr('mime_type','')}
if($(this).attr('thumbnail')===undefined){$(this).attr('thumbnail','')}
content+='<video id="video_preview" class="video-js vjs-theme-city" autoplay playsinline controls poster="'+$(this).attr('thumbnail')+'">';content+='<source src="'+$(this).attr('video_file')+'" type="'+$(this).attr('mime_type')+'" />';content+='</video>'}else if($(this).attr('video_url')!==undefined){content+='<video id="video_preview" class="video-js vjs-theme-city" autoplay playsinline controls poster="'+$(this).attr('thumbnail')+'">';content+='</video>'}
if(content.length!==0){open_column('second');$('.main .middle > .video_preview > div').html('');$('.main .middle > .video_preview').removeClass('d-none');$('.main .middle > .video_preview > div').html(content);fixed_layout_draggable();if(video_preview!==null){videojs('video_preview').dispose()}
if($(this).attr('video_url')===undefined){video_preview=videojs('video_preview')}else{var video_provider=($(this).attr('mime_type')).replace("video/","");var video_muted=!1;if(window.self!==window.top){video_muted=!0}
var this_video_url=$(this).attr('video_url');var this_mime_type=$(this).attr('mime_type');var vjs_options={controls:!0,muted:video_muted,sources:[{src:this_video_url,type:this_mime_type}],techOrder:[video_provider]};video_preview=videojs('video_preview',vjs_options)}
video_preview.on('play',()=>{if(video_preview.muted()){video_preview.muted(!1)}
if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}
if(audio_player!==undefined&&audio_player!==null){audio_player_handler('pause')}})}});function load_group_header(group_identifier){if(group_identifier!==undefined){var data={load:'group_header',group_id:group_identifier,skip_output:!0};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
load_group_header_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_group_header_request!=null){load_group_header_request.abort();load_group_header_request=null}},success:function(data){}}).done(function(data){if($.trim(data)!==''){group_header_contents=data;$('.main .middle > .group_headers > .header_content').html(data);$('.main .middle > .group_headers').removeClass('d-none');$('.main .middle > .group_headers').addClass('header_content_loaded')}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+errorThrown)}})}}
$("body").on('click','.iframe_embed',function(e){if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){e.preventDefault();window.open($(this).attr('embed_url'),'_blank');return}
if(video_preview!==undefined&&video_preview!==null){video_preview.pause()}
if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}
if(audio_player!==undefined&&audio_player!==null){audio_player_handler('pause')}
$('.main .middle > .video_preview').addClass('d-none');$('.main .middle > .video_preview > div').html('');$('.main .middle > .group_headers').addClass('d-none');$('.main .middle > .group_headers > .header_content').html('');$('.main .middle > .iframe_window > div').html('<iframe></iframe>');$('.main .middle > .iframe_window > div > iframe').attr('frameborder',0);$('.main .middle > .iframe_window > div > iframe').attr('allowFullScreen',!0);$('.main .middle > .iframe_window > div > iframe').attr('webkitallowfullscreen',!0);$('.main .middle > .iframe_window > div > iframe').attr('mozallowfullscreen',!0);$('.main .middle > .iframe_window > div > iframe').attr('src',$(this).attr('embed_url'));if($(this).attr('iframe_class')!==undefined){$('.main .middle > .iframe_window > div > iframe').addClass($(this).attr('iframe_class'))}
if($(this).attr('iframe_relative_height')!==undefined){$('.main .middle > .iframe_window').css('position','relative');$('.main .middle > .iframe_window').css('height',$(this).attr('iframe_relative_height'))}else{$('.main .middle > .iframe_window').removeAttr('style')}
$('.main .middle > .iframe_window').removeClass('d-none')});var load_form_request=null;var code_editor_form=[];$.fn.replace_text=function(text){if(typeof text!=='string'){text=String(text)}
text=decode_specialchars(text);this.text(text);return this}
function decode_specialchars(text){const entityMap={'&amp;':'&','&lt;':'<','&gt;':'>','&quot;':'"','&#039;':"'"};return text.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g,function(match){return entityMap[match]})}
$('body').on('keydown','.main .formbox > .fields > div > form > .formdata > .field > input',function(event){if(event.which===13){$('.main .formbox > .bottom > span.submit').trigger('click');event.preventDefault()}});$('body').on('click','.load_form',function(e){if($(this).attr('form')!==undefined){if($(window).width()<767.98){$('.main .chat_page_container').removeClass('show_navigation')}
open_column('third');var load={form:$(this).attr('form')};load=$.extend(load,$(this).data());if($(this).attr('enlarge')!==undefined){load_form(load,!0)}else{load_form(load)}}});$('body').on('change','.main .formbox .switch_form',function(e){if($(this).attr('form')!==undefined){var load={form:$(this).attr('form')};var field_name=$(this).find('select').attr('name');load[field_name]=$(this).find('select').val();if($(this).attr('pass_field_values')!==undefined){var field_name=$(this).attr('pass_field_values');load[field_name]=$(this).parent().find('.field > select[name="'+field_name+'"]').val()}
load=$.extend(load,$(this).data());if($(this).attr('enlarge')!==undefined){load_form(load,!0)}else{load_form(load)}}});$('body').on('change','.main .formbox .field > select.preview_audio_file',function(e){var audio_file_location=$(this).attr('audio_location');audio_file_location=audio_file_location+$(this).val();$('.main .formbox > .form_audio_preview > div').html('');$("<audio></audio>").attr({'src':audio_file_location,'type':'audio/mpeg',}).appendTo('.main .formbox > .form_audio_preview > div');var form_audio_preview=$('.main .formbox > .form_audio_preview > div > audio')[0];form_audio_preview.play()});function load_form(load,enlarge){var loader_content='';if(load!==undefined){$('.main .middle').removeClass('col-lg-9');$('.main .middle').removeClass('col-lg-6');$('.main .middle').removeClass('col-lg-5');if($('.main .middle').hasClass('display_chat_alone')){$('.main .middle').removeClass('col-lg-12')}
if($(window).width()>767.98){$('.main .info_panel').addClass('d-none')}
$('.main .formbox').removeClass('col-lg-3');$('.main .formbox').removeClass('col-lg-4');if($('.main .middle').hasClass('display_chat_alone')){if(enlarge!==undefined){$('.main .middle').addClass('col-lg-8');$('.main .formbox').addClass('col-lg-4')}else{$('.main .middle').addClass('col-lg-9');$('.main .formbox').addClass('col-lg-3')}}else{if(enlarge!==undefined){$('.main .middle').addClass('col-lg-5');$('.main .formbox').addClass('col-lg-4')}else{$('.main .middle').addClass('col-lg-6');$('.main .formbox').addClass('col-lg-3')}}
$('.main .formbox').removeClass('d-none');$(".main .formbox").addClass('processing');$(".main .formbox > .fields > div > .error").text('').hide();for(let i=0;i<10;i++){loader_content+='<div class="field loading">';loader_content+='<label>Loading</label>';loader_content+='<input name="loader" type="text" autocomplete="off">';loader_content+='</div>'}
$(".main .formbox > .fields > div > form > .formdata").html(loader_content);$(".main .formbox > .head > .title").replace_text(language_string('loading'));$(".main .formbox > .bottom > span.submit").replace_text(language_string('loading'));$(".main .formbox > .bottom > span.submit").show();if(user_csrf_token!==null){load.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){load.login_session_id=user_login_session_id;load.access_code=user_access_code;load.session_time_stamp=user_session_time_stamp}
load_form_request=$.ajax({type:'POST',url:api_request_url,data:load,async:!0,beforeSend:function(){if(load_form_request!=null){load_form_request.abort();load_form_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);var form='';var fields=data.fields;if(Object.keys(data).length>0){if(data.loaded!==undefined){$(".main .formbox > .head > .title").replace_text(data.loaded.title);if(data.loaded.button!==undefined){$(".main .formbox > .bottom > span.submit").replace_text(data.loaded.button)}else{$(".main .formbox > .bottom > span.submit").hide()}}
$.each(fields,function(key,val){field=fields[key];if(field.clone_field_on_input!==undefined){field.class=field.class+' clone_field_on_input'}
var attributes=attribute=selected='';var parent_attributes='class="'+field.class+'" ';if(field.attributes!==undefined){$.each(field.attributes,function(attrkey,attrval){attributes=attributes+attrkey+'="'+attrval+'" '})}
if(field.type!==undefined&&field.type=='color'){parent_attributes='class="'+field.class+' input-group color_picker" ';attributes=attributes+'class="form-control input-lg" '}
if(field.clone_field_on_input!==undefined){parent_attributes=parent_attributes+' name="'+key+'" '}
if(field.child_fields!==undefined){var child_field_index=1;attributes=attributes+'child_fields="';$.each(field.child_fields,function(parent_field_name,child_fields){if(child_field_index!==1){attributes=attributes+','}
attributes=attributes+parent_field_name+'|'+child_fields;child_field_index++});attributes=attributes+'" '}
if(field.parent_attributes!==undefined){$.each(field.parent_attributes,function(attrkey,attrval){parent_attributes=parent_attributes+attrkey+'="'+attrval+'" '})}
if(field.placeholder!==undefined){attribute='placeholder="'+field.placeholder+'"'}
if(field.value!==undefined){attribute='value="'+field.value+'"'}else if(field.accept!==undefined){attribute='accept="'+field.accept+'"'}
form=form+'<div '+parent_attributes+'>';if(field.title!==undefined){form=form+'<label>'+field.title;if(field.required!==undefined){form=form+'<i class="required">*</i>'}
if(field.infotip!==undefined){form=form+'<i class="form-infotip bi bi-info-circle-fill" data-bs-toggle="tooltip" title="'+field.infotip+'"></i>'}
form=form+'</label>'}
if(field.clone_field_on_input!==undefined){if(field.values!==undefined){var extra_clone_field=!1;$.each(field.values,function(clone_field_key,clone_field_value){extra_clone_field=!0;form=form+'<input name="'+key+'[]" value="'+clone_field_value+'" type="'+field.type+'" '+attribute+' '+attributes+' autocomplete="off"/>'});if(extra_clone_field){form=form+'<input name="'+key+'[]" type="'+field.type+'" '+attribute+' '+attributes+' autocomplete="off"/>'}}else{form=form+'<input name="'+key+'[]" type="'+field.type+'" '+attribute+' '+attributes+' autocomplete="off"/>'}}else if(field.tag=='input'&&field.type=='date'||field.tag=='input'&&field.type=='datetime-local'){form=form+'<input type="'+field.type+'" name="'+key+'" '+attribute+' '+attributes+' autocomplete="off"/>';form=form+'<span class="date_selector">';form=form+'<i class="bi bi-calendar-plus"></i>';form=form+'</span>'}else if(field.tag=='paragraph'){form=form+'<span class="paragraph_field">';form=form+'<p>'+field.text+'</p>';form=form+'</span>'}else if(field.tag=='link'){if(field.link_target==undefined){field.link_target=''}else{field.link_target='target="'+field.link_target+'"'}
form=form+'<span class="link_field">';form=form+'<a href="'+field.link+'" '+field.link_target+'>'+field.text+'</a>';form=form+'</span>'}else if(field.tag=='input'&&field.type=='file'){if(field.multi_select!==undefined){key=key+'[]';attribute=attribute+' multiple'}
form=form+'<span class="selector">';form=form+'<input type="file" name="'+key+'" '+attribute+'/>';form=form+'<span class="file-browse"><span>'+language_string('choose_file')+'</span><i class="bi bi-folder"></i></span>';form=form+'</span>'}else if(field.tag=='checkbox'){form=form+'<div class="checkbox">';$.each(field.options,function(optkey,optval){var option=field.options[optkey];selected='';if(field.optionkey!==undefined&&field.optionkey=='optionvalue'){optkey=optval}
if(field.values===undefined){if(field.value!==undefined){try{field.values=JSON.parse(field.value)}catch(e){field.values=field.value}}}
if(field.values!==undefined){if(!Array.isArray(field.values)&&field.values!==""){field.values=[field.values];field.values=field.values.map(value=>String(value))}
if(Array.isArray(field.values)&&(field.values).includes(optkey)){selected="checked"}}else if(field.select_all!==undefined){selected="checked"}
form=form+'<label>';form=form+'<span class="checkbox">';form=form+'<input type="checkbox" name="'+key+'[]" '+selected+' value="'+optkey+'"/>';form=form+'<span class="checkmark"></span>';form=form+'</span>';form=form+'<span class="checkbox_label">'+optval+'</span>';form=form+'</label>'});form=form+'</div>'}else if(field.tag=='select'){form=form+'<select name="'+key+'" autocomplete="off" '+attributes+'>';form=form+'<option value="">-------</option>';$.each(field.options,function(optkey,optval){var option=field.options[optkey];selected='';if(field.optionkey!==undefined&&field.optionkey=='optionvalue'){optkey=optval}
if(field.value!==undefined&&field.value==optkey){selected="selected"}
form=form+'<option '+selected+' value="'+optkey+'">'+optval+'</option>'});form=form+'</select>'}else if(field.tag=='image_list'){form=form+'<div class="image_list" '+attributes+'><div><ul>';$.each(field.options,function(optkey,optval){form=form+'<li>';form=form+'<input type="radio" name="'+key+'" value="'+optkey+'"/>';form=form+'<img src="'+optval+'"/>';form=form+'</li>'});form=form+'</ul></div></div>'}else if(field.closetag!==undefined&&field.closetag==!0||field.tag=='textarea'){if(field.placeholder==undefined){attribute=''}
if(field.value==undefined){field.value=''}else{attribute=''}
form=form+'<'+field.tag+' name="'+key+'" '+attribute+' '+attributes+' autocomplete="off">'+field.value+'</'+field.tag+'>'}else{var color_picker=!1;if(field.type!==undefined&&field.type=='color'){field.type='text';color_picker=!0;form=form+'<div class="color_selector">'}
form=form+'<'+field.tag+' name="'+key+'" type="'+field.type+'" '+attribute+' '+attributes+' autocomplete="off"/>';if(color_picker){form=form+'<span class="input-group-append">';form=form+'<span class="input-group-text colorpicker-input-addon"><i></i></span>';form=form+'</span>';form=form+'</div>'}}
form=form+'</div>'});$(".main .formbox > .fields > div > form > .formdata").html(form)}
adjust_form_textarea();append_color_picker();$(".main .formbox .toggle_form_fields > select").trigger('change');$(".main .formbox > .fields").scrollTop(0);$("[data-bs-toggle=tooltip]").tooltip();$(".main .formbox > .fields > div > form > .formdata > .filebrowse > .selector > input").hide();$(".main .formbox").removeClass('processing')}else{console.log('ERROR : '+data);$(".main .formbox").addClass('error');$(".main .formbox > .head > .title").replace_text(language_string('error'))}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){$(".main .formbox").addClass('error');$(".main .formbox > .head > .title").replace_text(language_string('error'))}})}}
function append_color_picker(){$(".main .formbox > .fields > div > form > .formdata > .color_picker").each(function(){$(this).colorpicker({autoInputFallback:!1})})}
function adjust_form_textarea(){$(".main .formbox > .fields > div > form > .formdata textarea").each(function(){if($(this).attr("rows")==undefined){$(this).css("height","auto");var scrollHeight=$(this).prop('scrollHeight');$(this).css("height",(scrollHeight+10)+"px")}
if($(this).parent().hasClass("content_editor")){var content_editor=$(this);var editor_toolbar=[['style',['bold','italic','underline','clear']],['color',['forecolor','backcolor']],['para',['ul','ol','paragraph']],['height',['height']]['table',['table']],['insert',['link','picture','video','table']],['view',['fullscreen','codeview']],];var editor_popover={image:[['custom',['imageAttributes']],['imagesize',['imageSize100','imageSize50','imageSize25']],['float',['floatLeft','floatRight','floatNone']],['remove',['removeMedia']]],};if($(this).parent().hasClass("tiny_toolbar")){var editor_toolbar=[['style',['bold','italic','underline']],['para',['ul','ol']],];var editor_popover={image:[],}}
$(this).summernote({toolbar:editor_toolbar,popover:editor_popover,minHeight:300,codeviewFilter:!1,tooltip:!1,dialogsInBody:!0,imageAttributes:{icon:'<i class="note-icon-pencil"/>',disableUpload:!0},callbacks:{onInit:function(e){let buttons=$('.main .formbox > .fields > div > form > .formdata .note-editor button[data-toggle="dropdown"]');buttons.each((key,value)=>{$(value).on('click',function(e){$(this).closest('.note-btn-group').toggleClass('open')})})},}})}else if($(this).parent().hasClass("code_editor")){var code_editor_id="form_code_editor";var code_editor_mode="application/x-httpd-php";if($(this).attr("code_editor_id")!==undefined){code_editor_id=$(this).attr("code_editor_id")}
if($(this).attr("code_editor_mode")!==undefined){code_editor_mode=$(this).attr("code_editor_mode")}
if($(this).parent().hasClass("d-none")){$(this).parent().removeClass("d-none");$(this).parent().addClass("code-editor-d-none")}
code_editor_form[code_editor_id]=CodeMirror.fromTextArea(document.getElementById(code_editor_id),{lineNumbers:!0,lineWrapping:!0,theme:"dracula",mode:code_editor_mode,});if($(this).parent().hasClass("code-editor-d-none")){$(this).parent().addClass("d-none");$(this).parent().removeClass("code-editor-d-none")}}})}
$(document).on('click','.main .formbox .selectinput > input',function(){this.setSelectionRange(0,this.value.length)});$(document).on('keypress','.main .formbox .selectinput > input',function(e){e.preventDefault()});$('body').on('keypress','.main .formbox .clone_field_on_input > input',function(e){var field_name=$(this).attr('name');var existingClone=$(".main .formbox .clone_field_on_input > input[name='"+field_name+"']:last");if(existingClone.length===0||existingClone.val()!==""){var originalDiv=$(this);var clonedDiv=originalDiv.clone();clonedDiv.val("");clonedDiv.appendTo($(this).parent())}});$('body').on('click','.main .formbox > .bottom > .submit',function(e){e.preventDefault();if(!$(".main .formbox").hasClass('processing')){$(".main .formbox").addClass('processing');$('.main .formbox .selectinput > input').val('');$(".main .formbox > .fields > div > .error").text('').hide();$('.main .formbox > .fields > div > form > .formdata .error').removeClass('error');form_base64('encode');var data=new FormData($('.main .formbox > .fields > div > form.dataform')[0]);if($(".main .formbox > .fields > div > form > .formdata > .filebrowse > .selector > .multifiles").length){var multifiles=$(".main .formbox > .fields > div > form > .formdata > .filebrowse > .selector > .multifiles").get(0).files;for(var i=0;i<multifiles.length;i++){data.append("multifiles["+i+"]",multifiles[i])}}
if($(".main .formbox > .fields > div > form > .formdata > .field.content_editor").length){var content_editor_contents=$(".main .formbox > .fields > div > form > .formdata > .field.content_editor > textarea");var content_editor_name=content_editor_contents.attr('name');data.append(content_editor_name,$(content_editor_contents).summernote('code'))}
if($(".main .formbox > .fields > div > form > .formdata > .field.code_editor").length){var code_editor_id="form_code_editor";$(".main .formbox > .fields > div > form > .formdata > .field.code_editor").each(function(){if($(this).find('textarea').attr("code_editor_id")!==undefined){code_editor_id=$(this).find('textarea').attr("code_editor_id")}
var code_editor_contents=$(this).find('textarea');var code_editor_name=code_editor_contents.attr('name');var code_editor_contents=code_editor_form[code_editor_id].getValue();data.append(code_editor_name,code_editor_contents)})}
if(user_csrf_token!==null){data.append("csrf_token",user_csrf_token)}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.append("login_session_id",user_login_session_id);data.append("access_code",user_access_code);data.append("session_time_stamp",user_session_time_stamp)}
$.ajax({url:api_request_url,dataType:'text',cache:!1,contentType:!1,processData:!1,async:!0,data:data,type:'post',success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data===null){window.location.href=baseurl}else{if(data.success){if(data.alert_message!==undefined){alert(decode_specialchars(data.alert_message))}
if(data.force_reload_aside!==undefined){$('.main .aside > .site_records > .current_record').attr('load',data.force_reload_aside);$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');if(data.filter_data!==undefined){$(".main .aside > .site_records > .current_record > .title").attr('filter_data',data.filter_data)}
$(".main .aside > .site_records > .current_record > .title").trigger('click')}
if(data.todo=='reload'){if(data.reload!==undefined&&$.isArray(data.reload)){if(jQuery.inArray($('.main .aside > .site_records > .current_record').attr('load'),data.reload)!==-1){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');$(".main .aside > .site_records > .current_record > .title").trigger('click')}}else if(data.reload!==undefined&&$('.main .aside > .site_records > .current_record').attr('load')===data.reload){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');$(".main .aside > .site_records > .current_record > .title").trigger('click')}
$(".main .formbox > .bottom > span.cancel").trigger('click')}else if(data.todo=='redirect'){window.location.href=data.redirect}else if(data.todo=='refresh'){if(data.on_refresh!==undefined){data.on_refresh=JSON.stringify(data.on_refresh);WebStorage('set','load_on_refresh',data.on_refresh)}
location.reload(!0)}else if(data.todo=='consolelog'&&data.log!==undefined){console.log(data.log)}else if(data.todo=='load_aside'||data.todo=='load_form'){if(data.attributes!==undefined){var ls_attributes='';$.each(data.attributes,function(attr_key,attr_val){ls_attributes=ls_attributes+attr_key+'="'+attr_val+'" '});var load_aside_trigger='<div class="'+data.todo+'" '+ls_attributes+'>load_aside</div>';$('.main .create_ajx_request').html(load_aside_trigger);$('.main .create_ajx_request > div').trigger('click')}}else if(data.todo=='load_conversation'){if(data.reload_aside!==undefined&&$('.main .aside > .site_records > .current_record').attr('load')==='groups'){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');$(".main .aside > .site_records > .current_record > .title").trigger('click')}
var load_data=[];load_data[data.identifier_type]=data.identifier;load_conversation(load_data)}}else{var error_message=language_string('error')+' : '+data.error_message;$(".main .formbox > .fields > div > .error").replace_text(error_message).fadeIn();if(data.error_variables!==undefined){$.each(data.error_variables,function(key,val){$('.main .formbox > .fields > div > form > .formdata [name="'+val+'"]').addClass('error');$('.main .formbox > .fields > div > form > .formdata [name="'+val+'"]').parent().find('.file-browse').addClass('error')});if(data.error_variables[0]!==undefined&&$('.main .formbox > .fields > div > form > .formdata [name="'+data.error_variables[0]+'"]').length>0){$(".main .formbox > .fields").animate({scrollTop:$('.main .formbox > .fields > div > form > .formdata [name="'+data.error_variables[0]+'"]').position().top-50},500)}}else{$(".main .formbox > .fields").scrollTop(0)}}}}else{console.log('ERROR : '+data)}
form_base64('decode');$(".main .formbox").removeClass('processing')}).fail(function(qXHR,textStatus,errorThrown){$(".main .formbox").removeClass('processing');form_base64('decode')})}});function form_base64($todo='encode'){var result;$('.main .formbox > .fields > div > form > .formdata > .field.base_encode').each(function(){if($(this).find('input').length!=0){if($todo=='encode'){result=b64EncodeUnicode($(this).find('input').val())}else{result=b64DecodeUnicode($(this).find('input').val())}
$(this).find('input').val(result)}else if($(this).find('textarea').length!=0){if($todo=='encode'){result=b64EncodeUnicode($(this).find('textarea').val())}else{result=b64DecodeUnicode($(this).find('textarea').val())}
$(this).find('textarea').val(result)}})}
function b64EncodeUnicode(str){return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,function toSolidBytes(match,p1){return String.fromCharCode('0x'+p1)}))}
function b64DecodeUnicode(str){return decodeURIComponent(atob(str).split('').map(function(c){return'%'+('00'+c.charCodeAt(0).toString(16)).slice(-2)}).join(''))}
$('body').on('click','.main .formbox > .fields > div > form >.formdata > .filebrowse > .selector > span',function(e){if($(e.target).hasClass('bi-x-lg')){$(this).parent().find('input').val('');$(this).find('span').replace_text(language_string('choose_file'));$(this).find('i').removeClass('bi-x-lg');$(this).find('i').addClass('bi-folder')}else{$(this).parent().find('input').trigger('click')}});$('body').on('click','.main .formbox > .fields > div > form > .formdata > .field > .colorpickicon',function(){$(this).parent().find('.colorpick').focus()});$('body').on('change','.main .formbox > .fields > div > form >.formdata > .filebrowse > .selector > input[type=file]',function(e){var filename=(e.target.files[0].name);if(filename.length>25){filename=(filename).substring(0,24)+"..."}
$(this).parent().find('span > span').text(filename);$(this).parent().find('span > i').removeClass('bi-folder');$(this).parent().find('span > i').addClass('bi-x-lg')});$('.main .formbox > .bottom > span.cancel').on('click',function(e){open_column('first',!0);$('.main .middle').removeClass('col-lg-5');$('.main .middle').removeClass('col-lg-6');if(!$('.main .middle').hasClass('display_chat_alone')){$('.main .middle').addClass('col-lg-9')}else{$('.main .middle').addClass('col-lg-12')}
if($(window).width()>767.98){$('.main .info_panel').addClass('d-none')}
$('.main .formbox').addClass('d-none')});$("body").on("change",".main .formbox .toggle_form_fields > select",function(e){var current_element=$(this);if(current_element.attr("child_fields")!==undefined){var show_fields=current_element.attr("child_fields").split(",")}else if(current_element.attr("show_fields")!==undefined){var show_fields=current_element.attr("show_fields").split(",")}else{var show_fields=[];$(this).find('option').each(function(){var show_option_val=$(this).val();if(show_option_val!==''&&show_option_val!==0){show_fields.push($(this).val()+'|'+$(this).val()+'_fields')}})}
var value_selected=current_element.val();var reset_value=!1;if(current_element.attr("reset_value")!==undefined){reset_value=!0}
if(current_element.attr("hide_field")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+current_element.attr("hide_field")).addClass('d-none')}
if(current_element.attr("common_field")!==undefined){if(value_selected!==''&&value_selected!==0){$('.main .formbox > .fields > div > form > .formdata > .field.'+current_element.attr("common_field")).removeClass('d-none')}}
if(show_fields!==undefined){var total_results_found=0;$.each(show_fields,function(index,value){var search_value=value.split("|");if(search_value[1]!==undefined&&search_value[1].length>0&&value_selected===search_value[0]){if(reset_value){$('.main .formbox > .fields > div > form > .formdata > .field.'+search_value[1]).find('select').prop('selectedIndex',0)}
if($('.main .formbox > .fields > div > form > .formdata > .field.'+search_value[1]).length>0){total_results_found=total_results_found+1}
$('.main .formbox > .fields > div > form > .formdata > .field.'+search_value[1]).removeClass('d-none')}});if(total_results_found===0){if(current_element.attr("other_cases")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+current_element.attr("other_cases")).removeClass('d-none')}}}});$("body").on("change",".main .formbox .showfieldon > select",function(e){var searcharray=$(this).attr("checkvalue").split(",");if(jQuery.inArray($(this).val(),searcharray)!==-1){$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")).removeClass('d-none');$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")+' input').prop('disabled',!1);$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")+' textarea').prop('disabled',!1);if($(this).attr("hideclass")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")).addClass('d-none');if($(this).attr("removefield_onsubmit")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")+' input').prop('disabled',!0);$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")+' textarea').prop('disabled',!0)}}}else{$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")).addClass('d-none');if($(this).attr("removefield_onsubmit")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")+' input').prop('disabled',!0);$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("fieldclass")+' textarea').prop('disabled',!0)}
if($(this).attr("hideclass")!==undefined){$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")).removeClass('d-none');$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")+' input').prop('disabled',!1);$('.main .formbox > .fields > div > form > .formdata > .field.'+$(this).attr("hideclass")+' textarea').prop('disabled',!1)}}});$('body').on('click','.main .formbox > .fields > div > form > .formdata > .field > .image_list > div > ul > li',function(e){if($(this).hasClass('selected')){$('.main .formbox > .fields > div > form > .formdata > .field > .image_list > div > ul > li').removeClass('selected');$(this).find('input').prop("checked",!1)}else{$('.main .formbox > .fields > div > form > .formdata > .field > .image_list > div > ul > li').removeClass('selected');$(this).find('input').prop("checked",!0);$(this).addClass('selected')}});$(document).on('click','.main .formbox .selectfield > input',function(){this.setSelectionRange(0,this.value.length)});$(document).on('keypress','.main .formbox .selectfield > input',function(e){e.preventDefault()});var load_audio_player_request=null;var audio_player=document.getElementById("audio_player");var audio_player_play_btn=$('.audio_player_controls > div > .controls > .play_btn > i');var audio_player_enabled=!1;var mini_audio_player_enabled=!1;var current_audio_subtitle_element='.audio_player_box > .header > .info > .currently_playing > .subtitle > span';var hls_audio_player;var current_audio_url=null;var mini_audio_player_play_btn=$('.main .aside > .mini_audio_player > div > .right > .controls > span.play_audio > i');var radio_now_playing_request=null;var radio_now_playing_timeout=null;if($('.audio_player_box > .header').length>0){audio_player_enabled=!0;current_audio_subtitle_element+=',.main .aside > .mini_audio_player > div > .center > .description > span'}
if($('.main .aside > .mini_audio_player').length>0){mini_audio_player_enabled=!0}
function audio_player_handler(action){var isHlsStream=$('.audio_player_controls > div > .controls > .play_btn').attr('hls_stream')==="1";if(action==='play'){if(current_audio_url===null){current_audio_url=$('.currently_playing > .audio_player_controls > audio').find('source').attr('src')}
if(isHlsStream&&current_audio_url!==null){(async()=>{if(!window.Hls){await import("https://cdn.jsdelivr.net/npm/hls.js@latest")}
if(Hls.isSupported()){if(hls_audio_player){hls_audio_player.destroy()}
hls_audio_player=new Hls();hls_audio_player.loadSource(current_audio_url);hls_audio_player.attachMedia(audio_player);hls_audio_player.on(Hls.Events.MANIFEST_PARSED,function(){audio_player.play()})}})()}else{audio_player.play()}}else if(action==='pause'){audio_player.pause();if(hls_audio_player){hls_audio_player.stopLoad();hls_audio_player.detachMedia();hls_audio_player.destroy();hls_audio_player=null}}else if(action==='load'){if(!isHlsStream){audio_player.load()}}}
$('.main').on('click','.load_audio_player',function(e){open_module('.audio_player_box','.main .aside',!0);open_column('first');if(mini_audio_player_enabled){$('.main .aside > .mini_audio_player').addClass('d-none')}
if(!$('.audio_player_box').hasClass('opened')||$(this).attr('audio_content_id')!==undefined||$(this).attr('refresh')!==undefined){var audio_content_id=null;if($(this).attr('audio_content_id')!==undefined){audio_content_id=$(this).attr('audio_content_id')}
load_audio_player(audio_content_id)}
if(!$('.audio_player_box').hasClass('opened')){$('.audio_player_box').addClass('opened');$('.audio_player_box > .header > .info > .currently_playing > .audio_player_controls > audio').hide();$(current_audio_subtitle_element).marquee({duration:12000,gap:50,delayBeforeStart:500,pauseOnHover:!0,direction:'left',startVisible:!0,duplicated:!0})}});$('.main').on('click','.mini_audio_player > div > .right > .controls > span',function(e){if(!$(".audio_player_box > .header").hasClass('d-none')){$total_tracks=$('.audio_player_box > .playlist > div > ul > li').length;if($(this).hasClass('play_audio')){$('.audio_player_box .currently_playing > .audio_player_controls > div > .controls > .play_btn').trigger('click')}else if($total_tracks==0){var audio_content_id=null;if($(this).parent().attr('audio_content_id')!==undefined){audio_content_id=$(this).parent().attr('audio_content_id')}
load_audio_player(audio_content_id,!0)}else if($(this).hasClass('prev_track')){$('.audio_player_box .currently_playing > .audio_player_controls > div > .controls > .previous_audio').trigger('click')}else if($(this).hasClass('next_track')){$('.audio_player_box .currently_playing > .audio_player_controls > div > .controls > .next_audio').trigger('click')}}else{var audio_content_id=null;if($(this).parent().attr('audio_content_id')!==undefined){audio_content_id=$(this).parent().attr('audio_content_id')}
load_audio_player(audio_content_id,!0)}});$('.main').on('input','.audio_player_range_control',function(e){$(this).css('background','linear-gradient(to right, var(--audio-player-tertiary-bg-color) 0%, var(--audio-player-tertiary-bg-color) '+this.value+'%, var(--audio-player-quinary-bg-color) '+this.value+'%, var(--audio-player-quinary-bg-color) 100%)')});$('.main').on('input','.audio_player_volume_control',function(e){var volume=$(this).val();WebStorage('set','audio_player_volume',volume);audio_player.volume=volume/100});$('.main').on('click','.audio_player_box > .header > .audio_player_controls > div > .volume',function(e){if($(this).find('.control').is(":visible")){$(this).find('.control').hide()}else{$(this).find('.control').show()}});$(document).click(function(e){if($(e.target).parents(".audio_player_controls").length===0){$('.audio_player_box > .header > .audio_player_controls > div > .volume > .control').hide()}
if($(".audio_player_box > .header .currently_playing").hasClass('autoplay')&&$(".audio_player_box > .header .currently_playing").hasClass('window_loaded')){$(".audio_player_box > .header .currently_playing").removeClass('autoplay');$(".audio_player_box > .header .currently_playing").removeClass('window_loaded');if(!$(".audio_player_box > .header").hasClass('d-none')){setTimeout(function(){audio_player_handler('play')},500)}else{var audio_content_id=null;if($(this).attr('audio_content_id')!==undefined){audio_content_id=$(this).attr('audio_content_id')}
load_audio_player(audio_content_id,!0)}}});$(window).on("load",function(){if(mini_audio_player_enabled){if($('.main .aside > .audio_player_box').hasClass('hidden')){$('.main .aside > .mini_audio_player').removeClass('d-none')}}
$(".audio_player_box > .header .currently_playing").addClass('window_loaded');if(WebStorage('get','audio_player_volume')!==null){var audio_volume=WebStorage('get','audio_player_volume');$('.audio_player_volume_control').val(audio_volume).trigger("input")}else{$('.audio_player_volume_control').val(100).trigger("input")}});$('.main').on('click','.load_audio',function(e){var parent=$(this).parent();$('.audio_player_box > .playlist > div > ul > li').removeClass('current_playing');$(this).parent().parent().addClass('current_playing');var audio_tag=$('.audio_player_box > .header > .info > .currently_playing > .audio_player_controls > audio');createCookie('audio_current_playing_id',$(this).attr('audio_content_id'),30);if($(this).attr('audio_file_name')!==undefined){createCookie('audio_current_playing_file_name',$(this).attr('audio_file_name'),30)}else{createCookie('audio_current_playing_file_name','',30)}
$('.audio_player_box > .header').removeClass('d-none');$('.audio_player_box > .header > .info > .currently_playing > .title').text(parent.parent().find('.info > .title').text());$('.audio_player_box > .header > .info > .currently_playing > .subtitle > span').marquee('destroy').text(parent.find('.audio_description').text());$('.audio_player_box > .header > .info > .image > span > img').attr('src',parent.parent().find('.image > img').attr('src'));if(mini_audio_player_enabled){if($('.main .aside > .audio_player_box').hasClass('hidden')){$('.main .aside > .mini_audio_player').removeClass('d-none')}
$('.main .aside > .mini_audio_player > div > .center > .title').text(parent.parent().find('.info > .title').text());$('.main .aside > .mini_audio_player > div > .center > .description > span').marquee('destroy').text(parent.find('.audio_description').text());$('.main .aside > .mini_audio_player > div > .left > .image > img').attr('src',parent.parent().find('.image > img').attr('src'))}
$(current_audio_subtitle_element).marquee({duration:12000,gap:50,delayBeforeStart:500,pauseOnHover:!0,direction:'left',startVisible:!0,duplicated:!0});audio_tag.removeAttr("src");audio_tag.find('source').attr('src',$(this).attr('audio_url'));current_audio_url=$(this).attr('audio_url');$('.audio_player_controls > div > .controls > .play_btn').attr('audio_type',$(this).attr('audio_type'));if($(this).attr('hls_stream')!==undefined){$('.audio_player_controls > div > .controls > .play_btn').attr('hls_stream',$(this).attr('hls_stream'))}else{$('.audio_player_controls > div > .controls > .play_btn').attr('hls_stream',0)}
if($(this).attr('audio_content_id')!==undefined){$('.audio_player_controls > div > .controls > .play_btn').attr('audio_content_id',$(this).attr('audio_content_id'))}else{$('.audio_player_controls > div > .controls > .play_btn').attr('audio_content_id',0)}
if($(this).attr('streaming_server')!==undefined){$('.audio_player_controls > div > .controls > .play_btn').attr('streaming_server',$(this).attr('streaming_server'))}else{$('.audio_player_controls > div > .controls > .play_btn').attr('streaming_server','other')}
if($(this).attr('mime_type')!==undefined){audio_tag.find('source').attr('type',$(this).attr('mime_type'))}else{audio_tag.find('source').removeAttr('type')}
$(".audio_player_controls > div > .seek_bar > div > .current_timestamp > span").text('00:00');$(".audio_player_controls > div > .seek_bar > div > .duration > span").text('00:00');$(".audio_player_seekbar").val(0).trigger("input");audio_player_handler('pause');audio_player_handler('load');audio_player_handler('play')});$(".audio_player_seekbar").on("mouseup",function(){audio_player_handler('play')});$(".audio_player_seekbar").on("mousedown",function(){audio_player_handler('pause')});window.onload=function(){$(".audio_player_seekbar").bind('touchstart',function(){if(is_touch_device()){audio_player_handler('pause')}}).bind('touchend',function(event){if(is_touch_device()){var offset=$(this).offset();var left=(event.changedTouches[0].pageX-offset.left);var totalWidth=$(".audio_player_seekbar").width();var percentage=(left/totalWidth);if(isFinite(audio_player.duration)){var audioTime=audio_player.duration*percentage;audio_player.currentTime=audioTime}
audio_player_handler('play')}})}
$(".audio_player_seekbar").on("click",function(e){var offset=$(this).offset();var left=(e.pageX-offset.left);var totalWidth=$(".audio_player_seekbar").width();var percentage=(left/totalWidth);var audioTime=audio_player.duration*percentage;audio_player.currentTime=audioTime});if(audio_player_enabled){audio_player.ontimeupdate=function(){var audio_type=$('.audio_player_controls > div > .controls > .play_btn').attr('audio_type');if(audio_type!=='radio_station'){if(isFinite(audio_player.currentTime)){$(".audio_player_controls > div > .seek_bar > div > .current_timestamp > span").text(timestamp_convertor(audio_player.currentTime))}
if(isFinite(audio_player.duration)){$(".audio_player_controls > div > .seek_bar > div > .duration > span").text(timestamp_convertor(audio_player.duration))}
var percentage=(audio_player.currentTime/audio_player.duration)*100;if(isFinite(percentage)){$(".audio_player_seekbar").val(percentage).trigger("input")}}};audio_player.addEventListener('play',function(){if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}
if(video_preview!==undefined&&video_preview!==null){video_preview.pause()}
audio_player_play_btn.removeClass('bi-play-fill');audio_player_play_btn.addClass('bi-pause-fill');if(mini_audio_player_enabled){mini_audio_player_play_btn.removeClass('bi-play-fill');mini_audio_player_play_btn.addClass('bi-pause-fill')}
if(radio_now_playing_timeout!==null){clearTimeout(radio_now_playing_timeout)}
if(radio_now_playing_request!=null){radio_now_playing_request.abort();radio_now_playing_request=null}
if($('.audio_player_box .play_audio').attr('audio_type')!=='radio_station'){$('.audio_player_seekbar').removeAttr('disabled');$('.audio_player_box > .header > .audio_player_controls > div > .seek_bar').removeClass('disabled')}else{if($('.audio_player_box .play_audio').attr('streaming_server')!=='other'){fetch_now_playing_info(!0)}
$('.audio_player_seekbar').attr('disabled','disabled');$('.audio_player_box > .header > .audio_player_controls > div > .seek_bar').addClass('disabled')}});audio_player.addEventListener('pause',function(){audio_player_play_btn.removeClass('bi-pause-fill');audio_player_play_btn.addClass('bi-play-fill');if(mini_audio_player_enabled){mini_audio_player_play_btn.removeClass('bi-pause-fill');mini_audio_player_play_btn.addClass('bi-play-fill')}});audio_player.addEventListener('ended',function(){$(".audio_player_seekbar").val(0).trigger("input");audio_player_play_btn.removeClass('bi-pause-fill');audio_player_play_btn.addClass('bi-play-fill');if(mini_audio_player_enabled){mini_audio_player_play_btn.removeClass('bi-pause-fill');mini_audio_player_play_btn.addClass('bi-play-fill')}
if($('.audio_player_box > .playlist > div > ul > li.current_playing').is(':last-child')){$('.audio_player_box > .playlist > div > ul > li').first().find('.load_audio').trigger('click')}else{$('.audio_player_box > .playlist > div > ul > li.current_playing').next('li').find('.load_audio').trigger('click')}})}
$('.main').on('click','.audio_player_box .previous_audio',function(e){var current_playing=$('.audio_player_box > .playlist > div > ul > li.current_playing');if(current_playing.length===0||current_playing.is(':first-child')){$('.audio_player_box > .playlist > div > ul > li.playable').last().find('.load_audio').trigger('click')}else{$('.audio_player_box > .playlist > div > ul > li.current_playing').prevAll('li.playable').eq(0).find('.load_audio').trigger('click')}});$('.main').on('click','.audio_player_box .next_audio',function(e){var current_playing=$('.audio_player_box > .playlist > div > ul > li.current_playing');if(current_playing.length===0||current_playing.is(':last-child')){$('.audio_player_box > .playlist > div > ul > li.playable').first().find('.load_audio').trigger('click')}else{$('.audio_player_box > .playlist > div > ul > li.current_playing').nextAll('li.playable').eq(0).find('.load_audio').trigger('click')}});function fetch_now_playing_info(reset){if($('.audio_player_box .play_audio').attr('audio_content_id')!==undefined){if(radio_now_playing_timeout!==null){clearTimeout(radio_now_playing_timeout)}
if(reset===undefined){var radio_now_playing_refresh_time=30000}else{var radio_now_playing_refresh_time=100}
radio_now_playing_timeout=setTimeout(function(){var data={load:'radio_now_playing',audio_content_id:$('.audio_player_box .play_audio').attr('audio_content_id'),};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
radio_now_playing_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(radio_now_playing_request!=null){radio_now_playing_request.abort();radio_now_playing_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);$('.audio_player_box > .header > .info > .currently_playing > .subtitle > span').marquee('destroy').text(data.title);if(mini_audio_player_enabled){$('.main .aside > .mini_audio_player > div > .center > .description > span').marquee('destroy').text(data.title)}
$(current_audio_subtitle_element).marquee({duration:12000,gap:50,delayBeforeStart:500,pauseOnHover:!0,direction:'left',startVisible:!0,duplicated:!0})}
radio_now_playing_request=null;radio_now_playing_timeout=null;fetch_now_playing_info()}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+errorThrown);radio_now_playing_request=null;radio_now_playing_timeout=null;fetch_now_playing_info()}})},radio_now_playing_refresh_time)}}
$('.main').on('click','.audio_player_box .play_audio',function(e){if(audio_player.paused&&audio_player.currentTime>=0&&!audio_player.started){if($(this).attr('audio_type')!==undefined&&$(this).attr('audio_type')==='radio_station'){audio_player_handler('pause');audio_player_handler('load')}
audio_player_handler('play')}else{audio_player_handler('pause')}});function load_audio_player(audio_content_id,autoplay){var search=null;var list='';if(audio_content_id===undefined){audio_content_id=null}
if(autoplay===undefined){autoplay=!1}
var loader_content='';for(let i=0;i<16;i++){loader_content=loader_content+'<li>';loader_content=loader_content+'<span class="audio_player_loading">';loader_content=loader_content+'<span class="image"></span>';loader_content=loader_content+'<span class="content">';loader_content=loader_content+'<span class="title"></span>';loader_content=loader_content+'<span class="description"></span>';loader_content=loader_content+'</span>';loader_content=loader_content+'</span>';loader_content=loader_content+'</li>'}
$('.audio_player_box > .playlist > div > ul').html(loader_content);$('.audio_player_box > .zero_results').addClass('d-none');$('.audio_player_box > .playlist').removeClass('d-none');$(".audio_player_box > .playlist").scrollTop(0);var data={load:"audio_player",};if(audio_content_id!==null){data.audio_content_id=audio_content_id}
if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
load_audio_player_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_audio_player_request!==null){load_audio_player_request.abort();load_audio_player_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.loaded!==undefined){var button_attributes='';if(data.loaded.button_attributes!==undefined){$.each(data.loaded.button_attributes,function(attrkey,attrval){button_attributes=button_attributes+attrkey+'="'+data.loaded.button_attributes[attrkey]+'" '})}
var button='<span '+button_attributes+'>'+data.loaded.button.text+'</span>';$('.audio_player_box > .heading > div > .title').replace_text(data.loaded.title);$('.audio_player_box > .heading > div > .button').html(button)}
if(data.content!==undefined){$('.audio_player_box > .playlist > div > ul').html('');$.each(data.content,function(key,val){var item=data.content[key];var option_attributes='';if(item.option_attributes!==undefined){$.each(item.option_attributes,function(attrkey,attrval){option_attributes=option_attributes+attrkey+'="'+item.option_attributes[attrkey]+'" '})}
var list='<li class="'+item.class+'">';list=list+'<div class="image">';list=list+'<img src="'+item.image+'">';list=list+'</div>';list=list+'<div class="info">';list=list+'<span class="title">'+item.title+'</span>';list=list+'<span class="subtitle">'+item.subtitle+'</span>';list=list+'</div>';list=list+'<div class="options">';list=list+'<span class="option '+item.option.class+'" '+option_attributes+'>'+item.option.text+'</span>';if(item.description!==undefined){list=list+'<span class="audio_description d-none">'+item.description+'</span>'}
list=list+'</div>';list=list+'</li>';$('.audio_player_box > .playlist > div > ul').append(list)});if(autoplay){$(".audio_player_box > .playlist > div > ul > li.playable:first-child > .options > .load_audio").addClass('clicked').trigger('click')}}else{$('.audio_player_box > .playlist').addClass('d-none');$('.audio_player_box > .zero_results').removeClass('d-none')}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){$('.audio_player_box > .playlist > div > ul').html('');console.log('ERROR : '+data)}})};var get_info_request=null;var load_info_records_request=null;$('body').on('click','.get_info',function(event){if($('.main .middle').hasClass('display_chat_alone')){return}
if(!$(event.target).hasClass('prevent_default')&&!$(event.target).parent().hasClass('prevent_default')||$(this).hasClass('force_request')){var userid=groupid=0;var data={load:'site_user'};if($(this).attr('user_id')!==undefined){data.user_id=$(this).attr('user_id')}else if($(this).attr('group_id')!==undefined){data.group_id=$(this).attr('group_id')}else if($(this).attr('auto_find')!==undefined){if($(".main .chatbox").attr('group_id')!==undefined){data.load='site_user';data.group_id=$(".main .chatbox").attr('group_id')}else if($(".main .chatbox").attr('user_id')!==undefined){data.user_id=$(".main .chatbox").attr('user_id')}else{data.user_id=1}}
if($(window).width()<767.98){$('.main .chat_page_container').removeClass('show_navigation')}
data.open_column=!0;data=$.extend(data,$(this).data());get_info(data)}});$('.main .close_info_panel').on('click',function(e){open_column('first',!0);$('.main .middle').removeClass('col-lg-5');$('.main .middle').removeClass('col-lg-6');$('.main .middle').addClass('col-lg-9');$('.main .info_panel').addClass('d-none');$('.main .formbox').addClass('d-none')});function get_info(data){data.load='site_user';if(data.group_id!==undefined){data.load='group'}
if(data.open_column!==undefined&&data.open_column===!0){open_column('fourth');$('.main .page_column[column="fourth"] .confirm_box > .content > .btn.cancel').trigger('click');$('.main .middle').removeClass('col-lg-9');$('.main .middle').addClass('col-lg-6');$('.main .formbox').addClass('d-none');$('.main .info_panel').removeClass('d-none')}
$('.main .info_panel > .loader').removeClass('error');$(".main .info_panel > .loader > div > .error_text > .title").replace_text(language_string('error'));$(".main .info_panel > .loader > div > .error_text > .subtitle").replace_text(language_string('error_message'));$(".main .info_panel > .info_box > .img > .online_status").hide();$('.main .info_panel > .loader').show();if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
get_info_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_info_records_request!=null){load_info_records_request.abort();load_info_records_request=null}
if(get_info_request!=null){get_info_request.abort();get_info_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);var images=options=statistics=contents='';if(Object.keys(data).length>0){if(data.error!==undefined){$('.main .info_panel > .loader').addClass('error');if(data.error.title!==undefined){$(".main .info_panel > .loader > div > .error_text > .title").replace_text(data.error.title)}
$(".main .info_panel > .loader > div > .error_text > .subtitle").replace_text(data.error.message)}else{if(data.loaded!==undefined){$(".main .info_panel > .info_box > .heading").replace_text(data.loaded.heading);$(".main .info_panel > .info_box > .subheading").replace_text(data.loaded.subheading);$(".main .info_panel > .coverpic > .img").html('<img src="'+data.loaded.cover_pic+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>');var cover_picture=data.loaded.cover_pic;if(cover_picture.indexOf('default.png')<0){$(".main .info_panel > .coverpic").addClass('preview_image');$(".main .info_panel > .coverpic").attr('load_image',data.loaded.cover_pic)}else{$(".main .info_panel > .coverpic").removeClass('preview_image');$(".main .info_panel > .coverpic").attr('load_image','')}
$(".main .info_panel > .info_box > .img > img").attr('src',data.loaded.image);$(".main .info_panel > .info_box > .img > img").addClass('preview_image');$(".main .info_panel > .info_box > .img > img").attr('load_image',data.loaded.image);$(".main .info_panel > .info_box > .img > img").attr('onerror',"this.onerror=null; this.src='"+blur_img_url+"';");if(data.loaded.online_status!==undefined){$(".main .info_panel > .info_box > .img > .online_status > span").removeClass('online idle offline');$(".main .info_panel > .info_box > .img > .online_status > span").addClass(data.loaded.online_status);$(".main .info_panel > .info_box > .img > .online_status").show()}}
$('.main .info_panel > .controls > div > span,.main .info_panel > .controls > div > div').addClass('d-none');$('.main .info_panel > .controls > div > span').html('');if(data.button!==undefined){$('.main .info_panel > .controls > div > span').removeAttr('class');$('.main .info_panel > .controls > div > span').addClass(data.button.class);$('.main .info_panel > .controls > div > span').html('<span></span>');$.each(data.button.attributes,function(attrkey,attrval){$('.main .info_panel > .controls > div > span > span').attr(attrkey,attrval)});$('.main .info_panel > .controls > div > span > span').replace_text(data.button.title);$('.main .info_panel > .controls > div > span').removeClass('d-none')}
if(data.options!==undefined){$('.main .info_panel > .controls > div > .options').removeClass('d-none');$.each(data.options,function(key,val){options=options+'<li class="'+data.options[key].class+'" ';$.each(data.options[key].attributes,function(attrkey,attrval){options=options+attrkey+'="'+data.options[key].attributes[attrkey]+'" '});if(data.options[key].title!==undefined){options=options+'>'+data.options[key].title+'</li>'}else{options=options+'>'+data.options[key].option+'</li>'}})}
$('.main .info_panel > .controls > div > .options > .dropdown_list > ul').html(options);if(data.statistics!==undefined){$.each(data.statistics,function(key,val){statistics=statistics+'<div>';statistics=statistics+'<span class="value">'+data.statistics[key].value+'</span>';statistics=statistics+'<span>'+data.statistics[key].title+'</span>';statistics=statistics+'</div>'});$('.main .info_panel > .statistics').show()}else{$('.main .info_panel > .statistics').hide()}
$('.main .info_panel > .statistics > div').html(statistics);if(data.content!==undefined){$.each(data.content,function(key,val){if(data.content[key].field!==undefined){contents=contents+'<div class="field">';if(data.content[key].field.title!==undefined){if(data.content[key].field.title_img!==undefined){var title_img='<span class="image"><img src="'+data.content[key].field.title_img+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/></span>';data.content[key].field.title='<span>'+data.content[key].field.title+'</span>'+title_img}
contents=contents+'<span class="title">'+data.content[key].field.title+'</span>'}
if(data.content[key].field.images!==undefined){var image_class="default";images=data.content[key].field.images;if(data.content[key].field.class!==undefined){image_class=data.content[key].field.class}
contents=contents+'<div class="icons '+image_class+'"><ul>';$.each(images,function(img_key,image){contents=contents+'<li';$.each(image.attributes,function(img_attribute_key,img_attribute_value){contents=contents+' '+img_attribute_key+'="'+img_attribute_value+'"'});var tooltip_title='';if(image.title!==undefined){tooltip_title='title="'+image.title+'" data-bs-toggle="tooltip"'}
contents=contents+'><img '+tooltip_title+' onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';" src="'+image.image+'"/>';contents=contents+'</li>'});contents=contents+'</ul></div>'}else if(data.content[key].field.buttons!==undefined){var field_buttons=data.content[key].field.buttons;contents=contents+'<div class="field_buttons"><ul>';$.each(field_buttons,function(btn_key,field_button){contents=contents+'<li';$.each(field_button.attributes,function(field_button_attribute_key,field_button_attribute_value){contents=contents+' '+field_button_attribute_key+'="'+field_button_attribute_value+'"'});contents=contents+'><span>'+field_button.title+'</span>';contents=contents+'</li>'});contents=contents+'</ul></div>'}else if(data.content[key].field.multiple_records!==undefined){var records_identifier='multiple_records';var multi_records=data.content[key].field.multiple_records;if(multi_records.identifier!==undefined){records_identifier=multi_records.identifier}
contents=contents+'<div class="info_records '+records_identifier+'">';if(multi_records.dropdown!==undefined){contents=contents+'<div class="record_selection">';contents=contents+'<div class="dropdown_button">';contents=contents+'<span class="text">'+language_string('loading')+'</span>';contents=contents+'<div class="dropdown_list">';contents=contents+'<ul>';$.each(multi_records.dropdown,function(index,dropdown_item){var dropdown_attributes='';if(dropdown_item.attributes!==undefined){$.each(dropdown_item.attributes,function(attr_index,attr_value){dropdown_attributes+=attr_index+'="'+attr_value+'" '})}
contents=contents+'<li '+dropdown_attributes+' load="'+dropdown_item.load+'" class="hide_onClick load_info_records" ';contents=contents+'records_block_class="'+records_identifier+'">'+dropdown_item.title+'</li>'});contents=contents+'</ul>';contents=contents+'</div>';contents=contents+'</div>';contents=contents+'</div>'}
contents=contents+'<div class="contents">';contents=contents+'<div>';contents=contents+'<ul>';contents=contents+'</ul>';contents=contents+'</div>';contents=contents+'</div>';contents=contents+'<div class="no_results_found d-none">';contents=contents+'<span class="image">';contents=contents+'<span></span>';contents=contents+'</span>';contents=contents+'</div>';contents=contents+'<div class="current_records d-none">';contents=contents+'<span class="loaded"></span>';contents=contents+'<span class="data_attributes"></span>';contents=contents+'<span class="offset"></span>';contents=contents+'</div>';contents=contents+'<div class="load_more d-none">';contents=contents+'<div class="load_info_records" append=true records_block_class="'+records_identifier+'">';contents=contents+'<span>'+language_string('load_more')+'</span></div>';contents=contents+'</div>';contents=contents+'</div>'}else if(data.content[key].field.value!==undefined){if(data.content[key].field.link!==undefined){var field_link=data.content[key].field.link;contents=contents+'<span class="value">';contents=contents+'<a target="_blank" href="'+field_link+'">'+data.content[key].field.value+'</a>';contents=contents+'</span>'}else{contents=contents+'<span class="value">'+data.content[key].field.value+'</span>'}}
contents=contents+'</div>'}})}
$('.main .info_panel > .content > .fields').html(contents);if($('.main .info_panel .info_records > .record_selection > div > .dropdown_list > ul > li').length>0){$('.main .info_panel .info_records > .record_selection > div > .dropdown_list > ul > li:first-child').trigger('click');$('.main .info_panel .info_records > .record_selection > div > .dropdown_list').hide()}
var tooltipTriggerList=[].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList=tooltipTriggerList.map(function(tooltipTriggerEl){return new bootstrap.Tooltip(tooltipTriggerEl)})
$('.main .info_panel > .loader').hide()}}}else{console.log('ERROR : '+data);$(".main .info_panel > .info_box > .heading").replace_text(language_string('error'));$('.main .info_panel > .loader').addClass('error')}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){$('.main .info_panel > .loader').addClass('error');$(".main .info_panel > .info_box > .heading").replace_text(language_string('error'))}})}
$('.main').on('click','.load_info_records',function(e){var load=$(this);if(load.attr('records_block_class')!==undefined){var records_block=$('.main .info_panel > .content > .fields > .field > .info_records.'+load.attr('records_block_class'));var offset=0;var load_records='';if(load.attr('load')!==undefined){load_records=load.attr('load')}
records_block.find('.load_more').addClass('d-none');if(load.attr('append')!==undefined){load_records=$.trim(records_block.find('.current_records > .loaded').text());offset=$.trim(records_block.find('.current_records > .offset').text())}else{records_block.find('.no_results_found').addClass('d-none');records_block.find('.current_records > .loaded').text(load_records);records_block.find('.contents > div > ul').html('');records_block.find('.record_selection > div > .text').replace_text(language_string('loading'));var append_data=load.data();$.each(append_data,function(index,data_item){if(records_block.find('.current_records > .data_attributes > span').length===0){records_block.find('.current_records > .data_attributes').html('<span>Append Data</span>')}
var data_index='data-'+index;records_block.find('.current_records > .data_attributes > span').attr(data_index,append_data[index])})}
var data={load:load_records,offset:offset,};data=$.extend(data,records_block.find('.current_records > .data_attributes > span').data());if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
load_info_records_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_info_records_request!=null){load_info_records_request.abort();load_info_records_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);var contents='';if(data.loaded!==undefined){if(data.loaded.format!==undefined){records_block.find('.contents').removeClass('grid_format list_format');records_block.find('.contents').addClass(data.loaded.format+'_format');if(data.loaded.offset!==undefined){records_block.find('.current_records > .offset').text(data.loaded.offset)}
if(load.attr('append')===undefined){if(data.loaded.title!==undefined){records_block.find('.record_selection > div > .text').replace_text(data.loaded.title)}}
if(data.loaded.load_more!==undefined){records_block.find('.load_more').removeClass('d-none')}
if(data.content!==undefined){if(data.loaded.format==='grid'){$.each(data.content,function(index,item){var attributes='';if(item.attributes!==undefined){$.each(item.attributes,function(attr_index,attr_value){attributes+=attr_index+'="'+attr_value+'" '})}
contents=contents+'<li>';contents=contents+'<span '+attributes+'>';contents=contents+'<img src="'+item.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';contents=contents+'</span>';contents=contents+'</li>'})}else if(data.loaded.format==='list'){$.each(data.content,function(index,item){var attributes='';if(item.attributes!==undefined){$.each(item.attributes,function(attr_index,attr_value){attributes+=attr_index+'="'+attr_value+'" '})}
contents=contents+'<li '+attributes+'>';contents=contents+'<span class="left">';contents=contents+'<span class="image">';contents=contents+'<img src="'+item.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';contents=contents+'</span>';contents=contents+'</span>';contents=contents+'<span class="right">';if(item.heading!==undefined){contents=contents+'<span class="heading">'+item.heading+'</span>'}
if(item.description!==undefined){contents=contents+'<span class="description">'+item.description+'</span>'}
if(item.footer!==undefined){contents=contents+'<span class="footer">'+item.footer+'</span>'}
contents=contents+'</span>';contents=contents+'</li>'})}}
if(load.attr('append')!==undefined){records_block.find('.contents > div > ul').append(contents)}else{if(contents.length===0){records_block.find('.no_results_found').removeClass('d-none')}
records_block.find('.contents > div > ul').html(contents)}}}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+errorThrown)}})}});$('.main').on('click','.social_media_share',function(e){if($(this).attr('share_on')!==undefined){var share_on=$(this).attr('share_on');var share_url=$(this).attr('share_url');var popup_window=!0;share_url=encodeURIComponent(share_url);if(share_on==='whatsapp'){share_url='https://wa.me/?text='+share_url}else if(share_on==='bluesky'){share_url='https://bsky.app/intent/compose?text='+share_url}else if(share_on==='facebook'){share_url='https://www.facebook.com/sharer/sharer.php?u='+share_url}else if(share_on==='linkedin'){share_url='https://www.linkedin.com/shareArticle?mini=true&url='+share_url}else if(share_on==='reddit'){share_url='https://www.reddit.com/submit?url='+share_url}else if(share_on==='twitter'){share_url='https://x.com/intent/tweet?url='+share_url}else if(share_on==='telegram'){share_url='https://t.me/share/url?url='+share_url}else if(share_on==='tumblr'){share_url='https://www.tumblr.com/widgets/share/tool?canonicalUrl='+share_url}else if(share_on==='vk'){share_url='https://vk.com/share.php?url='+share_url}else if(share_on==='pinterest'){share_url='https://pinterest.com/pin/create/button/?url='+share_url}else if(share_on==='threads'){share_url='https://threads.net/intent/post?text='+share_url}
if(popup_window){window.open(share_url,'_blank','width=600,height=400')}else{window.open(share_url,'_blank')}}});var grid_list_request={'gifs':null,'stickers':null,'emojis':null,'video_search':null};$("body").on("keyup",".grid_list > div > .search",function(e){if(e.which==13){var module=$(this).parent();grid_list(module)}});$("body").on("click",".load_grid_list",function(e){if($(this).hasClass('toggle_grid_module')){var mod_class_name='.grid_list > div.'+$(this).attr('load');if($('.grid_list').hasClass('hidden')||!$(mod_class_name).hasClass('d-none')){if(!$('.chatbox > .footer > .grid_list').hasClass('hidden')&&$('.chatbox > .footer > .attachments').hasClass('hasAttachments')){open_module('.attachments','.chatbox > .footer')}else{open_module('.grid_list','.chatbox > .footer')}}}
var load_list=!0;var module=$('.grid_list > div.'+$(this).attr('load'));if(load_list){if($(this).attr('reload')!==undefined||module.find('.results > div > ul > li').length==0){module.find('.data_attributes').html('<span></span>');$.each($(this).data(),function(name,value){name='data-'+name;module.find('.data_attributes > span').attr(name,value)});grid_list(module)}
$('.grid_list > div').addClass('d-none');module.removeClass('d-none')}
if($(window).width()>767.98){$('#message_editor').summernote('focus')}});$('.main .chatbox > .footer > .grid_list > div > .results').on('scroll',function(e){if($(this).scrollTop()+$(this).innerHeight()>=$(this)[0].scrollHeight-20){var module=$(this).parent();if(module.attr('offset')!==undefined&&module.attr('offset')!==0){if(!module.find('results').hasClass('loading')){grid_list(module,!0);module.find('.results').addClass('loading')}}}});function grid_list(module,append){var search=null;var list=subtabs='';var offset=0;search=module.find('.search > div > input').val();var loader_content='';for(let i=0;i<16;i++){loader_content=loader_content+'<li class="item_loading"><span class="loader"><span>';loader_content=loader_content+'<span></span>';loader_content=loader_content+'</span></li>'}
if(append===undefined){module.find('.results > div > ul').removeAttr('class').html(loader_content);module.find(".results").scrollTop(0);module.attr('offset',0)}else{offset=module.attr('offset');if(offset=='endofresults'){return!1}}
module.find('.results').addClass('loading');var load={load:module.attr('load')};load.search=search;load.frontend=!0;load.offset=offset;load=$.extend(load,module.find('.data_attributes > span').data());var load_module=$.trim(module.attr('load'));if(user_csrf_token!==null){load.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){load.login_session_id=user_login_session_id;load.access_code=user_access_code;load.session_time_stamp=user_session_time_stamp}
grid_list_request[load_module]=$.ajax({type:'POST',url:api_request_url,data:load,async:!0,beforeSend:function(){if(grid_list_request[load_module]!==null){grid_list_request[load_module].abort();grid_list_request[load_module]=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.subtabs!=undefined){$.each(data.subtabs,function(key,val){var subtab=data.subtabs[key];var attributes='';if(subtab.attributes!==undefined){$.each(subtab.attributes,function(attrkey,attrval){attributes=attributes+attrkey+'="'+subtab.attributes[attrkey]+'" '})}
subtabs=subtabs+'<li class="'+subtab.class+'" '+attributes+'> <span>';subtabs=subtabs+'<img src="'+subtab.image+'" onerror="on_error_img(this)"/>';subtabs=subtabs+'</span> </li>'});module.find('.subtabs > ul').html(subtabs);module.find('.subtabs').show()}
if(append===undefined){module.find('.results > div > ul').addClass(load.load);module.find('.results > div > ul').html('')}
if(data.offset!==undefined){module.attr('offset',data.offset)}
if(data.content!==undefined){$.each(data.content,function(key,val){var item=data.content[key];var attributes='';if(item.attributes!==undefined){$.each(item.attributes,function(attrkey,attrval){attributes=attributes+attrkey+'="'+item.attributes[attrkey]+'" '})}
var list='<li class="'+item.class+'" '+attributes+'> <span>';list=list+'<img src="'+item.image+'" onerror="on_error_img(this)"/>';list=list+'</span> </li>';module.find('.results > div > ul').append(list)})}}else{console.log('ERROR : '+data)}
module.find('.results').removeClass('loading')}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){module.find('.results > div > ul').html('')}
module.find('.results').removeClass('loading')})}
function on_error_img(image,mode=1){if(mode===2){image.parentElement.parentElement.classList.add('error')}else{image.parentElement.parentElement.style.display="none";image.parentElement.parentElement.remove()}};var useMediaRecorder_api=!1;$(document).ready(function(){var audio_recorder_jsFileUrl=baseurl+'assets/js/chat_page/audio_message_record_rtc.js';if(system_variable('ffmpeg')==='enable'){useMediaRecorder_api=!0}
if(useMediaRecorder_api){audio_recorder_jsFileUrl=baseurl+'assets/js/chat_page/audio_message_media_recorder.js'}
$.getScript(audio_recorder_jsFileUrl,function(){console.log('Loaded Audio Recorder Files')})});var load_messages_request=null;var alert_message_time_interval=null;var load_messages_reload_timeout=null;var audio_message_preview=document.getElementById("audio_message_preview");var page_rendering_fix=!1;var load_messages_reload_loop=0;var focus_on_send_button=!0;var shared_screenshot_BlobIds=[];$('.main .chatbox > .contents > .chat_messages').on('scroll',function(e){$('.main .chatbox > .contents > .date').hide();if(Math.abs($(this).scrollTop())+$(this).innerHeight()>=$(this)[0].scrollHeight-60){if(!$('.main .chatbox > .contents > .chat_messages').hasClass('EndResults')&&!$('.main .chatbox > .contents > .chat_messages').hasClass('loading')){$('.main .chatbox > .contents > .chat_messages').addClass('loading');var data={message_id_less_than:get_message_id('first'),prepend_messages:!0,};if($(".main .chatbox").attr('group_id')!==undefined){data.group_id=$(".main .chatbox").attr('group_id')}else if($(".main .chatbox").attr('user_id')!==undefined){data.user_id=$(".main .chatbox").attr('user_id')}
if($('.main .chatbox > .contents > .chat_messages').hasClass('searching')){if($('.main .middle .search_messages > div > .search > div > input').val().length>0){data.search=$('.main .middle .search_messages > div > .search > div > input').val()}}
if(data.group_id!==undefined||data.user_id!==undefined){load_conversation(data)}}}
if(page_rendering_fix){$('.main .chatbox > .contents > .chat_messages').attr('style','overflow:auto');setTimeout(function(){$('.main .chatbox > .contents > .chat_messages').attr('style','overflow-x:hidden')},500)}});$("body").on('click','.main .load_message',function(e){if($(this).attr('message_id')!==undefined){var data={message_id:$(this).attr('message_id'),prepend_messages:!0,find_message:!0,};if($(".main .chatbox").attr('group_id')!==undefined){data.group_id=$(".main .chatbox").attr('group_id')}else if($(".main .chatbox").attr('user_id')!==undefined){data.user_id=$(".main .chatbox").attr('user_id')}
if(data.group_id!==undefined||data.user_id!==undefined){if(data.group_id==$(".main .chatbox").attr('group_id')||data.user_id==$(".main .chatbox").attr('user_id')){var message_element=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+data.message_id+'"]');if(message_element.length>0){highlight_message(data.message_id)}else{load_conversation(data)}}}}});$("body").on("keyup",".main .middle .search_messages > div > .search > div > input",function(e){if(e.which==13||search_on_change_of_input){var data=[];if($(this).val().length>0){data.search=$(this).val();$('.main .chatbox').addClass('searching_chat_message')}
if($(".main .chatbox").attr('group_id')!==undefined){data.group_id=$(".main .chatbox").attr('group_id')}else if($(".main .chatbox").attr('user_id')!==undefined){data.user_id=$(".main .chatbox").attr('user_id')}
load_conversation(data)}});$("body").on("click",".main .reload_conversation",function(e){$('.main .middle .search_messages').hide();var data=[];if($(".main .chatbox").attr('group_id')!==undefined){data.group_id=$(".main .chatbox").attr('group_id')}else if($(".main .chatbox").attr('user_id')!==undefined){data.user_id=$(".main .chatbox").attr('user_id')}
load_conversation(data)});$("body").on("click",".main .share_file",function(e){open_column('second');var content={'share_file':$(this).attr('file_name'),'scrollToBottom':!0,};send_message(content)});$("body").on("click",".main .share_user_location",function(e){if("geolocation" in navigator){navigator.geolocation.getCurrentPosition(function(position){var content={'share_user_location':!0,'latitude':position.coords.latitude,'longitude':position.coords.longitude,'scrollToBottom':!0,};send_message(content)},function(error){alert("Error getting location: "+error.message)})}else{alert("Geolocation is not supported by your browser.")}});function highlight_message(message_id){var message_element=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+message_id+'"]');if(message_element.length>0){var scroll_to_position=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+message_id+'"]')[0].offsetTop;scroll_to_position=scroll_to_position-10;message_element.addClass('highlight');$('.main .chatbox > .contents > .chat_messages').animate({scrollTop:scroll_to_position},1500);setTimeout(function(){message_element.removeClass('highlight')},5000)}}
$("body").on('click','.main .chatbox .toggle_switch_user',function(e){if(!$('.main .chatbox > .header > .switch_user').hasClass('open')){$('.main .middle .search_messages').hide()}
$('.main .chatbox > .header > .switch_user').toggleClass('open');$('.main .chatbox > .header > .switch_user > div.search_users > .search > div > input').trigger('focus')});$("body").on('click','.main .switch_user_id',function(e){if($(this).attr('user_id')!==undefined){$('.main .chatbox > .header > .switch_user > .user_id > input').val($(this).attr('user_id'));if($(this).find('.image > img').attr('src')!==undefined){$('.main .chatbox > .header > .switch_user > .username').text($(this).find('.title').text());if($(this).attr('user_id')===$('.logged_in_user_id').text()){$('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image').html('')}else{$('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image').html('<img src="'+$(this).find('.image > img').attr('src')+'"/>')}}
$('.main .chatbox > .header > .switch_user').removeClass('open')}});$("body").on("keyup",".main .chatbox > .header > .switch_user > div.search_users > .search > div > input",function(e){if(e.which==13){var keyword=$(this).val();if($(".main .chatbox").attr('group_id')!==undefined&&keyword.length>0){var user_info='';var post_data={load:'group_members_mentions',search:keyword,switch_user:!0,group_id:$(".main .chatbox").attr('group_id')};$('.main .chatbox > .header > .switch_user > div.search_users > .list > ul').html('');if(user_csrf_token!==null){post_data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){post_data.login_session_id=user_login_session_id;post_data.access_code=user_access_code;post_data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:post_data,async:!0}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(Object.keys(data).length>0){$.each(data,function(key,val){user_info='<li class="switch_user_id" user_id="'+data[key].user_id+'">';user_info+='<span class="image"> <img onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';" src="'+data[key].avatar+'"> </span>';user_info+='<span class="title">'+data[key].name+'</span>';user_info+='</li>';$('.main .chatbox > .header > .switch_user > div.search_users > .list > ul').append(user_info)})}}})}}});function get_message_id(find){var message_ids=[];var message_id=0;if(find!==undefined&&find==='last_seen_by_recipient'){var all_messages=$('.main .chatbox > .contents > .chat_messages > ul > li.seen_by_recipient');find='last'}else{var all_messages=$('.main .chatbox > .contents > .chat_messages > ul > li')}
all_messages.each(function(){if($(this).attr('message_id')!=undefined&&!$(this).hasClass('skip_message')){message_ids.push($(this).attr('message_id'))}});if(find!==undefined&&find==='last'){message_ids.sort(function(a,b){return b-a})}else{message_ids.sort(function(a,b){return a-b})}
if(message_ids[0]!==undefined){message_id=message_ids[0]}
return message_id}
$("body").on('click','.send_sticker',function(e){var content={'sticker':$(this).attr('sticker'),'sticker_pack':$(this).attr('sticker_pack'),'scrollToBottom':!0,};send_message(content)});$("body").on('click','.add_emoji',function(e){$('#message_editor').summernote('restoreRange');var emojiClass='emoji_icon emoji-'+$(this).attr('emoji');var emoji_tag="<span contenteditable=false class='"+emojiClass+"'>&nbsp;</span>";emoji_tag+="<span>&nbsp;</span>";var emoji_tag="<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=' class='"+emojiClass+"'/>";$('#message_editor').summernote('pasteHTML',emoji_tag)});$("body").on('click','.detach_message',function(e){$('.main .attached_message_id > input').val('0');$('.main .chatbox > .footer .attached_message').hide();$('#message_editor').summernote('restoreRange')});$("body").on('click','.attach_message',function(e){$('.main .chatbox > .footer .attached_message > .attached_message_preview > div.content > .right').hide();var message_id=$(this).attr('message_id');var send_by=$(this).parents('.message').find('.header .send_by').text();var content=$(this).parents('.message').find('.message_content').html();var thumbnail=$(this).parents('.message').find('.files .preview_image').attr('src');if(content===undefined||content.length===0){content=$(this).parents('.message').attr('message_label')}
if(thumbnail!==undefined){thumbnail='<img src="'+thumbnail+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';$('.main .chatbox > .footer .attached_message > .attached_message_preview > div.content > .right > .thumbnail').html(thumbnail);$('.main .chatbox > .footer .attached_message > .attached_message_preview > div.content > .right').show()}
$('.main .attached_message_id > input').val(message_id);$('.main .chatbox > .footer .attached_message > .attached_message_preview > div.content > .left > .send_by').replace_text(send_by);$('.main .chatbox > .footer .attached_message > .attached_message_preview > div.content > .left > .text').html(content);$('.main .chatbox > .footer .attached_message').show();$('#message_editor').summernote('restoreRange')});function send_message(content){var data=new FormData();var empty_message=!1;var message=gif_url='';var files_attached=!1;var attached_media_type;data.append("add","message");typing_indicator('reset');$('.main .middle .chatbox > .alert_message').hide();close_module('.grid_list','.chatbox > .footer');$('.message_editor .note-editor.note-frame .note-editing-area .note-editable').removeClass('highlight');if($('.main .chatbox').attr('group_id')!==undefined){data.append("group_id",$('.main .chatbox').attr('group_id'))}else if($('.main .chatbox').attr('user_id')!==undefined){data.append("user_id",$('.main .chatbox').attr('user_id'))}else{return!1}
if(content!==undefined){$.each(content,function(key,value){data.append(key,value)});if(content.sticker!==undefined||content.share_user_location!==undefined||content.audio_message!==undefined||content.share_file!==undefined||content.screenshot!==undefined){empty_message=!0}}else{if(!$('#message_editor').summernote('isEmpty')){message=$('#message_editor').summernote('code')}
data.append("message",message);if($('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_url').val().length!==0){var attached_media_url=$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_url').val();var attached_media_type=$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_type').val();if(attached_media_type==='gif'){gif_url=attached_media_url;data.append("gif_url",gif_url)}else{data.append(attached_media_type,attached_media_url)}
empty_message=!0}else if($(".file_attachments").length!==0){var files=[];var file_index=0;$(".file_attachments").each(function(){files=$(this).get(0).files;for(var i=0;i<files.length;i++){var file_identifier=(files[i].name.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,''))+'_'+files[i].lastModified;var check_removed=$(".attachments li.removed[file_identifier='"+file_identifier+"']");if(check_removed.length==0){var vid_attached_thumb='.attached_video_thumbnails > input[name="video_thumbnail_'+file_identifier+'"]';if($(vid_attached_thumb).length>0){data.append("file_attachments_thumb["+file_index+"]",$(vid_attached_thumb).val())}
data.append("file_attachments["+file_index+"]",files[i]);file_index=file_index+1;files_attached=!0}}});empty_message=!0}
$('.main .chatbox > .footer > .attachments > div > .files > ul').html('');$('.main .chatbox > .footer > .grid_list > div > .results > div > ul > li').removeClass('selected');deattach_media();$('.attachments > div > .attached_files > form').html('')}
$('.main .chatbox > .footer .attached_video_thumbnails').html('');var characters=message.replace(/(<([^>]+)>)/ig,"");var totalCharacters=characters.length;var min_message_length=1;if($('.main .chatbox > .footer > .editor').attr('min_message_length')!==undefined){min_message_length=parseInt($('.main .chatbox > .footer > .editor').attr('min_message_length'));if(isNaN(min_message_length)){min_message_length=1}}
if(totalCharacters===0){if(message.match(/<img [^>]*src="[^"]*"[^>]*>/gm)){totalCharacters=message.match(/<img [^>]*src="[^"]*"[^>]*>/gm).length}}
if(totalCharacters<min_message_length&&!empty_message){$('.message_editor .note-editor.note-frame .note-editing-area .note-editable').addClass('highlight');return!1}else{var pending_message_identifier='pending_'+RandomString(6);var sample_message_alignment='';var sample_message=message;if(content!==undefined&&content.share_user_location!=undefined){sample_message=language_string('sharing_your_location')}
if(attached_media_type!==undefined&&attached_media_type==='video_url'){if(message.length===0){sample_message=language_string('sharing_video')}}
var send_sample_data={"messages":[{"class":'sample_message own_message '+pending_message_identifier,"image":$('.logged_in_user_avatar').attr('src'),"posted_by":$('.logged_in_user_name').text(),"name_color":$('.logged_in_user_name_color').text(),"sample_data":!0,"content":sample_message,}],"append":!0};if(content!==undefined&&content.scrollToBottom!==undefined){send_sample_data.scrollToBottom=!0}else if(content===undefined){send_sample_data.scrollToBottom=!0}
if(system_variable('own_message_alignment')==='right'){sample_message_alignment=' align_right'}
$('#message_editor').summernote('code','');if($('.main .chatbox').attr('group_id')!==undefined){if($('.main .chatbox > .header > .switch_user').length>0){if($('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image > img').length>0){send_sample_data.messages[0].image=$('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image > img').attr('src');send_sample_data.messages[0].posted_by=$('.main .chatbox > .header > .switch_user > .username').text();var send_as_user_id=$('.main .chatbox > .header > .switch_user > .user_id > input').val();if(send_as_user_id.length>0&&send_as_user_id!=='0'){data.append('send_as_user_id',send_as_user_id);if(system_variable('message_alignment')==='right'){sample_message_alignment=' align_right'}else{sample_message_alignment=''}}}}}
send_sample_data.messages[0].class+=sample_message_alignment;if(gif_url.length!==0){send_sample_data.messages[0].class=send_sample_data.messages[0].class+' gif';send_sample_data.messages[0].attachments=new Array();send_sample_data.messages[0].attachments[0]={"image":gif_url,"original":gif_url,}}else if(content!==undefined){if(content.sticker!=undefined&&content.sticker_pack!=undefined){send_sample_data.messages[0].content='';send_sample_data.messages[0].class=send_sample_data.messages[0].class+' sticker';var sticker_url=baseurl+'assets/files/stickers/'+content.sticker_pack+'/'+content.sticker;send_sample_data.messages[0].attachments=new Array();send_sample_data.messages[0].attachments[0]={"image":sticker_url,"original":sticker_url,}}else if(content.screenshot!=undefined){send_sample_data.messages[0].content='';send_sample_data.messages[0].class=send_sample_data.messages[0].class+' screenshot';send_sample_data.messages[0].attachments=new Array();send_sample_data.messages[0].attachments[0]={"image":content.screenshot,"original":content.screenshot,}}else if(content.audio_message!=undefined&&content.blob!=undefined){send_sample_data.messages[0].content='';send_sample_data.messages[0].attachment_type='audio_message';send_sample_data.messages[0].class=send_sample_data.messages[0].class+' audio_message';var audioURL=window.URL.createObjectURL(content.blob);send_sample_data.messages[0].attachments=new Array();send_sample_data.messages[0].attachments[0]={"audio_file":audioURL,"file_type":'audio/webm',}}}else if(files_attached){send_sample_data.messages[0].attachments=new Array();send_sample_data.messages[0].attachments[0]={"file_name":language_string('uploading_files'),"file_icon":baseurl+'assets/files/defaults/uploading_files.png',"subtitle":"0%",}}
if($('.main .attached_message_id > input').val().length!==0){data.append("attach_message",$('.main .attached_message_id > input').val())}
load_messages(send_sample_data);var pending_message_element=$('.main .chatbox > .contents > .chat_messages > ul > li.'+pending_message_identifier);if($('.main .chatbox > .contents > .chat_messages > ul > li > div > .left > .selector').length>0){$('.main .chatbox .selector').removeClass('multi_selection');$('.main .chatbox .selector').addClass('d-none')}
if(user_csrf_token!==null){data.append("csrf_token",user_csrf_token)}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.append("login_session_id",user_login_session_id);data.append("access_code",user_access_code);data.append("session_time_stamp",user_session_time_stamp)}
$.ajax({type:'POST',url:api_request_url,xhr:function(){var xhr=new window.XMLHttpRequest();if(files_attached){xhr.upload.addEventListener("progress",function(evt){if(evt.lengthComputable){var percentComplete=((evt.loaded/evt.total)*100);pending_message_element.find('.file_details > .subtitle').text(parseInt(percentComplete)+'%')}},!1)}
return xhr},data:data,cache:!1,contentType:!1,processData:!1,async:!0,success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.alert!==undefined){$('.main .middle .chatbox > .alert_message > div > .message').removeClass('error warning success');if(data.alert.type!==undefined){$('.main .middle .chatbox > .alert_message > div > .message').addClass(data.alert.type)}
$('.main .middle .chatbox > .alert_message > div > .message').replace_text(data.alert.message);$('.main .middle .chatbox > .alert_message').show();if(alert_message_time_interval!==null){clearTimeout(alert_message_time_interval)}
alert_message_time_interval=setTimeout(function(){$('.main .middle .chatbox > .alert_message').hide();alert_message_time_interval=null},3000)}
if(data.refresh!==undefined){location.reload(!0)}else if(data.message!==undefined){data.message.append=!0;load_messages(data.message)}
pending_message_element.remove()}else{console.log('ERROR : '+data);pending_message_element.addClass('failed');setTimeout(function(){pending_message_element.remove()},2000)}}).fail(function(qXHR,textStatus,errorThrown){console.log('ERROR : '+errorThrown);pending_message_element.addClass('failed');setTimeout(function(){pending_message_element.remove()},2000)});$('.main .attached_message_id > input').val('0');$('.main .chatbox > .footer .attached_message').hide();$('.chatbox > .footer > .attachments').removeClass('hasAttachments');if(focus_on_send_button){$('#message_editor').summernote('focus')}}}
$('.main .chatbox').on('drop',function(e){e.stopPropagation();e.preventDefault();if(!$('.main .chatbox').hasClass('d-none')&&!$('.main .chatbox > .footer').hasClass('d-none')){var dropped_files=e.originalEvent.dataTransfer.files;var identifier='user_input_'+RandomString(6);var new_file_input='<input type="file" multiple name="file_attachments[]" class="file_attachments '+identifier+'"/>';$('.attachments > div > .attached_files > form').append(new_file_input);$('.'+identifier).hide();$('.'+identifier).prop('files',dropped_files);$('.'+identifier).trigger('change')}});$("body").on('click','.attach_file',function(e){var identifier='user_input_'+RandomString(6);var new_file_input='<input type="file" multiple name="file_attachments[]" class="file_attachments '+identifier+'"/>';$('.attachments > div > .attached_files > form').append(new_file_input);$('.'+identifier).hide();$('.'+identifier).trigger('click')});$("body").on('click','.attach_media ',function(e){$(this).parent().find('li').removeClass('selected');$(this).addClass('selected');$('.main .chatbox > .footer > .editor > div > .attached_media > .media_image > img').removeAttr('src');$('.main .chatbox > .footer > .editor > div > .attached_media > .media_image > img').attr('src',$(this).find('img').attr('src'));$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_url').val($(this).attr('media_url'));var attached_media_type='gif';if($(this).attr('media_type')!==undefined){attached_media_type=$(this).attr('media_type')}
$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_type').val(attached_media_type);$('.main .chatbox > .footer > .editor > div > .attached_media').removeClass('d-none');$('#message_editor').summernote('restoreRange');$('#message_editor').summernote('focus')});$("body").on('click','.deattach_media ',function(e){deattach_media()});function deattach_media(){$('.main .chatbox > .footer > .grid_list > div > .results > div > ul > li.attach_media').removeClass('selected');$('.main .chatbox > .footer > .editor > div > .attached_media > .media_image > img').removeAttr('src');$('.main .chatbox > .footer > .editor > div > .attached_media').addClass('d-none');$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input').val('')}
$("body").on('change','.file_attachments',function(e){open_module('.attachments','.chatbox > .footer',!0);var file='';$('.chatbox > .footer > .attachments').addClass('hasAttachments');for(var i=0;i<$(this).get(0).files.length;++i){var filesize=($(this).get(0).files[i].size/1024/1024).toFixed(2);var extension=$(this).get(0).files[i].type;var file_identifier=($(this).get(0).files[i].name.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,''))+'_'+$(this).get(0).files[i].lastModified;file='<li file_identifier="'+file_identifier+'"><span class="file">';file+='<span class="file_preview">';if(extension==='image/jpeg'||extension==='image/webp'||extension==='image/png'||extension==='image/gif'||extension==='image/bmp'||extension==='image/x-ms-bmp'){var preview=URL.createObjectURL($(this).get(0).files[i]);file+='<span class="image">';file+='<img src="'+preview+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';">';file+='</span>'}else{file+='<span class="icon"></span>'}
if(extension==='video/mp4'||extension==='video/webm'||extension==='video/ogg'){generate_attached_video_thumbnail($(this).get(0).files[i],file_identifier)}
file+='</span>';file+='<span class="file_details">';file+='<span class="file_name" title="'+$(this).get(0).files[i].name+'">'+$(this).get(0).files[i].name+'</span>';file+='<span class="file_size">'+filesize+' mb</span>';file+='</span>';file+='</span>';file+='<span class="remove_file"><span class="bi bi-x-circle-fill"></span></span>';file+='</li>';$('.main .chatbox > .footer > .attachments > div > .files > ul').append(file);deattach_media()}});function generate_attached_video_thumbnail(video_file,fileIndex){try{let canvasContainer=$("#vid-attach-canvas-container");if(canvasContainer.length===0){canvasContainer=$("<div>",{id:"vid-attach-canvas-container"});$("body").append(canvasContainer)}
let canvas=$("#vid-attach-canvas-container canvas")[0];let thumbnailsContainer=$(".attached_video_thumbnails");if(!canvas){canvas=document.createElement("canvas");canvas.id="thumbnail-canvas";canvas.width=640;canvas.height=360;canvas.style.border="1px solid black";$("#vid-attach-canvas-container").append(canvas)}
const fileReader=new FileReader();fileReader.onload=function(e){try{const video=document.createElement("video");video.src=e.target.result;$(canvasContainer).show();video.addEventListener("loadeddata",function(){try{canvas.width=video.videoWidth;canvas.height=video.videoHeight;video.currentTime=2;video.addEventListener("seeked",function(){try{const context=canvas.getContext("2d");context.drawImage(video,0,0,canvas.width,canvas.height);const thumbnailDataUrl=canvas.toDataURL("image/png");$(canvasContainer).hide();const inputField=$("<input>",{type:"hidden",name:`video_thumbnail_${fileIndex}`,value:thumbnailDataUrl});thumbnailsContainer.append(inputField)}catch(error){console.log("Error while drawing video frame on canvas: ",error)}})}catch(error){console.log("Error while seeking video: ",error)}});video.load()}catch(error){console.log("Error while loading video: ",error)}};fileReader.readAsDataURL(video_file)}catch(error){console.log("Error in generate_attached_video_thumbnail function: ",error)}}
$("body").on('click','.main .chatbox > .footer > .attachments > div > .files > ul > li > .remove_file',function(e){$(this).parent('li').addClass('d-none removed');if($('.main .chatbox > .footer > .attachments > div > .files > ul > li:visible').length===0){open_module('.attachments','.chatbox > .footer');$('.chatbox > .footer > .attachments').removeClass('hasAttachments')}});$("body").on('click','.load_conversation',function(event){if(!$(event.target).hasClass('prevent_default')&&!$(event.target).parent().hasClass('prevent_default')||$(this).hasClass('force_request')){var load=[];shared_screenshot_BlobIds=[];if($(this).attr('group_id')!==undefined){load.group_id=$(this).attr('group_id');if(system_variable('load_group_info_on_group_load')==='enable'){if($(window).width()>992){load.load_group_info=!0}}
$('.main .side_navigation .menu_items').find('li.realtime_module[module="groups"] > .menu_item > .unread').html('')}else if($(this).attr('user_id')!==undefined){load.user_id=$(this).attr('user_id');if(system_variable('show_profile_on_pm_open')==='enable'){if($(window).width()>992){load.load_user_info=!0}}
$('.main .side_navigation .menu_items').find('li.realtime_module[module="private_conversations"] > .menu_item > .unread').html('')}
$('.main .middle .search_messages').hide();if($(this).attr('search')!==undefined){load.search=$(this).attr('search');if($(this).attr('search_message_id')!==undefined){load.search_message_id=!0}}
if($(this).hasClass('info_panel_message_button')){load.hide_infopanel_onload=!0}
if($(this).hasClass('attend_video_call')){if($(this).hasClass('audio_only_chat')){load.open_audio_call=!0}else{load.open_video_call=!0}}
if(!$('.main .chatbox > .footer > .editor .audio_recorder_box').hasClass('d-none')){$('.cancel_recording').trigger('click')}
if(video_chat_available&&isVideoChatActive&&!exit_video_chat_on_change){$('.main .middle > .video_chat_interface').addClass('show_chat_window')}
load_conversation(load)}});function load_conversation(load){$('.main .chatbox > .contents > .chat_messages').addClass('loading');typing_indicator('reset');var browser_title=default_meta_title;var browser_address_bar=baseurl;var hide_infopanel_onload=!0;if(load.prepend_messages===undefined&&load.append_messages===undefined){if(system_variable('video_chat')!=='disable'){if(video_chat_available&&isVideoChatActive&&exit_video_chat_on_change){exit_video_chat()}}
open_column('second');$('.main .chatbox > .header > .icons').addClass('d-none');$('.main .chatbox > .contents > .error_message').hide();if($(window).width()<=991&&$(window).width()>=770.98){if(load.hide_infopanel_onload!==undefined){hide_infopanel_onload=!1}}
$('.main .chatbox > .info_box').html('');$('.main .chatbox > .info_box').hide();close_chat_header_window('all');$('.main .chatbox > .header > .image').show();$('.main .chatbox > .header').removeClass('d-none');$('.main .chatbox > .header').removeClass('view_info');$('.main .chatbox > .header > .image').removeClass('get_info');$('.main .chatbox > .header > .heading').removeClass('get_info');$(".main .chatbox > .header > .icons > span.delete_multiple_messages").addClass('d-none');$(".main .chatbox > .header > .image > .thumbnail").removeClass('img_loaded');$(".main .chatbox > .header > .image > .thumbnail > img").attr('src',baseurl+'assets/files/defaults/loading.gif');$(".main .chatbox > .header > .heading > .title").replace_text(language_string('loading'));$('.main .middle > .content > div').addClass('d-none');$('.main .middle > .content > .chatbox').removeClass('d-none');$('.main .chatbox > .footer').removeClass('d-none');$('.main .middle').removeClass('col-lg-5');$('.main .middle').removeClass('col-lg-6');if(!$('.main .middle').hasClass('display_chat_alone')){$('.main .middle').addClass('col-lg-9')}
if(hide_infopanel_onload){$('.main .info_panel').addClass('d-none')}
$('.main .formbox').addClass('d-none');$('.main .chatbox > .contents > .chat_messages > ul').html('');$('.main .chatbox > .header > .switch_user').addClass('d-none');$('.main .chatbox > .header .toggle_switch_user').addClass('d-none');$('.main .chatbox > .header > .switch_user').removeClass('open');$('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image').html('');$('.main .chatbox > .header > .switch_user > div.search_users > .search > div > input').val('');$('.main .chatbox > .header > .switch_user > div.search_users > .list > ul').html('');$('.main .chatbox > .header > .switch_user > .user_id > input').val('0');$('.main .chatbox > .header > .switch_user > .username').text('');$(".main .chatbox > .header > .message_selection").find('input').prop('checked',!1);$(".main .chatbox > .header > .message_selection").addClass('d-none');$(".main .chatbox > .contents > .chat_messages").removeClass('multi_selection');$(".main .chatbox > .header > .icons .toggle_checkbox").addClass('d-none');$('.main .middle .confirm_box > .error').hide();$('.main .middle .confirm_box').addClass('d-none');$('.main .middle .chatbox > .alert_message').hide();$('.main .chatbox > .header .join_video_call_icon').removeClass('online');$('.main .chatbox > .header .join_video_call_icon').addClass('d-none');$('.main .chatbox > .header .join_audio_call_icon').removeClass('online');$('.main .chatbox > .header .join_audio_call_icon').addClass('d-none');if(audio_message_preview!==undefined&&audio_message_preview!==null){audio_message_preview.pause()}}
var data={load:"group_messages",};if(load.group_id!==undefined){data.load="group_messages";data.group_id=load.group_id;var list_element=$('.main .aside > .site_records > .records > .list > li.group_conversation[group_id="'+load.group_id+'"]');list_element.find('.title > .unread').html('')}else if(load.user_id!==undefined){data.load="private_chat_messages";data.user_id=load.user_id;var list_element=$('.main .aside > .site_records > .records > .list > li.private_conversation[user_id="'+load.user_id+'"]');list_element.find('.title > .unread').html('')}
if(load.find_message!==undefined){data.find_message=!0}
if(load.search!==undefined){if(load.search_message_id!==undefined&&load.search_message_id){data.search_message_id=!0}
data.search=load.search;$('.main .chatbox > .header > .icons > span.reload_conversation').removeClass('d-none');$('.main .chatbox > .contents > .chat_messages').addClass('searching')}else{$('.main .chatbox').removeClass('chat_message_selection searching_chat_message');$('.main .middle .search_messages > div > .search > div > input').val('');$('.main .chatbox > .header > .icons > span.reload_conversation').addClass('d-none');$('.main .chatbox > .contents > .chat_messages').removeClass('searching')}
if(load.message_id_less_than!==undefined){data.message_id_less_than=load.message_id_less_than}
if(load.prepend_messages===undefined&&load.append_messages===undefined){close_module('.grid_list','.chatbox > .footer');close_module('.attachments','.chatbox > .footer');$(".main .chatbox > .footer").hide();$('.main .attached_message_id > input').val('0');$('.main .chatbox > .footer .attached_message').hide();if($('.main .middle .conversation_loader > ul > li').length===0){$('.main .middle .conversation_loader > ul').html(loader_content())}
$('.main .middle .conversation_loader').removeClass('error').show()}
if(load.message_id!==undefined){data.message_id=load.message_id}
if($('.main .middle').hasClass('display_chat_alone')){data.display_chat_alone=!0}
if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
load_conversation_ajax_request(data,load)}
function load_conversation_ajax_request(data,load){var old_data=data;var browser_title=default_meta_title;var browser_address_bar=baseurl;load_messages_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_messages_request!=null){load_messages_request.abort();load_messages_request=null}
if(load_group_header_request!=null){load_group_header_request.abort();load_group_header_request=null}
if(load_messages_reload_timeout!==null){clearTimeout(load_messages_reload_timeout);load_messages_reload_timeout=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);load_messages_reload_loop=0;if(load.prepend_messages===undefined&&load.append_messages===undefined){if(data.error_message!==undefined){$('.main .chatbox > .contents > .error_message > div > div > .image').html('').hide();$('.main .chatbox > .contents > .error_message > div > div > .text > .title').replace_text(data.error_message.title);$('.main .chatbox > .contents > .error_message > div > div > .text > .subtitle').replace_text(data.error_message.subtitle);if(data.error_message.image!==undefined){var error_image='<img src="'+data.error_message.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';$('.main .chatbox > .contents > .error_message > div > div > .image').html(error_image).show()}
$('.main .chatbox > .contents > .error_message').show()}
if(data.info_box!==undefined){var info_box='<div ';$.each(data.info_box.attributes,function(attr_key,attr_value){info_box+=attr_key+'="'+attr_value+'" '});info_box+='>';info_box+='<div class="content">'+data.info_box.content+'</div>';info_box+='</div>';$('.main .chatbox > .info_box').html(info_box);$('.main .chatbox > .info_box').show();if(data.info_box.trigger_click!==undefined){$('.main .chatbox > .info_box > .api_request').trigger('click')}}
if(data.loaded!==undefined){if(data.error_message===undefined){$('.main .chatbox > .header > .icons').removeClass('d-none')}
if(data.loaded.react_messages!==undefined&&data.loaded.react_messages){$(".main .chatbox").attr('react_messages',!0)}else{$(".main .chatbox").removeAttr('react_messages')}
if(data.loaded.view_info!==undefined){$('.main .chatbox > .header').addClass('view_info');$('.main .chatbox > .header > .image').addClass('get_info');$('.main .chatbox > .header > .heading').addClass('get_info')}
if(data.loaded.browser_title!==undefined){browser_title=data.loaded.browser_title}
if(data.loaded.browser_address_bar!==undefined){browser_address_bar=data.loaded.browser_address_bar;if($('.main .middle').hasClass('display_chat_alone')){if(!browser_address_bar.includes("display_chat_alone=true")){let conv_url_separator=browser_address_bar.includes("?")?"&":"?";browser_address_bar+=conv_url_separator+"display_chat_alone=true"}}}
if(data.loaded.title!==undefined){$(".main .chatbox > .header > .heading > .title").replace_text(data.loaded.title)}
if(data.loaded.subtitle!==undefined){$(".main .chatbox > .header > .heading > .subtitle").replace_text(data.loaded.subtitle)}else{$(".main .chatbox > .header > .heading > .subtitle").replace_text('')}
if(data.loaded.image!==undefined){$(".main .chatbox > .header > .image > .thumbnail").addClass('img_loaded');$(".main .chatbox > .header > .image > .thumbnail > img").attr('src',data.loaded.image);$(".main .chatbox > .header > .image > .thumbnail > img").on('error',function(){$(this).attr("src",blur_img_url)})}
if(data.loaded.group_header!==undefined){if(data.loaded.group_id!==undefined){load_group_header(data.loaded.group_id)}}
if(data.loaded.multi_select!==undefined&&data.loaded.multi_select){$(".main .chatbox > .header > .message_selection").removeClass('d-none');$(".main .chatbox > .header > .icons .toggle_checkbox").removeClass('d-none')}
if(data.loaded.background_image!==undefined){$(".main .middle .chatbox > .background_image").html('<img src="'+data.loaded.background_image+'" onerror="this.onerror=null; this.style.display='+"'none'"+';"/>')}else{$(".main .middle .chatbox > .background_image").html('')}
if(data.loaded.group_id!==undefined){$(".main .chatbox").removeAttr('user_id');$(".main .chatbox").attr('group_id',data.loaded.group_id);if($('.main .chatbox').attr('group_id')!=='all'&&$('.main .chatbox > .header > .switch_user').length>0){var default_user_image=$('.logged_in_user_avatar').attr('src');default_user_image="<img src='"+default_user_image+"'"+' onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';$('.main .chatbox > .header > .switch_user').removeClass('d-none');$('.main .chatbox > .header > .switch_user > .username').text($('.logged_in_user_name').text());$('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image').html('');$('.main .chatbox > .header > .switch_user > .user_id > input').val('0');$('.main .chatbox > .header .toggle_switch_user').removeClass('d-none')}}else if(data.loaded.user_id!==undefined){$(".main .chatbox").removeAttr('group_id');$(".main .chatbox").attr('user_id',data.loaded.user_id)}else{$(".main .chatbox").removeAttr('user_id');$(".main .chatbox").removeAttr('group_id')}
if(data.loaded.video_chat!==undefined&&data.loaded.video_chat===!0){$('.main .chatbox > .header .join_video_call_icon').removeClass('d-none');if(data.loaded.video_chat_online!==undefined&&data.loaded.video_chat_online===!0){$('.main .chatbox > .header .join_video_call_icon').addClass('online')}
if(load.open_video_call!==undefined){$('.main .chatbox > .header .join_video_call_icon').trigger('click')}}
if(data.loaded.audio_chat!==undefined&&data.loaded.audio_chat===!0){$('.main .chatbox > .header .join_audio_call_icon').removeClass('d-none');if(data.loaded.audio_chat_online!==undefined&&data.loaded.audio_chat_online===!0){$('.main .chatbox > .header .join_audio_call_icon').addClass('online')}
if(load.open_audio_call!==undefined){$('.main .chatbox > .header .join_audio_call_icon').trigger('click')}}
if(data.loaded.messaging!==undefined&&data.loaded.messaging===!0){$(".main .chatbox > .footer").show()}else{$(".main .chatbox > .footer").hide()}
$(".main .chatbox > .footer .messenger_features").show();if(data.loaded.disable_features!==undefined){$.each(data.loaded.disable_features,function(feature_index,feature){if(feature==='voice_message'){if(!$('.main .chatbox > .footer > .editor .audio_recorder_box').hasClass('d-none')){$('.cancel_recording').trigger('click')}}
if(feature==='attach_files'){$('.main .chatbox > .footer > .attachments > div > .files > ul').html('');$('.attachments > div > .attached_files > form').html('');$('.chatbox > .footer > .attachments').removeClass('hasAttachments')}
if(feature==='gifs'){deattach_media()}
feature=".main .chatbox > .footer .messenger_features."+feature+"_feature";$(feature).hide()})}}
update_wsocket_data()}
if(load.load_group_info!==undefined||load.load_user_info!==undefined){$('.main .chatbox > .header > .heading > .view_info').trigger('click')}
if(load.prepend_messages!==undefined){data.prepend_messages=!0}else{data.scrollToBottom=!0}
load_messages(data)}else{console.log('ERROR : '+data)}
if(load.prepend_messages===undefined&&load.append_messages===undefined){if(browser_title!==undefined){change_browser_title(browser_title);history.pushState({},null,browser_address_bar)}}
$('.main .middle .conversation_loader').removeClass('error').hide();$('.main .chatbox > .contents > .chat_messages').removeClass('loading EndResults')}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+errorThrown);console.log('PAGE CONTENT : '+data);$('.main .middle .conversation_loader').addClass('error');if(load.prepend_messages===undefined&&load.append_messages===undefined){load_messages_reload_loop=load_messages_reload_loop+1;if(load_messages_reload_loop<5){load_messages_reload_timeout=setTimeout(function(){load_conversation_ajax_request(old_data,load)},3500)}else{load_messages_reload_loop=0}}}
$('.main .chatbox > .contents > .chat_messages').removeClass('loading EndResults')})}
function load_messages(data){var messages='';var highlight_message_element=!1;var highlight_message_id=0;var total_messages=0
if(data.loaded!==undefined){if(data.loaded.group_id!==undefined&&data.loaded.group_id!=$('.main .chatbox').attr('group_id')){data.messages=[]}else if(data.loaded.user_id!==undefined&&data.loaded.user_id!=$('.main .chatbox').attr('user_id')){data.messages=[]}}
if(data.messages!==undefined){total_messages=data.messages.length;$.each(data.messages,function(key,val){var message=data.messages[key];var add_to_list=!0;if(message.message_id!==undefined){if($('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+message.message_id+'"]').length>0){add_to_list=!1}
if(message.highlight_message!==undefined){highlight_message_element=!0;highlight_message_id=message.message_id}}
if(add_to_list){if(message.message_label===undefined){message.message_label='Message'}
if(message.message_id===undefined){messages=messages+'<li class="set_message_date has_excerpt message '+message.class+'" message_label="'+message.message_label+'">'}else{messages=messages+'<li class="set_message_date has_excerpt message '+message.class+'" message_label="'+message.message_label+'" message_id="'+message.message_id+'">'}
if(message.date!==undefined){messages=messages+'<span class="date" message_sent_on="'+message.date+'"><span>'+message.date+'</span></span>'}
messages=messages+'<div>';messages=messages+'<div class="left">';if(data.loaded!==undefined&&data.loaded.multi_select!==undefined&&data.loaded.multi_select){messages=messages+'<label class="selector select_item">';messages=messages+'<input type="checkbox" name="message_ids[]" value="'+message.message_id+'">';messages=messages+'<span class="checkmark"></span>';messages=messages+'</label>'}
if(message.image!==undefined){messages=messages+'<span class="image">';messages=messages+'<img loading="lazy" src="'+message.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';">';messages=messages+'</span>'}
messages=messages+'</div>';messages=messages+'<div class="right">';messages=messages+'<div class="header">';if(message.name_color===undefined){message.name_color='#e91e63'}
if(message.sender_user_id!==undefined){var group_id_attribute='';if(message.message_group_id!==undefined){group_id_attribute='data-group_identifier="'+message.message_group_id+'"'}
messages=messages+'<span class="send_by get_info" '+group_id_attribute+' user_id="'+message.sender_user_id+'" role="button" style="color:'+message.name_color+';">';messages=messages+message.posted_by+'</span>'}else{messages=messages+'<span class="send_by" style="color:'+message.name_color+';">'+message.posted_by+'</span>'}
if(message.read_status!==undefined){if(message.read_status==='read'){messages=messages+'<span class="read_status read"><i class="bi bi-check-all"></i></span>'}else{messages=messages+'<span class="read_status"><i class="bi bi-check d-none"></i></span>'}}
if(message.badge!=undefined){messages=messages+'<span class="text_badge"';if(message.badge.text_color!=undefined&&message.badge.background!=undefined){messages=messages+' style="color:'+message.badge.text_color+';';messages=messages+'border:0px;';messages=messages+'background:'+message.badge.background+';"'}
messages=messages+'>'+message.badge.text+'</span>'}
if(message.sample_data!=undefined){messages=messages+'<div class="tools">'}else{messages=messages+'<div class="tools dropdown_button">'}
if(message.time!=undefined){messages=messages+'<span class="timestamp">'+message.time+'</span>'}
if(message.sample_data!=undefined){messages=messages+'<div class="options">';messages=messages+'<span class="bi bi-clock"></span>';messages=messages+'</div>'}else if(message.options!=undefined&&message.options.length!=0){messages=messages+'<div class="options">';messages=messages+'<span class="iconic_arrow-down"></span>';messages=messages+'<div class="dropdown_list">';messages=messages+'<ul>';$.each(message.options,function(optkey,optval){var attributes=message.options[optkey].attributes;messages=messages+'<li ';$.each(attributes,function(attrkey,attrval){messages=messages+attrkey+'="'+attributes[attrkey]+'" '});messages=messages+'class="hide_onClick '+message.options[optkey].class+'">'+message.options[optkey].option+'</li>'});messages=messages+'</ul>';messages=messages+'</div>';messages=messages+'</div>'}
messages=messages+'</div>';messages=messages+'</div>';var empty_message_content=!0;if(message.content!==undefined&&message.content.trim()!==''||message.reply_message!==undefined){empty_message_content=!1;messages=messages+'<div class="content">';messages=messages+'<div>';if(message.reply_message!==undefined){var attached_message='';attached_message+='message_id="'+message.parent_message_id+'" ';messages=messages+'<div class="quote load_message" '+attached_message+'>';messages=messages+'<span class="transparent_layer"></span>';messages=messages+'<div>';messages=messages+'<div class="left">';messages=messages+'<div class="send_by">'+message.attached_message_author+'</div>';messages=messages+'<div class="text">'+message.reply_message+'</div>';messages=messages+'</div>';if(message.reply_thumbnail!==undefined){messages=messages+'<div class="right">';messages=messages+'<div class="thumbnail">';messages=messages+'<img loading="lazy" src="'+message.reply_thumbnail+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';messages=messages+'</div>';messages=messages+'</div>'}
messages=messages+'</div></div>'}
if(message.content!==undefined&&message.content.trim()!==''){messages=messages+'<div class="message_content">';messages=messages+message.content
messages=messages+'</div>';messages=messages+'<span class="read_more_toggle">';messages=messages+'<span><i class="bi bi-chevron-double-down"></i></span>';messages=messages+'</span>'}
messages=messages+'</div>';messages=messages+'</div>'}
if(message.attachments!==undefined){var additional_class='';if(empty_message_content){additional_class='empty_message_content'}
messages=messages+'<div class="files '+additional_class+'">';messages=messages+'<div>';messages=messages+'<ul class="'+message.attachment_type+'">';var thumb_image_class='single_image';if(message.attachments.length>1){thumb_image_class=''}
if(message?.attachment_type==='video_files'&&Array.isArray(message.attachments)&&message.attachments.length>1){thumb_image_class='group_video_file'}
$.each(message.attachments,function(attachment_index,attachment_value){var attachment=message.attachments[attachment_index];if(attachment.image!==undefined){var image_attributes='';if(attachment.image_size!==undefined&&message.attachments.length===1){image_attributes='style="width:'+attachment.image_size.width+'px; height:'+attachment.image_size.height+'px;"'}
messages=messages+'<li>';messages=messages+'<span class="file image '+thumb_image_class+'" '+image_attributes+'>';messages=messages+'<img loading="lazy" class="preview_image" original="'+attachment.original+'" src="'+attachment.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';if(message.attachment_type==='image_files'||message.attachment_type==='screenshot'){if(attachment.download_file!==undefined){var download_attributes='';$.each(attachment.download_file,function(download_attr_key,download_attr_value){download_attributes=download_attributes+download_attr_key+'="'+download_attr_value+'" '});messages+='<span class="file_download">';messages+='<span class="download_file" download="attachment" '+download_attributes+'><i class="bi bi-arrow-down-circle-fill"></i></span>';messages+='</span>'}}
messages=messages+'</span>';messages=messages+'</li>'}else if(message.attachment_type==='video_files'&&attachment.thumbnail!==undefined){messages=messages+'<li>';messages=messages+'<span class="file video '+thumb_image_class+'">';messages=messages+'<img loading="lazy" src="'+attachment.thumbnail+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';messages=messages+'<span class="play_icon preview_video" video_file="'+attachment.video+'" mime_type="'+attachment.file_type+'" thumbnail="'+attachment.thumbnail+'">';messages=messages+'<i class="bi bi-play-fill"></i></span>';if(attachment.download_file!==undefined){var download_attributes='';$.each(attachment.download_file,function(download_attr_key,download_attr_value){download_attributes=download_attributes+download_attr_key+'="'+download_attr_value+'" '});messages+='<span class="file_download">';messages+='<span class="download_file" download="attachment" '+download_attributes+'>';messages+='<i class="bi bi-arrow-down-circle-fill"></i>';messages+='</span>';messages+='</span>'}
messages=messages+'</span>';messages=messages+'</li>'}else if(message.attachment_type==='user_location'){messages=messages+'<li>';messages=messages+'<div class="user_location generate_user_location" lat="'+attachment.latitude+'" long="'+attachment.longitude+'">';messages=messages+'</div>';messages=messages+'</li>'}else if(message.attachment_type==='url_meta'){var url_attributes='class="url_meta open_link" link="'+attachment.url+'" target="_blank"';messages=messages+'<li>';if(attachment.mime_type==='video/mpeg'||attachment.mime_type==='video/ogg'||attachment.mime_type==='video/webm'||attachment.mime_type==='video/mp4'||attachment.mime_type==='video/vimeo'||attachment.mime_type==='video/youtube'||attachment.mime_type==='video/dailymotion'){if(attachment.mime_type==='video/mp4'||attachment.mime_type==='video/mpeg'||attachment.mime_type==='video/ogg'||attachment.mime_type==='video/webm'){url_attributes='class="url_meta preview_video" mime_type="'+attachment.mime_type+'" video_file="'+attachment.url+'" thumbnail="'+attachment.meta_image+'"'}else{url_attributes='class="url_meta preview_video" mime_type="'+attachment.mime_type+'" video_url="'+attachment.url+'" thumbnail="'+attachment.meta_image+'"'}}else if(attachment.iframe_embed!==undefined){url_attributes='class="url_meta iframe_embed" embed_url="'+attachment.iframe_embed+'"';if(attachment.iframe_class!==undefined){url_attributes=url_attributes+' iframe_class="'+attachment.iframe_class+'"'}
if(attachment.iframe_relative_height!==undefined){url_attributes=url_attributes+' iframe_relative_height="'+attachment.iframe_relative_height+'"'}}
messages=messages+'<span '+url_attributes+'>';messages=messages+'<span class="image">';messages=messages+'<img loading="lazy" src="'+attachment.meta_image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';if(attachment.mime_type==='video/mpeg'||attachment.mime_type==='video/ogg'||attachment.mime_type==='video/webm'||attachment.mime_type==='video/mp4'||attachment.mime_type==='video/vimeo'||attachment.mime_type==='video/youtube'||attachment.mime_type==='video/dailymotion'){messages=messages+'<span class="play_icon">';messages=messages+'<i class="bi bi-play-fill"></i>';messages=messages+'</span>'}
messages=messages+'</span>';messages=messages+'<span class="details">';messages=messages+'<span class="title">'+attachment.meta_title+'</span>';messages=messages+'<span class="description">'+attachment.meta_description+'</span>';messages=messages+'</span>';messages=messages+'</span>';messages=messages+'</li>'}else if(message.attachment_type==='audio_files'||message.attachment_type==='audio_message'){messages=messages+'<li>';messages=messages+'<div class="file audio_preview"><div>';messages=messages+'<div class="audio_controls">';messages=messages+'<div><div><div>';messages=messages+'<span class="play_button" audio="'+attachment.audio_file+'" mime_type="'+attachment.file_type+'">';messages=messages+'<i class="bi bi-play-fill"></i></span>';messages=messages+'<span class="current_timestamp"><span>00:00</span></span> ';messages=messages+'<div class="control"><div> ';messages=messages+'<input type="range" min="1" max="100" value="1" class="audio_player_range_control audio_preview_seekbar"> ';messages=messages+'</div></div>';messages=messages+'<span class="duration"> <span>00:00</span> </span>';messages=messages+'<div class="volume d-none"> ';messages=messages+'<div class="control" style="display: none;"> ';messages=messages+'<div> <div> ';messages=messages+'<input type="range" min="1" max="100" value="1" class="audio_player_range_control">';messages=messages+'</div> </div> </div>';messages=messages+'<span class="icon"><i class="bi bi-volume-down-fill"></i></span>';messages=messages+'</div> </div>';messages=messages+'</div> </div>';messages=messages+'</div>';if(message.attachment_type==='audio_files'){if(attachment.download_file!==undefined){var download_attributes='';$.each(attachment.download_file,function(download_attr_key,download_attr_value){download_attributes=download_attributes+download_attr_key+'="'+download_attr_value+'" '});messages=messages+'<div class="icon download_file" download="attachment" '+download_attributes+'> ';messages=messages+'<i class="bi bi-arrow-down"></i>';messages=messages+'</div>'}else{messages=messages+'<div class="icon"> ';messages=messages+'<i class="bi bi-music-note"></i>';messages=messages+'</div>'}}else{messages=messages+'<div class="icon"> ';messages=messages+'<i class="bi bi-mic-fill"></i>';messages=messages+'</div>'}
messages=messages+'</div></div>';messages=messages+'</li>'}else if(attachment.file_name!==undefined){messages=messages+'<li>';messages=messages+'<span class="file others"><span>';if(message.attachment_type==='pdf_files'&&attachment.thumbnail!==undefined){messages=messages+'<span class="icon pdf_preview_thumnail">';var pdf_preview_tag='class="preview_pdf" pdf="'+attachment.preview_pdf+'"';messages=messages+'<img loading="lazy" '+pdf_preview_tag+' src="'+attachment.thumbnail+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';messages=messages+'</span>'}else if(attachment.file_icon!==undefined){messages=messages+'<span class="icon">';messages=messages+'<img loading="lazy" src="'+attachment.file_icon+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';messages=messages+'</span>'}
messages=messages+'<span class="file_details"><span class="name">'+attachment.file_name+'</span>';if(attachment.file_size!==undefined){messages=messages+'<span class="subtitle">'+attachment.file_size+'</span>'}else if(attachment.subtitle!==undefined){messages=messages+'<span class="subtitle">'+attachment.subtitle+'</span>'}
messages=messages+'</span>';if(attachment.download_file!==undefined){var download_attributes='';$.each(attachment.download_file,function(download_attr_key,download_attr_value){download_attributes=download_attributes+download_attr_key+'="'+download_attr_value+'" '});messages+='<span class="file_download">';messages+='<span class="download_file" download="attachment" '+download_attributes+'><i class="bi bi-arrow-down-circle-fill"></i></span>';messages+='</span>'}
messages=messages+'</span></span>';messages=messages+'</li>'}
messages=messages+'</li>'});messages=messages+'</ul>';messages=messages+'</div>';messages=messages+'</div>'}
if(message.audio_message!=undefined){messages=messages+'<li>';messages=messages+'<span class="file video"></span>';messages=messages+'</li>';messages=messages+'<div class="audio_file">';messages=messages+'<div>';messages=messages+'</div>';messages=messages+'</div>'}
if(data.loaded!==undefined&&data.loaded.react_messages!==undefined&&data.loaded.react_messages){var react_messages=!0}else{var react_messages=!1}
if(!message.system_message&&message.reactions!==undefined&&message.reactions.total_reactions!==undefined||!message.system_message&&react_messages){var message_reactions_class='';if(message.reactions.total_reactions===undefined){message_reactions_class=' d-none'}
messages=messages+'<div class="message_reactions'+message_reactions_class+'">';if(react_messages){messages=messages+'<div class="selection d-none">';messages=messages+'<ul>';var reactions=['like','haha','love','angry','wow','sad'];var reaction_class='';$.each(reactions,function(r_index,reaction){reaction_class='reaction reaction-'+reaction;if(message.reactions.user_reaction!==undefined&&reaction==message.reactions.user_reaction){reaction_class+=' reacted'}
if(data.loaded.group_id!==undefined){messages=messages+'<li class="api_request" data-reaction="'+reaction+'" data-add="group_message_reaction"';messages=messages+' data-group_message_id="'+message.message_id+'" pass_send_as_user_id=true>'}else{messages=messages+'<li class="api_request" data-reaction="'+reaction+'" data-add="private_chat_message_reaction"';messages=messages+' data-private_chat_message_id="'+message.message_id+'">'}
messages=messages+'<span class="'+reaction_class+'"></span>';messages=messages+'</li>'});messages=messages+'</ul>';messages=messages+'</div>'}
messages=messages+'<div class="reactions">';messages=messages+'<ul>';if(message.reactions.total_reactions!==undefined){$.each(message.reactions.total_reactions,function(reaction,total){messages=messages+'<li>';messages=messages+'<span class="reaction reaction-'+reaction+'"></span>';messages=messages+'<span class="total_reactions">'+total+'</span>';messages=messages+'</li>'})}else if(react_messages){}
messages=messages+'</ul>';messages=messages+'</div>';messages=messages+'</div>'}
messages=messages+'</div>';messages=messages+'</div>';messages=messages+'</li>'}})}
var append_messages=!1;if(data.append!==undefined||data.append_messages!==undefined){append_messages=!0;$('.main .chatbox > .contents > .chat_messages > ul').prepend(messages)}else if(data.prepend_messages!==undefined){$('.main .chatbox > .contents > .chat_messages > ul').append(messages)}else{$('.main .chatbox > .contents > .chat_messages > ul').html(messages);$('.main .chatbox .selector').addClass('d-none')}
if(!$('.main .chatbox .message_selection > .selector').is(":visible")){$('.main .chatbox .selector').addClass('d-none')}
append_read_more();set_message_dates(append_messages);generate_user_location();if(data.scrollToBottom!==undefined&&data.loaded!==undefined&&data.loaded.scroll_from_message_id!==undefined&&total_messages>0){var scroll_from_message_id=data.loaded.scroll_from_message_id;scroll_from_message_id=$('.main .chatbox > .contents > .chat_messages').find('ul > li[message_id="'+scroll_from_message_id+'"]');if(scroll_from_message_id.length){var scrollToPosition=scroll_from_message_id[0].offsetTop;scrollToPosition=scrollToPosition-180;$('.main .chatbox > .contents > .chat_messages').animate({scrollTop:scrollToPosition},'smooth')}else{var scroll_from_message_id=$('.main .chatbox > .contents > .chat_messages > ul > li:last-child');let scrollToPosition=scroll_from_message_id.position().top+$('.main .chatbox > .contents > .chat_messages').scrollTop();$('.main .chatbox > .contents > .chat_messages').animate({scrollTop:scrollToPosition},'smooth')}}else if(data.scrollToBottom!==undefined&&total_messages>0){$('.main .chatbox > .contents > .chat_messages').scrollTop(0)}else if(highlight_message_element){highlight_message(highlight_message_id)}}
$('body').on('click',".main .chatbox > .header > .icons .toggle_checkbox",function(e){if($('.main .chatbox .selector').length>0){$('.main .chatbox .selector').toggleClass('d-none multi_selection');$('.main .chatbox').toggleClass('chat_message_selection');$('.main .chatbox .selector').parent('.left').toggleClass('selection_visible')}
if($('.main .chatbox > .header > div > .selector').hasClass('d-none')){$('.main .chatbox .selector > input[type="checkbox"]').prop('checked',!1);$(".main .chatbox > .header > .icons > span.delete_multiple_messages").addClass('d-none')}});function remove_messages(data){var message_element='';var noerror=!0;if(data!==undefined){if(data.conversation_type!==undefined){if(data.conversation_type==='group_chat'&&$(".main .chatbox").attr('group_id')===undefined){noerror=!1}else if(data.conversation_type==='private_chat'&&$(".main .chatbox").attr('user_id')===undefined){noerror=!1}}
if(noerror&&data.message_id!==undefined){if(Array.isArray(data.message_id)){$.each(data.message_id,function(index,message_id){message_element=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+message_id+'"]');message_element.remove()})}else{message_element=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+data.message_id+'"]');message_element.remove()}}}}
function generate_user_location(){var jsFileUrl='https://unpkg.com/leaflet/dist/leaflet.js';if(!window.isLeafletLoaded){addCssFile('https://unpkg.com/leaflet/dist/leaflet.css');$.getScript(jsFileUrl,function(){window.isLeafletLoaded=!0;generate_user_location_callback()})}else{generate_user_location_callback()}}
function generate_user_location_callback(){if(typeof L!=='undefined'&&typeof L.map==='function'){$('.main .chat_messages > ul > li > div > .right > .files > div > .user_location > li > .generate_user_location').each(function(){$(this).html('<div class="map_wrapper"> <div class="map"></div> <div class="open_map"></div> </div> ');$(this).removeClass('generate_user_location');var latitude=$(this).attr('lat');var longitude=$(this).attr('long');if(system_variable('map_for_location_sharing')==='openstreetmap'){var map_link=`https://www.openstreetmap.org/?mlat=${latitude}&mlon=${longitude}&zoom=15`}else if(system_variable('map_for_location_sharing')==='baidu_maps'){var map_link=`https://map.baidu.com/?latlng=${latitude},${longitude}&zoom=15`}else{var map_link=`https://www.google.com/maps?q=${latitude},${longitude}`}
$(this).find('.map_wrapper > .open_map').addClass('open_link');$(this).find('.map_wrapper > .open_map').attr('target','_blank');$(this).find('.map_wrapper > .open_map').attr('link',map_link);var mapContainer=$(this).find('.map_wrapper .map')[0];var map=L.map(mapContainer,{zoomControl:!1,attributionControl:!1}).setView([latitude,longitude],13);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);L.marker([latitude,longitude]).addTo(map)})}}
function mention_everyone(realtime_log_id){var data={add:'notify_group_members',realtime_log_id:realtime_log_id,};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:data,async:!0,success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.continue_process!==undefined){mention_everyone(realtime_log_id)}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){console.log('ERROR : '+errorThrown)})}
function update_message_reactions(data){if(data!==undefined){var update_reactions=!1;if(data.message_id!==undefined){if(data.group_id!==undefined&&$(".main .chatbox").attr('group_id')!==undefined){if($(".main .chatbox").attr('group_id')==data.group_id||$(".main .chatbox").attr('group_id')=='all'){update_reactions=!0}}else if(data.user_ids!==undefined&&$(".main .chatbox").attr('user_id')!==undefined){update_reactions=!0}
if(update_reactions){var message_element=$('.main .chatbox > .contents > .chat_messages > ul > li[message_id="'+data.message_id+'"]');var update_content='';message_element.find('.message_reactions > .selection > ul > li > .reaction').removeClass('reacted');if(data.user_reaction!==undefined){message_element.find('.message_reactions > .selection > ul > li > .reaction').removeClass('reacted');var user_reaction_class='.reaction-'+data.user_reaction;message_element.find('.message_reactions > .selection > ul > li > .reaction'+user_reaction_class).addClass('reacted')}
var total_reactions=0;if(data.total_reactions!==undefined){total_reactions=Object.keys(data.total_reactions).length}
if(total_reactions>0){$.each(data.total_reactions,function(reaction,total){update_content=update_content+'<li>';update_content=update_content+'<span class="reaction reaction-'+reaction+'"></span>';update_content=update_content+'<span class="total_reactions">'+total+'</span>';update_content=update_content+'</li>'})}else{if($(".main .chatbox").attr('react_messages')!==undefined){}}
message_element.find('.message_reactions > .reactions > ul').html(update_content);if(total_reactions>0){message_element.find('.message_reactions').removeClass('d-none')}}}}}
$('body').on('click','.main .chatbox .selector.select_all > input',function(e){$('.main .chatbox .selector.select_item > input').prop('checked',this.checked).change()});$('body').on('change','.main .chatbox .selector.select_item > input',function(e){if($(".main .chatbox .selector.select_item > input:checked").length>0){$(".main .chatbox > .header > .icons > span.delete_multiple_messages").removeClass('d-none')}else{$(".main .chatbox > .header > .icons > span.delete_multiple_messages").addClass('d-none')}});$('.main .chat_messages').on('click','.message_reactions > .selection > ul > li',function(e){$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none')});$('.main .chat_messages').on('click','.message_reactions > .reactions > ul > li > .reaction',function(e){if($(this).parent().parent().parent().parent().find('.selection').hasClass('d-none')){$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none');$(this).parent().parent().parent().parent().find('.selection').removeClass('d-none')}else{$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none')}});$('.main').on('click','.middle',function(e){var hide_reaction_selection=!0;if($(e.target).hasClass('react_to_messages')){hide_reaction_selection=!1}else if($(e.target).parents('.reactions').hasClass('reactions')){hide_reaction_selection=!1}
if(hide_reaction_selection){$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none')}});$('.main .chat_messages').on('click','.right > .header > .tools > div .dropdown_list > ul > li.react_to_messages',function(e){$reaction_element=$(this).parent().parent().parent().parent().parent().parent().find('.message_reactions');if($reaction_element.find('.selection').hasClass('d-none')){$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none');$reaction_element.find('.selection').removeClass('d-none');if($reaction_element.hasClass('d-none')){$reaction_element.addClass('reaction_d-none');$reaction_element.removeClass('d-none')}}else{if($reaction_element.hasClass('reaction_d-none')){$reaction_element.removeClass('reaction_d-none');$reaction_element.addClass('d-none')}
$('.main .chatbox > .contents > .chat_messages .message_reactions > .selection').addClass('d-none')}});function set_message_dates(append_messages=!1){$('.main .chatbox > .contents > .chat_messages > ul > li.set_message_date').each(function(){var message_sent_on='';if($(this).find('.date').attr('message_sent_on')!==undefined){message_sent_on=$(this).find('.date').attr('message_sent_on');if(!append_messages){$('.main .chatbox > .contents > .chat_messages > ul > li > .date[message_sent_on="'+message_sent_on+'"]').removeClass('show');$(this).find('.date').addClass('show')}else{if($('.main .chatbox > .contents > .chat_messages > ul > li > .date[message_sent_on="'+message_sent_on+'"]').length<2){$(this).find('.date').addClass('show')}}}
$(this).removeClass('set_message_date')})}
function append_read_more(){var read_more_criteria=300;if($('.main .chatbox > .contents').attr('read_more_criteria')!==undefined){read_more_criteria=parseInt($('.main .chatbox > .contents').attr('read_more_criteria'));if(isNaN(read_more_criteria)){read_more_criteria=300}}
$('.main .chatbox > .contents > .chat_messages > ul > li.has_excerpt').each(function(){if($(this).find('div > .right > .content > div > .message_content').outerHeight()>=read_more_criteria){$(this).find('div > .right > .content > div > .message_content').css('max-height',read_more_criteria+'px');$(this).addClass('excerpt')}
$(this).removeClass('has_excerpt')})}
$('.main .chat_messages').on('click','li.excerpt .content > div > .read_more_toggle',function(e){$(this).parent().find('.message_content').css('max-height','');$(this).parents('li.excerpt').removeClass('excerpt')});$('.main .chat_messages').on('click','.play_button',function(e){if($(this).find('i').hasClass('bi-stop-fill')){$('.main .chatbox > .contents > .chat_messages .file.audio_preview').removeClass('current_playing');audio_message_preview.pause();audio_message_preview.currentTime=0}else{var audio_tag=$('#audio_message_preview');audio_tag.find('source').attr('src',$(this).attr('audio'));if($(this).attr('mime_type')!==undefined){audio_tag.find('source').attr('type',$(this).attr('mime_type'))}else{audio_tag.find('source').removeAttr('type')}
$(".main .chat_messages .audio_controls > div > div > div > .current_timestamp > span").text('00:00');$(".main .chat_messages .audio_controls > div > div > div > .duration > span").text('00:00');$(".audio_preview_seekbar").val(0).trigger("input");$('.main .chatbox > .contents > .chat_messages .file.audio_preview').removeClass('current_playing');$(this).parents('.audio_preview').addClass('current_playing');audio_message_preview.pause();audio_message_preview.load();audio_message_preview.play()}});audio_message_preview.addEventListener('play',function(){if(audio_player!==undefined&&audio_player!==null){audio_player_handler('pause')}
if(video_preview!==undefined&&video_preview!==null){video_preview.pause()}
$('.main .chat_messages .play_button > i').removeClass('bi-stop-fill');$('.main .chat_messages .play_button > i').addClass('bi-play-fill');$('.main .chat_messages .current_playing .play_button > i').removeClass('bi-play-fill');$('.main .chat_messages .current_playing .play_button > i').addClass('bi-stop-fill')});audio_message_preview.addEventListener('pause',function(){$('.main .chat_messages .play_button > i').removeClass('bi-stop-fill');$('.main .chat_messages .play_button > i').addClass('bi-play-fill')});audio_message_preview.addEventListener('ended',function(){$('.main .chat_messages .play_button > i').removeClass('bi-stop-fill');$('.main .chat_messages .play_button > i').addClass('bi-play-fill')});audio_message_preview.ontimeupdate=function(){if(isFinite(audio_message_preview.currentTime)){var current_timestamp=timestamp_convertor(audio_message_preview.currentTime);$(".main .chat_messages .current_playing .audio_controls > div > div > div > .current_timestamp > span").text(current_timestamp)}
if(isFinite(audio_message_preview.duration)){var audio_duration=timestamp_convertor(audio_message_preview.duration);$(".main .chat_messages .current_playing .audio_controls > div > div > div > .duration > span").text(audio_duration)}
var percentage=(audio_message_preview.currentTime/audio_message_preview.duration)*100;if(isFinite(percentage)){$(".current_playing .audio_preview_seekbar").val(percentage).trigger("input")}};$('.main').on('mouseup','.current_playing .audio_preview_seekbar',function(e){audio_message_preview.play()});$('.main').on('mousedown touchstart','.current_playing .audio_preview_seekbar',function(e){audio_message_preview.pause()});$('.main').on('mouseenter','.chatbox > .contents > .chat_messages.show_timestamp_on_mouseover > ul > li',function(e){$(this).find('.header > .tools > .timestamp').addClass('visible')});$('.main').on('mouseleave','.chatbox > .contents > .chat_messages.show_timestamp_on_mouseover > ul > li',function(e){$('.chat_messages.show_timestamp_on_mouseover > ul > li .header > .tools > .timestamp').removeClass('visible')});$('.main').on('click','.current_playing .audio_preview_seekbar',function(e){var offset=$(this).offset();var left=(e.pageX-offset.left);var totalWidth=$(this).width();var percentage=(left/totalWidth);var audioTime=audio_message_preview.duration*percentage;if(!isNaN(audioTime)&&isFinite(audioTime)){audio_message_preview.currentTime=audioTime}});$('.main').on('touchend','.current_playing .audio_preview_seekbar',function(e){var offset=$(this).offset();var left=(e.changedTouches[0].pageX-offset.left);var totalWidth=$(this).width();var percentage=(left/totalWidth);var audioTime=audio_message_preview.duration*percentage;audio_message_preview.currentTime=audioTime;audio_message_preview.play()});function getscrenshotBlobId(blob){return blob.size.toString()}
$(document).on('paste',function(event){if(!$('.main .chatbox').hasClass('d-none')&&!$('.main .chatbox > .footer').hasClass('d-none')){var items=(event.clipboardData||event.originalEvent.clipboardData).items;var blob=null;for(var i=0;i<items.length;i++){if(items[i].type.indexOf("image")===0){blob=items[i].getAsFile();break}}
if(blob){var blobId=getscrenshotBlobId(blob);if(shared_screenshot_BlobIds.includes(blobId)){console.log("This screenshot has been previously shared.");return}
shared_screenshot_BlobIds.push(blobId);var reader=new FileReader();reader.onload=function(event){$('.main .chatbox > .footer > .editor > div > .attached_media > .media_image > img').removeAttr('src');$('.main .chatbox > .footer > .editor > div > .attached_media > .media_image > img').attr('src',event.target.result);$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_url').val(event.target.result);var attached_media_type='screenshot';$('.main .chatbox > .footer > .editor > div > .attached_media > .media_url > input.attached_media_type').val(attached_media_type);$('.main .chatbox > .footer > .editor > div > .attached_media').removeClass('d-none')};reader.readAsDataURL(blob)}}});var filter_text_on_paste=!1;var user_allowed_file_types=system_variable('allowed_file_types');var send_message_button=function(context){var ui=$.summernote.ui;var button=ui.button({contents:'<span class="send_message_btn"/> Send',click:function(){send_message()}});return button.render()}
$("body").on('click','.main .chatbox > .contents > .chat_messages',function(e){var stop_hide_process=!1;if($(e.target).hasClass('tools')||$(e.target).parents().hasClass('tools')){stop_hide_process=!0}
if(!$('.grid_list').hasClass('hidden')&&!stop_hide_process){if(!$('.chatbox > .footer > .grid_list').hasClass('hidden')&&$('.chatbox > .footer > .attachments').hasClass('hasAttachments')){open_module('.attachments','.chatbox > .footer')}else{open_module('.grid_list','.chatbox > .footer')}}});$("body").on('click','.main .chatbox > .footer > .editor .send_message_button .send_message',function(e){$(".main .chatbox > .footer > .editor .message_editor .note-editor .note-toolbar").hide();send_message()});$("body").on('click','.main .add_to_editor',function(e){if($(this).attr('content')!==undefined){$('#message_editor').summernote('restoreRange');$('#message_editor').summernote('insertText',$(this).attr('content'))}});$("body").on('click','.main .chatbox > .footer > .editor .toggle_message_toolbar > div > div.toggle_toolbar_button_old',function(e){$('.main .chatbox > .footer > .editor').toggleClass('show_toolbar')});$("body").on('click','.main .chatbox > .footer > .editor .toggle_message_toolbar > div.msg_attach_options > div.toggle_toolbar_button',function(e){if($(this).hasClass('opened')){$(this).removeClass('opened')}else{$(this).addClass('opened')}});$("body").on('click','.main .chatbox > .footer > .editor .trigger_attach_files',function(e){var identifier='user_input_'+RandomString(6);var input_attributes='';if($.trim(user_allowed_file_types)!==''){input_attributes=' accept="'+user_allowed_file_types+'" '}
var new_file_input='<input type="file" '+input_attributes+' multiple name="file_attachments[]" class="file_attachments '+identifier+'"/>';$('.attachments > div > .attached_files > form').append(new_file_input);$('.'+identifier).hide();$('.'+identifier).trigger('click')});$("body").on('click','.main .chatbox > .footer > .editor .format_text_message',function(e){$('#message_editor').summernote('restoreRange');$(".main .chatbox > .footer > .editor .message_editor .note-editor .note-toolbar").toggle();$('#message_editor').summernote('focus')});$("body").on('click','.main .chatbox > .footer > .editor .msg_attach_options',function(e){$(".main .chatbox > .footer > .editor .message_editor .note-editor .note-toolbar").hide()});$(document).ready(function(){if($('#message_editor').length>0){$('#message_editor').summernote({toolbar:[['style',['bold','italic','underline']],['para',['ul','ol']],],icons:{bold:"iconic_bold",italic:"iconic_italic",underline:"iconic_underline",unorderedlist:"iconic_list",orderedlist:"iconic_list-numbers",},buttons:{},popover:{image:[],},placeholder:language_string('message_textarea_placeholder'),codeviewFilter:!0,disableDragAndDrop:!0,disableResizeImage:!0,disableResizeEditor:!0,maxHeight:'150px',tooltip:!1,hintDirection:'top',hint:[{match:/\B@(\w*)$/,search:function(keyword,callback){if($(".main .chatbox").attr('group_id')!==undefined&&keyword.length>0){var post_data={load:'group_members_mentions',search:keyword,group_id:$(".main .chatbox").attr('group_id')};if(user_csrf_token!==null){post_data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){post_data.login_session_id=user_login_session_id;post_data.access_code=user_access_code;post_data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:post_data,dataType:"json",async:!1}).done(function(users){callback($.grep(users,function(user){if(user.name.toLowerCase().indexOf(keyword.toLowerCase())==0||user.username.toLowerCase().indexOf(keyword.toLowerCase())==0){return user}}))})}},template:function(user){return'<span class="search_group_users"><span><img src="'+user.avatar+'"/></span>'+user.name+'</span>'},content:function(user){var mention_content='@['+user.username+']';return mention_content}}],callbacks:{onChange:function(contents,$editable){},onPaste:function(e){if(filter_text_on_paste){var bufferText=((e.originalEvent||e).clipboardData||window.clipboardData).getData('Text');e.preventDefault();document.execCommand('insertText',!1,bufferText)}},onKeydown:function(e){if(e.keyCode!==13){typing_indicator()}
if(system_variable('enter_is_send')==='enable'){if(e.keyCode==13&&!e.shiftKey){var restricted_nodes=['UL','OL','LI'];var enter_is_send=!0;var element_parents=[];element_parents[1]=window.getSelection().anchorNode.parentNode.nodeName;element_parents[2]=window.getSelection().anchorNode.parentNode.parentNode.nodeName;element_parents[3]=window.getSelection().anchorNode.parentNode.parentNode.parentNode.nodeName;element_parents[4]=window.getSelection().anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName;$.each(element_parents,function(key,value){var index=$.inArray(value,restricted_nodes);if(index!=-1){enter_is_send=!1}});if($('.message_editor .note-popover.bottom.note-hint-popover').is(":visible")){enter_is_send=!1}
if($('.message_editor .note-popover.popover.in.note-hint-popover').is(":visible")){enter_is_send=!1}
if(enter_is_send){e.preventDefault();$('.main .chatbox > .footer > .editor .send_message_button .send_message').trigger('click')}}}
var max_message_length=0;var totalCharacters=e.currentTarget.innerText;if($('.main .chatbox > .footer > .editor').attr('max_message_length')!==undefined){max_message_length=parseInt($('.main .chatbox > .footer > .editor').attr('max_message_length'));if(isNaN(max_message_length)){max_message_length=0}}
if(max_message_length!=0&&totalCharacters.trim().length>=max_message_length){if(e.keyCode!=8&&!(e.keyCode>=37&&e.keyCode<=40)&&e.keyCode!=46&&!(e.keyCode==88&&e.ctrlKey)&&!(e.keyCode==67&&e.ctrlKey))e.preventDefault();}},}}).on('summernote.keydown',function(e){$('#message_editor').summernote('saveRange')})}});function CleanHTML(input){var stringStripper=/(\n|\r| class=(")?Mso[a-zA-Z]+(")?)/g;var output=input.replace(stringStripper,' ');var commentSripper=new RegExp('<!--(.*?)-->','g');var output=output.replace(commentSripper,'');var tagStripper=new RegExp('<(/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>','gi');output=output.replace(tagStripper,'');var badTags=['style','script','applet','embed','noframes','noscript'];for(var i=0;i<badTags.length;i++){tagStripper=new RegExp('<'+badTags[i]+'.*?'+badTags[i]+'(.*?)>','gi');output=output.replace(tagStripper,'')}
var badAttributes=['style','start'];for(var i=0;i<badAttributes.length;i++){var attributeStripper=new RegExp(' '+badAttributes[i]+'="(.*?)"','gi');output=output.replace(attributeStripper,'')}
return output};$(window).on('load',function(){let locationTriggered=!1;$('.main .show_navigation>.side_navigation').on('click',function(){if(!locationTriggered){locationTriggered=!0;if(system_variable('people_nearby_feature')==='enable'){locate_user_position()}}})});function locate_user_position(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(add_geo_location)}else{console.log("Geolocation is not supported by this browser.")}}
function add_geo_location(position){if(position!==undefined){if(position.coords!==undefined){var data={update:"site_user_location",latitude:position.coords.latitude,longitude:position.coords.longitude};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:api_request_url,data:data,async:!0,success:function(data){}})}}};var show_statistics_request=null;$('body').on('click','.show_statistics',function(e){open_column('second');if($(this).hasClass('stat_menu_item')){$('.main .middle > .content > .statistics > .stats_tabs > ul > li').removeClass('active');if($(this).attr('statistics')!==undefined){var stat_menu_item=$(this).attr('statistics');$('.main .middle > .content > .statistics > .stats_tabs > ul > li[statistics="'+stat_menu_item+'"]').addClass('active')}else{$(this).addClass('active')}}else{$('.main .middle > .content > .statistics > .stats_tabs > ul > li').removeClass('active');$('.main .middle > .content > .statistics > .stats_tabs > ul > li').eq(0).addClass('active')}
show_statistics($(this))});function show_statistics(load_data){$('.main .middle > .content > .statistics > .contents').html('');$('.main .middle > .content > .statistics > .loader').show();$('.main .middle > .content > div').addClass('d-none');$('.main .middle > .foot').addClass('d-none');$('.main .middle > .content > .statistics').removeClass('d-none');$('.main .middle > .group_headers > .header_content').html('');$('.main .middle > .group_headers').removeClass('header_content_loaded');$('.main .middle > .group_headers').addClass('d-none');document.title=default_meta_title;var browser_address_bar=baseurl;if(load_data.attr('statistics')!==undefined&&load_data.attr('statistics')==='wallet'){browser_address_bar=browser_address_bar+'wallet/'}
history.pushState({},null,browser_address_bar);var data={load:'statistics',};if(load_data.attr('statistics')!==undefined){data.statistics=load_data.attr('statistics');$('.main .middle>.content>.statistics>.header>.icons>span.show_statistics').attr('statistics',data.statistics)}else{$('.main .middle>.content>.statistics>.header>.icons>span.show_statistics').removeAttr('statistics')}
if(load_data.attr('stat_title')!==undefined){var stat_title=load_data.attr('stat_title');$('.main .middle>.content>.statistics>.header>.left>.title > span').replace_text(language_string(stat_title));$('.main .middle>.content>.statistics>.header>.icons>span.show_statistics').attr('stat_title',stat_title);$('.main .middle>.content>.statistics>.stats_tabs').hide()}else{$('.main .middle>.content>.statistics>.header>.left>.title > span').replace_text(language_string('statistics'));$('.main .middle>.content>.statistics>.header>.icons>span.show_statistics').removeAttr('stat_title');$('.main .middle>.content>.statistics>.stats_tabs').show()}
if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
show_statistics_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(show_statistics_request!=null){show_statistics_request.abort();show_statistics_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);var modules=data.module;$.each(modules,function(module_index,module){var contents='';if(module.type==='numbers'){contents+='<div class="total_numbers container">';contents+='<div class="row">';var items=module.items;$.each(items,function(item_index,item){var item_attributes='';if(item.attributes!==undefined){$.each(item.attributes,function(attr_key,attr_val){item_attributes=item_attributes+attr_key+'="'+attr_val+'" '})}
contents+='<div class="item col-lg-4">';contents+='<div '+item_attributes+'>';if(item.button!==undefined){contents+='<div class="button_div">';contents+='<span class="title">'+item.title+'</span>';contents+='<span class="button">'+item.button+'</span>';contents+='</div>'}else if(item.title!==undefined){contents+='<span class="title">'+item.title+'</span>'}
contents+='<span class="result">'+item.result+'</span>';contents+='</div>';contents+='</div>'});contents+='</div>';contents+='</div>'}else if(module.type==='list'){var list=module.items;contents+='<div class="table_content container">';contents+='<div class="row">';contents+='<div class="col-12">';contents+='<div class="table_list">';if(module.title!==undefined){contents+='<h4 class="heading">'+module.title+'</h4>'}
$.each(list,function(list_items_index,list_items){contents+='<div class="item">';$.each(list_items,function(list_item_index,list_item){$.each(list_item,function(item_index,item){if(item.type==='image'){var image_class_name='';if(item.class_name!==undefined){image_class_name=' '+item.class_name}
contents+='<div class="image'+image_class_name+'">';contents+='<span>';contents+='<img src="'+item.image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';"/>';contents+='</span>';contents+='</div>'}else if(item.type==='info'){contents+='<div class="info">';if(item.bold_text!==undefined){contents+='<span class="bold_text">'+item.bold_text+'</span>'}
contents+='<span>'+item.text+'</span>';contents+='</div>'}else if(item.type==='button'){var btn_class_name='';if(item.class_name!==undefined){btn_class_name=' '+item.class_name}
contents+='<div class="button'+btn_class_name+'">';contents=contents+'<span ';if(item.attributes!==undefined){$.each(item.attributes,function(attrkey,attrval){contents+=attrkey+'="'+attrval+'" '})}
contents+='>'+item.text+'</span>';contents+='</div>'}})});contents+='</div>'});contents+='</div>';contents+='</div>';contents+='</div>';contents+='</div>'}
$('.main .middle > .content > .statistics > .contents').append(contents)});$('.main .middle > .content > .statistics > .loader').hide()}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+data)}})};let pricing_currentIndex=0;var load_membership_info_request=null;var selected_membership_package_id=0;var site_user_membership_order_request=wallet_top_up_request=null;$('body').on('click','.load_membership_info',function(e){open_column('second');var package_id=0;if($(this).attr('package_id')!==undefined){package_id=$(this).attr('package_id')}
load_membership_info(package_id)});$('.main').on('click','.membership_info > .contents > .payment_page > div > .package-info > .back-button',function(e){$('.main .middle > .content > .membership_info > .contents > .payment_page').addClass('d-none')});$('.main').on('click','.membership_info .pricing-table-container > .pricing-table > .pricing-body > span.buy_now',function(e){var package_name=$(this).parent().parent().find('.pricing-head > .package_name').text();var pricing=$(this).parent().parent().find('.pricing-head > .pricing').text();var duration=$(this).parent().parent().find('.pricing-head > .duration').text();var selected_info=$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .package-info > .details');selected_membership_package_id=$(this).parent().parent().attr('membership_package_id');selected_info.find('.package_name').text(package_name);selected_info.find('.pricing > span').text(pricing);selected_info.find('.duration').text(duration);var package_pricing=pricing.match(/\d+/);if(package_pricing!==null){package_pricing=parseInt(package_pricing[0],10)}
$('.main .middle > .content > .membership_info > .contents > .payment_page').removeClass('d-none');$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .place_order').removeClass('d-none');$('.main .middle > .content > .membership_info > .contents').animate({scrollTop:$('.main .middle > .content > .membership_info > .contents > .payment_page').offset().top},1000)});function load_membership_info(membership_package_id){$('.main .middle > .content > div').addClass('d-none');$('.main .middle > .foot').addClass('d-none');$('.main .middle > .group_headers > .header_content').html('');$('.main .middle > .group_headers').removeClass('header_content_loaded');$('.main .middle > .group_headers').addClass('d-none');$('.main .middle > .content > .membership_info > .contents > .preloader-container').removeClass('d-none');$('.main .middle > .content > .membership_info').removeClass('d-none');$('.main .middle > .content > .membership_info > .contents > .membership-info > .membership-card').html('');$('.main .middle > .content > .membership_info > .contents > .membership-info').addClass('d-none');$('.main .middle > .content > .membership_info > .contents > .available_packages .pricing-table-container').html('');$('.main .middle > .content > .membership_info > .contents > .available_packages').addClass('d-none');$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .payment-gateways > ul').html('');$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .payment-gateways').addClass('d-none');$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .place_order').addClass('d-none');$('.main .middle > .content > .membership_info > .contents > .payment_page').addClass('d-none');document.title=default_meta_title;var membership_package_url=baseurl+'membership_packages/';membership_package_id=parseInt(membership_package_id);if(membership_package_id!==0&&membership_package_id!==null){membership_package_url=membership_package_url+membership_package_id+'/'}
history.pushState({},null,membership_package_url);var data={load:'membership_info',};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
load_membership_info_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(load_membership_info_request!=null){load_membership_info_request.abort();load_membership_info_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.info_items!==undefined){var info_items='';$.each(data.info_items,function(index,info_item){info_items+='<div class="info-item">';info_items+='<p>'+info_item.title+'</p>';if(info_item.value!==undefined){info_items+='<p>'+info_item.value+'</p>'}
if(info_item.button!==undefined){var item_attributes='';var item_class_name='button';if(info_item.attributes!==undefined){$.each(info_item.attributes,function(attr_key,attr_val){if(attr_key==='class'){item_class_name=item_class_name+' '+attr_val}else{item_attributes=item_attributes+attr_key+'="'+attr_val+'" '}})}
info_items+='<span class="'+item_class_name+'" '+item_attributes+'>'+info_item.button+'</span>'}
info_items+='</div>'});$('.main .middle > .content > .membership_info > .contents > .membership-info > .membership-card').html(info_items);$('.main .middle > .content > .membership_info > .contents > .membership-info').removeClass('d-none')}
if(data.packages!==undefined){var packages='';$.each(data.packages,function(index,pricing){packages+='<div class="pricing-table" membership_package_id="'+pricing.membership_package_id+'">';packages+='<div class="pricing-head">';packages+='<h3 class="package_name">'+pricing.title+'</h3>';packages+='<span class="pricing">'+pricing.pricing+'</span>';packages+='<span class="duration">'+pricing.duration+'</span></span>';packages+='</div>';packages+='<div class="pricing-body">';if(pricing.benefits!==undefined){packages+='<ul>';$.each(pricing.benefits,function(benefit_index,package_benefit){packages+='<li>';packages+='<svg class="tick-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">';packages+='<path fill="currentColor" d="M9.293 16.293L5.293 12.293a1 1 0 0 1 1.414-1.414L10 14.586l7.293-7.293a1 1 0 1 1 1.414 1.414l-8 8a1 1 0 0 1-1.414 0z" />';packages+='</svg>';packages+=package_benefit;packages+='</li>'});packages+='</ul>'}
if(pricing.purchase_button!==undefined){packages+='<span class="buy_now">'+pricing.purchase_button+'</span>'}
packages+='</div>';packages+='</div>'});$('.main .middle > .content > .membership_info > .contents > .available_packages .pricing-table-container').html(packages);$('.main .middle > .content > .membership_info > .contents > .available_packages').removeClass('d-none')}
if(data.payment_gateways!==undefined){var payment_gateways='';var color_scheme='light';if($('body').hasClass('dark_mode')){color_scheme='dark'}
$.each(data.payment_gateways,function(index,gateway){payment_gateways+='<li><span class="create_order" payment_gateway_id="'+index+'"><img src="'+baseurl+'assets/files/payment_gateways/'+color_scheme+'/'+gateway+'.png"/></span></li>'});$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .payment-gateways > ul').html(payment_gateways);$('.main .middle > .content > .membership_info > .contents > .payment_page > div > .payment-gateways').removeClass('d-none')}
$('.main .middle > .content > .membership_info > .contents > .preloader-container').addClass('d-none');pricing_currentIndex=0;membership_pricing_slider(pricing_currentIndex);if(membership_package_id!==0&&membership_package_id!==null){$('.pricing-table[membership_package_id="'+membership_package_id+'"]').find('.buy_now').trigger('click')}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+data)}})}
$('.main').on('click','.membership_place_order',function(e){var data={add:'site_user_membership_order',membership_package_id:selected_membership_package_id,};if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
site_user_membership_order_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(site_user_membership_order_request!=null){site_user_membership_order_request.abort();site_user_membership_order_request=null}},success:function(data){}}).done(function(data){if(isJSON(data)){data=$.parseJSON(data);if(data.redirect!==undefined){window.location.href=data.redirect}else if(data.alert!==undefined){alert(data.alert)}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+data)}})});function membership_pricing_slider(index){var pricingTables=$('.membership_info > .contents > .available_packages .pricing-table-container > .pricing-table');var pricingTableContainer=$('.membership_info > .contents > .available_packages .pricing-table-container');var translateX=-index*(pricingTables.outerWidth()+10);pricingTableContainer.css('transform',`translateX(${translateX}px)`)}
$('.membership_info > .contents > .available_packages > div > .header > div > .right > .previous_pricing').click(function(){if(pricing_currentIndex>0){pricing_currentIndex--;membership_pricing_slider(pricing_currentIndex)}});$('.membership_info > .contents > .available_packages > div > .header > div > .right > .next_pricing').click(function(){var pricingTables=$('.membership_info > .contents > .available_packages .pricing-table-container > .pricing-table');if(pricing_currentIndex<pricingTables.length-1){pricing_currentIndex++;membership_pricing_slider(pricing_currentIndex)}});$('.wallet_topup_modal').on('click','.wallet_payment_gateways > li > .payment_method',function(e){$('.wallet_topup_modal .payment_method_id_selected').val($(this).attr('payment_gateway_id'));$('.wallet_topup_modal .modal-body>form .wallet_payment_gateways>li>.payment_method').removeClass('selected');$(this).addClass('selected')});$("body").on('click','.main .open_send_tips_modal',function(e){if($(this).attr('user_id')!==undefined){$('.send_tips_modal .tip_amount').val('');$('.send_tips_modal .tip_user_id').val($(this).attr('user_id'));$('#send_tips_modal').modal('show')}});$('.wallet_topup_modal').on('click','.topup_wallet_submit',function(e){if(!$(this).hasClass('processing')){$(this).addClass('processing');$(".wallet_topup_modal .modal-body>form .error").hide();var data={update:'wallet',amount:$('.wallet_topup_modal .topup_amount').val(),payment_gateway_id:$('.wallet_topup_modal .payment_method_id_selected').val()};if($(this).attr('withdraw')!==undefined){var data={update:'wallet',withdrawal:!0,withdraw_amount:$('.wallet_topup_modal .withdraw_amount').val(),transfer_details:$('.wallet_topup_modal .transfer_details').val()}}
if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}
wallet_top_up_request=$.ajax({type:'POST',url:api_request_url,data:data,async:!0,beforeSend:function(){if(wallet_top_up_request!=null){wallet_top_up_request.abort();wallet_top_up_request=null}},success:function(data){}}).done(function(data){$('.wallet_topup_modal .topup_wallet_submit').removeClass('processing');if(isJSON(data)){data=$.parseJSON(data);if(data.redirect!==undefined){$('.wallet_topup_modal .topup_wallet_submit').addClass('processing');window.location.href=data.redirect}else if(data.error_message!==undefined||data.success_message!==undefined){if(data.success_message!==undefined){data.error_message=data.success_message}
if(data.clear_form!==undefined){$('.wallet_topup_modal .modal-body > form')[0].reset()}
$(".wallet_topup_modal .modal-body > form .error").replace_text(data.error_message).fadeIn();var wallet_modalBody=$('.wallet_topup_modal .modal-body');var wallet_ErrorDiv=wallet_modalBody.find('.error');if(wallet_ErrorDiv.length){wallet_modalBody.animate({scrollTop:wallet_ErrorDiv.offset().top-wallet_modalBody.offset().top+wallet_modalBody.scrollTop()},500)}}}else{console.log('ERROR : '+data)}}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!=='abort'&&qXHR.statusText!=='canceled'){console.log('ERROR : '+data)}
$('.wallet_topup_modal .topup_wallet_submit').removeClass('processing')})}});$("body").on('click','.api_request',function(e){if(!$(this).hasClass('processing')){$(this).addClass('processing');var form_data=output_message_field=null;if($(this).attr('form_data')!==undefined){form_data=$(this).attr('form_data');var data=new FormData($(form_data)[0])}else{var data=$(this).data()}
var element=$(this);var skip_hide_action=!1;var column='first';if(element.attr('column')!==undefined){column=element.attr('column')}
if($(this).attr('output_message_field')!==undefined){output_message_field=$(this).attr('output_message_field');$(output_message_field).hide()}
if($(this).attr('loader')!==undefined){$($(this).attr('loader')).show()}
if($(this).hasClass('change_site_color_scheme')&&$(this).data('color_scheme')!==undefined){if($(this).data('color_scheme')==='light_mode'){var css_variable_file=baseurl+'assets/css/common/css_variables.css'}else{var css_variable_file=baseurl+'assets/css/common/dark_mode_css_variables.css'}(async()=>{try{var css_file_response=await fetch(css_variable_file);if(!css_file_response.ok){console.log('CSS File load failed: '+css_file_response.statusText)}}catch(error){console.log('Error loading file:',error)}})()}
if($(this).attr('pass_send_as_user_id')!==undefined){if($('.main .chatbox > .header > .switch_user').length>0){if($('.main .chatbox > .header > .switch_user > .current_selected_user > .user_image > img').length>0){var send_as_user_id=$('.main .chatbox > .header > .switch_user > .user_id > input').val();if(send_as_user_id.length>0&&send_as_user_id!=='0'){data.send_as_user_id=send_as_user_id}}}}
if(form_data!==null){if(user_csrf_token!==null){data.append("csrf_token",user_csrf_token)}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.append("login_session_id",user_login_session_id);data.append("access_code",user_access_code);data.append("session_time_stamp",user_session_time_stamp)}}else{if(user_csrf_token!==null){data.csrf_token=user_csrf_token}
if(user_login_session_id!==null&&user_access_code!==null&&user_session_time_stamp!==null){data.login_session_id=user_login_session_id;data.access_code=user_access_code;data.session_time_stamp=user_session_time_stamp}}
if($(this).attr('multi_select')!==undefined){if($(this).attr('data-chat_messages')!==undefined){if($(".main .chatbox").attr('group_id')!==undefined){data.remove="group_messages"}else if($(".main .chatbox").attr('user_id')!==undefined){data.remove="private_chat_messages"}
data.message_id=new Array();$(".main .chatbox .selector.select_item > input:checked").each(function(){data.message_id.push($(this).val())})}else{var selected=new Array();$(".main .aside > .site_records > .records > .list > li > div > .selector.select_item > input:checked").each(function(){selected.push($(this).val())});data[$(this).attr('multi_select')]=selected}}
if(form_data!==null){var request_data={url:api_request_url,dataType:'text',cache:!1,contentType:!1,processData:!1,async:!0,data:data,type:'post',success:function(data){}}}else{var request_data={type:'POST',url:api_request_url,data:data,async:!0,success:function(data){}}}
$.ajax(request_data).done(function(data){if(data===''){location.reload(!0)}else if(isJSON(data)){data=$.parseJSON(data);if(data.success){if(data.close_modal!==undefined){$(data.close_modal).modal('hide')}
if(data.force_reload_aside!==undefined){$('.main .aside > .site_records > .current_record').attr('load',data.force_reload_aside);$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');if(data.filter_data!==undefined){$(".main .aside > .site_records > .current_record > .title").attr('filter_data',data.filter_data)}
$(".main .aside > .site_records > .current_record > .title").trigger('click')}
if(data.reload!==undefined&&$.isArray(data.reload)){if(jQuery.inArray($('.main .aside > .site_records > .current_record').attr('load'),data.reload)!==-1){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');$(".main .aside > .site_records > .current_record > .title").trigger('click')}}else if(data.todo=='reload'){if(data.reload!==undefined&&$('.main .aside > .site_records > .current_record').attr('load')===data.reload){$(".main .aside > .site_records > .current_record").removeClass('loading');$(".main .aside > .site_records > .current_record > .title > div").removeClass('dropdown_button');if(data.filter_data!==undefined){$(".main .aside > .site_records > .current_record > .title").attr('filter_data',data.filter_data)}
$(".main .aside > .site_records > .current_record > .title").trigger('click')}}else if(data.todo=='refresh'){window.location.href=baseurl}else if(data.todo=='refresh_current_page'){location.reload(!0)}else if(data.todo=='consolelog'&&data.log!==undefined){console.log(data.log)}else if(data.todo=='redirect'){if(data.remove_login_session!==undefined){WebStorage('remove','login_session_id');WebStorage('remove','access_code');WebStorage('remove','session_time_stamp');WebStorage('remove','remove_login_session');setTimeout(function(){window.location.href=data.redirect},2000)}else{window.location.href=data.redirect}}else if(data.todo=='update_message_reactions'){if(data.update_data!==undefined){update_message_reactions(data.update_data)}}else if(data.todo=='remove_messages'){$(".main .chatbox > .header > .message_selection").find('input').prop('checked',!1);if(data.remove_data!==undefined){remove_messages(data.remove_data)}}else if(data.todo=='load_conversation'){if(data.reload_aside!==undefined&&$('.main .aside > .site_records > .current_record').attr('load')==='groups'){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}
var load_data=[];load_data[data.identifier_type]=data.identifier;load_conversation(load_data)}
if(data.info_box!==undefined){get_info(data.info_box)}
$('.main .page_column[column="'+column+'"] .confirm_box > .content > .btn.cancel').trigger('click')}else{if(data.error_message_position===undefined){if(data.error_message!==undefined&&output_message_field!==null){$(output_message_field).replace_text(data.error_message);$(output_message_field).fadeIn()}else if(data.error_message!==undefined){$('.main .page_column[column="'+column+'"] .confirm_box > .error > .message > span').replace_text(data.error_message);$('.main .page_column[column="'+column+'"] .confirm_box > .error').fadeIn();skip_hide_action=!0}}}}else{console.log('ERROR : '+data)}
if(element.attr('loader')!==undefined){$(element.attr('loader')).hide()}
element.removeClass('processing');if(element.attr('hide_window')!==undefined){$(element.attr('hide_window')).hide()}
if(element.attr('hide_element')!==undefined&&!skip_hide_action){$(element.attr('hide_element')).addClass('d-none')}}).fail(function(qXHR,textStatus,errorThrown){if(element.attr('loader')!==undefined){$(element.attr('loader')).hide()}
element.removeClass('processing');if(element.attr('hide_window')!==undefined){$(element.attr('hide_window')).hide()}
if(element.attr('hide_element')!==undefined){$(element.attr('hide_element')).addClass('d-none')}
console.log('ERROR : '+errorThrown)})}});var realtime_request=null;var realtime_timeout=null;var realtime_refresh_rate=$.trim(system_variable('refresh_rate'));var site_notification_tone=$('.site_sound_notification > div > audio')[0];var side_navigation=$('.main .side_navigation .menu_items');var current_video_caller_id=0;var isFetching_systasks=!1;var userFpToken=null;var chk_userFpToken=!1;var ws_instance=null;var realtime_first_run=!0;var sys_tasks_count=0;if(realtime_refresh_rate.length==0){realtime_refresh_rate=2000}
if(realtime_request_url===undefined){realtime_request_url=api_request_url}
realtime_timeout=setTimeout(function(){realtime()},2500);$(window).on("load",function(){if(system_variable('fingerprint_module')!='disable'){getUserFp()}});async function getUserFp(){try{ThumbmarkJS.setOption('exclude',['permissions','plugins']);userFpToken=await ThumbmarkJS.getFingerprint()}catch(error){console.log("Error getting User device Token :",error)}}
function get_rt_post_data(){var whos_typing_last_logged_user_id=0;var logged_in_user_id=0;var request_time=new Date($.now());var post_data={request_time:request_time,realtime:!0,};if($('.logged_in_user_id').length>0){logged_in_user_id=$('.logged_in_user_id').text()}
post_data.logged_in_user_id=logged_in_user_id;if(system_variable('realtime_mode')!=='websocket'){if(sys_tasks_count===10){post_data.sys_tasks=!0;sys_tasks_count=0}
sys_tasks_count++}
if(system_variable('realtime_mode')==='websocket'&&userFpToken!==null){post_data.userFpToken=userFpToken}else if(!chk_userFpToken&&userFpToken!==null){post_data.userFpToken=userFpToken;chk_userFpToken=!0}
if(!$('.main .chatbox').hasClass('d-none')&&!$('.main .chatbox > .contents > .chat_messages').hasClass('searching')){var pass_conversation_id=!0;if($(window).width()<767.98){if($('.main .middle').hasClass('previous')||$('.main .middle').css('display')=='none'){pass_conversation_id=!1}}
if(pass_conversation_id){if($('.main .chatbox').attr('group_id')!==undefined){post_data.group_id=$('.main .chatbox').attr('group_id')}else if($('.main .chatbox').attr('user_id')!==undefined){post_data.user_id=$('.main .chatbox').attr('user_id')}
if(system_variable('video_chat')!='disable'){if(!$('.main .chatbox > .header .join_video_call_icon').hasClass('d-none')){if($('.main .chatbox > .header .join_video_call_icon').hasClass('online')){post_data.video_chat_status='online'}else{post_data.video_chat_status='offline'}}
if(system_variable('audio_chat')!='disable'){if(!$('.main .chatbox > .header .join_audio_call_icon').hasClass('d-none')){if($('.main .chatbox > .header .join_audio_call_icon').hasClass('online')){post_data.audio_chat_status='online'}else{post_data.audio_chat_status='offline'}}}
if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){if(isVideoChatActive){if(!exit_video_chat_on_change&&current_video_chat_id!==null&&current_video_chat_type==='private_chat'){current_video_caller_id=post_data.current_video_caller_id=current_video_chat_id;if($('.main .middle > .video_chat_interface').hasClass('audio_only_chat')){post_data.audio_only_call=!0}}else if($('.main .chatbox').attr('user_id')!==undefined){current_video_caller_id=post_data.current_video_caller_id=$('.main .chatbox').attr('user_id');if($('.main .middle > .video_chat_interface').hasClass('audio_only_chat')){post_data.audio_only_call=!0}}}}}}
if($('.main .chatbox').attr('group_id')!==undefined||$('.main .chatbox').attr('user_id')!==undefined){post_data.message_id_greater_than=get_message_id('last');post_data.last_seen_by_recipient=get_message_id('last_seen_by_recipient')}
if($('.main .chatbox > .header > .heading > .whos_typing').attr('last_logged_user_id')!==undefined){whos_typing_last_logged_user_id=$('.main .chatbox > .header > .heading > .whos_typing').attr('last_logged_user_id')}
post_data.whos_typing_last_logged_user_id=whos_typing_last_logged_user_id}
if(side_navigation.find('li.realtime_module[module="groups"]').length>0){$unread_group_messages=0;if(side_navigation.find('li.realtime_module[module="groups"]').attr('unread')!=undefined){$unread_group_messages=side_navigation.find('li.realtime_module[module="groups"]').attr('unread')}
post_data.unread_group_messages=$unread_group_messages}
if($('.call_notification').length>0){if($('.call_notification').attr('current_call_id')!==undefined){post_data.check_call_logs=!0;post_data.current_call_id=$('.call_notification').attr('current_call_id')}}
if(side_navigation.find('li.realtime_module[module="private_conversations"]').length>0){$unread_private_chat_messages=0;if(side_navigation.find('li.realtime_module[module="private_conversations"]').attr('unread')!=undefined){$unread_private_chat_messages=side_navigation.find('li.realtime_module[module="private_conversations"]').attr('unread')}
post_data.unread_private_chat_messages=$unread_private_chat_messages}
if(side_navigation.find('li.realtime_module[module="site_notifications"]').length>0){$unread_site_notifications=0;if(side_navigation.find('li.realtime_module[module="site_notifications"]').attr('unread')!=undefined){$unread_site_notifications=side_navigation.find('li.realtime_module[module="site_notifications"]').attr('unread')}
post_data.unread_site_notifications=$unread_site_notifications}
if(side_navigation.find('li.realtime_module[module="friends"]').length>0){$pending_friend_requests=0;if(side_navigation.find('li.realtime_module[module="friends"]').attr('pending')!=undefined){$pending_friend_requests=side_navigation.find('li.realtime_module[module="friends"]').attr('pending')}
post_data.pending_friend_requests=$pending_friend_requests}
if($('.main .aside > .site_records > .current_record').attr('load')=='online'){var current_record_filter=$('.current_record_filter').val();var current_record_sort_by=$('.current_record_sort_by').val();if(current_record_sort_by!=0&&current_record_sort_by!==null){current_record_filter='sorted_by'}
if(current_record_filter==0||current_record_filter===null){$recent_online_user_id=0;$recent_online_user_online_status=0;$total_online_users=0;if(side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_id')!=undefined){$recent_online_user_id=side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_id')}
if(side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_online_status')!=undefined){$recent_online_user_online_status=side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_online_status')}
if(side_navigation.find('li.realtime_module[module="online_users"]').attr('total_online_users')!=undefined){$total_online_users=side_navigation.find('li.realtime_module[module="online_users"]').attr('total_online_users')}
post_data.recent_online_user_id=$recent_online_user_id;post_data.recent_online_user_online_status=$recent_online_user_online_status;post_data.total_online_users=$total_online_users}}
if(side_navigation.find('li.realtime_module[module="complaints"]').length>0){$unresolved_complaints=0;if(side_navigation.find('li.realtime_module[module="complaints"]').attr('unresolved')!=undefined){$unresolved_complaints=side_navigation.find('li.realtime_module[module="complaints"]').attr('unresolved')}
post_data.unresolved_complaints=$unresolved_complaints}
$last_realtime_log_id=0;if($('.main_window').attr('last_realtime_log_id')!=undefined){$last_realtime_log_id=$('.main_window').attr('last_realtime_log_id')}
post_data.last_realtime_log_id=$last_realtime_log_id;return post_data}
function realtime(){if(realtime_timeout!=null){clearTimeout(realtime_timeout)}
var fetch_api_support=!1;var force_disable_fetch=!0;if(typeof fetch!='undefined'&&typeof fetch=='function'&&force_disable_fetch==!1){fetch_api_support=!0}
realtime_timeout=setTimeout(function(){var post_data=get_rt_post_data();if(system_variable('realtime_mode')==='websocket'){if(realtime_first_run){realtime_first_run=!1;realtime_ajax(post_data)}
realtime_wsocket()}else if(fetch_api_support){realtime_fetch_api(post_data)}else{realtime_ajax(post_data)}},realtime_refresh_rate)}
function update_wsocket_data(){if(system_variable('realtime_mode')==='websocket'){let chat_context={type:"chat_context",payload:get_rt_post_data()};if(ws_instance&&ws_instance.readyState===WebSocket.OPEN){ws_instance.send(JSON.stringify(chat_context))}}}
function realtime_wsocket(){let ws_instance_url=system_variable('websocket_url');if(user_login_session_id===null){user_login_session_id=system_variable('login_session_id');user_access_code=system_variable('access_code');user_session_time_stamp=system_variable('time_stamp')}
if(user_login_session_id!=null&&user_access_code!=null&&user_session_time_stamp!=null){ws_instance_url=`${ws_instance_url}?login_session_id=${user_login_session_id}&access_code=${user_access_code}&session_time_stamp=${user_session_time_stamp}`}
let reconnectAttempts=0;const maxReconnectAttempts=4;let reconnectTimeout=null;function connectWebSocket(){ws_instance=new WebSocket(ws_instance_url);ws_instance.onopen=function(){reconnectAttempts=0;console.log("Connected to WebSocket server.");let chat_context={type:"chat_context",payload:get_rt_post_data()};ws_instance.send(JSON.stringify(chat_context))};ws_instance.onmessage=function(event){realtime_results(event.data);let chat_context={type:"chat_context",payload:get_rt_post_data()};ws_instance.send(JSON.stringify(chat_context))};ws_instance.onerror=function(error){console.log("WebSocket Error: "+error);reconnectWebSocket()};ws_instance.onclose=function(){console.log("Disconnected from WebSocket server.");reconnectWebSocket()}}
function reconnectWebSocket(){if(reconnectAttempts>=maxReconnectAttempts){console.log("Maximum reconnection attempts reached. Exiting...");return}
console.log(`Attempt ${reconnectAttempts + 1} to reconnect to WebSocket...`);let delay=Math.pow(2,reconnectAttempts)*1000;reconnectAttempts++;if(reconnectTimeout){clearTimeout(reconnectTimeout)}
reconnectTimeout=setTimeout(function(){console.log("Reconnecting...");connectWebSocket()},delay)}
connectWebSocket()}
function realtime_fetch_api(post_data){if(user_csrf_token!=null){post_data.csrf_token=user_csrf_token}
let realtime_request=async()=>{const response=await fetch(realtime_request_url,{method:'POST',headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(post_data)});if(response.status!=200){throw new Error("cannot fetch data")}
let data=await response.json();return data};realtime_request().then((data)=>{realtime_results(data,!1)}).catch((err)=>{console.log("rejected",err.message);realtime_request=null;realtime_timeout=null;realtime()})}
function realtime_ajax(post_data){if(user_csrf_token!=null){post_data.csrf_token=user_csrf_token}
if(user_login_session_id!=null&&user_access_code!=null&&user_session_time_stamp!=null){post_data.login_session_id=user_login_session_id;post_data.access_code=user_access_code;post_data.session_time_stamp=user_session_time_stamp}
realtime_request=$.ajax({type:'POST',url:realtime_request_url,data:post_data,async:!0,beforeSend:function(){if(realtime_request!=null){realtime_request.abort();realtime_request=null}},success:function(data){}}).done(function(data){realtime_results(data)}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!='abort'&&qXHR.statusText!='canceled'){console.log('ERROR : '+errorThrown)}
realtime_request=null;realtime_timeout=null;realtime()})}
function realtime_results(data,parse_json){var valid_json_data=!0;if(parse_json===undefined){if(isJSON(data)){data=$.parseJSON(data)}else{valid_json_data=!1}}
if(valid_json_data){var aside_refresh=!0;if(data.tk_user_code!==undefined){if(userFpToken!==null){user_csrf_token=data.tk_user_code}}
if(data.reload_page!==undefined){location.reload(!0)}
if(data.alert_message!==undefined){alert(data.alert_message)}
if(data.play_sound_notification!==undefined&&data.play_sound_notification){if(site_notification_tone.paused){site_notification_tone.currentTime=0;site_notification_tone.play().catch(function(error){if(error.name==='NotAllowedError'){console.log("Notification Playback not allowed without user interaction.")}else{console.error("An error occurred while playing the Notification:",error)}})}}
if($('.main .aside > .site_records .current_record_search_keyword').val().length>0){aside_refresh=!1}
if(!$('.main .aside > .site_records > .tools > .tool.multiple_selection').hasClass('d-none')){aside_refresh=!1}
if($('.main .aside > .site_records .current_record_filter').val().length>1){aside_refresh=!1}
if($('.main .aside > .site_records .current_record_sort_by').val().length>1){aside_refresh=!1}
if($('.main .aside > .site_records > .current_record').hasClass('loading')){aside_refresh=!1}
var aside_scroll_position=$('.main .aside > .site_records > .records > .list').scrollTop();if(aside_scroll_position>150){aside_refresh=!1}
if(!$('.main .chatbox').hasClass('d-none')&&!$('.main .chatbox > .contents > .chat_messages').hasClass('searching')){if(data.group_messages!==undefined){data.group_messages.append=!0;var scroll_position=$('.main .chatbox > .contents > .chat_messages').scrollTop();scroll_position=Math.abs(scroll_position);var screen_height=($(window).height())-50;if(scroll_position<screen_height){data.group_messages.scrollToBottom=!0}
if(data.group_messages.messages!==undefined){if(data.group_messages.messages[0]!==undefined){if(data.group_messages.messages[0].own_message===undefined||!data.group_messages.messages[0].own_message){var browser_title=language_string('new_message_notification');change_browser_title(browser_title,5000)}}}
load_messages(data.group_messages)}
if(data.last_seen_by_recipient!==undefined){if(data.last_seen_by_recipient.user_id!==undefined&&$('.main .chatbox').attr('user_id')!==undefined){if($('.main .chatbox').attr('user_id')==data.last_seen_by_recipient.user_id){if(data.last_seen_by_recipient.message_id!==undefined){var last_seen_by_recipient_id=parseInt(data.last_seen_by_recipient.message_id);$('.main .chatbox > .contents > .chat_messages > ul > li').each(function(){if($(this).attr('message_id')!=undefined&&!$(this).hasClass('seen_by_recipient')){var this_message_id=parseInt($(this).attr('message_id'));if(this_message_id<=last_seen_by_recipient_id){$(this).addClass('seen_by_recipient');$(this).find('.read_status').addClass('read');$(this).find('.read_status').html('<i class="bi bi-check-all"></i>')}}})}}}}
var update_video_chat_status=!1;if(data.video_chat_status!==undefined){if(data.video_chat_status.group_id!==undefined&&data.video_chat_status.group_id==$('.main .chatbox').attr('group_id')){update_video_chat_status=!0}else if(data.video_chat_status.user_id!==undefined&&data.video_chat_status.user_id==$('.main .chatbox').attr('user_id')){update_video_chat_status=!0;var reject_video_call_onupdate=!0;if(!exit_video_chat_on_change){if(current_video_chat_type==='group'){reject_video_call_onupdate=!1}else if(current_video_chat_id!==data.video_chat_status.user_id&&current_video_chat_type==='private_chat'){reject_video_call_onupdate=!1}}
if(data.video_chat_status.rejected!==undefined&&reject_video_call_onupdate){console.log('Call Rejected');exit_video_chat()}}}
if(update_video_chat_status&&data.video_chat_status.online!==undefined){if(data.video_chat_status.audio_only!==undefined){$('.main .chatbox > .header .join_audio_call_icon').addClass('online')}else{$('.main .chatbox > .header .join_video_call_icon').addClass('online')}}else if(update_video_chat_status){if(data.video_chat_status.audio_only!==undefined){$('.main .chatbox > .header .join_audio_call_icon').removeClass('online')}else{$('.main .chatbox > .header .join_video_call_icon').removeClass('online')}}
if(data.private_chat_messages!==undefined){data.private_chat_messages.append=!0;var scroll_position=$('.main .chatbox > .contents > .chat_messages').scrollTop();scroll_position=Math.abs(scroll_position);if(scroll_position<300){data.private_chat_messages.scrollToBottom=!0}
if(data.private_chat_messages.messages!==undefined){if(data.private_chat_messages.messages[0]!==undefined){if(data.private_chat_messages.messages[0].own_message===undefined||!data.private_chat_messages.messages[0].own_message){var browser_title=language_string('new_message_notification');change_browser_title(browser_title,5000)}}}
load_messages(data.private_chat_messages)}
if(data.users_typing!==undefined){if(data.users_typing.last_inserted_user_id!==undefined){$('.main .chatbox > .header > .heading > .whos_typing').attr('last_logged_user_id',data.users_typing.last_inserted_user_id)}
if(data.users_typing.users!==undefined){if(data.users_typing.group_id!==undefined&&data.users_typing.group_id==$(".main .chatbox").attr('group_id')){whos_typing(data.users_typing.users)}else if(data.users_typing.user_id!==undefined&&data.users_typing.user_id==$(".main .chatbox").attr('user_id')){whos_typing(data.users_typing.users)}else{whos_typing(null)}}}}
if(data.new_call_notification!==undefined){var current_notification_call_id=0;if($('.call_notification').length>0){if($('.call_notification').attr('current_call_id')!==undefined){current_notification_call_id=$('.call_notification').attr('current_call_id')}}
if(!$('.main .middle > .video_chat_interface').hasClass('d-none')){if($('.main .chatbox').attr('user_id')!==undefined){current_video_caller_id=$('.main .chatbox').attr('user_id')}}else{current_video_caller_id=0}
if(data.new_call_notification.caller_id!==undefined&&data.new_call_notification.caller_name!==undefined){if(data.new_call_notification.caller_id!=current_notification_call_id&&current_video_caller_id!=data.new_call_notification.caller_id){call_notification_timeout('start');$('.call_notification').removeClass('d-none');$('.call_notification').attr('current_call_id',data.new_call_notification.caller_id);$('.call_notification > .call_notification-text .user_name').replace_text(data.new_call_notification.caller_name);$('.call_notification > .user-image').html('<img src="'+data.new_call_notification.caller_image+'" onerror="this.onerror=null; this.src='+"'"+blur_img_url+"'"+';" />');$('.call_notification > .action-buttons > .action-button.attend_video_call').addClass('load_conversation');$('.call_notification > .action-buttons > .action-button.attend_video_call').attr('user_id',data.new_call_notification.caller_id);if(data.new_call_notification.audio_only!==undefined){$('.call_notification > .action-buttons > .action-button.attend_video_call').addClass('audio_only_chat')}else{$('.call_notification > .action-buttons > .action-button.attend_video_call').removeClass('audio_only_chat')}
$('.call_notification .call_ringtone')[0].play().catch(function(error){if(error.name==='NotAllowedError'){console.log("Ringtone Playback not allowed without user interaction.")}else{console.error("An error occurred while playing the Ringtone:",error)}})}}else{current_video_caller_id=0;call_notification_timeout('stop');$('.call_notification').addClass('d-none');$('.call_notification').attr('current_call_id',0);if(!$('.call_notification .call_ringtone')[0].paused){$('.call_notification .call_ringtone')[0].pause();$('.call_notification .call_ringtone')[0].currentTime=0}}}
if(data.unread_group_messages!==undefined){if(data.unread_group_messages.length==0){data.unread_group_messages=0}
var unread_text='';side_navigation.find('li.realtime_module[module="groups"]').attr('unread',data.unread_group_messages);if(data.unread_group_messages!=0){unread_text='<span>'+abbreviateNumber(data.unread_group_messages)+'</span>';if($('.main .aside > .site_records > .current_record').attr('load')=='groups'){if(aside_refresh){var group_category_id=$('.site_records > .current_record .data_attributes > span');if(group_category_id.length>0){if(group_category_id.attr('data-group_category_id')!==undefined){group_category_id=group_category_id.attr('data-group_category_id');if($.trim(group_category_id)!==''){$('.main .aside > .site_records > .current_record').data('group_category_id',group_category_id)}}}
$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader');$('.main .aside > .site_records > .current_record').removeData('group_category_id')}}}else{if($('.main .aside > .site_records > .current_record').attr('load')=='groups'){$(".main .aside > .site_records > .records > .list > li > div > .center > .title > .unread").addClass('d-none')}}
side_navigation.find('li.realtime_module[module="groups"] > .menu_item > .unread').html(unread_text)}
if(data.unread_private_chat_messages!==undefined){if(data.unread_private_chat_messages.length==0){data.unread_private_chat_messages=0}
var unread_text='';side_navigation.find('li.realtime_module[module="private_conversations"]').attr('unread',data.unread_private_chat_messages);if(data.unread_private_chat_messages!=0){unread_text='<span>'+abbreviateNumber(data.unread_private_chat_messages)+'</span>';if($('.main .aside > .site_records > .current_record').attr('load')=='private_conversations'){if(aside_refresh){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}}}else{if($('.main .aside > .site_records > .current_record').attr('load')=='private_conversations'){$(".main .aside > .site_records > .records > .list > li > div > .center > .title > .unread").addClass('d-none')}}
$('.main .pm_shortcut > .notification_count').html(unread_text);side_navigation.find('li.realtime_module[module="private_conversations"] > .menu_item > .unread').html(unread_text)}
if(data.unread_site_notifications!==undefined){if(data.unread_site_notifications.length==0){data.unread_site_notifications=0}
var unread_text='';side_navigation.find('li.realtime_module[module="site_notifications"]').attr('unread',data.unread_site_notifications);if(data.unread_site_notifications!=0){unread_text='<span>'+abbreviateNumber(data.unread_site_notifications)+'</span>';if($('.main .aside > .site_records > .current_record').attr('load')=='site_notifications'){if(aside_refresh){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}}}
side_navigation.find('li.realtime_module[module="site_notifications"] > .menu_item > .unread').html(unread_text)}
if(data.pending_friend_requests!==undefined){if(data.pending_friend_requests.length==0){data.pending_friend_requests=0}
var unread_text='';side_navigation.find('li.realtime_module[module="friends"]').attr('pending',data.pending_friend_requests);if(data.pending_friend_requests!=0){unread_text='<span>'+abbreviateNumber(data.pending_friend_requests)+'</span>';if($('.main .aside > .site_records > .current_record').attr('load')=='friends'){if(aside_refresh){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}}}
side_navigation.find('li.realtime_module[module="friends"] > .menu_item > .unread').html(unread_text)}
if(data.unresolved_complaints!==undefined){if(data.unresolved_complaints.length==0){data.unresolved_complaints=0}
var unread_text='';side_navigation.find('li.realtime_module[module="complaints"]').attr('unresolved',data.unresolved_complaints);if(data.unresolved_complaints!=0){unread_text='<span>'+abbreviateNumber(data.unresolved_complaints)+'</span>';if($('.main .aside > .site_records > .current_record').attr('load')=='complaints'){if(aside_refresh){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}}}
side_navigation.find('li.realtime_module[module="complaints"] > .menu_item > .unread').html(unread_text)}
if(system_variable('realtime_mode')!=='websocket'){if(data.sys_tasks!==undefined){if(!isFetching_systasks){execute_sys_tasks()}}}
if(data.recent_online_user_id!==undefined){if($('.main .aside > .site_records > .current_record').attr('load')=='online'){if(data.recent_online_user_id.length==0){data.recent_online_user_id=0}
if(data.recent_online_user_online_status.length==0){data.recent_online_user_online_status=0}
if(data.total_online_users.length==0){data.total_online_users=0}
var current_recent_online_user_id=0;var current_online_user_online_status=0;var total_online_users=0;if(isFinite(side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_id'))){current_recent_online_user_id=side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_id')}
if(side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_online_status')!==undefined){current_online_user_online_status=side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_online_status')}
if(side_navigation.find('li.realtime_module[module="online_users"]').attr('total_online_users')!==undefined){total_online_users=side_navigation.find('li.realtime_module[module="online_users"]').attr('total_online_users')}
side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_id',data.recent_online_user_id);side_navigation.find('li.realtime_module[module="online_users"]').attr('recent_online_user_online_status',data.recent_online_user_online_status);side_navigation.find('li.realtime_module[module="online_users"]').attr('total_online_users',data.total_online_users);if(data.total_online_users!=total_online_users||data.recent_online_user_id!=current_recent_online_user_id||data.recent_online_user_online_status!=current_online_user_online_status){if(aside_refresh){$(".main .aside > .site_records > .current_record").removeClass('loading');$('.main .aside > .site_records > .current_record').attr('disable_preloader',!0);load_aside($(".main .aside > .site_records > .current_record"));$('.main .aside > .site_records > .current_record').removeAttr('disable_preloader')}}}}
if(data.unread_realtime_logs!==undefined){if(data.last_realtime_log_id!==undefined){$('.main_window').attr('last_realtime_log_id',data.last_realtime_log_id)}
realtime_logs(data.unread_realtime_logs)}
var total_unread_notifications=0;var current_total_unread_notifications=0;if($('.total_unread_notifications').attr('total_unread_notification')!==undefined){current_total_unread_notifications=parseInt($('.total_unread_notifications').attr('total_unread_notification'))}
if(isFinite(side_navigation.find('li.realtime_module[module="groups"]').attr('unread'))){total_unread_notifications=parseInt(total_unread_notifications)+parseInt(side_navigation.find('li.realtime_module[module="groups"]').attr('unread'))}
if(isFinite(side_navigation.find('li.realtime_module[module="private_conversations"]').attr('unread'))){total_unread_notifications=parseInt(total_unread_notifications)+parseInt(side_navigation.find('li.realtime_module[module="private_conversations"]').attr('unread'))}
if(isFinite(side_navigation.find('li.realtime_module[module="site_notifications"]').attr('unread'))){total_unread_notifications=parseInt(total_unread_notifications)+parseInt(side_navigation.find('li.realtime_module[module="site_notifications"]').attr('unread'))}
if(isFinite(side_navigation.find('li.realtime_module[module="complaints"]').attr('unresolved'))){total_unread_notifications=parseInt(total_unread_notifications)+parseInt(side_navigation.find('li.realtime_module[module="complaints"]').attr('unresolved'))}
if(isFinite(side_navigation.find('li.realtime_module[module="friends"]').attr('pending'))){total_unread_notifications=parseInt(total_unread_notifications)+parseInt(side_navigation.find('li.realtime_module[module="friends"]').attr('pending'))}
if(current_total_unread_notifications!=total_unread_notifications){var set_browser_title=system_variable('current_title');if($.trim(set_browser_title).length==0){set_browser_title=default_meta_title}
if(total_unread_notifications!=0){$('.total_unread_notifications').html('<span>'+abbreviateNumber(total_unread_notifications)+'</span>');document.title='['+total_unread_notifications+'] '+set_browser_title}else{$('.total_unread_notifications').html('');document.title=set_browser_title}
$('.total_unread_notifications').attr('total_unread_notification',total_unread_notifications)}}else{console.log('ERROR : '+data)}
realtime_request=null;realtime_timeout=null;if(system_variable('realtime_mode')!=='websocket'){realtime()}}
function realtime_logs(realtime_logs){$.each(realtime_logs,function(index,realtime_log){if(realtime_log.log_type!==undefined&&realtime_log.related_parameters!==undefined&&realtime_log.log_type!='skip_log'){if(realtime_log.log_type=='message_reaction'){realtime_log.related_parameters=$.parseJSON(realtime_log.related_parameters);if(realtime_log.related_parameters.total_reactions!==undefined){realtime_log.related_parameters.total_reactions=$.parseJSON(realtime_log.related_parameters.total_reactions);update_message_reactions(realtime_log.related_parameters)}}else if(realtime_log.log_type=='deleted_message'){realtime_log.related_parameters=$.parseJSON(realtime_log.related_parameters);if(realtime_log.related_parameters.message_id!==undefined){remove_messages(realtime_log.related_parameters)}}else if(realtime_log.log_type=='mention_everyone'){realtime_log.related_parameters=$.parseJSON(realtime_log.related_parameters);if(realtime_log.related_parameters.group_id!==undefined&&realtime_log.realtime_log_id!==undefined){mention_everyone(realtime_log.realtime_log_id)}}else if(realtime_log.log_type=='group_va_chat_settings'){if(system_variable('video_chat')!=='disable'){realtime_log.related_parameters=$.parseJSON(realtime_log.related_parameters);if(realtime_log.related_parameters.group_id!==undefined){if(current_video_chat_id==realtime_log.related_parameters.group_id&&current_video_chat_type==='group'){if(video_chat_available&&isVideoChatActive){location.reload(!0)}}}}}else if(realtime_log.log_type=='removed_all_messages'){realtime_log.related_parameters=$.parseJSON(realtime_log.related_parameters);if(realtime_log.related_parameters.group_id!==undefined){if($('.main .chatbox').attr('group_id')==realtime_log.related_parameters.group_id){$('.main .chatbox > .contents > .chat_messages > ul').html('')}}}}})}
function execute_sys_tasks(){if(!isFetching_systasks){isFetching_systasks=!0;var post_data={realtime:!0,sys_tasks:'execute'};if(user_csrf_token!=null){post_data.csrf_token=user_csrf_token}
if(user_login_session_id!=null&&user_access_code!=null&&user_session_time_stamp!=null){post_data.login_session_id=user_login_session_id;post_data.access_code=user_access_code;post_data.session_time_stamp=user_session_time_stamp}
$.ajax({type:'POST',url:realtime_request_url,data:post_data,async:!0,success:function(data){}}).done(function(data){isFetching_systasks=!1}).fail(function(qXHR,textStatus,errorThrown){if(qXHR.statusText!='abort'&&qXHR.statusText!='canceled'){console.log('ERROR : '+errorThrown)}
isFetching_systasks=!1})}};;