'use strict';
import { tableDisplayModes, crudActions } from '../../../../fd-toolbox/enums/enums.js';
import { internalTableColumnTypes, tableCustomActionPositions } from '../table-models.js';
import { minimalModeFirstColumnWidthPercentage, defaultFirstColumnWidthPercentage, minColumnWidthPercentage } from '../table-constants.js';
import { hasCrudPermission } from '../../auth/permissions/permission-checker.js';

var __defProp=Object['defineProperty'],__name=(_0x2a2f74,_0x2e5d3b)=>__defProp(_0x2a2f74,'name',{'value':_0x2e5d3b,'configurable':!![]});function getColumnSize(_0x5e5297,_0x35a4f5,_0x50a105,_0x18dd38){let _0x2798fa=-0x1*0x24cd+-0x112*-0xd+0x9*0x28b;if(_0x5e5297['index']===0xc7f+0x1ad+0x4*-0x38b){if(hasUserPermission(_0x35a4f5)){if(_0x50a105===tableDisplayModes['minimal'])_0x2798fa=Math['min'](minimalModeFirstColumnWidthPercentage,_0x5e5297['width']);else {const _0x18b200=Math['max'](defaultFirstColumnWidthPercentage,calculateFirstColumnWidthPercentage(_0x35a4f5));_0x2798fa=Math['min'](_0x18b200,_0x5e5297['width']);}}}else {if(_0x5e5297['type']===internalTableColumnTypes['action']&&isLastActionInternalColumn(_0x5e5297))_0x2798fa=calculateLastColumnWidthPercentage(_0x35a4f5);else {const _0x3006b7=-0x1283+0x1f3+0x10f4-defaultFirstColumnWidthPercentage,_0x4a57f0=_0x3006b7/(_0x18dd38['length']-(0x1ec0+-0x7a1+-0x1*0x171e)),_0x39f438=(_0x18dd38['length']-(0x153e+0x349*-0x5+-0x1*0x4d0))*minColumnWidthPercentage>_0x3006b7?_0x4a57f0:minColumnWidthPercentage;_0x2798fa=Math['min'](_0x39f438,_0x5e5297['width']);}}return _0x2798fa;}__name(getColumnSize,'getColumnSize');function hasUserPermission(_0x1091ab){const _0x4e4513=[crudActions['create'],crudActions['update'],crudActions['delete'],crudActions['view']];return _0x1091ab['uiResourceMeta']&&_0x4e4513['some'](_0x40cb6e=>hasCrudPermission(_0x40cb6e,_0x1091ab['uiResourceMeta']['resourceMeta']));}__name(hasUserPermission,'hasUserPermission');function calculateFirstColumnWidthPercentage(_0x35caaf){return (_0x35caaf['customActions']?.['filter'](_0x2a0d43=>_0x2a0d43['position']!==tableCustomActionPositions['dropdown']&&(_0x2a0d43['position']===tableCustomActionPositions['default']||!_0x2a0d43['position']))['length']??0xb*0x1b3+-0x6*0x31c+-0x9)*defaultFirstColumnWidthPercentage+defaultFirstColumnWidthPercentage;}__name(calculateFirstColumnWidthPercentage,'calculateFirstColumnWidthPercentage');function calculateLastColumnWidthPercentage(_0x1cfb07){return (_0x1cfb07['customActions']?.['filter'](_0x25644e=>_0x25644e['position']!==tableCustomActionPositions['dropdown']&&_0x25644e['position']===tableCustomActionPositions['lastColumn'])['length']??-0x174b+-0xeb8+0x2603)*defaultFirstColumnWidthPercentage+defaultFirstColumnWidthPercentage;}__name(calculateLastColumnWidthPercentage,'calculateLastColumnWidthPercentage');function isLastActionInternalColumn(_0x4ac455){return _0x4ac455['type']===internalTableColumnTypes['action']&&_0x4ac455['actionPosition']===tableCustomActionPositions['lastColumn'];}__name(isLastActionInternalColumn,'isLastActionInternalColumn');

export { getColumnSize };
