'use strict';
import { variableDeclarationKinds, normalizePathSeparators, isVariableDeclarator, isExportNamedVariableDeclaration, screamingSnakeToCamel, nodeTypes, isIdentifier, normalizeNodes } from '@flint/infra/analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { httpMethods } from '../../../base-repo/constants/http-methods.js';

var __defProp=Object['defineProperty'],__name=(_0x5eb131,_0x4eff0f)=>__defProp(_0x5eb131,'name',{'value':_0x4eff0f,'configurable':!![]});const ruleName='must-not-use-all-caps-constants';const ruleContent='\x0a`{{actual}}`\x20is\x20an\x20invalid\x20constant\x20name.\x20Please\x20rename\x20it\x20to\x20`{{recommended}}`.\x0a\x0a###\x20**Must\x20not**\x20use\x20ALL_CAPS\x20for\x20constants.\x0a\x0aUsing\x20ALL_CAPS\x20for\x20constants\x20is\x20only\x20allowed\x20for\x20environment\x20variables.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20FOO\x20=\x20\x22bar\x22;\x0aconst\x20BAZ_QUX\x20=\x20\x22quux\x22;\x0a\x0a####\x20Correct\x0a\x0aconst\x20foo\x20=\x20\x22bar\x22;\x0aconst\x20bazQux\x20=\x20\x22quux\x22;\x0a\x0a####\x20Why\x0a\x0aALL_CAPS\x20constants\x20make\x20code\x20noisy\x20and\x20inconsistent\x20with\x20the\x20project\x20style.',allowedHttpMethods=[httpMethods['get'],httpMethods['post'],httpMethods['put'],httpMethods['delete'],httpMethods['patch'],httpMethods['options'],httpMethods['connect'],httpMethods['method'],httpMethods['trace']];var mustNotUseAllCapsConstants = createEslintRule(ruleName,ruleContent,__name(function create(_0x4140d0,_0x328220){return {'VariableDeclaration'(_0x4c17d2){if(_0x4c17d2['kind']!==variableDeclarationKinds['const'])return;for(const _0x46a822 of _0x4c17d2['declarations']){handleNode(_0x46a822['id'],_0x4140d0,_0x328220);}}};},'create'),{'schema':[{'type':jsBasicTypes['object'],'properties':{'allow':{'type':jsBasicTypes['array'],'items':{'type':jsBasicTypes['string']},'minItems':0x1,'uniqueItems':!![]},'allowedPrefixes':{'type':jsBasicTypes['array'],'items':{'type':jsBasicTypes['string']},'minItems':0x1,'uniqueItems':!![]}},'additionalProperties':![]}],'defaultOptions':[{'allow':[],'allowedPrefixes':[]}]});function isProhibitedIdentifier(_0x41ae52){const _0x47f912=/^[A-Z0-9_$]+$/['test'](_0x41ae52),_0x3ecc0c=/[A-Z]/['test'](_0x41ae52);return _0x47f912&&_0x3ecc0c;}__name(isProhibitedIdentifier,'isProhibitedIdentifier');function isRouteHttpMethod(_0x2984bb,_0x22d1a1){const _0x528b60=normalizePathSeparators(_0x22d1a1),_0x3abe83=/\/app\/.*\/route\.ts$/['test'](_0x528b60),_0x2e86e7=isVariableDeclarator(_0x2984bb['parent'])&&isExportNamedVariableDeclaration(_0x2984bb['parent']['parent']['parent']);return allowedHttpMethods['includes'](_0x2984bb['name'])&&_0x2e86e7&&_0x3abe83;}__name(isRouteHttpMethod,'isRouteHttpMethod');function handleIdentifier(_0x52767e,_0x3fa498,_0x254dd2){const [{allow:_0x5aeb40,allowedPrefixes:_0x7778af}]=_0x254dd2,_0x18dee0=_0x3fa498['filename'],_0x3c9ee7=_0x7778af?.['some'](_0x464948=>_0x52767e['name']['startsWith'](_0x464948));if(!isProhibitedIdentifier(_0x52767e['name'])||_0x5aeb40?.['includes'](_0x52767e['name'])||_0x3c9ee7||isRouteHttpMethod(_0x52767e,_0x18dee0))return;_0x3fa498['report']({'node':_0x52767e,'messageId':ruleName,'data':{'actual':_0x52767e['name'],'recommended':screamingSnakeToCamel(_0x52767e['name'])}});}__name(handleIdentifier,'handleIdentifier');function handleObject(_0x4b4541,_0x14595f,_0x4f526e){for(const _0x2abcba of _0x4b4541){if(_0x2abcba['type']===nodeTypes['property'])handleNode(_0x2abcba['value'],_0x14595f,_0x4f526e);else _0x2abcba['type']===nodeTypes['restElement']&&handleNode(_0x2abcba['argument'],_0x14595f,_0x4f526e);}}__name(handleObject,'handleObject');function handleArray(_0x4f4e92,_0x3dad93,_0x4f879d){for(const _0x4976b9 of _0x4f4e92){_0x4976b9&&handleNode(_0x4976b9,_0x3dad93,_0x4f879d);}}__name(handleArray,'handleArray');function handleNode(_0x3dfa45,_0x49fd56,_0x54c021){isIdentifier(_0x3dfa45)&&handleIdentifier(_0x3dfa45,_0x49fd56,_0x54c021),_0x3dfa45['type']===nodeTypes['objectPattern']&&handleObject(_0x3dfa45['properties'],_0x49fd56,_0x54c021),_0x3dfa45['type']===nodeTypes['arrayPattern']&&handleArray(normalizeNodes(_0x3dfa45['elements']),_0x49fd56,_0x54c021),_0x3dfa45['type']===nodeTypes['assignmentPattern']&&handleNode(_0x3dfa45['left'],_0x49fd56,_0x54c021),_0x3dfa45['type']===nodeTypes['restElement']&&handleNode(_0x3dfa45['argument'],_0x49fd56,_0x54c021);}__name(handleNode,'handleNode');

export { mustNotUseAllCapsConstants as default, ruleName };
