(function(a,c){typeof exports=="object"&&typeof module!="undefined"?c(exports,require("@playwright/test"),require("node:path"),require("playwright")):typeof define=="function"&&define.amd?define(["exports","@playwright/test","node:path","playwright"],c):(a=typeof globalThis!="undefined"?globalThis:a||self,c(a.test={},a.test,a.path,a.playwright))})(this,function(a,c,h,f){"use strict";function m(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var k=m(h);const w=async t=>{await t.goto("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/welcome"),await t.locator("text=Get Started").click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/select-action"),await t.locator("text=Import wallet").click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/metametrics-opt-in"),await t.locator('[data-testid="page-container-footer-next"]').click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/create-password/import-with-seed-phrase"),await t.locator("select").selectOption("24");const o="hockey   dilemma   magic   rigid   blade   crawl   soldier   screen   mind   siege   disorder   hint   ramp   solid   flat   caution   swamp   anger   attend   trim   tell   obscure   rice   math".split(/\s+/);for(const[n,r]of Object.entries(o)){const s=t.locator(`[data-testid="import-srp__srp-word-${n}"]`);await s.click(),await s.fill(r)}await t.locator("text=I have read and agree to the Terms of Use").click(),await t.locator("#password").click(),await t.locator("#password").fill("Over123456"),await t.locator("#confirm-password").click(),await t.locator("#confirm-password").fill("Over123456"),await t.locator('button:has-text("Import")').click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/end-of-flow"),await t.locator("text=All Done").click(),await t.locator(".popover-header__title button").click()},p=c.test.extend({context:async({},t)=>{const e=k.default.join(__dirname,"./extension"),o=await f.chromium.launchPersistentContext("",{devtools:!1,headless:!1,timeout:0,args:[`--disable-extensions-except=${e}`,`--load-extension=${e}`]});await t(o),await o.close()},metaMaskPage:async({context:t,extensionId:e},o)=>{const n=`chrome-extension://${e}/popup.html`,r=t.pages(),s=r.length>0?r[0]:await t.newPage();await w(s),await s.goto(n);for(const d of t.pages())d.url().includes("home.html#initialize/welcome")&&await d.close();await o(s)},extensionId:async({context:t},e)=>{let[o]=t.backgroundPages();o||(o=await t.waitForEvent("backgroundpage"));const n=o.url().split("/")[2];await e(n)}}),i={confirmFeeEtcBtn:["button",{hasText:"Confirm"}],approveAddNetworkBtn:["button",{hasText:"Approve"}],switchNetworkBtn:["button",{hasText:"Switch network"}],rejectBtn:["button",{hasText:"Reject"}],nextBtn:["button",{hasText:"Next"}],connectBtn:["button",{hasText:"Connect"}]},l=async(t,e,o)=>{let n=!1;for(;!n;)await t.reload({waitUntil:"load"}),await t.waitForTimeout(1500),n=await t.locator(e,o).isVisible();return t.locator(e,o)};class u{constructor(e){this.metaMaskPage=e}async connect2Wallet(){await l(this.metaMaskPage,...i.nextBtn),await this.metaMaskPage.locator(...i.nextBtn).click(),await this.metaMaskPage.locator(...i.connectBtn).click()}async addAndSwitchNetwork(){await l(this.metaMaskPage,...i.approveAddNetworkBtn),await this.metaMaskPage.locator(...i.approveAddNetworkBtn).click(),await this.metaMaskPage.locator(...i.switchNetworkBtn).click()}async confirmTx(){await l(this.metaMaskPage,...i.confirmFeeEtcBtn),await this.metaMaskPage.locator(...i.confirmFeeEtcBtn).click()}}const g=t=>{console.log(`
---pages begin----`),t.pages().forEach(e=>console.log("pageurl",e.url())),t.backgroundPages().forEach(e=>console.log("background page url",e.url())),console.log(`---pages end----
`)};a.Metamask=u,a.SELECTORS=i,a.printPageUrls=g,a.signinWallet=w,a.testWithMetaMask=p,a.waitForMetaMask=l,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
