import{r as i,d as o,B as n,h as l}from"./p-9b6cc562.js";import{f as t}from"./p-cf4a3445.js";import{s as e}from"./p-889c70e7.js";import{s,g as a}from"./p-a198a5b7.js";import{m as d}from"./p-a4d32aeb.js";import"./p-e5527167.js";import"./p-95e9f2f6.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";import"./p-2b31742f.js";import"./p-24c4a299.js";import"./p-8cd54418.js";function r(i,o=[],n="."){return Object.keys(i).reduce(((l,t)=>Object.assign({},l,"[object Object]"===Object.prototype.toString.call(i[t])?r(i[t],o.concat([t]),n):{[o.concat([t]).join(n)]:i[t]})),{})}const c=class{constructor(n){i(this,n),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,n;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===(n=null==i?void 0:i.detail)||void 0===n?void 0:n.data)||{}}});this.floodteamCloseModal.emit()}}async onSearchInput(i){this.query=i.target.value,this.services=await s(this.query)}async onTrigger(i){var o,n,l,t,e,a;"set"===i.detail.name&&(null===(n=null===(o=i.detail)||void 0===o?void 0:o.payload)||void 0===n?void 0:n.name)&&(this.filter={...this.filter,[null===(t=null===(l=i.detail)||void 0===l?void 0:l.payload)||void 0===t?void 0:t.name]:(null===(a=null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.payload)||void 0===a?void 0:a.value)||null},this.services=await s(this.query,(i=>{var o,n;return null===(n=null===(o=this.filter)||void 0===o?void 0:o.tab)||void 0===n?void 0:n.includes(null==i?void 0:i.tab)})))}async toggleService(i){var o,n;i.preventDefault(),i.stopPropagation();const l=this.selectedIds;console.log(i),this.selectedIds.includes(null===(o=null==i?void 0:i.target)||void 0===o?void 0:o.value)?l.splice(this.selectedIds.indexOf(i.target.value),1):l.push(null===(n=null==i?void 0:i.target)||void 0===n?void 0:n.value),this.selectedIds=l,console.log(this.selectedIds)}async openCodeEditor(i,o){const n=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 n.present(),n}async componentDidLoad(){(null==n?void 0:n.isBrowser)&&(this.services=await s(this.query),console.log(this.services))}render(){var i,o,n;return[l("ion-content",{class:"ion-padding"},l("floodteam-title-bar",null,l("ion-router-link",{href:"/services"},"Services"),l("ion-buttons",{slot:"end"},l("ion-button",{fill:"solid",color:"primary",href:"/services/new"},"Add"))),l("fireenjin-search-bar",{paginationEl:this.paginationEl,filters:(null===(i=null==e?void 0:e.claims)||void 0===i?void 0:i.tester)||(null===(o=null==e?void 0:e.claims)||void 0===o?void 0:o.admin)?[{name:"tab",label:"Tab",icon:"albums",multiple:!0,options:a(),value:null===(n=this.filter)||void 0===n?void 0:n.tab}]:null}),l("ion-card",{class:"list-card"},l("ion-list",{class:"ion-no-padding"},l("fireenjin-pagination",{name:"services",approxItemHeight:84,results:this.services,renderItem:i=>l("ion-item",{href:`/services/${i.id}`,detail:!0},l("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)}),l("ion-label",null,l("h2",null,(null==i?void 0:i.name)||""," "),l("div",null,Object.entries((null==i?void 0:i.prices)||{}).map((([i,o])=>l("ion-chip",null,l("ion-label",null,i||"",":"," ",l("ion-text",{color:"success",slot:"end"},t(o||0)))))))))})))),l("floodteam-navigation-footer",null,l("fireenjin-chip-bar",null,l("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"import",type:"services"})},l("ion-icon",{class:"ft-icon-style",name:"cloud-upload"}),l("ion-label",null,"Import from CSV")),l("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"export",payload:this.services.map((i=>r(function(i){const o={...i};return["createdAt","updatedAt"].forEach((function(i){delete o[i]})),o}(i))))})},l("ion-icon",{name:"cloud-download",class:"ft-icon-style"}),l("ion-label",null,"Export to CSV")),l("ion-chip",{onClick:()=>this.openCodeEditor("autofill",null)},l("ion-icon",{class:"ft-icon-style",name:"code"}),l("ion-label",null,"Set Auto-Fill")),l("ion-chip",{onClick:()=>this.openCodeEditor("smartScoping",null)},l("ion-icon",{class:"ft-icon-style",name:"code"}),l("ion-label",null,"Set Smart Scoping"))))]}};c.style="";export{c as app_service_list}