import { resourceKeyList } from '@cloudbeaver/core-sdk' ; import type { MetadataMap } from '@cloudbeaver/core-utils' ; import type { NavNode } from '../shared/NodesManager/EntityTypes' ; import type { NavNodeInfoResource } from '../shared/NodesManager/NavNodeInfoResource' ; import type { IElementsTreeFilter , ITreeNodeState } from './useElementsTree' ; function isDefined < T > ( val ) { return val !== undefined && val !== null ; } export function elementsTreeNameFilter ( resource ) { return ( node , children , state ) => { const nodeState = state . get ( node . id ) ; if ( nodeState . filter === '' ) { return children ; } const nodes = resource . get ( resourceKeyList ( children ) ) . filter ( isDefined ) . filter ( child => child . name ?. toLowerCase ( ) . includes ( nodeState . filter . toLowerCase ( ) ) ) ; return nodes . map ( node => node . id ) ; } ; }