'use strict';
import { nodeTypes } from '@flint/infra/analysis/function-analysis';
import { isStringLiteral, isTemplateLiteral, isPrivateIdentifier, isBinaryExpression, isIdentifier, isVariableDefinition, isVariableDeclarator, isVariableDeclaration } from '@flint/infra/analysis/node-type-type-guards';
import { getNodeTsType } from '@flint/infra/analysis/type-analysis';
import { getDefinition } from '@flint/infra/analysis/scope-analysis';
import { getEnclosingFunctionFromNode } from '@flint/infra/analysis/tree-analysis';
import { variableDeclarationKinds } from '@flint/infra/analysis/module-analysis';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import _0x2de5a4__default from 'typescript';
import { first } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x1fc174,_0x217e1a)=>__defProp(_0x1fc174,'name',{'value':_0x217e1a,'configurable':!![]});function isStringType(_0x15e793){return typeof _0x15e793===jsBasicTypes['string'];}__name(isStringType,'isStringType');function isStringLikeTypeNode(_0xe7666d,_0x1c0599){return (getNodeTsType(_0xe7666d,_0x1c0599)['flags']&_0x2de5a4__default['TypeFlags']['StringLike'])!==-0x2bd*-0x4+-0x1*0x1fa1+0x14ad;}__name(isStringLikeTypeNode,'isStringLikeTypeNode');function getStringLiterals(_0x15744a){if(_0x15744a['type']===nodeTypes['binaryExpression'])return getStringLiteralsFromBinary(_0x15744a);return getStringLiteralsFromTemplate(_0x15744a['quasis']);}__name(getStringLiterals,'getStringLiterals');function isEmptyString(_0x2c288d){return isStringLiteral(_0x2c288d)&&_0x2c288d['value']===''||isTemplateLiteral(_0x2c288d)&&_0x2c288d['quasis']['length']===0x3*0x4be+0x1628+-0x43*0x8b&&first(_0x2c288d['quasis'])['value']['cooked']==='';}__name(isEmptyString,'isEmptyString');function isFixedStringExpressionIterative(_0x7892c,_0x11c3dc,_0x3d6d70,_0x4ba279){let _0x26fbac=!![];const _0x3d82f0=[_0x7892c];let _0xf33e06=_0x3d82f0['pop']();while(_0xf33e06&&_0x26fbac){const _0x170189=evaluateFixedStringExpressionStep(_0xf33e06,_0x11c3dc,_0x3d6d70,_0x4ba279);_0x26fbac=_0x170189['isFixedString'];if(_0x26fbac&&_0x170189['nextExpressions']['length']>0xa51+0x1*0x3d+-0x7*0x182)for(const _0x5cada9 of _0x170189['nextExpressions']){_0x3d82f0['push'](_0x5cada9);}_0xf33e06=_0x3d82f0['pop']();}return _0x26fbac;}__name(isFixedStringExpressionIterative,'isFixedStringExpressionIterative');function isExpressionOrNull(_0x2a2ed9){return !isPrivateIdentifier(_0x2a2ed9);}__name(isExpressionOrNull,'isExpressionOrNull');function collectStringLiterals(_0x3b7a91,_0x6cfbc4){if(isStringLiteral(_0x3b7a91))_0x6cfbc4['push'](_0x3b7a91['value']);else _0x3b7a91['type']===nodeTypes['binaryExpression']&&(collectStringLiterals(_0x3b7a91['left'],_0x6cfbc4),collectStringLiterals(_0x3b7a91['right'],_0x6cfbc4));}__name(collectStringLiterals,'collectStringLiterals');function getStringLiteralsFromBinary(_0x2f15ec){const _0x2b62fc=[];return collectStringLiterals(_0x2f15ec['left'],_0x2b62fc),collectStringLiterals(_0x2f15ec['right'],_0x2b62fc),_0x2b62fc;}__name(getStringLiteralsFromBinary,'getStringLiteralsFromBinary');function getStringLiteralsFromTemplate(_0x47bab1){return _0x47bab1['map'](_0x52f8ce=>_0x52f8ce['value']['cooked']??_0x52f8ce['value']['raw']);}__name(getStringLiteralsFromTemplate,'getStringLiteralsFromTemplate');function evaluateFixedStringExpressionStep(_0xd4330,_0x49880a,_0x40a22c,_0x1e65b1){let _0x5a63c0=![];const _0x2ebd18=[];if(isStringLiteral(_0xd4330))_0x5a63c0=!![];else {if(isTemplateLiteral(_0xd4330))_0x5a63c0=_0xd4330['expressions']['length']===-0x1277+0x102b+0x24c;else {if(isBinaryExpression(_0xd4330)){const _0x842749=_0xd4330['left'],_0x2d2af0=_0xd4330['right'],_0x566596=isExpressionOrNull(_0x842749)&&isExpressionOrNull(_0x2d2af0),_0x477b98=_0xd4330['operator']==='+'&&_0x566596;_0x5a63c0=_0x477b98,_0x477b98&&_0x566596&&(_0x2ebd18['push'](_0x842749),_0x2ebd18['push'](_0x2d2af0));}else isIdentifier(_0xd4330)&&(_0x5a63c0=appendFixedStringIdentifierInit(_0xd4330,_0x49880a,_0x40a22c,_0x1e65b1,_0x2ebd18));}}return {'isFixedString':_0x5a63c0,'nextExpressions':_0x2ebd18};}__name(evaluateFixedStringExpressionStep,'evaluateFixedStringExpressionStep');function appendFixedStringIdentifierInit(_0x2e4077,_0x44d477,_0x3b1f5d,_0x4dffa3,_0x34df3c){const _0x3598de=getDefinition(_0x2e4077,_0x3b1f5d);let _0x541715=![];if(_0x3598de&&isVariableDefinition(_0x3598de)&&isVariableDeclarator(_0x3598de['node'])){const _0x19dfd5=_0x3598de['node']['parent'],_0x4ef357=getEnclosingFunctionFromNode(_0x3598de['node']),_0x2b5900=isVariableDeclaration(_0x19dfd5)&&_0x19dfd5['kind']===variableDeclarationKinds['const']&&_0x4ef357===_0x44d477&&!!_0x3598de['node']['init']&&!_0x4dffa3['has'](_0x3598de['node']);_0x541715=_0x2b5900,_0x2b5900&&_0x3598de['node']['init']&&(_0x4dffa3['add'](_0x3598de['node']),_0x34df3c['push'](_0x3598de['node']['init']));}return _0x541715;}__name(appendFixedStringIdentifierInit,'appendFixedStringIdentifierInit');

export { getStringLiterals, isEmptyString, isExpressionOrNull, isFixedStringExpressionIterative, isStringLikeTypeNode, isStringType };
