'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { getExportedConstName, isExportNamedVariableDeclaration, isExportConstDeclaration, nodeTypes, isNameMatch } from '@flint/infra/analysis';
import { typeKeywords } from '../../../base-repo/constants/tools-constants.js';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x590e5e,_0x3f0dcf)=>__defProp(_0x590e5e,'name',{'value':_0x3f0dcf,'configurable':!![]});const ruleName='group-consts-as-const';const ruleContent='\x0a###\x20**Must**\x20write\x20constants\x20with\x20\x27as\x20const\x27.\x20\x0a\x0a####\x20Wrong\x0a\x0aexport\x20const\x20quxes\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20“Bar”,\x0a\x20\x20\x20\x20baz:\x20“Baz”,\x0a};\x0a\x0a####\x20Correct\x0a\x0aexport\x20const\x20quxes\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20“Bar”,\x0a\x20\x20\x20\x20baz:\x20“Baz”,\x0a}\x20as\x20const;\x0a\x0a####\x20Why\x0a\x0a\x27as\x20const\x27\x20makes\x20object\x20properties\x20readonly\x20and\x20preserves\x20literal\x20types\x20of\x20nested\x20values';var groupConstsAsConst = createEslintRule(ruleName,ruleContent,_0x4eafdb=>{return {'Program'(_0x3fc4d3){const _0x126256=_0x3fc4d3['body'];for(const _0x3654cd of _0x126256){isExportWithMultipleDeclarations(_0x3654cd)&&_0x4eafdb['report']({'node':_0x3654cd,'messageId':ruleName});if(isExportConstWithoutAsConst(_0x3654cd)){const _0x3429f6=getExportedConstName(_0x3654cd),_0xbc70ea=_0x3429f6&&hasPseudoEnumType(_0x126256,_0x3429f6);!_0xbc70ea&&_0x4eafdb['report']({'node':_0x3654cd,'messageId':ruleName});}}}};});function isExportWithMultipleDeclarations(_0x3ed5cb){return isExportNamedVariableDeclaration(_0x3ed5cb)&&_0x3ed5cb['declaration']['declarations']['length']>-0xbfd+0x1625+-0xa27;}__name(isExportWithMultipleDeclarations,'isExportWithMultipleDeclarations');function isExportConstWithoutAsConst(_0x11a2b0){if(!isExportConstDeclaration(_0x11a2b0))return ![];const _0x4eac8b=firstOrUndefined(_0x11a2b0['declaration']['declarations']),_0x378f70=_0x4eac8b?.['init'];if(!_0x378f70)return ![];const _0x3e8a83=_0x378f70['parent'];return _0x378f70['type']===nodeTypes['objectExpression']&&(!_0x3e8a83||_0x3e8a83['type']!==nodeTypes['TSAsExpression']);}__name(isExportConstWithoutAsConst,'isExportConstWithoutAsConst');function isPseudoEnumTypeAlias(_0x23ea83,_0x1f7a2b){let _0x1e79b8=![];if(_0x23ea83['type']===nodeTypes['exportNamedDeclaration']){const _0xfcbb5e=_0x23ea83['declaration'];if(_0xfcbb5e&&_0xfcbb5e['type']===nodeTypes['TSTypeAliasDeclaration']){const _0xbe9bad=_0xfcbb5e['typeAnnotation'];if(_0xbe9bad['type']===nodeTypes['TSIndexedAccessType']){const _0x3d04b4=_0xbe9bad['objectType'],_0x53d4fb=_0xbe9bad['indexType'],_0x5d9526=_0x3d04b4['type']===nodeTypes['TSTypeQuery']&&_0x3d04b4['exprName']['type']===nodeTypes['identifier']&&isNameMatch(_0x3d04b4['exprName'],_0x1f7a2b),_0x31a8c5=_0x53d4fb['type']===nodeTypes['TSTypeOperator']&&_0x53d4fb['operator']===typeKeywords['keyof'];if(_0x5d9526&&_0x31a8c5){const _0x5092b4=_0x53d4fb['typeAnnotation'];_0x1e79b8=!!_0x5092b4&&_0x5092b4['type']===nodeTypes['TSTypeQuery']&&_0x5092b4['exprName']['type']===nodeTypes['identifier']&&isNameMatch(_0x5092b4['exprName'],_0x1f7a2b);}}}}return _0x1e79b8;}__name(isPseudoEnumTypeAlias,'isPseudoEnumTypeAlias');function hasPseudoEnumType(_0x440be9,_0x21dfac){return _0x440be9['some'](_0x62983c=>isPseudoEnumTypeAlias(_0x62983c,_0x21dfac));}__name(hasPseudoEnumType,'hasPseudoEnumType');

export { groupConstsAsConst as default, ruleName };
