(function(factory){"use strict";if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof module!=='undefined'&&module.exports){module.exports=factory(require('jquery'));}else{factory(jQuery);}}(function($,undefined){var widgetData=[];var clientCountry='';var isChatyInMobile=(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))?1:0;var defaultFontFamily=["System Stack","Arial","Tahoma","Verdana","Helvetica","Times New Roman","Trebuchet MS","Georgia","-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"];var chatyEnv='dev';var isBoatUser=false;var chatyHasTimeDelay=false;var chatyMaxTimeInterval=0;var chatyHasPageScroll=false;var chatyHasExitIntent=false;var chatyPageScrolls=[];var chatyTimeInterval;var chatyIntervalTime=0;var lastScrollPer=0;var customExtraCSS="";var chatyHideTimeInterval;var chatyHideIntervalTime=0;var ariaLabel="";function checkForChatySettings(){chatyInterval=setInterval(function(){if(typeof(chaty_settings)=="object"){clearInterval(chatyInterval);if(typeof chaty_settings=="object"&&(chaty_settings.data_analytics_settings!="on"||chaty_settings.data_analytics_settings=="off")){isBoatUser=true;} if(isTrue(chaty_settings.has_chatway)){$("body").addClass("csaas-has-chatway");} widgetData=chaty_settings.chaty_widgets;checkForCountry();}},1000)} $(document).ready(function(){var botPattern="(googlebot\/|bot|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)";var re=new RegExp(botPattern,'i');var userAgent=navigator.userAgent;if(re.test(userAgent)){isBoatUser=true;} if(isChatyInMobile){$("body").addClass("cht-in-mobile");}else{$("body").addClass("cht-in-desktop");} if(isTrue(chaty_settings.has_chatway)){$("body").addClass("csaas-has-chatway");} if(typeof chaty_settings=="undefined"){console.log("Chaty settings doesn't exists");checkForChatySettings()}else if(chaty_settings.chaty_widgets.length==0){console.log("Chaty widget doesn't exists");}else{widgetData=chaty_settings.chaty_widgets;checkForCountry();if(typeof chaty_settings=="object"&&chaty_settings.data_analytics_settings!="on"||chaty_settings.data_analytics_settings=="off"){isBoatUser=true;}} if($(window).height()>$(window).width()){$("body").addClass("cht-portrait").removeClass("cht-landscape");}else{$("body").addClass("cht-landscape").removeClass("cht-portrait");} $(document).on("click","html, body",function(e){if($(".chaty-popup-whatsapp-form.active").length){$(".chaty-popup-whatsapp-form.active").each(function(){var widgetId=$(this).data("widget");var clickStatus=checkChatyCookieExpired(widgetId,"c-Whatsapp");if((!isEmpty(widgetId)||widgetId==0)&&clickStatus){saveChatyCookieString(widgetId,"c-Whatsapp");}})} $(".form-open").removeClass("form-open");$(".chaty-outer-forms").removeClass("active");$(".chaty .chaty-widget.chaty-no-close-button:not(.has-single)").addClass("chaty-open");if($(".chaty .chaty-widget").hasClass("chaty-open")){$(".chaty .chaty-widget:not(.chaty-no-close-button)").removeClass("chaty-open");$("body").removeClass("add-bg-blur-effect");} $("body").removeClass("add-bg-blur-effect");chatySetCookie("hide-bg-blur-effect",true,365);hideDefaultOpenWidgets();});$(document).on("click",".chaty, .chaty-outer-forms",function(e){e.stopPropagation();});$(document).on("click",".chaty.form-open .chaty-i-trigger.single-channel a",function(e){$("body").removeClass("add-bg-blur-effect");});$(document).on("click",".chaty.form-open .chaty-i-trigger.single-channel .chaty-cta-close",function(e){$("body").removeClass("add-bg-blur-effect");});$(document).on("click",".chaty-close-view-list",function(){$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$("body").removeClass("add-bg-blur-effect");chatySetCookie("hide-bg-blur-effect",true,365);hideDefaultOpenWidgets();});$(document).on("submit",".whatsapp-chaty-form",function(){if($(this).hasClass("form-google-analytics")){var widgetChannel="Whatsapp";if(window.hasOwnProperty("gtag")){gtag("event","chaty_"+widgetChannel,{eventCategory:"chaty_"+widgetChannel,event_action:"chaty_"+widgetChannel,method:"chaty_"+widgetChannel});} if(window.hasOwnProperty("ga")){var ga_settings=window.ga.getAll()[0];ga_settings&&ga_settings.send("event","click",{eventCategory:"chaty_"+widgetChannel,eventAction:"chaty_"+widgetChannel,method:"chaty_"+widgetChannel})}} var widgetId=$(this).data('widget');var chatyChannel=$(this).data('channel');var clickStatus=checkChatyCookieExpired(widgetId,"c-"+chatyChannel);if((!isEmpty(widgetId)||widgetId==0)&&clickStatus){saveChatyCookieString(widgetId,"c-"+chatyChannel);var widgetNonce=$("#chaty-widget-"+widgetId).data("nonce");if(!isBoatUser){$.ajax({url:chaty_settings.ajax_url,data:{widgetId:widgetId,userId:widgetId,isMobile:isChatyInMobile,channel:chatyChannel,nonce:widgetNonce,action:'update_chaty_channel_click'},dataType:'json',method:'post',});}} if($("#chaty-widget-"+widgetId).length){$("#chaty-widget-"+widgetId).removeClass("form-open");$(this).closest(".chaty-outer-forms").removeClass("active");if($("#chaty-widget-"+widgetId).find(".chaty-widget").hasClass("cssas-no-close-button")){$("#chaty-widget-"+widgetId).find(".chaty-widget:not(.has-single)").addClass("chaty-open")}} if($("body").hasClass("add-bg-blur-effect")){$("body").removeClass("add-bg-blur-effect");hideDefaultOpenWidgets();}});$(document).on("click",".chaty-close-button, .chaty-close-agent-list, .whatsapp-form-close-btn",function(e){e.preventDefault();e.stopPropagation();var widgetId=$(this).closest(".chaty-outer-forms").data('widget');if(!isEmpty(widgetId)||widgetId==0){if($("#chaty-widget-"+widgetId).length){$("#chaty-widget-"+widgetId).removeClass("form-open");$(this).closest(".chaty-outer-forms").removeClass("active");if($("#chaty-widget-"+widgetId).find(".chaty-widget").hasClass("chaty-no-close-button")){$("#chaty-widget-"+widgetId).find(".chaty-widget:not(.has-single)").addClass("chaty-open");}} if($(this).closest(".chaty-whatsapp-btn-form").length){var dataChannel=$(this).closest(".chaty-outer-forms").data('channel');if(!isEmpty(dataChannel)){var clickStatus=checkChatyCookieExpired(widgetId,"c-"+dataChannel);if(clickStatus){saveChatyCookieString(widgetId,"c-"+dataChannel);}} var visibleStatus=checkChatyCookieExpired(widgetId,'v-widget');if(visibleStatus){updateWidgetViews(widgetId);}} if($(this).hasClass("whatsapp-form-close-btn")){clickStatus=checkChatyCookieExpired(widgetId,"c-Whatsapp");if((!isEmpty(widgetId)||widgetId==0)&&clickStatus){saveChatyCookieString(widgetId,"c-Whatsapp");}}} $("body").removeClass("add-bg-blur-effect");});$(document).on("keypress",'.chaty-contact-input input[type="tel"]',function(e){var charCode=(e.which)?e.which:e.keyCode;if(charCode==43&&$(this).val()==""){return true;} if(charCode>=48&&charCode<=57){return true;} return false;});$(document).on("change",'.chaty-contact-input input[type="tel"]',function(){var regex=new RegExp(/^(\+)?\d*$/);var phone_number=$(this).val();if(!regex.test(phone_number)){$(this).val("");}});$(document).on("click","a.chaty-qr-code-form",function(e){e.preventDefault();var dataForm=$(this).data('form');if(!isEmpty(dataForm)){if($("#"+dataForm).length){var buttonHtml=$(this).html();if($("#"+dataForm).hasClass("active")){$(this).closest(".chaty").find(".chaty-widget:not(.has-single)").addClass("chaty-open");$(this).closest(".chaty").removeClass("form-open");$("#"+dataForm).removeClass("active");$("body").removeClass("add-bg-blur-effect");}else{$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$(this).closest(".chaty").addClass("form-open");$("#"+dataForm).addClass("active");buttonHtml=$(this).closest(".chaty").find(".chaty-widget .chaty-cta-close").find("button").html();$(this).closest(".chaty").find(".open-chaty-channel").html(buttonHtml);}}}});$(document).on("click","a.chaty-contact-us-form",function(e){e.preventDefault();var dataForm=$(this).data('form');if(!isEmpty(dataForm)){if($("#"+dataForm).length){if(googleV3Token!=""){googleV3Token="";refreshG3Token();} if($("#"+dataForm).hasClass("active")){$(this).closest(".chaty").find(".chaty-widget:not(.has-single)").addClass("chaty-open");$(this).closest(".chaty").removeClass("form-open");$("#"+dataForm).removeClass("active");$("body").removeClass("add-bg-blur-effect");}else{$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$(this).closest(".chaty").addClass("form-open");$("#"+dataForm).addClass("active");$("#"+dataForm).find(".chaty-ajax-success-message").remove();$("#"+dataForm).find(".chaty-ajax-error-message").remove();$("#"+dataForm).find(".has-chaty-error").removeClass("has-chaty-error");buttonHtml=$(this).closest(".chaty").find(".chaty-widget .chaty-cta-close").find("button").html();$(this).closest(".chaty").find(".open-chaty-channel").html(buttonHtml);}}}});$(document).on("click","a.chaty-whatsapp-btn-form",function(e){e.preventDefault();var dataForm=$(this).data('form');if(!isEmpty(dataForm)){if($("#"+dataForm).length){if($("#"+dataForm).hasClass("active")){$(this).closest(".chaty").find(".chaty-widget:not(.has-single)").addClass("chaty-open");$(this).closest(".chaty").removeClass("form-open");$("#"+dataForm).removeClass("active");$("body").removeClass("add-bg-blur-effect");setTimeout(function(){$("body").removeClass("add-bg-blur-effect");},100);}else{$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$(this).closest(".chaty").addClass("form-open");$("#"+dataForm).addClass("active");var buttonHtml=$(this).closest(".chaty").find(".chaty-widget .chaty-cta-close").find("button").html();$(this).closest(".chaty").find(".chaty-widget").find(".open-chaty-channel").html(buttonHtml);} setTimeout(function(){$(".chaty-whatsapp-btn-form.active .chaty-whatsapp-input").focus();},100);}}});$(document).on("click",".chaty-channel.chaty-agent-button",function(e){e.preventDefault();var dataForm=$(this).data('form');if(!isEmpty(dataForm)){if($("#"+dataForm).length){if(!$(this).closest(".chaty").find(".chaty-widget").hasClass("has-single")){var buttonHtml=$(this).html();$("#"+dataForm).addClass("is-active");$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$(this).closest(".chaty").addClass("form-open");$("#"+dataForm).addClass("active");buttonHtml=$(this).closest(".chaty").find(".chaty-widget .chaty-cta-close").find("button").html();$(this).closest(".chaty").find(".open-chaty-channel").html(buttonHtml);}else{if($(this).closest(".chaty").hasClass("form-open")){$(this).closest(".chaty").find(".chaty-widget:not(.has-single)").addClass("chaty-open");$(this).closest(".chaty").removeClass("form-open");$("#"+dataForm).removeClass("active");$("body").removeClass("add-bg-blur-effect");}else{buttonHtml=$(this).closest(".chaty").find(".chaty-widget .chaty-cta-close").find("button").html();$("#"+dataForm).addClass("is-active");$(this).closest(".chaty").find(".chaty-widget").removeClass("chaty-open");$(this).closest(".chaty").addClass("form-open");$("#"+dataForm).addClass("active");$(this).closest(".chaty").find(".open-chaty-channel").html(buttonHtml);}}}}});$(document).on("click",".chaty-channel a.has-gae",function(e){var widgetChannel=$(this).closest(".chaty-channel").data("channel");if(widgetChannel!==undefined&&widgetChannel!=""&&widgetChannel!=null){if(window.hasOwnProperty("gtag")){gtag("event","chaty_"+widgetChannel,{eventCategory:"chaty_"+widgetChannel,event_action:"chaty_"+widgetChannel,method:"chaty_"+widgetChannel});} if(window.hasOwnProperty("ga")){var ga_settings=window.ga.getAll()[0];ga_settings&&ga_settings.send("event","click",{eventCategory:"chaty_"+widgetChannel,eventAction:"chaty_"+widgetChannel,method:"chaty_"+widgetChannel})}}});$(document).on("mouseover",".chaty-widget.has-single .chaty-channel a.has-on-hover[data-hover]",function(){$(this).find(".on-hover-text").html($(this).data("hover"));}).on("mouseleave",".chaty-widget.has-single .chaty-channel a.has-on-hover[data-text]",function(){$(this).find(".on-hover-text").html($(this).data("text"));});$(document).on("submit",".whatsapp-chaty-form.has-form-gae",function(){var widget_id=$(this).data("widget");var widgetChannel=$("#Whatsapp-"+widget_id+"-channel").data("channel");if(widgetChannel!==undefined&&widgetChannel!=""&&widgetChannel!=null){if(window.hasOwnProperty("gtag")){gtag("event","chaty_whatsapp_redirect",{eventCategory:"chaty_whatsapp_redirect",event_action:"chaty_whatsapp_redirect",method:"chaty_whatsapp_redirect"});} if(window.hasOwnProperty("ga")){var ga_settings=window.ga.getAll()[0];ga_settings&&ga_settings.send("event","click",{eventCategory:"chaty_whatsapp_redirect",eventAction:"chaty_whatsapp_redirect",method:"chaty_whatsapp_redirect"})}}});$(document).on("click",".chaty-i-trigger:not(.single-channel)",function(){if($(this).closest(".chaty").hasClass("form-open")){$(this).closest(".chaty").removeClass("form-open");$(this).closest(".chaty-widget:not(.has-single)").addClass("chaty-open");}else{$(this).closest(".chaty-widget").toggleClass("chaty-open");} $(".chaty-outer-forms.active").each(function(){$(this).removeClass("active");var widgetID=$(this).data("widget");$("#chaty-widget-"+widgetID).removeClass("form-open");});if($(this).closest(".chaty").find(".chaty-widget").hasClass("chaty-no-close-button")){$(this).closest(".chaty").find(".chaty-widget:not(.has-single)").addClass("chaty-open");}});$(document).on("click",".chaty-i-trigger.single-channel .chaty-cta-close",function(){if($(this).closest(".chaty").hasClass("form-open")){$(this).closest(".chaty").removeClass("form-open");var chatyWidgetId=$(this).closest(".chaty").data("id");if($("#chaty-form-"+chatyWidgetId+"-Whatsapp").length&&$("#chaty-form-"+chatyWidgetId+"-Whatsapp").hasClass("active")){clickStatus=checkChatyCookieExpired(chatyWidgetId,"c-Whatsapp");if((!isEmpty(chatyWidgetId)||chatyWidgetId==0)&&clickStatus){saveChatyCookieString(chatyWidgetId,"c-Whatsapp");}}} $(".chaty-outer-forms.active").each(function(){$(this).removeClass("active");var widgetID=$(this).data("widget");$("#chaty-widget-"+widgetID).removeClass("form-open");});});if(!isChatyInMobile){$(document).on("mouseover","body:not(.chaty-in-mobile) .chaty.open-on-hover .chaty-i-trigger:not(.single-channel)",function(){if(!$(this).closest(".chaty-widget").hasClass("chaty-open")&&!$(this).closest(".chaty-widget").hasClass("on-chaty-widget")){$(this).closest(".chaty-widget").addClass("on-chaty-widget");$(this).find(".chaty-cta-main").trigger("click");}}).on("mouseleave","body:not(.chaty-in-mobile) .chaty.open-on-hover .chaty-i-trigger:not(.single-channel)",function(){if(!$(this).closest(".chaty-widget").hasClass("chaty-open")){$(this).closest(".chaty-widget").removeClass("on-chaty-widget")}});} $(document).on("click",".chaty-channel.single a",function(){var chatyWidgetId=$(this).closest(".chaty").data("id");if($(this).closest(".chaty").hasClass("first_click")){$(this).closest(".chaty-channel").removeClass("active");} removeChatyAnimation(chatyWidgetId);});$(document).on("click",".chaty-chatway-channel",function(){if(typeof(window.$chatway)=='object'){window.$chatway.openChatwayWidget()}});$(document).on("click",".chaty-channel a, .chaty-channel button",function(e){var clickStatus;var chatyChannel;var chatyChannels=[];var isSingle=0;var chatyWidgetIdentifier;var chatyWidgetId=$(this).closest(".chaty").data("id");if(typeof chatyWidgetId!='undefined'){chatyWidgetIdentifier=$("#chaty-widget-"+chatyWidgetId).data("identifier");if(typeof chatyWidgetIdentifier!='undefined'){var userId=$("#chaty-widget-"+chatyWidgetId).data("user");removeChatyAnimation(chatyWidgetId);if($(this).closest(".chaty-channel").hasClass("chaty-cta-main")||$(this).closest(".chaty-channel").hasClass("chaty-cta-close")){if($("#chaty-form-"+chatyWidgetId+"-Whatsapp").length&&$("#chaty-form-"+chatyWidgetId+"-Whatsapp").hasClass("active")){clickStatus=checkChatyCookieExpired(chatyWidgetId,"c-Whatsapp");if((!isEmpty(chatyWidgetId)||chatyWidgetId==0)&&clickStatus){saveChatyCookieString(chatyWidgetId,"c-Whatsapp");}} clickStatus=checkChatyCookieExpired(chatyWidgetId,'c-widget');$("#chaty-widget-"+chatyWidgetId).find(".ch-pending-msg").remove();if(clickStatus){saveChatyCookieString(chatyWidgetId,"c-widget");if($(this).closest(".chaty-channel").hasClass("chaty-cta-main")){chatyChannels=[];if($("#chaty-widget-"+chatyWidgetId).hasClass("chaty-has-chat-view")){$(".chaty-chat-view.chaty-chat-view-"+chatyWidgetId+" .chaty-view-channels").find(".chaty-channel").each(function(){chatyChannel=$(this).data("channel");clickStatus=checkChatyCookieExpired(chatyWidgetId,"v-"+chatyChannel);if(clickStatus&&typeof chatyChannel!='undefined'){saveChatyCookieString(chatyWidgetId,"v-"+chatyChannel);chatyChannels.push(chatyChannel);}});}else{$("#chaty-widget-"+chatyWidgetId+" .chaty-channel-list").find(".chaty-channel").each(function(){chatyChannel=$(this).data("channel");clickStatus=checkChatyCookieExpired(chatyWidgetId,"v-"+chatyChannel);if(clickStatus&&typeof chatyChannel!='undefined'){saveChatyCookieString(chatyWidgetId,"v-"+chatyChannel);chatyChannels.push(chatyChannel);}});} var widgetNonce=$("#chaty-widget-"+chatyWidgetId).data("nonce");if(!isBoatUser){$.ajax({url:chaty_settings.ajax_url,data:{widgetId:chatyWidgetId,userId:userId,isMobile:isChatyInMobile,channels:chatyChannels,isSingle:0,nonce:widgetNonce,action:'update_chaty_widget_click'},dataType:'json',method:'post',});}}} if($("#chaty-widget-"+chatyWidgetId).hasClass("first_click")){$("#chaty-widget-"+chatyWidgetId+" .chaty-cta-main").removeClass("active");$("#chaty-widget-"+chatyWidgetId+" .chaty-cta-main").removeClass("chaty-tooltip");}}else if($(this).closest(".chaty-channel").hasClass("single")){$("#chaty-widget-"+chatyWidgetId).find(".ch-pending-msg").remove();clickStatus=checkChatyCookieExpired(chatyWidgetId,'c-widget');var widgetNonce=$("#chaty-widget-"+chatyWidgetId).data("nonce") if(clickStatus){saveChatyCookieString(chatyWidgetId,'c-widget');isSingle=0;chatyChannels=[];chatyChannel=$(this).closest(".chaty-channel").data("channel");clickStatus=checkChatyCookieExpired(chatyWidgetId,"c-"+chatyChannel);if(clickStatus){chatyChannels.push(chatyChannel);isSingle=1;} if(!isBoatUser){$.ajax({url:chaty_settings.ajax_url,data:{widgetId:chatyWidgetId,userId:userId,isMobile:isChatyInMobile,channels:chatyChannels,isSingle:isSingle,nonce:widgetNonce,action:'update_chaty_widget_click'},dataType:'json',method:'post',});}} if($("#chaty-widget-"+chatyWidgetId).hasClass("first_click")){$("#chaty-widget-"+chatyWidgetId+" .chaty-tooltip").removeClass("chaty-tooltip");$("#chaty-widget-"+chatyWidgetId+" .single-channel a").addClass("chaty-tooltip");}}else if($(this).hasClass("chaty-link")){chatyChannel=$(this).closest(".chaty-channel").data("channel");clickStatus=checkChatyCookieExpired(chatyWidgetId,"c-"+chatyChannel);if(clickStatus){saveChatyCookieString(chatyWidgetId,"c-"+chatyChannel);var widgetNonce=$("#chaty-widget-"+chatyWidgetId).data("nonce");if(!isBoatUser){$.ajax({url:chaty_settings.ajax_url,data:{widgetId:chatyWidgetId,userId:userId,isMobile:isChatyInMobile,channel:chatyChannel,nonce:widgetNonce,action:'update_chaty_channel_click'},dataType:'json',method:'post',});}}}}}});$(document).on("submit",".chaty-ajax-contact-form",function(e){e.preventDefault();var inputErrorCounter=0;$(this).find(".has-chaty-error").each(function(){$(this).removeClass("has-chaty-error");});$(this).find(".chaty-error-msg").remove();$(this).find(".chaty-ajax-error-message").remove();$(this).find(".chaty-ajax-success-message").remove();$(this).find(".is-required").each(function(){if(jQuery.trim($(this).val())==""){inputErrorCounter++;$(this).addClass("has-chaty-error");if($(this).hasClass("chaty-text-block")){$(this).closest(".chaty-contact-input").find(".mce-tinymce").addClass("mce-error");}}});if(inputErrorCounter==0){var $form=$(this);var form=$form[0];var data=new FormData(form);$(".chaty-submit-button").attr("disabled",true);$("#chaty-submit-button-"+$form.data("index")+" .chaty-loader").addClass("active");jQuery.ajax({url:chaty_settings.ajax_url,enctype:'multipart/form-data',data:data,type:'post',dataType:'json',cache:false,contentType:false,processData:false,success:function(response){if(googleV3Token!=""){googleV3Token="";refreshG3Token();} $(".chaty-ajax-error-message").remove();$(".chaty-ajax-success-message").remove();$(".chaty-submit-button").attr("disabled",false);if(response.status==1){$("#chaty-submit-button-"+$form.data("index")+" .chaty-loader").removeClass("active");$(".chaty-contact-inputs").append("
"+response.message+"
");$(".chaty-ajax-contact-form").find(".chaty-contact-input .mce-tinymce").removeClass("mce-error");$(".field-name, .field-email, .field-message, .field-phone").val("");$(".chaty-ajax-contact-form").find(".chaty-input-field").val("");$(".chaty-ajax-contact-form").find(".chaty-textarea-field").val("");$("#"+$form.find(".chaty-text-block").attr("id")+"_ifr").contents().find("body").html("");if(response.redirect_action=="yes"){if(response.link_in_new_tab=="yes"){var openInNewTab=window.open(response.redirect_link,'_blank');if(openInNewTab==null){window.open(response.redirect_link);}}else{window.location=response.redirect_link;}} if(response.close_form_after=="yes"){setTimeout(function(){if($(".chaty-outer-forms.active").length){var widgetId=$(".chaty-outer-forms.active").data('widget');if(!isEmpty(widgetId)||widgetId==0){if($("#chaty-widget-"+widgetId).length){$("#chaty-widget-"+widgetId).removeClass("form-open");$("body").removeClass("add-bg-blur-effect");$(".chaty-outer-forms.active").removeClass("active");if($("#chaty-widget-"+widgetId).find(".chaty-widget").hasClass("chaty-no-close-button")){$("#chaty-widget-"+widgetId).find(".chaty-widget:not(.has-single)").addClass("chaty-open")}}}}},parseInt(response.close_form_after_seconds)*1000);}}else if(response.error==1){if(response.errors.length){for(var i=0;i"+response.errors[i].message+"");}} $(".chaty-loader").removeClass("active");}else if(response.status==0){$(".chaty-contact-inputs").append("
"+response.message+"
");$(".chaty-loader").removeClass("active");} $(".email_suggestion").html('');}});}else{$(".has-chaty-error:first").focus();} return false;});$(document).on('blur','.chaty-contact-form-box .field-email',function(event){var widget_id=$(this).closest(".chaty-contact-form-box").data("widget");$(this).mailcheck({suggested:function(element,suggestion){$('#email_suggestion'+widget_id).html("Did you mean "+suggestion.full+"?");},empty:function(element){$('#email_suggestion'+widget_id).html('');}});});if($(".chaty-contact-form-box .field-email").length){$(".chaty-contact-form-box .field-email").emailautocomplete({domains:["protonmail.com","yahoo.com","gmail.com"]});} $(document).on("click",".email_suggestion i",function(){$(this).closest(".chaty-contact-form-box").find(".field-email").val($(this).text()).focus();jQuery(this).closest(".email_suggestion").html('');});$(document).on("click",".chaty-widget.has-single .chaty-i-trigger .chaty-channel:not(.chaty-agent-button).Phone-channel",function(){window.location=$(this).find("a").prop("href");});$(document).on("click",".chaty-widget.has-single .chaty-i-trigger .chaty-channel:not(.chaty-agent-button).Phone-channel a, .picmo__popupContainer",function(e){e.stopPropagation();e.stopImmediatePropagation();});$(document).on("click",".chaty-wp-emoji-input",function(){if($(".picmo__popupContainer").length){}else{const{createPopup}=window.picmoPopup;const trig=document.querySelector("#chaty_whatsapp_input");const picker=createPopup({},{referenceElement:trig,triggerElement:trig,position:'top',hideOnEmojiSelect:false});picker.toggle();picker.addEventListener('emoji:select',(selection)=>{$('.chaty-whatsapp-input').val($(".chaty-whatsapp-input").val()+selection.emoji);});}});$(document).on("click","#chaty_whatsapp_input",function(){if($(".picmo__popupContainer").length){$(".picmo__popupContainer").remove();}});});function setChatyEditor(){if($(".chaty-text-block:not(.editor-loaded)").length){$(".chaty-text-block:not(.editor-loaded)").each(function(){text_id=$(this).attr("id");wp.editor.initialize(text_id,{tinymce:{wpautop:false,toolbar1:'bold italic underline',},quicktags:false});})}} $(window).resize(function(){if($(window).height()>$(window).width()){$("body").addClass("cht-portrait").removeClass("cht-landscape");}else{$("body").addClass("cht-landscape").removeClass("cht-portrait");}});function removeChatyAnimation(widgetId){if($("#chaty-widget-"+widgetId).data("animation")!=undefined&&$("#chaty-widget-"+widgetId).data("animation")!="none"){var animationClass="chaty-animation-"+$("#chaty-widget-"+widgetId).data("animation");$("#chaty-widget-"+widgetId+" ."+animationClass).removeClass(animationClass);} $("#chaty-widget-"+widgetId+" .ch-pending-msg").remove();} function checkForCountry(){var hasCountryFilter=false;if(widgetData.length){$.each(widgetData,function(key,widgetRecord){if(isTrue(widgetRecord.triggers.has_countries)&&!isEmpty(widgetRecord.triggers.countries)&&widgetRecord.triggers.countries.length){hasCountryFilter=true;}});} if(hasCountryFilter){clientCountry=getUserCountry();if(clientCountry!=''){startMakingWidgets();}else{getClientCountry();}}else{startMakingWidgets();}} function getClientCountry(){var $ipurl='https://www.cloudflare.com/cdn-cgi/trace';$.get($ipurl,function(cloudflaredata){var currentCountry=cloudflaredata.match("loc=(.*)");if(currentCountry.length>1){currentCountry=currentCountry[1];if(currentCountry){currentCountry=currentCountry.toUpperCase();if(currentCountry==""){currentCountry="-";} setUserCountry(currentCountry);startMakingWidgets();}}});} function startMakingWidgets(){if(widgetData.length){$("body").append(' ');$.each(widgetData,function(key,widgetRecord){var customCSS="";var advanceCustomCSS="";var activeChannels=0;var activeChannelList=[];var channelSetting={};var widgetStatus=checkForUserCountry(widgetRecord);widgetStatus=widgetStatus&&checkForTimeSchedule(widgetRecord);widgetStatus=widgetStatus&&checkForDayAndTimeSchedule(widgetRecord);let chatwaySettings=null;let hasChatway=0;let chatwayPosition=null;let hasOnlyChatway=false;$.each(widgetRecord.channels,function(key,channel){var channelStatus=checkForChannel(channel);if(channelStatus){if(channel.channel==="Chatway"){hasChatway=true;chatwayPosition=channel.chatway_position;chatwaySettings=channel;if(chatwayPosition==="inside-chaty"||widgetRecord.settings.cta_type==="chat-view"){hasOnlyChatway=true;activeChannels++;activeChannelList.push(channel);}}else{channelSetting=channel;activeChannelList.push(channel);activeChannels++;}}});if(widgetRecord.settings.default_state=="open"&&activeChannels==1&&widgetRecord.settings.cta_type!="chat-view"){widgetRecord.settings.default_state="click";widgetData[key].settings.default_state="click";} let chatwayClass='';if(hasChatway){chatwayClass='has-chatway-channel'} let skipWidget=(activeChannels==1&&hasOnlyChatway)?false:true;if(skipWidget&&widgetStatus&&activeChannels>0&&!$("#chaty-widget-"+widgetRecord.id).length){var widgetPosition=getWidgetPosition(widgetRecord.settings);widgetPosition=(widgetPosition=="right")?"right":"left";var toolTipPosition=getToolTipPosition(widgetRecord);if(widgetRecord.settings.cta_type=="chat-view"){var widgetHtml="";$("body").append(widgetHtml);makeChatyChatView(widgetRecord);}else{var widgetHtml="";$("body").append(widgetHtml);} if(isTrue(widgetRecord.triggers.auto_hide_widget)&&parseInt(widgetRecord.triggers.hide_after)>0){$("#chaty-widget-"+widgetRecord.id).addClass("auto-hide-chaty");$("#chaty-widget-"+widgetRecord.id).attr("data-time",widgetRecord.triggers.hide_after);} var clickStatus=checkChatyCookieExpired(widgetRecord.id,'c-widget');$("#chaty-widget-"+widgetRecord.id).addClass(widgetRecord.settings.show_cta);if(activeChannels==1&&widgetRecord.settings.cta_type!="chat-view"){if(widgetRecord.settings.icon_view!="vertical"){toolTipPosition=(widgetPosition!="right")?"right":"left";} var channelHtml=getChannelSetting(channelSetting,widgetRecord.id,toolTipPosition);$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger").append(channelHtml);$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger").addClass("single-channel");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel").addClass("single");$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").addClass("has-single");var ctaText=widgetRecord.settings.cta_text;if(!isEmpty(ctaText)){ctaText=htmlDecode(ctaText);} if(widgetRecord.settings.show_cta=="first_click"){if(clickStatus){$("#chaty-widget-"+widgetRecord.id+" .chaty-tooltip").removeClass("chaty-tooltip");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel").addClass("active").addClass("chaty-tooltip").addClass("pos-"+toolTipPosition);$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel").append(""+ctaText+"").addClass("active").addClass("has-on-hover");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel a").append(""+ctaText+"").addClass("has-on-hover");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel a").attr("data-text",ctaText);}else{$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel a").append(""+ctaText+"").removeClass("active").addClass("has-on-hover");}} if(widgetRecord.settings.show_cta=="all_time"){$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-tooltip").append(""+ctaText+"").addClass("active").addClass("has-on-hover");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger.single-channel .chaty-channel a").attr("data-text",ctaText);} var channel=channelSetting;if(channel.channel_type!="Instagram"||(channel.icon_color!="#ffffff"&&channel.icon_color!="#fff")){customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .color-element{ fill: "+channel.icon_color+"; color: "+channel.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" .channel-icon-"+channel.channel_type+" .color-element{ fill: "+channel.icon_color+"; color: "+channel.icon_color+";}";} customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-custom-icon { background-color: "+channel.icon_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-svg { background-color: "+channel.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" .channel-icon-"+channel.channel_type+" .chaty-svg { background-color: "+channel.icon_color+";}";if(channel.channel_type=="Contact_Us"){customCSS+=".chaty-contact-form-box #chaty-submit-button-"+widgetRecord.id+" {background-color: "+channel.contact_form_settings.button_bg_color+"; color: "+channel.contact_form_settings.button_text_color+";} ";customCSS+="#chaty-form-"+widgetRecord.id+"-Contact_Us .chaty-contact-form-title {background-color: "+channel.contact_form_settings.title_bg_color+"; } ";} var closeHtml='
'+'
'+'
'+'
';$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger").append(closeHtml);}else{$.each(widgetRecord.channels,function(key,channel){var channelStatus=checkForChannel(channel);if(channelStatus&&(channel.channel!=="Chatway"||(chatwayPosition==="inside-chaty"||widgetRecord.settings.cta_type==="chat-view"))){if(isValueEmpty(channel.channel_type)){channel.channel_type=channel.channel;} if(widgetRecord.settings.cta_type=="chat-view"){var channelHtml=getChannelSetting(channel,widgetRecord.id,"top");$(".chaty-chat-view-"+widgetRecord.id+" .chaty-view-channels").append(channelHtml);}else{var channelHtml=getChannelSetting(channel,widgetRecord.id,toolTipPosition);$("#chaty-widget-"+widgetRecord.id+" .chaty-channel-list").append(channelHtml);} if((channel.channel_type!="Instagram"&&channel.channel_type!="Instagram_DM")||(channel.icon_color!="#ffffff"&&channel.icon_color!="#fff")){customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .color-element{ fill: "+channel.icon_color+"; color: "+channel.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" .channel-icon-"+channel.channel_type+" .color-element{ fill: "+channel.icon_color+"; color: "+channel.icon_color+";}";} customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-custom-icon { background-color: "+channel.icon_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-svg { background-color: "+channel.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" .channel-icon-"+channel.channel_type+" .chaty-svg { background-color: "+channel.icon_color+";}";customCSS+=".chaty-chat-view-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-custom-icon { background-color: "+channel.icon_color+"; }";customCSS+=".chaty-chat-view-"+widgetRecord.id+" ."+channel.channel_type+"-channel .chaty-svg { background-color: "+channel.icon_color+";}";customCSS+=".chaty-chat-view-"+widgetRecord.id+" .channel-icon-"+channel.channel_type+" .chaty-svg { background-color: "+channel.icon_color+";}";if(channel.channel_type=="Contact_Us"){customCSS+=".chaty-contact-form-box #chaty-submit-button-"+widgetRecord.id+" {background-color: "+channel.contact_form_settings.button_bg_color+"; color: "+channel.contact_form_settings.button_text_color+";} ";customCSS+="#chaty-form-"+widgetRecord.id+"-Contact_Us .chaty-contact-form-title {background-color: "+channel.contact_form_settings.title_bg_color+"; } ";}}});var widgetIcon=getWidgetIcon(widgetRecord.settings,widgetRecord.id);var ctaText=widgetRecord.settings.cta_text;if(widgetRecord.settings.show_cta=="first_click"){if(!clickStatus){ctaText="";}} var ctaToolTipPosition=toolTipPosition;if(widgetRecord.settings.icon_view=="horizontal"){if(widgetPosition=="left"){ctaToolTipPosition="right";}else{ctaToolTipPosition="left";}} if(!isEmpty(ctaText)){ctaText=htmlDecode(ctaText);} var widgetButton='
'+''+ctaText+''+'
'+''+''+'
'+'
';$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger").html(widgetButton);var closeHtml='
'+'
'+'
'+'
';$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger").append(closeHtml);} $.each(widgetRecord.channels,function(key,channel){if(channel.channel_type=="Contact_Us"&&channel.hide_recaptcha_badge=="yes"){customCSS+=".grecaptcha-badge {visibility: hidden;}";}});if(widgetRecord.settings.cta_type=="chat-view"){widgetRecord.settings.show_close_button=="yes";} var clickStatus=checkChatyCookieExpired(widgetRecord.id,'c-widget');if(clickStatus&&(widgetRecord.settings.default_state!="open"||activeChannels==1)){checkForPendingMessage(widgetRecord.settings,widgetRecord.id);checkForWidgetAnimation(widgetRecord.settings,widgetRecord.id);} var extraSpace=0;if(widgetRecord.settings.default_state=="open"&&!isTrue(widgetRecord.settings.show_close_button)){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").addClass("chaty-no-close-button").addClass("chaty-open");extraSpace=1;} if(hasChatway){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").addClass(chatwayPosition);if(chatwayPosition==="above-chaty"){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").addClass("has-chatway");let toolTipPosition=getToolTipPosition(widgetRecord);let channelHtml=getChannelSetting(chatwaySettings,widgetRecord.id,toolTipPosition,key,widgetRecord.settings);if($("#chaty-widget-"+widgetRecord.id).length){$("#chaty-widget-"+widgetRecord.id+" .chaty-channel-list").prepend(channelHtml);customExtraCSS+="#chaty-widget-"+widgetRecord.id+" ."+chatwaySettings.channel_type+"-channel .color-element{ fill: "+chatwaySettings.icon_color+"; color: "+chatwaySettings.icon_color+";}";customExtraCSS+="#chaty-widget-"+widgetRecord.id+" ."+chatwaySettings.channel_type+"-channel .csaas-svg { background-color: "+chatwaySettings.icon_color+";}";customExtraCSS+=".channel-"+widgetRecord.id+"-"+chatwaySettings.channel_type+" .csaas-svg { background-color: "+chatwaySettings.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" ."+chatwaySettings.channel_type+"-channel .chaty-custom-icon { background-color: "+chatwaySettings.icon_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" ."+chatwaySettings.channel_type+"-channel .chaty-svg { background-color: "+chatwaySettings.icon_color+";}";customCSS+="#chaty-widget-"+widgetRecord.id+" .channel-icon-"+chatwaySettings.channel_type+" .chaty-svg { background-color: "+chatwaySettings.icon_color+";}";}}} if(isTrue(widgetRecord.settings.is_google_analytics_enabled)){$("#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel > a").addClass("has-gae");$("#chaty-form-"+widgetRecord.id+"-chaty-chat-view .chaty-channel > a").addClass("has-gae");$("#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger.single-channel .chaty-channel > a").addClass("has-gae");$(".chaty-outer-forms.chaty-whatsapp-btn-form.chaty-form-"+widgetRecord.id+" form.add-analytics").addClass("form-google-analytics");$(".whatsapp-chaty-form-"+widgetRecord.id).addClass("has-form-gae");} if(isTrue(widgetRecord.settings.has_custom_css)&&!isEmpty(widgetRecord.settings.custom_css)){advanceCustomCSS+=widgetRecord.settings.custom_css;} if(widgetRecord.settings.default_state=="hover"){$("#chaty-widget-"+widgetRecord.id).addClass("open-on-hover");}else if(widgetRecord.settings.default_state=="open"){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").addClass("default-open");if(clickStatus||!isTrue(widgetRecord.settings.show_close_button)){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget:not(.has-single)").addClass("chaty-open");} if(!clickStatus){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget").removeClass("default-open");}} if($("#chaty-widget-"+widgetRecord.id+" .chaty-widget:not(.has-single):not(.chaty-no-close-button)").hasClass("default-open")){if(isTrue(widgetRecord.settings.bg_blur_effect)){$("body").addClass("add-bg-blur-effect");}}else{$("body").removeClass("add-bg-blur-effect");} if(isTrue(widgetRecord.settings.bg_blur_effect)){$("#chaty-widget-"+widgetRecord.id+" .chaty-widget:not(.chaty-no-close-button)").addClass("has-bg-blur-effect");} var widgetSize=getWidgetSize(widgetRecord.settings.widget_size,widgetRecord.settings.custom_widget_size);widgetSize=parseInt(widgetSize);customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel > a {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel > a .chaty-custom-icon {display:block; width: "+widgetSize+"px; height: "+widgetSize+"px; line-height: "+widgetSize+"px; font-size: "+parseInt(widgetSize/2)+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel button {width: "+widgetSize+"px; height: "+widgetSize+"px; margin: 0; padding:0; outline: none; border-radius: 50%;}";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel .chaty-svg {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel .chaty-svg img {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel span.chaty-icon {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel a {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list .chaty-channel .chaty-svg .chaty-custom-channel-icon {width: "+widgetSize+"px; height: "+widgetSize+"px; line-height: "+widgetSize+"px; display: block; font-size:"+(parseInt(widgetSize/2))+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-cta-button {background-color: "+widgetRecord.settings.widget_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-cta-button button {background-color: "+widgetRecord.settings.widget_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel > a {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel > a .chaty-custom-icon {display:block; width: "+widgetSize+"px; height: "+widgetSize+"px; line-height: "+widgetSize+"px; font-size: "+parseInt(widgetSize/2)+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel button {width: "+widgetSize+"px; height: "+widgetSize+"px; margin: 0; padding:0; outline: none; border-radius: 50%;}";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel .chaty-svg {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel .chaty-svg img {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel span.chaty-icon {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel a {width: "+widgetSize+"px; height: "+widgetSize+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel .chaty-svg .chaty-custom-channel-icon {width: "+widgetSize+"px; height: "+widgetSize+"px; line-height: "+widgetSize+"px; display: block; font-size:"+(parseInt(widgetSize/2))+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .ch-pending-msg {background-color: "+widgetRecord.settings.pending_mesg_count_bgcolor+"; color: "+widgetRecord.settings.pending_mesg_count_color+"; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel .chaty-svg .widget-fa-icon {line-height: "+widgetSize+"px; font-size:"+(parseInt(widgetSize/2))+"px; }";if(widgetRecord.settings.icon_view=="vertical"){customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list {height: "+(activeChannels*(widgetSize+8))+"px; }";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-channel-list {width: "+(widgetSize+8)+"px; }";for(var i=0;i<=activeChannels;i++){customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-open .chaty-channel-list .chaty-channel:nth-child("+(i+1)+") {-webkit-transform: translateY(-"+((widgetSize+8)*(activeChannels-i-extraSpace))+"px); transform: translateY(-"+((widgetSize+8)*(activeChannels-i-extraSpace))+"px);}";customCSS+="#chaty-widget-"+widgetRecord.id+" .chaty-open.above-chaty.has-chatway .chaty-channel-list .chaty-channel:nth-child("+(i+1)+") {-webkit-transform: translateY(-"+((widgetSize+8)*(activeChannels-i-extraSpace+1))+"px); transform: translateY(-"+((widgetSize+8)*(activeChannels-i-extraSpace+1))+"px);}";} if(hasChatway&&chatwayPosition=="inside-chaty"){let i=0,j=1;for(let key=0;key0){customCSS+=".chaty-outer-forms.chaty-form-"+widgetRecord.id+" .chaty-agent-body {max-height: calc(100vh - "+agentMaxHeight+"px); overflow-y: auto; } ";} customCSS+="#chaty-form-"+widgetRecord.id+"-chaty-chat-view .chaty-view-header {background-color: "+widgetRecord.settings.cta_head_bg_color+";}";customCSS+="#chaty-form-"+widgetRecord.id+"-chaty-chat-view .chaty-view-header {color: "+widgetRecord.settings.cta_head_text_color+";}";customCSS+="#chaty-form-"+widgetRecord.id+"-chaty-chat-view .chaty-view-header svg {fill : "+widgetRecord.settings.cta_head_text_color+";}";var whatsAppMaxHeight=formBottomPos+72+widgetSize;if(whatsAppMaxHeight>0){} var contactFormMaxHeight=formBottomPos+82+widgetSize;if(contactFormMaxHeight>0){customCSS+=".chaty-outer-forms.chaty-contact-form-box.chaty-form-"+widgetRecord.id+" .chaty-contact-inputs {max-height: calc(100vh - "+contactFormMaxHeight+"px); overflow-y: auto; } ";} if(bottomSpacing!=25||sideSpacing!=25){$(".chaty-outer-forms.chaty-form-"+widgetRecord.id).addClass("custom-cht-pos");$("#chaty-widget-"+widgetRecord.id).addClass("has-custom-pos");} var total_wp_form_size=parseInt($("#chaty-form-"+widgetRecord.id+"-Whatsapp .chaty-whatsapp-header").outerHeight())+parseInt($("#chaty-form-"+widgetRecord.id+"-Whatsapp .chaty-whatsapp-footer").outerHeight())+parseInt(widgetSize)+parseInt(bottomSpacing)+20;customCSS+="#chaty-form-"+widgetRecord.id+"-Whatsapp .chaty-whatsapp-body { max-height: calc(100vh - "+total_wp_form_size+"px); overflow-y: auto; }";var visibleStatus=checkChatyCookieExpired(widgetRecord.id,'v-widget');if(visibleStatus){if(isTrue(widgetRecord.triggers.exit_intent)||isTrue(widgetRecord.triggers.has_time_delay)||isTrue(widgetRecord.triggers.has_display_after_page_scroll)>0){if((isTrue(widgetRecord.triggers.has_time_delay)&&parseInt(widgetRecord.triggers.time_delay)==0)){updateWidgetViews(widgetRecord.id);$("#chaty-widget-"+widgetRecord.id).addClass("active");}else if((isTrue(widgetRecord.triggers.has_time_delay)&&parseInt(widgetRecord.triggers.time_delay)>0)){chatyHasTimeDelay=true;if(parseInt(widgetRecord.triggers.time_delay)>chatyMaxTimeInterval){chatyMaxTimeInterval=widgetRecord.triggers.time_delay;} $("#chaty-widget-"+widgetRecord.id).addClass("on-chaty-delay");$("#chaty-widget-"+widgetRecord.id).addClass("delay-time-"+parseInt(widgetRecord.triggers.time_delay));$("#chaty-widget-"+widgetRecord.id).attr("data-time",parseInt(widgetRecord.triggers.time_delay));} if((isTrue(widgetRecord.triggers.has_display_after_page_scroll)&&parseInt(widgetRecord.triggers.display_after_page_scroll)==0)){updateWidgetViews(widgetRecord.id);$("#chaty-widget-"+widgetRecord.id).addClass("active");}else if((isTrue(widgetRecord.triggers.has_display_after_page_scroll)&&parseInt(widgetRecord.triggers.display_after_page_scroll)>0)){chatyHasPageScroll=true;$("#chaty-widget-"+widgetRecord.id).addClass("on-chaty-scroll");$("#chaty-widget-"+widgetRecord.id).addClass("page-scroll-"+parseInt(widgetRecord.triggers.display_after_page_scroll));$("#chaty-widget-"+widgetRecord.id).attr("data-scroll",parseInt(widgetRecord.triggers.display_after_page_scroll));} if(isTrue(widgetRecord.triggers.exit_intent)){chatyHasExitIntent=true;$("#chaty-widget-"+widgetRecord.id).addClass("on-chaty-exit-intent");}}else{updateWidgetViews(widgetRecord.id);$("#chaty-widget-"+widgetRecord.id).addClass("active");}}else{updateWidgetViews(widgetRecord.id);$("#chaty-widget-"+widgetRecord.id).addClass("active");} if(!isEmpty(widgetRecord.settings.font_family)&&widgetRecord.settings.font_family!="none"){var fontFamily=widgetRecord.settings.font_family;if($.inArray(fontFamily,defaultFontFamily)!=-1){if(fontFamily=="System Stack"){fontFamily="-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif";}}else{$('head').append('');$('head').append('');} customCSS+="#chaty-widget-"+widgetRecord.id+", #chaty-widget-"+widgetRecord.id+" .chaty-tooltip:after {font-family: "+fontFamily+"}";}} if(chatyHasExitIntent){bindExitIntentFunction();} if(customCSS!=""){if(!$("#custom-chaty-css").length){$("head").append("");} $("#custom-chaty-css").append(customCSS);} if(advanceCustomCSS!=""){if(!$("#custom-advance-chaty-css").length){$("head").append("");} $("#custom-advance-chaty-css").append(advanceCustomCSS);} if(key==(widgetData.length-1)){} if($(".chaty-sms-channel").length){$(".chaty-sms-channel").each(function(){var thisLink=$(this).attr("href");thisLink=thisLink.replace(/{title}/g,getPageTitle());thisLink=thisLink.replace(/{url}/g,window.location.href);$(this).attr("href",thisLink);});} $(document).on("click","#chaty-widget-"+widgetRecord.id+" .chaty-i-trigger .chaty-channel",function(){if($(this).closest(".chaty-widget").hasClass("has-single")){if($(this).closest(".chaty").hasClass("form-open")){if(isTrue(widgetRecord.settings.bg_blur_effect)){$("body").addClass("add-bg-blur-effect");}else{$("body").removeClass("add-bg-blur-effect");}}}else{if($(this).closest(".chaty-widget").hasClass("chaty-open")){$("body").removeClass("add-bg-blur-effect");}else{if(!$(this).closest(".chaty-widget").hasClass("chaty-no-close-button")){if(isTrue(widgetRecord.settings.bg_blur_effect)){$("body").addClass("add-bg-blur-effect");}}}}});});if(!$("#custom-advance-chaty-css").length){$("head").append("");} $("#custom-advance-chaty-css").append(customExtraCSS);if(($(".v3_site_key").length&&!isEmpty($(".v3_site_key").val()))||($(".v2_site_key").length&&!isEmpty($(".v2_site_key").val()))){LoadChatyGoogleRecaptcha();}} removeEmptyTooltip();checkForChatyTriggers();} function getPageTitle(){return $("title").length?$("title").text():"";} function makeChatyChatView(widgetRecord){var widgetId=widgetRecord.id;var widgetIndex=getWidgetIndex(widgetId);if(widgetIndex==null){widgetIndex=-1;} var bodyMsg=widgetRecord.settings.cta_body;var headMsg=widgetRecord.settings.cta_head;var pageTitle=$("title").text();if(!isEmpty(pageTitle)){bodyMsg=bodyMsg.replace(/{title}/g,pageTitle);headMsg=headMsg.replace(/{title}/g,pageTitle);}else{bodyMsg=bodyMsg.replace(/{title}/g,'');headMsg=headMsg.replace(/{title}/g,'');} bodyMsg=bodyMsg.replace(/{url}/g,""+window.location.href+"");headMsg=headMsg.replace(/{url}/g,""+window.location.href+"");var formHtml="";formHtml+="";$("#chaty-widget-"+widgetId).append(formHtml);} function htmlDecode(input){var doc=new DOMParser().parseFromString(input,"text/html");return doc.documentElement.textContent;} function checkForChannel(channel){if(isTrue(channel.is_agent)){if(channel.agent_data.length){if(((!isChatyInMobile&&isTrue(channel.is_agent_desktop))||(isChatyInMobile&&isTrue(channel.is_agent_mobile)))){return true;}}}else{if(((!isChatyInMobile&&isTrue(channel.is_desktop))||(isChatyInMobile&&isTrue(channel.is_mobile)))&&(channel.value!=''||(channel.channel=="Contact_Us"||channel.channel=="Chatway"))){return true;}} return false;} function updateWidgetViews(widgetId){if($("#chaty-widget-"+widgetId+" .chaty-channel.chaty-default-open").length){var dataForm=$("#chaty-widget-"+widgetId+" .chaty-channel.chaty-default-open a.chaty-whatsapp-btn-form").data('form');if(!isEmpty(dataForm)){var clickStatus=checkChatyCookieExpired(widgetId,"c-"+$("#chaty-widget-"+widgetId+" .chaty-channel.chaty-default-open").data('channel'));if(clickStatus){$("#"+dataForm).addClass("is-active");if($("#"+dataForm).length){var buttonHtml=$("#chaty-widget-"+widgetId+" .chaty-channel.chaty-default-open a.chaty-whatsapp-btn-form").html()+""+chaty_settings.lang.hide_whatsapp_form+"";removeChatyAnimation(widgetId);$("#chaty-widget-"+widgetId).find(".ch-pending-msg").remove();$("#chaty-widget-"+widgetId+" .chaty-widget").removeClass("chaty-open");$("#chaty-widget-"+widgetId).addClass("form-open");$("#"+dataForm).addClass("active");if($("#chaty-widget-"+widgetId+" .chaty-widget:not(.chaty-no-close-button)").hasClass("has-bg-blur-effect")){$("body").addClass("add-bg-blur-effect");} setTimeout(function(){$(".chaty-whatsapp-btn-form.active .chaty-whatsapp-input").focus();},100);$("#chaty-widget-"+widgetId+" .open-chaty-channel").html(buttonHtml);$("#chaty-widget-"+widgetId).addClass("active");$("#chaty-widget-"+widgetId).addClass("active");if($("#chaty-widget-"+widgetId).hasClass("auto-hide-chaty")){var hideAfter=parseInt($("#chaty-widget-"+widgetId).data("time"));if(hideAfter>0){hideAfter=hideAfter+chatyHideIntervalTime;$("#chaty-widget-"+widgetId).addClass("hide-after-"+hideAfter);}} if(chaty_settings.data_analytics_settings=="on"){var widgetChannels=[];var widgetChannel=$("#chaty-widget-"+widgetId+" .chaty-channel.chaty-default-open").data('channel');var viewChannelStatus=checkChatyCookieExpired(widgetId,"v-"+widgetChannel);if(viewChannelStatus&&typeof widgetChannel!='undefined'){saveChatyCookieString(widgetId,"v-"+widgetChannel);widgetChannels.push(widgetChannel);} if(!isBoatUser&&widgetChannels.length){var widgetNonce=$("#chaty-widget-"+widgetId).data("nonce");$.ajax({url:chaty_settings.ajax_url,data:{widgetId:widgetId,channels:widgetChannels,userId:widgetId,isMobile:isChatyInMobile,widgetNonce:widgetNonce,action:'update_chaty_channel_views',},type:'post',dataType:'json',success:function(response){},error:function(XMLHttpRequest,textStatus,errorThrown){monitorErrorLog(XMLHttpRequest,textStatus,errorThrown);}});}} return;}}}} $("#chaty-widget-"+widgetId).addClass("active");if($("#chaty-widget-"+widgetId).hasClass("auto-hide-chaty")){var hideAfter=parseInt($("#chaty-widget-"+widgetId).data("time"));if(hideAfter>0){hideAfter=hideAfter+chatyHideIntervalTime;$("#chaty-widget-"+widgetId).addClass("hide-after-"+hideAfter);}} var blur_effrct=chatyGetCookie("hide-bg-blur-effect");if(blur_effrct){$("body").removeClass("add-bg-blur-effect");} var viewStatus=checkChatyCookieExpired(widgetId,"v-widget");if(viewStatus){saveChatyCookieString(widgetId,'v-widget');var userId=$("#chaty-widget-"+widgetId).data("user");var widgetChannels=[];var isSingle=0;var isDefaultOpen=0;var widgetChannel;var widgetKey=$("#chaty-widget-"+widgetId).data("key");if(typeof widgetData[widgetKey]!=undefined){var activeWidgets=chatyGetCookie("activechatyWidgets");if(activeWidgets!=null){activeWidgets=activeWidgets.split(",");if($.inArray(widgetId,activeWidgets)==-1){activeWidgets.push(widgetId);activeWidgets=activeWidgets.join(",");chatySetCookie("activechatyWidgets",activeWidgets,1);}}else{activeWidgets=widgetId;chatySetCookie("activechatyWidgets",activeWidgets,1);}} if($("#chaty-widget-"+widgetId+" .chaty-widget").hasClass("has-single")){isSingle=1;widgetChannel=$("#chaty-widget-"+widgetId+" .chaty-channel").data("channel");var viewChannelStatus=checkChatyCookieExpired(widgetId,"v-"+widgetChannel);if(viewChannelStatus&&typeof widgetChannel!='undefined'){saveChatyCookieString(widgetId,"v-"+widgetChannel);widgetChannels.push(widgetChannel);}}else if($("#chaty-widget-"+widgetId+" .chaty-widget").hasClass("chaty-open")){isDefaultOpen=1;if($("#chaty-widget-"+widgetId).hasClass("chaty-has-chat-view")){$(".chaty-chat-view.chaty-chat-view-"+widgetId+" .chaty-view-channels").find(".chaty-channel").each(function(){chatyChannel=$(this).data("channel");clickStatus=checkChatyCookieExpired(widgetId,"v-"+chatyChannel);if(clickStatus&&typeof chatyChannel!='undefined'){saveChatyCookieString(widgetId,"v-"+chatyChannel);widgetChannels.push(chatyChannel);}});}else{$("#chaty-widget-"+widgetId+" .chaty-channel-list .chaty-channel").each(function(){widgetChannel=$(this).data("channel");var viewChannelStatus=checkChatyCookieExpired(widgetId,"v-"+widgetChannel);if(viewChannelStatus&&typeof widgetChannel!='undefined'){saveChatyCookieString(widgetId,"v-"+widgetChannel);widgetChannels.push(widgetChannel);}});}} if(viewStatus&&!isBoatUser){var widgetNonce=$("#chaty-widget-"+widgetId).data("nonce");if(!isBoatUser){$.ajax({url:chaty_settings.ajax_url,data:{widgetId:widgetId,channels:widgetChannels,userId:widgetId,isMobile:isChatyInMobile,isOpen:isDefaultOpen,isSingle:isSingle,widgetNonce:widgetNonce,action:'update_chaty_widget_views',},type:'post',dataType:'json',success:function(response){},error:function(XMLHttpRequest,textStatus,errorThrown){monitorErrorLog(XMLHttpRequest,textStatus,errorThrown);}});}}}} function updateVisitorCount(widgetId){var userId=$("#chaty-widget-"+widgetId).data("user");var isOldUser=chatySaasCheckCookie("triggeredFor"+userId);if(!isOldUser){chatySetCookie("triggeredFor"+userId,widgetId,2);}} function getWidgetSize(widgetSize,customSize){return widgetSize;} function getSvgIcon(iconName,widgetColor,iconColor,widgetId){switch(iconName){case"chat-smile":return'';case"chat-bubble":return'';case"chat-db":return'';default:return''}} function getChannelSetting(channel,widgetId,toolTipPosition){var extraClass="";if(isTrue(channel.is_agent)){if(channel.agent_data.length){var activeAgents=0;var activeAgent=[];$.each(channel.agent_data,function(key,agent){if(agent.value!=""){activeAgents++;activeAgent=agent;}});if(activeAgents>0){var channelIcon,channelLink;var widgetIndex=getWidgetIndex(widgetId);if(widgetIndex==null){widgetIndex=-1;} createAgentList(channel,widgetId);channelIcon=getChannelIcon(channel,widgetId);channelLink=getChannelURL(channel,channelIcon,toolTipPosition,widgetId);if((channel.channel_type!="Instagram"&&channel.channel_type!="Instagram_DM")||(channel.icon_color!="#ffffff"&&channel.icon_color!="#fff")){customExtraCSS+=".chaty-agent-"+widgetId+"-"+channel.channel+" .color-element {fill: "+channel.icon_color+"; color: "+channel.icon_color+";}";} customExtraCSS+=".chaty-agent-"+widgetId+"-"+channel.channel+" .chaty-custom-icon { background-color: "+channel.icon_color+";}";customExtraCSS+=".chaty-agent-"+widgetId+"-"+channel.channel+" .chaty-svg-img { background-color: "+channel.icon_color+";}";return"
"+channelLink+"
";}}}else{if(isValueEmpty(channel.channel_type)){channel.channel_type=channel.channel;} var channelIcon=getChannelIcon(channel,widgetId);var channelLink=getChannelURL(channel,channelIcon,toolTipPosition,widgetId);if(channel.channel_type=="Contact_Us"){extraClass+=" has-chaty-box chaty-contact-form";}else if(channel.channel_type=="Whatsapp"){if(isTrue(channel.is_default_open)){var clickStatus=checkChatyCookieExpired(widgetId,"c-"+channel.channel_type);if(clickStatus){extraClass+=" chaty-default-open"}}} return"
"+channelLink+"
";}} function createAgentList(channel,widgetId){var formHtml="";var widgetIndex=getWidgetIndex(widgetId);if(widgetIndex==null){widgetIndex=-1;} formHtml+="";customExtraCSS+=".chaty-agent-header.agent-info-"+widgetId+"-"+channel.channel+" { background-color: "+channel.header_bg_color+"; color: "+channel.header_text_color+" } ";customExtraCSS+=".agent-info-"+widgetId+"-"+channel.channel+" .chaty-close-agent-list svg { fill: "+channel.header_text_color+" } ";$("body").append(formHtml);} function getAgentChannelURL(channel,agent,widgetId,channelIcon,toolTipPosition){var agentURL=agent.value;var agentTarget="_blank";if(channel.channel_type=="Whatsapp"){var whatsAppNumber=getWhatsAppNumber(agent.value);if(isChatyInMobile){agentTarget="";agentURL="https://wa.me/"+whatsAppNumber;}else{agentTarget="_blank";agentURL="https://web.whatsapp.com/send?phone="+whatsAppNumber;}}else if(channel.channel_type=="WeChat"){agentTarget="";agentURL="javascript:;";}else if(channel.channel_type=="Email"){agentTarget="";agentURL="mailto:"+agent.value;}else if(channel.channel_type=="Facebook_Messenger"){if(isChatyInMobile){agentTarget="";}else{agentTarget="_blank";}}else if(channel.channel_type=="SMS"){agentTarget="";agentURL="sms:"+agent.value;}else if(channel.channel_type=="Telegram"){agentURL=trimChar(agent.value,"@");agentURL="https://telegram.me/"+agentURL;agentTarget="_blank";}else if(channel.channel_type=="Twitter"){agentURL="https://twitter.com/"+$.trim(agent.value);}else if(channel.channel_type=="Phone"){agentTarget="";agentURL="tel:"+$.trim(agent.value);}else if(channel.channel_type=="Skype"){agentTarget="";agentURL="skype:"+$.trim(agent.value)+"?chat";}else if(channel.channel_type=="Snapchat"){agentURL="https://www.snapchat.com/add/"+$.trim(agent.value);}else if(channel.channel_type=="Vkontakte"){agentURL="https://vk.me/"+$.trim(agent.value);}else if(channel.channel_type=="Linkedin"){if(agent.link_type=="personal"){agentURL="https://www.linkedin.com/in/"+$.trim(agent.value);}else{agentURL="https://www.linkedin.com/company/"+$.trim(agent.value);}}else if(channel.channel_type=="Viber"){if(agent.viber_url!=""){agentURL="viber://pa?chatURI="+agent.value;}else{agentURL=trimChar(agent.value,"+");if(!isNaN(agentURL)){agentURL=agentURL.replace("+","");if(navigator.userAgent.match(/(iPod|iPhone|iPad)/)){agentURL="+"+agentURL;} agentURL="viber://chat?number="+agentURL;}} agentTarget="";}else if(channel.channel_type=="TikTok"){agentURL=trimChar($.trim(agent.value),"@");agentURL="https://www.tiktok.com/@"+agentURL;agentTarget="";} return""+channelIcon+"";} function getAgentURL(agent,channel,widgetId,key,agentIcon,agentTitle){var agentURL=agent.value;var agentTarget="_blank";if(channel.channel_type=="Whatsapp"){var whatsAppNumber=getWhatsAppNumber(agent.value);var preSetMessage="";if(!isEmpty(agent.pre_set_message)){preSetMessage=decodeURI(agent.pre_set_message);var pageTitle=$("title").text();if(!isEmpty(pageTitle)){preSetMessage=preSetMessage.replace(/{title}/g,pageTitle);}else{preSetMessage=preSetMessage.replace(/{title}/g,'');} preSetMessage=preSetMessage.replace(/{url}/g,window.location);preSetMessage=encodeURIComponent(preSetMessage);} if(isChatyInMobile){agentTarget="";agentURL="https://wa.me/"+whatsAppNumber+"?text="+preSetMessage;}else{agentTarget="_blank";if(isTrue(agent.use_whatsapp_web)){agentURL="https://web.whatsapp.com/send?phone="+whatsAppNumber+"&text="+preSetMessage;}else{agentURL="https://wa.me/"+whatsAppNumber+"?text="+preSetMessage;}}}else if(channel.channel_type=="WeChat"){agentTarget="";agentURL="javascript:;";}else if(channel.channel_type=="Email"){agentTarget="";agentURL="mailto:"+agent.value;}else if(channel.channel_type=="Facebook_Messenger"){if(isChatyInMobile){agentTarget="";}else{agentTarget="_blank";}}else if(channel.channel_type=="SMS"){agentTarget="";agentURL="sms:"+agent.value;}else if(channel.channel_type=="Telegram"){agentURL=trimChar(agent.value,"@");agentURL="https://telegram.me/"+agentURL;agentTarget="_blank";}else if(channel.channel_type=="Twitter"){agentURL="https://twitter.com/"+$.trim(agent.value);}else if(channel.channel_type=="Instagram"){agentURL="https://www.instagram.com/"+trimChar(agent.value,"@");}else if(channel.channel_type=="Instagram_DM"){agentURL="https://ig.me/m/"+trimChar(agent.value,"@");}else if(channel.channel_type=="Phone"){agentTarget="";agentURL="tel:"+$.trim(agent.value);}else if(channel.channel_type=="Skype"){agentTarget="";agentURL="skype:"+$.trim(agent.value)+"?chat";}else if(channel.channel_type=="Snapchat"){agentURL="https://www.snapchat.com/add/"+$.trim(agent.value);}else if(channel.channel_type=="Vkontakte"){agentURL="https://vk.me/"+$.trim(agent.value);}else if(channel.channel_type=="Linkedin"){if(agent.link_type=="personal"){agentURL="https://www.linkedin.com/in/"+$.trim(agent.value);}else{agentURL="https://www.linkedin.com/company/"+$.trim(agent.value);}}else if(channel.channel_type=="Viber"){if(agent.viber_url!=""){agentURL="viber://pa?chatURI="+agent.value;}else{agentURL=trimChar(agent.value,"+");if(!isNaN(agentURL)){agentURL=agentURL.replace("+","");if(navigator.userAgent.match(/(iPod|iPhone|iPad)/)){agentURL="+"+agentURL;} agentURL="viber://chat?number="+agentURL;}} agentTarget="";}else if(channel.channel_type=="TikTok"){agentURL=trimChar($.trim(agent.value),"@");agentURL="https://www.tiktok.com/@"+agentURL;agentTarget="";} return""+agentIcon+""+agentTitle+"";} function getWhatsAppNumber(phoneNumber){phoneNumber=trimChar(phoneNumber,"+");phoneNumber=phoneNumber.replace(/ /g,"");phoneNumber=phoneNumber.replace(/-/g,"");phoneNumber=phoneNumber.replace(/_/g,"");return phoneNumber;} function trimChar(string,charToRemove){string=$.trim(string);while(string.charAt(0)==charToRemove){string=string.substring(1);} while(string.charAt(string.length-1)==charToRemove){string=string.substring(0,string.length-1);} return string;} function getChannelURL(channel,channelIcon,toolTipPosition,widgetId){var extraClass="";if(isTrue(channel.is_agent)){channel.url="javascript:;";channel.target="";}else{if(channel.channel_type=="Whatsapp"){if(isTrue(channel.has_welcome_message)){channel.url="javascript:;";channel.target="";extraClass+=" has-chaty-box chaty-whatsapp-btn-form";startMakingWhatsAppPopup(channel,widgetId);}else{var preSetMessage="";if(!isEmpty(channel.pre_set_message)){preSetMessage=decodeURI(channel.pre_set_message);var pageTitle=$("title").text();if(!isEmpty(pageTitle)){preSetMessage=preSetMessage.replace(/{title}/g,pageTitle);}else{preSetMessage=preSetMessage.replace(/{title}/g,'');} preSetMessage=preSetMessage.replace(/{url}/g,window.location);preSetMessage=encodeURIComponent(preSetMessage);} if(isChatyInMobile){channel.target="";channel.url="https://wa.me/"+channel.value+"?text="+preSetMessage;}else{channel.target="_blank";if(isTrue(channel.is_use_web_version)){channel.url="https://web.whatsapp.com/send?phone="+channel.value+"&text="+preSetMessage;}else{channel.url="https://wa.me/"+channel.value+"?text="+preSetMessage;}}}}else if(channel.channel_type=="WeChat"){if(!isEmpty(channel.qr_code_image_url)){startMakingWeChatChannel(channel,widgetId);channel.url="javascript:;";channel.target="";extraClass+=" has-chaty-box chaty-qr-code-form";}}else if(channel.channel_type=="Contact_Us"){startMakingContactForm(channel,widgetId);channel.url="javascript:;";channel.target="";extraClass+=" has-chaty-box chaty-contact-us-form";}else if(channel.channel_type=="Email"){if(!isEmpty(channel.mail_subject)){var mailSubject=decodeURI(channel.mail_subject);var pageTitle=$("title").text();if(!isEmpty(pageTitle)){mailSubject=mailSubject.replace(/{title}/g,pageTitle);}else{mailSubject=mailSubject.replace(/{title}/g,'');} mailSubject=mailSubject.replace(/{url}/g,window.location);mailSubject=encodeURIComponent(mailSubject);channel.url+="?subject="+mailSubject;}}else if(channel.channel_type=="Viber"){if(channel.viber_url!=""){channel.url="viber://pa?chatURI="+channel.value;}else{channel.value=trimChar(channel.value,"+");if(isChatyInMobile&&!isNaN(channel.value)){if(navigator.userAgent.match(/(iPod|iPhone|iPad)/)){channel.value="+"+channel.value;}} channel.url="viber://chat?number="+channel.value;} channel.target="";}else if(channel.channel_type=="Vkontakte"){channel.url="https://vk.me/"+$.trim(channel.value);}else if(channel.channel_type=="Waze"){channel.url=decodeURI($.trim(channel.value));}} if(channel.channel=="Link"||channel.channel=="Custom_Link"||channel.channel=="Custom_Link_3"||channel.channel=="Custom_Link_4"||channel.channel=="Custom_Link_5"){if(!isEmpty(channel.hover_text)){ariaLabel=channel.hover_text;}else{ariaLabel=channel.channel}}else{ariaLabel=channel.channel;} var onClickFn="";if(!isEmpty(channel.click_event)){onClickFn='onclick="'+channel.click_event+'"';channel.target="";channel.url="javascript:;";} return""+channelIcon+"";} function startMakingContactForm(channel,widgetId){var formHtml="";var widgetIndex=getWidgetIndex(widgetId);if(widgetIndex==null){widgetIndex=-1;} formHtml+="";$("body").append(formHtml);} function startMakingWhatsAppPopup(channel,widgetId){const currentDate=new Date();var currentMinute=(currentDate.getMinutes()<10)?"0"+currentDate.getMinutes():currentDate.getMinutes();var currentHour=(currentDate.getHours()<10)?"0"+currentDate.getHours():currentDate.getHours();const time=currentHour+":"+currentMinute;var formHtml="";var widgetIndex=getWidgetIndex(widgetId);if(widgetIndex==null){widgetIndex=-1;} var formAction="https://web.whatsapp.com/send";var formTarget="";if(!isChatyInMobile){if(isTrue(channel.is_use_web_version)){formAction="https://web.whatsapp.com/send";}else{formAction="https://wa.me/"+channel.value;} formTarget="_blank";}else{formAction="https://wa.me/"+channel.value;} formHtml+="