'use strict';
'use client';
import { relationTypes } from '../../../../fd-toolbox/enums/enums.js';
import { isString } from '../../../../fd-toolbox/types/ensure-type.js';
import { compareFormValue } from './edit-resources.js';

var __defProp=Object['defineProperty'],__name=(_0x51679c,_0x5e53d4)=>__defProp(_0x51679c,'name',{'value':_0x5e53d4,'configurable':!![]});function processRelation(_0x58ca57,_0x1f4788,_0x5d21db,_0x2417c5,_0x9db590,_0x285964,_0xf40632){const _0x59a282=[];if(!_0x2417c5['relation']||!isString(_0x1f4788)||compareFormValue(_0x9db590,_0x285964,_0x58ca57,_0xf40632))return _0x59a282;return _0x2417c5['relation']['type']===relationTypes['manyToOne']&&_0x59a282['push'](syncManyToOneRelation(_0x58ca57,_0x1f4788,_0x5d21db,_0x2417c5)),(_0x2417c5['relation']['type']===relationTypes['oneToMany']||_0x2417c5['relation']['type']===relationTypes['manyToMany'])&&_0x59a282['push'](syncOneToManyOrManyToManyRelation(_0x58ca57,_0x1f4788,_0x5d21db,_0x2417c5)),_0x59a282;}__name(processRelation,'processRelation');function syncManyToOneRelation(_0x1e3908,_0x145ce8,_0xb58e55,_0x15f512){const _0x417e53={'propertyName':_0x1e3908,'relatedResourceIds':_0x145ce8?[_0x145ce8]:[]};return _0x15f512['required']?_0xb58e55[_0x1e3908]=_0x145ce8:delete _0xb58e55[_0x1e3908],_0x417e53;}__name(syncManyToOneRelation,'syncManyToOneRelation');function syncOneToManyOrManyToManyRelation(_0x9f01e3,_0x29940c,_0x8b266,_0x44a3d1){const _0x52fc47={'propertyName':_0x9f01e3,'relatedResourceIds':_0x29940c?_0x29940c['split'](','):[]};return _0x44a3d1['required']?_0x8b266[_0x9f01e3]=_0x29940c:delete _0x8b266[_0x9f01e3],_0x52fc47;}__name(syncOneToManyOrManyToManyRelation,'syncOneToManyOrManyToManyRelation');

export { processRelation };
