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 d=":host{display:block;position:relative}.customer-details{display:grid;gap:0.75em}";const t=d;const c=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:d,last_name:t,name:c}=await e.target.getFormJson();await s({path:`wp/v2/users/me`,method:"PATCH",data:{first_name:d,last_name:t,email:a,name:c}});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,d,t;return a("sc-dashboard-module",{key:"1f6cfbc93e7bb5c58c80b3b7a6eb13d62e34f011",class:"account-details",error:this.error},a("span",{key:"25d26787f7d4320d4cc744fb148e4460e7d51abe",slot:"heading"},this.heading||wp.i18n.__("Account Details","surecart")," "),a("sc-card",{key:"5fa8f5e57de593d5414dbddb561253df231d9439"},a("sc-form",{key:"4734b933a755d483cd95384b3fb5ba897a9cda99",onScFormSubmit:e=>this.handleSubmit(e)},a("sc-input",{key:"26fbf283b159ac9474ec054f24b845572c6dc3da",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:"5aca9b4439fe3d10c56f99ad563b4c7cefd254c5",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},a("sc-column",{key:"6eae1eb38b0b074549c212bc7f0555c1062defaf"},a("sc-input",{key:"5e3c72b495dfd0d35e78e915de3621153d7705e0",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:"9b879810c5b44b89128f8cdf75122bab504f163f"},a("sc-input",{key:"94b792dc95ee084e3729e70bbf56e7f7ffec3ed6",label:wp.i18n.__("Last Name","surecart"),name:"last_name",value:(d=this.user)===null||d===void 0?void 0:d.last_name}))),a("sc-input",{key:"411e12095633a8bcddbd488955dde76c5f96629e",label:wp.i18n.__("Display Name","surecart"),name:"name",value:(t=this.user)===null||t===void 0?void 0:t.display_name}),a("div",{key:"5d2801d4f0ae73061fd385714812d6d5f986625b"},a("sc-button",{key:"505a95009635ebaab9140df81d0d2468fc163237",type:"primary",full:true,submit:true},wp.i18n.__("Save","surecart"))))),this.loading&&a("sc-block-ui",{key:"416d6da7d09e1baeeb81b1c3602cc8a61aa8ddde",spinner:true}))}};c.style=t;export{c as sc_wordpress_user_edit};
//# sourceMappingURL=p-34c2dec1.entry.js.map