'use strict';
import { metaPropertyNames } from '../constants/meta-property-names.js';
import { metas } from '../meta-core/constants/metas.js';
import { metaValidationMessages } from '../constants/meta-validation-messages.js';
import { getValueWithoutFirstPascalCasePart } from '../../../../fd-toolbox/server/strings/casing.js';
import { hasInternalResourceMeta, getInternalResourceMeta } from '../resources/internal-resource-meta.js';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { propertyTypes } from '../../properties/property-type.js';
import { convertFromCamelToPascalCase, convertFromPascalToCamelCase, convertFromPascalToUserFriendlyCase } from '../../../../fd-toolbox/strings/casing-converter.js';
import { pluralizeStrict } from '../../../../fd-toolbox/server/strings/strings.js';
import { withIdProps } from '../../../../fd-toolbox-core/types/resource-with-id.js';

var __defProp=Object['defineProperty'],__name=(_0x4fccba,_0x14a1e0)=>__defProp(_0x4fccba,'name',{'value':_0x14a1e0,'configurable':!![]});async function getResourceNameOrDefault(_0x2c93be){let _0x14d77e;await hasInternalResourceMeta(_0x2c93be)&&(_0x14d77e=convertFromCamelToPascalCase(_0x2c93be));let _0x13ec47=_0x2c93be;while(!_0x14d77e&&_0x13ec47!==''){_0x13ec47=getValueWithoutFirstPascalCasePart(_0x13ec47),await hasInternalResourceMeta(_0x13ec47)&&(_0x14d77e=convertFromCamelToPascalCase(_0x13ec47));}return _0x14d77e;}__name(getResourceNameOrDefault,'getResourceNameOrDefault');async function isResourceIdProperty(_0x49caa2,_0x18b803){let _0x26f418=![];if(_0x18b803){const _0x4caefe=createResourceIdProperty(_0x18b803);if(_0x49caa2['endsWith'](_0x4caefe)||_0x49caa2['endsWith'](convertFromCamelToPascalCase(_0x4caefe))){const _0x18d391=await getInternalResourceMeta(_0x18b803);_0x18d391&&(_0x26f418=!![]);}}else _0x49caa2['endsWith'](metas['idSuffix'])&&_0x49caa2['length']!==metas['idConstant']['length']&&(_0x26f418=!![]);return _0x26f418;}__name(isResourceIdProperty,'isResourceIdProperty');function isResourceListProperty(_0x4caa01){return _0x4caa01['endsWith'](metas['listSuffix']);}__name(isResourceListProperty,'isResourceListProperty');function isUrlProperty(_0x2f2760){return _0x2f2760['endsWith'](metas['urlSuffix']);}__name(isUrlProperty,'isUrlProperty');function createResourceIdProperty(_0x306054){return convertFromPascalToCamelCase(_0x306054)+metas['idSuffix'];}__name(createResourceIdProperty,'createResourceIdProperty');async function isResourceProperty(_0x4e3829,_0x46df10){if(_0x46df10===propertyTypes['array']||_0x46df10!==propertyTypes['object'])return ![];const _0x48ce82=await getResourceNameOrDefault(_0x4e3829);return !!_0x48ce82;}__name(isResourceProperty,'isResourceProperty');async function getUserFriendlyName(_0x338869){let _0x418203=convertFromCamelToPascalCase(_0x338869);return isResourceListProperty(_0x418203)&&(_0x418203=cutOffSuffix(_0x418203,metas['listSuffix']),_0x418203=pluralizeStrict(_0x418203)),isUrlProperty(_0x418203)&&isNotEqualToSuffix(_0x418203,metas['urlSuffix'])&&(_0x418203=cutOffSuffix(_0x418203,metas['urlSuffix'])),await isResourceIdProperty(_0x338869)&&(_0x418203=cutOffSuffix(_0x418203,metas['idSuffix'])),_0x418203!==metas['userSuffix']&&_0x418203['endsWith'](metas['userSuffix'])&&(_0x418203=cutOffSuffix(_0x418203,metas['userSuffix'])),convertFromPascalToUserFriendlyCase(_0x418203);}__name(getUserFriendlyName,'getUserFriendlyName');function getResourceDescriptionPropertyNames(_0x3f4b89){const _0x25a7a7=new Set(),_0x1f6843=getResourceDescription(_0x3f4b89);_0x1f6843['propertyToCheck']&&_0x25a7a7['add'](_0x1f6843['propertyToCheck']);_0x1f6843['resourceDescriptionProperty']&&_0x25a7a7['add'](_0x1f6843['resourceDescriptionProperty']);if(_0x1f6843['cases'])for(const _0x5b3cf0 of _0x1f6843['cases']){_0x25a7a7['add'](_0x5b3cf0['resourceDescriptionProperty']),_0x5b3cf0['additionalResourceDescriptionProperty']&&_0x25a7a7['add'](_0x5b3cf0['additionalResourceDescriptionProperty']);}return Array['from'](_0x25a7a7);}__name(getResourceDescriptionPropertyNames,'getResourceDescriptionPropertyNames');function getResourceDescription(_0x4ebcc7){const _0x7cc7aa=_0x4ebcc7['description'];if(!_0x7cc7aa['resourceDescriptionProperty']){if(Object['hasOwn'](_0x4ebcc7['properties'],metaPropertyNames['nameConst']))_0x7cc7aa['resourceDescriptionProperty']=metaPropertyNames['nameConst'];else Object['hasOwn'](_0x4ebcc7['properties'],metaPropertyNames['descriptionConst'])&&(_0x7cc7aa['resourceDescriptionProperty']=metaPropertyNames['descriptionConst']);}return _0x7cc7aa;}__name(getResourceDescription,'getResourceDescription');async function getResourceNameFromPropertyWithId(_0x4bcac3){return getResourceNameFromProperty(_0x4bcac3,metas['idSuffix']);}__name(getResourceNameFromPropertyWithId,'getResourceNameFromPropertyWithId');async function getResourceNameFromListProperty(_0x182662){return getResourceNameFromProperty(_0x182662,metas['listSuffix']);}__name(getResourceNameFromListProperty,'getResourceNameFromListProperty');function cutOffSuffix(_0xd5c741,_0x233f2d){return _0xd5c741['substring'](0x2*-0xeb+0x1*0x216d+-0x1f97,_0xd5c741['length']-_0x233f2d['length']);}__name(cutOffSuffix,'cutOffSuffix');function isIdProperty(_0x2cc0a5){return _0x2cc0a5?.['endsWith'](metas['idSuffix'])&&_0x2cc0a5['length']!==metas['idConstant']['length'];}__name(isIdProperty,'isIdProperty');function isIdOnlyProperty(_0x508ba7){return _0x508ba7===withIdProps['id'];}__name(isIdOnlyProperty,'isIdOnlyProperty');async function getResourceNameFromProperty(_0x1eea09,_0x1e5abc){const _0x38f489=convertFromCamelToPascalCase(cutOffSuffix(_0x1eea09,_0x1e5abc)),_0x2d5664=await getResourceNameOrDefault(_0x38f489);if(!_0x2d5664)throw createError(metaValidationMessages['resourceNameNotFound']['replace']('{0}',_0x1eea09)['replace']('{1}',_0x1e5abc)['replace']('{2}',_0x38f489));return _0x2d5664;}__name(getResourceNameFromProperty,'getResourceNameFromProperty');function isNotEqualToSuffix(_0x3b94ca,_0x322e89){return _0x3b94ca!==_0x322e89;}__name(isNotEqualToSuffix,'isNotEqualToSuffix');

export { createResourceIdProperty, cutOffSuffix, getResourceDescription, getResourceDescriptionPropertyNames, getResourceNameFromListProperty, getResourceNameFromPropertyWithId, getResourceNameOrDefault, getUserFriendlyName, isIdOnlyProperty, isIdProperty, isResourceIdProperty, isResourceListProperty, isResourceProperty, isUrlProperty };
