'use strict';
import { addPaging } from '../../../../../fd-toolbox/odata/odataconfig.js';
import { filterOperatorTypes } from '../../../../../fd-toolbox/enums/enums.js';
import { getResourceDescriptionValue } from '../../../core/resource-description/resource-description.js';
import { fetchResources } from '../../../resource-providers.js';
import { fetchUiResourceMeta } from '../../../ui-meta-providers.js';
import { getObjectValues } from '../../../../../fd-toolbox/lib/utils.js';
import { elements } from '../../../../../fd-toolbox/constants/elements.js';
import { getElementId } from '../../../../../fd-toolbox/html/element-ids.js';

var __defProp=Object['defineProperty'],__name=(_0x3bd6b7,_0x4395a8)=>__defProp(_0x3bd6b7,'name',{'value':_0x4395a8,'configurable':!![]});function getBrowserDialogTableId(_0x299cb0=-0x1*0xbba+-0x1c0c+0xd42*0x3){return getElementId(elements['browserDialog']['browserDialogElementId'],elements['table']['tableElementId'],_0x299cb0);}__name(getBrowserDialogTableId,'getBrowserDialogTableId');async function onInitBrowserDialog(_0x1d1461,_0x382dcb,_0x514fc5,_0x2c8132,_0x1b9174,_0x124eab,_0x5e5070){const _0x444b09=_0x382dcb['relation']['relatedResourceName'],_0x6f0616=await fetchUiResourceMeta(_0x444b09);_0x1d1461(_0x6f0616),await refreshBrowserDialogResources(_0x514fc5,_0x2c8132,_0x1b9174,_0x124eab,_0x6f0616['resourceMeta'],_0x5e5070);}__name(onInitBrowserDialog,'onInitBrowserDialog');async function onItemSelected(_0x2d03b9,_0x252e8f,_0x2e2967){const _0x9f6ddb=await getResourceDescriptionValue(_0x252e8f,_0x2d03b9),_0xbf1cc6={'id':_0x2d03b9['id'],'description':_0x9f6ddb};_0x2e2967(_0xbf1cc6);}__name(onItemSelected,'onItemSelected');function onBrowserDialogPaging(_0x355587,_0x2cd0d7,_0x34df55,_0x373fd2,_0x3e9094,_0x36ea26,_0x51d7aa){_0x34df55(addPaging(_0x373fd2,_0x355587['pageSize'],_0x355587['pagingSkip'])),refreshBrowserDialogResources(_0x2cd0d7,_0x34df55,_0x373fd2,_0x3e9094,_0x36ea26,_0x51d7aa);}__name(onBrowserDialogPaging,'onBrowserDialogPaging');async function refreshBrowserDialogResources(_0x498865,_0x3d6b88,_0x45439d,_0x27d25f,_0x19fec4,_0x23d39e){let _0x563fcd=_0x27d25f();if(_0x563fcd){_0x45439d['filters']=getObjectValues(_0x563fcd)['filter'](_0x44c421=>_0x44c421['rightSide']!==filterOperatorTypes['none']),_0x3d6b88(_0x45439d);const _0x16dc73=await fetchResources(_0x19fec4['resourceName'],_0x45439d);_0x498865(_0x16dc73?_0x16dc73['filter'](_0x3a51d5=>!_0x23d39e?.['includes'](_0x3a51d5['id'])):[]);}}__name(refreshBrowserDialogResources,'refreshBrowserDialogResources');async function setBrowserDialogResourceDescription(_0x3b001f,_0x435069,_0x4cb738,_0x2d50cf){if(_0x2d50cf&&_0x4cb738){const _0x6e6ce2=_0x3b001f['find'](_0x5e67af=>_0x5e67af['id']===_0x435069);if(_0x6e6ce2){const _0x5f26e7=await getResourceDescriptionValue(_0x4cb738,_0x6e6ce2);_0x2d50cf(_0x5f26e7);}}}__name(setBrowserDialogResourceDescription,'setBrowserDialogResourceDescription');

export { getBrowserDialogTableId, onBrowserDialogPaging, onInitBrowserDialog, onItemSelected, refreshBrowserDialogResources, setBrowserDialogResourceDescription };
