import{r as e,h as s}from"./p-e97fde0a.js";import{a as t}from"./p-6135d661.js";import"./p-401e165e.js";import"./p-d3366af3.js";const a=":host{display:block;position:relative}";const r=a;const d=class{constructor(s){e(this,s);this.heading=undefined;this.successUrl=undefined;this.user=undefined;this.loading=undefined;this.error=undefined;this.enableValidation=true}renderEmpty(){return s("slot",{name:"empty"},wp.i18n.__("User not found.","surecart"))}validatePassword(e){const s=new RegExp("^(?=.*?[#?!@$%^&*-]).{6,}$");if(s.test(e))return true;return false}async handleSubmit(e){this.loading=true;this.error="";try{const{password:s}=await e.target.getFormJson();await t({path:`wp/v2/users/me`,method:"PATCH",data:{password:s,meta:{default_password_nag:false}}});if(this.successUrl){window.location.assign(this.successUrl)}else{this.loading=false}}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart");this.loading=false}}render(){return s("sc-dashboard-module",{key:"d36a5aadccf0407f22295c201af2baf03c6fe5de",class:"customer-details",error:this.error},s("span",{key:"04ce67d53896e45c039b76e0860205c276fe6b98",slot:"heading"},this.heading||wp.i18n.__("Update Password","surecart")," "),s("slot",{key:"f4a6244551b3f1d033ece8af144f8b1a938a5e87",name:"end",slot:"end"}),s("sc-card",{key:"62bd0cce22e67d5b1fc872120e34100ef839ecb8"},s("sc-form",{key:"a26e73aa14138b802351fceb26a92612ac310229",onScFormSubmit:e=>this.handleSubmit(e)},s("sc-password",{key:"bdc4209f763a8d81df9968815b0f51b3e2e38b81",enableValidation:this.enableValidation,label:wp.i18n.__("New Password","surecart"),name:"password",confirmation:true,required:true}),s("div",{key:"62988c62cff94149397a7447ac1bdd53f771a6ce"},s("sc-button",{key:"6de7968693e65523345b1002fff9f0de59e4ac80",type:"primary",full:true,submit:true},wp.i18n.__("Update Password","surecart"))))),this.loading&&s("sc-block-ui",{key:"e24192b0a432092ff56cf43845634ed4db6e1850",spinner:true}))}};d.style=r;export{d as sc_wordpress_password_edit};
//# sourceMappingURL=p-1e77dff7.entry.js.map