/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@tenkeylabs/dappwright@2.13.5/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var fs$1=require("fs"),os=require("os"),path=require("path"),playwright=require("playwright-core"),util=require("util"),events=require("events"),zlib=require("zlib"),stream=require("stream"),https=require("https"),test=require("@playwright/test");function _interopDefaultLegacy(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function _interopNamespace(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(a){if("default"!==a){var i=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:function(){return t[a]}})}})),e.default=t,e}var fs__default=_interopDefaultLegacy(fs$1),os__default=_interopDefaultLegacy(os),path__default=_interopDefaultLegacy(path),path__namespace=_interopNamespace(path),playwright__default=_interopDefaultLegacy(playwright),util__default=_interopDefaultLegacy(util),events__default=_interopDefaultLegacy(events),zlib__default=_interopDefaultLegacy(zlib),stream__default=_interopDefaultLegacy(stream);const EXTENSION_ID="gadekpdjmpjjnnemgnhkbjgnjpdaakgh",EXTENSION_PUB_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnpiOcYGaEp02v5On5luCk/4g9j+ujgWeGlpZVibaSz6kUlyiZvcVNIIUXR568uv5NrEi5+j9+HbzshLALhCn9S43E7Ha6Xkdxs3kOEPBu8FRNwFh2S7ivVr6ixnl2FCGwfkP1S1r7k665eC1/xYdJKGCc8UByfSw24Rtl5odUqZX1SaE6CsQEMymCFcWhpE3fV+LZ6RWWJ63Zm1ac5KmKzXdj7wZzN3onI0Csc8riBZ0AujkThJmCR8tZt2PkVUDX9exa0XkJb79pe0Ken5Bt2jylJhmQB7R3N1pVNhNQt17Sytnwz6zG2YsB2XNd/1VYJe52cPNJc7zvhQJpHjh5QIDAQAB",DOWNLOAD_STATE_FILES={downloading:".downloading",success:".success",error:".error"},DOWNLOAD_CONFIG={pollIntervalMs:2e3};
/**
 * @license node-stream-zip | (c) 2020 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE
 * Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE
 */
