'use strict';
'use client';
import { filterOperatorTypes, propertyTypes, oDataOperators } from '../../../../fd-toolbox/enums/enums.js';
import { shortenWithEllipsis } from '../../../../fd-toolbox/strings/strings.js';
import { isEnum, isBooleanField, isGuid, isFlagsEnum, isDateOnly, isDateTime } from '../../core/property-types.js';
import { isDefaultInputField } from '../../edit-resource/services/edit-resource-components.js';
import { getResourceDescriptionValue } from '../../core/resource-description/resource-description.js';
import { propertyTypeFormats } from '../../constants/property-type-formats.js';
import { getObjectValues } from '../../../../fd-toolbox/lib/utils.js';
import { isOneToManyBrowserField, isManyToManyBrowserField } from '../../services/property-fields.js';
import { oDataFilterTypes } from '../../../../fd-toolbox/odata/odata-enums.js';
import { keyboardKeys } from '../../../../fd-toolbox/constants/keyboard-keys.js';
import { filterToODataOperator } from './filter-constants.js';
import { getFilterRightHand } from './filter-display.js';
import { isNullOrUndefined } from '../../../../fd-toolbox/functions/value-checking-functions.js';

var __defProp=Object['defineProperty'],__name=(_0x3ad6ce,_0x28c210)=>__defProp(_0x3ad6ce,'name',{'value':_0x28c210,'configurable':!![]});function onInitFilter(_0x178795,_0x31b6a6,_0x39fa43,_0x7277eb,_0x5b0444,_0x441b45,_0x4a3f87){if(isDefaultInputField(_0x7277eb)&&_0x31b6a6['length']>=0x941*0x3+0xd4d+0x9*-0x48e)_0x39fa43(shortenWithEllipsis(_0x31b6a6,-0x43*-0x6a+0x22bf+-0x349*0x13));else {if(isEnum(_0x7277eb['type'],_0x7277eb['typeFormat'])&&_0x31b6a6['length']>=-0xc8+0x209+-0x12d*0x1)_0x39fa43(shortenWithEllipsis(_0x31b6a6,0xe13+0x161*0x5+-0x14e4));else isBooleanField(_0x7277eb)&&_0x31b6a6['length']>=0x39e+-0x18e6+0x21*0xa6&&_0x39fa43(shortenWithEllipsis(_0x31b6a6,0xf29*0x1+-0x1cbb+-0xc*-0x124));}initWithState(_0x178795,_0x4a3f87,_0x7277eb,_0x5b0444,_0x441b45);}__name(onInitFilter,'onInitFilter');function shouldFilterInputBeVisible(_0x31c615){return Boolean(_0x31c615['rightSide']&&String(_0x31c615['rightSide'])['trim']()!==''&&_0x31c615['operator']!==filterOperatorTypes['none']);}__name(shouldFilterInputBeVisible,'shouldFilterInputBeVisible');async function onBrowserChanged(_0x3d3b08,_0x1a6162,_0x122cc7,_0x173927,_0x3f4db2,_0x422df7,_0x4b35b4,_0x3fa7cb,_0x26ae7f,_0x12672f,_0x1c62cb,_0x531e88){if(Array['isArray'](_0x3d3b08)&&_0x3d3b08['length']>0x1*0xa2a+0xa62*-0x1+0xe*0x4&&isGuid(_0x1a6162['typeFormat'],_0x1a6162['relation'])){const _0x2369ba=[];_0x531e88?.(!![]);for(const _0x195aba of _0x3d3b08){_0x2369ba['push'](_0x195aba['id']);}_0x3fa7cb(_0x2369ba);const _0x19ebb3={..._0x122cc7,'rightSide':_0x2369ba,'type':oDataFilterTypes['guid']};_0x3f4db2(_0x19ebb3),await onFilterChange(_0x19ebb3,_0x3f4db2,_0x173927,_0x422df7,_0x4b35b4,void(0x1f32+0xe5a+-0x2c*0x109),_0x1c62cb);}else {const _0x116260={..._0x122cc7,'rightSide':''};_0x531e88?.(![]),_0x3f4db2(_0x116260),await onFilterChange(_0x116260,_0x3f4db2,_0x173927,_0x422df7,_0x4b35b4,void(0x22df+-0x15c4+-0xd1b),_0x1c62cb);}const _0x2a38b4=await getFilterFormValue(_0x3d3b08,_0x12672f);_0x26ae7f['setValue'](_0x1a6162['name'],_0x2a38b4);}__name(onBrowserChanged,'onBrowserChanged');async function onDateChange(_0x5b46e5,_0x440a3b,_0x2e085d,_0x66b13e,_0x4eba0f,_0x288520,_0x5ab0e9,_0x5c733c){let _0x515472='';if(_0x5ab0e9){const _0x2b0f92=_0x5ab0e9['getFullYear'](),_0x48e9a1=String(_0x5ab0e9['getMonth']()+(-0x79c*-0x4+-0xb76+0x12f9*-0x1))['padStart'](0x1*0x2668+0x1b61+0x3*-0x15ed,'0'),_0x4281d3=String(_0x5ab0e9['getDate']())['padStart'](-0x2*-0x1189+-0x79*0x35+-0xa03,'0');_0x515472=_0x2b0f92+'-'+_0x48e9a1+'-'+_0x4281d3;}await onFilterChange({..._0x5b46e5,'rightSide':_0x515472},_0x440a3b,_0x2e085d,_0x66b13e,_0x4eba0f,void(-0x1b1f*0x1+-0x43*0x29+0x25da),_0x5c733c);if(!_0x5ab0e9)_0x288520(![]);}__name(onDateChange,'onDateChange');function isIntegerField(_0x5082a5){return _0x5082a5['type']===propertyTypes['integer']||_0x5082a5['type']===propertyTypes['number'];}__name(isIntegerField,'isIntegerField');function disableFilterInput(_0x5013f0){return _0x5013f0===filterOperatorTypes['empty'];}__name(disableFilterInput,'disableFilterInput');async function onFilterChange(_0x19cd44,_0x5dd15a,_0x1acd03,_0x493c53,_0x548d7d,_0x265663,_0x51f2aa,_0x45c081,_0x755af8){const _0x54d85e={..._0x19cd44,'operator':getFilterODataOperator(_0x1acd03),'rightSide':getFilterRightHand(_0x19cd44,_0x1acd03)};_0x5dd15a(_0x54d85e),disableFilterMultiBrowserIfNeeded(_0x54d85e,_0x1acd03,_0x5dd15a,_0x493c53),disableEnumFilterIfNeeded(_0x1acd03,_0x548d7d),_0x265663?.(_0x1acd03),_0x51f2aa&&setTimeout(()=>{_0x51f2aa();},-0x1745+0x3b*-0x85+0x35ec),(String(_0x54d85e['rightSide'])===oDataOperators['empty']||String(_0x54d85e['rightSide'])===''||Array['isArray'](_0x54d85e['rightSide'])&&_0x54d85e['rightSide']['length']===-0x1*0x17cb+0x2f0*-0xd+-0x9*-0x6e3)&&(_0x45c081&&(_0x45c081['current']=!![]),_0x755af8?.(![]));}__name(onFilterChange,'onFilterChange');function getFilterDisplayValues(_0x10555a,_0x59ebc9){let _0x4131bb;if(_0x10555a&&isEnum(_0x59ebc9['type'],_0x59ebc9['typeFormat']))_0x4131bb=_0x59ebc9['enumerationValues']?.['reduce']((_0x44f08c,_0x1b6152,_0x4712ec)=>{return _0x44f08c['set'](_0x1b6152['toString'](),_0x59ebc9['enumerationDisplayName'][_0x4712ec]),_0x44f08c;},new Map());return _0x4131bb;}__name(getFilterDisplayValues,'getFilterDisplayValues');async function onOperatorTypeChange(_0x4fa83f,_0x48c434,_0x542197,_0x33a6e9,_0x14ea68,_0x4dc286,_0x5a7c73){if(isNullOrUndefined(_0x5a7c73))return;const _0x93e65b=getFilterOperatorTypeByString(_0x5a7c73);_0x93e65b&&(await onFilterChange(_0x4fa83f,_0x48c434,_0x93e65b,_0x33a6e9,_0x14ea68,void(-0xac8+-0x1*0x1e36+0x28fe),_0x4dc286),_0x542197(_0x93e65b));}__name(onOperatorTypeChange,'onOperatorTypeChange');function onInputBlur(_0x5eb74c,_0x100255,_0x18faff,_0x342e72){const _0x28d2f0=_0x100255['relatedTarget'],_0x4eb767=_0x342e72?.['current'];if(_0x5eb74c||_0x28d2f0&&_0x4eb767?.['contains'](_0x28d2f0))return;_0x18faff(![]);}__name(onInputBlur,'onInputBlur');function updateFilterWidthContainer(_0x3a2e29,_0x5e907a,_0x50b2cf){if(_0x3a2e29['current']&&!_0x5e907a){const _0x148b16=_0x3a2e29['current']['offsetWidth'];_0x50b2cf(_0x148b16);}}__name(updateFilterWidthContainer,'updateFilterWidthContainer');function showFieldFilter(_0x5ac345,_0x8101e6,_0x3f37aa,_0x5e8bed,_0x2c7993,_0x11c20f,_0x3f2b51){if(_0x5ac345)return;_0x8101e6(!![]),requestAnimationFrame(()=>{_0x3f37aa['current']?.['focus'](),_0x5e8bed['current']?.['click']();if(!isEnumFilterInput(_0x11c20f))_0x2c7993['current']?.['open']();else _0x3f2b51&&document['getElementById'](_0x3f2b51)?.['focus']();});}__name(showFieldFilter,'showFieldFilter');function onFilterKeyDown(_0x2a3c1d,_0x3ceda9,_0x18f059){if(_0x3ceda9)return;const _0x44d0e1=_0x2a3c1d['key']===keyboardKeys['enter']||_0x2a3c1d['key']===keyboardKeys['space']||_0x2a3c1d['key']===keyboardKeys['arrowDown'];if(!_0x44d0e1)return;_0x2a3c1d['preventDefault'](),_0x2a3c1d['stopPropagation'](),_0x18f059();}__name(onFilterKeyDown,'onFilterKeyDown');function isSimpleFilterInput(_0x26d2b9){return isDefaultInputField(_0x26d2b9)&&!isGuid(_0x26d2b9['typeFormat'],_0x26d2b9['relation'])&&!isDateFilterInput(_0x26d2b9)&&!isIntegerField(_0x26d2b9)&&!isEnumFilterInput(_0x26d2b9);}__name(isSimpleFilterInput,'isSimpleFilterInput');function onFilterOpenChange(_0x59afd2,_0x5df37c,_0x33a8a9,_0x539765){if(!_0x59afd2)_0x5df37c['current']=!![];!_0x59afd2&&(_0x33a8a9===''||_0x33a8a9===oDataOperators['empty'])?_0x539765?.(![]):_0x539765?.(!![]);}__name(onFilterOpenChange,'onFilterOpenChange');function onCreateOnRightHandChange(_0x2987b2,_0x21f2ed,_0x2beed9,_0x1cb124,_0x5a8120,_0x15d67b,_0x2caf2d,_0x25f869,_0x52ee6e){return async _0x1f17a4=>{if(isNullOrUndefined(_0x1f17a4))return;await onFilterChange({..._0x2987b2,'rightSide':_0x1f17a4},_0x21f2ed,_0x2beed9,_0x1cb124,_0x5a8120,_0x15d67b,_0x25f869,_0x2caf2d,_0x52ee6e);};}__name(onCreateOnRightHandChange,'onCreateOnRightHandChange');function createOnOperatorTypeChange(_0x4a1414,_0x267ff6,_0x5928dd,_0x25591c,_0x26230f,_0x417584){return _0x2dd5f1=>{void onOperatorTypeChange(_0x4a1414,_0x267ff6,_0x5928dd,_0x25591c,_0x26230f,_0x417584,_0x2dd5f1);};}__name(createOnOperatorTypeChange,'createOnOperatorTypeChange');function createOnShowFieldFilter(_0x1fc7fb,_0x37c47d,_0x831ccc,_0x4dfba2,_0x30b5bc,_0x3f08f0,_0x3e4ba5){return ()=>{showFieldFilter(_0x1fc7fb,_0x37c47d,_0x831ccc,_0x4dfba2,_0x30b5bc,_0x3f08f0,_0x3e4ba5);};}__name(createOnShowFieldFilter,'createOnShowFieldFilter');function createOnGuidFilterClose(_0x5a07f0,_0x4fcefb){return ()=>{_0x5a07f0['current']=!![],_0x4fcefb?.(![]);};}__name(createOnGuidFilterClose,'createOnGuidFilterClose');function disableFilterMultiBrowserIfNeeded(_0x25365e,_0x2e7f63,_0x20fdbc,_0x33b305){if(_0x2e7f63!==filterOperatorTypes['empty'])_0x33b305(![]);else {if(_0x2e7f63===filterOperatorTypes['empty']){const _0x574b24=oDataFilterTypes['guid'];_0x20fdbc({..._0x25365e,'type':_0x574b24}),_0x33b305(!![]);}}}__name(disableFilterMultiBrowserIfNeeded,'disableFilterMultiBrowserIfNeeded');function disableEnumFilterIfNeeded(_0x4c5199,_0x41ac0b){_0x4c5199===filterOperatorTypes['empty']?_0x41ac0b(!![]):_0x41ac0b(![]);}__name(disableEnumFilterIfNeeded,'disableEnumFilterIfNeeded');function getFilterOperatorTypeByString(_0x1bd969){return getObjectValues(filterOperatorTypes)['find'](_0x5abcd8=>_0x5abcd8===_0x1bd969);}__name(getFilterOperatorTypeByString,'getFilterOperatorTypeByString');async function getFilterFormValue(_0x5a1189,_0x59a214){let _0x561a11='';if(_0x5a1189['length']>0xb*-0x10f+-0x1c56+0x27fb){const _0x50bb83=_0x5a1189['map'](_0x36106e=>getResourceDescriptionValue(_0x59a214,_0x36106e)),_0x542546=await Promise['all'](_0x50bb83);_0x561a11=_0x542546['join'](',\x20');}return _0x561a11;}__name(getFilterFormValue,'getFilterFormValue');function initWithState(_0x271d98,_0xca99c3,_0x47ece5,_0x23d669,_0x3550c7){initializeFilterOperatorType(_0x47ece5,_0x23d669,_0x271d98['operator']);const _0x29f50d=_0x271d98['rightSide']??'';isGuid(_0x47ece5['typeFormat'],_0x47ece5['relation'])&&_0x3550c7(_0x29f50d?[String(_0x29f50d)]:[]),isDateFilterInput(_0x47ece5)&&_0xca99c3(String(_0x29f50d));}__name(initWithState,'initWithState');function initializeFilterOperatorType(_0x416597,_0x3d117a,_0x35ee8d=filterOperatorTypes['none']){if(_0x35ee8d!==filterOperatorTypes['none'])return;if(_0x416597['type']===propertyTypes['string']){if(isDateFilterInput(_0x416597))_0x3d117a(filterOperatorTypes['equal']);else {if(_0x416597['typeFormat']===propertyTypeFormats['uuid']){const _0x3b2366=isOneToManyBrowserField(_0x416597)??isManyToManyBrowserField(_0x416597);_0x3d117a(_0x3b2366?filterOperatorTypes['in']:filterOperatorTypes['equal']);}else _0x3d117a(filterOperatorTypes['startsWith']);}}else _0x416597['type']===propertyTypes['integer']&&_0x3d117a(filterOperatorTypes['in']);}__name(initializeFilterOperatorType,'initializeFilterOperatorType');function getFilterODataOperator(_0x3e6196){return filterToODataOperator['get'](_0x3e6196)??oDataOperators['equal'];}__name(getFilterODataOperator,'getFilterODataOperator');function isEnumFilterInput(_0x45e6ef){return isEnum(_0x45e6ef['type'],_0x45e6ef['typeFormat'])||isFlagsEnum(_0x45e6ef['type'],_0x45e6ef['typeFormat']);}__name(isEnumFilterInput,'isEnumFilterInput');function isDateFilterInput(_0x16fdfa){return isDateOnly(_0x16fdfa['type'],_0x16fdfa['typeFormat'])||isDateTime(_0x16fdfa['type'],_0x16fdfa['typeFormat']);}__name(isDateFilterInput,'isDateFilterInput');

export { createOnGuidFilterClose, createOnOperatorTypeChange, createOnShowFieldFilter, disableFilterInput, getFilterDisplayValues, isIntegerField, isSimpleFilterInput, onBrowserChanged, onCreateOnRightHandChange, onDateChange, onFilterChange, onFilterKeyDown, onFilterOpenChange, onInitFilter, onInputBlur, onOperatorTypeChange, shouldFilterInputBeVisible, showFieldFilter, updateFilterWidthContainer };
