function check_for_number_chaty(t,e){return!!(""!=t&&("+"==t[0]&&(t=t.substr(1,t.length)),"Phone"==e&&"*"==t[0]&&(t=t.substr(1,t.length)),isNaN(t)))}function check_for_preview_pos(){if(jQuery(".chaty-setting-form").length){if(jQuery(window).width()>1179){var t=parseInt(jQuery(".chaty-setting-form").offset().top);jQuery(".btn-save-sticky").css("top",t+58),jQuery(".btn-help, .preview-help-btn").css("top",t+58+145),jQuery("a.remove-chaty-widget-sticky").css("top",t+58+145+119)}else jQuery(".btn-save-sticky").attr("style",""),jQuery(".btn-help, .preview-help-btn").attr("style",""),jQuery("a.remove-chaty-widget-sticky").attr("style","")}}jQuery(function(t){"use strict";var e,a=!1,c=!1,i=!1,o=!1,n=!1,s=!1,l=!1;function r(){if(t(".chaty-popup").hide(),0==t("#cht-form .js-chanel-desktop").length||0==t("#cht-form .js-chanel-mobile").length)return t("#no-device-popup").show(),!1;if(0==t("#cht-form .js-chanel-desktop:checked").length&&0==t("#cht-form .js-chanel-mobile:checked").length)return t("#device-popup").show(),!1;var e=0;return(t("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").each(function(){""==jQuery.trim(t(this).val())&&e++}),e!=t("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").length||t("#chaty-social-Contact_Us").length)?h():(t("#no-device-value").show(),!1)}function h(){return(t(".chaty-popup").hide(),t("#trigger_on_time").is(":checked")||t("#chaty_trigger_on_exit").is(":checked")||t("#chaty_trigger_on_scroll").is(":checked"))?d():(t("#trigger-popup").show(),!1)}function d(){return(t(".chaty-popup").hide(),t(".cht_active").is(":checked"))?(a=!0,t("#cht-form").trigger("submit"),!0):(t("#status-popup").show(),!1)}function p(){if(c){if(i){if(o){if(n){if(s)!l&&(l=!0,t("#channels-selected-list .phone-number").length&&t("#channels-selected-list .phone-number").each(function(){if(""!=jQuery.trim(t(this).val())&&jQuery.trim(t(this).val()).length>13)return t("#custom-message-popup .chaty-popup-header").text(t(this).data("label")+" number is not valid"),t("#custom-message-popup .chaty-popup-body").text("Seems like the "+t(this).data("label")+" number you're trying to enter isn't valid. Would you like to publish it anyway?"),t("#custom-message-popup").show(),!1}));else if(s=!0,t("#cht-form #Viber").length&&""!=t("#cht-form #Viber").val()){var a=jQuery.trim(t("#cht-form #Viber").val());if(e=check_for_number_chaty(a,"Viber"))return t("#custom-message-popup .chaty-popup-header").text("Viber number is not valid"),t("#custom-message-popup .chaty-popup-body").text("Seems like the Viber number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),t("#custom-message-popup").show(),!1}}else if(n=!0,t("#cht-form #SMS").length&&""!=t("#cht-form #SMS").val()){var a=jQuery.trim(t("#cht-form #SMS").val());if(e=check_for_number_chaty(a,"SMS"))return t("#custom-message-popup .chaty-popup-header").text("SMS number is not valid"),t("#custom-message-popup .chaty-popup-body").text("Seems like the SMS number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),t("#custom-message-popup").show(),!1}}else if(o=!0,t("#cht-form #Facebook_Messenger").length&&""!=t("#cht-form #Facebook_Messenger").val()){var a=jQuery.trim(t("#Facebook_Messenger").val());if(t("#cht-form #Facebook_Messenger").val(a),!/(?:http:\/\/)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(a)&&!/(?:http:\/\/)?m\.me\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(a))return t("#custom-message-popup .chaty-popup-header").text("Facebook page's URL is not valid"),t("#custom-message-popup .chaty-popup-body").text("Please make sure your Facebook page's URL looks like, https://m.me/YOURPAGE"),t("#custom-message-popup").show(),!1}}else if(i=!0,t("#cht-form #Phone").length&&""!=t("#cht-form #Phone").val()){var a=jQuery.trim(t("#cht-form #Phone").val());if(e=check_for_number_chaty(a,"Phone"))return t("#custom-message-popup .chaty-popup-header").text("Phone number is not valid"),t("#custom-message-popup .chaty-popup-body").text("Seems like the phone number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),t("#custom-message-popup").show(),!1}}else if(c=!0,t("#cht-form #Whatsapp").length&&""!=t("#cht-form #Whatsapp").val()){var a=jQuery.trim(t("#cht-form #Whatsapp").val());if(e=check_for_number_chaty(a,"Whatsapp"))return t("#custom-message-popup .chaty-popup-header").text("Whatsapp number is not valid"),t("#custom-message-popup .chaty-popup-body").text("Seems like the WhatsApp number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),t("#custom-message-popup").show(),!1}return r()}t(window).on("load",function(){setTimeout(()=>{t(".wp-editor-container iframe").contents().find("body").css({backgroundColor:"#fff",margin:0,padding:"0px 10px"})},500)}),t(document).ready(function(){t(document).on("change","input[name='cta_type']:checked",function(){"simple-view"==t(this).val()?(t("#simple-view").removeClass("hide-it"),t("#chat-view").addClass("hide-it"),t(".chaty-chat-view-option").removeClass("hide-option"),t("#cta-header-color-setting").addClass("hide-it")):(t("#simple-view").addClass("hide-it"),t("#chat-view").removeClass("hide-it"),t(".chaty-chat-view-option").addClass("hide-option"),t("#cta-header-color-setting").removeClass("hide-it")),change_custom_preview()}),t(document).on("click",".add-properties",function(e){e.preventDefault(),t(this).closest(".properties-box").toggleClass("active")}),t(document).on("click",".properties-list a",function(e){e.preventDefault();var a=t.trim(t(this).data("txt"));if(t(this).closest(".form-horizontal__item").hasClass("has-iframe")){var c=t(this).closest(".form-horizontal__item").find("iframe");c.contents().find("p").length?c.contents().find("p:last-child").append(" "+a):c.contents().find(".mce-content-body").append(" "+a)}else a=t.trim(t.trim(t(this).closest(".form-horizontal__item").find(".add-properties").val())+" "+a),t(this).closest(".form-horizontal__item").find(".add-properties").val(a);change_custom_preview()}),t(document).on("click","#cta_woocommerce_status",function(){t(this).is(":checked")?t(".woocommerce-settings").addClass("active"):t(".woocommerce-settings").removeClass("active")}),t(".form-fonts").SumoSelect({placeholder:"Select font family",csvDispCount:3}),t(".url-options, .url-select, .country-list").SumoSelect(),t("#chaty_attention_effect, #chaty_default_state").SumoSelect({placeholder:"Select font family",csvDispCount:3}),t(document).on("click","#chaty-social-channel",function(){t("#current_step").val(0)}),t(document).on("click","#chaty-app-customize-widget",function(){t("#current_step").val(1)}),t(document).on("click","#chaty-triger-targeting",function(){t("#current_step").val(2)}),jQuery(document).on("click","#update-chaty-traffic-source-rule",function(t){jQuery(".traffic-options-box").addClass("active"),jQuery("#chaty_traffic_source").val("yes")}),jQuery(document).on("click","#remove-traffic-rules",function(t){jQuery(".traffic-options-box").removeClass("active"),jQuery("#chaty_traffic_source").val("no")}),jQuery(document).on("click",".remove-traffic-option",function(t){jQuery(this).closest(".custom-traffic-rule").remove()}),t(document).on("click",".chaty-switch-toggle",function(){setTimeout(function(){t(".chaty-field-setting").each(function(){t(this).is(":checked")?t(this).closest(".field-setting-col").find(".field-settings").addClass("active"):t(this).closest(".field-setting-col").find(".field-settings").removeClass("active")})},100)}),t(document).on("change",".chaty-close_form_after-setting",function(){setTimeout(function(){t(".chaty-close_form_after-setting").each(function(){t(this).is(":checked")?t(this).closest(".form-field-setting-col").find(".close_form_after-settings").addClass("active"):t(this).closest(".form-field-setting-col").find(".close_form_after-settings").removeClass("active")})},100)}),t(document).on("click",".agent-button-action, .add-agent-btn",function(t){t.preventDefault(),jQuery("#agent-popup").show()}),t("#channel_input_Whatsapp").length&&(cht_settings.channel_settings.Whatsapp=document.querySelector("#channel_input_Whatsapp"),window.intlTelInput(cht_settings.channel_settings.Whatsapp,{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})),t(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").length&&t(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").each(function(){var e=t(this).closest("li.chaty-channel").data("id");void 0!=e&&t("#channel_input_"+e).length&&(cht_settings.channel_settings[e]=document.querySelector("#channel_input_"+e),window.intlTelInput(cht_settings.channel_settings[e],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"}))}),t(document).on("change",".chaty-redirect-setting",function(){setTimeout(function(){t(".chaty-redirect-setting").each(function(){t(this).is(":checked")?t(this).closest(".form-field-setting-col").find(".redirect_action-settings").addClass("active"):t(this).closest(".form-field-setting-col").find(".redirect_action-settings").removeClass("active")})},100)}),t(document).on("click",".email-setting",function(){setTimeout(function(){t(".email-setting-field").each(function(){t(this).is(":checked")?t(this).closest(".form-field-setting-col").find(".email-settings").addClass("active"):t(this).closest(".form-field-setting-col").find(".email-settings").removeClass("active")})},100)});let e=[];jQuery(".channels-icons > .icon.active").each((t,a)=>{e.push(a.dataset.social)}),wp.hooks.doAction("chaty.channel_update",{channel:e,target:null,action:"added",isExceeded:!1}),setTimeout(()=>{t(".whatsapp-welcome-message iframe").contents().find("body").css({backgroundColor:"#fff"})},100),t(document).on("click",".chaty-embedded-window",function(){setTimeout(function(){t(".embedded_window-checkbox").each(function(){if(t(this).is(":checked")){t(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").addClass("active");let e=t(this).closest("li.chaty-channel").find(".whatsapp-welcome-message iframe");e.contents().find("body").css({backgroundColor:"#fff"})}else t(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").removeClass("active")})},300)}),jQuery("input[name='switchPreview']:checked").trigger("change"),t(document).on("change","#cht-form input",function(){c=!1,i=!1,o=!1,n=!1,s=!1,l=!1}),t(document).on("click",".remove-js-script",function(e){e.preventDefault(),t(this).closest(".channels__input-box").find("input").val(""),t(this).closest(".channels__input-box").find("input").removeClass("cht-input-error").removeClass("cht-js-error"),t(this).closest(".channels__input-box").find(".cht-error-message").remove(),t(this).remove()}),t("#cht-form").on("submit",function(){if(a)return!0;t(this).find(".cht-input-error").removeClass("cht-input-error"),t(this).find(".cht-js-error").removeClass("cht-input-error"),t(this).find(".cht-error-message").remove(),t(this).find(".remove-js-script").remove(),set_social_channel_order();var e=0;return(t("#chaty-page-options .cht-required").length&&t("#chaty-page-options .cht-required").each(function(){""==jQuery.trim(t(this).val())&&(t(this).addClass("cht-input-error"),e++)}),t(".chaty-data-and-time-rules .cht-required").length&&t(".chaty-data-and-time-rules .cht-required").each(function(){""==jQuery.trim(t(this).val())&&(t(this).addClass("cht-input-error"),e++)}),cht_nonce_ajax.has_js_access||t("#channels-selected-list .channels__input").each(function(){""!=t.trim(t(this).val())&&-1!=t.trim(t(this).val()).toLowerCase().indexOf("javascript")&&(t("body, html").scrollTop(0),t("#chaty-social-channel").trigger("click"),t(this).addClass("cht-input-error cht-js-error"),t(this).after(""+cht_nonce_ajax.js_message+""+cht_nonce_ajax.remove+""),e++)}),0==e)?p():(t(".cht-input-error:first").focus(),!1)}),t(".chaty-popup-inner").on("click",function(t){t.stopPropagation()}),t(".chaty-popup-outer").on("click",function(e){t(".chaty-popup").hide()}),t(".check-for-numbers").on("click",function(){p()}),t(".check-for-device").on("click",function(){r()}),t(".check-for-triggers").on("click",function(){h()}),t(".check-for-status").on("click",function(){d()}),t(".change-status-and-save").on("click",function(){t(".cht_active").prop("checked",!0),a=!0,t(".chaty-popup").hide(),t("#cht-form").trigger("submit")}),t(".status-and-save").on("click",function(){t(".cht_active").prop("checked",!1),a=!0,t(".chaty-popup").hide(),t("#cht-form").trigger("submit")}),jQuery(document).on("click","#create-date-rule",function(t){jQuery("#date-schedule").addClass("active"),jQuery("#cht_date_rules").val("yes")}),jQuery(document).on("click","#remove-date-rule",function(t){jQuery("#date-schedule").removeClass("active"),jQuery("#cht_date_rules").val("no")})})}),function(t){jQuery(window).on("popstate",function(t){window.onbeforeunload=null,window.history&&window.history.pushState&&window.history.back()}),jQuery(document).ready(function(){jQuery(".chaty-table").length||jQuery("body input, body .icon, body textarea, body .btn-cancel:not(.close-btn-set) ").on("click",function(t){window.onbeforeunload=function(t){(t=t||window.event).preventDefault=!0,t.cancelBubble=!0,t.returnValue="Your beautiful goodbye message"}}),jQuery(document).on("submit","form",function(t){window.onbeforeunload=null}),jQuery(document).on("change",".channel-select-input",function(e){var a=t(this).closest("li").attr("data-id");jQuery.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{social:jQuery(this).val(),channel:a,action:"get_chaty_settings"},success:function(e){1==e.status&&("Whatsapp"==e.data.slug?t("#channel_input_"+e.channel).length&&(cht_settings.channel_settings[e.channel]=document.querySelector("#channel_input_"+e.channel),window.intlTelInput(cht_settings.channel_settings[e.channel],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})):t("#chaty-social-"+e.channel+" .channels__input-box").html(""),jQuery(".custom-icon-"+e.channel+" svg").html(e.data.svg),jQuery("#chaty-social-"+e.channel).attr("data-channel",e.data.slug),jQuery("#chaty-social-"+e.channel).find(".sp-preview-inner").css("background-color",e.data.color),jQuery("#chaty-social-"+e.channel).find(".chaty-color-field").val(e.data.color),jQuery("#chaty-social-"+e.channel).find(".channels__input").attr("placeholder",e.data.placeholder),jQuery("#chaty-social-"+e.channel).find(".channel-example").text(e.data.example),jQuery("#chaty-social-"+e.channel).find(".chaty-title").val(e.data.title),jQuery("#chaty-social-"+e.channel).find(".icon").attr("data-title",e.data.title),jQuery("#chaty-social-"+e.channel).find(".chaty-color-field").trigger("change"),jQuery(".help-section").html(""),""!=e.data.help_link?jQuery(".help-section").html('