import{r as e,j as o}from"./vendor-react-wBh_31cN.js";import{e as B,h as E,a as S,r as d}from"./index-dNe6i2rS.js";import{u as T,M as N,a as Q,b as $}from"./useMonitoringConfigsFilter-Dihz27_R.js";import{d as w}from"./dumbPluralize-CcxDsNiu.js";import{D as z}from"./relativeCheckTime-U3FQvqU-.js";import{t as h}from"./toast-wiGcevcF.js";import{b as H,u as q,d as A}from"./index-CcynNqTL.js";import{F as J}from"./FeatureGroupLayout-BVhmL1GV.js";import{c as K}from"./vendor-router-D1GqFWiT.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";import"./badge-UCnweWGd.js";import"./data-table-Mt0DWBPO.js";import"./checkbox-BlA4MwH9.js";import"./skeleton-C7BaXix8.js";import"./BlinkingDots-CJK9OJE3.js";import"./LoadMore-Bg-Y-iGB.js";import"./table-a0YeQrHM.js";import"./tooltip-DFFgUYh6.js";import"./icon-button-BZeFL7T7.js";import"./dropdown-menu-DCcmtBGI.js";import"./time-utils-CQYZ5msB.js";import"./addDays-Cdit4yPz.js";import"./always-oSAuSdys.js";import"./init-Dq_gEBi9.js";import"./concat-CTXo1gGM.js";import"./formatDistance-B6o-SXVU.js";import"./index-ZWn4qLiW.js";import"./sortBy-COer1Ia5.js";import"./mergeRight-D1nsCm60.js";import"./index-dHd2aGu6.js";import"./join-oazOKFfj.js";import"./includes-ucXR_9jq.js";import"./add-SI0q72Q7.js";import"./EnableConfigButton-dv9GX3tn.js";import"./monitoring-config-utils-Di6JXNMn.js";import"./theme-colors-BFneJNsI.js";import"./countBy-B-JkTAeT.js";import"./complement-BEggNnIO.js";import"./not-C0YaysLC.js";import"./whereEq-qRDwP6XF.js";import"./where-5NF5DPVb.js";import"./any-BVxDk2A0.js";import"./input-DFI7JniT.js";import"./label-gPWmc6ow.js";import"./editable-select-DItn4ZHW.js";import"./confirmation-dialog-C7dws5K4.js";import"./useCopyToClipboard-DfzwgDFE.js";import"./useNotifier-BGMn6HaH.js";import"./notifications-5miqOdlG.js";import"./NoData-BtM2pAIA.js";import"./Panel-D_anPZvo.js";import"./MissingMandatoryTagsWarning-BHZy5VlV.js";import"./combobox-QqI9aNup.js";import"./input-group-gxy3DSmS.js";import"./textarea-BJVuSob1.js";import"./vendor-recharts-DmJlpLaF.js";import"./list-page-header-Fc18Qd7m.js";import"./animated-progress-DY4TkPAt.js";import"./separator-CxqNNMXg.js";import"./value-7N0Keti9.js";import"./metadata-field-Uf1PM1Ss.js";import"./CardActionButton-9dnJFRFw.js";import"./Deprecated-DEh1iT37.js";import"./uniqBy-6oWnYXMs.js";import"./sort-qlseijG5.js";import"./ascend-DedmOJV5.js";import"./useFeatureGroupView-DzipL71b.js";import"./selectors-DK1_X0Cd.js";import"./index-DLI8oDiK.js";import"./useFeatureGroupVersions-NTqLwoPU.js";import"./project-BNFK3R_4.js";import"./useUserPermissions-Bu9Wyk8A.js";import"./useCurrentProject-CTMLbmkf.js";import"./useProject-BbrP3CX5.js";import"./index-DURBtSjL.js";import"./project-eQY1xQe-.js";const jo=()=>{const{id:n,fgId:r,fsId:s}=K(),{data:m=[],isLoading:f,refetch:C}=H({pId:n,fsId:s,fgId:r},{selectFromResult:B({data:E(S([],"items"))})}),p=m.map(i=>i.id),{data:g={},isLoading:l,refetch:F}=q({pId:n,fsId:s,fgId:r,configIds:p},{skip:p.length===0}),M=e.useMemo(()=>{const i={};return Object.entries(g).forEach(([R,v])=>{i[+R]=v.shiftedFeatureCount}),i},[g]),{filteredConfigs:j,filterState:x,updateField:b}=T(m),[D,a]=e.useState(!1),[t,y]=e.useState(void 0),[u,{isLoading:I}]=A(),L=e.useCallback(i=>{y(i),a(!0)},[]),G=e.useCallback(()=>{t&&u({pId:n,fsId:s,fgId:r,configId:t.id}).unwrap().then(()=>{a(!1),h.success(`Monitoring config '${t.name}' deleted successfully`)}).catch(()=>{h.error(`Failed to delete monitoring config '${t.name}'`)})},[t,u,r,s,n]),c=f||l,k=o.jsx($,{filterState:x,updateField:b}),O={value:m.length,label:w("monitoring configuration",m.length)},P=o.jsx(Q,{isFetching:c,onRefresh:()=>{C(),p.length>0&&F()}});return o.jsxs(o.Fragment,{children:[o.jsx(z,{isOpen:D,onClose:()=>a(!1),configName:(t==null?void 0:t.name)??"",onConfirm:G,isDeleting:I}),o.jsx(J,{route:d.project.featureGroup.featureMonitoringList,pathnamePostFix:"/feature-monitoring",filterToolbar:k,count:O,tools:P,isFetching:c,children:o.jsx(N,{monitoringConfigs:j,configHrefProps:{to:d.project.featureGroup.featureMonitoring,params:{fgId:r}},shiftCountByConfigId:M,isResultsLoading:l,isLoading:f,onClickDelete:L})})]})};export{jo as default};
