'use strict';
import _0x1869d0__default from 'path';
import { hookNamePattern, startsWithUpperCasePattern } from '@flint/infra/constants/rules-regex';
import { nodeTypes, getCalleeName } from '@flint/infra/analysis/function-analysis';
import { isCallExpression, isNamedFunctionWithIdentifier, isIdentifier, isStringLiteral } from '@flint/infra/analysis/node-type-type-guards';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { reactHooks } from '../../../base-repo/constants/react-hooks.js';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { first } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x5f065f,_0x38d304)=>__defProp(_0x5f065f,'name',{'value':_0x38d304,'configurable':!![]});const builtInHooks=new Set([reactHooks['useState'],reactHooks['useEffect'],reactHooks['useContext'],reactHooks['useReducer'],reactHooks['useCallback'],reactHooks['useMemo'],reactHooks['useRef'],reactHooks['useImperativeHandle'],reactHooks['useLayoutEffect'],reactHooks['useDebugValue'],reactHooks['useTransition'],reactHooks['useId']]);function hasEventHandler(_0x3b69c9){return _0x3b69c9['startsWith'](flintRuleIdentifiers['on'])&&_0x3b69c9[0x1*-0x1429+0x10c3+0x368]===_0x3b69c9[-0x109f*-0x1+0x124+-0x11c1]?.['toUpperCase']();}__name(hasEventHandler,'hasEventHandler');function isFixtureFile(_0xe01fb7){const _0x22cf62=[/fixtures/i,/\.fixture\.[tj]sx?$/i,/test-data/i,/mocks/i];return _0x22cf62['some'](_0x59a354=>_0x59a354['test'](_0xe01fb7));}__name(isFixtureFile,'isFixtureFile');function isCamelCase(_0x4853a4){const _0x1053c1=/^[a-z][a-zA-Z0-9]*$/;return _0x1053c1['test'](_0x4853a4);}__name(isCamelCase,'isCamelCase');function isPascalCase(_0x5ac3b8){const _0x2bd198=/^[A-Z][a-zA-Z0-9]*$/;return _0x2bd198['test'](_0x5ac3b8);}__name(isPascalCase,'isPascalCase');function getFileName(_0xfd6e55,_0x238b90){return _0x1869d0__default['basename'](_0xfd6e55,_0x238b90);}__name(getFileName,'getFileName');function getFileNamePrefix(_0x138522,_0x27f10a){const _0x5678c1=getFileName(_0x138522),_0x405e7d=_0x27f10a['exec'](_0x5678c1);return _0x405e7d?_0x405e7d[-0x81e+-0x4c5*0x5+-0x3e*-0x84]:void(0x25d4+0xabf*0x3+-0x4611);}__name(getFileNamePrefix,'getFileNamePrefix');function getFunctionName(_0xb8bdd8){const _0x3ce0a3=_0xb8bdd8['parent'];let _0x819541;return _0xb8bdd8['type']===nodeTypes['functionDeclaration']&&_0xb8bdd8['id']&&(_0x819541=_0xb8bdd8['id']['name']),_0x3ce0a3?.['type']===nodeTypes['variableDeclarator']&&_0x3ce0a3['id']['type']===nodeTypes['identifier']&&(_0x819541=_0x3ce0a3['id']['name']),_0x3ce0a3?.['type']===nodeTypes['methodDefinition']&&_0x3ce0a3['key']['type']===nodeTypes['identifier']&&(_0x819541=_0x3ce0a3['key']['name']),_0x3ce0a3?.['type']===nodeTypes['property']&&_0x3ce0a3['key']['type']===nodeTypes['identifier']&&(_0x819541=_0x3ce0a3['key']['name']),isCallExpression(_0xb8bdd8)&&(_0x819541=getCalleeName(_0xb8bdd8['callee'])),_0x819541;}__name(getFunctionName,'getFunctionName');function getFunctionNames(_0x893bbd){const _0x44e1a7=new Set(),_0x1470fc=getFunctionName(_0x893bbd);return _0x1470fc&&_0x44e1a7['add'](_0x1470fc),isNamedFunctionWithIdentifier(_0x893bbd)&&_0x44e1a7['add'](_0x893bbd['id']['name']),[..._0x44e1a7];}__name(getFunctionNames,'getFunctionNames');function getPropertyName(_0x535ed7){let _0x4b024f;const _0x2caa2e=_0x535ed7['type']===nodeTypes['property']?_0x535ed7['key']:_0x535ed7['property'];return isIdentifier(_0x2caa2e)&&(_0x4b024f=_0x2caa2e['name']),_0x2caa2e['type']===nodeTypes['literal']&&typeof _0x2caa2e['value']==='string'&&(_0x4b024f=_0x2caa2e['value']),_0x2caa2e['type']===nodeTypes['templateLiteral']&&_0x2caa2e['expressions']['length']===0x219e*0x1+0x23cb+-0x4569&&(_0x4b024f=first(_0x2caa2e['quasis'])['value']['cooked']),_0x4b024f;}__name(getPropertyName,'getPropertyName');function isPropertyNamed(_0x481e86,_0xb79fea){if(_0x481e86['key']['type']===nodeTypes['identifier']&&isNameMatch(_0x481e86['key'],_0xb79fea))return !![];if(_0x481e86['key']['type']===nodeTypes['literal']&&_0x481e86['key']['value']===_0xb79fea)return !![];return ![];}__name(isPropertyNamed,'isPropertyNamed');function getMemberPathParts(_0x39f145){const _0xa59723=[];let _0x4a7ce8=_0x39f145;while(_0x4a7ce8['type']===nodeTypes['memberExpression']){const _0x29f523=_0x4a7ce8['property'];_0x29f523['type']===nodeTypes['identifier']&&_0xa59723['unshift'](_0x29f523['name']),_0x29f523['type']===nodeTypes['literal']&&typeof _0x29f523['value']===jsBasicTypes['string']&&_0xa59723['unshift'](_0x29f523['value']),_0x4a7ce8=_0x4a7ce8['object'];}return _0x4a7ce8['type']===nodeTypes['identifier']&&_0xa59723['unshift'](_0x4a7ce8['name']),_0x4a7ce8['type']===nodeTypes['thisExpression']&&_0xa59723['unshift']('this'),_0xa59723['length']!==0x3fa*-0x3+-0x1c7c+0x286a?_0xa59723:void(0x1283+0x31*-0xc2+0x129f);}__name(getMemberPathParts,'getMemberPathParts');function isSameBaseMember(_0x18f873,_0x39bfd5){const _0x5bc7c2=getMemberPathParts(_0x18f873),_0x31e9c3=getMemberPathParts(_0x39bfd5);if(!_0x5bc7c2||!_0x31e9c3||_0x5bc7c2['length']>_0x31e9c3['length'])return ![];return _0x5bc7c2['every']((_0x5692ea,_0x543bed)=>_0x5692ea===_0x31e9c3[_0x543bed]);}__name(isSameBaseMember,'isSameBaseMember');function isMatchesNamedMember(_0x94d6cb,_0x3bd629,_0x1694dd){if(_0x3bd629!==void(0x2377+-0x1*0x1867+-0xb10)&&_0x94d6cb['object']['type']===nodeTypes['identifier']&&_0x94d6cb['object']['name']!==_0x3bd629)return ![];if(_0x1694dd!==void(0x4c5+-0x1564+-0x17*-0xb9)&&(_0x94d6cb['property']['type']===nodeTypes['identifier']&&!isNameMatch(_0x94d6cb['property'],_0x1694dd)||_0x94d6cb['property']['type']===nodeTypes['literal']&&_0x94d6cb['property']['value']!==_0x1694dd))return ![];return !![];}__name(isMatchesNamedMember,'isMatchesNamedMember');function isHookByName(_0x56c610){return !!_0x56c610&&hookNamePattern['test'](_0x56c610);}__name(isHookByName,'isHookByName');function isHookName(_0x3bb213){return builtInHooks['has'](_0x3bb213)||hookNamePattern['test'](_0x3bb213);}__name(isHookName,'isHookName');function isComponentByName(_0x3807a9){let _0x203606=![];const _0x326ed5=getFunctionName(_0x3807a9);return _0x326ed5&&startsWithUpperCasePattern['test'](_0x326ed5)&&(_0x203606=!![]),_0x203606;}__name(isComponentByName,'isComponentByName');function isReactHook(_0x2541be){return /^use[A-Z]/['test'](_0x2541be);}__name(isReactHook,'isReactHook');function isNameMatch(_0x22eea2,_0x445850){return _0x22eea2['type']===nodeTypes['identifier']&&_0x22eea2['name']===_0x445850||isStringLiteral(_0x22eea2)&&_0x22eea2['value']===_0x445850;}__name(isNameMatch,'isNameMatch');function getVariableName(_0x397295){let _0x5e67ff;return _0x397295['parent']?.['type']===nodeTypes['variableDeclarator']&&_0x397295['parent']['id']['type']===nodeTypes['identifier']&&(_0x5e67ff=_0x397295['parent']['id']['name']),_0x5e67ff;}__name(getVariableName,'getVariableName');function getMethodNameFromCallee(_0x26b791,_0x5ca5aa){let _0x40dd31,_0x5b914a=_0x26b791,_0x14712f=!![];while(_0x14712f){if(_0x5b914a['type']===nodeTypes['identifier'])_0x40dd31=_0x5b914a['name'],_0x14712f=![];else {if(_0x5b914a['type']===nodeTypes['memberExpression']){if(_0x5b914a['property']['type']===nodeTypes['identifier'])_0x40dd31=_0x5b914a['property']['name'],_0x14712f=![];else (_0x5b914a['object']['type']===nodeTypes['memberExpression']||_0x5b914a['object']['type']===nodeTypes['identifier']&&(_0x5ca5aa===void(-0x10*-0x22d+-0x20f5*0x1+-0x1db)||_0x5b914a['object']['name']===_0x5ca5aa)||_0x5b914a['object']['type']===nodeTypes['callExpression'])&&(_0x5b914a=_0x5b914a['object']);}}}return _0x40dd31;}__name(getMethodNameFromCallee,'getMethodNameFromCallee');function getSpecifierName(_0x4407c6){return isIdentifier(_0x4407c6)?_0x4407c6['name']:_0x4407c6['value'];}__name(getSpecifierName,'getSpecifierName');function isConstantsFileOrFolder(_0x23ff70,_0xbf8c01){const _0x3f0b86=_0x23ff70['split']('/'),_0x1a87b8=_0x3f0b86['at'](-(-0xbf8+0xc7d+-0x84))??'',_0x450116=_0x3f0b86['slice'](0x5*-0x5ad+0x437*-0x5+0x3174*0x1,-(-0x17e5+-0x449*-0x1+0x139d));return _0x1a87b8['includes'](_0xbf8c01)||_0x450116['some'](_0x584fc7=>_0x584fc7['includes'](_0xbf8c01));}__name(isConstantsFileOrFolder,'isConstantsFileOrFolder');function hasSuffix(_0x1aaddc,_0x86235d){return isIdentifier(_0x1aaddc)&&_0x1aaddc['name']['endsWith'](_0x86235d);}__name(hasSuffix,'hasSuffix');function getTSTypeReferenceNames(_0x179b0f){const _0x48b3e4=[];if(!_0x179b0f)return _0x48b3e4;else {if(_0x179b0f['type']===nodeTypes['TSTypeReference'])isIdentifier(_0x179b0f['typeName'])&&_0x48b3e4['push'](_0x179b0f['typeName']);else {if(_0x179b0f['type']===nodeTypes['TSUnionType']||_0x179b0f['type']===nodeTypes['TSIntersectionType'])return _0x179b0f['types']['flatMap'](getTSTypeReferenceNames);}}return _0x48b3e4;}__name(getTSTypeReferenceNames,'getTSTypeReferenceNames');

export { getFileName, getFileNamePrefix, getFunctionName, getFunctionNames, getMemberPathParts, getMethodNameFromCallee, getPropertyName, getSpecifierName, getTSTypeReferenceNames, getVariableName, hasEventHandler, hasSuffix, isCamelCase, isComponentByName, isConstantsFileOrFolder, isFixtureFile, isHookByName, isHookName, isMatchesNamedMember, isNameMatch, isPascalCase, isPropertyNamed, isReactHook, isSameBaseMember };
