'use strict';
import { searchableFilters } from '../../fd-component-toolbox/search/filter-names-constants.js';
import { searchAcrossResources } from '../../meta/server/meta-core/crud/search.js';
import { getUserId } from '../../meta/server/auth/users/current-user-id-provider.js';
import { permissionTypes } from '../../meta/core/resources/enums/permission-enums.js';
import { getResourceListUrl } from '../../meta/services/meta-navigations.js';
import { getUserPermissions, hasPermission } from '../../meta/server/permission/permission-checker.js';
import { crudActions } from '../../../fd-toolbox/enums/enums.js';

var __defProp=Object['defineProperty'],__name=(_0x2d57fa,_0x42eaaa)=>__defProp(_0x2d57fa,'name',{'value':_0x42eaaa,'configurable':!![]});async function getSearchableResourceResults(_0x4ec697,_0x2a1017){const _0x2fece1=_0x2a1017['filter'](_0x17abd0=>_0x17abd0!==searchableFilters['screens']);if(_0x2fece1['length']===0xfad*0x1+-0x125a+0x2ad)return [];return searchAcrossResources(_0x4ec697,_0x2fece1);}__name(getSearchableResourceResults,'getSearchableResourceResults');async function getSearchScreensResult(_0x400b96,_0x574789){const _0x285615=[];if(_0x574789['includes'](searchableFilters['screens'])){const _0x37b898=await getUserId(),_0x4f2aaa=await getUserPermissions(_0x37b898),_0x7e91f4=_0x4f2aaa['resourcePermissions'];if(_0x7e91f4)for(const _0x26b38f of Object['values'](_0x7e91f4)){_0x26b38f['type']===permissionTypes['resource']&&(!_0x26b38f['resourceId']||await hasPermission(_0x26b38f['resourceName'],crudActions['view'],_0x37b898))&&isPermissionMatchingQuery(_0x26b38f,_0x400b96)&&_0x285615['push']({'resourceName':_0x26b38f['resourceName'],'displayName':_0x26b38f['displayName'],'resourceListUrl':getResourceListUrl(_0x26b38f['resourceName'])});}}return _0x285615;}__name(getSearchScreensResult,'getSearchScreensResult');function isPermissionMatchingQuery(_0x168da7,_0x81994d){return _0x168da7['displayName']['toLowerCase']()['startsWith'](_0x81994d['toLowerCase']());}__name(isPermissionMatchingQuery,'isPermissionMatchingQuery');

export { getSearchScreensResult, getSearchableResourceResults };
