'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { isTestFile, isFixtureFile, isExportDeclaration, variableDeclarationKinds, isIdentifier, isTopLevelVariable, isVariableUsedWithoutPropertyAccess, isAsConstVariable, nodeTypes, getObjectPropsUsagesCount } from '@flint/infra/analysis';

var __defProp=Object['defineProperty'],__name=(_0x561280,_0x5024ce)=>__defProp(_0x561280,'name',{'value':_0x5024ce,'configurable':!![]});const ruleName='no-unused-properties-in-constants';const ruleContent='\x0a###\x20**Must\x20not**\x20define\x20unused\x20properties\x20in\x20constant\x20objects.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20foo\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20\x22bar\x22,\x0a\x20\x20\x20\x20baz:\x20\x22baz\x22,\x0a}\x20as\x20const;\x0a\x0afooFunc(foo.bar);\x0a\x0a####\x20Correct\x0a\x0aconst\x20foo\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20\x22bar\x22,\x0a}\x20as\x20const;\x0a\x0afooFunc(foo.bar);\x0a\x0a####\x20Why\x0a\x0aUnused\x20properties\x20can\x20mislead\x20developers\x20and\x20decrease\x20readability.';var noUnusedPropertiesInConstants = createEslintRule(ruleName,ruleContent,_0x5f535a=>{const _0xf28fb9=_0x5f535a['filename'];return {'VariableDeclaration'(_0x3bbf23){if(isTestFile(_0xf28fb9)||isFixtureFile(_0xf28fb9)||isExportDeclaration(_0x3bbf23['parent'])||_0x3bbf23['kind']!==variableDeclarationKinds['const'])return;for(const _0x1468d9 of _0x3bbf23['declarations']){if(isIdentifier(_0x1468d9['id'])){const _0x94cc4e=_0x5f535a['sourceCode']['getScope'](_0x3bbf23),_0x580872=_0x94cc4e['set']['get'](_0x1468d9['id']['name']);if(_0x580872&&isTopLevelVariable(_0x580872)&&!isVariableUsedWithoutPropertyAccess(_0x580872)&&isAsConstVariable(_0x1468d9)&&_0x1468d9['init']&&_0x1468d9['init']['type']===nodeTypes['TSAsExpression']&&_0x1468d9['init']['expression']['type']===nodeTypes['objectExpression']){const _0x2301b9=_0x1468d9['init']['expression']['properties'],_0x7b8e09=getObjectPropsUsagesCount(_0x580872,_0x2301b9);checkProperties(_0x2301b9,_0x7b8e09,_0x5f535a);}}}}};});function checkProperties(_0x30ddda,_0x38d372,_0x2c9e7a){for(const _0x228824 of _0x30ddda){_0x228824['type']===nodeTypes['property']&&!_0x38d372['has'](_0x228824)&&(_0x228824['value']['type']===nodeTypes['objectExpression']&&hasUsedChild(_0x228824['value']['properties'],_0x38d372)?checkProperties(_0x228824['value']['properties'],_0x38d372,_0x2c9e7a):_0x2c9e7a['report']({'node':_0x228824,'messageId':ruleName}));}}__name(checkProperties,'checkProperties');function hasUsedChild(_0x5a37b9,_0x93bdf9){let _0x403556=![];for(const _0xee4d75 of _0x5a37b9){if(_0xee4d75['type']===nodeTypes['property']&&(_0x93bdf9['has'](_0xee4d75)||_0xee4d75['value']['type']===nodeTypes['objectExpression']&&hasUsedChild(_0xee4d75['value']['properties'],_0x93bdf9))){_0x403556=!![];break;}}return _0x403556;}__name(hasUsedChild,'hasUsedChild');

export { noUnusedPropertiesInConstants as default, ruleName };
