import{r as i,d as o,B as l,h as n}from"./p-846bd001.js";import{f as t}from"./p-cf4a3445.js";import{s}from"./p-4ff8bb4b.js";import{s as e,g as a}from"./p-09bad279.js";import{m as d}from"./p-9732f456.js";import"./p-5cd01495.js";import"./p-259f1737.js";import"./p-ae2fb9dc.js";import"./p-65879f9e.js";import"./p-dca1478c.js";import"./p-2b31742f.js";import"./p-18891da7.js";import"./p-8cd54418.js";const r=class{constructor(l){i(this,l),this.fireenjinTrigger=o(this,"fireenjinTrigger",7),this.fireenjinSubmit=o(this,"fireenjinSubmit",7),this.floodteamCloseModal=o(this,"floodteamCloseModal",7),this.paginationEl=void 0,this.query=void 0,this.selectedIds=[],this.selectedServices=[],this.services=[],this.filter={tab:null}}onCodeChange(i){var o,l;if("bulkEdit"!==(null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.name)){for(const o of this.selectedIds)this.fireenjinSubmit.emit({name:"bulkEdit",endpoint:"editService",params:{id:o,data:(null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||{}}});this.floodteamCloseModal.emit()}}async onSearchInput(i){this.query=i.target.value,this.services=await e(this.query)}async onTrigger(i){var o,l,n,t,s,a;"set"===i.detail.name&&(null===(l=null===(o=i.detail)||void 0===o?void 0:o.payload)||void 0===l?void 0:l.name)&&(this.filter={...this.filter,[null===(t=null===(n=i.detail)||void 0===n?void 0:n.payload)||void 0===t?void 0:t.name]:(null===(a=null===(s=null==i?void 0:i.detail)||void 0===s?void 0:s.payload)||void 0===a?void 0:a.value)||null},this.services=await e(this.query,(i=>{var o,l;return null===(l=null===(o=this.filter)||void 0===o?void 0:o.tab)||void 0===l?void 0:l.includes(null==i?void 0:i.tab)})))}async toggleService(i){var o,l;i.preventDefault(),i.stopPropagation();const n=this.selectedIds;console.log(i),this.selectedIds.includes(null===(o=null==i?void 0:i.target)||void 0===o?void 0:o.value)?n.splice(this.selectedIds.indexOf(i.target.value),1):n.push(null===(l=null==i?void 0:i.target)||void 0===l?void 0:l.value),this.selectedIds=n,console.log(this.selectedIds)}async openCodeEditor(i,o){const l=await d.create({component:"fireenjin-mx-modal-code-editor",cssClass:"fireenjin-mx-modal-code-editor-wrapper",componentProps:{pageTitle:"autofill"===i?"Set Auto-Fill":"Set Smart Scoping",name:i,language:"json",value:o,endpoint:"",documentId:!0}});return await l.present(),l}async componentDidLoad(){(null==l?void 0:l.isBrowser)&&(this.services=await e(this.query),console.log(this.services))}render(){var i,o,l;return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/services"},"Services"),n("ion-buttons",{slot:"end"},n("ion-button",{fill:"solid",color:"primary",href:"/services/new"},"Add"))),n("fireenjin-search-bar",{paginationEl:this.paginationEl,filters:(null===(i=null==s?void 0:s.claims)||void 0===i?void 0:i.tester)||(null===(o=null==s?void 0:s.claims)||void 0===o?void 0:o.admin)?[{name:"tab",label:"Tab",icon:"albums",multiple:!0,options:a(),value:null===(l=this.filter)||void 0===l?void 0:l.tab}]:null}),n("ion-card",{class:"list-card"},n("ion-list",{class:"ion-no-padding"},n("fireenjin-pagination",{name:"services",approxItemHeight:84,results:this.services,renderItem:i=>n("ion-item",{href:`/services/${i.id}`,detail:!0},n("ion-checkbox",{id:`toggle.${(null==i?void 0:i.id)||""}`,slot:"start",onClick:i=>this.toggleService(i),value:null==i?void 0:i.id,checked:this.selectedIds.includes(null==i?void 0:i.id)}),n("ion-label",null,n("h2",null,(null==i?void 0:i.name)||""," "),n("div",null,Object.entries((null==i?void 0:i.prices)||{}).map((([i,o])=>n("ion-chip",null,n("ion-label",null,i||"",":"," ",n("ion-text",{color:"success",slot:"end"},t(o||0)))))))))})))),n("floodteam-navigation-footer",null,n("fireenjin-chip-bar",null,n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"import",type:"services"})},n("ion-icon",{class:"ft-icon-style",name:"cloud-upload"}),n("ion-label",null,"Import from CSV")),n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"export",collection:"services"})},n("ion-icon",{name:"cloud-download",class:"ft-icon-style"}),n("ion-label",null,"Export to CSV")),n("ion-chip",{onClick:()=>this.openCodeEditor("autofill",null)},n("ion-icon",{class:"ft-icon-style",name:"code"}),n("ion-label",null,"Set Auto-Fill")),n("ion-chip",{onClick:()=>this.openCodeEditor("smartScoping",null)},n("ion-icon",{class:"ft-icon-style",name:"code"}),n("ion-label",null,"Set Smart Scoping"))))]}};r.style="";export{r as app_service_list}