import{r as n,j as o}from"./vendor-react-wBh_31cN.js";import{e as E,a as S,r as C}from"./index-BKr2rJhV.js";import{u as T,c as w,d as N}from"./index-BUCjeAe2.js";import{u as G,M as Q,a as $,b as z}from"./useMonitoringConfigsFilter-C4vc8_mN.js";import{D as H}from"./relativeCheckTime-B4fUkGni.js";import{t as h}from"./toast-3g7Fh-a0.js";import{d as q}from"./dumbPluralize-CcxDsNiu.js";import{F as A}from"./FVPanel-Be3nTlMo.js";import{c as J}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"./sortBy-DS9fyPwj.js";import"./mergeRight-Cv2eiGXV.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"./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"./index-CHt3semm.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"./useUserPermissions-BVMFDLlq.js";import"./selectors-CMD4o3wq.js";import"./index-DkvW68Om.js";import"./useCurrentProject-C6qZaZgv.js";import"./useProject-FSnHbCQX.js";import"./index-BeaoFlb1.js";import"./project-eQY1xQe-.js";import"./ResourceNotFound-DwuevSJ8.js";import"./index-DJIjy7qt.js";import"./uniq-Cy5NeM3Y.js";import"./useProjectNavigate-5znX7Ojg.js";import"./useProjectRole-UlQXu1Cp.js";const xo=()=>{const{id:m,fsId:s,fvName:r,fvVersion:e}=J(),{data:p=[],isLoading:l,refetch:F}=T({pId:m,fsId:s,fvName:r,fvVersion:e},{selectFromResult:E({data:S([],"items")})}),a=p.map(i=>i.id),{data:c={},isLoading:g,refetch:M}=w({pId:m,fsId:s,fvName:r,fvVersion:e,configIds:a},{skip:a.length===0}),j=n.useMemo(()=>{const i={};return Object.entries(c).forEach(([V,B])=>{i[+V]=B.shiftedFeatureCount}),i},[c]),{filteredConfigs:v,filterState:x,updateField:D}=G(p),[b,f]=n.useState(!1),[t,y]=n.useState(void 0),[u,{isLoading:I}]=N(),L=n.useCallback(i=>{y(i),f(!0)},[]),k=n.useCallback(()=>{t&&u({pId:m,fsId:s,fvName:r,fvVersion:e,configId:t.id}).unwrap().then(()=>{f(!1),h.success(`Monitoring config '${t.name}' deleted successfully`)}).catch(()=>{h.error(`Failed to delete monitoring config '${t.name}'`)})},[t,u,s,r,e,m]),d=l||g,O=o.jsx(z,{filterState:x,updateField:D}),P={value:p.length,label:q("monitoring configuration",p.length)},R=o.jsx($,{isFetching:d,onRefresh:()=>{F(),a.length>0&&M()}});return o.jsxs(o.Fragment,{children:[o.jsx(H,{isOpen:b,onClose:()=>f(!1),configName:(t==null?void 0:t.name)??"",onConfirm:k,isDeleting:I}),o.jsx(A,{path:C.project.featureView.featureMonitoringList,filterToolbar:O,count:P,tools:R,isFetchingContent:d,children:()=>o.jsx(Q,{monitoringConfigs:v,shiftCountByConfigId:j,isResultsLoading:g,configHrefProps:{to:C.project.featureView.featureMonitoring,params:{fvName:r,fvVersion:e}},isLoading:l,onClickDelete:L})})]})};export{xo as default};
