import{r as i,e as t,B as l,h as e}from"./p-a89095f5.js";import{t as o}from"./p-3e7f0e42.js";import{s as a}from"./p-188ef7e9.js";import"./p-29ec504c.js";import"./p-8cd54418.js";import"./p-d7f93824.js";import"./p-2a0c7fc9.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";const n=class{constructor(l){i(this,l),this.fireenjinFetch=t(this,"fireenjinFetch",7),this.fireenjinSubmit=t(this,"fireenjinSubmit",7),this.fireenjinTrigger=t(this,"fireenjinTrigger",7),this.materialId=void 0,this.material={}}async onSuccess(i){var t,l,e,a,n,r,s,d;if("findMaterial"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint))this.material=(null===(e=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||void 0===e?void 0:e.material)||null;else if("editMaterial"===(null===(a=null==i?void 0:i.detail)||void 0===a?void 0:a.endpoint))(await o.create({message:"Material saved successfully!",duration:3e3})).present();else if("addMaterial"===(null===(n=null==i?void 0:i.detail)||void 0===n?void 0:n.endpoint)&&"new"===this.materialId){const t=document.querySelector("ion-router");this.materialId=(null===(d=null===(s=null===(r=null==i?void 0:i.detail)||void 0===r?void 0:r.data)||void 0===s?void 0:s.addMaterial)||void 0===d?void 0:d.id)||"new",t&&t.push(`/materials/${this.materialId}`)}}async fetchMaterial(){this.fireenjinFetch.emit({endpoint:"findMaterial",params:{id:this.materialId}})}componentDidLoad(){(null==l?void 0:l.isBrowser)&&this.fetchMaterial()}render(){var i,t,l;return[e("ion-content",{class:"ion-padding"},e("floodteam-title-bar",null,e("ion-router-link",{href:"/materials"},"Materials")),e("ion-card",{style:{overflow:"visible"}},e("fireenjin-form",{resetButton:"Clear",resetButtonColor:"medium",ref:i=>this.formEl=i,endpoint:"new"===this.materialId?"addMaterial":"editMaterial",documentId:"new"===this.materialId?null:this.materialId},e("ion-grid",null,e("ion-row",null,e("ion-col",{size:"10"},e("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"text",name:"name",label:"Name",value:null===(i=this.material)||void 0===i?void 0:i.name,required:!0}))))))),e("floodteam-navigation-footer",null,e("floodteam-title-bar",{back:"/materials"},e("ion-breadcrumbs",null,e("ion-breadcrumb",{href:"/materials"},e("ion-icon",{class:"ft-icon-style",slot:"start",name:"construct"}),"Materials"),e("ion-breadcrumb",{onClick:()=>{var i;return this.fireenjinTrigger.emit({name:"pin",payload:{icon:"flash",href:`/materials/${this.materialId}`,name:(null===(i=this.material)||void 0===i?void 0:i.name)||"Add a Material"}})}},e("ion-icon",{color:(null===(t=((null==a?void 0:a.pins)||[]).map((i=>null==i?void 0:i.href)))||void 0===t?void 0:t.includes(`/materials/${this.materialId}`))?"primary":null,slot:"start",name:"pin"}),(null===(l=this.material)||void 0===l?void 0:l.name)||"Edit Material")))),,]}};n.style="";export{n as app_material}