'use strict';
import _0x19fa71, { expect } from 'playwright/test';
import { uiAssertEqual } from '../asserters/ui-asserts.js';
import { createError } from '../../fd-toolbox/errors/errors.js';
import { logError } from '../../fd-toolbox/server/logging/logger.js';
import { uiElementVisibilityState } from '../../base-repo/constants/ui-constants.js';
import { commonLowerCaseWords } from '../../base-repo/constants/internal-common-strings.js';
import { ensureNotNullOrUndefined } from '../../fd-toolbox/functions/value-checking-functions.js';
import { htmlAttributes } from '../constants/ui-tester/html-contants.js';

var __defProp=Object['defineProperty'],__name=(_0x3c3ac8,_0x7b12c0)=>__defProp(_0x3c3ac8,'name',{'value':_0x7b12c0,'configurable':!![]});class UiTester{static{__name(this,'UiTester');}#page;constructor(_0xada88c){this.#page=_0xada88c;}get['page'](){return this.#page;}async['reload'](){await this.#page['reload'](),await this.#page['waitForLoadState'](waitingState['load']);}async['getText'](_0x4f57a5){const _0x375db2=await this['getById'](_0x4f57a5);return _0x375db2['textContent']();}async['getInnerHtml'](_0x402bd7){const _0xd2fd9d=await this['getById'](_0x402bd7);return _0xd2fd9d['innerHTML']();}async['waitForElementByText'](_0x1f9a4f){await this.#page['getByText'](_0x1f9a4f)['waitFor']();}async['goAndWait'](_0x2ebb3b){await this['gotoUrl'](_0x2ebb3b),await this['expectUrl'](_0x2ebb3b);}async['clickLoginButton'](_0x4212c4){await this['click'](_0x4212c4);}async['waitForDisappearFromUrl'](_0x3e190a){const _0x5c365b=0x205*-0x9d+-0x14702+-0x1*-0x36e73;await this.#page['waitForURL'](({href:_0x4d8abd})=>!_0x4d8abd['includes'](_0x3e190a),{'timeout':_0x5c365b});}async['gotoUrl'](_0x2406fd){await this.#page['goto'](_0x2406fd);}async['expectUrl'](_0x1e43d0){await this.#page['waitForURL'](({href:_0x5d8d27})=>_0x5d8d27['includes'](_0x1e43d0),{'timeout':waitTimeout});}async['click'](_0x27f233,_0x3b13ad){const _0x5d8bcf=await this['getById'](_0x27f233),_0x4e1d12=_0x5d8bcf['locator'](':scope:not([disabled])');await _0x4e1d12['click']({'force':_0x3b13ad});}async['waitForElementToLoad'](_0x77dcdf){try{const _0x340bb1=await this['getById'](_0x77dcdf);return await _0x340bb1['waitFor']({'state':uiElementVisibilityState['visible']}),!![];}catch{return ![];}}async['waitForElementWithIdPrefix'](_0x57ea1f,_0x5770b7=waitTimeout){try{return await this.#page['waitForFunction'](_0x325688=>!!document['querySelector']('[id^=\x27'+_0x325688+'\x27]'),_0x57ea1f,{'timeout':_0x5770b7}),!![];}catch{return ![];}}async['waitForElementToBeHidden'](_0xa1f73e){const _0x236004=await this['getById'](_0xa1f73e);await _0x236004['waitFor']({'state':uiElementVisibilityState['hidden']});}async['getResourceIndexByResourceId'](_0x28e02d,_0x1472fb){const _0xdef088='span[data-id=\x27'+_0x28e02d+'\x27]',_0x1b811c=htmlAttributes['dataRowIndex'];let _0x91cdac;if(_0x1472fb){const _0x57fe91=await this['getChildElementWithinParent'](_0x1472fb,_0xdef088);_0x91cdac=await waitForAndGetAttribute(_0x57fe91,_0x1b811c,_0x28e02d);}else {const _0x582aaf=this.#page['locator'](_0xdef088);_0x91cdac=await waitForAndGetAttribute(_0x582aaf,_0x1b811c,_0x28e02d);}if(_0x91cdac===void(-0x217f+0x65*-0xd+-0x135*-0x20))throw createError('Attribute\x20'+_0x1b811c+'\x20not\x20found\x20for\x20resourceId\x20'+_0x28e02d);return _0x91cdac;}async['getChildElementWithinParent'](_0x5b5deb,_0x17b9dc){const _0x19e659=await this['getById'](_0x5b5deb);await _0x19e659['waitFor']({'state':uiElementVisibilityState['visible']});const _0x424b43=_0x19e659['locator'](_0x17b9dc);return _0x424b43;}async['getByCss'](_0xe4f362){return this.#page['locator'](_0xe4f362);}async['getById'](_0x4d3cdc){const _0x35264f=getExactIdSelector(_0x4d3cdc),_0x1b7487=this.#page['locator'](_0x35264f),_0x2ea64f=await _0x1b7487['count']();if(_0x2ea64f>0x7*-0x541+-0xa*-0x392+0x113){if(_0x2ea64f>0x2699+-0xe45+-0x1853){const _0x301d95='Found\x20'+_0x2ea64f;logError(_0x301d95+'\x20elements\x20with\x20id\x20#'+_0x4d3cdc+',\x20using\x20the\x20first\x20one.');}return _0x1b7487['first']();}return _0x1b7487['first']();}async['assertEqual'](_0x52aec5,_0x19c85c){return expect(_0x52aec5)['toBe'](_0x19c85c);}async['assertNotEqual'](_0x1c67a2,_0x441167){return expect(_0x1c67a2)['not']['toBe'](_0x441167);}async['isElementExists'](_0x433169){const _0x13b93c=await this['getById'](_0x433169),_0x42ce40=_0x13b93c['count']();return await _0x42ce40>0x4*0x7c0+0x8c7*-0x3+-0x4ab;}async['goBack'](){await this.#page['goBack'](),await this.#page['waitForLoadState'](waitingState['load']);}async['clearWithBackspacesAndSendKeys'](_0x324435,_0x1f2fc1){const _0x209597=this['getById'](_0x324435),_0x50f803=await _0x209597;await _0x50f803['waitFor']({'state':uiElementVisibilityState['visible']}),await _0x50f803['clear'](),await _0x50f803['fill'](_0x1f2fc1);}async['getChildrenCount'](_0x3e605b){return _0x3e605b['evaluate'](_0x180c7a=>_0x180c7a['children']['length']);}async['assertChildrenCount'](_0x4ec1df,_0x144121){const _0x23533e=await this['getById'](_0x4ec1df);await _0x23533e['waitFor']({'state':uiElementVisibilityState['visible']});const _0x5bd8c1=await this['getChildrenCount'](_0x23533e);await uiAssertEqual(_0x5bd8c1,_0x144121);}async['getPrefixesById'](_0x17259a){return this.#page['locator']('[id^=\x22'+_0x17259a+'\x22]')['all']();}async['getChildren'](_0x4c6e18){return _0x4c6e18['evaluate'](_0x2ccbfb=>_0x2ccbfb['children']);}async['getChildrenByParentId'](_0x383d7f){const _0x2911ec=await this['getById'](_0x383d7f);return await _0x2911ec['waitFor']({'state':uiElementVisibilityState['visible']}),this['getChildren'](_0x2911ec);}async['waitForTextContentToBeChanged'](_0x4425f0){const _0x426ebb=await this['getById'](_0x4425f0);await _0x426ebb['waitFor']({'state':uiElementVisibilityState['visible']});const _0x4814c8=await _0x426ebb['textContent']();await this.#page['waitForFunction'](_0xc6c1d4=>{const _0x1afc62=_0xc6c1d4['el']?.['textContent']??'',_0x566305=_0xc6c1d4['prevText']??'';return _0x1afc62!==_0x566305;},{'el':await _0x426ebb['elementHandle'](),'prevText':_0x4814c8});}async['selectDropdownOption'](_0x41af6a,_0x520077){await this['click'](_0x41af6a),await this['click'](_0x520077);}async['waitForResponseJson'](_0x3576da){const _0x14f258=await this.#page['waitForResponse'](_0x3576da),_0x5114a1=await _0x14f258['json']();return _0x5114a1;}async['waitForElementTextById'](_0x3c1224,_0x47b0e8,_0x40168e=-0x5e6d+0xa*0xd63+0x4dbf){const _0x372931=await this['getById'](_0x3c1224);await expect(_0x372931)['toHaveText'](_0x47b0e8,{'timeout':_0x40168e});}async['waitForInputValueToMatch'](_0x4c1c5a,_0x2ab368){const _0xe8dc30=await this['getById'](_0x4c1c5a);await expect(_0xe8dc30)['toHaveValue'](_0x2ab368);}['getBaseUrl'](){const _0x35a457=_0x19fa71['info']()['project']['use']['baseURL'];return ensureNotNullOrUndefined(_0x35a457);}}const waitingState={'load':commonLowerCaseWords['load']},waitTimeout=0x1c540+-0xb*-0x368b+-0x1d349;async function waitForAndGetAttribute(_0x4c22a4,_0x3eb3d8,_0x293ffa){await _0x4c22a4['waitFor']({'state':uiElementVisibilityState['attached'],'timeout':0x7530});try{await _0x4c22a4['waitFor']({'state':uiElementVisibilityState['visible'],'timeout':0x2710});}catch{const _0x4376c0=await _0x4c22a4['getAttribute'](uiElementVisibilityState['hidden'])??void(-0x184*0x8+0x19*0xb6+-0x5a6);if(_0x4376c0===void(-0x49e*-0x1+0x1*0x1123+0x1*-0x15c1))throw createError('Element\x20with\x20resourceId\x20'+_0x293ffa+'\x20is\x20not\x20visible\x20and\x20not\x20hidden');}return await _0x4c22a4['getAttribute'](_0x3eb3d8)??void(0xdb5+-0x1b9*0x11+-0x7ca*-0x2);}__name(waitForAndGetAttribute,'waitForAndGetAttribute');function getExactIdSelector(_0xbde807){return '[id=\x22'+escapeAttributeSelectorValue(_0xbde807)+'\x22]';}__name(getExactIdSelector,'getExactIdSelector');function escapeAttributeSelectorValue(_0x5ee5ab){return _0x5ee5ab['replaceAll']('\x5c','\x5c\x5c')['replaceAll']('\x22','\x5c\x22');}__name(escapeAttributeSelectorValue,'escapeAttributeSelectorValue');

export { UiTester };
