'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes, isJSXNode, getLineDistance } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';

var __defProp=Object['defineProperty'],__name=(_0x51d9a4,_0xb01c79)=>__defProp(_0x51d9a4,'name',{'value':_0xb01c79,'configurable':!![]});const ruleName='must-not-use-ternary-operator-for-complicated-conditions';const constants={'messageIds':{'mustNotUseTernaryOperatorForComplicatedConditions':'mustNotUseTernaryOperatorForComplicatedConditions'},'meta':{'type':ruleTypes['suggestion'],'docs':{'description':'Disallow\x20the\x20use\x20of\x20ternary\x20operator\x20for\x20complicated\x20conditions.'},'messages':{'mustNotUseTernaryOperatorForComplicatedConditions':'must-not-use-ternary-operator-for-complicated-conditions\x0a###\x20**Must\x20not**\x20use\x20\x22?\x22\x20for\x20complicated\x20conditions.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20foo\x20=\x20bar()\x0a\x20\x20\x20\x20?\x20baz()\x0a\x20\x20\x20\x20:\x20[\x0a\x20\x20\x20\x20\x20\x20\x20\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20qux:\x20quux,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20corge:\x20grault,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20garply:\x20waldo,\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20];\x0a\x0a####\x20Correct\x0a\x0aif(bar()){\x0a\x20\x20\x20\x20…\x0a}\x20else{\x0a\x20\x20\x20\x20…\x0a}\x0a\x0a####\x20Why\x0a\x0aTernary\x20operators\x20are\x20useful\x20for\x20simple,\x20short\x20conditions,\x20but\x20when\x20they\x20involve\x20multiple\x20operations\x20or\x20complex\x20structures,\x20they\x20can\x20make\x20the\x20code\x20harder\x20to\x20understand\x20and\x20maintain.'},'schema':[]},'limits':{'maxFunctionArgumentsSimple':0x3}},createRule=ESLintUtils['RuleCreator'](_0x558a99=>''+url+_0x558a99),mustNotUseTernaryOperatorForComplicatedConditions=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x2eede5){return {[nodeTypes['conditionalExpression']](_0xd073e8){if(isJSXNode(_0xd073e8['consequent'])||isJSXNode(_0xd073e8['alternate']))return;const _0x5e40a0=isComplexExpression(_0xd073e8['consequent']),_0x1d302c=isComplexExpression(_0xd073e8['alternate']),_0x3312d0=isMultiLineExpression(_0xd073e8['consequent']),_0x1875c0=isMultiLineExpression(_0xd073e8['alternate']);(_0x5e40a0||_0x1d302c||_0x3312d0||_0x1875c0)&&_0x2eede5['report']({'node':_0xd073e8,'messageId':constants['messageIds']['mustNotUseTernaryOperatorForComplicatedConditions']});}};}});function isComplexArrowFunction(_0xea90fd){let _0xb73492=![];_0xea90fd['params']['length']>0x1fb7+-0x18fa+-0x6bb&&(_0xb73492=!![]);_0xea90fd['body']['type']===nodeTypes['callExpression']&&_0xea90fd['body']['arguments']['length']>constants['limits']['maxFunctionArgumentsSimple']&&(_0xb73492=!![]);if(_0xea90fd['body']['type']===nodeTypes['blockStatement'])_0xb73492=!![];return _0xb73492;}__name(isComplexArrowFunction,'isComplexArrowFunction');function isComplexExpression(_0x58cc51){if(!_0x58cc51)return ![];switch(_0x58cc51['type']){case nodeTypes['objectExpression']:return _0x58cc51['properties']['length']>-0xf9+0x1*0x1cd0+0x7d*-0x39;case nodeTypes['arrayExpression']:return _0x58cc51['elements']['length']>0xc4b+0x12ad*0x2+-0x31a3*0x1||_0x58cc51['elements']['some'](_0x437741=>_0x437741&&_0x437741['type']===nodeTypes['objectExpression']);case nodeTypes['callExpression']:case nodeTypes['newExpression']:return _0x58cc51['arguments']['length']>constants['limits']['maxFunctionArgumentsSimple'];case nodeTypes['conditionalExpression']:return !![];case nodeTypes['arrowFunctionExpression']:return isComplexArrowFunction(_0x58cc51);case nodeTypes['functionExpression']:return !![];default:return ![];}}__name(isComplexExpression,'isComplexExpression');function isMultiLineExpression(_0x12ba3c){return getLineDistance(_0x12ba3c,_0x12ba3c)!==0xfd1+0xa*0x3b7+-0x34f7;}__name(isMultiLineExpression,'isMultiLineExpression');

export { mustNotUseTernaryOperatorForComplicatedConditions as default, ruleName };
