'use strict';
'use client';
import { isUuidSet, isEmptyNullOrUndefined, isNullOrUndefined } from '../../../../fd-toolbox/functions/value-checking-functions.js';
import { getResourceDescriptionValue } from '../../core/resource-description/resource-description.js';
import { fetchResource } from '../../resource-providers.js';
import { fetchUiResourceMeta } from '../../ui-meta-providers.js';
import { createEmptyShortResourceDescriptor } from './short-resource-descriptor.js';
import { emptyUuid } from '../../../../fd-toolbox/constants/constants.js';

var __defProp=Object['defineProperty'],__name=(_0x308b7b,_0x51cc69)=>__defProp(_0x308b7b,'name',{'value':_0x51cc69,'configurable':!![]});function onUpdateBrowserInput(_0xb941a1,_0x4b17be,_0x166df3,_0xa590a7){if(_0xb941a1===''){const _0x143601=createEmptyShortResourceDescriptor();_0x4b17be(_0x143601),setBrowserDescription(_0x143601,_0x166df3),_0xa590a7?.(_0x143601['id']);}else _0x166df3(_0xb941a1);}__name(onUpdateBrowserInput,'onUpdateBrowserInput');function setBrowserDescription(_0x56f831,_0x233240){if(_0x56f831['description'])_0x233240(_0x56f831['description']);else isUuidSet(_0x56f831['id'])?_0x233240('Selected'):_0x233240('');}__name(setBrowserDescription,'setBrowserDescription');async function writeBrowserValue(_0x2b095c,_0x580510,_0x5c4fe4){if(isEmptyNullOrUndefined(_0x2b095c)){const _0x1c72dc=createEmptyShortResourceDescriptor();setBrowserDescription(_0x1c72dc,_0x5c4fe4);}else {const _0x561fbd=await getBrowserResourceMetaIfNeeded(_0x580510,void(-0x15*-0x18b+0x2140+-0x41a7));await getResourceDescriptionAndSetDescription(_0x2b095c,_0x5c4fe4,_0x561fbd);}}__name(writeBrowserValue,'writeBrowserValue');async function handleLoadRelatedResourceDescription(_0x4d29c8,_0xff6c08,_0x62855b,_0x1449ba,_0x49055c){const _0x4ff18e=_0x49055c??_0x1449ba?.['getValues'](_0x4d29c8['name']);_0x4ff18e&&(await writeBrowserValue(_0x4ff18e,_0x4d29c8,_0xff6c08),_0x62855b(!![]));}__name(handleLoadRelatedResourceDescription,'handleLoadRelatedResourceDescription');async function getBrowserResourceMetaIfNeeded(_0x24dd49,_0x26b680){if(!isNullOrUndefined(_0x26b680))return _0x26b680;const _0x5964b5=await fetchUiResourceMeta(_0x24dd49['relation']['relatedResourceName']);return _0x5964b5['resourceMeta'];}__name(getBrowserResourceMetaIfNeeded,'getBrowserResourceMetaIfNeeded');async function getResourceDescriptionAndSetDescription(_0x574a1c,_0x40451c,_0x6ed145){if(!_0x574a1c||_0x574a1c===emptyUuid)return void(0xe06+0x93e+-0x1744);const _0x5cffe0=await fetchResource(_0x6ed145,_0x574a1c);if(_0x5cffe0){const _0x4b958f={'id':_0x5cffe0['id'],'description':await getResourceDescriptionValue(_0x6ed145,_0x5cffe0)};setBrowserDescription(_0x4b958f,_0x40451c);}return _0x5cffe0;}__name(getResourceDescriptionAndSetDescription,'getResourceDescriptionAndSetDescription');

export { handleLoadRelatedResourceDescription, onUpdateBrowserInput, setBrowserDescription, writeBrowserValue };
