@checksum-ai/runtime 2.0.11 → 2.0.12-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -1
- package/cli.js +3 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -1
- package/pw-report-template.html +20 -20
- package/test-run-monitor.js +66 -66
- package/vtg-pw-bridge-runner.js +1 -1
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CHECKSUM_RUNTIME_BUILD_TIME=
|
|
1
|
+
CHECKSUM_RUNTIME_BUILD_TIME=2026-01-15T14:09:57.205Z
|
package/cli.js
CHANGED
|
@@ -1747,7 +1747,9 @@ Example:
|
|
|
1747
1747
|
`)}}};e(ewr,"CLIHelp");var vnt=ewr;var twr=class twr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}async run(){let a=`npx playwright show-report ${this.getNonChecksumArgs().join(" ")}`;try{await this.execCmd(a)}catch(s){console.log("Error showing report",s.message)}}};e(twr,"CLIShowReport");var Jkt=twr;var NI=require("fs"),jK=require("path");AAe();Wme();var rwr=class rwr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}init({requireChecksumFolder:r=!0}={}){try{this.findProjectRoot()}catch(a){console.log(a.message),process.exit(1)}if(this.checksumRoot=(0,jK.join)(process.cwd(),$Et),!(0,NI.existsSync)(this.checksumRoot)){if(r)throw new Error("Could not find checksum folder in your project, you should run the init command first to setup your Checksum.ai project.");(0,NI.mkdirSync)(this.checksumRoot)}if(!(0,NI.existsSync)(this.getChecksumRootOrigin()))throw new Error("Could not find checksum node module, please install @checksum-ai/runtime package and try again.")}install(){console.log("Creating checksum directory and necessary files to run your tests..."),this.init({requireChecksumFolder:!1});let r=(0,NI.existsSync)((0,jK.join)(this.checksumRoot,"checksum.config.ts"));hOr({isInit:!r}).forEach(l=>{let d=(0,jK.join)(this.checksumRoot,l);(0,NI.existsSync)(d)||(0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),l),d)});let a=(0,jK.join)(this.checksumRoot,".gitignore.example"),s=(0,jK.join)(this.checksumRoot,".gitignore");(0,NI.existsSync)(a)&&!(0,NI.existsSync)(s)&&((0,NI.copyFileSync)(a,s),(0,NI.unlinkSync)(a)),this.validateAuthExists(),(0,NI.mkdirSync)((0,jK.join)(this.checksumRoot,"tests"),{recursive:!0})}addTsConfig(){console.log("Adding tsconfig.json to your checksum directory..."),this.init();let r=(0,jK.join)(this.checksumRoot,"tsconfig.json");(0,NI.existsSync)(r)||(0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),"tsconfig.json"),r)}async addEslintConfig(){console.log("Adding ESLint config to your checksum directory..."),this.init();let r=(0,jK.join)(this.checksumRoot,"eslint.config.js");(0,NI.existsSync)(r)?console.log("eslint.config.js already exists."):((0,NI.copyFileSync)((0,jK.join)(this.getChecksumRootOrigin(),"eslint.config.js"),r),console.log("Added eslint.config.js."));let a=["eslint","@eslint/js","typescript","typescript-eslint"],s=this.getChecksumArg("yes"),l=!!s;if(!s)try{l=await Ctt({message:`Install required devDependencies now? (${a.join(", ")})`,choices:[{name:"Yes",value:"yes"},{name:"No",value:"no"}],default:"yes"})==="yes"}catch{l=!1}if(l){let g=(0,NI.existsSync)((0,jK.join)(this.projectRootDirectory,"yarn.lock"))?`yarn add -D ${a.join(" ")}`:`npm i -D ${a.join(" ")}`;try{console.log("Installing devDependencies...",g),await this.execCmd(`cd "${this.projectRootDirectory}" && ${g}`),console.log("DevDependencies installed successfully.")}catch(b){console.log("Failed installing devDependencies:",b.message)}}else console.log(`Skipped installing devDependencies. You can install them manually with:
|
|
1748
1748
|
npm i -D `+a.join(" ")+`
|
|
1749
1749
|
or
|
|
1750
|
-
yarn add -D `+a.join(" "))}};e(rwr,"CLIInstall");var MLe=rwr;e7();var nwr=class nwr extends NP{constructor(r,a=!1){super(r,a);let s=r[0];this.vtgTestFileParser=new xwe(s)}async run(){this.vtgTestFileParser.loadTestsFromFile();let r=this.vtgTestFileParser.testMirrors[0].translateStatementsToSteps();VA.info("Test steps:",JSON.stringify(r,null,2))}};e(nwr,"VtgTestFileParser");var zkt=nwr;var HAn=require("fs"),GAn=qd(require("path"));xz();xCr();var iwr=class iwr extends WRe{constructor(a){super(a,"/client-api/runtime");this.config=a}};e(iwr,"CliAPIService");var Wkt=iwr;var awr=class awr extends NP{constructor(r,a=!1){super(r,a,{muteChecksumConfigMissingError:!0}),this.config.apiURL||(this.config.apiURL=Hcn({}).apiURL)}async initApiService(){let r=this.config.apiKey,a=this.getArg("--api-key");a&&a!==""?this.config.apiKey=a:!!r?this.config.apiKey=r:this.handleError("No API key provided. Please provide an API key using --api-key=<apiKey>"),this.apiService=new Wkt(this.config)}async downloadDotenv(){try{let r=await this.apiService.get("dotenv");if(!r.ok){let{status:l,statusText:d}=r;l===403&&this.handleError('The API key you provided is not valid. Please check your API key and try again, running: "npx checksumai dotenv --download --api-key=<apiKey>"'),this.handleError(`Error occured when trying to download the .env file. ${l} ${d}`)}let a=await r.text()
|
|
1750
|
+
yarn add -D `+a.join(" "))}};e(rwr,"CLIInstall");var MLe=rwr;e7();var nwr=class nwr extends NP{constructor(r,a=!1){super(r,a);let s=r[0];this.vtgTestFileParser=new xwe(s)}async run(){this.vtgTestFileParser.loadTestsFromFile();let r=this.vtgTestFileParser.testMirrors[0].translateStatementsToSteps();VA.info("Test steps:",JSON.stringify(r,null,2))}};e(nwr,"VtgTestFileParser");var zkt=nwr;var HAn=require("fs"),GAn=qd(require("path"));xz();xCr();var iwr=class iwr extends WRe{constructor(a){super(a,"/client-api/runtime");this.config=a}};e(iwr,"CliAPIService");var Wkt=iwr;var awr=class awr extends NP{constructor(r,a=!1){super(r,a,{muteChecksumConfigMissingError:!0}),this.config.apiURL||(this.config.apiURL=Hcn({}).apiURL)}async initApiService(){let r=this.config.apiKey,a=this.getArg("--api-key");a&&a!==""?this.config.apiKey=a:!!r?this.config.apiKey=r:this.handleError("No API key provided. Please provide an API key using --api-key=<apiKey>"),this.apiService=new Wkt(this.config)}async downloadDotenv(){try{let r=await this.apiService.get("dotenv");if(!r.ok){let{status:l,statusText:d}=r;l===403&&this.handleError('The API key you provided is not valid. Please check your API key and try again, running: "npx checksumai dotenv --download --api-key=<apiKey>"'),this.handleError(`Error occured when trying to download the .env file. ${l} ${d}`)}let a=await r.text();a=this.removeAuthorizeReports(a);let s=GAn.default.join(this.checksumRoot,".env");(0,HAn.writeFileSync)(s,a),console.log(`The .env file has been downloaded to ${s}`)}catch{this.handleError("Error occured when trying to download the .env file.")}}async run(){await this.initApiService(),this.getArg("--download")?await this.downloadDotenv():this.handleError("Invalid command. Use --download to download the .env file and run the command again.")}handleError(r){console.error(r),process.exit(1)}removeAuthorizeReports(r){return r.split(`
|
|
1751
|
+
`).filter(l=>!l.trim().toUpperCase().startsWith("AUTHORIZE_REPORTS=")).join(`
|
|
1752
|
+
`)}};e(awr,"CLIDotEnvManager");var Hkt=awr;var Hwe=require("fs"),swr=require("path");var owr=class owr extends NP{constructor(a,s=!1){super(a,s,{skipChecksumDataLoad:!0});this.packagesToOverride=["playwright-core","playwright"]}async run(){var a,s;try{console.log("Validating Playwright version..."),this.findProjectRoot();let l=(0,swr.join)(this.projectRootDirectory,"node_modules","@checksum-ai","runtime","package.json");if(!(0,Hwe.existsSync)(l))throw new Error(`package.json not found in: ${l}`);let d=JSON.parse((0,Hwe.readFileSync)(l,"utf8")),g=((a=d.dependencies)==null?void 0:a["@playwright/test"])||((s=d.devDependencies)==null?void 0:s["@playwright/test"]);if(!g)throw new Error(`No @playwright/test dependency found in ${l}`);let b=await this.getCurrentPlaywrightVersions();console.log(`Expected Playwright version: ${g}`);let E=b.filter(S=>!this.versionsMatch(g,S.version));if(E.length>0){console.log("\u274C Playwright version conflicts detected:"),E.forEach(({packageName:S,version:F})=>{console.log(` - Found version: ${S}@${F} (expected: ${g})`)}),console.log("\u{1F527} Attempting to fix Playwright version conflicts...");try{let S=[];for(let{packageName:F}of E){if(S.includes(F))continue;await this.fixPlaywrightConflicts(F,g)&&S.push(F)}S.length>0&&(console.log("Running npm install to apply the override..."),await this.execCmd("npm install"),console.log("\u2705 Playwright version conflicts have been resolved"))}catch(S){console.log(String(S)),console.log("\u274C Failed to fix Playwright version conflicts automatically"),console.log("Please manually add the following to your package.json:"),console.log('"overrides": {');for(let{packageName:F}of E)console.log(` "${F}": "${g}"`);return console.log("}"),console.log("Then run 'npm install'"),!1}}else console.log("\u2705 Playwright version validation passed");return!0}catch(l){return console.error("Error validating Playwright version:",l.message),!1}}async getCurrentPlaywrightVersions(){try{let a=[];for(let s of this.packagesToOverride){let l=await this.getCmdOutput(`npm list ${s}`),d=new RegExp(`${s.replace("@","")}@([^@\\s]+)`,"g"),g;for(;(g=d.exec(l))!==null;)a.push({packageName:s,version:g[1]})}return a}catch{throw new Error("Could not determine current Playwright versions")}}versionsMatch(a,s){let l=a.replace(/^[\^~]/,""),d=s.replace(/^[\^~]/,"");return l===d}async fixPlaywrightConflicts(a,s){let l=(0,swr.join)(this.projectRootDirectory,"package.json"),d;try{d=JSON.parse((0,Hwe.readFileSync)(l,"utf8"))}catch{throw new Error("No package.json found in project root")}return d.overrides||(d.overrides={}),d.overrides[a]&&this.versionsMatch(d.overrides[a],s)?(console.log(`\u2705 Playwright version ${s} is already set as override in package.json`),!1):(d.overrides[a]=s,(0,Hwe.writeFileSync)(l,JSON.stringify(d,null,2)),console.log(`\u2705 Added ${a} override to package.json: ${s}`),!0)}};e(owr,"CLIValidatePlaywrightVersion");var jLe=owr;var cwr=class cwr extends NP{constructor(r,a=!1){super(r,a,{skipChecksumDataLoad:!0})}async run(){console.log("Running postinstall processes...");try{return console.log("Running Playwright version validation..."),await new jLe(this.args,this.debugMode).run()||console.log("\u26A0\uFE0F Playwright version validation failed, but continuing with postinstall..."),console.log("\u2705 Postinstall processes completed"),!0}catch(r){return console.error("Error during postinstall:",r.message),!1}}};e(cwr,"CLIPostinstall");var Gkt=cwr;pS();var uwr=class uwr{constructor(){}async execute(){let r=eg.useCLIDebug||!!process.argv.find(s=>s==="--cksm-clidebug"||s==="--cksm-repl"||s==="--cksm-debug");r&&wEr(!0);let a=process.argv.slice(3);switch(process.argv.find(s=>s==="--help"||s==="-h")&&(await new vnt(a,r).run(process.argv[2]),process.exit(0)),process.argv[2]){case"init":new MLe(a,r).install();break;case"tsconfig":new MLe(a,r).addTsConfig();break;case"eslint":await new MLe(a,r).addEslintConfig();break;case"test":await new ynt(a,r).run();return;case"show-report":await new Jkt(a,r).run();break;case"dotenv":await new Hkt(a,r).run();break;case"vtg":let s=e(l=>a.find(d=>d===l),"hasArg");if(s("--cksm-new-file"))throw Error("VTG new file mode is now the default. Remove the --cksm-new-file flag and run again with `vtg [story-id]`");if(s("--cksm-file"))throw Error("VTG edit file mode is now run using the --cksm-edit instead of --cksm-file flag, Run again with `vtg --cksm-edit [absolute-path-to-file]`");if(s("--cloud")&&!s("--cksm-legacy"))throw Error("VTG cloud mode can only be run in legacy mode. Use the --cksm-legacy flag to run in legacy mode with `vtg [story-id] --cksm-legacy --cloud`");try{if(s("--cksm-legacy"))throw Error("VTG in legacy mode is not supported anymore. To support we need to pass checksum config to it for it to work again.");let l=s("--headed")?a:["--headed",...a];eg.CI&&(l=l.filter(d=>d!=="--headed")),await new ynt(l,r,!0).run()}catch(l){console.log("Error",l.message)}break;case"vtg-test-parser":await new zkt(a,r).run();break;case"validate-playwright-version":await new jLe(a,r).run();break;case"postinstall":await new Gkt(a,r).run();break;default:await new vnt(a,r).run()}process.exit(0)}};e(uwr,"CLIDispatcher");var Kkt=uwr;(async()=>await new Kkt().execute())();
|
|
1751
1753
|
/*! Bundled license information:
|
|
1752
1754
|
|
|
1753
1755
|
lodash/lodash.js:
|
package/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
// import { ExpectWrapper } from "./index.helpers";
|
|
15
15
|
interface ChecksumAIMethod {
|
|
16
16
|
(title: string): IChecksumPage;
|
|
17
|
-
<T>(title: string, body: () => T | Promise<T
|
|
17
|
+
<T>(title: string, body: () => T | Promise<T>, options?: ChecksumAIOptions): Promise<T>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
type EnumValues<T> = T[keyof T];
|
|
@@ -335,7 +335,7 @@ export type ChecksumAIOptions = {
|
|
|
335
335
|
skipAutoRecovery?: boolean;
|
|
336
336
|
};
|
|
337
337
|
export type ChecksumAI = {
|
|
338
|
-
(description: string, testFunction: Function): Promise<any>;
|
|
338
|
+
(description: string, testFunction: Function, options?: ChecksumAIOptions): Promise<any>;
|
|
339
339
|
} & {
|
|
340
340
|
[K in keyof ChecksumAIOptions]: ChecksumAI;
|
|
341
341
|
};
|
package/index.js
CHANGED
|
@@ -622,7 +622,7 @@ Result: ${JSON.stringify(C)}`);else w=C;let k;l7e(t)&&(k=t.id),!k&&DUn(f)&&(k=f.
|
|
|
622
622
|
`).map(t=>t.trim()).join(" ")};gzn.O=function(i){return this.inspectOpts.colors=this.useColors,KVt.inspect(i,this.inspectOpts)}});var vzn=gr((kks,tVr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?tVr.exports=hzn():tVr.exports=yzn()});var sVr={};ER(sVr,{Decoder:()=>iVr,Encoder:()=>nVr,PacketType:()=>RE,protocol:()=>Ezn});function bzn(i){return Object.prototype.toString.call(i)==="[object Object]"}var xzn,Azn,rVr,$Ea,Ezn,RE,oVr,nVr,XVt,iVr,uVr,aVr,ZVt=zt(()=>{xzn=nf(pFe(),1);mzn();Y$r();Azn=nf(vzn(),1),rVr=(0,Azn.default)("socket.io-parser"),$Ea=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Ezn=5;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(RE||(RE={}));oVr=class oVr{constructor(t){this.replacer=t}encode(t){return rVr("encoding packet %j",t),(t.type===RE.EVENT||t.type===RE.ACK)&&R_t(t)?this.encodeAsBinary({type:t.type===RE.EVENT?RE.BINARY_EVENT:RE.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===RE.BINARY_EVENT||t.type===RE.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),rVr("encoded %j as %s",t,r),r}encodeAsBinary(t){let r=fzn(t),a=this.encodeAsString(r.packet),o=r.buffers;return o.unshift(a),o}};e(oVr,"Encoder");nVr=oVr;e(bzn,"isObject");XVt=class XVt extends xzn.Emitter{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);let a=r.type===RE.BINARY_EVENT;a||r.type===RE.BINARY_ACK?(r.type=a?RE.EVENT:RE.ACK,this.reconstructor=new aVr(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(L_t(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0,a={type:Number(t.charAt(0))};if(RE[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===RE.BINARY_EVENT||a.type===RE.BINARY_ACK){let c=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);let f=t.substring(c,r);if(f!=Number(f)||t.charAt(r)!=="-")throw new Error("Illegal attachments");a.attachments=Number(f)}if(t.charAt(r+1)==="/"){let c=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););a.nsp=t.substring(c,r)}else a.nsp="/";let o=t.charAt(r+1);if(o!==""&&Number(o)==o){let c=r+1;for(;++r;){let f=t.charAt(r);if(f==null||Number(f)!=f){--r;break}if(r===t.length)break}a.id=Number(t.substring(c,r+1))}if(t.charAt(++r)){let c=this.tryParse(t.substr(r));if(XVt.isPayloadValid(a.type,c))a.data=c;else throw new Error("invalid payload")}return rVr("decoded %s as %j",t,a),a}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case RE.CONNECT:return bzn(r);case RE.DISCONNECT:return r===void 0;case RE.CONNECT_ERROR:return typeof r=="string"||bzn(r);case RE.EVENT:case RE.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&$Ea.indexOf(r[0])===-1);case RE.ACK:case RE.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}};e(XVt,"Decoder");iVr=XVt,uVr=class uVr{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let r=dzn(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};e(uVr,"BinaryReconstructor");aVr=uVr});function CZ(i,t,r){return i.on(t,r),e(function(){i.off(t,r)},"subDestroy")}var cVr=zt(()=>{e(CZ,"on")});var Czn,wzn,cO,VEa,lVr,uWe,pVr=zt(()=>{ZVt();cVr();Czn=nf(pFe(),1),wzn=nf(B_t(),1),cO=(0,wzn.default)("socket.io-client:socket"),VEa=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),lVr=class lVr extends Czn.Emitter{constructor(t,r,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=r,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[CZ(t,"open",this.onopen.bind(this)),CZ(t,"packet",this.onpacket.bind(this)),CZ(t,"error",this.onerror.bind(this)),CZ(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){var a,o,c;if(VEa.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;let f={type:RE.EVENT,data:r};if(f.options={},f.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){let w=this.ids++;cO("emitting packet with ack id %d",w);let T=r.pop();this._registerAckCallback(w,T),f.id=w}let _=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,v=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!_?cO("discard packet as the transport is not currently writable"):v?(this.notifyOutgoingListeners(f),this.packet(f)):this.sendBuffer.push(f),this.flags={},this}_registerAckCallback(t,r){var a;let o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[t]=r;return}let c=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let _=0;_<this.sendBuffer.length;_++)this.sendBuffer[_].id===t&&(cO("removing packet with ack id %d from the buffer",t),this.sendBuffer.splice(_,1));cO("event with ack id %d has timed out after %d ms",t,o),r.call(this,new Error("operation has timed out"))},o),f=e((..._)=>{this.io.clearTimeoutFn(c),r.apply(this,_)},"fn");f.withError=!0,this.acks[t]=f}emitWithAck(t,...r){return new Promise((a,o)=>{let c=e((f,_)=>f?o(f):a(_),"fn");c.withError=!0,r.push(c),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());let a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...c)=>a!==this._queue[0]?void 0:(o!==null?a.tryCount>this._opts.retries&&(cO("packet [%d] is discarded after %d tries",a.id,a.tryCount),this._queue.shift(),r&&r(o)):(cO("packet [%d] was successfully sent",a.id),this._queue.shift(),r&&r(null,...c)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(t=!1){if(cO("draining queue"),!this.connected||this._queue.length===0)return;let r=this._queue[0];if(r.pending&&!t){cO("packet [%d] has already been sent and is waiting for an ack",r.id);return}r.pending=!0,r.tryCount++,cO("sending packet [%d] (try n\xB0%d)",r.id,r.tryCount),this.flags=r.flags,this.emit.apply(this,r.args)}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){cO("transport is open - connecting"),typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:RE.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){cO("close (%s)",t),this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(a=>String(a.id)===t)){let a=this.acks[t];delete this.acks[t],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case RE.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case RE.EVENT:case RE.BINARY_EVENT:this.onevent(t);break;case RE.ACK:case RE.BINARY_ACK:this.onack(t);break;case RE.DISCONNECT:this.ondisconnect();break;case RE.CONNECT_ERROR:this.destroy();let a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);break}}onevent(t){let r=t.data||[];cO("emitting event %j",r),t.id!=null&&(cO("attaching ack callback to event"),r.push(this.ack(t.id))),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let r=this._anyListeners.slice();for(let a of r)a.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){let r=this,a=!1;return function(...o){a||(a=!0,cO("sending ack %j",o),r.packet({type:RE.ACK,id:t,data:o}))}}onack(t){let r=this.acks[t.id];if(typeof r!="function"){cO("bad ack %s",t.id);return}delete this.acks[t.id],cO("calling ack %s with %j",t.id,t.data),r.withError&&t.data.unshift(null),r.apply(this,t.data)}onconnect(t,r){cO("socket connected with id %s",t),this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){cO("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(cO("performing disconnect (%s)",this.nsp),this.packet({type:RE.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let r=this._anyListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let r=this._anyOutgoingListeners;for(let a=0;a<r.length;a++)if(t===r[a])return r.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let r=this._anyOutgoingListeners.slice();for(let a of r)a.apply(this,t.data)}}};e(lVr,"Socket");uWe=lVr});function AFe(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}var Szn=zt(()=>{e(AFe,"Backoff");AFe.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*i);i=Math.floor(t*10)&1?i+r:i-r}return Math.min(i,this.max)|0};AFe.prototype.reset=function(){this.attempts=0};AFe.prototype.setMin=function(i){this.ms=i};AFe.prototype.setMax=function(i){this.max=i};AFe.prototype.setJitter=function(i){this.jitter=i}});var Dzn,Tzn,Sj,fVr,cWe,kzn=zt(()=>{zVt();pVr();ZVt();cVr();Szn();Dzn=nf(pFe(),1),Tzn=nf(B_t(),1),Sj=(0,Tzn.default)("socket.io-client:manager"),fVr=class fVr extends Dzn.Emitter{constructor(t,r){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Sbe(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((a=r.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new AFe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;let o=r.parser||sVr;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(Sj("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Sj("opening %s",this.uri),this.engine=new oWe(this.uri,this.opts);let r=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;let o=CZ(r,"open",function(){a.onopen(),t&&t()}),c=e(_=>{Sj("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",_),t?t(_):this.maybeReconnectOnOpen()},"onError"),f=CZ(r,"error",c);if(this._timeout!==!1){let _=this._timeout;Sj("connect attempt will timeout after %d",_);let v=this.setTimeoutFn(()=>{Sj("connect attempt timed out after %d",_),o(),c(new Error("timeout")),r.close()},_);this.opts.autoUnref&&v.unref(),this.subs.push(()=>{this.clearTimeoutFn(v)})}return this.subs.push(o),this.subs.push(f),this}connect(t){return this.open(t)}onopen(){Sj("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(CZ(t,"ping",this.onping.bind(this)),CZ(t,"data",this.ondata.bind(this)),CZ(t,"error",this.onerror.bind(this)),CZ(t,"close",this.onclose.bind(this)),CZ(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){wbe(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){Sj("error",t),this.emitReserved("error",t)}socket(t,r){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new uWe(this,t,r),this.nsps[t]=a),a}_destroy(t){let r=Object.keys(this.nsps);for(let a of r)if(this.nsps[a].active){Sj("socket %s is still active, skipping close",a);return}this._close()}_packet(t){Sj("writing packet %j",t);let r=this.encoder.encode(t);for(let a=0;a<r.length;a++)this.engine.write(r[a],t.options)}cleanup(){Sj("cleanup"),this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){Sj("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,r){var a;Sj("closed due to %s",t),this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)Sj("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let r=this.backoff.duration();Sj("will wait %dms before reconnect attempt",r),this._reconnecting=!0;let a=this.setTimeoutFn(()=>{t.skipReconnect||(Sj("attempting reconnect"),this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(Sj("reconnect attempt error"),t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):(Sj("reconnect success"),t.onreconnect())}))},r);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}};e(fVr,"Manager");cWe=fVr});function j_t(i,t){typeof i=="object"&&(t=i,i=void 0),t=t||{};let r=czn(i,t.path||"/socket.io"),a=r.source,o=r.id,c=r.path,f=M_t[o]&&c in M_t[o].nsps,_=t.forceNew||t["force new connection"]||t.multiplex===!1||f,v;return _?(Izn("ignoring socket cache for %s",a),v=new cWe(a,t)):(M_t[o]||(Izn("new io instance for %s",a),M_t[o]=new cWe(a,t)),v=M_t[o]),r.query&&!t.query&&(t.query=r.queryKey),v.socket(r.path,t)}var Pzn,Izn,M_t,Fzn=zt(()=>{lzn();kzn();pVr();Pzn=nf(B_t(),1);ZVt();zVt();Izn=(0,Pzn.default)("socket.io-client"),M_t={};e(j_t,"lookup");Object.assign(j_t,{Manager:cWe,Socket:uWe,io:j_t,connect:j_t})});var Nzn=zt(()=>{"use strict"});var ezt,dVr,tzt,Ozn=zt(()=>{"use strict";Fzn();Nzn();ezt={URL:"http://localhost:3000",NAMESPACE:"auto-recovery",RECONNECTION_ATTEMPTS:5,RECONNECTION_DELAY:1e3},dVr=class dVr{constructor(t={}){this.socket=null;this.connectionState="disconnected";this.connectionPromise=null;this.resolution=null;this.options=t,this.url=t.url||ezt.URL,this.namespace=t.namespace||ezt.NAMESPACE,this.initializationPromise=this.createInitializationPromise()}createInitializationPromise(){return new Promise((t,r)=>{this.resolveInitialization=a=>t(a),this.rejectInitialization=a=>r(a)}).then(t=>(this.resolution=t,this.log("\u2705 Client initialization successful"),t),t=>{throw this.resolution=t,this.logError("\u274C Client initialization failed:",t),t}).finally(()=>{this.disconnect()})}defineHandlers(t){return t}async startSession(t,r,a){try{if(await this.connect(),this.emit(t,r,o=>{this.resolveInitialization(o)}),a&&a>0){let o=new Promise((c,f)=>{setTimeout(()=>{f(new Error(`Session initialization timed out after ${a}ms`))},a)});return Promise.race([this.initializationPromise,o])}return this.initializationPromise}catch(o){throw this.logError("\u274C Failed to start session:",o),this.rejectInitialization(o),o}}isConnected(){var t;return((t=this.socket)==null?void 0:t.connected)||!1}getConnectionState(){return this.connectionState}success(t){return{success:!0,data:t}}error(t){return{success:!1,error:t}}log(t,...r){this.options.verbose&&console.log(`[${this.namespace}] ${t}`,...r)}logError(t,...r){this.options.verbose&&console.error(`[${this.namespace}] ${t}`,...r)}async connect(){var t;if(this.connectionPromise)return this.connectionPromise;if(this.connectionState==="connected"&&((t=this.socket)!=null&&t.connected))return Promise.resolve();this.connectionState="connecting",this.connectionPromise=this.establishConnection();try{await this.connectionPromise,this.connectionState="connected"}catch(r){throw this.connectionState="disconnected",this.connectionPromise=null,r}return this.connectionPromise}establishConnection(){return new Promise((t,r)=>{let a=!1;try{let o=`${this.url}/${this.namespace}`;this.log(`\u{1F517} Connecting to socket at: ${o}`),this.socket=j_t(o,{autoConnect:!0,reconnection:!0,reconnectionAttempts:ezt.RECONNECTION_ATTEMPTS,reconnectionDelay:ezt.RECONNECTION_DELAY,...this.options.path&&{path:this.options.path}}),this.setupConnectionHandlers(t,r,a)}catch(o){this.logError("\u274C Failed to create socket connection:",o),a||r(o)}})}setupConnectionHandlers(t,r,a){if(!this.socket)return;let o={resolve:t,reject:r,connectionResolved:a};this.socket.on("connect",()=>this.handleConnect(o)),this.socket.on("reconnect",()=>this.handleReconnect()),this.socket.on("connect_error",c=>this.handleConnectError(c,o)),this.socket.on("disconnect",c=>this.handleDisconnect(c,o)),this.socket.io.on("reconnect_attempt",c=>this.handleReconnectAttempt(c)),this.socket.io.on("reconnect_error",c=>this.handleReconnectError(c)),this.socket.io.on("reconnect_failed",()=>this.handleReconnectFailed(o))}handleConnect(t){this.log("\u2705 Connected to socket"),this.connectionState="connected",this.setupEventHandlers(),t.connectionResolved||(t.connectionResolved=!0,t.resolve())}handleReconnect(){this.log("\u2705 Reconnected to socket"),this.connectionState="connected"}handleConnectError(t,r){var a;this.logError("\u274C Connection error:",t),this.connectionState="disconnected",!r.connectionResolved&&((a=this.socket)==null?void 0:a.disconnected)!==!1&&(r.connectionResolved=!0,r.reject(t))}handleDisconnect(t,r){this.log("\u{1F50C} Disconnected from socket:",t),this.connectionState="disconnected";let a=new Error(`Socket disconnected: ${t}`),o=!1;this.resolution===null&&t==="io server disconnect"&&(this.rejectInitialization(a),o=!0),!r.connectionResolved&&(t==="io server disconnect"||t==="transport close")&&(r.connectionResolved=!0,r.reject(a)),!o&&this.resolution===null&&this.connectionState==="disconnected"&&this.rejectInitialization(a)}handleReconnectAttempt(t){this.log(`\u{1F504} Reconnection attempt #${t}`),this.connectionState="reconnecting"}handleReconnectError(t){this.logError("\u274C Reconnection attempt failed:",t)}handleReconnectFailed(t){this.logError("\u274C All reconnection attempts failed"),this.connectionState="disconnected",this.resolution===null&&this.rejectInitialization("All reconnection attempts failed"),t.connectionResolved||(t.connectionResolved=!0,t.reject(new Error("All reconnection attempts failed")))}setupEventHandlers(){if(!this.socket){this.logError("\u274C Cannot setup event handlers: socket is null");return}this.log("\u2705 Setting up event handlers"),this.socket.on("__call",this.handleGatewayCall.bind(this))}async handleGatewayCall(t,r){this.log(`\u{1F4E5} Gateway called method: ${t.key} with args:`,t.args);try{let a=this.validateGatewayCall(t);if(a){r(a);return}let o=this.handlers[t.key];if(!o){let f=`No handler registered for method: ${t.key}`;this.logError(`\u274C ${f}`),r(this.error(f));return}let c=await o(...t.args);r(this.success(c))}catch(a){this.logError("\u274C Error handling gateway call:",a),r(this.error(a.message||"Unknown error occurred"))}}validateGatewayCall(t){return t.key?Array.isArray(t.args)?null:(this.logError("\u274C Received call with invalid args"),this.error("Args must be an array")):(this.logError("\u274C Received call with undefined key"),this.error("Key is undefined"))}emit(t,r,a){if(!this.socket){this.logError("\u274C Cannot emit: socket is null");return}this.log(`\u{1F4E4} Emitting event: ${t}`),this.socket.emit(t,r,o=>{a(o)})}disconnect(){this.connectionState!=="shutting_down"&&(this.connectionState="shutting_down",this.log("\u{1F50C} Initiating disconnect"),this.socket&&(this.socket.disconnect(),this.socket=null),this.connectionPromise=null,this.connectionState="disconnected",this.log("\u2705 Disconnected successfully"))}};e(dVr,"AbstractClient");tzt=dVr});var Bzn,Rzn,Lzn,Mzn,jzn,Uzn,nzt,rzt,qzn=zt(()=>{"use strict";l$n();f$n();JH();Ozn();jne();yT();nzt=class nzt extends(Uzn=tzt,jzn=wj.names.getState,Mzn=wj.names.invokeCode,Lzn=wj.names.final_result,Rzn=wj.names.wait,Bzn=wj.names.getElementScreenshot,Uzn){constructor(r,a){super({verbose:V0.testRun.autoRecovery.verboseConsoleLog,url:a.config.apiURL,namespace:"auto-recovery",path:"/auto-recovery/socket.io"});this.utils=r;this.initData=a;this.stepsThoughts=[];this.handlers=this.defineHandlers({callLangChainTool:e(async(r,a)=>{if(!this[r])throw new Error(`Tool ${r} not found`);return a.thought&&this.stepsThoughts.push(a.thought),await this[r].invoke(a)},"callLangChainTool"),getStatus:e(async r=>({sessionId:r,status:"active",data:{message:"Status retrieved successfully"}}),"getStatus")});this[jzn]=v7e.buildTool(wj,wj.names.getState,async r=>this.getStateHandler(r));this[Mzn]=v7e.buildTool(wj,wj.names.invokeCode,async r=>this.invokeCodeHandler(r));this[Lzn]=v7e.buildTool(wj,wj.names.final_result,async r=>this.finalResultHandler(r));this[Rzn]=v7e.buildTool(wj,wj.names.wait,async r=>this.waitHandler(r));this[Bzn]=v7e.buildTool(wj,wj.names.getElementScreenshot,async r=>this.getElementScreenshotHandler(r))}async init(){let r={...this.initData,version:wj.version};return await this.startSession("initialize",r).catch(a=>{this.utils.analytics.ARError({error:a.message});let o="Auto-Recovery attempt finished unsuccessfully";return this.utils.createChecksumStep({title:o,withError:!0}),this.utils.addAutoRecoveryErrorToReport(o,!1),{finalThought:o,stepsThoughts:[],result:"failed"}})}static async build(r){let a=await r.buildFallbackData();return new nzt(r,a)}async invokeCodeHandler(r){let a;return await this.utils.runConditionallyWithinStep(!0,r.thought||"Invoke Code",async()=>{try{let o=await this.utils.invokeCode(r.code);this.utils.createChecksumStep({title:"Code Invoked Successfully"}),a={success:!0,invokeCodeResult:`invokeCodeResult: ${o}`,appState:(await this.utils.buildFallbackData()).applicationState}}catch(o){a={success:!1,invokeCodeResult:`Error while invoking code: ${o}`,appState:(await this.utils.buildFallbackData()).applicationState}}}),a}async getStateHandler(r){return this.utils.createChecksumStep({title:r.thought}),this.utils.analytics.ARGetState(r.thought),{success:!0,appState:(await this.utils.buildFallbackData()).applicationState}}finalResultHandler(r){let a=r.result==="pass",o=this.initData.type==="assertion"?a?"soft_assertion":"hard_assertion":a?"finish":"failed";this.utils.analytics.ARFinalResult({finalThought:r.thought,result:o,stepsThoughts:this.stepsThoughts});let c={finalThought:r.thought,result:o,stepsThoughts:this.stepsThoughts};this.utils.addAutoRecoveryErrorToReport(r.thought,a),this.resolveInitialization(c)}async getElementScreenshotHandler(r){return{success:!0,screenshot:await this.utils.getScreenshotForElement(r.checksumId)}}async waitHandler(r){await new Promise(o=>setTimeout(o,r.time||5e3));let a=await this.utils.buildFallbackData();return{success:!0,waitResult:`waited for ${r.time} seconds, the current HTML of the application after the wait is: ${a.applicationState.reducedHTML}`}}};e(nzt,"AutoRecoveryAgent");rzt=nzt});var mVr,izt,Qzn=zt(()=>{"use strict";Pjt();Qdt();mVr=class mVr{constructor(t,r){this.sessionId=null;if(!rie.getCurrentTestInfo())throw new Error("TestRunAnalytics must be initialized with testInfo before RecoveryAnalytics can be used");let o=rie.getCurrentInstance();if(!o)throw new Error("TestRunAnalytics instance not found. Make sure TestRunAnalytics is initialized before creating RecoveryAnalytics");let c=o.getTestSuiteRunInfo();this.analytics=$me.createFromConfig(c,rie.isolatedMode,!0),this.fallbackId=t,this.fallbackType=r}updateToSessionId(t){this.sessionId!==t&&(this.sessionId=t)}get tableName(){return"fallbacks"}get metadata(){return{...this.analytics.metadata,fallbackType:this.fallbackType,sessionId:this.sessionId||"unknown",fallbackId:this.fallbackId}}event(t){this.analytics.trackEventWithTable(t,this.metadata,this.tableName)}setFallbackType(t){this.fallbackType=t}aiFallbackStart(t){this.event({event:"AI Fallback Start",metadata:this.metadata,...t})}aiFallbackConfig(t){this.event({event:"AI Fallback Config",metadata:this.metadata,...t})}aiFallbackIterationResponse(t){this.event({event:"AI Fallback Iteration Response",metadata:this.metadata,...t})}aiFallbackAssertion(t){this.event({event:"AI Fallback Assertion Execution",metadata:this.metadata,...t})}aiFallbackChangeVariable(t){this.event({event:"AI Fallback Change Variable",metadata:this.metadata,...t})}aiFallbackSummary(t){this.event({event:"AI Fallback Summary",metadata:this.metadata,fallbackType:this.fallbackType,...t})}aiFallbackActionExecution(t){this.event({event:"AI Fallback Action Execution",metadata:this.metadata,...t})}aiFallbackActionExecutionFailure(t){this.event({event:"AI Fallback Action Execution Failure",metadata:this.metadata,...t})}aiFallbackEnd(t){this.event({event:"AI Fallback End",metadata:this.metadata,...t})}ARStart(){this.event({event:"Auto-Recovery Start",metadata:this.metadata})}ARConfig(t){this.event({event:"Auto-Recovery Config",metadata:this.metadata,...t})}ARGetState(t){this.event({event:"Auto-Recovery State",metadata:this.metadata,thought:t})}ARInvokeCode(t,r){this.event({event:"Auto-Recovery Invoke Code",metadata:this.metadata,thought:t,code:r})}ARFinalResult(t){this.event({event:"Auto-Recovery Final Result",metadata:this.metadata,...t})}autoRecoveryDisconnect(t){this.event({event:"Auto-Recovery Disconnect",metadata:this.metadata,...t})}ARFinish(t){this.event({event:"Auto-Recovery Finish",metadata:this.metadata,...t})}ARError(t){this.event({event:"Auto-Recovery Error",metadata:this.metadata,...t})}};e(mVr,"RecoveryAnalytics");izt=mVr});var $zn=zt(()=>{"use strict"});var Vzn,zzn,EFe,azt,Jzn=zt(()=>{"use strict";Jkr();Vzn=require("fs"),zzn=nf(require("path"));Qzn();$zn();EFe=class EFe{constructor({page:t,evaluateWithChecksum:r,checksumPage:a,pageInteractor:o,arConfig:c,sessionId:f,runtimeFallbackData:_,fallbackData:v,variableStore:C}){this.reducedHtmlTimeoutMs=3e4;this.page=t,this.evaluateWithChecksum=r,this.checksumPage=a,this.pageInteractor=o,this.arConfig=c,this.sessionId=f,this.runtimeFallbackData=_,this.fallbackData=v,this.variableStore=C,this._analytics=new izt(this.sessionId,v.type)}static async start(t){return new EFe({...t})}getMatcherResultFileData(t){let r=t.matcherResult;if((r==null?void 0:r.name)!=="toHaveScreenshot")return;let a=e((_,v=!0)=>{if(!_)return"";try{return(0,Vzn.readFileSync)(_,v?"base64":"utf-8")}catch{return""}},"readFileSafe"),o=a(r==null?void 0:r.actual),c=a(r==null?void 0:r.diff),f=a(r==null?void 0:r.expected);if(!f)throw new Error("No expected file found for 'toHaveScreenshot'");return{...r,actual:o,diff:c,expected:f}}async getSelectionDataForChecksumId(t){return await this.evaluateWithChecksum(async a=>{let{selector:o,locator:c,clickOffset:f,parentFramesSelectors:_,invalid:v,rrwebId:C}=await window.checksum.testGenerator.getSelectorForChecksumId(a),w=await window.checksum.testGenerator.getElementForChecksumId(a),T=w instanceof HTMLOptionElement&&w.value?w.value:void 0;return{selector:o,locator:c,clickOffset:f,selectOptionValue:T,parentFramesSelectors:_,invalid:v,rrwebId:C}},t)}async getReducedHtml(t=EFe.currentChecksumId){if(this.pageInteractor.getCurrentURL()==="about:blank")return{reducedHTML:"Error: Page is about:blank. Cannot get reduced HTML - either wait or navigate to a valid page before continuing.",currentChecksumId:t};let{reducedHTML:r,currentChecksumId:a}=await this.pageInteractor.getCurrentReducedHTML({stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:t});return EFe.currentChecksumId=a,{reducedHTML:r,currentChecksumId:a}}async getApplicationState(){let{reducedHTML:t}=await this.getReducedHtml();return{reducedHTML:t,screenshot:await this.getPageScreenshot()}}async buildFallbackData(){let t=new Promise((o,c)=>setTimeout(()=>c(new Error(`getReducedHtml timeout after ${this.reducedHtmlTimeoutMs/1e3} seconds`)),this.reducedHtmlTimeoutMs)),{reducedHTML:r,currentChecksumId:a}=await Promise.race([this.getReducedHtml(),t]);return{storyInfo:this.runtimeFallbackData.storyInfo,testIdentification:this.runtimeFallbackData.testIdentification,fallbackConfig:this.runtimeFallbackData.fallbackConfig,thoughts:this.runtimeFallbackData.thoughts,errorData:{error:{name:this.fallbackData.error.name,message:this.fallbackData.error.message,stack:this.fallbackData.error.stack},errorFileContent:await this.getErrorFileContent(this.fallbackData.error)},applicationState:{reducedHTML:r,screenshot:await this.getPageScreenshot()},stepData:{matcher:this.getMatcherResultFileData(this.fallbackData.error)},currentChecksumId:a,failingStepThought:this.runtimeFallbackData.thoughts.failing,type:this.fallbackData.type,config:this.runtimeFallbackData.config,sessionId:this.sessionId,variableStore:this.variableStore.reduce((o,c)=>(o[`variablesStore.${c.name}`]=c.value,o),{}),arConfig:this.arConfig}}async scrollToElement(t){t&&await this.pageInteractor.scrollElementIntoViewByChecksumId(t)}async getPageScreenshot(t=this.arConfig){try{return this.checksumPage.wrapInternalSteps(async()=>{var a;return(await this.page.screenshot({fullPage:!0,type:((a=t.modelConfig)==null?void 0:a.provider)==="anthropic"?"jpeg":"png"})).toString("base64")})}catch{return}}async getErrorFileContent(t){try{let r=zzn.default.dirname(this.runtimeFallbackData.testIdentification.testFileName);return tVe.toRecord(t,r)}catch{throw new Error("Error while getting error file content for AI fallback")}}async wait(){await this.page.waitForTimeout(5e3)}async preprocessCode(t){var R;let r=t,a=t,o=[],c=t.match(/getByChecksumId\([^)]+\)\.([a-zA-Z]+)\(([^)]*)\)/),f=c==null?void 0:c[1],_=c==null?void 0:c[2],v=/(?:page\.)?getByChecksumId\(['"]([^'"]+)['"]\)/,C=(R=t.match(v))==null?void 0:R[1];if(!C)throw new Error("Checksum ID not found in the code");let w=await this.getSelectionDataForChecksumId(C);if(!(w!=null&&w.locator)||w.invalid)throw new Error(`Locator or selector not found for checksumId: ${C}`);a=a.replace(v,w.locator);let T=/variables?Store\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g,k=null;for(;(k=T.exec(t))!==null;){let B=k[1],U=this.variableStore.find(W=>W.name===B);U&&(o.push(U),a=a.replace(k[0],`"${U.value}"`))}return{originalCode:r,modifiedCode:a,usedVariables:o,checksumId:C,locator:w.locator,method:f,methodArgs:_}}async invokeCode(t){try{let r=await this.preprocessCode(t),{modifiedCode:a}=r,o=new Function("page",`return (async () => { return page.${a}; })()`),c;return await this.step(a,async()=>c=await o(this.page),!1,{box:!0,noLocation:!0,obtainStep:e(f=>{this.checksumPage.addAutoRecoveryStepId(f.stepId)},"obtainStep")}),{success:!0,result:c}}catch(r){throw console.log("Error while invoking code",r.message),r}}addAutoRecoveryErrorToReport(t,r){let a=this.runtimeFallbackData.thoughts.failing,o=r?`\u2705 "${a}" auto-recovered`:`\u274C "${a}" failed`;this.checksumPage.addPwAnnotation({type:o,description:t.replace(/^"(.*)"$/,"$1")}),r&&this.checksumPage.addErrorMessage(this.fallbackData.error,`${o}:
|
|
623
623
|
${t}`)}get createChecksumStep(){return t=>this.checksumPage.createChecksumStep(t)}get step(){return this.checksumPage.step.bind(this.checksumPage)}get runConditionallyWithinStep(){return(t,r,a)=>this.checksumPage.runConditionallyWithinStep(t,r,a)}async getScreenshotForElement(t){var r;try{let a=await this.getSelectionDataForChecksumId(t);if(!a)throw new Error(`Locator not found for checksumId: ${t}`);let o=((r=this.arConfig.modelConfig)==null?void 0:r.provider)==="anthropic"?"jpeg":"png";return(await this.page.locator(a.selector).screenshot({type:o})).toString("base64")}catch{throw new Error(`Failed to get screenshot for element: ${t}`)}}get analytics(){return this._analytics}};e(EFe,"AutoRecoveryRuntimeIteratorUtils"),EFe.currentChecksumId="0";azt=EFe});var Nbe,Obe,Wzn=zt(()=>{"use strict";jne();Hdt();qzn();Jzn();bve();Nbe=class Nbe extends Jme{init(t){var r;return this.initializationData=t,(r=this.initializationData.fallbackConfig).arMode??(r.arMode="fast"),this}canResolve(t){return!0}get failingThought(){return this.initializationData.thoughts.failing}getRecoveryAttemptTitle(){switch(this.initializationData.type){case"action":return`Checksum Auto-Recovery: trying to achieve action "${this.failingThought}"...`;case"assertion":return`Checksum Auto-Recovery: trying to verify assertion "${this.failingThought}"...`}}static async registerSession(t){let r=t.config.apiURL,a=t.config.apiKey;return await(await fetch(`${r}${Nbe.API_BASE_ROUTE}/register-auto-recovery-session`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:a},body:JSON.stringify({appName:t.testIdentification.testFileName,fallbackData:t})})).json()}async prepareSession(t){let r=await Nbe.registerSession(this.initializationData);this.utils=new azt({page:this.page,evaluateWithChecksum:this.evaluateWithChecksum,checksumPage:this.checksumPage,pageInteractor:this.pageInteractor,arConfig:r.arConfig,sessionId:r.sessionId,runtimeFallbackData:this.initializationData,fallbackData:t,variableStore:this.variables});try{this.agent=await rzt.build(this.utils)}catch(a){let o=a instanceof Error?a.message:String(a),c=a instanceof Error?a.stack:void 0;throw new Error(`Failed to prepare ARFallback: ${o}`)}}async resolve(t){let r=null,a=new Promise((c,f)=>{r=setTimeout(()=>{r=null,this.utils.analytics.ARError({error:`Auto-recovery timed out after ${Nbe.TIMEOUT_MS/1e3} seconds`});let _="Auto-Recovery attempt finished unsuccessfully";this.utils.createChecksumStep({title:_,withError:!0}),this.utils.addAutoRecoveryErrorToReport(_,!1),f(new Error(_))},Nbe.TIMEOUT_MS)}),o=Date.now();await this.prepareSession(t),this.utils.analytics.ARStart();try{let c=await Promise.race([this.agent.init(),a]);return r!==null&&(clearTimeout(r),r=null),this.utils.analytics.ARFinish({duration:Date.now()-o}),{fbResult:c.result,thought:c.finalThought,stepsThoughts:c.stepsThoughts,steps:[]}}catch(c){throw r!==null&&(clearTimeout(r),r=null),this.utils.analytics.ARFinish({duration:Date.now()-o}),c}}};e(Nbe,"ARFallback"),Nbe.API_BASE_ROUTE="/auto-recovery",Nbe.TIMEOUT_MS=12e4;Obe=Nbe});var Hzn,Gzn=zt(()=>{"use strict";Hzn=e(i=>{let t=i.info();return t.annotations.some(r=>r.type==="bug")||t.tags.some(r=>r==="@bug")},"isKnownBugTest")});var Kzn={};ER(Kzn,{VtgUserStoryService:()=>U_t});var _Vr,U_t,hVr=zt(()=>{"use strict";yT();fQ();qw();_Vr=class _Vr{constructor(t,r){this.apiService=t;this.config=r}getStory(){return this.story}getTestGenerationData(){return this.userStoryTestGeneration}hasTestGenerationData(){return!!this.userStoryTestGeneration}async fetchStory(t){if(V0.vtg.useFakeStory){this.story={...V0.vtg.fakeStory,id:"fake-story",environment:{name:void 0,userRole:void 0},internalTestId:"fake-internal-test-id"},tf.info("Using fake flow data",this.story);return}if(!t)throw new Error("no story id provided");try{let a=await(await this.apiService.post(`test-generation/info/${t}`)).json();if(!(a!=null&&a.id))throw new Error(`Story ${t} not found`);let{id:o,title:c,steps:f,startUrl:_,userRole:v,environment:C,internalTestId:w,version:T,collectionName:k}=a;this.story={id:o,goal:c,instructions:f,url:_,internalTestId:w,environment:{userRole:v,name:C},version:T,testFlowDescription:f,collectionName:k}}catch(r){throw tf.error(`Error fetching story by id ${t}:`,r),new Error(`Couldn't fetch story by id ${t}. Make sure the server is running and the story id is correct. Original error: ${JSON.stringify(r)}`)}}getEnvInfo(){return q_t(this.config,{role:this.story.environment.userRole,environment:this.story.environment.name})}async createTestGeneration(){if(!this.story.id)return;let t=await this.apiService.post(`test-generation/create/${this.story.id}`,{internalTestId:this.story.internalTestId}),{testGenerationId:r}=await t.json();return this.userStoryTestGeneration={testGenerationId:r},this.userStoryTestGeneration}setTestGenerationData(t){this.userStoryTestGeneration=t}};e(_Vr,"VtgUserStoryService");U_t=_Vr});var gVr,szt,Yzn=zt(()=>{"use strict";gVr=class gVr{constructor(t,r){this.config=t;this.baseURL=t.apiURL+r}getBaseURL(){return this.baseURL}get(t){let r=`${this.baseURL}/${t}`;return fetch(r,{method:"GET",headers:{ChecksumAppCode:this.config.apiKey}})}put(t,r){return fetch(`${this.baseURL}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},body:r?JSON.stringify(r):void 0})}post(t,r){return fetch(`${this.baseURL}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.config.apiKey},body:r?JSON.stringify(r):void 0})}delete(t){return fetch(`${this.baseURL}/${t}`,{method:"DELETE",headers:{ChecksumAppCode:this.config.apiKey}})}putFile(t,r){return fetch(t,{method:"PUT",headers:{"Content-Type":r.type},body:r})}};e(gVr,"RuntimeAPIService");szt=gVr});var Xzn={};ER(Xzn,{VtgCloudAPIService:()=>Q_t});var yVr,Q_t,vVr=zt(()=>{"use strict";Yzn();yVr=class yVr extends szt{constructor(r){super(r,"/client-api/runtime");this.config=r}};e(yVr,"VtgCloudAPIService");Q_t=yVr});var Tz,Zzn,wZ,bVr,lWe,ozt,xVr=zt(()=>{"use strict";v7();hCn();JH();bve();Z6e();yRt();jne();MTr();Tz=require("fs"),Zzn=nf(Tkr()),wZ=nf(require("path"));p7n();Okr();yT();x5n();A5n();E5n();C5n();w5n();SRn();fQ();ZLr();Wzn();MQr();Gzn();bVr=1e3*30,lWe=class lWe extends iJe{constructor(r,a="normal",o,c,f,_,v,C,w,T,k,R){var W,X,ne;super(r,T,()=>this.pageInteractor);this.page=r;this.runMode=a;this.testRunAnalytics=o;this.monitorBridge=c;this.testInfo=f;this.checksumTestId=_;this.test=v;this.options=C;this.isReplMode=w;this.config=T;this.pageInteractorAPI=k;this.hasRuntimeStartedTrace=!1;this.unzippedHarData=[];this.fallbacks=[];this.hasUsedAutoRecovery=!1;this.arSummaries=[];this.arStepIds=[];this.arResults=[];this.failedSteps=[];this.thoughtsCounter=0;this.highLevelThoughts=[];this.pages={};this.framesMsgBroker=new w$e;this.previousSteps=[];this.scriptLoadWrapper=e(async(r,a)=>(!this.isTimeMachineFrame(a)&&this.navigationPromise&&await this.navigationPromise,this.wrapInternalSteps(r,a.page())),"scriptLoadWrapper");this.scriptLoadCheck=e(async r=>r.evaluate(()=>!!window.checksum),"scriptLoadCheck");this.scriptLoadCallback=e(async r=>{await r.evaluate(async({appSpecificRules:a,esraTimeout:o,sessionRecorder:c,showFrontendLogs:f,showTMSeeker:_,filesObserver:v,nativeDialogObserver:C,assertionsObserver:w,actionsObserver:T,recordOptions:k})=>{var R;(R=window.checksum)==null||R.testGenerator.init(a,{esraTimeout:o,showFrontendLogs:f,skipElementHighlighting:!0,recordOptions:k},{assertionGenerator:!1,sessionRecorder:c,filesObserver:v,nativeDialogObserver:C,assertionsObserver:w,actionsObserver:T});try{_&&window.checksum.timeMachine.openSeekbar()}catch{}},{appSpecificRules:this.appSpecificRules,esraTimeout:bVr,sessionRecorder:!!(!this.isTimeMachineFrame(r)&&(this.timeMachine||this.isVTG)),showFrontendLogs:V0.isDevMode,showTMSeeker:this.isTimeMachineFrame(r)&&process.env.CHECKSUM_SHOW_TIME_MACHINE==="true",filesObserver:this.isVTG&&!this.isTimeMachineFrame(r),nativeDialogObserver:this.isVTG&&!this.isTimeMachineFrame(r),assertionsObserver:this.isVTG&&!this.isTimeMachineFrame(r),actionsObserver:this.isVTG&&!this.isTimeMachineFrame(r),recordOptions:this.isVTG?this.getVTGRecordOptions():void 0}),Dv(`[init] init script loaded for ${r.page().url()}`)},"scriptLoadCallback");eJn(C.printLogs),this.isVTG&&(this.options={...this.options,useChecksumAI:{actions:!1,assertions:!1,arVersion:1,visualComparison:!1},useMockData:!1,useChecksumSelectors:!1,autoHealPRs:!1},uzt(this.page)),Hzn(v)&&this.config.options.useChecksumAI.skipTestsWithKnownBugs&&(console.log("Auto recovery will not run for this test as it is marked as a known bug"),this.config.options.useChecksumAI.actions=!1,this.config.options.useChecksumAI.assertions=!1,this.config.options.useChecksumAI.visualComparison=!1),this.injectedScriptManager.setScriptLoadWrapper(this.scriptLoadWrapper).setScriptLoadCallback(this.scriptLoadCallback).setScriptLoadCheck(this.scriptLoadCheck);let B=Bbe({config:this.config,throwIfAuthFailed:!0}),U=this.getPlaywrightProjectConfig();if(this.pageInteractor=new r4e(this.evaluateWithChecksum.bind(this),()=>this.page.mainFrame(),()=>this.timeMachine,{log:Dv,logError:Dv},{navigationTimeout:(W=U.use)==null?void 0:W.navigationTimeout,actionTimeout:(X=U.use)==null?void 0:X.actionTimeout,testAssetsDir:Sft(Mne()),waitActionDelay:1e3},this.pageInteractorAPI,B),this.checkForActiveTracing(),this.resetFallbacks(),R&&(this.highLevelThoughts=R.highLevelThoughts??[],this.pages=R.pages??{},this.timeMachineBrowserContext=R.timeMachineBrowserContext,this.variableStore=R.variableStore),V0.testRun.timeMachine.active){let ce=this.shouldRecordRRwebEvents()?{recordRRwebEventsToFile:!0,recordRRwebEventsToFilePath:ECn(this.checksumTestId,this.testInfo.retry)}:{};this.timeMachine=new Jqt(this.framesMsgBroker,this.injectedScriptManager,{...ce,headless:process.env.CHECKSUM_SHOW_TIME_MACHINE==="true"?!1:V0.testRun.timeMachine.headless,webProxy:(ne=f.project.use)==null?void 0:ne.proxy}),this.timeMachineBrowserContext&&this.timeMachine.setTimeMachineBrowserContext(this.timeMachineBrowserContext)}this.pages[this.getPageGuid(r)]=this.proxy}previousThoughtsAndTimestamps(){return this.previousSteps}static async init(r,a,o,c,f,_,v,C,w=!1){let T=!1;_||(_=await lWe.fetchVtgInternalTestId(C),_||(_=fRt(5),T=!0,console.warn(`Checksum test id was not defined for test "${f.title}" and was auto-generated. Please replace - "${f.title}" with -
|
|
624
624
|
test(defineChecksumTest("${f.title}", "${_}"), async ({ page }) => {...`))),o.addTestInfo(_,f.testId,T),C.options.useChecksumAI!==void 0&&typeof C.options.useChecksumAI=="boolean"&&(C.options.useChecksumAI={actions:C.options.useChecksumAI,assertions:!1,visualComparison:!1});let k=new Z$e(C),R=new lWe(r,C.runMode,a,o,f,_,v,{useChecksumSelectors:!0,useChecksumAI:{actions:!0,assertions:!1},newAssertionsEnabled:C.runMode!=="normal",useMockData:!1,printLogs:!1,...C.options},w,C,k,{variableStore:c});return v._checksum.expect.setPage(R),v._checksum.checksumAI.page=R,c.clearAll(),R.testRunAnalytics.testRunStart(),await R.asyncInit(),R.proxy}static async fetchVtgInternalTestId(r){try{let a=process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG;if(!a)return;let o=JSON.parse(a);if(o.mode!=="start"||!o.storyId)return;let{VtgUserStoryService:c}=await Promise.resolve().then(()=>(hVr(),Kzn)),{VtgCloudAPIService:f}=await Promise.resolve().then(()=>(vVr(),Xzn)),_=new f(r),v=new c(_,r);await v.fetchStory(o.storyId);let C=v.getStory();return C==null?void 0:C.internalTestId}catch(a){console.warn("Failed to fetch VTG internalTestId from story:",a);return}}async asyncInit(r=!1){await this.loadAppSpecificRules(),await this.wrapInternalSteps(async()=>{await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")})}),this.timeMachine&&(await this.timeMachine.prepare(this.page.mainFrame()),this.timeMachineBrowserContext=this.timeMachine.getTimeMachineBrowserContext()),this.pageInteractor.init(),r||await this.prepareForTestArtifacts();let a=wZ.resolve(__dirname,"mock-auto-heal-agent.js");await this.page.addInitScript({path:a})}async getPage(r){let a=this.page.context().pages()[r];if(!a)throw new Error(`Page with index ${r} not found`);return this.makePage(a)}async makePage(r){let a=this.getPageGuid(r);if(this.pages[a])return this.pages[a];let o=new lWe(r,this.runMode,this.testRunAnalytics,this.monitorBridge,this.testInfo,this.checksumTestId,this.test,this.options,this.isReplMode,this.config,this.pageInteractorAPI,{highLevelThoughts:this.highLevelThoughts,pages:this.pages,timeMachineBrowserContext:this.timeMachineBrowserContext,variableStore:this.variableStore});return await o.asyncInit(!0),o.proxy}getTimeMachinePage(){var r;return(r=this.timeMachine)==null?void 0:r.getPage()}getFramesMessageBroker(){return this.framesMsgBroker}isTimeMachineFrame(r){var a;return r===((a=this.timeMachine)==null?void 0:a.getFrame())}shouldRecordRRwebEvents(){return V0.testRun.timeMachine.recordRRwebEventsToFile&&this.config.options.hostReports}getPageGuid(r){return r._guid}getPlaywrightProjectConfig(){return this.testInfo.project}checkForActiveTracing(){var o;let a=(o=this.getPlaywrightProjectConfig().use)==null?void 0:o.trace;this.traceMode=typeof a=="string"?a:a==null?void 0:a.mode}registerPageEvents(){super.registerPageEvents(),this.injectedScriptManager.addTrackedFrame(this.page),this.page.on("framenavigated",async r=>{this.injectedScriptManager.onFrameNavigated(r)})}checksumSelector(r){return this.checksumStepId=r,this.options.useChecksumSelectors&&this.setSelectorFallback(r),this.proxy}checksumAI(r,a,o){let c=this.addNewThought(r,"action",!!a);return this.previousSteps.push({thought:c.thought,timestamp:Date.now()}),a&&typeof a=="function"?this.test.step(r,async f=>{var _;try{return o!=null&&o.withDialog&&this.pageInteractor.listenToDialog(),await a()}catch(v){if(c.children=[],!this.options.useChecksumAI.actions||o!=null&&o.withDialog||o!=null&&o.skipAutoRecovery)throw v;this.setAIFallback(r,"action");try{return await this.initiateFallbackSequence({type:"action",error:v,method:void 0,args:[],testInfo:this.testInfo,step:f},{fallbackTypes:[Uve,Obe]})}catch(C){throw this.testRunAnalytics.testRunError({failedThought:r,error:(C==null?void 0:C.message)||"Unknown error"}),C}}finally{this.pageInteractor.removeListener("dialog"),this.currentThought=(_=this.currentThought)==null?void 0:_.parent}}):(this.options.useChecksumAI.actions&&!(o!=null&&o.skipAutoRecovery)&&this.setAIFallback(r,"action"),this.proxy)}resolveAssetsFolder(r){return r.map(a=>wZ.join(Sft(Mne()),a))}getRuntimeOptions(){return this.options}addPwAnnotation(r){this.testInfo.annotations.push({type:r.type,description:`
|
|
625
|
-
${r.description}`})}async onTestComplete(r){this.testRunAnalytics.testRunEnd({success:r,autoRecoveryTriggered:this.hasUsedAutoRecovery,summaries:this.arSummaries}),this.monitorBridge.addChecksumTestMetadata({checksumTestId:this.checksumTestId,pwTestId:this.testInfo.testId,retry:this.testInfo.retry,type:"autoRecoveryMetadata",data:{autoRecoveryTriggered:this.hasUsedAutoRecovery,autoRecovered:this.hasUsedAutoRecovery&&r}}),this.monitorBridge.addChecksumTestMetadata({checksumTestId:this.checksumTestId,pwTestId:this.testInfo.testId,retry:this.testInfo.retry,type:"autoRecoverySummaries",data:this.arSummaries}),this.cleanupMockData()}async wrapInternalSteps(r,a=this.page){try{return a.mainFrame()._checksumInternal=!0,a._checksumInternal=!0,await r()}finally{a.mainFrame()._checksumInternal=!1,a._checksumInternal=!1}}async conditionallyWrapInternalSteps(r,a){return r?this.wrapInternalSteps(a):a()}async wrapNoLocationSteps(r){try{return this.testInfo._checksumNoLocation=!0,await r()}finally{this.testInfo._checksumNoLocation=!1}}findAllStepsRecursively(r,a,o=[]){for(let c of r){(c._stepId===a||c.stepId===a)&&o.push(c);let f=[c.steps,c._testInfoSteps,c._steps].filter(Boolean);for(let _ of f)this.findAllStepsRecursively(_,a,o)}return o}makeChecksumStepFunction(r){return a=>{if(!r)return;let o=a._stepId||a.stepId;this.findAllStepsRecursively(a._testInfo._steps,o).forEach(f=>{f.error={message:"ChecksumStepError",stack:"Fallback Failed",cause:void 0}})}}async createChecksumStep(r){let a,o={box:!0,noLocation:!0,obtainStep:e(c=>{a=c},"obtainStep")};return await this.step(r.title,this.makeChecksumStepFunction(r.withError),!1,o),this.arStepIds.push(a.stepId),a}async step(r,a,o=!0,{obtainStep:c=void 0,box:f=!1,noLocation:_=void 0}={}){let v=this.testInfo._checksumNoLocation;try{this.testInfo._checksumInternal=o===!0,_!==void 0&&(this.testInfo._checksumNoLocation=_),await this.test.step(r,a||(()=>{}),{obtainStep:c,box:f})}finally{this.testInfo._checksumInternal=!1,this.testInfo._checksumNoLocation=v}}addErrorMessage(r,a){this.testInfo.addError(r,a)}async evaluateWithChecksum(r,a,o=!0){return this.navigationPromise&&await this.navigationPromise,this.conditionallyWrapInternalSteps(o,()=>this.page.evaluate(r,a))}getChecksumTestId(){return this.checksumTestId}addNewThought(r,a,o=!1){let c={id:void 0,thought:r,type:a,children:o?[]:void 0,parent:void 0};if(!this.currentThought)this.highLevelThoughts.push(c);else if(this.currentThought.children)this.currentThought.children.push(c),c.parent=this.currentThought;else{let f=this.currentThought.parent;f?(f.children.push(c),c.parent=f):this.highLevelThoughts.push(c)}return c.parent?c.id=`${c.parent.id}.${c.parent.children.length}`:c.id=`${++this.thoughtsCounter}`,this.currentThought=c,c}buildThoughtsChainForFallback(r=this.highLevelThoughts){let a=[];return r.forEach(o=>{a.push(o.thought),o.children&&a.push(...this.buildThoughtsChainForFallback(o.children))}),a}getVTGRecordOptions(){return{recordCanvas:!0,recordCrossOriginIframes:this.isVTG,sampling:{mousemove:!1},slimDOMOptions:"all"}}compoundSelection(...r){let a=super.compoundSelection(...r);return a.setAnalytics(()=>this.testRunAnalytics),this.checksumStepId&&this.options.useChecksumSelectors&&this.setCompoundSelectorFallback(this.checksumStepId),a}setSelectorFallback(r){let a={checksumId:r,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:this.config.apiKey,apiURL:this.config.apiURL,timeout:bVr};this.pushFallback(this.constructFallback(Xdt).init(a)),this.pushFallback(this.constructFallback(Kdt).init(a))}setCompoundSelectorFallback(r){this.pushFallback(this.constructFallback(Ydt).init({checksumId:r,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:this.config.apiKey,apiURL:this.config.apiURL,timeout:bVr}))}setAIFallback(r,a){var _;let o=((_=this.options.useChecksumAI)==null?void 0:_.arVersion)===1,c=e(()=>{var R,B;let v=this.buildThoughtsChainForFallback(),C={title:this.testInfo.title},w={testFileName:this.testInfo.file,testId:this.testInfo.testId,testSuiteId:process.env.CHECKSUM_TEST_SUITE_ID||""},T={previous:v.slice(0,-1),failing:r,next:v.slice(1)},k={storyInfo:C,testIdentification:w,fallbackConfig:{arMode:(R=this.options.useChecksumAI)==null?void 0:R.arMode,overrideOptions:(B=this.options.useChecksumAI)==null?void 0:B.overrideOptions},thoughts:T,config:{apiURL:this.config.apiURL,apiKey:this.config.apiKey},type:a};return this.constructFallback(Obe).init(k)},"createArFallback"),f=e(()=>{var v,C;return this.constructFallback(Uve).init({goal:this.testInfo.title,testFile:this.testInfo.file,apiKey:this.config.apiKey,apiURL:this.config.apiURL,testId:this.checksumTestId,thoughts:this.buildThoughtsChainForFallback(),benchmark:V0.benchmark,arMode:(v=this.options.useChecksumAI)==null?void 0:v.arMode,overrideOptions:(C=this.options.useChecksumAI)==null?void 0:C.overrideOptions,fallbackType:a})},"createAIFallback");return o?this.pushFallback(f()):this.pushFallback(c()),this.proxy}pushFallback(r){this.fallbacks.push(r),this.sortFallbacks()}handleAIFallback(r,a,o,c){let f=r.fallbackAnalyticsPayload.iterationSteps,_=f.length>0?c/f.length:0;this.testRunAnalytics.testRunFallbackExecution({result:o.fbResult,failedThought:r.getFailedThought(),summary:o.summary,stepsPayload:r.fallbackAnalyticsPayload,type:r.fallbackType??a.type,benchmark:V0.benchmark.toString(),duration:c,avgDuration:_,success:["finish","soft_assertion"].includes(o.fbResult)}),this.arResults.push({failedThought:r.getFailedThought(),result:o.fbResult,thought:o.thought})}handleAutoRecovery(r,a,o,c){let f=o.stepsThoughts.length>0?c/o.stepsThoughts.length:0;this.testRunAnalytics.testRunAutoRecovery({failingThought:r.failingThought,type:a.type,finalThought:o.thought,result:o.fbResult,duration:c,avgStepDuration:f,stepsThoughts:o.stepsThoughts,version:"v1"})}async runFallback(r,a){let o=Date.now(),c=r.resolve(a),f=await fD(c,r.timeout),_=Date.now()-o;r instanceof Uve&&(this.hasUsedAutoRecovery=!0,this.handleAIFallback(r,a,f,_)),r instanceof Obe&&(this.hasUsedAutoRecovery=!0,this.handleAutoRecovery(r,a,f,_));let v=f.thought?`: ${f.thought}`:"";if(!f||f.fbResult==="failed")throw this.createChecksumStep({title:`Recovery Failed${v}`,withError:!0}),new Error("Fallback failed");if(f.fbResult==="hard_assertion")throw this.createChecksumStep({title:`Recovery Failed${v}`,withError:!0}),new pdt(f.fbResult);if(r instanceof Uve&&f.summary&&this.arSummaries.push(f.summary),r instanceof Obe&&f.thought&&this.arSummaries.push(f.thought),this.createChecksumStep({title:`Recovery Complete${v}`}),f.steps.length===1){let C=f.steps[0];C.thought&&(this.currentThought.thought=C.thought)}else this.currentThought.children=f.steps.map((C,w)=>({id:`${this.currentThought.id}.${w+1}`,thought:C.thought,type:C.type,children:void 0,parent:this.currentThought}))}async runConditionallyWithinStep(r,a,o){return r?await this.step(a,o):await o()}async onExecutionError(r){try{return await this.initiateFallbackSequence({type:"action",...r})}catch(a){if(!this.currentThought){let{locator:o,method:c}=r;this.testRunAnalytics.testRunActionExecutionFailure({locator:o.toString(),selector:o._selector,method:c,checksumStepId:this.checksumStepId,error:a.toString()})}throw a}}async initiateFallbackSequence(r,{fallbackTypes:a=void 0}={}){Dv(`[initiateFallbackSequence] with type: ${r.type}...`);let o=this.fallbacks.find(_=>_ instanceof Uve);if(o){let _=o.getFailedThought(),v=this.variableStore.getActiveVariables();this.fallbacks.forEach(C=>{C.setThought(_),C.setVariables(v)})}let c=this.fallbacks.find(_=>_ instanceof Obe);if(c){let _=c.failingThought;this.fallbacks.forEach(v=>{v instanceof Obe&&v.setVariables(this.variableStore.getActiveVariables()),v.setThought(_)})}let f=this.fallbacks;a&&(f=f.filter(_=>a.reduce((v,C)=>v||_ instanceof C,!1))),f=f.filter(_=>_.canResolve(r));try{for(let _ of f){let v=_==null?void 0:_.toString();v&&console.log(`Using ${v}`);let C;try{let w=await this.runConditionallyWithinStep(r.type!=="assertion"||!r.withChecksumAI,_.getRecoveryAttemptTitle(r),async()=>await this.runFallback(_,r));C=!0}catch(w){if(C=!1,r.withChecksumAI&&w.message==="fetch failed")throw new Error(P4e);w instanceof pdt&&w.fallbackResult==="hard_assertion"&&(r.error.fallbackResult="hard_assertion"),v&&console.log(`Failed to use ${v}`),_.cancel();continue}return!0}throw r.error}finally{this.resetFallbacks()}}resetFallbacks(){this.fallbacks=[this.constructFallback(Zdt).init()]}async shutdown(){if(this.shouldRecordRRwebEvents()){try{await this.timeMachine.flushRRwebEventsToFile();let r=this.timeMachine.getRRwebFilePath();this.monitorBridge.addAsset({type:"rrweb-recording",path:r,testId:this.checksumTestId,fileName:wZ.basename(r)})}catch(r){Dv("Error shutting down RRweb events recording",r)}if(this.testRunAnalytics)return Dv("Flushing analytics events......"),this.testRunAnalytics.close()}}sortFallbacks(){let r=[Zdt,Ydt,Xdt,Kdt,Uve];this.fallbacks.sort((a,o)=>r.indexOf(a.constructor)-r.indexOf(o.constructor))}constructFallback(r){return new r(this.page,this.evaluateWithChecksum.bind(this),this,this.pageInteractor,{generateSelectionData:this.runMode!=="normal"})}async prepareForTestArtifacts(){if((this.options.useMockData||this.runMode==="refactor")&&await this.prepareAPIMock(),this.traceMode&&this.traceMode!=="off"){let a=await this.getTraceFilePath();a&&this.monitorBridge.addAsset({type:"trace",path:a,testId:this.checksumTestId,project:this.testInfo.project.name})}if(!1){let a=ACn(mRt(this.testInfo.file),this.checksumTestId);this.monitorBridge.addAsset({type:"har",path:a,testId:this.checksumTestId})}}async getTraceFilePath(){try{return this.hasRuntimeStartedTrace?CCn(mRt(this.testInfo.file),this.checksumTestId).replace(".zip",".original.zip"):this.testInfo.outputPath("trace.zip")}catch{return}}async prepareMockData(){let r=CTr(mRt(this.testInfo.file)),a=wZ.join(r,`${this.checksumTestId}.har.zip`);if(!(0,Tz.existsSync)(a))throw new Error("Could not find har file or zip file");let o=wZ.join(r,"tmp");(0,Tz.existsSync)(o)||(0,Tz.mkdirSync)(o);let c=(0,Tz.readFileSync)(a),f=await(0,Zzn.loadAsync)(c);for(let v of Object.keys(f.files)){let C=await f.file(v).async("string"),w=wZ.join(o,v);(0,Tz.writeFileSync)(w,C),this.unzippedHarData.push(w)}let _=wZ.join(o,"test.har");if(!(0,Tz.existsSync)(_))throw this.cleanupMockData(),new Error(`Could not find har file ${_} after unzipping ${a}`);return _}cleanupMockData(){this.unzippedHarData.forEach(r=>{(0,Tz.rmSync)(r)}),this.unzippedHarData.length>0&&(0,Tz.rmSync)(wZ.dirname(this.unzippedHarData[0]),{recursive:!0,force:!0})}async prepareAPIMock(){let r={GET:0,POST:0,PUT:0,DELETE:0};try{let a=await this.prepareMockData();await this.page.routeFromHAR(a,{url:"*/**",notFound:"fallback",update:!1});let o=this.page._routes[0].handler;await this.page.route("**/*",c=>{let f=c.request().headers(),_=c.request().method();f["Checksum-Id"]=(++r[_]).toString(),c.request()._applyFallbackOverrides({headers:f}),o(c)})}catch(a){Dv("Error setting up mock data",a.message)}}async loadAppSpecificRules(){this.appSpecificRules={};let r=wZ.join(h9e(Mne()),"settings.asr");if(!(0,Tz.existsSync)(r)){Dv("Could not find ASR file");return}let{ungzip:a}=ETr();try{let o=await a((0,Tz.readFileSync)(r));this.appSpecificRules=JSON.parse(o)||{}}catch(o){Dv("Could not read ASR file",o.message)}}addAutoRecoveryStepId(r){this.arStepIds.push(r)}};e(lWe,"RuntimePage");ozt=lWe});function zEa(i,t){return t}function JEa(i,t){return i.filter(r=>r!==void 0)}function rJn(i){return typeof i!="object"||i===null?0:Array.isArray(i)?2:GEa(i)?1:i instanceof Set?3:i instanceof Map?4:5}function WEa(i){let t=new Set;for(let r of i)for(let a of[...Object.keys(r),...Object.getOwnPropertySymbols(r)])t.add(a);return t}function HEa(i,t){return typeof i=="object"&&Object.prototype.propertyIsEnumerable.call(i,t)}function iJn(i){var a;let t=0,r=(a=i[0])==null?void 0:a[Symbol.iterator]();return{[Symbol.iterator](){return{next(){var o;do{if(r===void 0)return{done:!0,value:void 0};let c=r.next();if(c.done===!0){t+=1,r=(o=i[t])==null?void 0:o[Symbol.iterator]();continue}return{done:!1,value:c.value}}while(!0)}}}}}function GEa(i){if(!nJn.includes(Object.prototype.toString.call(i)))return!1;let{constructor:t}=i;if(t===void 0)return!0;let r=t.prototype;return!(r===null||typeof r!="object"||!nJn.includes(Object.prototype.toString.call(r))||!r.hasOwnProperty("isPrototypeOf"))}function KEa(i,t,r){let a={};for(let o of WEa(i)){let c=[];for(let v of i)HEa(v,o)&&c.push(v[o]);if(c.length===0)continue;let f=t.metaDataUpdater(r,{key:o,parents:i}),_=aJn(c,t,f);_!==C7e.skip&&(o==="__proto__"?Object.defineProperty(a,o,{value:_,configurable:!0,enumerable:!0,writable:!0}):a[o]=_)}return a}function YEa(i){return i.flat()}function XEa(i){return new Set(iJn(i))}function ZEa(i){return new Map(iJn(i))}function eCa(i){return i.at(-1)}function lzt(...i){return tCa({})(...i)}function tCa(i,t){let r=rCa(i,a);function a(...o){return aJn(o,r,t)}return e(a,"customizedDeepmerge"),a}function rCa(i,t){return{defaultMergeFunctions:czt,mergeFunctions:{...czt,...Object.fromEntries(Object.entries(i).filter(([r,a])=>Object.hasOwn(czt,r)).map(([r,a])=>a===!1?[r,czt.mergeOthers]:[r,a]))},metaDataUpdater:i.metaDataUpdater??zEa,deepmerge:t,useImplicitDefaultMerging:i.enableImplicitDefaultMerging??!1,filterValues:i.filterValues===!1?void 0:i.filterValues??JEa,actions:C7e}}function aJn(i,t,r){var c;let a=((c=t.filterValues)==null?void 0:c.call(t,i,r))??i;if(a.length===0)return;if(a.length===1)return AVr(a,t,r);let o=rJn(a[0]);if(o!==0&&o!==5){for(let f=1;f<a.length;f++)if(rJn(a[f])!==o)return AVr(a,t,r)}switch(o){case 1:return nCa(a,t,r);case 2:return iCa(a,t,r);case 3:return aCa(a,t,r);case 4:return sCa(a,t,r);default:return AVr(a,t,r)}}function nCa(i,t,r){let a=t.mergeFunctions.mergeRecords(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(i,t,r):a}function iCa(i,t,r){let a=t.mergeFunctions.mergeArrays(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(i):a}function aCa(i,t,r){let a=t.mergeFunctions.mergeSets(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(i):a}function sCa(i,t,r){let a=t.mergeFunctions.mergeMaps(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(i):a}function AVr(i,t,r){let a=t.mergeFunctions.mergeOthers(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(i):a}var C7e,RIs,tJn,nJn,czt,EVr=zt(()=>{C7e={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},RIs={defaultMerge:C7e.defaultMerge};e(zEa,"defaultMetaDataUpdater");e(JEa,"defaultFilterValues");(function(i){i[i.NOT=0]="NOT",i[i.RECORD=1]="RECORD",i[i.ARRAY=2]="ARRAY",i[i.SET=3]="SET",i[i.MAP=4]="MAP",i[i.OTHER=5]="OTHER"})(tJn||(tJn={}));e(rJn,"getObjectType");e(WEa,"getKeys");e(HEa,"objectHasProperty");e(iJn,"getIterableOfIterables");nJn=["[object Object]","[object Module]"];e(GEa,"isRecord");e(KEa,"mergeRecords$1");e(YEa,"mergeArrays$1");e(XEa,"mergeSets$1");e(ZEa,"mergeMaps$1");e(eCa,"mergeOthers$1");czt={mergeRecords:KEa,mergeArrays:YEa,mergeSets:XEa,mergeMaps:ZEa,mergeOthers:eCa};e(lzt,"deepmerge");e(tCa,"deepmergeCustom");e(rCa,"getUtils");e(aJn,"mergeUnknowns");e(nCa,"mergeRecords");e(iCa,"mergeArrays");e(aCa,"mergeSets");e(sCa,"mergeMaps");e(AVr,"mergeOthers")});function eJn(i){sJn=i}function Dv(...i){sJn&&console.log(...i)}async function _5n(i,t,r,a=6e4){if(!(t in i))return i;let o=e(()=>i[t](...r),"executor");return a===null?o():fD(o(),a,"Execution timeout")}function q_t(i,{role:t,environment:r}={},a=!1){var _,v;let o;if(r&&(o=(_=i.environments)==null?void 0:_.find(({name:C})=>r===C)),o||(o=(v=i.environments)==null?void 0:v.find(({default:C})=>C)),!o)throw new Error("Environment not found. Please make sure your environments are properly defined in the checksum.config.ts file.");let c=o.users,f;if(c&&(t!==void 0&&(f=c.find(C=>C.role===t)),f||(f=c.find(C=>C.default))),!f)throw new Error(`User not found. Please make sure the users array for the "${o.name}" environment is properly defined in the checksum.config.ts file.`);if(r&&o.name!==r){if(a)throw new Error(`Could not find environment with name "${r}" in config file`);console.warn(`Could not find environment with name "${r}" in config file, trying to use default environment`)}if(t&&f.role!==t){if(a)throw new Error(`Could not find user with role "${t}" for environment "${r}" in config file`);console.warn(`Could not find user with role "${t}" for environment "${r}" in config file, trying to login with environment's default user`)}return{environment:o,user:f}}function oCa(i){let t=`${i??Mne()}/login.ts`;if(!(0,pzt.existsSync)(t))throw console.warn(`Could not locate the login.ts file. Please make sure your login file exists at ${t}`),new Error("Could not find login.ts file");try{return require(t).default}catch(r){throw console.warn("Error loading login.ts file",r),r}}async function uCa(i,t,{environment:r,user:a,config:o}){try{let c=e(()=>t(i,{environment:r,user:a,config:o}),"performLogin");"checksumAI"in i?await i.checksumAI(`Log in${a!=null&&a.role?` using ${a.role} role`:""}${r!=null&&r.name?` in ${r.name} environment`:""}`,c):await c()}catch(c){throw console.warn(`The login method threw an exception, please check the login.ts file for the following error:
|
|
625
|
+
${r.description}`})}async onTestComplete(r){this.testRunAnalytics.testRunEnd({success:r,autoRecoveryTriggered:this.hasUsedAutoRecovery,summaries:this.arSummaries}),this.monitorBridge.addChecksumTestMetadata({checksumTestId:this.checksumTestId,pwTestId:this.testInfo.testId,retry:this.testInfo.retry,type:"autoRecoveryMetadata",data:{autoRecoveryTriggered:this.hasUsedAutoRecovery,autoRecovered:this.hasUsedAutoRecovery&&r}}),this.monitorBridge.addChecksumTestMetadata({checksumTestId:this.checksumTestId,pwTestId:this.testInfo.testId,retry:this.testInfo.retry,type:"autoRecoverySummaries",data:this.arSummaries}),this.cleanupMockData()}async wrapInternalSteps(r,a=this.page){try{return a.mainFrame()._checksumInternal=!0,a._checksumInternal=!0,await r()}finally{a.mainFrame()._checksumInternal=!1,a._checksumInternal=!1}}async conditionallyWrapInternalSteps(r,a){return r?this.wrapInternalSteps(a):a()}async wrapNoLocationSteps(r){try{return this.testInfo._checksumNoLocation=!0,await r()}finally{this.testInfo._checksumNoLocation=!1}}findAllStepsRecursively(r,a,o=[]){for(let c of r){(c._stepId===a||c.stepId===a)&&o.push(c);let f=[c.steps,c._testInfoSteps,c._steps].filter(Boolean);for(let _ of f)this.findAllStepsRecursively(_,a,o)}return o}makeChecksumStepFunction(r){return a=>{if(!r)return;let o=a._stepId||a.stepId;this.findAllStepsRecursively(a._testInfo._steps,o).forEach(f=>{f.error={message:"ChecksumStepError",stack:"Fallback Failed",cause:void 0}})}}async createChecksumStep(r){let a,o={box:!0,noLocation:!0,obtainStep:e(c=>{a=c},"obtainStep")};return await this.step(r.title,this.makeChecksumStepFunction(r.withError),!1,o),this.arStepIds.push(a.stepId),a}async step(r,a,o=!0,{obtainStep:c=void 0,box:f=!1,noLocation:_=void 0}={}){let v=this.testInfo._checksumNoLocation;try{this.testInfo._checksumInternal=o===!0,_!==void 0&&(this.testInfo._checksumNoLocation=_),await this.test.step(r,a||(()=>{}),{obtainStep:c,box:f})}finally{this.testInfo._checksumInternal=!1,this.testInfo._checksumNoLocation=v}}addErrorMessage(r,a){this.testInfo.addError(r,a)}async evaluateWithChecksum(r,a,o=!0){return this.navigationPromise&&await this.navigationPromise,this.conditionallyWrapInternalSteps(o,()=>this.page.evaluate(r,a))}getChecksumTestId(){return this.checksumTestId}addNewThought(r,a,o=!1){let c={id:void 0,thought:r,type:a,children:o?[]:void 0,parent:void 0};if(!this.currentThought)this.highLevelThoughts.push(c);else if(this.currentThought.children)this.currentThought.children.push(c),c.parent=this.currentThought;else{let f=this.currentThought.parent;f?(f.children.push(c),c.parent=f):this.highLevelThoughts.push(c)}return c.parent?c.id=`${c.parent.id}.${c.parent.children.length}`:c.id=`${++this.thoughtsCounter}`,this.currentThought=c,c}buildThoughtsChainForFallback(r=this.highLevelThoughts){let a=[];return r.forEach(o=>{a.push(o.thought),o.children&&a.push(...this.buildThoughtsChainForFallback(o.children))}),a}getVTGRecordOptions(){return{recordCanvas:!0,recordCrossOriginIframes:this.isVTG,sampling:{mousemove:!1},slimDOMOptions:"all"}}compoundSelection(...r){let a=super.compoundSelection(...r);return a.setAnalytics(()=>this.testRunAnalytics),this.checksumStepId&&this.options.useChecksumSelectors&&this.setCompoundSelectorFallback(this.checksumStepId),a}setSelectorFallback(r){let a={checksumId:r,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:this.config.apiKey,apiURL:this.config.apiURL,timeout:bVr};this.pushFallback(this.constructFallback(Xdt).init(a)),this.pushFallback(this.constructFallback(Kdt).init(a))}setCompoundSelectorFallback(r){this.pushFallback(this.constructFallback(Ydt).init({checksumId:r,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:this.config.apiKey,apiURL:this.config.apiURL,timeout:bVr}))}setAIFallback(r,a){var _;let o=((_=this.options.useChecksumAI)==null?void 0:_.arVersion)===1,c=e(()=>{var R,B;let v=this.buildThoughtsChainForFallback(),C={title:this.testInfo.title},w={testFileName:this.testInfo.file,testId:this.testInfo.testId,testSuiteId:process.env.CHECKSUM_TEST_SUITE_ID||""},T={previous:v.slice(0,-1),failing:r,next:v.slice(1)},k={storyInfo:C,testIdentification:w,fallbackConfig:{arMode:(R=this.options.useChecksumAI)==null?void 0:R.arMode,overrideOptions:(B=this.options.useChecksumAI)==null?void 0:B.overrideOptions},thoughts:T,config:{apiURL:this.config.apiURL,apiKey:this.config.apiKey},type:a};return this.constructFallback(Obe).init(k)},"createArFallback"),f=e(()=>{var v,C;return this.constructFallback(Uve).init({goal:this.testInfo.title,testFile:this.testInfo.file,apiKey:this.config.apiKey,apiURL:this.config.apiURL,testId:this.checksumTestId,thoughts:this.buildThoughtsChainForFallback(),benchmark:V0.benchmark,arMode:(v=this.options.useChecksumAI)==null?void 0:v.arMode,overrideOptions:(C=this.options.useChecksumAI)==null?void 0:C.overrideOptions,fallbackType:a})},"createAIFallback");return o?this.pushFallback(f()):this.pushFallback(c()),this.proxy}pushFallback(r){this.fallbacks.push(r),this.sortFallbacks()}handleAIFallback(r,a,o,c){let f=r.fallbackAnalyticsPayload.iterationSteps,_=f.length>0?c/f.length:0;this.testRunAnalytics.testRunFallbackExecution({result:o.fbResult,failedThought:r.getFailedThought(),summary:o.summary,stepsPayload:r.fallbackAnalyticsPayload,type:r.fallbackType??a.type,benchmark:V0.benchmark.toString(),duration:c,avgDuration:_,success:["finish","soft_assertion"].includes(o.fbResult)}),this.arResults.push({failedThought:r.getFailedThought(),result:o.fbResult,thought:o.thought})}handleAutoRecovery(r,a,o,c){let f=o.stepsThoughts.length>0?c/o.stepsThoughts.length:0;this.testRunAnalytics.testRunAutoRecovery({failingThought:r.failingThought,type:a.type,finalThought:o.thought,result:o.fbResult,duration:c,avgStepDuration:f,stepsThoughts:o.stepsThoughts,version:"v1"})}async runFallback(r,a){let o=Date.now(),c=r.resolve(a),f=await fD(c,r.timeout),_=Date.now()-o;r instanceof Uve&&(this.hasUsedAutoRecovery=!0,this.handleAIFallback(r,a,f,_)),r instanceof Obe&&(this.hasUsedAutoRecovery=!0,this.handleAutoRecovery(r,a,f,_));let v=f.thought?`: ${f.thought}`:"";if(!f||f.fbResult==="failed")throw this.createChecksumStep({title:`Recovery Failed${v}`,withError:!0}),new Error("Fallback failed");if(f.fbResult==="hard_assertion")throw this.createChecksumStep({title:`Recovery Failed${v}`,withError:!0}),new pdt(f.fbResult);if(r instanceof Uve&&f.summary&&this.arSummaries.push(f.summary),r instanceof Obe&&f.thought&&this.arSummaries.push(f.thought),this.createChecksumStep({title:`Recovery Complete${v}`}),f.steps.length===1){let C=f.steps[0];C.thought&&(this.currentThought.thought=C.thought)}else this.currentThought.children=f.steps.map((C,w)=>({id:`${this.currentThought.id}.${w+1}`,thought:C.thought,type:C.type,children:void 0,parent:this.currentThought}))}async runConditionallyWithinStep(r,a,o){return r?await this.step(a,o):await o()}async onExecutionError(r){try{return await this.initiateFallbackSequence({type:"action",...r})}catch(a){if(!this.currentThought){let{locator:o,method:c}=r;this.testRunAnalytics.testRunActionExecutionFailure({locator:o.toString(),selector:o._selector,method:c,checksumStepId:this.checksumStepId,error:a.toString()})}throw a}}async initiateFallbackSequence(r,{fallbackTypes:a=void 0}={}){Dv(`[initiateFallbackSequence] with type: ${r.type}...`);let o=this.fallbacks.find(_=>_ instanceof Uve);if(o){let _=o.getFailedThought(),v=this.variableStore.getActiveVariables();this.fallbacks.forEach(C=>{C.setThought(_),C.setVariables(v)})}let c=this.fallbacks.find(_=>_ instanceof Obe);if(c){let _=c.failingThought;this.fallbacks.forEach(v=>{v instanceof Obe&&v.setVariables(this.variableStore.getActiveVariables()),v.setThought(_)})}let f=this.fallbacks;a&&(f=f.filter(_=>a.reduce((v,C)=>v||_ instanceof C,!1))),f=f.filter(_=>_.canResolve(r));try{for(let _ of f){let v=_==null?void 0:_.toString();v&&console.log(`Using ${v}`);let C;try{let w=await this.runConditionallyWithinStep(r.type!=="assertion"||!r.withChecksumAI,_.getRecoveryAttemptTitle(r),async()=>await this.runFallback(_,r));C=!0}catch(w){if(C=!1,r.withChecksumAI&&w.message==="fetch failed")throw new Error(P4e);w instanceof pdt&&w.fallbackResult==="hard_assertion"&&(r.error.fallbackResult="hard_assertion"),v&&console.log(`Failed to use ${v}`),_.cancel();continue}return!0}throw r.error}finally{this.resetFallbacks()}}resetFallbacks(){this.fallbacks=[this.constructFallback(Zdt).init()]}async shutdown(){if(this.shouldRecordRRwebEvents()){try{await this.timeMachine.flushRRwebEventsToFile();let r=this.timeMachine.getRRwebFilePath();this.monitorBridge.addAsset({type:"rrweb-recording",path:r,testId:this.checksumTestId,fileName:wZ.basename(r)})}catch(r){Dv("Error shutting down RRweb events recording",r)}if(this.testRunAnalytics)return Dv("Flushing analytics events......"),this.testRunAnalytics.close()}}sortFallbacks(){let r=[Zdt,Ydt,Xdt,Kdt,Uve];this.fallbacks.sort((a,o)=>r.indexOf(a.constructor)-r.indexOf(o.constructor))}constructFallback(r){return new r(this.page,this.evaluateWithChecksum.bind(this),this,this.pageInteractor,{generateSelectionData:this.runMode!=="normal"})}async prepareForTestArtifacts(){if((this.options.useMockData||this.runMode==="refactor")&&await this.prepareAPIMock(),this.traceMode&&this.traceMode!=="off"){let a=await this.getTraceFilePath();a&&this.monitorBridge.addAsset({type:"trace",path:a,testId:this.checksumTestId,project:this.testInfo.project.name})}if(!1){let a=ACn(mRt(this.testInfo.file),this.checksumTestId);this.monitorBridge.addAsset({type:"har",path:a,testId:this.checksumTestId})}}async getTraceFilePath(){try{return this.hasRuntimeStartedTrace?CCn(mRt(this.testInfo.file),this.checksumTestId).replace(".zip",".original.zip"):this.testInfo.outputPath("trace.zip")}catch{return}}async prepareMockData(){let r=CTr(mRt(this.testInfo.file)),a=wZ.join(r,`${this.checksumTestId}.har.zip`);if(!(0,Tz.existsSync)(a))throw new Error("Could not find har file or zip file");let o=wZ.join(r,"tmp");(0,Tz.existsSync)(o)||(0,Tz.mkdirSync)(o);let c=(0,Tz.readFileSync)(a),f=await(0,Zzn.loadAsync)(c);for(let v of Object.keys(f.files)){let C=await f.file(v).async("string"),w=wZ.join(o,v);(0,Tz.writeFileSync)(w,C),this.unzippedHarData.push(w)}let _=wZ.join(o,"test.har");if(!(0,Tz.existsSync)(_))throw this.cleanupMockData(),new Error(`Could not find har file ${_} after unzipping ${a}`);return _}cleanupMockData(){this.unzippedHarData.forEach(r=>{(0,Tz.rmSync)(r)}),this.unzippedHarData.length>0&&(0,Tz.rmSync)(wZ.dirname(this.unzippedHarData[0]),{recursive:!0,force:!0})}async prepareAPIMock(){let r={GET:0,POST:0,PUT:0,DELETE:0};try{let a=await this.prepareMockData();await this.page.routeFromHAR(a,{url:"*/**",notFound:"fallback",update:!1});let o=this.page._routes[0].handler;await this.page.route("**/*",c=>{let f=c.request().headers(),_=c.request().method();f["Checksum-Id"]=(++r[_]).toString(),c.request()._applyFallbackOverrides({headers:f}),o(c)})}catch(a){Dv("Error setting up mock data",a.message)}}async loadAppSpecificRules(){this.appSpecificRules={};let r=wZ.join(h9e(Mne()),"settings.asr");if(!(0,Tz.existsSync)(r)){Dv("Could not find ASR file");return}let{ungzip:a}=ETr();try{let o=await a((0,Tz.readFileSync)(r));this.appSpecificRules=JSON.parse(o)||{}}catch(o){Dv("Could not read ASR file",o.message)}}addAutoRecoveryStepId(r){this.arStepIds.push(r)}};e(lWe,"RuntimePage");ozt=lWe});function zEa(i,t){return t}function JEa(i,t){return i.filter(r=>r!==void 0)}function rJn(i){return typeof i!="object"||i===null?0:Array.isArray(i)?2:GEa(i)?1:i instanceof Set?3:i instanceof Map?4:5}function WEa(i){let t=new Set;for(let r of i)for(let a of[...Object.keys(r),...Object.getOwnPropertySymbols(r)])t.add(a);return t}function HEa(i,t){return typeof i=="object"&&Object.prototype.propertyIsEnumerable.call(i,t)}function iJn(i){var a;let t=0,r=(a=i[0])==null?void 0:a[Symbol.iterator]();return{[Symbol.iterator](){return{next(){var o;do{if(r===void 0)return{done:!0,value:void 0};let c=r.next();if(c.done===!0){t+=1,r=(o=i[t])==null?void 0:o[Symbol.iterator]();continue}return{done:!1,value:c.value}}while(!0)}}}}}function GEa(i){if(!nJn.includes(Object.prototype.toString.call(i)))return!1;let{constructor:t}=i;if(t===void 0)return!0;let r=t.prototype;return!(r===null||typeof r!="object"||!nJn.includes(Object.prototype.toString.call(r))||!r.hasOwnProperty("isPrototypeOf"))}function KEa(i,t,r){let a={};for(let o of WEa(i)){let c=[];for(let v of i)HEa(v,o)&&c.push(v[o]);if(c.length===0)continue;let f=t.metaDataUpdater(r,{key:o,parents:i}),_=aJn(c,t,f);_!==C7e.skip&&(o==="__proto__"?Object.defineProperty(a,o,{value:_,configurable:!0,enumerable:!0,writable:!0}):a[o]=_)}return a}function YEa(i){return i.flat()}function XEa(i){return new Set(iJn(i))}function ZEa(i){return new Map(iJn(i))}function eCa(i){return i.at(-1)}function lzt(...i){return tCa({})(...i)}function tCa(i,t){let r=rCa(i,a);function a(...o){return aJn(o,r,t)}return e(a,"customizedDeepmerge"),a}function rCa(i,t){return{defaultMergeFunctions:czt,mergeFunctions:{...czt,...Object.fromEntries(Object.entries(i).filter(([r,a])=>Object.hasOwn(czt,r)).map(([r,a])=>a===!1?[r,czt.mergeOthers]:[r,a]))},metaDataUpdater:i.metaDataUpdater??zEa,deepmerge:t,useImplicitDefaultMerging:i.enableImplicitDefaultMerging??!1,filterValues:i.filterValues===!1?void 0:i.filterValues??JEa,actions:C7e}}function aJn(i,t,r){var c;let a=((c=t.filterValues)==null?void 0:c.call(t,i,r))??i;if(a.length===0)return;if(a.length===1)return AVr(a,t,r);let o=rJn(a[0]);if(o!==0&&o!==5){for(let f=1;f<a.length;f++)if(rJn(a[f])!==o)return AVr(a,t,r)}switch(o){case 1:return nCa(a,t,r);case 2:return iCa(a,t,r);case 3:return aCa(a,t,r);case 4:return sCa(a,t,r);default:return AVr(a,t,r)}}function nCa(i,t,r){let a=t.mergeFunctions.mergeRecords(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(i,t,r):a}function iCa(i,t,r){let a=t.mergeFunctions.mergeArrays(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(i):a}function aCa(i,t,r){let a=t.mergeFunctions.mergeSets(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(i):a}function sCa(i,t,r){let a=t.mergeFunctions.mergeMaps(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(i):a}function AVr(i,t,r){let a=t.mergeFunctions.mergeOthers(i,t,r);return a===C7e.defaultMerge||t.useImplicitDefaultMerging&&a===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(i):a}var C7e,RIs,tJn,nJn,czt,EVr=zt(()=>{C7e={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},RIs={defaultMerge:C7e.defaultMerge};e(zEa,"defaultMetaDataUpdater");e(JEa,"defaultFilterValues");(function(i){i[i.NOT=0]="NOT",i[i.RECORD=1]="RECORD",i[i.ARRAY=2]="ARRAY",i[i.SET=3]="SET",i[i.MAP=4]="MAP",i[i.OTHER=5]="OTHER"})(tJn||(tJn={}));e(rJn,"getObjectType");e(WEa,"getKeys");e(HEa,"objectHasProperty");e(iJn,"getIterableOfIterables");nJn=["[object Object]","[object Module]"];e(GEa,"isRecord");e(KEa,"mergeRecords$1");e(YEa,"mergeArrays$1");e(XEa,"mergeSets$1");e(ZEa,"mergeMaps$1");e(eCa,"mergeOthers$1");czt={mergeRecords:KEa,mergeArrays:YEa,mergeSets:XEa,mergeMaps:ZEa,mergeOthers:eCa};e(lzt,"deepmerge");e(tCa,"deepmergeCustom");e(rCa,"getUtils");e(aJn,"mergeUnknowns");e(nCa,"mergeRecords");e(iCa,"mergeArrays");e(aCa,"mergeSets");e(sCa,"mergeMaps");e(AVr,"mergeOthers")});function eJn(i){sJn=i}function Dv(...i){sJn&&console.log(...i)}async function _5n(i,t,r,a=6e4){if(!(t in i))return i;let o=e(()=>i[t](...r),"executor");return a===null?o():fD(o(),a,"Execution timeout")}function q_t(i,{role:t,environment:r}={},a=!1){var _,v;let o;if(r&&(o=(_=i.environments)==null?void 0:_.find(({name:C})=>r===C)),o||(o=(v=i.environments)==null?void 0:v.find(({default:C})=>C)),!o)throw new Error("Environment not found. Please make sure your environments are properly defined in the checksum.config.ts file.");let c=o.users,f;if(c&&(t!==void 0&&(f=c.find(C=>C.role===t)),f||(f=c.find(C=>C.default))),!f)throw new Error(`User not found. Please make sure the users array for the "${o.name}" environment is properly defined in the checksum.config.ts file.`);if(r&&o.name!==r){if(a)throw new Error(`Could not find environment with name "${r}" in config file`);console.warn(`Could not find environment with name "${r}" in config file, trying to use default environment`)}if(t&&f.role!==t){if(a)throw new Error(`Could not find user with role "${t}" for environment "${r}" in config file`);console.warn(`Could not find user with role "${t}" for environment "${r}" in config file, trying to login with environment's default user`)}return{environment:o,user:f}}function oCa(i){let t=`${i??Mne()}/login.ts`;if(!(0,pzt.existsSync)(t))throw console.warn(`Could not locate the login.ts file. Please make sure your login file exists at ${t}`),new Error("Could not find login.ts file");try{return require(t).default}catch(r){throw console.warn("Error loading login.ts file",r),r}}async function uCa(i,t,{environment:r,user:a,config:o}){try{let c=e(()=>t(i,{environment:r,user:a,config:o}),"performLogin");"checksumAI"in i?await i.checksumAI(`Log in${a!=null&&a.role?` using ${a.role} role`:""}${r!=null&&r.name?` in ${r.name} environment`:""}`,c,{skipAutoRecovery:!0}):await c()}catch(c){throw console.warn(`The login method threw an exception, please check the login.ts file for the following error:
|
|
626
626
|
`,c),c}}function Bbe(i){let{config:t,folder:r,throwIfAuthFailed:a}=i,o=oCa(r);return async(c,{role:f,environment:_}={})=>{let{environment:v,user:C}=q_t(t,{role:f,environment:_},i.throwIfEnvInfoInvalid);if(a&&!C)throw new Error("Could not find user credentials matching the provided role and/or environment");await uCa(c,o,{environment:v,user:C,config:t})}}function oJn(i,{environmentName:t,userRole:r}){let a=Bbe(i);return o=>a(o,{environment:t,role:r})}function Zqt(){if(pWe)return pWe;try{let i=(0,pzt.existsSync)(`${Mne()}/checksum.config.ts`)?"checksum.config.ts":(0,pzt.existsSync)(`${Mne()}/checksum.config.tmp.ts`)?"checksum.config.tmp.ts":void 0;if(i)return fzt(require(`${Mne()}/${i}`).default)}catch{console.warn("Could not find checksum config file, will run with defaults")}return fzt()}function fzt(i={}){var r,a,o,c;let t={apiKey:void 0,runMode:"normal",apiURL:"https://api.checksum.ai",options:{useChecksumSelectors:!0,useChecksumAI:{actions:!0,assertions:!1,skipTestsWithKnownBugs:!0},newAssertionsEnabled:!0,useMockData:!1,printLogs:!1,hideReports:process.env.AUTHORIZE_REPORTS==="true"}};return((a=(r=i.options)==null?void 0:r.useChecksumAI)==null?void 0:a.visualComparison)===void 0&&((c=(o=i.options)==null?void 0:o.useChecksumAI)!=null&&c.assertions)&&(i.options.useChecksumAI.visualComparison=!0),pWe=lzt(t,i),V0.testRun.disableAutoRecovery&&(pWe.options.useChecksumAI={actions:!1,assertions:!1,visualComparison:!1}),V0.testRun.disableHostReports&&(pWe.options.hostReports=!1),pWe}function uzt(i){let t=e(r=>{r.on("dialog",a=>{})},"makeDialogHandler");i.context().pages().forEach(t),i.context().on("page",r=>{t(r)})}var pzt,sJn,pWe,P4e,fQ=zt(()=>{"use strict";xVr();v7();Z6e();pzt=require("fs");yT();EVr();sJn=!1;e(eJn,"setLogToConsole");e(Dv,"log");e(_5n,"executePlaywrightMethodWithTimeout");e(q_t,"resolveEnvironment");e(oCa,"requireLogin");e(uCa,"proceedWithLogin");e(Bbe,"makeUnboundLogin");e(oJn,"makeBoundLogin");e(Zqt,"loadChecksumConfig");e(fzt,"getChecksumConfig");e(uzt,"preventDialogAutoDismissal");P4e="Checksum failed connecting to the server"});var D7e=gr((h9s,mJn)=>{var FVr=require("tty"),fJn,bzt,dJn,pCa=((dJn=(bzt=(fJn=FVr==null?void 0:FVr.WriteStream)==null?void 0:fJn.prototype)==null?void 0:bzt.hasColors)==null?void 0:dJn.call(bzt))??!1,Ux=e((i,t)=>{if(!pCa)return o=>o;let r=`\x1B[${i}m`,a=`\x1B[${t}m`;return o=>{let c=o+"",f=c.indexOf(a);if(f===-1)return r+c+a;let _=r,v=0;for(;f!==-1;)_+=c.slice(v,f)+r,v=f+a.length,f=c.indexOf(a,v);return _+=c.slice(v)+a,_}},"format"),vx={};vx.reset=Ux(0,0);vx.bold=Ux(1,22);vx.dim=Ux(2,22);vx.italic=Ux(3,23);vx.underline=Ux(4,24);vx.overline=Ux(53,55);vx.inverse=Ux(7,27);vx.hidden=Ux(8,28);vx.strikethrough=Ux(9,29);vx.black=Ux(30,39);vx.red=Ux(31,39);vx.green=Ux(32,39);vx.yellow=Ux(33,39);vx.blue=Ux(34,39);vx.magenta=Ux(35,39);vx.cyan=Ux(36,39);vx.white=Ux(37,39);vx.gray=Ux(90,39);vx.bgBlack=Ux(40,49);vx.bgRed=Ux(41,49);vx.bgGreen=Ux(42,49);vx.bgYellow=Ux(43,49);vx.bgBlue=Ux(44,49);vx.bgMagenta=Ux(45,49);vx.bgCyan=Ux(46,49);vx.bgWhite=Ux(47,49);vx.bgGray=Ux(100,49);vx.redBright=Ux(91,39);vx.greenBright=Ux(92,39);vx.yellowBright=Ux(93,39);vx.blueBright=Ux(94,39);vx.magentaBright=Ux(95,39);vx.cyanBright=Ux(96,39);vx.whiteBright=Ux(97,39);vx.bgRedBright=Ux(101,49);vx.bgGreenBright=Ux(102,49);vx.bgYellowBright=Ux(103,49);vx.bgBlueBright=Ux(104,49);vx.bgMagentaBright=Ux(105,49);vx.bgCyanBright=Ux(106,49);vx.bgWhiteBright=Ux(107,49);mJn.exports=vx});var xJn=gr(($9s,bJn)=>{"use strict";bJn.exports=vCa;function yCa(i){let t={defaultWidth:0,output:process.stdout,tty:require("tty")};return i?(Object.keys(t).forEach(function(r){i[r]||(i[r]=t[r])}),i):t}e(yCa,"normalizeOpts");function vCa(i){let t=yCa(i);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let r=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(r)&&r!==0)return r}return t.defaultWidth}e(vCa,"cliWidth")});var EJn=gr((z9s,AJn)=>{"use strict";AJn.exports=({onlyFirst:i=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,i?void 0:"g")}});var xzt=gr((J9s,CJn)=>{"use strict";var bCa=EJn();CJn.exports=i=>typeof i=="string"?i.replace(bCa(),""):i});var SJn=gr((W9s,OVr)=>{"use strict";var wJn=e(i=>Number.isNaN(i)?!1:i>=4352&&(i<=4447||i===9001||i===9002||11904<=i&&i<=12871&&i!==12351||12880<=i&&i<=19903||19968<=i&&i<=42182||43360<=i&&i<=43388||44032<=i&&i<=55203||63744<=i&&i<=64255||65040<=i&&i<=65049||65072<=i&&i<=65131||65281<=i&&i<=65376||65504<=i&&i<=65510||110592<=i&&i<=110593||127488<=i&&i<=127569||131072<=i&&i<=262141),"isFullwidthCodePoint");OVr.exports=wJn;OVr.exports.default=wJn});var TJn=gr((G9s,DJn)=>{"use strict";DJn.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var IJn=gr((K9s,BVr)=>{"use strict";var xCa=xzt(),ACa=SJn(),ECa=TJn(),kJn=e(i=>{if(typeof i!="string"||i.length===0||(i=xCa(i),i.length===0))return 0;i=i.replace(ECa()," ");let t=0;for(let r=0;r<i.length;r++){let a=i.codePointAt(r);a<=31||a>=127&&a<=159||a>=768&&a<=879||(a>65535&&r++,t+=ACa(a)?2:1)}return t},"stringWidth");BVr.exports=kJn;BVr.exports.default=kJn});var FJn=gr((X9s,PJn)=>{"use strict";PJn.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var RVr=gr((Z9s,OJn)=>{var $_t=FJn(),NJn={};for(let i of Object.keys($_t))NJn[$_t[i]]=i;var gy={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};OJn.exports=gy;for(let i of Object.keys(gy)){if(!("channels"in gy[i]))throw new Error("missing channels property: "+i);if(!("labels"in gy[i]))throw new Error("missing channel labels property: "+i);if(gy[i].labels.length!==gy[i].channels)throw new Error("channel and label counts mismatch: "+i);let{channels:t,labels:r}=gy[i];delete gy[i].channels,delete gy[i].labels,Object.defineProperty(gy[i],"channels",{value:t}),Object.defineProperty(gy[i],"labels",{value:r})}gy.rgb.hsl=function(i){let t=i[0]/255,r=i[1]/255,a=i[2]/255,o=Math.min(t,r,a),c=Math.max(t,r,a),f=c-o,_,v;c===o?_=0:t===c?_=(r-a)/f:r===c?_=2+(a-t)/f:a===c&&(_=4+(t-r)/f),_=Math.min(_*60,360),_<0&&(_+=360);let C=(o+c)/2;return c===o?v=0:C<=.5?v=f/(c+o):v=f/(2-c-o),[_,v*100,C*100]};gy.rgb.hsv=function(i){let t,r,a,o,c,f=i[0]/255,_=i[1]/255,v=i[2]/255,C=Math.max(f,_,v),w=C-Math.min(f,_,v),T=e(function(k){return(C-k)/6/w+1/2},"diffc");return w===0?(o=0,c=0):(c=w/C,t=T(f),r=T(_),a=T(v),f===C?o=a-r:_===C?o=1/3+t-a:v===C&&(o=2/3+r-t),o<0?o+=1:o>1&&(o-=1)),[o*360,c*100,C*100]};gy.rgb.hwb=function(i){let t=i[0],r=i[1],a=i[2],o=gy.rgb.hsl(i)[0],c=1/255*Math.min(t,Math.min(r,a));return a=1-1/255*Math.max(t,Math.max(r,a)),[o,c*100,a*100]};gy.rgb.cmyk=function(i){let t=i[0]/255,r=i[1]/255,a=i[2]/255,o=Math.min(1-t,1-r,1-a),c=(1-t-o)/(1-o)||0,f=(1-r-o)/(1-o)||0,_=(1-a-o)/(1-o)||0;return[c*100,f*100,_*100,o*100]};function CCa(i,t){return(i[0]-t[0])**2+(i[1]-t[1])**2+(i[2]-t[2])**2}e(CCa,"comparativeDistance");gy.rgb.keyword=function(i){let t=NJn[i];if(t)return t;let r=1/0,a;for(let o of Object.keys($_t)){let c=$_t[o],f=CCa(i,c);f<r&&(r=f,a=o)}return a};gy.keyword.rgb=function(i){return $_t[i]};gy.rgb.xyz=function(i){let t=i[0]/255,r=i[1]/255,a=i[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,a=a>.04045?((a+.055)/1.055)**2.4:a/12.92;let o=t*.4124+r*.3576+a*.1805,c=t*.2126+r*.7152+a*.0722,f=t*.0193+r*.1192+a*.9505;return[o*100,c*100,f*100]};gy.rgb.lab=function(i){let t=gy.rgb.xyz(i),r=t[0],a=t[1],o=t[2];r/=95.047,a/=100,o/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;let c=116*a-16,f=500*(r-a),_=200*(a-o);return[c,f,_]};gy.hsl.rgb=function(i){let t=i[0]/360,r=i[1]/100,a=i[2]/100,o,c,f;if(r===0)return f=a*255,[f,f,f];a<.5?o=a*(1+r):o=a+r-a*r;let _=2*a-o,v=[0,0,0];for(let C=0;C<3;C++)c=t+1/3*-(C-1),c<0&&c++,c>1&&c--,6*c<1?f=_+(o-_)*6*c:2*c<1?f=o:3*c<2?f=_+(o-_)*(2/3-c)*6:f=_,v[C]=f*255;return v};gy.hsl.hsv=function(i){let t=i[0],r=i[1]/100,a=i[2]/100,o=r,c=Math.max(a,.01);a*=2,r*=a<=1?a:2-a,o*=c<=1?c:2-c;let f=(a+r)/2,_=a===0?2*o/(c+o):2*r/(a+r);return[t,_*100,f*100]};gy.hsv.rgb=function(i){let t=i[0]/60,r=i[1]/100,a=i[2]/100,o=Math.floor(t)%6,c=t-Math.floor(t),f=255*a*(1-r),_=255*a*(1-r*c),v=255*a*(1-r*(1-c));switch(a*=255,o){case 0:return[a,v,f];case 1:return[_,a,f];case 2:return[f,a,v];case 3:return[f,_,a];case 4:return[v,f,a];case 5:return[a,f,_]}};gy.hsv.hsl=function(i){let t=i[0],r=i[1]/100,a=i[2]/100,o=Math.max(a,.01),c,f;f=(2-r)*a;let _=(2-r)*o;return c=r*o,c/=_<=1?_:2-_,c=c||0,f/=2,[t,c*100,f*100]};gy.hwb.rgb=function(i){let t=i[0]/360,r=i[1]/100,a=i[2]/100,o=r+a,c;o>1&&(r/=o,a/=o);let f=Math.floor(6*t),_=1-a;c=6*t-f,f&1&&(c=1-c);let v=r+c*(_-r),C,w,T;switch(f){default:case 6:case 0:C=_,w=v,T=r;break;case 1:C=v,w=_,T=r;break;case 2:C=r,w=_,T=v;break;case 3:C=r,w=v,T=_;break;case 4:C=v,w=r,T=_;break;case 5:C=_,w=r,T=v;break}return[C*255,w*255,T*255]};gy.cmyk.rgb=function(i){let t=i[0]/100,r=i[1]/100,a=i[2]/100,o=i[3]/100,c=1-Math.min(1,t*(1-o)+o),f=1-Math.min(1,r*(1-o)+o),_=1-Math.min(1,a*(1-o)+o);return[c*255,f*255,_*255]};gy.xyz.rgb=function(i){let t=i[0]/100,r=i[1]/100,a=i[2]/100,o,c,f;return o=t*3.2406+r*-1.5372+a*-.4986,c=t*-.9689+r*1.8758+a*.0415,f=t*.0557+r*-.204+a*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,f=f>.0031308?1.055*f**(1/2.4)-.055:f*12.92,o=Math.min(Math.max(0,o),1),c=Math.min(Math.max(0,c),1),f=Math.min(Math.max(0,f),1),[o*255,c*255,f*255]};gy.xyz.lab=function(i){let t=i[0],r=i[1],a=i[2];t/=95.047,r/=100,a/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;let o=116*r-16,c=500*(t-r),f=200*(r-a);return[o,c,f]};gy.lab.xyz=function(i){let t=i[0],r=i[1],a=i[2],o,c,f;c=(t+16)/116,o=r/500+c,f=c-a/200;let _=c**3,v=o**3,C=f**3;return c=_>.008856?_:(c-16/116)/7.787,o=v>.008856?v:(o-16/116)/7.787,f=C>.008856?C:(f-16/116)/7.787,o*=95.047,c*=100,f*=108.883,[o,c,f]};gy.lab.lch=function(i){let t=i[0],r=i[1],a=i[2],o;o=Math.atan2(a,r)*360/2/Math.PI,o<0&&(o+=360);let f=Math.sqrt(r*r+a*a);return[t,f,o]};gy.lch.lab=function(i){let t=i[0],r=i[1],o=i[2]/360*2*Math.PI,c=r*Math.cos(o),f=r*Math.sin(o);return[t,c,f]};gy.rgb.ansi16=function(i,t=null){let[r,a,o]=i,c=t===null?gy.rgb.hsv(i)[2]:t;if(c=Math.round(c/50),c===0)return 30;let f=30+(Math.round(o/255)<<2|Math.round(a/255)<<1|Math.round(r/255));return c===2&&(f+=60),f};gy.hsv.ansi16=function(i){return gy.rgb.ansi16(gy.hsv.rgb(i),i[2])};gy.rgb.ansi256=function(i){let t=i[0],r=i[1],a=i[2];return t===r&&r===a?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)};gy.ansi16.rgb=function(i){let t=i%10;if(t===0||t===7)return i>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let r=(~~(i>50)+1)*.5,a=(t&1)*r*255,o=(t>>1&1)*r*255,c=(t>>2&1)*r*255;return[a,o,c]};gy.ansi256.rgb=function(i){if(i>=232){let c=(i-232)*10+8;return[c,c,c]}i-=16;let t,r=Math.floor(i/36)/5*255,a=Math.floor((t=i%36)/6)/5*255,o=t%6/5*255;return[r,a,o]};gy.rgb.hex=function(i){let r=(((Math.round(i[0])&255)<<16)+((Math.round(i[1])&255)<<8)+(Math.round(i[2])&255)).toString(16).toUpperCase();return"000000".substring(r.length)+r};gy.hex.rgb=function(i){let t=i.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let r=t[0];t[0].length===3&&(r=r.split("").map(_=>_+_).join(""));let a=parseInt(r,16),o=a>>16&255,c=a>>8&255,f=a&255;return[o,c,f]};gy.rgb.hcg=function(i){let t=i[0]/255,r=i[1]/255,a=i[2]/255,o=Math.max(Math.max(t,r),a),c=Math.min(Math.min(t,r),a),f=o-c,_,v;return f<1?_=c/(1-f):_=0,f<=0?v=0:o===t?v=(r-a)/f%6:o===r?v=2+(a-t)/f:v=4+(t-r)/f,v/=6,v%=1,[v*360,f*100,_*100]};gy.hsl.hcg=function(i){let t=i[1]/100,r=i[2]/100,a=r<.5?2*t*r:2*t*(1-r),o=0;return a<1&&(o=(r-.5*a)/(1-a)),[i[0],a*100,o*100]};gy.hsv.hcg=function(i){let t=i[1]/100,r=i[2]/100,a=t*r,o=0;return a<1&&(o=(r-a)/(1-a)),[i[0],a*100,o*100]};gy.hcg.rgb=function(i){let t=i[0]/360,r=i[1]/100,a=i[2]/100;if(r===0)return[a*255,a*255,a*255];let o=[0,0,0],c=t%1*6,f=c%1,_=1-f,v=0;switch(Math.floor(c)){case 0:o[0]=1,o[1]=f,o[2]=0;break;case 1:o[0]=_,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=f;break;case 3:o[0]=0,o[1]=_,o[2]=1;break;case 4:o[0]=f,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=_}return v=(1-r)*a,[(r*o[0]+v)*255,(r*o[1]+v)*255,(r*o[2]+v)*255]};gy.hcg.hsv=function(i){let t=i[1]/100,r=i[2]/100,a=t+r*(1-t),o=0;return a>0&&(o=t/a),[i[0],o*100,a*100]};gy.hcg.hsl=function(i){let t=i[1]/100,a=i[2]/100*(1-t)+.5*t,o=0;return a>0&&a<.5?o=t/(2*a):a>=.5&&a<1&&(o=t/(2*(1-a))),[i[0],o*100,a*100]};gy.hcg.hwb=function(i){let t=i[1]/100,r=i[2]/100,a=t+r*(1-t);return[i[0],(a-t)*100,(1-a)*100]};gy.hwb.hcg=function(i){let t=i[1]/100,a=1-i[2]/100,o=a-t,c=0;return o<1&&(c=(a-o)/(1-o)),[i[0],o*100,c*100]};gy.apple.rgb=function(i){return[i[0]/65535*255,i[1]/65535*255,i[2]/65535*255]};gy.rgb.apple=function(i){return[i[0]/255*65535,i[1]/255*65535,i[2]/255*65535]};gy.gray.rgb=function(i){return[i[0]/100*255,i[0]/100*255,i[0]/100*255]};gy.gray.hsl=function(i){return[0,0,i[0]]};gy.gray.hsv=gy.gray.hsl;gy.gray.hwb=function(i){return[0,100,i[0]]};gy.gray.cmyk=function(i){return[0,0,0,i[0]]};gy.gray.lab=function(i){return[i[0],0,0]};gy.gray.hex=function(i){let t=Math.round(i[0]/100*255)&255,a=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(a.length)+a};gy.rgb.gray=function(i){return[(i[0]+i[1]+i[2])/3/255*100]}});var RJn=gr((tPs,BJn)=>{var Azt=RVr();function wCa(){let i={},t=Object.keys(Azt);for(let r=t.length,a=0;a<r;a++)i[t[a]]={distance:-1,parent:null};return i}e(wCa,"buildGraph");function SCa(i){let t=wCa(),r=[i];for(t[i].distance=0;r.length;){let a=r.pop(),o=Object.keys(Azt[a]);for(let c=o.length,f=0;f<c;f++){let _=o[f],v=t[_];v.distance===-1&&(v.distance=t[a].distance+1,v.parent=a,r.unshift(_))}}return t}e(SCa,"deriveBFS");function DCa(i,t){return function(r){return t(i(r))}}e(DCa,"link");function TCa(i,t){let r=[t[i].parent,i],a=Azt[t[i].parent][i],o=t[i].parent;for(;t[o].parent;)r.unshift(t[o].parent),a=DCa(Azt[t[o].parent][o],a),o=t[o].parent;return a.conversion=r,a}e(TCa,"wrapConversion");BJn.exports=function(i){let t=SCa(i),r={},a=Object.keys(t);for(let o=a.length,c=0;c<o;c++){let f=a[c];t[f].parent!==null&&(r[f]=TCa(f,t))}return r}});var MJn=gr((nPs,LJn)=>{var LVr=RVr(),kCa=RJn(),hWe={},ICa=Object.keys(LVr);function PCa(i){let t=e(function(...r){let a=r[0];return a==null?a:(a.length>1&&(r=a),i(r))},"wrappedFn");return"conversion"in i&&(t.conversion=i.conversion),t}e(PCa,"wrapRaw");function FCa(i){let t=e(function(...r){let a=r[0];if(a==null)return a;a.length>1&&(r=a);let o=i(r);if(typeof o=="object")for(let c=o.length,f=0;f<c;f++)o[f]=Math.round(o[f]);return o},"wrappedFn");return"conversion"in i&&(t.conversion=i.conversion),t}e(FCa,"wrapRounded");ICa.forEach(i=>{hWe[i]={},Object.defineProperty(hWe[i],"channels",{value:LVr[i].channels}),Object.defineProperty(hWe[i],"labels",{value:LVr[i].labels});let t=kCa(i);Object.keys(t).forEach(a=>{let o=t[a];hWe[i][a]=FCa(o),hWe[i][a].raw=PCa(o)})});LJn.exports=hWe});var VJn=gr((aPs,$Jn)=>{"use strict";var jJn=e((i,t)=>(...r)=>`\x1B[${i(...r)+t}m`,"wrapAnsi16"),UJn=e((i,t)=>(...r)=>{let a=i(...r);return`\x1B[${38+t};5;${a}m`},"wrapAnsi256"),qJn=e((i,t)=>(...r)=>{let a=i(...r);return`\x1B[${38+t};2;${a[0]};${a[1]};${a[2]}m`},"wrapAnsi16m"),Ezt=e(i=>i,"ansi2ansi"),QJn=e((i,t,r)=>[i,t,r],"rgb2rgb"),gWe=e((i,t,r)=>{Object.defineProperty(i,t,{get:e(()=>{let a=r();return Object.defineProperty(i,t,{value:a,enumerable:!0,configurable:!0}),a},"get"),enumerable:!0,configurable:!0})},"setLazyProperty"),MVr,yWe=e((i,t,r,a)=>{MVr===void 0&&(MVr=MJn());let o=a?10:0,c={};for(let[f,_]of Object.entries(MVr)){let v=f==="ansi16"?"ansi":f;f===t?c[v]=i(r,o):typeof _=="object"&&(c[v]=i(_[t],o))}return c},"makeDynamicStyles");function NCa(){let i=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,a]of Object.entries(t)){for(let[o,c]of Object.entries(a))t[o]={open:`\x1B[${c[0]}m`,close:`\x1B[${c[1]}m`},a[o]=t[o],i.set(c[0],c[1]);Object.defineProperty(t,r,{value:a,enumerable:!1})}return Object.defineProperty(t,"codes",{value:i,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",gWe(t.color,"ansi",()=>yWe(jJn,"ansi16",Ezt,!1)),gWe(t.color,"ansi256",()=>yWe(UJn,"ansi256",Ezt,!1)),gWe(t.color,"ansi16m",()=>yWe(qJn,"rgb",QJn,!1)),gWe(t.bgColor,"ansi",()=>yWe(jJn,"ansi16",Ezt,!0)),gWe(t.bgColor,"ansi256",()=>yWe(UJn,"ansi256",Ezt,!0)),gWe(t.bgColor,"ansi16m",()=>yWe(qJn,"rgb",QJn,!0)),t}e(NCa,"assembleStyles");Object.defineProperty($Jn,"exports",{enumerable:!0,get:NCa})});var WJn=gr((oPs,JJn)=>{"use strict";var V_t=IJn(),OCa=xzt(),BCa=VJn(),UVr=new Set(["\x1B","\x9B"]),RCa=39,zJn=e(i=>`${UVr.values().next().value}[${i}m`,"wrapAnsi"),LCa=e(i=>i.split(" ").map(t=>V_t(t)),"wordLengths"),jVr=e((i,t,r)=>{let a=[...t],o=!1,c=V_t(OCa(i[i.length-1]));for(let[f,_]of a.entries()){let v=V_t(_);if(c+v<=r?i[i.length-1]+=_:(i.push(_),c=0),UVr.has(_))o=!0;else if(o&&_==="m"){o=!1;continue}o||(c+=v,c===r&&f<a.length-1&&(i.push(""),c=0))}!c&&i[i.length-1].length>0&&i.length>1&&(i[i.length-2]+=i.pop())},"wrapWord"),MCa=e(i=>{let t=i.split(" "),r=t.length;for(;r>0&&!(V_t(t[r-1])>0);)r--;return r===t.length?i:t.slice(0,r).join(" ")+t.slice(r).join("")},"stringVisibleTrimSpacesRight"),jCa=e((i,t,r={})=>{if(r.trim!==!1&&i.trim()==="")return"";let a="",o="",c,f=LCa(i),_=[""];for(let[v,C]of i.split(" ").entries()){r.trim!==!1&&(_[_.length-1]=_[_.length-1].trimLeft());let w=V_t(_[_.length-1]);if(v!==0&&(w>=t&&(r.wordWrap===!1||r.trim===!1)&&(_.push(""),w=0),(w>0||r.trim===!1)&&(_[_.length-1]+=" ",w++)),r.hard&&f[v]>t){let T=t-w,k=1+Math.floor((f[v]-T-1)/t);Math.floor((f[v]-1)/t)<k&&_.push(""),jVr(_,C,t);continue}if(w+f[v]>t&&w>0&&f[v]>0){if(r.wordWrap===!1&&w<t){jVr(_,C,t);continue}_.push("")}if(w+f[v]>t&&r.wordWrap===!1){jVr(_,C,t);continue}_[_.length-1]+=C}r.trim!==!1&&(_=_.map(MCa)),a=_.join(`
|
|
627
627
|
`);for(let[v,C]of[...a].entries()){if(o+=C,UVr.has(C)){let T=parseFloat(/\d[^m]*/.exec(a.slice(v,v+4)));c=T===RCa?null:T}let w=BCa.codes.get(Number(c));c&&w&&(a[v+1]===`
|
|
628
628
|
`?o+=zJn(w):C===`
|
|
@@ -2035,7 +2035,7 @@ Supported model providers are: ${f}`)}}}catch(f){if("code"in f&&f.code.includes(
|
|
|
2035
2035
|
at ${f.url}:${f.lineNumber}:${f.columnNumber}`),a.write(C+`
|
|
2036
2036
|
`)}async run(r){await this.init(r),this.buildServices(r),this.buildServer(),await this.loadIfNecessary(),await this.start()}async loadIfNecessary(){let r=await this.getInitialServicesData();r&&(this.actionsManager.setActions(r.actions),this.testAssetsManager.setCurrentSaveAsLocation(this.editLocationPath),this.storyId=r.storyId,r.testGenerationData&&this.userStoryService.setTestGenerationData(r.testGenerationData))}async init(r){tf.info(`Initializing VTG with runtime version ${this.checksumRuntimeVersion}...`),await this.patchPlaywright(),this.loadPlaywrightConfigForVTG(),this.webDriver=this.buildWebDriver(r),this.webDriver.registerEventListener(this),this.taskTimeMachine=new abe(this.webDriver.frameMsgBroker,this.webDriver.injectedScriptManager,{headless:!V0.vtg.taskTimeMachine.showTaskTimeMachine,timestampBatchingEnabled:!1,sortByTimestamp:!0,taskTimeout:V0.vtg.taskTimeMachine.taskTimeout,debugPort:V0.vtg.isSeparateProcess?V0.vtg.taskTimeMachine.debugPort:void 0,frameMsgBrokerRegisterName:"task-time-machine",logPerformance:V0.vtg.taskTimeMachine.logPerformance,webProxy:this.getPlaywrightProxySettings()}),this.pageInteractor=new r4e(this.webDriver.evaluateWithChecksum.bind(this.webDriver),()=>this.webDriver.appMainFrame,this.webDriver.getTimeMachine.bind(this.webDriver),{log:e((a,...o)=>o!=null&&o.length?tf.info(a,...o):tf.info(a),"log"),logError:e((a,...o)=>o!=null&&o.length?tf.error(a,...o):tf.error(a),"logError")},{...this.getTimeoutParams(),waitActionDelay:1e3,testAssetsDir:__dirname,listenToDialog:!0,listenToFileChooser:!1},new Z$e(this.checksumConfig)),this.testAssetsManager=new YHt(this.projectRootDirectory,this.checksumRoot,this.vtgInternalFilesDir,this.vtgTestFileRunConfig)}buildServices(r){this.actionsManager=new EWt,this.settingsService=new Y1t(this.checksumRoot,this.apiService,this.vtgInternalFilesDir),this.apiService=new Q_t(this.checksumConfig),this.settingsService=new Y1t(this.checksumRoot,this.apiService),this.userStoryService=new U_t(this.apiService,this.checksumConfig),this.variableStoreService=new iGt,this.evaluatorService=new sGt(this.variableStoreService,this.settingsService,this.vtgTestFileMode,r,this.port),this.actionsService=new tJt(this.checksumConfig,this.checksumRoot,this.pageInteractor,this.apiService,this.userStoryService,this.actionsManager,this.testAssetsManager,this.webDriver,this.evaluatorService,this.vtgInternalFilesDir),this.assertionsService=new lJt(this.webDriver,this.actionsManager,this.evaluatorService),this.locatorsService=new bJt(this.webDriver,this.taskTimeMachine,this.apiService,this.userStoryService,this.evaluatorService),this.aiTestGenerationService=new nJt(this.webDriver,this.pageInteractor,this.actionsService,this.actionsManager,this.apiService,this.userStoryService),this.aiAssertionsService=new cJt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver,this.evaluatorService,{logPerformance:V0.vtg.aiAssertions.logPerformance}),this.aiThoughtsService=new nGt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver),this.storageService=new AWt(this.checksumConfig,this.userStoryService,this.apiService,this.actionsManager,this.testAssetsManager,this.actionsService,this.vtgTestFileRunConfig,this.evaluatorService,this.settingsService,this.taskTimeMachine),this.actionsManager.setStorageService(this.storageService),this.monacoService=new uGt,this.aiChatService=new Ztr(this.taskTimeMachine,this.evaluatorService)}buildServer(){this.reactAppServer=new GHt(this.actionsService,this.assertionsService,this.locatorsService,this.aiTestGenerationService,this.aiAssertionsService,this.aiThoughtsService,this.actionsManager,this.storageService,this.settingsService,this.monacoService,this.evaluatorService,this.aiChatService)}loadPlaywrightConfigForVTG(){try{let r=`${this.checksumRoot}/playwright.config.ts`;if((0,k3e.existsSync)(r)){let a=require(r).default;a&&(this.playwrightConfigForVTG=a)}}catch{tf.warning("Could not find playwright config file, will run with defaults")}}async getInitialServicesData(){switch(this.vtgMode){case"cloud":return this.getInitialServicesDataFromCloud();case"edit":return this.vtgTestFileMode?await this.getInitialServicesDataForEditedFile():this.getInitialServicesDataFromJSON("local");case"start":if(this.vtgTestFileRunConfig.restoreFromAutoSave)return this.getInitialServicesDataFromJSON("auto-save")}}getInitialServicesDataFromJSON(r){let a=this.storageService.getLocalSavedJSONFilePath(r,this.storyId),o=this.storageService.readLocalSavedDataFromJSONFile(a);if(!o)throw new Error(`No data found in ${r} while reading from ${a}`);return{actions:o.executedActions,storyId:o.story.id}}async getInitialServicesDataFromCloud(){let a=await(await this.apiService.post(`test-generation/${this.cloudTestGenerationId}/info`)).json(),{actionsDownloadSignedURL:o}=a,c=await fetch(o,{mode:"cors",credentials:"same-origin",headers:{"Content-Type":"application/json"}});if(!c.ok)throw new Error(`HTTP error! Status: ${c.status}`);let f=await c.json();return{actions:this.initializeTestStepsWithIds(f),storyId:a.story.id}}initializeTestStepsWithIds(r){return r.map((a,o)=>({...a,id:(0,ahn.randomUUID)(),assertions:(a.assertions??[]).map(c=>({...c,id:(0,ahn.randomUUID)()}))}))}async getInitialServicesDataForEditedFile(){var a,o,c,f,_,v,C;if(((a=this.vtgTestFileRunConfig)==null?void 0:a.mode)!=="edit")return;let r=[];if(!this.vtgTestFileRunConfig.restoreFromAutoSave){let w=(o=this.vtgTestFileRunConfig)==null?void 0:o.actionsJsonFilePath;r=this.storageService.readJsonFile(w),(0,k3e.rmSync)(w,{force:!0}),r=this.initializeTestStepsWithIds(r)}if((c=this.vtgTestFileRunConfig)!=null&&c.internalTestId)try{let w=await this.apiService.post(`test-generation-by-internal-test-id/${(f=this.vtgTestFileRunConfig)==null?void 0:f.internalTestId}/info`);if(!w.ok){let k=w.statusText;try{let R=await w.text();try{k=JSON.parse(R).message||R||w.statusText}catch{k=R||w.statusText}}catch{k="Test id not found or invalid"}throw new Error(`Error fetching test generation data: ${k}`)}let T=await w.json();if(this.vtgTestFileRunConfig.restoreFromAutoSave){let k=this.storageService.getLocalSavedJSONFilePath("auto-save"),R=this.storageService.readLocalSavedDataFromJSONFile(k);if(!R)throw new Error(`No data found in auto-save while reading from ${k}`);r=R==null?void 0:R.executedActions}return{actions:r,storyId:T.story.id,testGenerationData:T.testGenerationData}}catch{tf.warning(`Could not find data matching internal test id: ${(_=this.vtgTestFileRunConfig)==null?void 0:_.internalTestId}`)}if((v=this.vtgTestFileRunConfig)!=null&&v.storyId)return{actions:r,storyId:(C=this.vtgTestFileRunConfig)==null?void 0:C.storyId};throw new Error("Cannot edit file without either valid internal test id or story id")}async start({createAssetsFolder:r=!0}={}){var o,c;await this.userStoryService.fetchStory(this.storyId),r&&this.testAssetsManager.createTestAssetsFolders(),this.testAssetsManager.createTestGenerationLocalAutoSaveFolder(),await this.reactAppServer.start();let{environment:a}=this.userStoryService.getEnvInfo();await this.webDriver.prepare({baseURL:a.baseURL,shutdown:!this.vtgTestFileMode},{serverPort:await this.reactAppServer.getPort()}),V0.vtg.writeLogFile&&this.setupFrontendLogging(this.webDriver.page),await this.webDriver.page.evaluate(()=>{"checksumRRWeb"in window&&console.log(`Using forked rrweb. ${JSON.stringify(window.checksumRRWeb)}`)}),await this.webDriver.addHARMockAPIRecordings(this.testAssetsManager.getHarFilePath()),await this.initTimeMachine(),this.pageInteractor.init(),this.assertionsService.setPage(this.webDriver.appMainFrame.page()),this.actionsService.setPage(this.webDriver.appMainFrame.page()),this.evaluatorService.setPage(this.webDriver.appMainFrame.page()),this.aiChatService.setPage(this.webDriver.appMainFrame.page()),await this.taskTimeMachine.prepare(this.webDriver.appMainFrame,void 0,f=>this.webDriver.registerTimeMachineFrame(f)),await this.reactAppServer.evaluateServerPort(this.webDriver.page),await this.webDriver.appMainFrame.goto("about:blank",{waitUntil:"domcontentloaded",timeout:0}),await this.webDriver.getTimeMachine().toggleTimeMachineHandleEvents(!1),this.vtgMode==="start"&&!this.vtgTestFileRunConfig.restoreFromAutoSave&&(await this.actionsService.addInitialLoginAction(),await this.actionsService.addStartURLNavigationAction(),this.vtgTestFileMode&&await this.storageService.saveTestFile()),tf.info("VTG is ready with story:",{goal:(o=this.userStoryService.getStory())==null?void 0:o.goal}),await this.webDriver.page.evaluate(({localSaveFolderPath:f,stepsData:_,appViewport:v,userStoryGoal:C,isLoadedFromFile:w})=>{window.vtg.initClient(f,_,v,this.checksumRuntimeVersion,C,w)},{localSaveFolderPath:this.editLocationPath,stepsData:await this.actionsManager.buildStepDataWithCode(this.actionsManager.actions,{loadingFromFile:["edit","cloud"].includes(this.vtgMode)}),appViewport:this.webDriver.getApplicationViewport(),userStoryGoal:(c=this.userStoryService.getStory())==null?void 0:c.goal,isLoadedFromFile:this.vtgTestFileMode}),this.vtgTestFileMode||await new Promise(()=>{})}getTimeoutParams(){var o,c,f,_;let r=((c=(o=this.playwrightConfigForVTG)==null?void 0:o.use)==null?void 0:c.navigationTimeout)||3e4,a=((_=(f=this.playwrightConfigForVTG)==null?void 0:f.use)==null?void 0:_.actionTimeout)||5e3;return{navigationTimeout:r,actionTimeout:a}}getPlaywrightProxySettings(){var f,_;let r=(_=(f=this.playwrightConfigForVTG)==null?void 0:f.use)==null?void 0:_.proxy,{server:a,username:o,password:c}=r||{};if(o&&c&&a)return{username:o,password:c,server:a}}getPlaywrightViewportSettings(){var o,c;let{width:r=1280,height:a=720}=((c=(o=this.playwrightConfigForVTG)==null?void 0:o.use)==null?void 0:c.viewport)||{};return{width:r,height:a}}buildWebDriver(r){var c,f,_,v,C,w;let a=this.getPlaywrightProxySettings(),o=this.getPlaywrightViewportSettings();return new eGt({scriptSource:V0.checksumScript.source,scriptURL:V0.checksumScript.url,scriptFile:V0.checksumScript.path,isScriptFileAbsolute:!0,fullScreenResolution:!1,hostWindowViewport:!0,baseURL:(c=this.checksumConfig.environments.find(T=>T.default))==null?void 0:c.baseURL,useProxy:!!a,webProxy:a,disableWebSecurity:!0,allowFileAccess:!0,remoteDebugging:V0.vtg.remoteDebugging,remoteDebuggingPort:V0.vtg.vtgRemoteDebuggingPort},{devtools:!1,headless:V0.CI},{frontendAppSpecificRules:{},frontendTestGenerationConfig:{logPrefix:"$checksum"},viewport:o,completeOriginHeaderOnLivePage:!V0.vtg.isSeparateProcess&&!((v=(_=(f=this.checksumConfig.options)==null?void 0:f.modelConfig)==null?void 0:_.browserArgs)!=null&&v.skipDisableWebSecurity)&&!((w=(C=this.checksumConfig.options)==null?void 0:C.modelConfig)!=null&&w.skipCompleteOriginHeaderOnDisableWebSecurity)},r)}async onWebDriverContextClose(){var r,a,o;this.evaluatorService.stopListening(),(r=this.vtgTestFileRunConfig)!=null&&r.evalFilePath&&(0,k3e.rmSync)((a=this.vtgTestFileRunConfig)==null?void 0:a.evalFilePath,{force:!0}),this.vtgTestFileRunConfig.mode==="edit"&&(0,k3e.rmSync)((o=this.vtgTestFileRunConfig)==null?void 0:o.actionsJsonFilePath,{force:!0})}initializeAccordingToVTGMode(r){var c;let a=r.indexOf("--edit"),o=r.indexOf("--cloud");if(r.indexOf("--test-file")!==-1){this.vtgTestFileMode=!0,this.vtgTestFileRunConfig=JSON.parse(process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG),this.vtgMode=this.vtgTestFileRunConfig.mode,this.storyId=((c=this.vtgTestFileRunConfig)==null?void 0:c.mode)==="start"?this.vtgTestFileRunConfig.storyId:void 0;return}a!==-1&&(this.vtgMode="edit",this.editLocationPath=r[a+1]),o!==-1&&(this.vtgMode="cloud",this.cloudTestGenerationId=r[o+1]),this.vtgMode==="start"&&(this.storyId=r[0])}getWebDriver(){return this.webDriver}async eval(r){return this.evaluatorService.listenForExecution(r)}};e(shn,"VisualTestGenerator");var err=shn;xVr();bve();var DAi=require("child_process"),uhn=require("net");yT();var TAi=require("path");v7();var SAi=nf(lht());fQ();var ohn=e(async(i,t,r,a,o={})=>{let{preventDialogFromAutoDismissing:c=!1,retry:f=!0,maxRetries:_=void 0,numberOfRetries:v=0}=o;try{console.log(`${i} attempting to connect to ${t} on port ${r}...`);let w=(await SAi.chromium.connectOverCDP("http://127.0.0.1:"+r)).contexts()[0],T=a(w.pages());for(;!T;)await TA(1e3),T=a(w.pages());return console.log(`${i} is connected to ${t} on port ${r}`,T.url()),c&&uzt(T),T}catch(C){if(!f||_&&v>=_)throw console.error(`${i} failed to connect to ${t}, retries were exhausted or disabled`,C),C;return console.log(`${i} is waiting and retrying connection to ${t} on port ${r}...`),await TA(1e3),ohn(i,t,r,a,{...o,numberOfRetries:v+1})}},"connectToPage");qw();var chn=class chn{constructor(t){this.checksumConfig=t;this.isReady=!1;this.onMessage=e(async(t,r)=>{let{id:a,err:o,result:c}=await this.execute(t);r.write(this.messageParser.makeMessage(JSON.stringify({id:a,err:this.serializedErr(o),result:c})))},"onMessage");this.messageParser=new kGe(this.onMessage),this.isReadyPromise=new Promise(r=>{this.isReadyResolve=r}),this.routeInterceptor=new BWe({completeOriginHeader:!0})}async eval(t){return this.listenForExecution(t)}async run(t){this.liveAppPage=t,await this.applyRouteInterceptorsIfNecessary(),await this.createServer(),this.startRunner()}async applyRouteInterceptorsIfNecessary(){var r,a,o,c,f,_;if(!((o=(a=(r=this.checksumConfig.options)==null?void 0:r.modelConfig)==null?void 0:a.browserArgs)!=null&&o.skipDisableWebSecurity)&&!((f=(c=this.checksumConfig.options)==null?void 0:c.modelConfig)!=null&&f.skipCompleteOriginHeaderOnDisableWebSecurity))try{await((_=this.liveAppPage)==null?void 0:_.route("**/*",async(v,C)=>this.routeInterceptor.intercept(v,C,{page:this.liveAppPage},{completeOriginHeader:!0})))}catch(v){tf.error("[WebDriver] applyRouteInterceptors error",v)}}startRunner(){let t=V0.isRepoMode?"yarn vtg-pw-bridge":`ts-node ${(0,TAi.join)(__dirname,"vtg-pw-bridge-runner.js")}`;les(t,{CHECKSUM_PORT:this.port.toString(),CHECKSUM_CONFIG:JSON.stringify(this.checksumConfig)})}async createServer(){this.server=(0,uhn.createServer)(t=>{t.on("data",async r=>{try{await this.messageParser.onMessage(t,r)}catch(a){t.write(JSON.stringify({err:a.message}))}}),t.on("end",()=>{}),t.on("error",r=>{}),this.connectToVTG()}),this.port=await this.acquirePortNumber(),this.server.listen(this.port,()=>tf.info(`VTG PW Bridge Server listening on port ${this.port}...`))}serializedErr(t){return t&&JSON.stringify(t,Object.getOwnPropertyNames(t))}async connectToVTG(){tf.info("[VTG PW Bridge] Connecting to VTG...");let t=e(r=>r.frames().find(a=>a.name()==="time-machine-iframe"),"findTimeMachineIframe");this.vtgPage=await this.connectToPage("VTG page",V0.vtg.vtgRemoteDebuggingPort,r=>r.find(a=>t(a))),this.vtgTimeMachineFrame=t(this.vtgPage),this.taskTimeMachinePage=await this.connectToPage("Task Time Machine page",V0.vtg.taskTimeMachine.debugPort,r=>r[0]),tf.info("[VTG PW Bridge] Connected to VTG."),this.isReady=!0,this.isReadyResolve()}async connectToPage(t,r,a){return ohn("Playwright via Bridge",t,r,a,{preventDialogFromAutoDismissing:!0})}async acquirePortNumber(){return await new Promise((t,r)=>{let a=(0,uhn.createServer)();a.unref(),a.on("error",r),a.listen(0,()=>{let o=a.address().port;a.close(()=>{t(o)})})})}async listenForExecution(t){return new Promise(r=>{this.resolveEvaluator=r,this.listener=t})}stopListening(){var t;(t=this.resolveEvaluator)==null||t.call(this)}buildContext(t){let{frame:r,expectConfig:a}=t,o={};switch(r){case"task-time-machine":o.page=this.taskTimeMachinePage.frameLocator("iframe");break;case"vtg-time-machine":o.page=this.vtgTimeMachineFrame.frameLocator("iframe");break;case"live":default:break}return a&&(o.expect=qbe.expect.configure(a)),o}wrapCodeInContext(t,r){return`(async ({${Object.keys(r).join(", ")}}) => { ${t} })`}async execute(t){this.isReady||tf.warning("[VTG PW Bridge] Execute called before ready"),await this.isReadyPromise;let{id:r,code:a,options:o}=t,c=this.buildContext(o),f=this.wrapCodeInContext(a,c)+"(context)";return new Promise(_=>{this.listener&&this.listener(f,c,(v,C)=>{_({id:r,err:v,result:C})})})}};e(chn,"VtgPwBridge");var trr=chn;async function les(i,t={}){let r={...process.env,...t};(0,DAi.spawn)(i,{env:r,shell:!0,stdio:["inherit","inherit","inherit"],detached:!1}).on("exit",o=>{process.exit(o)})}e(les,"spawnCmd");var eEi=require("@playwright/test"),tEi=nf(ZAi());var lae=class lae{constructor(t){this.options=t;this.importPluginPackages()}importPluginPackages(){lae.pw??(lae.pw=lht()),lae.StealthPlugin??(lae.StealthPlugin=require("puppeteer-extra-plugin-stealth"))}static createFreshInstance(){try{let{addExtra:t}=lht(),r=t(lae.pw.chromium);return console.log("[StealthProvider] Created fresh playwright-extra instance for testing"),r}catch(t){throw console.error("[StealthProvider] Error creating fresh instance:",t),t}}buildChromiumWithPlugins(t){let{project:r}=this.options,a=r.use.userAgent,o=r.use.playwrightExtra||[],c=lae.StealthPlugin();if(o.push(c),this.isCustomUserAgent(a)){c.enabledEvasions.delete("user-agent-override");let v=require("puppeteer-extra-plugin-stealth/evasions/user-agent-override")({userAgent:a});o.push(v)}let f=t??lae.pw.chromium;return o.forEach((_,v)=>{try{!(_ instanceof tEi.PuppeteerExtraPlugin)&&_!==c&&console.warn(`Plugin at index ${v} in the project's checksum.config.ts file is not an instance of PuppeteerExtraPlugin.`),f.use(_)}catch(C){console.warn(C)}}),f}isCustomUserAgent(t){return t?!Object.values(eEi.devices).some(r=>t===r.userAgent):!1}};e(lae,"StealthProvider");var irr=lae;Pjt();function rEi(i,t){return{testSuiteRunId:t,appName:"generic-app",commitHash:"generic-commit-hash",envName:"generic-env-name",branch:"generic-branch",checksumRuntimeVersion:i}}e(rEi,"createDefaultTestSuiteRunInfo");var iEi=require("crypto");var mhn={},Qvt=!!process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG,aEi=e((i,t,r={},a=!1)=>{let{runMode:o,environments:c}=t,f=c.find(v=>v.default),_=i.extend({baseURL:f.baseURL,bypassCSP:!0,...Qvt?{trace:"off",video:"off",screenshot:"off",ignoreHTTPSErrors:!0}:{},permissions:e(async({},v,C)=>{if(!Qvt)await v(C.project.use.permissions);else{let w=new Set(C.project.use.permissions);w.add("clipboard-read"),w.add("clipboard-write"),w.add("camera"),w.add("storage-access"),w.add("notifications"),w.add("geolocation"),w.add("microphone"),await v(Array.from(w))}},"permissions"),proxy:e(async({proxy:v},C)=>{v?await C({...v,bypass:"127.0.0.1,localhost"}):await C(v)},"proxy"),browser:e(async({browser:v,browserName:C,launchOptions:w},T,k)=>{let R=e(()=>(k.project.use.playwrightExtra||[]).some(X=>X.constructor.name==="StealthPlugin"),"checkIfStealthPluginExists"),B=e(async()=>{let W=await(await new irr({project:k.project}).buildChromiumWithPlugins()).launch(w);await T(W)},"launchBrowserWithStealthPlugin");Qvt?V0.vtg.isSeparateProcess?await T(v):R()?(console.log("StealthPlugin already configured"),await T(v)):await B():V0.useRemoteDebugging.enabled&&R()?await B():await T(v)},"browser"),launchOptions:e(async({launchOptions:v},C)=>{var k;let w=v!=null&&v.args?[...v.args]:[],T=e(R=>{w.includes(R)||w.push(R)},"pushArg");if(r.useMockData&&T("--disable-web-security"),V0.bypassProxyForLocalhost&&T("--proxy-bypass-list=localhost,127.0.0.1"),Qvt){T("--proxy-bypass-list=localhost,127.0.0.1"),V0.vtg.isSeparateProcess&&T(`--remote-debugging-port=${V0.vtg.appRemoteDebuggingPort}`);let R=((k=r.modelConfig)==null?void 0:k.browserArgs)??{};R.skipDisableWebSecurity||T("--disable-web-security"),R.skipAllowFileAccessFromFiles||T("--allow-file-access-from-files"),R.skipDisableSiteIsolationTrials||T("--disable-site-isolation-trials"),R.skipAllowRunningInsecureContent||T("--allow-running-insecure-content")}V0.useRemoteDebugging.enabled&&T(`--remote-debugging-port=${V0.useRemoteDebugging.port}`),await C({...v,args:w})},"launchOptions"),variableStore:e(async({},v)=>{let C=new fWe;await v(C)},"variableStore"),vs:e(async({variableStore:v},C)=>{await C(v)},"vs"),variablesStore:e(async({variableStore:v},C)=>{await C(v)},"variablesStore"),testRunAnalytics:e(async({},v,C)=>{let w=(()=>{try{if(process.env.CHECKSUM_TEST_SUITE_INFO)return JSON.parse(process.env.CHECKSUM_TEST_SUITE_INFO);throw new Error("Missing Checksum test suite info")}catch{return console.warn("\u26A0\uFE0F Warning: It seems like you ran the test suite directly via Playwright. This can lead to degraded functionality and unexpected issues. To ensure a fully supported and stable test run, please use: 'npx checksumai test'."),rEi("playwright-run-version-unknown",(0,iEi.randomUUID)())}})(),T=nEi(C),k=rie.getTestRunInstance({...w,checksumTestId:T},process.env.CHECKSUM_ISOLATED_MODE==="true",C);await v(k)},"testRunAnalytics"),monitorBridge:[async({},v,C)=>{let w=new dzt(C);await v(w)},{scope:"worker"}],page:e(async({page:v,monitorBridge:C,variableStore:w,testRunAnalytics:T},k,R)=>{let B=await ozt.init(v,T,C,w,R,nEi(R),_,t,a);Object.defineProperty(B.constructor,"name",{value:"Page"}),await k(B),await B.onTestComplete(R.status==="passed"),await B.shutdown()},"page"),vtg:e(async({page:v},C)=>{if(!Qvt)C(null);else if(V0.vtg.isSeparateProcess){let w=new trr(t);await w.run(v),await C(w)}else{let w=new err(["--test-file"],!1,t);await w.run(v),await C(w)}},"vtg")});return{test:_,defineChecksumTest:Ses}},"createChecksumTestExtension"),Ses=e((i,t,r)=>{let o=new Error().stack.split(`
|
|
2037
2037
|
`).filter(c=>c.includes(".checksum.spec.ts"))[0];if(!o)throw new Error("Could not locate test location. Make sure test is run from valid checksum test file");return mhn[o]=t,i},"defineChecksumTest");function nEi(i){let{file:t,line:r}=i,a=Object.keys(mhn).filter(c=>c.trim().includes(t.trim()));if(!a.length)return;let o=4;for(let c=0;c<o;c++)for(let f of a){let _;try{_=parseInt(f.split(":").reverse()[1])}catch{continue}if(_-c===parseInt(r))return mhn[f]}}e(nEi,"getCurrentTestIdFromMapping");fQ();JH();jne();fQ();var Des=["toPass"],Tes=["toBeOK"],kes=["toBeAttached","toBeChecked","toBeDisabled","toBeEditable","toBeEmpty","toBeEnabled","toBeFocused","toBeHidden","toBeInViewport","toBeVisible","toContainClass","toContainText","toHaveAccessibleDescription","toHaveAccessibleErrorMessage","toHaveAccessibleName","toHaveAttribute","toHaveClass","toHaveCount","toHaveCSS","toHaveId","toHaveJSProperty","toHaveRole","toHaveScreenshot","toHaveText","toHaveValue","toHaveValues","toMatchAriaSnapshot"],Ies=["toHaveScreenshot","toHaveTitle","toHaveURL"],Pes=["toMatchSnapshot"],Fes=["toBe","toBeCloseTo","toBeDefined","toBeFalsy","toBeGreaterThan","toBeGreaterThanOrEqual","toBeInstanceOf","toBeLessThan","toBeLessThanOrEqual","toBeNaN","toBeNull","toBeTruthy","toBeUndefined","toContain","toContainEqual","toEqual","toHaveLength","toHaveProperty","toMatch","toMatchObject","toStrictEqual","toThrow","toThrowError"],sEi=[...Fes,...Pes],_Uo=[...Des,...Tes,...kes,...Ies];var _hn=class _hn{constructor(t,r,a=!1,o=!1,c={}){this.page=t;this.soft=a;this.skipAutoRecovery=o;this.configuration=c;this.fallbackEnabled=!1;this.withChecksumAI=!1;this.withChecksumAIMatcher=e(async()=>{throw this.withChecksumAI=!0,new Error},"withChecksumAIMatcher");this.setThought(r)}setThought(t){var r,a;t&&(this.checksumAIThought=this.page.addNewThought(t,"assertion"),this.useChecksumAIOptions=(r=this.page.getRuntimeOptions())==null?void 0:r.useChecksumAI,(a=this.useChecksumAIOptions)!=null&&a.assertions&&(this.page.setAIFallback(t,"assertion"),this.fallbackEnabled=!0))}get(t,r,a){if(typeof r!="string")return t[r];if(r==="checksumAI")return o=>(this.setThought(o),a);if(r==="withChecksumAI"||typeof t[r]=="function"){let o=r==="withChecksumAI"?this.withChecksumAIMatcher:t[r];return(...c)=>sEi.includes(r)?o.call(t,...c):this.checksumAIThought?this.executeMatcherWithinStep(o,t,...c):this.executeMatcher(o,t,...c)}else{let o=t[r];return new Proxy(o,this)}}findNestedErrors(t,r){t.error&&t.infectParentStepsWithError&&r.push(t.error);for(let a of t.steps)this.findNestedErrors(a,r)}async callMatcher(t,r,...a){this.beforeMatcherCall();let o=t.call(r,...a),c=o instanceof Promise?await o:o;if(this.step){let f=[];if(this.step.error?f.push(this.step.error):this.findNestedErrors(this.step,f),f.length)throw f[0]}return c}executeMatcherWithinStep(t,r,...a){return this.page.step(this.checksumAIThought.thought,()=>this.callMatcher(t,r,...a).catch(this.onMatcherFailure.bind(this)),!1,{obtainStep:e(o=>this.step=o,"obtainStep")}).catch(o=>{if(!this.soft&&!(this.withChecksumAI&&o.message===P4e))throw o}).finally(this.afterMatcherExecute.bind(this))}async executeMatcher(t,r,...a){try{return await this.callMatcher(t,r,...a)}catch(o){await this.onMatcherFailure(o)}finally{this.afterMatcherExecute()}}beforeMatcherCall(){this.page.setExpectConfiguration(this.configuration)}afterMatcherExecute(){this.checksumAIThought=void 0,this.fallbackEnabled=!1,this.withChecksumAI=!1,this.page.resetFallbacks(),this.page.setExpectConfiguration(void 0)}shouldInitiateFallback(t){var a;return!(!this.fallbackEnabled||((a=t.matcherResult)==null?void 0:a.name)==="toHaveScreenshot"&&!this.useChecksumAIOptions.visualComparison)}async onMatcherFailure(t){var r,a;if(!this.shouldInitiateFallback(t))throw Dv("[onMatcherFailure] fallback disabled, continuing with error."),this.page.testRunAnalytics.testRunAssertionExecutionFailure({failedThought:(r=this.checksumAIThought)==null?void 0:r.thought,error:t.message,matcher:(a=t.matcherResult)==null?void 0:a.name}),t;if(Dv("[onMatcherFailure] initiating fallback sequence with thought:",this.checksumAIThought.thought),this.skipAutoRecovery){if(this.soft)return;throw t}try{await this.page.initiateFallbackSequence({type:"assertion",error:t,withChecksumAI:this.withChecksumAI,testInfo:this.page.testInfo})}catch(o){if(this.soft)return;throw o}throw this.soft=!0,t}};e(_hn,"ExpectCallProxyHandler");var arr=_hn;var $vt=class $vt{constructor(t=void 0,r={}){this.page=t;this.configuration=r}get(t,r){return r==="setPage"?a=>{this.page=a}:r==="extend"?(...a)=>{let o=t.extend(...a);return new Proxy(o,this)}:r==="configure"?a=>{let o=t.configure(a);return new Proxy(o,new $vt(this.page,{...this.configuration,...a}))}:r==="soft"?(...a)=>{let o=this.manipulateArgsAndExtractThought(a),c=t.soft(...a);return new Proxy(c,this.makeExpectCallProxyHandler(o,!0))}:r==="poll"?(...a)=>{let o=this.manipulateArgsAndExtractThought(a),c=t.poll(...a);return new Proxy(c,this.makeExpectCallProxyHandler(o))}:r==="skipAutoRecovery"?new Proxy(()=>{},{apply:e((o,c,f)=>{let _=this.manipulateArgsAndExtractThought(f),v=t.apply(c,f);return new Proxy(v,this.makeExpectCallProxyHandler(_,void 0,!0))},"apply"),get:e((o,c)=>new Proxy(t,new $vt(this.page,{...this.configuration,skipAutoRecovery:!0}))[c],"get")}):t[r]instanceof Function?t[r].bind(t):t[r]}apply(t,r,a){let o=this.manipulateArgsAndExtractThought(a),c=t.apply(r,a);return new Proxy(c,this.makeExpectCallProxyHandler(o))}makeExpectCallProxyHandler(t,r,a){var o,c;return new arr(this.page,t,r===!0?!0:(o=this.configuration)==null?void 0:o.soft,a===!0?!0:(c=this.configuration)==null?void 0:c.skipAutoRecovery,this.configuration)}manipulateArgsAndExtractThought(t){let r,a=t[1];if(typeof a=="string")r=a,t[1]=void 0;else if(typeof a=="object"){if(a.checksumAI===!1){t[1].checksumAI=void 0;return}a.checksumAI&&typeof a.checksumAI=="string"?(r=a.checksumAI,t[1].checksumAI=void 0):a.message&&(r=a.message,t[1].message=void 0)}return r}};e($vt,"ExpectProxyHandler");var srr=$vt;var urr=class urr{constructor(t){this.expect=t;this.proxy=new Proxy(this.expect,new srr)}static init(t){return new urr(t).proxy}};e(urr,"ChecksumExpect");var orr=urr;v7();var cEi=require("@playwright/test");fQ();var oEi=nf(vT()),crr=require("fs");var Vvt=nf(require("path"));var Nes=e(i=>{let t=z7e(i),r=new J7e(t),a=Wht();return r.transformSourceFile([new ZFe(i),new YHe(i,a,{newRequireIdentifier:"checksumHotRequire",extraImportArguments:[oEi.factory.createIdentifier("__filename")]})]),`${Dti}
|
|
2038
|
-
${r.getTestFileCode().code}`},"transformFileToHoRequireFormat"),Oes=e(i=>{let t=Vvt.default.dirname(i),a=Vvt.default.basename(i).split(".")[0],o=Math.random().toString(36).substring(2,15),c=Vvt.default.extname(i);return Vvt.default.join(t,`${a}-${Date.now()}-${o}${c}`)},"generateTempFilePath"),Bes=e((i,t)=>{let r=Wht();return new W7e(t,r).getResolvedPath(i)},"resolveFilePath"),Res=e((i,t=__filename)=>{let r;try{let a=require.resolve(Bes(i,t)),o=Nes(a);r=Oes(a),(0,crr.writeFileSync)(r,o);let c=require(r);return require.cache[a]=require.cache[r],c}catch(a){throw console.error("Error in require",a),a}finally{r&&(0,crr.unlinkSync)(r)}},"checksumHotRequire"),uEi=Res;bve();function Les(i){let t=Zqt(),{options:r,apiKey:a,environments:o}=t,c=o.find(R=>R.default);if(!c)throw new Error("No default environment found. Please set the default field to true on one of the environments in the checksum.config.ts file.");if(!c.baseURL)throw new Error("A baseURL is required. Please set the baseURL field in the default environment in the checksum.config.ts file.");if(!c.users.find(R=>R.default))throw new Error("A default user within the default environment is required. Please set one of the default environment users as default in the checksum.config.ts file.");if(!a)throw new Error("An API key is required. Please set the apiKey field in the checksum.config.ts file.");let _=process.env.CHECKSUM_REPL==="true",{test:v,defineChecksumTest:C}=aEi(i??cEi.test,t,r,_),w=orr.init(v.expect),T=Mes();v._checksum={expect:w,checksumAI:T},_&&(console.log("Detected REPL mode"),v.beforeEach(async()=>{v.setTimeout(0)}),v.afterEach(async()=>{for(;;)await TA(1e3)}));let k=e(({name:R,userRole:B})=>{let{environment:U,user:W}=q_t(t,{environment:R,role:B},!0),X=oJn({config:t,throwIfEnvInfoInvalid:!0},{environmentName:U.name,userRole:W.role});return{environment:U,user:W,login:X}},"getEnvironment");return{test:v,expect:w,login:Bbe({config:t}),defineChecksumTest:C,getEnvironment:k,checksumAI:T}}e(Les,"init");var hhn=e(i=>new Proxy(i,{apply:e(function(r,a,o){return r.page.checksumAI(o[0],o[1],
|
|
2038
|
+
${r.getTestFileCode().code}`},"transformFileToHoRequireFormat"),Oes=e(i=>{let t=Vvt.default.dirname(i),a=Vvt.default.basename(i).split(".")[0],o=Math.random().toString(36).substring(2,15),c=Vvt.default.extname(i);return Vvt.default.join(t,`${a}-${Date.now()}-${o}${c}`)},"generateTempFilePath"),Bes=e((i,t)=>{let r=Wht();return new W7e(t,r).getResolvedPath(i)},"resolveFilePath"),Res=e((i,t=__filename)=>{let r;try{let a=require.resolve(Bes(i,t)),o=Nes(a);r=Oes(a),(0,crr.writeFileSync)(r,o);let c=require(r);return require.cache[a]=require.cache[r],c}catch(a){throw console.error("Error in require",a),a}finally{r&&(0,crr.unlinkSync)(r)}},"checksumHotRequire"),uEi=Res;bve();function Les(i){let t=Zqt(),{options:r,apiKey:a,environments:o}=t,c=o.find(R=>R.default);if(!c)throw new Error("No default environment found. Please set the default field to true on one of the environments in the checksum.config.ts file.");if(!c.baseURL)throw new Error("A baseURL is required. Please set the baseURL field in the default environment in the checksum.config.ts file.");if(!c.users.find(R=>R.default))throw new Error("A default user within the default environment is required. Please set one of the default environment users as default in the checksum.config.ts file.");if(!a)throw new Error("An API key is required. Please set the apiKey field in the checksum.config.ts file.");let _=process.env.CHECKSUM_REPL==="true",{test:v,defineChecksumTest:C}=aEi(i??cEi.test,t,r,_),w=orr.init(v.expect),T=Mes();v._checksum={expect:w,checksumAI:T},_&&(console.log("Detected REPL mode"),v.beforeEach(async()=>{v.setTimeout(0)}),v.afterEach(async()=>{for(;;)await TA(1e3)}));let k=e(({name:R,userRole:B})=>{let{environment:U,user:W}=q_t(t,{environment:R,role:B},!0),X=oJn({config:t,throwIfEnvInfoInvalid:!0},{environmentName:U.name,userRole:W.role});return{environment:U,user:W,login:X}},"getEnvironment");return{test:v,expect:w,login:Bbe({config:t}),defineChecksumTest:C,getEnvironment:k,checksumAI:T}}e(Les,"init");var hhn=e(i=>new Proxy(i,{apply:e(function(r,a,o){let c={...r.options,...o[2]};return r.page.checksumAI(o[0],o[1],c)},"apply"),get:e(function(r,a){return a==="withDialog"?(r.options.withDialog=!0,hhn(i)):a==="skipAutoRecovery"?(r.options.skipAutoRecovery=!0,hhn(i)):r[a]},"get"),set:e(function(r,a,o){if(a==="page")return r[a]=o},"set")}),"makeChecksumAIProxy"),Mes=e(()=>{let i=e(function(){},"func");return i.page=void 0,i.options={withDialog:!1,withTomer:!1,skipAutoRecovery:!1},hhn(i)},"makeChecksumAI");0&&(module.exports={AutoRecoveryMode,RunMode,checksumHotRequire,getChecksumConfig,getLogin,init});
|
|
2039
2039
|
/*! Bundled license information:
|
|
2040
2040
|
|
|
2041
2041
|
lodash/lodash.js:
|