import{r as i,d as o,B as n,h as l}from"./p-03169580.js";import{f as t}from"./p-cf4a3445.js";import{s as e}from"./p-02c5cd3a.js";import{s,g as d}from"./p-8197ffbf.js";import{m as a}from"./p-3bc4f2ce.js";import"./p-59c95c5f.js";import"./p-c9699503.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-3a8e6af1.js";import"./p-2b31742f.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";function r(i,o=[],n="."){return Object.keys(i).reduce(((l,t)=>Object.assign({},l,Object.prototype.toString.call(i[t])==="[object Object]"?r(i[t],o.concat([t]),n):{[o.concat([t]).join(n)]:i[t]})),{})}function c(i,...o){const n={...i};o.forEach((function(i){delete n[i]}));return n}const u="";let v=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.selectedIds=[];this.selectedServices=[];this.services=[];this.filter={tab:null}}onCodeChange(i){var o,n;if(((o=i===null||i===void 0?void 0:i.detail)===null||o===void 0?void 0:o.name)==="bulkEdit")return;for(const o of this.selectedIds){this.fireenjinSubmit.emit({name:"bulkEdit",endpoint:"editService",params:{id:o,data:((n=i===null||i===void 0?void 0:i.detail)===null||n===void 0?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,d;if(i.detail.name==="set"&&((n=(o=i.detail)===null||o===void 0?void 0:o.payload)===null||n===void 0?void 0:n.name)){this.filter={...this.filter,[(t=(l=i.detail)===null||l===void 0?void 0:l.payload)===null||t===void 0?void 0:t.name]:((d=(e=i===null||i===void 0?void 0:i.detail)===null||e===void 0?void 0:e.payload)===null||d===void 0?void 0:d.value)||null};this.services=await s(this.query,(i=>{var o,n;return(n=(o=this.filter)===null||o===void 0?void 0:o.tab)===null||n===void 0?void 0:n.includes(i===null||i===void 0?void 0:i.tab)}))}}async toggleService(i){var o,n;i.preventDefault();i.stopPropagation();const l=this.selectedIds;console.log(i);if(this.selectedIds.includes((o=i===null||i===void 0?void 0:i.target)===null||o===void 0?void 0:o.value)){l.splice(this.selectedIds.indexOf(i.target.value),1)}else{l.push((n=i===null||i===void 0?void 0:i.target)===null||n===void 0?void 0:n.value)}this.selectedIds=l;console.log(this.selectedIds)}async openCodeEditor(i,o){const n=await a.create({component:"fireenjin-mx-modal-code-editor",cssClass:"fireenjin-mx-modal-code-editor-wrapper",componentProps:{pageTitle:i==="autofill"?"Set Auto-Fill":"Set Smart Scoping",name:i,language:"json",value:o,endpoint:"",documentId:true}});await n.present();return n}async componentDidLoad(){if(!(n===null||n===void 0?void 0:n.isBrowser))return;this.services=await s(this.query)}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:((i=e===null||e===void 0?void 0:e.claims)===null||i===void 0?void 0:i.tester)||((o=e===null||e===void 0?void 0:e.claims)===null||o===void 0?void 0:o.admin)?[{name:"tab",label:"Tab",icon:"albums",multiple:true,options:d(),value:(n=this.filter)===null||n===void 0?void 0:n.tab}]:null}),l("ion-card",null,l("ion-list",{class:"ion-no-padding"},l("fireenjin-pagination",{approxItemHeight:84,results:this.services,renderItem:i=>l("ion-item",{href:`/services/${i.id}`,detail:true},l("ion-checkbox",{id:`toggle.${(i===null||i===void 0?void 0:i.id)||""}`,slot:"start",onClick:i=>this.toggleService(i),value:i===null||i===void 0?void 0:i.id,checked:this.selectedIds.includes(i===null||i===void 0?void 0:i.id)}),l("ion-label",null,l("h2",null,(i===null||i===void 0?void 0:i.name)||""," "),l("div",null,Object.entries((i===null||i===void 0?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(c(i,"createdAt","updatedAt"))))})},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"))))]}};v.style=u;export{v as app_service_list};
//# sourceMappingURL=p-b7dad3e4.entry.js.map