'use strict';
import { changeFiltersForManyToOne, removeResourceRelation } from '../../relations/meta-relations.js';
import { apiAddRelation } from '../../edit-resource/services/property-metas.js';
import { getRelatedResourceMultiListItems } from './related-resources-component.js';

var __defProp=Object['defineProperty'],__name=(_0x3355e9,_0xd0c913)=>__defProp(_0x3355e9,'name',{'value':_0xd0c913,'configurable':!![]});async function onViewMultiListRelationChange(_0x225bf1,_0x312ef3,_0x83ae5a,_0x19ff8d){const _0x2cd8c1=_0x225bf1['propertyName'];changeFiltersForManyToOne(_0x225bf1['filters'],_0x19ff8d['id']),await apiAddRelation(_0x83ae5a,_0x312ef3['resourceName'],_0x2cd8c1,_0x19ff8d['id']);}__name(onViewMultiListRelationChange,'onViewMultiListRelationChange');async function onRelationUnassign(_0xe3f47f,_0x115567,_0x17784e,_0x4ee95b){const _0x526bf2=_0xe3f47f['tableInstance']['uiResourceMeta']?.['resourceMeta'],_0x20259a=_0xe3f47f['row']['item']['id'],_0x9bbdaa=_0x115567['propertyName'],_0x462c68=__name(()=>{changeFiltersForManyToOne(_0x115567['filters']);},'setManyToOneFilters');await removeResourceRelation(_0x526bf2,_0x20259a,_0x17784e,_0x9bbdaa,_0x462c68,_0x4ee95b);}__name(onRelationUnassign,'onRelationUnassign');async function initializeMultiListItems(_0x7edb67,_0x44bd83,_0x4f4a92,_0x48c415,_0xf54370){if(_0xf54370)_0x44bd83(_0xf54370);else {const _0x4f038f=await getRelatedResourceMultiListItems(_0x7edb67,_0x4f4a92['id'],_0x48c415,_0x4f4a92);_0x44bd83(_0x4f038f);}}__name(initializeMultiListItems,'initializeMultiListItems');

export { initializeMultiListItems, onRelationUnassign, onViewMultiListRelationChange };
