import{r as e,h as s}from"./p-e97fde0a.js";import{a}from"./p-dd3464cd.js";import"./p-401e165e.js";import"./p-d3366af3.js";const t=":host{display:block;position:relative}";const d=t;const r=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 a({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:"9cd61c8c4ffec13d96ebf9c8dd101af50938f655",class:"customer-details",error:this.error},s("span",{key:"925cc949d186b12a1749cdf067dd7d75a1227c3b",slot:"heading"},this.heading||wp.i18n.__("Update Password","surecart")," "),s("slot",{key:"148b1d6b511814c6d6a07b25bbb9ab46d21d3a3e",name:"end",slot:"end"}),s("sc-card",{key:"e6f585526341af6240fa448eed021518b7395292"},s("sc-form",{key:"8a2a768536541af011f097e540692fd773718e32",onScFormSubmit:e=>this.handleSubmit(e)},s("sc-password",{key:"4a661359cc21111a17c0b1099cfd9b57894d6a41",enableValidation:this.enableValidation,label:wp.i18n.__("New Password","surecart"),name:"password",confirmation:true,required:true}),s("div",{key:"369a7b07ab525b624c78be518ae940814e87f945"},s("sc-button",{key:"3fb0f0c4dbdb86dcbf20cf8d4683977582c06e42",type:"primary",full:true,submit:true},wp.i18n.__("Update Password","surecart"))))),this.loading&&s("sc-block-ui",{key:"a1180161e90b8179aeae8b54c15320e7877a0a4a",spinner:true}))}};r.style=d;export{r as sc_wordpress_password_edit};
//# sourceMappingURL=p-9ae26f94.entry.js.map