'use strict';
import { metaQueryParams } from '../../fd-toolbox/constants/meta-query-params.js';
import { apiGet } from '../../fd-toolbox/api/api-client.js';
import { apiPathNames } from '../../fd-toolbox/api/api-path-names.js';
import { setCache, getCache } from '../../fd-toolbox/cache/cache.js';
import { isMetaCacheEnabled } from './fd-meta-toolbox-service.js';
import { saveResourceMetaIdToCache, getResourceMetaId } from './services/resource-name-client-converter.js';

var __defProp=Object['defineProperty'],__name=(_0x5dceb5,_0xc07879)=>__defProp(_0x5dceb5,'name',{'value':_0xc07879,'configurable':!![]});const resourceMetaCachePrefix='UiResourceMeta';async function fetchUiResourceMeta(_0x15967c){if(isMetaCacheEnabled()){const _0x193039=getUiResourceMetaFromCache(_0x15967c);if(_0x193039)return _0x193039;}let _0x160e31=await apiGet(apiPathNames['uiMeta'],void(0x7*-0xf3+0xb9e*-0x1+0x1243),[{'name':metaQueryParams['resource'],'value':_0x15967c}]);const _0x158c7c=_0x160e31['data'];return saveResourceMetaIdToCache(_0x158c7c['resourceMeta']['resourceName'],_0x158c7c['resourceMeta']['id']),saveUiResourceMetaToCache(_0x158c7c),_0x158c7c;}__name(fetchUiResourceMeta,'fetchUiResourceMeta');async function fetchUiResourceMetas(_0x2d8459){const _0x4ab17b={},_0x15ced0=[],_0x1bc0d6={};if(isMetaCacheEnabled())for(const _0x2633ad of _0x2d8459){const _0x3aad7f=getUiResourceMetaFromCache(_0x2633ad);_0x3aad7f&&(_0x4ab17b[_0x2633ad]=_0x3aad7f,_0x15ced0['push'](_0x2633ad));}const _0x47bbde=new Set(_0x15ced0),_0x522cbb=[...new Set(_0x2d8459['filter'](_0x4cd7c9=>!_0x47bbde['has'](_0x4cd7c9)))];if(_0x522cbb['length']>0xa53*0x1+0x14bc+-0x1f0f){const _0x519baf=new URLSearchParams();for(const _0x9a03db of _0x522cbb){_0x519baf['append'](metaQueryParams['resource'],_0x9a03db);}const _0x163655=await apiGet(apiPathNames['uiMetas']+'?'+_0x519baf['toString']());for(const _0x57d0fe in _0x163655['data']){const _0x2c7db7=_0x163655['data'][_0x57d0fe];_0x1bc0d6[_0x57d0fe]=_0x2c7db7,setCache({'key':resourceMetaCachePrefix+'_'+_0x2c7db7['resourceMeta']['id'],'data':_0x2c7db7}),saveResourceMetaIdToCache(_0x2c7db7['resourceMeta']['resourceName'],_0x2c7db7['resourceMeta']['id']);}}return {..._0x1bc0d6,..._0x4ab17b};}__name(fetchUiResourceMetas,'fetchUiResourceMetas');function saveUiResourceMetaToCache(_0xf0b332){setCache({'key':resourceMetaCachePrefix+'_'+_0xf0b332['resourceMeta']['id'],'data':_0xf0b332});}__name(saveUiResourceMetaToCache,'saveUiResourceMetaToCache');function saveUiResourceMetasToCache(_0x375d07){_0x375d07['forEach'](saveUiResourceMetaToCache);}__name(saveUiResourceMetasToCache,'saveUiResourceMetasToCache');function getUiResourceMetaFromCache(_0x30a9db){const _0x4fd1f4=getResourceMetaId(_0x30a9db),_0x38f93a=getCache({'key':resourceMetaCachePrefix+'_'+_0x4fd1f4});return _0x38f93a;}__name(getUiResourceMetaFromCache,'getUiResourceMetaFromCache');

export { fetchUiResourceMeta, fetchUiResourceMetas, getUiResourceMetaFromCache, resourceMetaCachePrefix, saveUiResourceMetaToCache, saveUiResourceMetasToCache };
