import{r as e,h as a}from"./p-e97fde0a.js";import{a as s}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(a){e(this,a);this.heading=undefined;this.successUrl=undefined;this.user=undefined;this.loading=undefined;this.error=undefined;this.enableValidation=true}renderEmpty(){return a("slot",{name:"empty"},wp.i18n.__("User not found.","surecart"))}validatePassword(e){const a=new RegExp("^(?=.*?[#?!@$%^&*-]).{6,}$");if(a.test(e))return true;return false}async handleSubmit(e){this.loading=true;this.error="";try{const{password:a}=await e.target.getFormJson();await s({path:`wp/v2/users/me`,method:"PATCH",data:{password:a,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 a("sc-dashboard-module",{key:"9623b556f4312f98ba7adb045a96cb15a218950a",class:"customer-details",error:this.error},a("span",{key:"2c3adc0dcb56a9db00b2168b9fe2ea82ff9cabf2",slot:"heading"},this.heading||wp.i18n.__("Update Password","surecart")," "),a("slot",{key:"99db1aaa31cc73eceec73801ea49a07cef9d9b6a",name:"end",slot:"end"}),a("sc-card",{key:"11f8bb7cd820531f5e274d87b9a0945cf9152503"},a("sc-form",{key:"8df3c17ea73ba049035a02f603da79a7d12ab68e",onScFormSubmit:e=>this.handleSubmit(e)},a("sc-password",{key:"478566b1292a405c3baa9024ef03a28e592da007",enableValidation:this.enableValidation,label:wp.i18n.__("New Password","surecart"),name:"password",confirmation:true,required:true}),a("div",{key:"15212a8c7f9bcd5054aea79c35a128ce77661b78"},a("sc-button",{key:"b4e41bfd96f74432f6ad533669b7696d97dae75a",type:"primary",full:true,submit:true},wp.i18n.__("Update Password","surecart"))))),this.loading&&a("sc-block-ui",{key:"f3d7bd1598cecebdd2f21e2783115d71c018c64f",spinner:true}))}};r.style=d;export{r as sc_wordpress_password_edit};
//# sourceMappingURL=p-bf0cd18e.entry.js.map