import{r as e,h as a}from"./p-9add63ef.js";import"./p-445fd8b4.js";import{a as s}from"./p-259c3935.js";import"./p-401e165e.js";import"./p-d3366af3.js";const t=":host{display:block;position:relative}.customer-details{display:grid;gap:0.75em}";const c=t;const i=class{constructor(a){e(this,a);this.heading=undefined;this.successUrl=undefined;this.user=undefined;this.loading=undefined;this.error=undefined}renderEmpty(){return a("slot",{name:"empty"},wp.i18n.__("User not found.","surecart"))}async handleSubmit(e){this.loading=true;try{const{email:a,first_name:t,last_name:c,name:i}=await e.target.getFormJson();await s({path:`wp/v2/users/me`,method:"PATCH",data:{first_name:t,last_name:c,email:a,name:i}});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(){var e,s,t,c;return a("sc-dashboard-module",{key:"c873dbb5fde98599e5469626735155dd8bad7347",class:"account-details",error:this.error},a("span",{key:"d7d61fdb81f9b4672309040f2339a46ca64f6ae5",slot:"heading"},this.heading||wp.i18n.__("Account Details","surecart")," "),a("sc-card",{key:"11154dd3e85dba90aa52a9cc1d37994b96fb60b6"},a("sc-form",{key:"574de64fc392ee2666346c708a22307a9f9bc74f",onScFormSubmit:e=>this.handleSubmit(e)},a("sc-input",{key:"8cf5f349b6aaf151e64319faf462693cf18a8691",label:wp.i18n.__("Account Email","surecart"),name:"email",value:(e=this.user)===null||e===void 0?void 0:e.email,required:true}),a("sc-columns",{key:"068c84390f8871b706c3d8a83b59f620f3e76658",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},a("sc-column",{key:"f17d8a8ebe2c82c987c874116093dd631b48c385"},a("sc-input",{key:"a77b538cacd3a3e197d976718b9d9e8cdecd8212",label:wp.i18n.__("First Name","surecart"),name:"first_name",value:(s=this.user)===null||s===void 0?void 0:s.first_name})),a("sc-column",{key:"31aacae027df0c438de6f2d67f4c98535c7bda83"},a("sc-input",{key:"1e029f07eebe636c0f7ff4e74467bd5e19a2b68f",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:(t=this.user)===null||t===void 0?void 0:t.last_name}))),a("sc-input",{key:"8bbf1f99c7762be03b647b13c383a196c209ac19",label:wp.i18n.__("Display Name","surecart"),name:"name",value:(c=this.user)===null||c===void 0?void 0:c.display_name}),a("div",{key:"a57a6edf2fa15be6c2956b278080cab5f210e9f4"},a("sc-button",{key:"dc5421f2837ef791029837d822c7bfb6aecbfe85",type:"primary",full:true,submit:true},wp.i18n.__("Save","surecart"))))),this.loading&&a("sc-block-ui",{key:"8a56afc8a96ed6c01e1b5691f8753fb7c5bb7892",spinner:true}))}};i.style=c;export{i as sc_wordpress_user_edit};
//# sourceMappingURL=p-257ea2c3.entry.js.map