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-BKr2rJhV.js";import{u as T,M as N,a as Q,b as $}from"./useMonitoringConfigsFilter-C4vc8_mN.js";import{d as w}from"./dumbPluralize-CcxDsNiu.js";import{D as z}from"./relativeCheckTime-B4fUkGni.js";import{t as h}from"./toast-3g7Fh-a0.js";import{b as H,u as q,d as A}from"./index-CHt3semm.js";import{F as J}from"./FeatureGroupLayout-CZQFBHKM.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-nyizWwTN.js";import"./data-table-Cd-8SUjZ.js";import"./checkbox-DbZXziG0.js";import"./skeleton-BgYOfhyh.js";import"./BlinkingDots-CJK9OJE3.js";import"./LoadMore-Bg-Y-iGB.js";import"./table-CQMBoaty.js";import"./tooltip-Da8-EbK8.js";import"./icon-button-FETOk6q1.js";import"./dropdown-menu-CUHqMoVG.js";import"./time-utils-tK1noPML.js";import"./addDays-DjM7nKyN.js";import"./always-CtAmwIxm.js";import"./init-BDcDHUTz.js";import"./concat-AxOj0lUI.js";import"./formatDistance-qDinyJzC.js";import"./index-BUCjeAe2.js";import"./sortBy-DS9fyPwj.js";import"./mergeRight-Cv2eiGXV.js";import"./index-DdhqPQ_t.js";import"./join-DatdAzSt.js";import"./includes-D04d5Ytc.js";import"./add-DCChD-X4.js";import"./EnableConfigButton-DmKM5PcF.js";import"./monitoring-config-utils-tOp8yJ4T.js";import"./theme-colors-BFneJNsI.js";import"./countBy-DcWJUjKY.js";import"./complement-DGLuzEAM.js";import"./not-CZjOXJzQ.js";import"./whereEq-B89ULFn6.js";import"./where-Ba1ERwbI.js";import"./any-Db6pVWyk.js";import"./input-H6_qmzms.js";import"./label-Dnebucx5.js";import"./editable-select-Co_-YcCr.js";import"./confirmation-dialog-DFt7ZgUQ.js";import"./useCopyToClipboard-3DFwhniW.js";import"./useNotifier-BCEAoFCf.js";import"./notifications-x-pTFTQl.js";import"./NoData-jkjqmCYT.js";import"./Panel-epT8eD0X.js";import"./MissingMandatoryTagsWarning-DpOcErx3.js";import"./combobox-CcK1PxyF.js";import"./input-group-Z3Qmt3PL.js";import"./textarea-Co48BFy3.js";import"./vendor-recharts-DmJlpLaF.js";import"./list-page-header-DZysveul.js";import"./animated-progress-BdqEbBYd.js";import"./separator-2OqrG5Vy.js";import"./value-76ihWpF6.js";import"./metadata-field-B_vcklh-.js";import"./CardActionButton-Ch696ne3.js";import"./Deprecated-lKLzSfj7.js";import"./uniqBy-qYjau2JN.js";import"./sort-BIlPehKK.js";import"./ascend-D9xyxTFQ.js";import"./useFeatureGroupView-DA5FGFQv.js";import"./selectors-CMD4o3wq.js";import"./index-DkvW68Om.js";import"./useFeatureGroupVersions-BYs4kN2x.js";import"./project-D1vLPF8t.js";import"./useUserPermissions-BVMFDLlq.js";import"./useCurrentProject-C6qZaZgv.js";import"./useProject-FSnHbCQX.js";import"./index-BeaoFlb1.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};
