'use strict';
import { oDataOperators } from '../../enums/enums.js';
import { isEmptyNullOrUndefined } from '../../functions/value-checking-functions.js';
import { tryParseNumber } from '../../numbers/numbers.js';
import { trimCharacter } from '../../strings/strings.js';
import { oDataFilterTypes, oDataComparisonTypes } from '../odata-enums.js';
import { oDataLogicalOperators, oDataDataTypePrefixes, oDataSeparators } from '../odata-filter-constants.js';
import { firstOrUndefined } from '../../server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x30de62,_0x3ebc8b)=>__defProp(_0x30de62,'name',{'value':_0x3ebc8b,'configurable':!![]});function parseODataFilter(_0x379233){let _0x51d082=[];if(isEmptyNullOrUndefined(_0x379233))return _0x51d082;let _0x39ab25=splitFilters(_0x379233);for(let _0x15e181 of _0x39ab25){_0x51d082['push'](getODataFilter(_0x15e181));}return _0x51d082;}__name(parseODataFilter,'parseODataFilter');function splitFilters(_0x4393bb){return _0x4393bb['split'](oDataLogicalOperators['and']);}__name(splitFilters,'splitFilters');function getODataFilter(_0x4a171e){let _0x2879bd=getODataOperator(_0x4a171e),_0x1d1247=_0x4a171e['split'](_0x2879bd)['map'](_0xc080ee=>_0xc080ee['trim']()),_0x347150=firstOrUndefined(_0x1d1247),_0xfdfb4,_0x36a783=oDataFilterTypes['string'];if(_0x1d1247[0x243e+-0x376*0x7+-0xc03]?.['startsWith'](oDataDataTypePrefixes['guidPrefix'])){let _0x298ee0=0x1af8+0x1300+0x51b*-0x9;_0xfdfb4=trimCharacter(_0x1d1247[-0x19b3+0x161c+-0x5*-0xb8]['substring'](_0x298ee0),'\x27'),_0x36a783=oDataFilterTypes['guid'];}else {if(_0x2879bd===oDataOperators['in']&&_0x1d1247[-0x2b*-0x51+0x45*-0x6+-0x5fe*0x2]?.['startsWith']('(guid')){let _0x2772c4=_0x1d1247[-0x1*-0x734+-0x6a*0x3b+0x113b]['replace'](/[()']/g,'')['split'](','),_0x3ca975=[];for(let _0x30bcdc of _0x2772c4){_0x3ca975['push'](_0x30bcdc['replace'](oDataDataTypePrefixes['guidPrefix'],''));}_0xfdfb4=_0x3ca975,_0x36a783=oDataFilterTypes['guid'];}else {if(_0x1d1247[-0x1c*-0x1d+-0xb8*-0x1a+-0x15db]?.['startsWith'](oDataDataTypePrefixes['datePrefix']))_0xfdfb4=trimCharacter(_0x1d1247[0x255c+0x5a*0x4+-0x26c3]['substring'](0x1621+0x38b*0x2+-0x1d2e),['\x27',oDataSeparators['timezoneSuffix']]),_0x36a783=oDataFilterTypes['date'];else {if(_0x2879bd===oDataOperators['in'])_0xfdfb4=_0x1d1247[-0x1*0x2389+-0x6b*-0x2b+0x1191]['replace'](/[()"]/g,'')['split'](',')['map'](_0x30c24e=>+_0x30c24e),_0x36a783=oDataFilterTypes['number'];else {if(_0x2879bd===oDataOperators['startsWith']){const [_0x12fa9a,_0x2921c6]=_0x1d1247[0x69*0x9+-0xd7e*-0x1+-0x112e]['replace'](/[()]/g,'')['split'](',')['map'](_0x4c8d1f=>_0x4c8d1f['trim']());_0x347150=_0x12fa9a,_0xfdfb4=_0x2921c6;}else !_0x1d1247[0x1*-0x101f+-0x19bb+0x29db]?.['includes']('\x27')&&!isNaN(tryParseNumber(_0x1d1247[-0x2125+-0x19ba+-0x60*-0x9d]))?(_0xfdfb4=tryParseNumber(_0x1d1247[0x1998+-0x11c+-0x187b]),_0x36a783=oDataFilterTypes['number']):_0xfdfb4=trimCharacter(_0x1d1247[-0x93f*0x2+0x1*-0x441+0x2d8*0x8],'\x27');}}}}const _0xd133de={'leftSide':_0x347150,'rightSide':_0xfdfb4,'type':_0x36a783,'operator':_0x2879bd,'comparisonType':oDataComparisonTypes['equal']};return _0xd133de;}__name(getODataFilter,'getODataFilter');function getODataOperator(_0x2184c2){if(_0x2184c2['startsWith'](oDataOperators['startsWith']+'('))return oDataOperators['startsWith'];else {if(_0x2184c2['includes']('\x20'+oDataOperators['equal']+'\x20'))return oDataOperators['equal'];else {if(_0x2184c2['includes']('\x20'+oDataOperators['greaterThan']+'\x20'))return oDataOperators['greaterThan'];else {if(_0x2184c2['includes']('\x20'+oDataOperators['greaterThanEqual']+'\x20'))return oDataOperators['greaterThanEqual'];else {if(_0x2184c2['includes']('\x20'+oDataOperators['lessThan']+'\x20'))return oDataOperators['lessThan'];else {if(_0x2184c2['includes']('\x20'+oDataOperators['lessThanEqual']+'\x20'))return oDataOperators['lessThanEqual'];else return _0x2184c2['includes']('\x20'+oDataOperators['in']+'\x20')?oDataOperators['in']:oDataOperators['equal'];}}}}}}__name(getODataOperator,'getODataOperator');

export { parseODataFilter };
