import{r as i,e,B as o,h as n}from"./p-a89095f5.js";import{t as l}from"./p-3e7f0e42.js";import{s as t}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 d=class{constructor(o){i(this,o),this.fireenjinFetch=e(this,"fireenjinFetch",7),this.fireenjinTrigger=e(this,"fireenjinTrigger",7),this.itemId=void 0,this.item=void 0}async onSuccess(i){var e,o,n,t,d,s,a,r;if("findInventory"===(null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.endpoint))this.item=(null===(n=null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.data)||void 0===n?void 0:n.inventory)||null;else if("editInventory"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint))(await l.create({message:"Item saved successfully!",duration:3e3})).present();else if("addInventory"===(null===(d=null==i?void 0:i.detail)||void 0===d?void 0:d.endpoint)&&"new"===this.itemId){const e=document.querySelector("ion-router");this.itemId=(null===(r=null===(a=null===(s=null==i?void 0:i.detail)||void 0===s?void 0:s.data)||void 0===a?void 0:a.addInventory)||void 0===r?void 0:r.id)||"new",e&&e.push(`/inventory/${this.itemId}`)}}async fetchInventory(){this.fireenjinFetch.emit({endpoint:"findInventory",params:{id:this.itemId}})}componentDidLoad(){(null==o?void 0:o.isBrowser)&&this.fetchInventory()}render(){var i,e,o,l,d,s,a,r,v,u,c,m,p;return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/inventory"},"Inventory")),n("ion-card",{style:{overflow:"visible"}},n("ion-card-header",null,(null===(i=this.item)||void 0===i?void 0:i.id)?"Edit":"Add"," ",(null===(e=this.item)||void 0===e?void 0:e.name)||"Item"),n("fireenjin-form",{resetButton:"Clear",resetButtonColor:"medium",ref:i=>this.formEl=i,endpoint:"new"===this.itemId?"addInventory":"editInventory",documentId:"new"===this.itemId?null:this.itemId},n("ion-grid",null,n("ion-row",null,n("ion-col",{size:"10"},n("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"text",name:"name",label:"Name",value:null===(o=this.item)||void 0===o?void 0:o.name,required:!0})),n("ion-col",{"size-md":"6",size:"10"},n("fireenjin-select",{label:"FloodTeam Location",labelPosition:"stacked",name:"locationId",options:((null==t?void 0:t.locations)||[]).map((i=>({label:(null==i?void 0:i.name)||"No Location Name",value:null==i?void 0:i.id}))),value:null===(d=null===(l=this.item)||void 0===l?void 0:l.location)||void 0===d?void 0:d.id})),n("ion-col",{"size-md":"6",size:"10"},n("fireenjin-select",{"data-fill":!0,labelPosition:"stacked",name:"equipment",options:[{label:"equipmentsss",value:null}],label:"Equipment",value:null===(a=null===(s=this.item)||void 0===s?void 0:s.equipment)||void 0===a?void 0:a.id,required:!0})),n("ion-col",{"size-md":"4",size:"10"},n("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"text",name:"code",label:"Code",value:null===(r=this.item)||void 0===r?void 0:r.code,required:!0})),n("ion-col",{"size-md":"4",size:"10"},n("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"number",name:"inStock",label:"In Stock",value:(null===(v=this.item)||void 0===v?void 0:v.inStock)||0,required:!0})),n("ion-col",{"size-md":"4",size:"10"},n("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"number",name:"retockBelow",label:"Restock Below",value:(null===(u=this.item)||void 0===u?void 0:u.restockBelow)||0,required:!0})),n("ion-col",{size:"10"},n("fireenjin-select-tags",{name:"tags",label:"Tags",labelPosition:"stacked",value:null===(c=this.item)||void 0===c?void 0:c.tags,allowAdding:!0,options:[{label:"Important",value:"important"}]}))))))),n("floodteam-navigation-footer",null,n("floodteam-title-bar",{back:"/inventory"},n("ion-breadcrumbs",null,n("ion-breadcrumb",{href:"/inventory"},n("ion-icon",{class:"ft-icon-style",slot:"start",name:"barcode-outline"}),"Inventory"),n("ion-breadcrumb",{onClick:()=>{var i;return this.fireenjinTrigger.emit({name:"pin",payload:{icon:"flash",href:`/inventory/${this.itemId}`,name:(null===(i=this.item)||void 0===i?void 0:i.name)||"Add an Item"}})}},n("ion-icon",{color:(null===(m=((null==t?void 0:t.pins)||[]).map((i=>null==i?void 0:i.href)))||void 0===m?void 0:m.includes(`/inventory/${this.itemId}`))?"primary":null,slot:"start",name:"pin"}),("new"===this.itemId?"Add an Item":null===(p=this.item)||void 0===p?void 0:p.name)||"Edit Item"))))]}};d.style="";export{d as app_inventory}