import{j as e,q as r,aH as X,v as Z,ch as Y,F as u,be as $,r as l,p as ee,D as te,h8 as se,ed as y,d as v,em as ae,en as ne,bl as q,cg as B}from"./index-C6OVXshM.js";import{F as re}from"./FilterResult-DI0HiAXB.js";import{s as d,S as w}from"./sort-BOLIcXtz.js";import{u as ie}from"./Deprecated-C2s2xtW5.js";import{F as oe,K as H,u as le}from"./useFeatureFilters-C0tQqz2i.js";import{F as ce}from"./FeatureFilters-CJeOaW51.js";import{m as xe}from"./min-BF2EoXpM.js";const pe=(t,c,a=0)=>{const s=t.length,i=a&&a<s?a:s,n=i*c;return{data:t.slice(n-i,n>s?s:n),totalPages:s?Math.ceil(s/i):1}},me={"name (A -> Z)":["name",d.string,w.asc],"name (Z -> A)":["name",d.string,w.desc]},he=({search:t,onSearchChange:c,typeFilters:a,onTypeFiltersChange:s,types:i,onToggleKey:n,keyFilter:k,sortKey:o,setSortKey:g})=>e.jsx(r,{width:"100%",flexDirection:"column",alignItems:"center",children:e.jsxs(r,{width:"100%",children:[e.jsx(X,{variant:"white",value:t,icon:Z.glass,placeholder:"Find feature",onChange:c}),e.jsx(Y,{maxWidth:"180px",width:"max-content",ml:"15px",variant:"white",isMulti:!0,value:a,options:i,placeholder:"type",onChange:s,noDataMessage:"type all"}),e.jsx(u,{ml:"10px",sx:{label:{div:{bg:"white"}}},children:e.jsx(oe,{icon:Z.target,checked:k===H.label,onChange:n(H.label),children:"Label (target) features only"})}),e.jsx($,{label:"sort by",labelPosition:"inline",width:"max-content",variant:"white",value:o,ml:"auto",options:Object.keys(me),onChange:g})]})}),R={"10 features":10,"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},ue={"name (A -> Z)":["name",d.string,w.asc],"name (Z -> A)":["name",d.string,w.desc]},we=({data:t,renderChild:c,extraActions:a,type:s=y.fg,...i})=>{var E;const[n,k]=l.useState("20 features"),[o,g]=l.useState("name (A -> Z)"),x=R[n]||1,[f,S]=l.useState(1),{isActiveFeatures:O,handleBasket:W,isSwitch:z}=ie(),{dataFiltered:j,types:I,search:T,typeFilters:L,keyFilter:P,onTypeFiltersChange:K,onSearchChange:M,onToggleKey:A,onReset:G}=le(t.features??[],"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:C,totalPages:p}=l.useMemo(()=>pe(j,f,x),[j,x,f]),m=l.useMemo(()=>{const h=ue[o];if(h){const[N,Q,U]=h;return ee(d(N,Q,U),b=>{const D=b.findIndex(te("name","Feature Group"));return D>0?[b[D],...b.filter((de,V)=>D!==V)]:b})(C)}return C},[C,o]),F=((E=t==null?void 0:t.features)==null?void 0:E.length)??0,_=j.length,J=F!==_;return l.useEffect(()=>{S(1)},[x]),e.jsxs(r,{width:"100%",flexDirection:"column",alignItems:"center",children:[e.jsxs(r,{sx:{...se.stickyHeader},pt:"20px",mt:"-20px",children:[s===y.fg&&e.jsx(ce,{search:T,typeFilters:L,types:I,keyFilter:P,enableStorageConnectorFilter:!1,sortKey:o,setSortKey:g,onToggleKey:A,onSearchChange:M,onTypeFiltersChange:K}),s===y.td&&e.jsx(he,{search:T,typeFilters:L,types:I,keyFilter:P,sortKey:o,setSortKey:g,onToggleKey:A,onSearchChange:M,onTypeFiltersChange:K}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",children:[e.jsxs(r,{children:[e.jsx(v,{primary:!0,px:"5px",children:xe(x,F)}),e.jsx(v,{children:"features displayed out of"}),e.jsx(v,{primary:!0,px:"5px",children:F}),e.jsx(v,{children:"features"})]}),a&&e.jsx(r,{ml:"10px",children:a}),z&&s===y.fg&&e.jsx(u,{ml:"10px",children:e.jsx(ae,{mode:ne.bulk,possible:m.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${m.length} features`,handleClick:W(m,t),inBasket:O(m,t)})}),e.jsx(u,{ml:"auto",sx:{span:{mt:"4px"}},children:e.jsx($,{variant:"white",value:n,label:"show",labelPosition:"side",options:Object.keys(R),onChange:k})}),p>1&&e.jsx(u,{sx:{span:{marginTop:"4px"}},children:e.jsx(q,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(B,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",mb:"20px",flexDirection:"column",width:"100%"},...i,children:[m.map(h=>e.jsx(u,{children:c({type:s,parent:t,data:h})},h.name)),F>x&&e.jsx(q,{mt:"10px",mb:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(B,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})}),J&&e.jsx(re,{subject:"features",result:j.length,onReset:G})]})]})};export{we as F};
