import{j as y,a as j,h7 as k,ex as A,ap as P,d as D,r as o,d0 as E}from"./index-_eM6l4Nf.js";const w={label:{"> div":{py:0,pl:"4px",pr:"8px",alignItems:"center"},"> div:hover":{div:{backgroundColor:"grayShade3",borderColor:"transparent"}}}},I={label:{div:{backgroundColor:"white"}}},O=({children:e,icon:n,white:u=!1,size:i="md",...l})=>y.jsx(j,{sx:u?k(I,w):w,alignItems:"center",children:y.jsxs(A,{...l,children:[y.jsx(P,{p:"4px !important",size:i,icon:n||D.cross,sx:!n&&{visibility:"hidden",width:"0px",mr:"-15px"}}),e]})}),p=(e,n,u)=>e.filter(({[u]:i})=>Array.isArray(n)?n.length?n.includes(i):e:n===i);var M=(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.onDemand=6]="onDemand",e[e.feature=7]="feature",e[e.null=8]="null",e))(M||{});const R=(e,n="",u=!1,i="")=>{const[l,f]=o.useState([]),[h,b]=o.useState([]),[a,d]=o.useState(8),[m,c]=E({search:n}),x=o.useCallback(({target:r})=>{const t=r.value;c(t?{search:t}:{})},[c]),C=o.useCallback(r=>()=>{d(t=>t===r?8:r)},[d]),T=o.useCallback(()=>{c({}),f([]),b([]),d(8)},[c]),g=o.useMemo(()=>{const r=Array.from(new Set(e.filter(({name:s})=>s!=="Feature Group").map(({type:s})=>s)));let t=[];return u&&(t=Array.from(new Set(e.map(({onlineType:s})=>s)))),{offlineTypes:r,onlineTypes:t}},[e]),S=o.useMemo(()=>{let r=e;return a===1&&(r=p(r,!0,"partition")),a===6&&(r=p(r,!0,"onDemand")),a===0&&(r=p(r,!0,"primary")),a===2&&(r=p(r,!0,"label")),a===7&&(r=r.filter(t=>{const s=t.primary===!0,v=t.partition===!0,L=t.name.toLowerCase()===i.toLowerCase();return!s&&!v&&!L})),r=p(r,l,"type"),r=p(r,h,"onlineType"),a===5&&(r=r.filter(({name:t})=>t.toLowerCase()===i)),r.filter(({name:t})=>{const s=(m.get("search")||"").toLowerCase();return t.toLowerCase().includes(s)||t.includes("Feature Group")})},[e,m,a,l,h,i]);return o.useMemo(()=>({dataFiltered:S,types:g.offlineTypes,onlineTypes:g.onlineTypes,search:m.get("search")||"",typeFilters:l,onlineTypeFilters:h,keyFilter:a,onTypeFiltersChange:f,onOnlineTypeFiltersChange:b,onSearchChange:x,onToggleKey:C,onReset:T}),[S,g,m,l,a,f,x,C,T])};export{O as F,M as K,p as f,R as u};
