'use strict';
import { fetchUiResourceMeta, fetchUiResourceMetas } from './ui-meta-providers.js';
import { getObjectValues } from '../../fd-toolbox/lib/utils.js';

var __defProp=Object['defineProperty'],__name=(_0x5af097,_0x1a36be)=>__defProp(_0x5af097,'name',{'value':_0x1a36be,'configurable':!![]});async function fetchResourceMeta(_0x56e83e){const _0x5a9c79=fetchUiResourceMeta(_0x56e83e),_0xe63640=await _0x5a9c79;return _0xe63640['resourceMeta'];}__name(fetchResourceMeta,'fetchResourceMeta');async function fetchResourceMetas(_0x4a5de7){const _0x3d9f5b=await fetchUiResourceMetas(_0x4a5de7),_0x19cc17={};for(const _0x492da4 of Object['values'](_0x3d9f5b)){_0x19cc17[_0x492da4['resourceMeta']['resourceName']]=_0x492da4['resourceMeta'];}return _0x19cc17;}__name(fetchResourceMetas,'fetchResourceMetas');async function getRelatedResourcesMetas(_0x4ab209){const _0x26e94a=[];for(const _0x389672 of getObjectValues(_0x4ab209['properties'])){if(_0x389672['relation']?.['relatedResourceName']){const _0x255efc=await fetchResourceMeta(_0x389672['relation']['relatedResourceName']);_0x255efc&&_0x26e94a['push'](_0x255efc);}}return _0x26e94a;}__name(getRelatedResourcesMetas,'getRelatedResourcesMetas');async function getManyToManyRelatedPropertyMetas(_0x44d072){let _0x3d801a=[];for(const _0x435b95 of Object['values'](_0x44d072['resourceMeta']['properties'])){if(_0x435b95['relation']?.['manyToManyInfo']){const _0x4fbcb8=_0x435b95['relation']['manyToManyInfo']['firstResourceName']===_0x44d072['resourceMeta']['resourceName']?_0x435b95['relation']['manyToManyInfo']['manyToManySecondPropertyName']:_0x435b95['relation']['manyToManyInfo']['manyToManyFirstPropertyName'],_0x4e6d93=await fetchUiResourceMeta(_0x435b95['relation']?.['manyToManyInfo']?.['manyToManyResourceName']);if(_0x4e6d93){const _0x326f44=_0x4e6d93['resourceMeta']['properties'][_0x4fbcb8];_0x326f44&&_0x3d801a['push'](_0x326f44);}}}if(_0x3d801a['length']===-0x9a3*0x3+0x1154*-0x2+-0x1*-0x3f91){const _0x22e7f3=await fetchManyToManyRelatedPropertyMetas(_0x44d072['resourceMeta']);_0x3d801a=_0x22e7f3;}return _0x3d801a;}__name(getManyToManyRelatedPropertyMetas,'getManyToManyRelatedPropertyMetas');async function fetchManyToManyRelatedPropertyMetas(_0x4737d9){const _0x19130a=new Set(),_0x1803de=new Set();for(const _0x3d2b48 of Object['values'](_0x4737d9['properties'])){const _0xfaf77e=_0x3d2b48['relation'];if(_0xfaf77e?.['manyToManyInfo']){const _0x25c143=_0xfaf77e['manyToManyInfo']['manyToManyResourceName'],_0x3a7b90=_0xfaf77e['manyToManyInfo']['manyToManySecondPropertyName'];_0x19130a['add'](_0x25c143),_0x1803de['add'](_0x3a7b90);}}const _0x2c4da9=await fetchUiResourceMetas([..._0x19130a]);return Object['values'](_0x2c4da9)['filter'](_0x45523d=>_0x19130a['has'](_0x45523d['resourceMeta']['resourceName']))['flatMap'](_0x501705=>Object['values'](_0x501705['resourceMeta']['properties'])['filter'](_0x32d44c=>_0x1803de['has'](_0x32d44c['name'])));}__name(fetchManyToManyRelatedPropertyMetas,'fetchManyToManyRelatedPropertyMetas');

export { fetchResourceMeta, fetchResourceMetas, getManyToManyRelatedPropertyMetas, getRelatedResourcesMetas };