let fs=fs__default.default;const consts={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSIGFIRST:80,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,MAXFILECOMMENT:65535,ENDL64HDR:20,ENDL64SIG:117853008,ENDL64SIGFIRST:80,ENDL64OFS:8,END64HDR:56,END64SIG:101075792,END64SIGFIRST:80,END64SUB:24,END64TOT:32,END64SIZ:40,END64OFF:48,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FLG_ENTRY_ENC:1,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535},StreamZip=function(t){let e,a,i,n,s,o;const r=this,c=!1!==t.storeEntries?{}:null,l=t.file,d=t.nameEncoding?new TextDecoder(t.nameEncoding):null;function u(){fs.fstat(e,((s,o)=>{if(s)return r.emit("error",s);a=o.size,i=t.chunkSize||Math.round(a/1e3),i=Math.max(Math.min(i,Math.min(131072,a)),Math.min(1024,a)),function(){const t=Math.min(consts.ENDHDR+consts.MAXFILECOMMENT,a);n={win:new FileWindowBuffer(e),totalReadLength:t,minPos:a-t,lastPos:a,chunkSize:Math.min(1024,i),firstByte:consts.ENDSIGFIRST,sig:consts.ENDSIG,complete:f},n.win.read(a-n.chunkSize,n.chunkSize,w)}()}))}function w(t,e){if(t||!e)return r.emit("error",t||new Error("Archive read error"));let a=n.lastPos,i=a-n.win.position;const s=n.win.buffer,o=n.minPos;for(;--a>=o&&--i>=0;)if(s.length-i>=4&&s[i]===n.firstByte&&s.readUInt32LE(i)===n.sig)return n.lastBufferPosition=i,n.lastBytesRead=e,void n.complete();if(a===o)return r.emit("error",new Error("Bad archive"));if(n.lastPos=a+1,n.chunkSize*=2,a<=o)return r.emit("error",new Error("Bad archive"));const c=Math.min(n.chunkSize,a-o);n.win.expandLeft(c,w)}function f(){const t=n.win.buffer,e=n.lastBufferPosition;try{s=new CentralDirectoryHeader,s.read(t.slice(e,e+consts.ENDHDR)),s.headerOffset=n.win.position+e,s.commentLength?r.comment=t.slice(e+consts.ENDHDR,e+consts.ENDHDR+s.commentLength).toString():r.comment=null,r.entriesCount=s.volumeEntries,r.centralDirectory=s,s.volumeEntries===consts.EF_ZIP64_OR_16&&s.totalEntries===consts.EF_ZIP64_OR_16||s.size===consts.EF_ZIP64_OR_32||s.offset===consts.EF_ZIP64_OR_32?function(){const t=consts.ENDL64HDR;n.lastBufferPosition>t?(n.lastBufferPosition-=t,h()):(n={win:n.win,totalReadLength:t,minPos:n.win.position-t,lastPos:n.win.position,chunkSize:n.chunkSize,firstByte:consts.ENDL64SIGFIRST,sig:consts.ENDL64SIG,complete:h},n.win.read(n.lastPos-n.chunkSize,n.chunkSize,w))}():(n={},g())}catch(t){r.emit("error",t)}}function h(){const t=n.win.buffer,e=new CentralDirectoryLoc64Header;e.read(t.slice(n.lastBufferPosition,n.lastBufferPosition+consts.ENDL64HDR));const i=a-e.headerOffset;n={win:n.win,totalReadLength:i,minPos:e.headerOffset,lastPos:n.lastPos,chunkSize:n.chunkSize,firstByte:consts.END64SIGFIRST,sig:consts.END64SIG,complete:p},n.win.read(a-n.chunkSize,n.chunkSize,w)}function p(){const t=n.win.buffer,e=new CentralDirectoryZip64Header;e.read(t.slice(n.lastBufferPosition,n.lastBufferPosition+consts.END64HDR)),r.centralDirectory.volumeEntries=e.volumeEntries,r.centralDirectory.totalEntries=e.totalEntries,r.centralDirectory.size=e.size,r.centralDirectory.offset=e.offset,r.entriesCount=e.volumeEntries,n={},g()}function g(){n={win:new FileWindowBuffer(e),pos:s.offset,chunkSize:i,entriesLeft:s.volumeEntries},n.win.read(n.pos,Math.min(i,a-n.pos),m)}function m(e,a){if(e||!a)return r.emit("error",e||new Error("Entries read error"));let s=n.pos-n.win.position,o=n.entry;const l=n.win.buffer,u=l.length;try{for(;n.entriesLeft>0;){o||(o=new ZipEntry,o.readHeader(l,s),o.headerOffset=n.win.position+s,n.entry=o,n.pos+=consts.CENHDR,s+=consts.CENHDR);const e=o.fnameLen+o.extraLen+o.comLen;if(u-s<e+(n.entriesLeft>1?consts.CENHDR:0))return n.win.moveRight(i,m,s),void(n.move=!0);o.read(l,s,d),t.skipEntryNameValidation||o.validateName(),c&&(c[o.name]=o),r.emit("entry",o),n.entry=o=null,n.entriesLeft--,n.pos+=e,s+=e}r.emit("ready")}catch(e){r.emit("error",e)}}function y(){if(!c)throw new Error("storeEntries disabled")}function E(t){return t.offset+consts.LOCHDR+t.fnameLen+t.extraLen}function k(t){return!!(8&~t.flags)}function I(t,a,i){r.stream(t,((n,s)=>{if(n)i(n);else{let n,o;s.on("error",(t=>{o=t,n&&(s.unpipe(n),n.close((()=>{i(t)})))})),fs.open(a,"w",((c,l)=>{if(c)return i(c);o?fs.close(e,(()=>{i(o)})):(n=fs.createWriteStream(a,{fd:l}),n.on("finish",(()=>{r.emit("extract",t,a),o||i()})),s.pipe(n))}))}}))}function T(t,e,a){if(!e.length)return a();let i=e.shift();i=path__default.default.join(t,path__default.default.join(...i)),fs.mkdir(i,{recursive:!0},(i=>{if(i&&"EEXIST"!==i.code)return a(i);T(t,e,a)}))}function _(t,e,a,i,n){if(!a.length)return i(null,n);const s=a.shift(),o=path__default.default.join(t,s.name.replace(e,""));I(s,o,(s=>{if(s)return i(s,n);_(t,e,a,i,n+1)}))}t.fd?(e=t.fd,u()):fs.open(l,"r",((t,a)=>{if(t)return r.emit("error",t);e=a,u()})),Object.defineProperty(this,"ready",{get:()=>false}),this.entry=function(t){return y(),c[t]},this.entries=function(){return y(),c},this.stream=function(t,a){return this.openEntry(t,((t,i)=>{if(t)return a(t);const n=E(i);let s=new EntryDataReaderStream(e,n,i.compressedSize);if(i.method===consts.STORED);else{if(i.method!==consts.DEFLATED)return a(new Error("Unknown compression method: "+i.method));s=s.pipe(zlib__default.default.createInflateRaw())}k(i)&&(s=s.pipe(new EntryVerifyStream(s,i.crc,i.size))),a(null,s)}),!1)},this.entryDataSync=function(t){let a=null;if(this.openEntry(t,((e,i)=>{a=e,t=i}),!0),a)throw a;let i=Buffer.alloc(t.compressedSize);if(new FsRead(e,i,0,t.compressedSize,E(t),(t=>{a=t})).read(!0),a)throw a;if(t.method===consts.STORED);else{if(t.method!==consts.DEFLATED&&t.method!==consts.ENHANCED_DEFLATED)throw new Error("Unknown compression method: "+t.method);i=zlib__default.default.inflateRawSync(i)}if(i.length!==t.size)throw new Error("Invalid size");if(k(t)){new CrcVerify(t.crc,t.size).data(i)}return i},this.openEntry=function(t,a,i){if("string"==typeof t&&(y(),!(t=c[t])))return a(new Error("Entry not found"));if(!t.isFile)return a(new Error("Entry is not file"));if(!e)return a(new Error("Archive closed"));const n=Buffer.alloc(consts.LOCHDR);new FsRead(e,n,0,n.length,t.offset,(e=>{if(e)return a(e);let i;try{t.readDataHeader(n),t.encrypted&&(i=new Error("Entry encrypted"))}catch(t){i=t}a(i,t)})).read(i)},this.extract=function(t,e,a){let i=t||"";if("string"==typeof t&&((t=this.entry(t))?i=t.name:i.length&&"/"!==i[i.length-1]&&(i+="/")),!t||t.isDirectory){const t=[],n=[],s={};for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)&&0===e.lastIndexOf(i,0)){let a=e.replace(i,"");const o=c[e];if(o.isFile&&(t.push(o),a=path__default.default.dirname(a)),a&&!s[a]&&"."!==a){s[a]=!0;let t=a.split("/").filter((t=>t));for(t.length&&n.push(t);t.length>1;){t=t.slice(0,t.length-1);const e=t.join("/");if(s[e]||"."===e)break;s[e]=!0,n.push(t)}}}n.sort(((t,e)=>t.length-e.length)),n.length?T(e,n,(n=>{n?a(n):_(e,i,t,a,0)})):_(e,i,t,a,0)}else fs.stat(e,((i,n)=>{n&&n.isDirectory()?I(t,path__default.default.join(e,path__default.default.basename(t.name)),a):I(t,e,a)}))},this.close=function(t){o||!e?(o=!0,t&&t()):(o=!0,fs.close(e,(a=>{e=null,t&&t(a)})))};const b=events__default.default.EventEmitter.prototype.emit;this.emit=function(...t){if(!o)return b.call(this,...t)}};StreamZip.setFs=function(t){fs=t},StreamZip.debugLog=(...t)=>{StreamZip.debug&&console.log(...t)},util__default.default.inherits(StreamZip,events__default.default.EventEmitter);const propZip=Symbol("zip");StreamZip.async=class extends events__default.default.EventEmitter{constructor(t){super();const e=new StreamZip(t);e.on("entry",(t=>this.emit("entry",t))),e.on("extract",((t,e)=>this.emit("extract",t,e))),this[propZip]=new Promise(((t,a)=>{e.on("ready",(()=>{e.removeListener("error",a),t(e)})),e.on("error",a)}))}get entriesCount(){return this[propZip].then((t=>t.entriesCount))}get comment(){return this[propZip].then((t=>t.comment))}async entry(t){return(await this[propZip]).entry(t)}async entries(){return(await this[propZip]).entries()}async stream(t){const e=await this[propZip];return new Promise(((a,i)=>{e.stream(t,((t,e)=>{t?i(t):a(e)}))}))}async entryData(t){const e=await this.stream(t);return new Promise(((t,a)=>{const i=[];e.on("data",(t=>i.push(t))),e.on("end",(()=>{t(Buffer.concat(i))})),e.on("error",(t=>{e.removeAllListeners("end"),a(t)}))}))}async extract(t,e){const a=await this[propZip];return new Promise(((i,n)=>{a.extract(t,e,((t,e)=>{t?n(t):i(e)}))}))}async close(){const t=await this[propZip];return new Promise(((e,a)=>{t.close((t=>{t?a(t):e()}))}))}};class CentralDirectoryHeader{read(t){if(t.length!==consts.ENDHDR||t.readUInt32LE(0)!==consts.ENDSIG)throw new Error("Invalid central directory");this.volumeEntries=t.readUInt16LE(consts.ENDSUB),this.totalEntries=t.readUInt16LE(consts.ENDTOT),this.size=t.readUInt32LE(consts.ENDSIZ),this.offset=t.readUInt32LE(consts.ENDOFF),this.commentLength=t.readUInt16LE(consts.ENDCOM)}}class CentralDirectoryLoc64Header{read(t){if(t.length!==consts.ENDL64HDR||t.readUInt32LE(0)!==consts.ENDL64SIG)throw new Error("Invalid zip64 central directory locator");this.headerOffset=readUInt64LE(t,consts.ENDSUB)}}class CentralDirectoryZip64Header{read(t){if(t.length!==consts.END64HDR||t.readUInt32LE(0)!==consts.END64SIG)throw new Error("Invalid central directory");this.volumeEntries=readUInt64LE(t,consts.END64SUB),this.totalEntries=readUInt64LE(t,consts.END64TOT),this.size=readUInt64LE(t,consts.END64SIZ),this.offset=readUInt64LE(t,consts.END64OFF)}}class ZipEntry{readHeader(t,e){if(t.length<e+consts.CENHDR||t.readUInt32LE(e)!==consts.CENSIG)throw new Error("Invalid entry header");this.verMade=t.readUInt16LE(e+consts.CENVEM),this.version=t.readUInt16LE(e+consts.CENVER),this.flags=t.readUInt16LE(e+consts.CENFLG),this.method=t.readUInt16LE(e+consts.CENHOW);const a=t.readUInt16LE(e+consts.CENTIM),i=t.readUInt16LE(e+consts.CENTIM+2);this.time=parseZipTime(a,i),this.crc=t.readUInt32LE(e+consts.CENCRC),this.compressedSize=t.readUInt32LE(e+consts.CENSIZ),this.size=t.readUInt32LE(e+consts.CENLEN),this.fnameLen=t.readUInt16LE(e+consts.CENNAM),this.extraLen=t.readUInt16LE(e+consts.CENEXT),this.comLen=t.readUInt16LE(e+consts.CENCOM),this.diskStart=t.readUInt16LE(e+consts.CENDSK),this.inattr=t.readUInt16LE(e+consts.CENATT),this.attr=t.readUInt32LE(e+consts.CENATX),this.offset=t.readUInt32LE(e+consts.CENOFF)}readDataHeader(t){if(t.readUInt32LE(0)!==consts.LOCSIG)throw new Error("Invalid local header");this.version=t.readUInt16LE(consts.LOCVER),this.flags=t.readUInt16LE(consts.LOCFLG),this.method=t.readUInt16LE(consts.LOCHOW);const e=t.readUInt16LE(consts.LOCTIM),a=t.readUInt16LE(consts.LOCTIM+2);this.time=parseZipTime(e,a),this.crc=t.readUInt32LE(consts.LOCCRC)||this.crc;const i=t.readUInt32LE(consts.LOCSIZ);i&&i!==consts.EF_ZIP64_OR_32&&(this.compressedSize=i);const n=t.readUInt32LE(consts.LOCLEN);n&&n!==consts.EF_ZIP64_OR_32&&(this.size=n),this.fnameLen=t.readUInt16LE(consts.LOCNAM),this.extraLen=t.readUInt16LE(consts.LOCEXT)}read(t,e,a){const i=t.slice(e,e+=this.fnameLen);this.name=a?a.decode(new Uint8Array(i)):i.toString("utf8");const n=t[e-1];this.isDirectory=47===n||92===n,this.extraLen&&(this.readExtra(t,e),e+=this.extraLen),this.comment=this.comLen?t.slice(e,e+this.comLen).toString():null}validateName(){if(/\\|^\w+:|^\/|(^|\/)\.\.(\/|$)/.test(this.name))throw new Error("Malicious entry: "+this.name)}readExtra(t,e){let a,i;const n=e+this.extraLen;for(;e<n;)a=t.readUInt16LE(e),e+=2,i=t.readUInt16LE(e),e+=2,consts.ID_ZIP64===a&&this.parseZip64Extra(t,e,i),e+=i}parseZip64Extra(t,e,a){a>=8&&this.size===consts.EF_ZIP64_OR_32&&(this.size=readUInt64LE(t,e),e+=8,a-=8),a>=8&&this.compressedSize===consts.EF_ZIP64_OR_32&&(this.compressedSize=readUInt64LE(t,e),e+=8,a-=8),a>=8&&this.offset===consts.EF_ZIP64_OR_32&&(this.offset=readUInt64LE(t,e),e+=8,a-=8),a>=4&&this.diskStart===consts.EF_ZIP64_OR_16&&(this.diskStart=t.readUInt32LE(e))}get encrypted(){return(this.flags&consts.FLG_ENTRY_ENC)===consts.FLG_ENTRY_ENC}get isFile(){return!this.isDirectory}}class FsRead{constructor(t,e,a,i,n,s){this.fd=t,this.buffer=e,this.offset=a,this.length=i,this.position=n,this.callback=s,this.bytesRead=0,this.waiting=!1}read(t){let e;if(StreamZip.debugLog("read",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0,t){let a=0;try{a=fs.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(t){e=t}this.readCallback(t,e,e?a:null)}else fs.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,t))}readCallback(t,e,a){if("number"==typeof a&&(this.bytesRead+=a),e||!a||this.bytesRead===this.length)return this.waiting=!1,this.callback(e,this.bytesRead);this.read(t)}}class FileWindowBuffer{constructor(t){this.position=0,this.buffer=Buffer.alloc(0),this.fd=t,this.fsOp=null}checkOp(){if(this.fsOp&&this.fsOp.waiting)throw new Error("Operation in progress")}read(t,e,a){this.checkOp(),this.buffer.length<e&&(this.buffer=Buffer.alloc(e)),this.position=t,this.fsOp=new FsRead(this.fd,this.buffer,0,e,this.position,a).read()}expandLeft(t,e){this.checkOp(),this.buffer=Buffer.concat([Buffer.alloc(t),this.buffer]),this.position-=t,this.position<0&&(this.position=0),this.fsOp=new FsRead(this.fd,this.buffer,0,t,this.position,e).read()}expandRight(t,e){this.checkOp();const a=this.buffer.length;this.buffer=Buffer.concat([this.buffer,Buffer.alloc(t)]),this.fsOp=new FsRead(this.fd,this.buffer,a,t,this.position+a,e).read()}moveRight(t,e,a){this.checkOp(),a?this.buffer.copy(this.buffer,0,a):a=0,this.position+=a,this.fsOp=new FsRead(this.fd,this.buffer,this.buffer.length-a,a,this.position+this.buffer.length-a,e).read()}}class EntryDataReaderStream extends stream__default.default.Readable{constructor(t,e,a){super(),this.fd=t,this.offset=e,this.length=a,this.pos=0,this.readCallback=this.readCallback.bind(this)}_read(t){const e=Buffer.alloc(Math.min(t,this.length-this.pos));e.length?fs.read(this.fd,e,0,e.length,this.offset+this.pos,this.readCallback):this.push(null)}readCallback(t,e,a){this.pos+=e,t?(this.emit("error",t),this.push(null)):e?(e!==a.length&&(a=a.slice(0,e)),this.push(a)):this.push(null)}}class EntryVerifyStream extends stream__default.default.Transform{constructor(t,e,a){super(),this.verify=new CrcVerify(e,a),t.on("error",(t=>{this.emit("error",t)}))}_transform(t,e,a){let i;try{this.verify.data(t)}catch(t){i=t}a(i,t)}}class CrcVerify{constructor(t,e){this.crc=t,this.size=e,this.state={crc:-1,size:0}}data(t){const e=CrcVerify.getCrcTable();let a=this.state.crc,i=0,n=t.length;for(;--n>=0;)a=e[255&(a^t[i++])]^a>>>8;if(this.state.crc=a,this.state.size+=t.length,this.state.size>=this.size){const t=Buffer.alloc(4);if(t.writeInt32LE(4294967295&~this.state.crc,0),a=t.readUInt32LE(0),a!==this.crc)throw new Error("Invalid CRC");if(this.state.size!==this.size)throw new Error("Invalid size")}}static getCrcTable(){let t=CrcVerify.crcTable;if(!t){CrcVerify.crcTable=t=[];const e=Buffer.alloc(4);for(let a=0;a<256;a++){let i=a;for(let t=8;--t>=0;)1&i?i=3988292384^i>>>1:i>>>=1;i<0&&(e.writeInt32LE(i,0),i=e.readUInt32LE(0)),t[a]=i}}return t}}function parseZipTime(t,e){const a=toBits(t,16),i=toBits(e,16),n={h:parseInt(a.slice(0,5).join(""),2),m:parseInt(a.slice(5,11).join(""),2),s:2*parseInt(a.slice(11,16).join(""),2),Y:parseInt(i.slice(0,7).join(""),2)+1980,M:parseInt(i.slice(7,11).join(""),2),D:parseInt(i.slice(11,16).join(""),2)},s=[n.Y,n.M,n.D].join("-")+" "+[n.h,n.m,n.s].join(":")+" GMT+0";return new Date(s).getTime()}function toBits(t,e){let a=(t>>>0).toString(2);for(;a.length<e;)a="0"+a;return a.split("")}function readUInt64LE(t,e){return 4294967296*t.readUInt32LE(e+4)+t.readUInt32LE(e)}var node_stream_zip=StreamZip;const downloadDir=(t,e)=>path__default.default.resolve(os__default.default.tmpdir(),"dappwright",t,e.replace(/\./g,"_")),extractZip=async(t,e)=>{const a=new node_stream_zip.async({file:t});fs__default.default.mkdirSync(e,{recursive:!0}),await a.extract(null,e)},editExtensionPubKey=t=>{const e=path__default.default.resolve(t,"manifest.json"),a=JSON.parse(fs__default.default.readFileSync(e,"utf-8"));a.key=EXTENSION_PUB_KEY,fs__default.default.writeFileSync(e,JSON.stringify(a))},request=t=>new Promise((e=>{https.get(t,(t=>{if(302==t.statusCode){https.get(t.headers.location,e).on("error",(t=>{throw console.warn("request redirected error:",t.message),t}))}else e(t)})).on("error",(t=>{throw console.warn("request error:",t.message),t}))})),getGithubRelease=(t,e)=>new Promise(((a,i)=>{const n=RegExp(`v?${e}$`,"img"),s={headers:{"User-Agent":"Mozilla/5.0"}};process.env.GITHUB_TOKEN&&(s.headers.Authorization=`Bearer ${process.env.GITHUB_TOKEN}`);const o=new URL(t);o.searchParams.set("per_page","100");https.get(o.toString(),s,(s=>{let o="";s.on("data",(t=>{o+=t})),s.on("end",(()=>{const s=JSON.parse(o);if(!Array.isArray(s))return i(`There was a problem connecting to github API to get the extension release (URL: ${t}). Error: ${s.message}`);for(const t of s)if(!t.draft&&("latest"===e||n.test(t.tag_name)))for(const e of t.assets)e.name.includes("chrome")&&a({downloadUrl:e.browser_download_url,filename:e.name,tag:t.tag_name});i(`Version ${e} not found!`)}))})).on("error",(t=>{throw console.warn("getGithubRelease error:",t.message),t}))})),downloadGithubRelease=(t,e,a)=>new Promise((async i=>{fs__default.default.existsSync(a)||fs__default.default.mkdirSync(a,{recursive:!0});const n=path__default.default.join(a,t),s=fs__default.default.createWriteStream(n),o=await request(e);o.pipe(s),o.on("end",(()=>{i(n)}))})),printVersion=(t,e,a)=>{console.log(""),"latest"===e?console.warn("[33m%s[0m",`It is not recommended to run ${t} with "latest" version. Use it at your own risk or set to the recommended version "${a}".`):isNewerVersion(a,e)?console.warn("[33m%s[0m",`Seems you are running a newer version (${e}) of ${t} than recommended by the Dappwright team.\n      Use it at your own risk or set to the recommended version "${a}".`):isNewerVersion(e,a)?console.warn("[33m%s[0m",`Seems you are running an older version (${e}) of ${t} than recommended by the Dappwright team.\n      Use it at your own risk or set the recommended version "${a}".`):console.log(`Using ${t} v${e}`),console.log("")},isNewerVersion=(t,e)=>{if(t===e)return!1;const a=t.replace(/[^\d.-]/g,"").split("."),i=e.replace(/[^\d.-]/g,"").split("."),n=a.length>i.length?a.length:i.length;for(let t=0;t<n;t++)if((Number(a[t])||0)!==(Number(i[t])||0))return(Number(i[t])||0)>(Number(a[t])||0);return!0},createWalletDownloader=(t,e,a)=>async i=>{const{version:n}=i;return(await downloadWalletExtension(t,n,e,a)).path};async function downloadWalletExtension(t,e,a,i){const n=createDownloadStatePaths(downloadDir(t,e));return e?isPrimaryWorker()&&!isDownloadComplete(n)?(printVersion(t,e,i),await performDownload(t,e,a,n),{path:n.rootDir,wasDownloaded:!0}):(await waitForDownloadCompletion(t,n),{path:n.rootDir,wasDownloaded:!1}):(console.info(`Running tests on local ${t} build`),{path:n.rootDir,wasDownloaded:!1})}async function performDownload(t,e,a,i){prepareRootDir(i),markDownloadStarted(i);try{console.info(`Downloading ${t} ${e}...`);const n=await getGithubRelease(a,e),s=path__default.default.dirname(i.rootDir),o=await downloadGithubRelease(n.filename,n.downloadUrl,s);await extractZip(o,i.rootDir),editExtensionPubKey(i.rootDir),markDownloadSuccess(i)}catch(t){throw handleDownloadError(i,t),t}finally{cleanupDownloadingFlag(i)}}function createDownloadStatePaths(t){return{rootDir:t,downloadingFile:path__default.default.join(t,DOWNLOAD_STATE_FILES.downloading),successFile:path__default.default.join(t,DOWNLOAD_STATE_FILES.success),errorFile:path__default.default.join(t,DOWNLOAD_STATE_FILES.error)}}function isDownloadComplete(t){return fs__default.default.existsSync(t.successFile)}function hasDownloadError(t){return fs__default.default.existsSync(t.errorFile)}function getErrorMessage$1(t){if(!hasDownloadError(t))return null;try{return fs__default.default.readFileSync(t.errorFile,"utf-8")}catch{return"Unknown error occurred during download"}}function ensureRootDirExists(t){fs__default.default.existsSync(t)||fs__default.default.mkdirSync(t,{recursive:!0})}function markDownloadStarted(t){ensureRootDirExists(t.rootDir),fs__default.default.writeFileSync(t.downloadingFile,"")}function markDownloadSuccess(t){fs__default.default.writeFileSync(t.successFile,""),deleteFileIfExists(t.errorFile)}function markDownloadError(t,e){ensureRootDirExists(t.rootDir),fs__default.default.writeFileSync(t.errorFile,e)}function cleanupDownloadingFlag(t){deleteFileIfExists(t.downloadingFile)}function prepareRootDir(t){fs__default.default.existsSync(t.rootDir)&&fs__default.default.rmSync(t.rootDir,{recursive:!0,force:!0}),fs__default.default.mkdirSync(t.rootDir,{recursive:!0})}function deleteFileIfExists(t){fs__default.default.existsSync(t)&&fs__default.default.unlinkSync(t)}function sleep(t){return new Promise((e=>setTimeout(e,t)))}function isPrimaryWorker(){return"0"===process.env.TEST_PARALLEL_INDEX}async function waitForDownloadCompletion(t,e){for(;!isDownloadComplete(e);){if(hasDownloadError(e)){const a=getErrorMessage$1(e)||"Unknown error";throw new Error(`Primary worker failed to download ${t}: ${a}`)}console.info(`Waiting for primary worker to download ${t}...`),await sleep(DOWNLOAD_CONFIG.pollIntervalMs)}}function handleDownloadError(t,e){markDownloadError(t,e instanceof Error?e.message:String(e))}const getElementByContent=(t,e,a="*")=>t.waitForSelector(`//${a}[contains(text(), '${e}')]`),getInputByLabel=(t,e,a=!1,i=2e3)=>t.waitForSelector([`//label[contains(.,'${e}')]/following-sibling::textarea`,`//label[contains(.,'${e}')]/following-sibling::*//input`,`//h6[contains(.,'${e}')]/parent::node()/parent::node()/following-sibling::input`,`//h6[contains(.,'${e}')]/parent::node()/parent::node()/following-sibling::*//input`,...a?[]:[`//span[contains(.,'${e}')]/parent::node()/parent::node()/following-sibling::*//input`,`//span[contains(.,'${e}')]/following-sibling::*//input`]].join("|"),{timeout:i}),waitForChromeState=async t=>{await t.waitForTimeout(3e3)},clickOnElement=async(t,e,a)=>{const i=await getElementByContent(t,e,a);await i.click()},clickOnButton=async(t,e)=>{await t.getByRole("button",{name:e,exact:!0}).click()},typeOnInputField=async(t,e,a,i=!1,n=!1,s=!1)=>{let o;try{o=await getInputByLabel(t,e,n,5e3)}catch(t){if(s)return!1;throw t}return i&&await t.evaluate((t=>{t.value=""}),o),await o.type(a),!0},performPopupAction=async(t,e)=>{const a=await t.context().waitForEvent("page");await e(a),a.isClosed()||await a.waitForEvent("close")},performSetup=(t,e)=>async(a,i=e)=>{for(const e of i)await e(t,a)};class Wallet{constructor(t){this.version=void 0,this.page=void 0,this.page=t}}Wallet.id=void 0,Wallet.recommendedVersion=void 0,Wallet.releasesUrl=void 0,Wallet.homePath=void 0,Wallet.download=void 0;const countAccounts$1=t=>async()=>{await t.getByTestId("wallet-switcher--dropdown").click();const e=await t.locator('//*[@data-testid="wallet-switcher--dropdown"]/*/*[2]/*').count();return await t.getByTestId("wallet-switcher--dropdown").click(),e},createAccount$1=t=>async e=>{e&&console.warn('parameter "name" is not supported for Coinbase'),await t.getByTestId("portfolio-header--switcher-cell-pressable").click(),await t.getByTestId("wallet-switcher--manage").click(),await t.getByTestId("manage-wallets-account-item--action-cell-pressable").click();try{await t.getByTestId("add-new-wallet--continue").click({timeout:2e3})}catch{}await waitForChromeState(t)},switchAccount$1=t=>async e=>{await t.getByTestId("portfolio-header--switcher-cell-pressable").click();const a=new RegExp(`${e} \\$`);await t.getByRole("button",{name:a}).click()},deleteAccount$1=async t=>{console.warn("deleteAccount not implemented - Coinbase does not support importing/removing additional private keys")},importPK=async t=>{console.warn("importPK not implemented - Coinbase does not support importing/removing private keys")},goHome=async t=>{await t.getByTestId("portfolio-navigation-link").click()},navigateHome=async t=>{await t.goto(t.url().split("?")[0])},addNetwork$1=t=>async e=>{let a;await t.getByTestId("settings-navigation-link").click(),await t.getByTestId("network-setting-cell-pressable").click(),await t.getByTestId("add-custom-network").click(),await t.getByTestId("custom-network-name-input").fill(e.networkName),await t.getByTestId("custom-network-rpc-url-input").fill(e.rpc),await t.getByTestId("custom-network-chain-id-input").fill(e.chainId.toString()),await t.getByTestId("custom-network-currency-symbol-input").fill(e.symbol),await t.getByTestId("custom-network-save").click();try{a=await t.waitForSelector('//span[@data-testid="text-input-error-label"]',{timeout:50})}catch{}if(a){const t=await a.textContent();throw new SyntaxError(t)}await waitForChromeState(t),await goHome(t)},deleteNetwork$1=t=>async e=>{await t.getByTestId("settings-navigation-link").click(),await t.getByTestId("network-setting-cell-pressable").click(),await t.getByTestId("network-list-search").fill(e),await(await t.waitForSelector('//div[@data-testid="list-"][1]//button')).click(),await t.getByTestId("custom-network-delete").click(),await goHome(t)},hasNetwork$1=t=>async e=>{await t.getByTestId("settings-navigation-link").click(),await t.getByTestId("network-setting").click(),await t.getByTestId("network-list-search").fill(e);const a=await t.isVisible('//div[@data-testid="list-"][1]//button');return await goHome(t),a},switchNetwork$1=async t=>{console.warn("switchNetwork not implemented")},confirmNetworkSwitch$1=async()=>{console.warn("confirmNetworkSwitch not implemented")},updateNetworkRpc$1=async t=>{console.warn("updateNetworkRpc not implemented - Coinbase uses different network management")};async function getStarted(t,{seed:e="already turtle birth enroll since owner keep patch skirt drift any dinner",password:a="password1234!!!!"}){await t.getByTestId("btn-import-existing-wallet").click(),await t.getByTestId("btn-import-recovery-phrase").click(),await t.getByRole("button",{name:"Acknowledge"}).click(),await t.getByTestId("secret-input").fill(e),await t.getByTestId("btn-import-wallet").click(),await t.getByTestId("setPassword").fill(a),await t.getByTestId("setPasswordVerify").fill(a),await t.getByTestId("terms-and-privacy-policy").check(),await t.getByTestId("btn-password-continue").click(),await waitForChromeState(t)}const signin$1=async()=>{console.warn("signin not implemented")},lock$1=t=>async()=>{await t.getByTestId("settings-navigation-link").click(),await t.getByTestId("lock-wallet-button").click()},unlock$1=t=>async(e="password1234!!!!")=>{await t.getByTestId("unlock-with-password").last().fill(e),await t.getByTestId("unlock-wallet-button").last().click(),await goHome(t),await t.waitForSelector("//div[@data-testid='asset-list']//*[not(text='')]",{timeout:1e4})},getTokenBalance$1=t=>async e=>{const a=new RegExp(String.raw` ${e}`),i=[async()=>{await t.bringToFront(),await t.getByTestId("portfolio-selector-nav-tabLabel--crypto").click();const e=t.getByTestId(/asset-item.*cell-pressable/).filter({hasText:a});return await t.waitForTimeout(500),await e.isVisible()?e:null},async()=>{await t.getByTestId("portfolio-selector-nav-tabLabel--testnet").click();const e=t.getByTestId(/asset-item.*cell-pressable/).filter({hasText:a});return await t.waitForTimeout(500),await e.isVisible()?e:null}];let n;for(const t of i)n=await t();if(!n)throw new Error(`Token ${e} not found`);const s=(await n.textContent()).replaceAll(/ |,/g,"").split(e)[2];return s?Number(s):0},addToken$1=async t=>{console.warn("addToken not implemented - Coinbase does not support adding custom tokens")},approve$1=t=>async()=>{await performPopupAction(t,(async t=>{await t.getByTestId("allow-authorize-button").click()}))},reject$1=t=>async()=>{await performPopupAction(t,(async t=>{const e=t.getByTestId("deny-authorize-button"),a=t.getByTestId("request-cancel-button");await e.or(a).click()}))},sign$1=t=>async()=>{await performPopupAction(t,(async t=>{await t.getByTestId("sign-message").click()}))},confirmTransaction$1=t=>async()=>{await performPopupAction(t,(async t=>{try{await(await t.waitForSelector("text='Got it'",{timeout:1e3})).click()}catch{}await t.getByTestId("request-confirm-button").click()}))};class CoinbaseWallet extends Wallet{constructor(...t){super(...t),this.options=void 0,this.defaultSetupSteps=[getStarted,navigateHome],this.setup=performSetup(this.page,this.defaultSetupSteps),this.addNetwork=addNetwork$1(this.page),this.addToken=addToken$1,this.approve=approve$1(this.page),this.createAccount=createAccount$1(this.page),this.confirmNetworkSwitch=confirmNetworkSwitch$1,this.confirmTransaction=confirmTransaction$1(this.page),this.countAccounts=countAccounts$1(this.page),this.deleteAccount=deleteAccount$1,this.deleteNetwork=deleteNetwork$1(this.page),this.getTokenBalance=getTokenBalance$1(this.page),this.hasNetwork=hasNetwork$1(this.page),this.importPK=importPK,this.lock=lock$1(this.page),this.reject=reject$1(this.page),this.sign=sign$1(this.page),this.signin=signin$1,this.switchAccount=switchAccount$1(this.page),this.switchNetwork=switchNetwork$1,this.unlock=unlock$1(this.page),this.updateNetworkRpc=updateNetworkRpc$1}}CoinbaseWallet.id="coinbase",CoinbaseWallet.recommendedVersion="3.136.0",CoinbaseWallet.releasesUrl="https://api.github.com/repos/TenKeyLabs/coinbase-wallet-archive/releases",CoinbaseWallet.homePath="/index.html",CoinbaseWallet.download=createWalletDownloader(CoinbaseWallet.id,CoinbaseWallet.releasesUrl,CoinbaseWallet.recommendedVersion);const getSettingsSwitch=(t,e)=>t.waitForSelector([`//span[contains(.,'${e}')]/parent::div/following-sibling::div/label/div`].join("|")),getErrorMessage=async t=>{try{const e=await t.waitForSelector(".mm-help-text.mm-box--color-error-default",{timeout:5e3});return await e.innerText()}catch(t){return}},accountList=t=>t.locator(".multichain-account-cell"),accountListItem=(t,e)=>accountList(t).filter({has:t.getByText(e,{exact:!0})}),networkMenuItemRegex=/^network-list-item-(?!options)\w+:\S+$/,networkList=t=>t.getByTestId(networkMenuItemRegex),networkListItem=(t,e)=>networkList(t).filter({has:t.getByText(e,{exact:!0})}),findNetworkListItem=async(t,e)=>{const a=networkListItem(t,e);if(await a.isVisible())return a;const i=t.getByRole("tab",{name:"Popular"}),n="true"===await i.getAttribute("aria-selected");return await t.getByRole("tab",{name:n?"Custom":"Popular"}).click(),a};async function goToSettings(t){await openAccountOptionsMenu(t),await t.getByTestId("global-menu-settings").click()}const clickOnSettingsSwitch=async(t,e)=>{const a=await getSettingsSwitch(t,e);await a.click()},openNetworkDropdown=async t=>{const e=t.getByTestId("sort-by-networks");await e.waitFor({state:"visible"}),await e.click()},openNetworkSettings=async t=>{await openAccountOptionsMenu(t),await t.getByTestId("global-menu-networks").click()},openAccountOptionsMenu=async t=>{const e=t.getByTestId("account-options-menu-button"),a=t.getByTestId("notifications-tag-counter__unread-dot");await e.or(a).first().click()},openAccountMenu=async t=>{await t.getByTestId("account-menu-icon").click()},clickBackButton=async t=>{await t.getByRole("button",{name:"Back"}).click()},createAccount=t=>async e=>{await t.bringToFront(),await openAccountMenu(t);const a=await accountList(t).count();await t.getByTestId("add-multichain-account-button").click(),await test.expect(accountList(t)).toHaveCount(a+1),e&&(await t.getByTestId("multichain-account-cell-end-accessory").last().click(),await t.getByLabel("Rename").click(),await t.getByTestId("account-name-input").getByRole("textbox").fill(e),await t.getByLabel("Confirm").click()),await accountList(t).last().click(),await waitForChromeState(t)},deleteAccount=t=>async e=>{await t.bringToFront(),await openAccountMenu(t),await accountListItem(t,e).getByTestId("multichain-account-cell-end-accessory").click(),await t.getByLabel("Account details").click(),await t.getByTestId("account-details-row-remove-account").click(),await t.getByRole("button",{name:"Remove",exact:!0}).click(),await waitForChromeState(t)},switchAccount=t=>async e=>{await t.bringToFront(),await openAccountMenu(t),await accountListItem(t,e).click()},countAccounts=t=>async()=>(console.warn("countAccounts not yet implemented"),-1),importPk=t=>async e=>{await t.bringToFront(),await openAccountMenu(t),await t.getByTestId("account-list-add-wallet-button").click(),await t.getByTestId("add-wallet-modal-import-account").click(),await typeOnInputField(t,"Enter your private key string here:",e),await t.getByTestId("import-account-confirm-button").click();const a=await getErrorMessage(t);if(a)throw await clickOnButton(t,"Cancel"),await clickBackButton(t),new SyntaxError(a);await clickBackButton(t)};async function importAccount(t,{seed:e="already turtle birth enroll since owner keep patch skirt drift any dinner"}){await t.getByTestId("onboarding-import-wallet").click(),await t.getByTestId("onboarding-import-with-srp-button").click(),await t.getByTestId("srp-input-import__srp-note").pressSequentially(e,{delay:30}),await t.getByTestId("import-srp-confirm").click()}async function createPassword(t,{password:e="password1234"}){await t.getByTestId("create-password-new-input").fill(e),await t.getByTestId("create-password-confirm-input").fill(e),await t.getByTestId("create-password-terms").click(),await t.getByTestId("create-password-submit").click()}async function doOnboarding(t){await t.getByTestId("metametrics-checkbox").click(),await t.getByTestId("metametrics-i-agree").click(),await t.getByTestId("manage-default-settings").click(),await t.getByTestId("category-item-General").click(),await t.getByTestId("backup-and-sync-toggle-container").click(),await t.getByTestId("category-back-button").click(),await t.getByTestId("privacy-settings-back-button").click(),await t.getByTestId("onboarding-complete-done").click(),await waitForChromeState(t),await t.goto(t.url().split("#")[0])}const closePopup=async t=>{await new Promise((t=>setTimeout(t,1e3))),await t.getByTestId("popover-close").isVisible()&&await t.getByTestId("popover-close").click();const e=t.getByRole("button",{name:"Not now"});await e.isVisible()&&await e.click()};async function adjustSettings(t){await goToSettings(t),await t.locator(".tab-bar__tab",{hasText:"Advanced"}).click(),await clickOnSettingsSwitch(t,"Show test networks"),await clickOnSettingsSwitch(t,"Show extension in full-size view"),await t.getByRole("button",{name:"Close"}).click(),await waitForChromeState(t),await t.reload({waitUntil:"domcontentloaded"})}const switchNetwork=t=>async(e="main")=>{await t.bringToFront(),await openNetworkDropdown(t);const a=await findNetworkListItem(t,e);await a.click(),await waitForChromeState(t)},addNetwork=t=>async({networkName:e,rpc:a,chainId:i,symbol:n})=>{await openNetworkDropdown(t),await clickOnElement(t,"Custom"),await clickOnButton(t,"Add custom network"),await t.getByTestId("network-form-network-name").fill(e),await t.getByTestId("test-add-rpc-drop-down").click(),await clickOnButton(t,"Add RPC URL"),await t.getByTestId("rpc-url-input-test").fill(a),await clickOnButton(t,"Add URL"),await t.getByTestId("network-form-chain-id").fill(String(i)),await t.getByTestId("network-form-ticker-input").fill(n);const s=await getErrorMessage(t);if(s)throw await t.getByRole("dialog").getByRole("button",{name:"Close"}).click(),new SyntaxError(s);await clickOnButton(t,"Save"),await t.getByTestId("modal-header-close-button").click(),await closePopup(t),await waitForChromeState(t),await switchNetwork(t)(e)},deleteNetwork=t=>async e=>{await t.bringToFront(),await openNetworkSettings(t),await networkListItem(t,e).getByTestId(/network-list-item-options-button/).click(),await t.getByTestId("network-list-item-options-delete").click(),await clickOnButton(t,"Delete"),await waitForChromeState(t)},hasNetwork=t=>async e=>{await t.bringToFront(),await openNetworkSettings(t);const a=await networkListItem(t,e).isVisible();return await t.getByRole("dialog").getByRole("button",{name:"Close"}).first().click(),a},confirmNetworkSwitch=t=>async()=>{await performPopupAction(t,(async e=>{await e.getByTestId("page-container-footer-next").click(),await waitForChromeState(t)}))},updateNetworkRpc=t=>async({chainId:e,rpc:a})=>{await t.bringToFront(),await openNetworkSettings(t),await clickOnButton(t,"Add a custom network"),await t.getByTestId("network-form-chain-id").fill(String(e)),await clickOnButton(t,"edit the original network"),await t.getByTestId("test-add-rpc-drop-down").click(),await clickOnButton(t,"Add RPC URL"),await t.getByTestId("rpc-url-input-test").fill(a),await clickOnButton(t,"Add URL"),await clickOnButton(t,"Save")},approve=t=>async()=>{await performPopupAction(t,(async e=>{await clickConfirm(e),await waitForChromeState(t)}))},clickConfirm=async t=>{await t.getByTestId("confirm-btn").click()},reject=t=>async()=>{await performPopupAction(t,(async t=>{const e=t.getByTestId("confirm-footer-cancel-button"),a=t.getByTestId("cancel-btn");await e.or(a).click()}))},sign=t=>async()=>{await performPopupAction(t,(async t=>{await t.bringToFront(),await t.reload(),await t.getByTestId("confirm-footer-button").click()}))},confirmTransaction=t=>async e=>{await performPopupAction(t,(async t=>{e&&(await t.getByTestId("edit-gas-fee-icon").click(),await t.getByTestId("gas-option-advanced").click(),e.gas&&await t.getByTestId("max-base-fee-input").getByRole("textbox").fill(String(e.gas)),e.priority&&await t.getByTestId("priority-fee-input").getByRole("textbox").fill(String(e.priority)),e.gasLimit&&await t.getByTestId("gas-input").getByRole("textbox").fill(String(e.gasLimit)),await t.getByTestId("gas-fee-modal-save-button").click()),await t.getByTestId("confirm-footer-button").click()}))},lock=t=>async()=>{await t.bringToFront(),await openAccountOptionsMenu(t),await t.getByTestId("global-menu-lock").click()},unlock=t=>async(e="password1234")=>{await t.bringToFront(),await t.getByTestId("unlock-password").fill(e),await t.getByTestId("unlock-submit").click(),await closePopup(t)},signin=t=>async()=>{await performPopupAction(t,(async e=>{await e.waitForURL(/(connect)|(signature-request)/);await e.getByText(/Connect this website/).isVisible()&&await clickConfirm(e);const a=e.getByTestId("confirm-footer-button");await a.scrollIntoViewIfNeeded(),await a.click(),await waitForChromeState(t)}))},addToken=t=>async({tokenAddress:e,symbol:a})=>{await t.bringToFront(),await t.getByTestId("asset-list-control-bar-action-button").click(),await t.getByTestId("importTokens__button").click(),await t.getByTestId("import-tokens-modal-custom-address").fill(e),await t.waitForTimeout(500),a&&await t.getByTestId("import-tokens-modal-custom-symbol").fill(a),await t.getByTestId("import-tokens-button-next").click(),await t.getByTestId("import-tokens-modal-import-button").click()},getTokenBalance=t=>async e=>{await t.bringToFront(),await t.waitForTimeout(1e3);const a=new RegExp(String.raw`\d ${e}$`),i=t.getByTestId("multichain-token-list-item-value").filter({hasText:a});if(!await i.isVisible())throw new Error(`Token ${e} not found`);const n=(await i.textContent()).split(" ")[0].replace(/,/,"");return parseFloat(n)};class MetaMaskWallet extends Wallet{constructor(...t){super(...t),this.options=void 0,this.defaultSetupSteps=[importAccount,createPassword,doOnboarding,closePopup,adjustSettings],this.setup=performSetup(this.page,this.defaultSetupSteps),this.addNetwork=addNetwork(this.page),this.addToken=addToken(this.page),this.approve=approve(this.page),this.createAccount=createAccount(this.page),this.confirmNetworkSwitch=confirmNetworkSwitch(this.page),this.confirmTransaction=confirmTransaction(this.page),this.countAccounts=countAccounts(),this.deleteAccount=deleteAccount(this.page),this.deleteNetwork=deleteNetwork(this.page),this.getTokenBalance=getTokenBalance(this.page),this.hasNetwork=hasNetwork(this.page),this.importPK=importPk(this.page),this.lock=lock(this.page),this.reject=reject(this.page),this.sign=sign(this.page),this.signin=signin(this.page),this.switchAccount=switchAccount(this.page),this.switchNetwork=switchNetwork(this.page),this.unlock=unlock(this.page),this.updateNetworkRpc=updateNetworkRpc(this.page)}}MetaMaskWallet.id="metamask",MetaMaskWallet.recommendedVersion="13.17.0",MetaMaskWallet.releasesUrl="https://api.github.com/repos/metamask/metamask-extension/releases",MetaMaskWallet.homePath="/home.html",MetaMaskWallet.download=createWalletDownloader(MetaMaskWallet.id,MetaMaskWallet.releasesUrl,MetaMaskWallet.recommendedVersion);const WALLETS=[CoinbaseWallet,MetaMaskWallet],getWalletType=t=>{const e=WALLETS.find((e=>e.id===t));if(!e)throw new Error(`Wallet ${t} not supported`);return e},closeWalletSetupPopup=(t,e)=>{e.on("page",(async e=>{e.url()===walletHomeUrl(t)&&await e.close()}))},getWallet=async(t,e)=>{const a=getWalletType(t),i=e.pages()[0];return"about:blank"===i.url()&&await i.goto(walletHomeUrl(t)),new a(i)},walletHomeUrl=t=>{const e=getWalletType(t);return`chrome-extension://${EXTENSION_ID}${e.homePath}`};async function launch(t,e){const{...a}=e,i=getWalletType(a.wallet);if(!i)throw new Error("Wallet not supported");const n=await resetBrowserSession(e),s=await launchBrowser(i,n,a);return closeWalletSetupPopup(i.id,s),{wallet:await getWallet(i.id,s),browserContext:s}}async function resetBrowserSession(t){const e=process.env.TEST_WORKER_INDEX||"0",a=path__namespace.resolve(os__default.default.tmpdir(),"dappwright","session"),i=path__namespace.join(a,t.wallet,e);await fs__default.default.promises.rm(i,{recursive:!0,force:!0});const n=path__namespace.join(i,"Default");return await fs__default.default.promises.mkdir(n,{recursive:!0}),await fs__default.default.promises.writeFile(path__namespace.join(n,"Preferences"),JSON.stringify({intl:{accept_languages:"en",selected_languages:"en"}})),i}async function launchBrowser(t,e,a){const i=[await t.download(a)].concat(a.additionalExtensions||[]),n=[`--disable-extensions-except=${i.join(",")}`,`--load-extension=${i.join(",")}`];return 0!=a.headless&&n.push("--headless=new"),await playwright__default.default.chromium.launchPersistentContext(e,{headless:!1,args:n})}const bootstrap=async(t,{seed:e,password:a,showTestNets:i,...n})=>{const{browserContext:s,wallet:o}=await launch(t,n);return await o.setup({seed:e,password:a,showTestNets:i}),[o,o.page,s]},defaultObject={bootstrap:bootstrap,launch:launch,getWallet:getWallet};exports.CoinbaseWallet=CoinbaseWallet,exports.MetaMaskWallet=MetaMaskWallet,exports.bootstrap=bootstrap,exports.default=defaultObject,exports.getWallet=getWallet,exports.launch=launch;
//# sourceMappingURL=/sm/2b21d2efe812bf697279548ef79cb6e9065a9f22dd2da3c2ebed546443e78d75.map