!function(t){"use strict";var r=function(t,r){t.addClass("error");var e=t.siblings(".error-message");e.length?e.text(r).show():t.after('<span class="error-message" style="display: block;">'+r+"</span>")},e=function(t){t.find(".error").removeClass("error"),t.find(".error-message").text("").hide()},n={init:function(){t(document).on("click",".password-toggle",this.toggle)},toggle:function(r){r.preventDefault();var e=t(this),n=e.data("target"),a=t('[name="'.concat(n,'"]'));"password"===a.attr("type")?(a.attr("type","text"),e.attr("aria-label","Hide password"),e.find(".eye-icon").attr("viewBox","0 0 24 24").html('\n\t\t\t\t\t<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n\t\t\t\t\t<path d="M14.084 14.158a3 3 0 0 1-4.242-4.242" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n\t\t\t\t\t<path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n\t\t\t\t\t<path d="m2 2 20 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n\t\t\t\t')):(a.attr("type","password"),e.attr("aria-label","Show password"),e.find(".eye-icon").attr("viewBox","0 0 20 20").html('\n\t\t\t\t\t<path d="M10 4C4.5 4 2 10 2 10C2 10 4.5 16 10 16C15.5 16 18 10 18 10C18 10 15.5 4 10 4Z" stroke="currentColor" stroke-width="1.5"/>\n\t\t\t\t\t<circle cx="10" cy="10" r="3" stroke="currentColor" stroke-width="1.5"/>\n\t\t\t\t'))}},a={init:function(){this.bindEvents()},bindEvents:function(){t("#smartpay-login-form").on("submit",this.handleSubmit.bind(this)),t(document).on("input","#smartpay-login-form input",this.clearFieldError)},handleSubmit:function(n){var a,i,o=this;n.preventDefault();var s=t(n.target),d=s.find('button[type="submit"]'),l=d.find(".btn-text").text();e(s),s.find(".form-message").html("");var c=s.find('[name="username"]').val().trim(),u=s.find('[name="password"]').val();if(c)if(u){d.prop("disabled",!0),d.find(".btn-text").text("Signing in...");var m=s.serialize()+"&action=smartpay_user_login&nonce="+((null===(a=window.smartpayData)||void 0===a?void 0:a.nonce)||"");t.post((null===(i=window.smartpayData)||void 0===i?void 0:i.ajaxUrl)||"/wp-admin/admin-ajax.php",m).done(function(t){return o.handleResponse(t,s,d,l)}).fail(function(){return o.handleError(s,d,l)})}else r(s.find('[name="password"]'),"Password is required");else r(s.find('[name="username"]'),"Username or email is required")},handleResponse:function(t,r,e,n){var a=r.find(".form-message");t.success?(a.html('<div class="alert alert-success">'+t.data.message+"</div>"),setTimeout(function(){window.location.href=t.data.redirect||"/"},1e3)):(a.html('<div class="alert alert-error">'+(t.data.message||"Invalid credentials")+"</div>"),e.prop("disabled",!1),e.find(".btn-text").text(n))},handleError:function(t,r,e){t.find(".form-message").html('<div class="alert alert-error">An error occurred. Please try again.</div>'),r.prop("disabled",!1),r.find(".btn-text").text(e)},clearFieldError:function(){var r=t(this);r.hasClass("error")&&""!==r.val().trim()&&(r.removeClass("error"),r.siblings(".error-message").text("").hide())}};t(document).ready(function(){void 0===window.smartpayData&&(window.smartpayData={ajaxUrl:"/wp-admin/admin-ajax.php",nonce:"",strings:{processing:"Processing...",error:"An error occurred. Please try again."}},console.warn("smartpayData not found, using defaults")),t(".smartpay-login-page").length&&a.init(),n.init()})}(jQuery);