import{r as e,h as a}from"./p-9add63ef.js";import"./p-8dccb656.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 d=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:d}=await e.target.getFormJson();await s({path:`wp/v2/users/me`,method:"PATCH",data:{first_name:t,last_name:c,email:a,name:d}});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:"63b10a42189403935ed2d149f6432b7c215b5411",class:"account-details",error:this.error},a("span",{key:"0a2f72f909d54fafafb40db7e07ab8c1d8e9f642",slot:"heading"},this.heading||wp.i18n.__("Account Details","surecart")," "),a("sc-card",{key:"43a45982cf08116e2a46be04b0d210719e467200"},a("sc-form",{key:"80cc9132b372b9a3523b13a506040061e9d59a7c",onScFormSubmit:e=>this.handleSubmit(e)},a("sc-input",{key:"0ffee3c9051bae7d5693c315a829132f273c752b",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:"807cdcf2de0971480f39d59b97aef3f06a35500e",style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},a("sc-column",{key:"598ff340ee9c3b4a8a08519e2c1604f1b8fd34d7"},a("sc-input",{key:"846b10eb01fed727e6640b1759bdd0e41866d555",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:"de088f871fd1dab740212dffa36207a033b564b8"},a("sc-input",{key:"19783e82994bd63868e6881c09ac3a18490193d2",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:"6816098890f6ffae8a32f1c330cf7446b15da828",label:wp.i18n.__("Display Name","surecart"),name:"name",value:(c=this.user)===null||c===void 0?void 0:c.display_name}),a("div",{key:"4fccddd3a12d41cdaa6d407dee0fbc109a4c62eb"},a("sc-button",{key:"4bd7fea0b6fb5cd1a3ba7eb3760ee1fe48051fee",type:"primary",full:true,submit:true},wp.i18n.__("Save","surecart"))))),this.loading&&a("sc-block-ui",{key:"643c26d7c3e844769fcbf992cf4d37ba769ff4e3",spinner:true}))}};d.style=c;export{d as sc_wordpress_user_edit};
//# sourceMappingURL=p-af391833.entry.js.map