'use strict';
import { isEmptyNullOrUndefined } from '../../../../fd-toolbox/functions/value-checking-functions.js';
import { oDataComparisonTypes, oDataFilterTypes } from '../../../../fd-toolbox/odata/odata-enums.js';
import { withUserIdProps } from '../../../../fd-toolbox/types/with-user-id.js';
import { hasPermission } from '../permission/permission-checker.js';
import { preventExpandsIfHasNoAccess } from './resource-provider-expands.js';

var __defProp=Object['defineProperty'],__name=(_0x1a1299,_0x5c4d88)=>__defProp(_0x1a1299,'name',{'value':_0x5c4d88,'configurable':!![]});function checkBelowLevelIfNoPermission(_0x117534,_0x1a0b7f,_0x2c12d5,_0x482157,_0x2f16fd,_0x58c799){let _0x3a634b;if(!_0x2c12d5&&!_0x58c799&&_0x2f16fd['auth']['belowLevelAllowedCrudByUserId']['includes'](_0x482157['crudAction'])&&!isEmptyNullOrUndefined(_0x117534)){const _0x36c58c={'type':oDataFilterTypes['guid'],'comparisonType':oDataComparisonTypes['equal'],'leftSide':withUserIdProps['userId'],'rightSide':_0x1a0b7f['toString']()};if(_0x117534['filters'])_0x117534['filters']['push'](_0x36c58c);else _0x117534['filters']=[_0x36c58c];}else !_0x2c12d5&&!_0x2f16fd['auth']['belowLevelAllowedCrudByUserId']['includes'](_0x482157['crudAction'])&&(_0x3a634b=[]);return _0x3a634b;}__name(checkBelowLevelIfNoPermission,'checkBelowLevelIfNoPermission');async function filterOutIfNoPermission(_0x322d42,_0x51c76b,_0x7ffdbe,_0x598a87,_0x11cedd,_0x553fbe){let _0x2e12f3=_0x322d42;if(!_0x51c76b){const _0xe6e8b3=[];for(let _0x48d290 of _0x322d42){_0x7ffdbe['resourceMetaId']=_0x11cedd['id'],_0x7ffdbe['resource']=_0x48d290;const _0x551e58=await hasPermission(_0x7ffdbe);if(_0x551e58){let _0x420815;_0x553fbe&&(_0x420815=await preventExpandsIfHasNoAccess(_0x553fbe,_0x598a87,_0x11cedd,_0x48d290)),_0x420815&&_0xe6e8b3['push'](_0x420815);}}_0x2e12f3=_0xe6e8b3;}return _0x2e12f3;}__name(filterOutIfNoPermission,'filterOutIfNoPermission');

export { checkBelowLevelIfNoPermission, filterOutIfNoPermission };
