'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes } from '@flint/infra/analysis';
import { files } from '../../../base-repo/app-constants/project-paths.js';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { cliOptionFlags } from '../../../base-repo/constants/tools-constants.js';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';

var __defProp=Object['defineProperty'],__name=(_0x540c2f,_0x32f45f)=>__defProp(_0x540c2f,'name',{'value':_0x32f45f,'configurable':!![]});const ruleName='must-use-prefix-for-env-vars';const ruleId='mustUsePrefixForEnvVars';const uniqueNonEmptyStringArray={'type':jsBasicTypes['array'],'items':{'type':jsBasicTypes['string']},'minItems':0x1,'uniqueItems':!![]},constants={'meta':{'type':ruleTypes['problem'],'docs':{'description':ruleName},'messages':{[ruleId]:ruleName+'\x0a###\x20**Must**\x20use\x20prefix\x20for\x20env\x20vars.\x0a\x0a####\x20Wrong\x0a\x0aFOO=\x0aNEXT_PUBLIC_BAR=\x0a\x0a####\x20Correct\x0a\x0aFD_FOO=\x0aNEXT_PUBLIC_FD_BAR=\x0a\x0a####\x20Why\x0a\x0aThis\x20ensures\x20consistency,\x20improves\x20readability,\x20and\x20prevents\x20naming\x20conflicts\x20across\x20different\x20parts\x20of\x20the\x20application.'},'schema':[{'type':jsBasicTypes['object'],'properties':{'requiredPrefixes':uniqueNonEmptyStringArray,'vendorPrefixes':uniqueNonEmptyStringArray,'ignore':{'type':jsBasicTypes['object'],'properties':{'equals':uniqueNonEmptyStringArray,'startsWith':uniqueNonEmptyStringArray},'additionalProperties':![]}},'additionalProperties':![]}]},'processLiteral':flintRuleIdentifiers['process'],'envLiteral':files['env']},createRule=ESLintUtils['RuleCreator'](_0x711296=>''+url+_0x711296),mustUsePrefixForEnvVars=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[{'vendorPrefixes':['NEXT_PUBLIC_'],'requiredPrefixes':['FD_','CI_'],'ignore':{'startsWith':['npm_']}}],'create'(_0x564415,[{requiredPrefixes:requiredPrefixes=[],vendorPrefixes:vendorPrefixes=[],ignore:_0x59683c}]){return {'MemberExpression'(_0x1fd0df){if(!isProcessEnv(_0x1fd0df))return;const _0x4f9167=getEnvVarName(_0x1fd0df);if(!_0x4f9167||isIgnored(_0x4f9167,_0x59683c))return;const _0x46fe24=getEnvVarNameParts(_0x4f9167,{'requiredPrefixes':requiredPrefixes,'vendorPrefixes':vendorPrefixes});if(!_0x46fe24||_0x46fe24['requiredPrefix'])return;_0x564415['report']({'node':_0x1fd0df['property'],'messageId':ruleId});}};}});function isProcessEnv(_0x1f43a3){return _0x1f43a3['object']['type']===nodeTypes['memberExpression']&&_0x1f43a3['object']['object']['type']===nodeTypes['identifier']&&_0x1f43a3['object']['object']['name']===constants['processLiteral']&&_0x1f43a3['object']['property']['type']===nodeTypes['identifier']&&_0x1f43a3['object']['property']['name']===constants['envLiteral'];}__name(isProcessEnv,'isProcessEnv');function getEnvVarName(_0x5e604f){const _0x2f65e6=_0x5e604f['property'];let _0x369977;if(_0x5e604f['computed'])_0x2f65e6['type']===nodeTypes['literal']&&typeof _0x2f65e6['value']==='string'&&(_0x369977=_0x2f65e6['value']);else _0x2f65e6['type']===nodeTypes['identifier']&&(_0x369977=_0x2f65e6['name']);return _0x369977;}__name(getEnvVarName,'getEnvVarName');function escapeWithBackslash(_0x56c701){return '\x5c'+_0x56c701;}__name(escapeWithBackslash,'escapeWithBackslash');function escapeRegExpPattern(_0x5d7df6){const _0x128603=['^','$','/','\x5c','.','*','+','?','{','}','(',')','[',']','|'];return _0x5d7df6['replaceAll'](new RegExp(regExpOr(_0x128603['map'](escapeWithBackslash)),cliOptionFlags['globalRegex']),escapeWithBackslash);}__name(escapeRegExpPattern,'escapeRegExpPattern');function regExpOr(_0xa3c71a){return _0xa3c71a['join']('|');}__name(regExpOr,'regExpOr');function createRegExp({requiredPrefixes:_0x758111,vendorPrefixes:_0x2ec22d}){const _0x222139=_0x758111['map'](escapeRegExpPattern),_0x32d41b=_0x2ec22d['map'](escapeRegExpPattern);return new RegExp('^(?:('+regExpOr(_0x32d41b)+')?('+regExpOr(_0x222139)+')?([A-Za-z0-9_\x5c$]+))$');}__name(createRegExp,'createRegExp');function getEnvVarNameParts(_0x504814,_0x5c4fa2){const _0x455d62=createRegExp(_0x5c4fa2)['exec'](_0x504814);if(!_0x455d62)return void(-0x9*-0x2e1+0x41*-0x11+-0x1598);const [,_0xc07281,_0x5095f0,_0x3c81be]=_0x455d62;return {'vendorPrefix':_0xc07281,'requiredPrefix':_0x5095f0,'name':_0x3c81be};}__name(getEnvVarNameParts,'getEnvVarNameParts');function isIgnored(_0x45d7a9,_0x830832){const _0x4bb60f={'equals':[],'startsWith':[],..._0x830832};return _0x4bb60f['equals']['includes'](_0x45d7a9)||_0x4bb60f['startsWith']['some'](_0x189241=>_0x45d7a9['startsWith'](_0x189241));}__name(isIgnored,'isIgnored');

export { mustUsePrefixForEnvVars as default, ruleId, ruleName };
