'use strict';
import { nodeTypes } from '@flint/infra/analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { commonLowerCaseWords } from '../../../base-repo/constants/internal-common-strings.js';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x4c4269,_0x4b783f)=>__defProp(_0x4c4269,'name',{'value':_0x4b783f,'configurable':!![]});const ruleName='must-not-use-inline-await';const ruleContent='\x0a###\x20**Must\x20not**\x20use\x20inline\x20await\x0a\x0a####\x20Wrong\x0a\x0areturn\x20(await\x20foo()).field;\x0a\x0a####\x20Correct\x0a\x0aconst\x20bar\x20=\x20await\x20foo();\x0areturn\x20bar.baz;\x0a\x0a####\x20Why\x0a\x0aStoring\x20the\x20result\x20of\x20an\x20async\x20function\x20in\x20a\x20separate\x20variable\x20increases\x20readability.',defaultAllowedProps=[commonLowerCaseWords['data']];var mustNotUseInlineAwait = createEslintRule(ruleName,ruleContent,__name(function create(_0x3ae3d7,_0x3240b1){const _0x3e0805=firstOrUndefined(_0x3240b1)?.['allowedProps']??[];return {'AwaitExpression'(_0x43de4a){const _0x4536b5=_0x43de4a['parent'];if(_0x4536b5){const _0x87935c=isDotAccessFromAwait(_0x43de4a,_0x3e0805);_0x87935c&&_0x3ae3d7['report']({'node':_0x43de4a,'messageId':ruleName});}}};},'create'),{'schema':[{'type':'object','properties':{'allowedProps':{'type':jsBasicTypes['array'],'items':{'type':jsBasicTypes['string']}}},'additionalProperties':![]}],'defaultOptions':[{'allowedProps':[...defaultAllowedProps]}]});function isTransparent(_0x22dade){return _0x22dade['type']===nodeTypes['TSNonNullExpression']||_0x22dade['type']===nodeTypes['TSAsExpression']||_0x22dade['type']===nodeTypes['TSTypeAssertion']||_0x22dade['type']===nodeTypes['chainExpression'];}__name(isTransparent,'isTransparent');function isMemberDotRead(_0x7c8218,_0x42d4ec){return _0x7c8218['type']===nodeTypes['memberExpression']&&!_0x7c8218['computed']&&_0x7c8218['property']['type']===nodeTypes['identifier']&&_0x7c8218['object']===_0x42d4ec;}__name(isMemberDotRead,'isMemberDotRead');function isWriteToMember(_0x897507){let _0x3e0a3e=![];return _0x897507['parent']?.['type']===nodeTypes['assignmentExpression']&&_0x897507['parent']['left']===_0x897507&&(_0x3e0a3e=!![]),_0x3e0a3e;}__name(isWriteToMember,'isWriteToMember');function isAllowedProperty(_0x26cdba,_0x5ea290){return _0x26cdba['property']['type']===nodeTypes['identifier']&&_0x5ea290['includes'](_0x26cdba['property']['name'])&&_0x26cdba['parent']['type']!==nodeTypes['memberExpression'];}__name(isAllowedProperty,'isAllowedProperty');function isDotAccessFromAwait(_0x358120,_0x519d1f){let _0x1b156d=![],_0x5d05df=_0x358120,_0x1a5911=_0x358120['parent'];while(_0x1a5911){if(isMemberDotRead(_0x1a5911,_0x5d05df)){_0x1a5911['type']===nodeTypes['memberExpression']&&(!isWriteToMember(_0x1a5911)&&!isAllowedProperty(_0x1a5911,_0x519d1f)&&(_0x1b156d=!![]));break;}if(!isTransparent(_0x1a5911))break;_0x5d05df=_0x1a5911,_0x1a5911=_0x1a5911['parent'];}return _0x1b156d;}__name(isDotAccessFromAwait,'isDotAccessFromAwait');

export { mustNotUseInlineAwait as default, ruleName };
