'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { isTestFile, nodeTypes, getMemberPathParts } from '@flint/infra/analysis';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x102c54,_0x4985dd)=>__defProp(_0x102c54,'name',{'value':_0x4985dd,'configurable':!![]});const ruleName='must-not-use-page-directly';const constants={'pageIdentifier':flintRuleIdentifiers['page']},ruleContent='\x0a###\x20**Must\x20not**\x20use\x20page\x20directly.\x0a\x0a####\x20Wrong\x0a\x0aawait\x20page.click(\x22#foo-submit\x22);\x0aconst\x20text\x20=\x20await\x20page.textContent(\x22#foo-result\x22);\x0a\x0a####\x20Correct\x0a\x0aawait\x20uiTester.click(\x22foo-submit\x22);\x0aconst\x20text\x20=\x20await\x20uiTester.getText(\x22foo-result\x22);\x0a\x0a####\x20Why\x0a\x0aDirect\x20usage\x20of\x20page\x20in\x20tests\x20makes\x20scenarios\x20harder\x20to\x20read\x20and\x20maintain,\x20so\x20use\x20uiTester\x20helpers\x20instead.';var mustNotUsePageDirectly = createEslintRule(ruleName,ruleContent,_0xaa83f7=>{if(!isTestFile(_0xaa83f7['filename']))return {};return {'CallExpression'(_0xe69775){if(!isDirectPageCall(_0xe69775['callee']))return;_0xaa83f7['report']({'node':_0xe69775,'messageId':ruleName});}};});function isDirectPageCall(_0x3a6bfb){if(_0x3a6bfb['type']!==nodeTypes['memberExpression'])return ![];const _0x1babe3=getMemberPathParts(_0x3a6bfb);return firstOrUndefined(_0x1babe3??[])===constants['pageIdentifier'];}__name(isDirectPageCall,'isDirectPageCall');

export { mustNotUsePageDirectly as default, ruleName };
