import{r as i,B as l,h as o,H as t}from"./p-a89095f5.js";import{c as s,g as a}from"./p-57b02476.js";import"./p-188ef7e9.js";import"./p-d7f93824.js";import"./p-2a0c7fc9.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";const n=({beforeHTML:i="<h1>What is the name of the company?</h1>",label:l="Company Name",value:o=null,name:t="companyName"}={})=>({name:t,beforeHTML:i,fields:[{label:l,labelPosition:"stacked",placeholder:"The Flood Team",name:"name",type:"text",clearInput:!0,required:!0,value:o}]}),e=class{constructor(l){i(this,l),this.paths={default:()=>[n({value:this.companyName}),s({value:this.phone})]},this.currentPath="default",this.currentStep="companyName",this.locationId=void 0,this.phone=void 0,this.address=void 0,this.companyId=void 0,this.companyName=void 0,this.endpoint="addCompany",this.errors=[],this.steps=[],this.currentSlideIndex=0}async setPath(i){var l,o,t,s;return this.currentPath=i||this.currentPath,this.currentStep=(null===(s=null===(t=null===(o=null===(l=this.paths)||void 0===l?void 0:l[this.currentPath])||void 0===o?void 0:o.call(l))||void 0===t?void 0:t[this.currentSlideIndex])||void 0===s?void 0:s.name)||null,this.steps=this.paths[this.currentPath](),this.steps}onError(i){i.detail.endpoint===this.endpoint&&setTimeout((()=>{this.errors=i.detail.error.response.errors.map((i=>i.message))}),100)}onChange(i){var l,o;console.log(i),"name"===(null===(l=null==i?void 0:i.target)||void 0===l?void 0:l.name)&&(this.companyName=(null===(o=null==i?void 0:i.target)||void 0===o?void 0:o.value)||null)}async onSuccess(i){var l,o,t;this.errors=[],i.detail.endpoint===this.endpoint&&(this.companyId=null===(t=null===(o=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||void 0===o?void 0:o.addCompany)||void 0===t?void 0:t.id)}async onSlideChange(i){this.currentSlideIndex=await i.target.getActiveIndex(),await this.setPath()}onBeforeSubmit(i){return{...i}}async componentDidLoad(){(null==l?void 0:l.isBrowser)&&await this.setPath()}render(){var i,l;const s=1/this.steps.length*this.currentSlideIndex;return o(t,null,this.errors.map((i=>o("floodteam-error",{message:i}))),!(this.currentSlideIndex>=this.steps.length)&&o("ion-progress-bar",{style:{width:"80%",margin:this.companyId?"0 auto":"30px auto",transition:"opacity ease 500ms",opacity:this.companyId?"0":"1"},value:s}),o("fireenjin-flow",{endpoint:this.endpoint,steps:this.steps,beforeSubmit:this.onBeforeSubmit.bind(this),prevButton:{color:"medium",fill:"outline",label:"Back"},nextButton:{color:"primary",fill:"solid",icon:null,label:"Next"}},o("div",{style:{color:"var(--ion-text-color)",padding:"2rem 3rem"}},o("h1",{class:"ion-padding-horizontal"},"Success! ",this.companyName," has been added 💪."),o("p",{class:"ion-padding-horizontal",style:{color:"var(--ion-color-medium-shade)"}},"The company has been added to the database and will be synced with Notion."),o("div",{class:"confirm-card"},o("span",null,o("small",null,"Company Name"),o("p",null,this.companyName||"")),o("span",null,o("small",null,"Phone"),o("p",null,this.phone||"")),o("span",null,o("small",null,"Address"),o("p",null,(null===(i=this.address)||void 0===i?void 0:i.full)||"")),o("span",null,o("small",null,"Flood Team Location"),o("p",null,null===(l=a(this.locationId))||void 0===l?void 0:l.name)),o("span",null,o("small",null,"Company ID"),o("p",null,this.companyId))),o("div",{style:{display:"flex",justifyContent:"space-between",gap:"2rem"}},o("ion-button",{class:"btn",size:"default",expand:"block",fill:"outline","data-clipboard-text":this.companyId},"Copy to clipboard",o("ion-icon",{name:"clipboard",slot:"end"})),o("ion-button",{size:"default",href:`/companies/${this.companyId}`,expand:"block"},"View Company")))))}};export{e as floodteam_company_flow}