"use strict";function iaGenerateLink(a){jQuery(".uap-ap-generate-links-result").css("visibility","hidden");jQuery(".uap-ap-generate-social-result").css("visibility","hidden");var c=jQuery("#ia_generate_aff_custom_url").val();if(jQuery("#campaigns_select").length){var b=jQuery("#campaigns_select").val();"..."==b&&(b="")}else b="";var d=0,e=0;jQuery("#ref_type").html()&&1==jQuery("#ref_type").val()&&(d=1);jQuery("#friendly_links").html()&&1==jQuery("#friendly_links").val()&&(e=1);jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ia_ajax_return_url_for_aff",aff_id:a,url:c,campaign:b,slug:d,friendly_links:e},success:function(f){if(f){var g=JSON.parse(f);f=g.url;var l=g.social;g=g.qr_code;0!=f&&(jQuery(".uap-ap-generate-links-result").html(f),jQuery(".uap-ap-generate-links-result").css("visibility","visible"));l&&(jQuery(".uap-ap-generate-social-result").html(l),jQuery(".uap-ap-generate-social-result").css("visibility","visible"));g&&(jQuery(".uap-ap-generate-qr-code").html(g),jQuery(".uap-ap-generate-qr-code").css("visibility","visible"));uapReloadListAffiliateLinksTable()}}})}
function uapRegisterCheckViaAjax(a){var c="#"+jQuery(".uap-form-create-edit [name="+a+"]").parent().attr("id"),b=jQuery(".uap-form-create-edit [name="+a+"]").val(),d="";"pass2"==a?d=jQuery(".uap-form-create-edit [name=pass1]").val():"confirm_email"==a&&(d=jQuery(".uap-form-create-edit [name=user_email]").val());jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_check_reg_field_ajax",type:a,value:b,second_value:d},success:function(e){jQuery(c+" .uap-register-notice").remove();jQuery(".uap-form-create-edit [name="+a+"]").removeClass("uap-input-notice");1!=e&&(jQuery(c).append('<div class="uap-register-notice">'+e+"</div>"),jQuery(".uap-form-create-edit [name="+a+"]").addClass("uap-input-notice"))}})}function uapAjaxCheckFieldConditionOnblurOnclick(a,c,b,d){a=jQuery(".uap-form-create-edit [name="+a+"]").val();uapAjaxCheckFieldCondition(a,c,b,d)}
function uapAjaxCheckOnClickFieldCondition(a,c,b,d,e){if("checkbox"==d){var f=[];jQuery(".uap-form-create-edit [name='"+a+"[]']:checked").each(function(){f.push(jQuery(this).val())});a=f.join(",")}else a=jQuery(".uap-form-create-edit [name="+a+"]:checked").val();uapAjaxCheckFieldCondition(a,c,b,e)}function uapAjaxCheckCnChangeMultiselectFieldCondition(a,c,b,d){a=jQuery(".uap-form-create-edit [name='"+a+"[]']").val();null!=a&&(a=a.join(","),uapAjaxCheckFieldCondition(a,c,b,d))}
function uapAjaxCheckFieldCondition(a,c,b,d){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_check_logic_condition_value",val:a,field:b},success:function(e){var f=jQuery("#uap_exceptionsfields").val();if(f){f=f.split(",");var g=f.indexOf(b)}else f=[];"1"==e?1==d?(jQuery(c).fadeIn(200),-1!=f.indexOf(b)&&f.splice(g,1)):(jQuery(c).fadeOut(200),-1==f.indexOf(b)&&f.push(b)):1==d?(jQuery(c).fadeOut(200),-1==f.indexOf(b)&&f.push(b)):(jQuery(c).fadeIn(200),-1!=f.indexOf(b)&&f.splice(g,1));f&&(f=f.join(","),jQuery("#uap_exceptionsfields").val(f))}})}function uapGetCheckboxRadioValue(a,c){if("radio"==a){var b=jQuery("[name="+c+"]:checked").val();if("undefined"!=typeof b)return b}else{var d=[];jQuery("[name='"+c+"[]']:checked").each(function(){d.push(this.value)});if(0<d.length)return d.join(",")}return jQuery('[name="'+c+'"]').is(":checked")?1:""}
function uapRegisterCheckViaAjaxRec(a){jQuery(".uap-register-notice").remove();var c=[],b=jQuery("#uap_exceptionsfields").val();if(b)var d=b.split(",");for(b=0;b<a.length;b++)if(!(d&&-1<d.indexOf(a[b]))){jQuery(".uap-form-create-edit [name="+a[b]+"]").removeClass("uap-input-notice");var e=jQuery(".uap-form-create-edit [name="+a[b]+"]").attr("type");"undefined"==typeof e&&(e=jQuery(".uap-form-create-edit [name='"+a[b]+"[]']").attr("type"));"undefined"==typeof e&&(e=jQuery(".uap-form-create-edit [name='"+a[b]+"']").prop("nodeName"));"undefined"==typeof e&&(e=jQuery(".uap-form-create-edit [name='"+a[b]+"[]']").prop("nodeName"),"SELECT"==e&&(e="multiselect"));"checkbox"==e||"radio"==e?e=uapGetCheckboxRadioValue(e,a[b]):"multiselect"==e?(e=jQuery(".uap-form-create-edit [name='"+a[b]+"[]']").val(),"object"==typeof e&&null!=e&&(e=e.join(","))):e=jQuery(".uap-form-create-edit [name="+a[b]+"]").val();var f="";"pass2"==a[b]?f=jQuery(".uap-form-create-edit [name=pass1]").val():"confirm_email"==a[b]?f=jQuery(".uap-form-create-edit [name=user_email]").val():"tos"==a[b]&&(e=jQuery(".uap-form-create-edit [name=tos]").is(":checked")?1:0);c.push({type:a[b],value:e,second_value:f})}jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_check_reg_field_ajax",fields_obj:c},success:function(g){g=JSON.parse(g);for(var l=1,h=0;h<g.length;h++){var k=jQuery(".uap-form-create-edit [name="+g[h].type+"]").attr("type");"undefined"==typeof k&&(k=jQuery(".uap-form-create-edit [name='"+g[h].type+"[]']").attr("type"));"undefined"==typeof k&&(k=jQuery(".uap-form-create-edit [name='"+g[h].type+"']").prop("nodeName"));"undefined"==typeof k&&(k=jQuery(".uap-form-create-edit [name='"+g[h].type+"[]']").prop("nodeName"),"SELECT"==k&&(k="multiselect"));k="radio"==k?jQuery(".uap-form-create-edit [name="+g[h].type+"]").parent().parent().attr("id"):"checkbox"==k&&"tos"!=g[h].type?jQuery(".uap-form-create-edit [name='"+g[h].type+"[]']").parent().parent().attr("id"):"multiselect"==k?jQuery(".uap-form-create-edit [name='"+g[h].type+"[]']").parent().attr("id"):jQuery(".uap-form-create-edit [name="+g[h].type+"]").parent().attr("id");1!=g[h].value&&("undefined"==typeof k?jQuery(".uap-form-create-edit [name="+g[h].type+"]").after('<div class="uap-register-notice">'+g[h].value+"</div>"):(jQuery("#"+k).append('<div class="uap-register-notice">'+g[h].value+"</div>"),jQuery(".uap-form-create-edit [name="+g[h].type+"]").addClass("uap-input-notice")),l=0)}if(1==l)window.must_submit=1,jQuery(".uap-form-create-edit").submit();else return!1}})}
function uapShowSubtabs(a){"block"==jQuery("#uap_public_ap_"+a).css("display")?(jQuery("#uap_fa_sign-"+a).removeClass("fa-account-down-uap"),jQuery("#uap_fa_sign-"+a).addClass("fa-account-right-uap"),jQuery(".uap-public-ap-menu-subtabs").css("display","none")):(jQuery(".uap-ap-menu-sign").removeClass("fa-account-down-uap"),jQuery(".uap-ap-menu-sign").addClass("fa-account-right-uap"),jQuery(".uap-public-ap-menu-subtabs").css("display","none"),jQuery("#uap_public_ap_"+a).css("display","block"),jQuery("#uap_fa_sign-"+a).removeClass("fa-account-right-uap"),jQuery("#uap_fa_sign-"+a).addClass("fa-account-down-uap"))}function uapPaymentType(){jQuery.each(["paypal","bt","stripe","stripe_v2","stripe_v3"],function(c,b){jQuery("#uap_payment_with_"+b).css("display","none")});var a=jQuery("[name=uap_affiliate_payment_type]").val();jQuery("#uap_payment_with_"+a).fadeIn(200)}
function uapBecomeAffiliatePublic(){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_make_wp_user_affiliate_from_public"},success:function(a){a&&(window.location.href=a)}})}
function uapAddToWallet(a,c,b){var d=jQuery(b).val();if(""!=d){d=d.split(",");for(var e in d)d[e]=parseInt(d[e])}else d=[];if(jQuery(a).is(":checked"))-1==d.indexOf(c)&&d.push(c);else for(e in d)parseInt(d[e])==c&&d.splice(e,1);d=d.join(",");jQuery(b).val(d);jQuery("#uap_total_amount").html("");jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_get_amount_for_referral_list",r:d},success:function(f){f?jQuery("#uap_total_amount").html(f):jQuery("#uap_total_amount").html(0)}})}
function uapRemoveWalletItem(a,c){var b=window.location.href;jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_delete_wallet_item_via_ajax",type:a,code:c},success:function(d){d&&(window.location.href=b)}})}
function uapDeleteFileViaAjax(a,c,b,d,e){if(confirm("Are you sure you want to delete?")){var f=jQuery(b).attr("data-h");jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_delete_attachment_ajax_action",attachemnt_id:a,user_id:c,field_name:d,h:f},success:function(g){jQuery(e).val("");jQuery(b+" .ajax-file-upload-filename").remove();jQuery(b+" .uap-delete-attachment-bttn").remove();jQuery(b+" .uap-member-photo").length&&(jQuery(b+" .uap-member-photo").remove(),"uap_avatar"==d&&(jQuery(b).prepend("<div class='uap-no-avatar uap-member-photo'></div>"),jQuery(b+" .uap-file-upload").css("display","block")));jQuery(b+" .uap-file-name-uploaded").length&&jQuery(b+" .uap-file-name-uploaded").remove();jQuery(b+" .ajax-file-upload-progress").length&&jQuery(b+" .ajax-file-upload-progress").remove();jQuery(b+" .uap-icon-file-type").length&&jQuery(b+" .uap-icon-file-type").remove()}})}}
function uapMakeInputhString(a,c,b){var d=jQuery(b).val();-1==d&&(d="");d=""!=d?d.split(","):[];jQuery(a).is(":checked")?d.push(c):(a=d.indexOf(c),d.splice(a,1));d=d.join(",");""==d&&(d=-1);jQuery(b).val(d)}
function uapAffiliateUsernameTest(a){jQuery(".uap-username-not-exists").remove();jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_check_if_username_is_affiliate",username:a},success:function(c){1==c&&jQuery("#uap_affiliate_username_text").after('<div class="uap-username-not-exists">Username that You write is not affiliate!</div>')}})}
function uapCheckLoginField(a,c){var b=jQuery("#notice_"+a);b.fadeOut(500,function(){b.remove()});var d=jQuery("#uap_login_form [name="+a+"]").parent();""==jQuery("#uap_login_form [name="+a+"]").val()&&jQuery(d).append('<div class="uap-login-notice" id="notice_'+a+'">'+c+"</div>")}
function uapStripeV2UpdateFields(){var a=jQuery(".stripe_v2_meta_data_country").val(),c=jQuery(".stripe_v2_meta_data_user_type").val();"us"!=a&&(a="non_us");jQuery(".uap-stripe-v2-field").each(function(){var b=jQuery(this).attr("data-country"),d=jQuery(this).attr("data-type");"all"==b&&"all"==d?jQuery(this).css("display","block"):a==b?(c==d||"all"==d)&&jQuery(this).css("display","block"):c==d?(a==b||"all"==b)&&jQuery(this).css("display","block"):jQuery(this).css("display","none")});a=jQuery(".stripe_v2_meta_data_country").val();"ca"==a&&(jQuery(".uap-js-routing-number").css("display","none"),jQuery(".uap-js-transit-number").css("display","block"),jQuery(".uap-js-institution-number").css("display","block"))};function uapDoHideInfoAffiliateBar(a){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_info_affiliate_bar_do_hide"},success:function(c){jQuery(".uap-menu-section").fadeOut(300);jQuery("#uap_info_affiliate_bar").fadeOut(300);jQuery("#uap_iab_style").remove()}})};function uapInfoAffiliateBarUpdateLink(){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ia_ajax_return_url_for_aff",aff_id:jQuery("#uap_info_affiliate_bar_extra_info").attr("data-affiliate_id"),url:window.location.href,campaign:"",slug:jQuery("#ap_affiliate_bar_ref_type").val(),friendly_links:jQuery("#uap_affiliate_bar_friendly_links").val()},success:function(a){a&&(a=JSON.parse(a).url,0!=a&&jQuery(".uap-js-iab-affiliate-link").val(a))}})}
function uapInfoAffiliateBarChangeBannerSize(a){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ajax_get_banner_for_permalink",affiliate_id:jQuery("#uap_info_affiliate_bar_banner_extra_info").attr("data-affiliate_id"),uid:jQuery("#uap_info_affiliate_bar_banner_extra_info").attr("data-uid"),url:window.location.href,size:a},success:function(c){c&&(jQuery("#uap_info_bar_banner_the_value").val(c),jQuery("#uap_info_bar_banner_wrapp").html(c))}})}
jQuery(document).ajaxSend(function(a,c,b){"string"===typeof b.data&&!1!==b.data.includes("action=uap")&&"string"===typeof b.url&&b.url.includes("/admin-ajax.php")&&(a=jQuery('meta[name="uap-token"]').attr("content"),c.setRequestHeader("X-CSRF-UAP-TOKEN",a))});window.addEventListener("DOMContentLoaded",function(){jQuery(".uap-js-submit-campaign").on("click",function(a){a.preventDefault();jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ajax_save_campaign",campaignName:jQuery("[name=campaign_name]").val()},success:function(c){location.reload()}})});jQuery("#uap_login_username").on("blur",function(){var a=jQuery(".uap-js-login-form-error-messages").attr("data-log");uapCheckLoginField("log",a)});jQuery("#uap_login_password").on("blur",function(){var a=jQuery(".uap-js-login-form-error-messages").attr("data-pwd");uapCheckLoginField("pwd",a)});jQuery("#uap_login_form").on("submit",function(a){a.preventDefault();a=jQuery("#uap_login_form [name=log]").val();var c=jQuery("#uap_login_form [name=pwd]").val();if(""!=a&&""!=c)jQuery("#uap_login_form").unbind("submit").submit();else return a=jQuery(".uap-js-login-form-error-messages").attr("data-log"),c=jQuery(".uap-js-login-form-error-messages").attr("data-pwd"),uapCheckLoginField("log",a),uapCheckLoginField("pwd",c),FALSE});""!=jQuery(".uap-js-payment-settings-nonce").val()&&(uapPaymentType(),uapStripeV2UpdateFields());jQuery(".uap-js-submit-simple-link").on("click",function(a){a.preventDefault();jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ajax_save_simple_link",url:jQuery("[name=url]").val(),currentUrl:jQuery(".uap-js-simple-links-section").attr("data-current_url")},success:function(c){c?document.location.href=c:location.reload()}})});jQuery(".uap-general-date-filter").length&&jQuery(".uap-general-date-filter").each(function(){jQuery(this).datepicker({dateFormat:"yy-mm-dd",onSelect:function(a){jQuery(this).val(a)}})});jQuery(".uap-js-select2-data").length&&jQuery(".uap-js-select2-data").each(function(a,c){var b=jQuery(c).attr("data-selector"),d=jQuery(c).attr("data-label");jQuery(b).select2({placeholder:d,allowClear:!0})});jQuery(".uap-js-date-picker-data").length&&jQuery(".uap-js-date-picker-data").each(function(a,c){var b=jQuery(c).attr("data-selector");jQuery(b).datepicker({dateFormat:"dd-mm-yy"})});jQuery(".uap-js-upload-file-data").length&&jQuery(".uap-js-upload-file-data").each(function(a,c){var b=jQuery(c).attr("data-rand"),d=jQuery(c).attr("data-url"),e=jQuery(c).attr("data-max_size"),f=jQuery(c).attr("data-alowed_types"),g=jQuery(c).attr("data-name"),l=jQuery(c).attr("data-alert_text");jQuery("#uap_fileuploader_wrapp_"+b+" .uap-file-upload").uploadFile({onSelect:function(h){jQuery("#uap_fileuploader_wrapp_"+b+" .ajax-file-upload-container").css("display","block");return""!=jQuery("#uap_upload_hidden_"+b).val()?(alert(l),!1):!0},url:d,fileName:"uap_file",dragDrop:!1,showFileCounter:!1,showProgress:!0,showFileSize:!1,maxFileSize:e,allowedTypes:f,onSuccess:function(h,k,m,n){if(k){h=jQuery.parseJSON(k);"undefined"!=typeof h.secret&&jQuery("#uap_fileuploader_wrapp_"+b).attr("data-h",h.secret);k='<div onClick="uapDeleteFileViaAjax('+h.id+", -1, '#uap_fileuploader_wrapp_"+b+"', '"+g+"', '#uap_upload_hidden_"+b+"');\" class='uap-delete-attachment-bttn'>Remove</div>";jQuery("#uap_fileuploader_wrapp_"+b+" .uap-file-upload").prepend(k);switch(h.type){case "image":jQuery("#uap_fileuploader_wrapp_"+b+" .uap-file-upload").prepend("<img src="+h.url+" class='uap-member-photo' /><div class='uap-clear'></div>");break;case "other":jQuery("#uap_fileuploader_wrapp_"+b+" .uap-file-upload").prepend("<div class=uap-icon-file-type></div><div class=uap-file-name-uploaded>"+h.name+"</div>")}jQuery("#uap_upload_hidden_"+b).val(h.id);setTimeout(function(){jQuery("#uap_fileuploader_wrapp_"+b+" .ajax-file-upload-container").css("display","none")},3E3)}}})});jQuery(".uap-js-login-form-details").length&&jQuery(".uap-js-login-form-details").each(function(a,c){var b=jQuery(c).attr("data-username_selector"),d=jQuery(c).attr("data-password_selector"),e=jQuery(c).attr("data-error_message");jQuery(b).on("blur",function(){uapCheckLoginField("log",e)});jQuery(d).on("blur",function(){uapCheckLoginField("pwd",e)});jQuery("#uap_login_form").on("submit",function(f){f.preventDefault();f=jQuery("#uap_login_form [name=log]").val();var g=jQuery("#uap_login_form [name=pwd]").val();if(""!=f&&""!=g)jQuery("#uap_login_form").unbind("submit").submit();else return uapCheckLoginField("log",e),uapCheckLoginField("pwd",e),FALSE})});jQuery(".uap-js-owl-settings-data").length&&jQuery(".uap-js-owl-settings-data").each(function(a,c){uapInitiateOwl(c)});if(jQuery(".uap-js-account-page-campaigns-delete-item").length)jQuery(".uap-js-account-page-campaigns-delete-item").on("click",function(a,c){var b=jQuery(this).attr("data-id");jQuery("#uap_delete_campaign").val(b);jQuery("#uap_campaign_form").submit()});if(jQuery(".uap-js-payment-settings-stripe-tos").length)jQuery(".uap-js-payment-settings-stripe-tos").on("click",function(a,c){jQuery(".stripe_v2_tos").removeAttr("disabled");window.open("https://stripe.com/us/connect-account/legal","_blank")});if(0<jQuery(".uap-js-list-affiliate-links-remove").length)jQuery(".uap-js-list-affiliate-links-remove").on("click",function(){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ajax_do_remove_affiliate_link",id:jQuery(this).attr("data-id")},success:function(a){location.reload()}})});if(0<jQuery(".uap-js-list-affiliate-links-copy").length)jQuery(".uap-js-list-affiliate-links-copy").on("click",function(){var a=document.createElement("textarea");a.value=jQuery(this).attr("data-link");document.body.appendChild(a);a.select();document.execCommand("copy");document.body.removeChild(a);"undefined"!==typeof uapSwal&&uapSwal({title:jQuery(this).attr("data-confirm"),text:"",type:"success",showConfirmButton:!1,confirmButtonClass:"btn-success",confirmButtonText:"OK",timer:1E3})})});function uapInitiateOwl(a){a=jQuery(a).attr("data-selector");var c=jQuery(a).attr("data-autoHeight"),b=jQuery(a).attr("data-animateOut"),d=jQuery(a).attr("data-animateIn"),e=jQuery(a).attr("data-lazyLoad"),f=jQuery(a).attr("data-loop"),g=jQuery(a).attr("data-autoplay"),l=jQuery(a).attr("data-autoplayTimeout"),h=jQuery(a).attr("data-autoplayHoverPause"),k=jQuery(a).attr("data-autoplaySpeed"),m=jQuery(a).attr("data-nav"),n=jQuery(a).attr("data-navSpeed"),p=jQuery(a).attr("data-dots"),q=jQuery(a).attr("data-dotsSpeed"),r=jQuery(a).attr("data-responsiveClass"),t=jQuery(a).attr("data-navigation");jQuery(a).owluapCarousel({items:1,mouseDrag:!0,touchDrag:!0,autoHeight:c,animateOut:b,animateIn:d,lazyLoad:e,loop:f,autoplay:g,autoplayTimeout:l,autoplayHoverPause:h,autoplaySpeed:k,nav:m,navSpeed:n,navText:["",""],dots:p,dotsSpeed:q,responsiveClass:r,responsive:{0:{nav:!1},450:{nav:t}}})}
function uapReloadListAffiliateLinksTable(){jQuery.ajax({type:"post",url:decodeURI(ajax_url),data:{action:"uap_ajax_load_list_affiliate_links_table"},success:function(a){jQuery(".uap-js-list-affiliate-links-wrapp").remove();jQuery(".uap-user-page-content").append(a)}})}