import{r as t,c,h as e,g as o}from"./p-e964d29c.js";import{d as a}from"./p-7d777370.js";import{a as s}from"./p-58fb2d26.js";import"./p-d636f04c.js";import"./p-a5a65406.js";import{N as n}from"./p-363dca49.js";import{C as r}from"./p-3611030f.js";import{d as i}from"./p-4052fee2.js";import"./p-112455b1.js";const u={"Account number":"Kontonummer",Name:"Namn",Email:"E-post","Create account":"Skapa konto","Failed to create account.":"Kunde inte skapa konto.","Account was created.":"Kontot skapades.","Creating account...":"Skapar konto..."},m=class{constructor(e){t(this,e),this.createAccount=c(this,"createAccount",7),this.notice=c(this,"notice",7),this.close=c(this,"close",7)}componentWillLoad(){this.accountNumber=s.Identifier.generate(12),this.t=i.create({sv:u},this.element)}async submitAccount(t){const c={number:t.detail.accountNumber,customer:{name:""==t.detail.name?void 0:t.detail.name,email:""==t.detail.email?void 0:t.detail.email},method:[]};this.notice.emit(n.execute(this.t("Creating account..."),(async()=>{let t;this.close.emit();const e=await r.post("account/",c);if(a.Error.is(e))t=[!1,this.t("Failed to create account.")];else{t=[!0,this.t("Account was created.")];const c=await r.get("account/");this.createAccount.emit(c)}return t})))}render(){return[e("form",null,e("section",null,e("smoothly-input",{name:"accountNumber",type:"text",value:this.accountNumber},this.t("Account number")),e("smoothly-input",{name:"name",type:"text"},this.t("Name"))),e("section",null,e("smoothly-input",{name:"email",type:"text"},this.t("Email")),e("smoothly-submit",{fill:"clear",prevent:!0,onSubmit:t=>this.submitAccount(t)},e("smoothly-icon",{toolTip:this.t("Create account"),name:"add-circle",fill:"clear",size:"medium",color:"success"}))))]}get element(){return o(this)}};m.style=".sc-payfunc-account-create-h>form.sc-payfunc-account-create{width:100%;flex-wrap:wrap;display:flex}section.sc-payfunc-account-create{display:flex;flex-grow:1}section.sc-payfunc-account-create:last-of-type{flex-grow:2;min-width:calc(100% - 45px)}section.sc-payfunc-account-create>smoothly-input.sc-payfunc-account-create{border:1px solid rgb(var(--smoothly-medium-color));margin-bottom:0.5em;margin-left:-1px;flex-grow:1}section.sc-payfunc-account-create:last-of-type>smoothly-submit.sc-payfunc-account-create{float:right;margin-bottom:.5em;border:none}section.sc-payfunc-account-create:first-of-type{flex-wrap:wrap}section.sc-payfunc-account-create:first-of-type>*.sc-payfunc-account-create:first-of-type{flex-grow:1;flex-basis:8em}section.sc-payfunc-account-create:first-of-type>*.sc-payfunc-account-create:last-of-type{flex-grow:3}smoothly-icon.sc-payfunc-account-create{cursor:pointer;float:right}";export{m as payfunc_account_create}