'use strict';
import { oDataOperators } from '../../enums/enums.js';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { createError } from '../../errors/errors.js';
import { oDataFilterTypes } from '../odata-enums.js';

var __defProp=Object['defineProperty'],__name=(_0x5d59ed,_0x209984)=>__defProp(_0x5d59ed,'name',{'value':_0x209984,'configurable':!![]});function getODataFilterAsString(_0x27a080){_0x27a080['operator']??=oDataOperators['equal'];if(_0x27a080['type']===void(-0x1b49+0x1*-0x12a1+-0xf4e*-0x3)||_0x27a080['type']===oDataFilterTypes['default']){if(typeof _0x27a080['rightSide']===jsBasicTypes['number'])_0x27a080['type']=oDataFilterTypes['number'];else {if(typeof _0x27a080['rightSide']===jsBasicTypes['boolean']||typeof _0x27a080['rightSide']===jsBasicTypes['string'])_0x27a080['type']=oDataFilterTypes['string'];else _0x27a080['rightSide']instanceof Date?_0x27a080['type']=oDataFilterTypes['date']:_0x27a080['type']=oDataFilterTypes['string'];}}return typeof _0x27a080['rightSide']===jsBasicTypes['string']&&!isNaN(Number(_0x27a080['rightSide']))&&(_0x27a080['rightSide']=Number(_0x27a080['rightSide'])),getFilterString(_0x27a080);}__name(getODataFilterAsString,'getODataFilterAsString');function getFilterString(_0x22464f){switch(_0x22464f['operator']){case oDataOperators['in']:return handleInOperator(_0x22464f);case oDataOperators['nin']:return handleInOperator(_0x22464f);case oDataOperators['empty']:return '';case oDataOperators['startsWith']:return handleStartsWithOperator(_0x22464f);default:return handleDefaultOperators(_0x22464f);}}__name(getFilterString,'getFilterString');function handleInOperator(_0x2f31d4){let _0xc16c54=_0x2f31d4['rightSide'];return _0x2f31d4['type']===oDataFilterTypes['guid']&&(_0xc16c54=oDataFormatGuid(_0x2f31d4['rightSide'])),_0x2f31d4['leftSide']+'\x20'+_0x2f31d4['operator']+'\x20('+_0xc16c54+')';}__name(handleInOperator,'handleInOperator');function handleStartsWithOperator(_0x155bac){return _0x155bac['operator']+'('+_0x155bac['leftSide']+',\x20'+_0x155bac['rightSide']+')';}__name(handleStartsWithOperator,'handleStartsWithOperator');function handleDefaultOperators(_0x864696){switch(_0x864696['type']){case oDataFilterTypes['string']:return handleStringFilter(_0x864696);case oDataFilterTypes['date']:return handleDateFilter(_0x864696);case oDataFilterTypes['guid']:return handleGuidFilter(_0x864696);case oDataFilterTypes['number']:return handleNumberFilter(_0x864696);case oDataFilterTypes['lambda']:return handleLambdaFilter(_0x864696);default:throw createError('Unsupported\x20filter\x20type:\x20'+_0x864696['type']);}}__name(handleDefaultOperators,'handleDefaultOperators');function handleStringFilter(_0x161487){let _0x5b3d9a=handleNumberFilter(_0x161487);return typeof _0x161487['rightSide']===jsBasicTypes['string']&&(_0x5b3d9a=_0x161487['leftSide']+'\x20'+_0x161487['operator']+'\x20\x27'+_0x161487['rightSide']+'\x27'),_0x161487['rightSide']===jsBasicTypes['null']&&(_0x5b3d9a=handleNumberFilter(_0x161487)),_0x5b3d9a;}__name(handleStringFilter,'handleStringFilter');function handleDateFilter(_0x49fd30){return _0x49fd30['leftSide']+'\x20'+_0x49fd30['operator']+'\x20datetime\x27'+_0x49fd30['rightSide']+'\x27';}__name(handleDateFilter,'handleDateFilter');function handleGuidFilter(_0x490372){return _0x490372['leftSide']+'\x20'+_0x490372['operator']+'\x20guid\x27'+_0x490372['rightSide']+'\x27';}__name(handleGuidFilter,'handleGuidFilter');function handleNumberFilter(_0x19a5e4){return _0x19a5e4['leftSide']+'\x20'+_0x19a5e4['operator']+'\x20'+_0x19a5e4['rightSide'];}__name(handleNumberFilter,'handleNumberFilter');function handleLambdaFilter(_0x3ec134){const _0xc2b3b5=_0x3ec134['lambdaConfig'];if(!_0xc2b3b5)throw createError('Lambda\x20configuration\x20is\x20missing');return _0xc2b3b5['baseEnumerablePropertyName']+'/'+_0xc2b3b5['method']+'(i:i/'+_0x3ec134['leftSide']+'\x20'+_0x3ec134['operator']+'\x20guid\x27'+_0x3ec134['rightSide']+'\x27)';}__name(handleLambdaFilter,'handleLambdaFilter');function oDataFormatGuid(_0x37cf91){let _0x5c37b1;if(typeof _0x37cf91===jsBasicTypes['string'])_0x5c37b1=''+_0x37cf91;else Array['isArray'](_0x37cf91)&&(_0x5c37b1=_0x37cf91['map'](_0x4b2fe1=>'guid\x27'+_0x4b2fe1+'\x27')['join'](','));return _0x5c37b1;}__name(oDataFormatGuid,'oDataFormatGuid');

export { getODataFilterAsString };
