'use strict';
import { createError } from '../../../fd-toolbox/errors/errors.js';
import { metaErrorMessages } from '../../../level2/meta/constants/meta-error-messages-constants.js';
import { ensureNotNullOrUndefined } from '../../../fd-toolbox/functions/value-checking-functions.js';

var __defProp=Object['defineProperty'],__name=(_0x2535dc,_0x1a667b)=>__defProp(_0x2535dc,'name',{'value':_0x1a667b,'configurable':!![]});function getExistingRelationsModified(_0x321d64,_0x3376ab,_0x4f038f,_0x215120){const _0x38b4db=getProcessedExistingRelations(_0x3376ab);return _0x4f038f&&addRelation(_0x38b4db,_0x321d64,_0x4f038f),_0x215120&&removeRelation(_0x38b4db,_0x321d64,_0x215120),_0x38b4db;}__name(getExistingRelationsModified,'getExistingRelationsModified');function getProcessedExistingRelations(_0x3f5f5b){const _0x406ef8=[];return _0x406ef8['push'](...mapDictionaryToPropertyRelationSyncInfos(ensureNotNullOrUndefined(_0x3f5f5b))),_0x406ef8;}__name(getProcessedExistingRelations,'getProcessedExistingRelations');function getInitialExistingRelations(_0x39e9d6){if(!_0x39e9d6)return [];return Object['entries'](_0x39e9d6)['map'](mapDictionary);}__name(getInitialExistingRelations,'getInitialExistingRelations');function addRelation(_0x4a4f46,_0xb7b34e,_0x45596f){const _0x352d71=findSyncInfoByPropertyName(_0x4a4f46,_0xb7b34e);_0x352d71['relatedResourceIds']['push'](..._0x45596f);}__name(addRelation,'addRelation');function removeRelation(_0x190fff,_0x5bf0c5,_0x4facf1){const _0x43b9cd=findSyncInfoByPropertyName(_0x190fff,_0x5bf0c5);_0x43b9cd['relatedResourceIds']=_0x43b9cd['relatedResourceIds']['filter'](_0x1d22b5=>_0x1d22b5!==_0x4facf1);}__name(removeRelation,'removeRelation');function findSyncInfoByPropertyName(_0x516b17,_0x4c8df7){const _0x227dfe=_0x516b17['find'](_0x16326b=>_0x16326b['propertyName']===_0x4c8df7);if(!_0x227dfe)throw createError(metaErrorMessages['propertyRelationSyncInfoNotFound']['replace']('{0}',_0x4c8df7));return _0x227dfe;}__name(findSyncInfoByPropertyName,'findSyncInfoByPropertyName');function mapDictionaryToPropertyRelationSyncInfos(_0x5dc4cc){const _0x2a8a85=[];if(_0x5dc4cc&&Object['keys'](_0x5dc4cc)['length']>0x1b9d+0x134d+-0x5*0x962)for(const [_0x53b95d,_0x4b2ca3]of Object['entries'](_0x5dc4cc)){const _0x1fac1d={'propertyName':_0x53b95d,'relatedResourceIds':[..._0x4b2ca3]};_0x2a8a85['push'](_0x1fac1d);}return _0x2a8a85;}__name(mapDictionaryToPropertyRelationSyncInfos,'mapDictionaryToPropertyRelationSyncInfos');function mapDictionary([_0x31c1f3,_0x55aa3b]){const _0x298093={'propertyName':_0x31c1f3,'relatedResourceIds':_0x55aa3b};return _0x298093;}__name(mapDictionary,'mapDictionary');

export { getExistingRelationsModified, getInitialExistingRelations, getProcessedExistingRelations };
