import{j as b,a as w,gV as j,g7 as L,af as k,r as a,gW as A}from"./index-d6499a22.js";import{f as l}from"./utils-2cbbb028.js";const v={label:{"> div":{py:0,pl:"4px",pr:"8px",alignItems:"center"},"> div:hover":{div:{backgroundColor:"grayShade3",borderColor:"transparent"}}}},M={label:{div:{backgroundColor:"white"}}},O=({children:e,icon:u,white:m=!1,...i})=>b.jsx(w,{sx:m?j(M,v):v,alignItems:"center",children:b.jsxs(L,{...i,children:[b.jsx(k,{p:"4px !important",size:"md",icon:u}),e]})});var P=(e=>(e[e.primary=0]="primary",e[e.partition=1]="partition",e[e.label=2]="label",e[e.type=3]="type",e[e.onlineType=4]="onlineType",e[e.eventTime=5]="eventTime",e[e.null=6]="null",e))(P||{});const R=(e,u="",m=!1,i="")=>{const[p,f]=a.useState([]),[h,T]=a.useState([]),[n,g]=a.useState(6),[c,s]=A({search:u}),C=a.useCallback(({target:t})=>{const r=t.value;s(r?{search:r}:{})},[s]),S=a.useCallback(t=>()=>{g(r=>r===t?6:t)},[g]),d=a.useCallback(()=>{s({}),f([]),T([]),g(6)},[s]),y=a.useMemo(()=>{const t=Array.from(new Set(e.map(({type:o})=>o)));let r=[];return m&&(r=Array.from(new Set(e.map(({onlineType:o})=>o)))),{offlineTypes:t,onlineTypes:r}},[e]),x=a.useMemo(()=>{let t=e;return n===1&&(t=l(t,!0,"partition")),n===0&&(t=l(t,!0,"primary")),n===2&&(t=l(t,!0,"label")),t=l(t,p,"type"),t=l(t,h,"onlineType"),n===5&&(t=t.filter(({name:r})=>r.toLowerCase()===i)),t.filter(({name:r})=>{const o=(c.get("search")||"").toLowerCase();return r.toLowerCase().includes(o)})},[e,c,n,p,h,i]);return a.useMemo(()=>({dataFiltered:x,types:y.offlineTypes,onlineTypes:y.onlineTypes,search:c.get("search")||"",typeFilters:p,onlineTypeFilters:h,keyFilter:n,onTypeFiltersChange:f,onOnlineTypeFiltersChange:T,onSearchChange:C,onToggleKey:S,onReset:d}),[x,y,c,p,n,f,C,S,d])};export{O as F,P as K,R as u};
