!function(e){"function"==typeof define&&define.amd?define("auth",e):e()}(function(){"use strict";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(o){o('.picture-field input[type="file"]').on("change",function(e){var n,i=o(".sign-in-form.register .picture-field .picture-preview");i.html(""),e.target.files[0]&&((n=new FileReader).onload=function(e){e=o('<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,")"));o(e).appendTo(i)},n.readAsDataURL(e.target.files[0]))}),o(".picture-field").on("click",".review-gallery-image-remove",function(e){e.preventDefault(),o('.picture-field input[type="file"]').val("").trigger("change")})}),jQuery(function(n){var i=n(".mylisting-register .primary-role-fields > .fields-wrapper"),o=n(".mylisting-register .secondary-role-fields > .fields-wrapper");("secondary"===n('.mylisting-register input[name="mylisting_user_role"]:checked').val()?i:o).detach(),n('.mylisting-register input[name="mylisting_user_role"]').change(function(e){"secondary"===e.target.value?(i.detach(),o.appendTo(".mylisting-register .secondary-role-fields")):(o.detach(),i.appendTo(".mylisting-register .primary-role-fields")),n(e.target).addClass("role-active"),n(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 o=jQuery(".login-content"),i=jQuery("meta[name='google-signin-client_id']").attr("content"),i=(google.accounts.id.initialize({client_id:i,callback:function(e){o.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 o.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,i){console.log("Failed",e,n,i),o.removeClass("cts-processing-login")}})}}),o.width());google.accounts.id.renderButton(n,{theme:"outline",size:"large",width:i,logo_alignment:"center",locale:CASE27.google_btn_local}),google.accounts.id.prompt()})},jQuery(".cts-facebook-signin").click(function(n){n.preventDefault();var o=jQuery(".login-content");FB.login(function(e){e.authResponse&&(o.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 o.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,i){console.log("Failed",e,n,i),o.removeClass("cts-processing-login")}}))},{scope:"public_profile,email"})})});
