(e=>{"function"==typeof define&&define.amd?define("auth",e):e()})(function(){jQuery(function(e){e('form.sign-in-form .form-group input[type="password"]').parent().wrap('<span class="toggle-password"></span>'),e(".toggle-password").append('<span class="show-toggle-password"></span>'),e(".show-toggle-password").on("click",function(){e(this).toggleClass("display-password"),e(this).hasClass("display-password")?e(this).siblings(".form-group").find('input[type="password"]').prop("type","text"):e(this).siblings(".form-group").find('input[type="text"]').prop("type","password")})}),jQuery(function(i){i('.picture-field input[type="file"]').on("change",function(e){var n,r=i(".sign-in-form.register .picture-field .picture-preview");r.html(""),e.target.files[0]&&((n=new FileReader).onload=function(e){e=i('<div class="review-gallery-image">\n                    <span class="review-gallery-preview-icon">\n                        <a class="review-gallery-image-remove" href="#">\n                            <i class="mi delete"></i>\n                        </a>\n                    </span>\n                </div>').css("background-image","url(".concat(e.target.result,")"));i(e).appendTo(r)},n.readAsDataURL(e.target.files[0]))}),i(".picture-field").on("click",".review-gallery-image-remove",function(e){e.preventDefault(),i('.picture-field input[type="file"]').val("").trigger("change")})}),jQuery(function(r){function n(e,n){var r;e&&e.length&&n&&(e=e.find('input[name="password"]')).length&&(r=e.closest(".form-group").find("label"),e.attr("id",n),r.length)&&r.attr("for",n)}function i(e){n(o,"primary"===e?"reg_password":"reg_primary_password"),n(s,"secondary"===e?"reg_password":"reg_secondary_password")}function a(){var e=r(".mylisting-register #reg_password");e.length&&e.trigger("keyup")}var o=r(".mylisting-register .primary-role-fields > .fields-wrapper"),s=r(".mylisting-register .secondary-role-fields > .fields-wrapper"),e="secondary"===r('.mylisting-register input[name="mylisting_user_role"]:checked').val()?"secondary":"primary";i(e),("secondary"==e?o:s).detach(),a(),r('.mylisting-register input[name="mylisting_user_role"]').change(function(e){var n="secondary"===e.target.value?"secondary":"primary";i(n),"secondary"==n?(o.detach(),s.appendTo(".mylisting-register .secondary-role-fields")):(s.detach(),o.appendTo(".mylisting-register .primary-role-fields")),a(),r(e.target).addClass("role-active"),r(e.target).siblings().removeClass("role-active")})}),jQuery(function(n){n(".login-tabs a").click(function(e){e.preventDefault(),("register"===e.target.dataset.form?(n(".login-form-wrap").addClass("hide"),n(".register-form-wrap")):(n(".register-form-wrap").addClass("hide"),n(".login-form-wrap"))).removeClass("hide"),n(".login-tabs li").removeClass("active"),n(e.target).parents("li").addClass("active")}),n(".login-form-wrap").hasClass("hide")||n(".login-form-wrap #username").focus(),n(".showlogin").click(function(e){e.preventDefault(),n('.login-tabs a[data-form="login"]').click()})}),window.onGoogleLibraryLoad=function(){jQuery(".cts-google-signin").each(function(e,n){var i=jQuery(".login-content"),r=jQuery("meta[name='google-signin-client_id']").attr("content"),r=(google.accounts.id.initialize({client_id:r,callback:function(e){i.addClass("cts-processing-login"),jQuery.ajax({url:"".concat(CASE27.mylisting_ajax_url,"&action=cts_login_endpoint&security=").concat(CASE27.ajax_nonce),type:"POST",dataType:"json",data:{network:"google",token:e.credential,process:"login",user_role:jQuery(n).parents(".login-container").find('input[name="mylisting_user_role"]:checked').val()},success:function(e){if("error"===e.status&&e.message)return i.removeClass("cts-processing-login"),alert(e.message);e=jQuery(n).parents(".login-container").find('input[name="redirect"]').val();e?window.location.href=e:window.location.reload()},error:function(e,n,r){console.log("Failed",e,n,r),i.removeClass("cts-processing-login")}})}}),i.width());google.accounts.id.renderButton(n,{theme:"outline",size:"large",width:r,logo_alignment:"center",locale:CASE27.google_btn_local}),google.accounts.id.prompt()})},jQuery(".cts-facebook-signin").click(function(n){n.preventDefault();var i=jQuery(".login-content");FB.login(function(e){e.authResponse&&(i.addClass("cts-processing-login"),jQuery.ajax({url:"".concat(CASE27.mylisting_ajax_url,"&action=cts_login_endpoint&security=").concat(CASE27.ajax_nonce),type:"POST",dataType:"json",data:{network:"facebook",token:e.authResponse.accessToken,process:"login",user_role:jQuery(n.target).parents(".login-container").find('input[name="mylisting_user_role"]:checked').val()},success:function(e){if("error"===e.status&&e.message)return i.removeClass("cts-processing-login"),alert(e.message);e=jQuery(n.target).parents(".login-container").find('input[name="redirect"]').val();e?window.location.href=e:window.location.reload()},error:function(e,n,r){console.log("Failed",e,n,r),i.removeClass("cts-processing-login")}}))},{scope:"public_profile,email"})})});
