shiplightai 0.1.67 → 0.1.68

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/dist/index.js CHANGED
@@ -4365,7 +4365,7 @@ ${p.join(`
4365
4365
  `)}function xc(e,t){let i=[],n=t?.version||"unknown";i.push(`// @generated by shiplightai v${n}`),i.push(...bo()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let a=new Set,o={imports:a,actionEntityStore:t?.actionEntityStore},r=t?.testName||"Test Suite",s=Ln(t?.tags);i.push(`test.describe.serial('${s}${_e(r)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(i.push(...bi("beforeAll",e.beforeAll,o,1)),i.push("")),e.beforeEach&&e.beforeEach.length>0&&(i.push(...bi("beforeEach",e.beforeEach,o,1)),i.push(""));for(let c=0;c<e.tests.length;c++){let d=e.tests[c],h=d.timeout||d.skip!==void 0||d.fail!==void 0||d.only||d.slow?{timeout:d.timeout,skip:d.skip,fail:d.fail,only:d.only,slow:d.slow}:void 0;if(d.parameters&&d.parameters.length>0)for(let p of d.parameters){let g=wo(d.testFlow,p.values);i.push(...vi(g,`${_e(d.name)} [${_e(p.name)}]`,o,1,h)),i.push("")}else i.push(...vi(d.testFlow,_e(d.name),o,1,h)),(c<e.tests.length-1||e.afterEach||e.afterAll)&&i.push("")}return e.afterEach&&e.afterEach.length>0&&(i.push(...bi("afterEach",e.afterEach,o,1)),i.push("")),e.afterAll&&e.afterAll.length>0&&i.push(...bi("afterAll",e.afterAll,o,1)),i.push("});"),yo(i,a),i.join(`
4366
4366
  `)}function Ln(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}var vc=["testContext","request"];function xi(e){let t=new Set;function i(n){for(let a of n)switch(a.type){case ue.ACTION:{let r=a.action_entity?.action_data?.kwargs;if(r?.args&&Array.isArray(r.args))for(let s of r.args)typeof s=="string"&&vc.includes(s)&&t.add(s);break}case ue.STEP:i(a.statements);break;case ue.IF_ELSE:{let o=a;i(o.then),o.else&&i(o.else);break}case ue.WHILE_LOOP:i(a.body);break}}return i(e),t}function _c(e){let t=xi(e.statements??[]);if(e.teardown)for(let i of xi(e.teardown))t.add(i);return t}function Rn(e){return`{ ${["page","agent",...Array.from(e).sort()].join(", ")} }`}function vi(e,t,i,n=0,a){let o=" ".repeat(n),r=[],s=_c(e),l=Rn(s),c=a?.only?"test.only":"test";r.push(`${o}${c}('${t}', async (${l}) => {`),a?.skip===!0?r.push(`${o} test.skip();`):typeof a?.skip=="string"&&r.push(`${o} test.skip(true, '${_e(a.skip)}');`),a?.fail===!0?r.push(`${o} test.fail();`):typeof a?.fail=="string"&&r.push(`${o} test.fail(true, '${_e(a.fail)}');`),a?.slow&&r.push(`${o} test.slow();`),a?.timeout&&r.push(`${o} test.setTimeout(${a.timeout});`);let d=e.teardown&&e.teardown.length>0,h=n+1;if(d){if(r.push(`${o} try {`),e.statements&&e.statements.length>0){r.push(`${o} // Test steps`);let g=pe(e.statements,h+1,i);r.push(...g)}r.push(`${o} } finally {`),r.push(`${o} // Teardown`);let p=pe(e.teardown,h+1,i,"teardown");r.push(...p),r.push(`${o} }`)}else if(e.statements&&e.statements.length>0){r.push(`${o} // Test steps`);let p=pe(e.statements,h,i);r.push(...p)}return r.push(`${o}});`),r}function mo(e,t,i){let n=[],a=fo(t),o=xi(a),r=Rn(o);return n.push(`test.${e}(async (${r}) => {`),n.push(...pe(a,1,i,e)),n.push("});"),n}function bi(e,t,i,n){let a=" ".repeat(n),o=[],r=fo(t);if(e==="beforeAll"||e==="afterAll"){let l={...i,noAgent:!0};o.push(`${a}test.${e}(async ({ browser }, workerInfo) => {`),o.push(`${a} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),o.push(...pe(r,n+1,l,e)),o.push(`${a} await page.close();`),o.push(`${a}});`)}else{let l=xi(r),c=Rn(l);o.push(`${a}test.${e}(async (${c}) => {`),o.push(...pe(r,n+1,i,e)),o.push(`${a}});`)}return o}function fo(e){let i=oc({goal:"_hook",statements:e});return me(i).statements??[]}function wo(e,t){let i=Mn(e);for(let[n,a]of Object.entries(t))i=i.split(`<<${n}>>`).join(String(a));return me(i)}function bo(){return["import { test, expect } from 'shiplightai/fixture';"]}function yo(e,t){if(t.size>0){let i=0;for(let a=0;a<e.length;a++)e[a].startsWith("import ")&&(i=a+1);let n=Array.from(t);e.splice(i,0,...n)}}var go=5;function vo(e,t,i){let n={expandingPaths:new Set([Nn(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=Ne(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=Ne(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=Ne(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function Ne(e,t,i){let n=[];for(let a of e)if(Mc(a)){let o=Ic(a,t,i);n.push(o)}else n.push(Pc(a,t,i));return n}function Mc(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Ic(e,t,i){if(i.depth>=go)throw new Error(`Template expansion exceeded maximum depth of ${go}. Check for deeply nested or circular template references.`);let n=Nn(Ac(t),e.template),a=!Tc(n)&&i.basePath?Nn(i.basePath,e.template):n;if(i.expandingPaths.has(a))throw new Error(`Circular template reference detected: ${a} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${a}`);i.referencedPaths.add(a);let o;try{o=Ec(a,"utf-8")}catch(f){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${f.message}`)}let r=po(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let f of s)if(!(f in l))throw new Error(`Template ${e.template} requires param "${f}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let y=$c(c);for(let[b,m]of Object.entries(l))y=y.split(`<<${b}>>`).join(String(m));c=po(y)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},h=Ne(c,a,d),g={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:h};return Object.keys(l).length>0&&(g.template_params=l),g}function Pc(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=Ne(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=Ne(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=Ne(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=Ne(n.DO,t,i)),n}var Fn=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function Hn(e,t,i){let n=Sc(e),a=n?.name,o=n?.tags,r=n?.use;if(n&&(n.name!==void 0||n.tags!==void 0||n.use!==void 0)&&(delete n.name,delete n.tags,delete n.use),n?.suite){if(n.goal||n.statements)throw new Fn('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Oc(n,a,o,r,t,i)}return Cc(n,a,o,r,t,i)}function Cc(e,t,i,n,a,o){let r=e?.beforeEach,s=e?.afterEach,l=_o(e?.parameters),c=e?.timeout,d=e?.skip,h=e?.fail,p=e?.only,g=e?.slow,f=e?.settings,y=n;if(f){let _={};f.auto_dismiss_modal!==void 0&&(_.autoDismissModal=!!f.auto_dismiss_modal),f.browser_timezone!==void 0&&f.browser_timezone!==null&&(_.timezoneId=String(f.browser_timezone)),f.browser_language!==void 0&&f.browser_language!==null&&(_.locale=String(f.browser_language)),f.extra_http_headers!==void 0&&f.extra_http_headers!==null&&typeof f.extra_http_headers=="object"&&(_.extraHTTPHeaders=f.extra_http_headers),Object.keys(_).length>0&&(y={...y,..._})}if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow,delete e.settings),e?.url)throw new Fn(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let b=[];if(a&&e&&typeof e=="object"){let _=vo(e,a,o);e=_.doc,b=_.referencedTemplatePaths}let m=xo(e),x=me(m);return a&&(Xe(x.statements??[],a,"main"),x.teardown&&Xe(x.teardown,a,"teardown")),{testFlow:x,name:t,tags:i,use:y,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:h,only:p,slow:g,referencedTemplatePaths:b}}function Oc(e,t,i,n,a,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=r.beforeAll,l=r.afterAll,c=r.beforeEach,d=r.afterEach,h=[],p=r.tests.map(y=>{if(!y.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(y.statements)||y.statements.length===0)throw new Error(`Suite test "${y.name}" must have a non-empty "statements" array.`);let b={goal:y.name,statements:y.statements};y.teardown&&(b.teardown=y.teardown);let m=[],x=b;if(a&&typeof b=="object"){let $=vo(b,a,o);x=$.doc,m=$.referencedTemplatePaths,h.push(...m)}let _=xo(x),E=me(_),A=_o(y.parameters);return{testFlow:E,name:y.name,tags:Array.isArray(y.tags)?y.tags:void 0,parameters:A,timeout:y.timeout,skip:y.skip,fail:y.fail,only:y.only,slow:y.slow}}),g=r.base_url,f=g?{...n,baseURL:g}:n;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:f,referencedTemplatePaths:h}}function _o(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,i)=>{if(!t.name)throw new Error(`Parameter set at index ${i} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function Xe(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=Lc(t,o,r),a.type===ue.STEP)Xe(a.statements,t,o);else if(a.type===ue.IF_ELSE){let s=a;Xe(s.then,t,`${o}.then`),s.else&&Xe(s.else,t,`${o}.else`)}else a.type===ue.WHILE_LOOP&&Xe(a.body,t,`${o}.body`)}}function Lc(e,t,i){let n=kc("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}function ko(e,t,i){let n=/\btemplate:\s/.test(e),a=/^suite:/m.test(e),o=n||a?null:Pn(e);if(o&&!o.valid)return{valid:!1,errors:o.errors,warnings:[],stats:o.stats};let r,s,l=[];try{let c=i?.parsed??Hn(e,t);l=c.referencedTemplatePaths;let d={version:i?.version,actionEntityStore:i?.actionEntityStore},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?r=xc(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):r=yc(c.testFlow,{...d,testName:c.name,tags:c.tags,use:h,beforeEach:c.beforeEach,afterEach:c.afterEach,parameters:c.parameters,timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow});let p=r.split(`
4367
4367
  `).filter(g=>!g.startsWith("import ")).join(`
4368
- `);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),Dc(Rc(s),{recursive:!0}),Nc(s,r)}catch(c){let d=c instanceof Fn?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var Wn="0.1.67";function So(e){try{return Fc(e).mtimeMs}catch{return 0}}var Uc=`// @generated by shiplightai v${Wn}`;function Bc(e,t){if(!To(e)||Eo(e,"utf-8").split(`
4368
+ `);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),Dc(Rc(s),{recursive:!0}),Nc(s,r)}catch(c){let d=c instanceof Fn?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var Wn="0.1.68";function So(e){try{return Fc(e).mtimeMs}catch{return 0}}var Uc=`// @generated by shiplightai v${Wn}`;function Bc(e,t){if(!To(e)||Eo(e,"utf-8").split(`
4369
4369
  `,1)[0]!==Uc)return!1;let n=So(e);for(let a of t)if(So(a)>n)return!1;return!0}function Gc(e){let t=process.argv.slice(2),i=[],n=Un(e);for(let a of t){if(a.startsWith("-"))continue;let o=a.endsWith(".yaml.spec.ts")?a.replace(/\.yaml\.spec\.ts$/,".test.yaml"):a;if(!o.endsWith(".test.yaml"))continue;let r=Un(e,o);To(r)&&i.push(r.startsWith(n)?r.slice(n.length+1):o)}return i.length>0?i:null}function Ao(e){let t=Gc(e.cwd),i=t??Wc("**/*.test.yaml",{cwd:e.cwd,ignore:["**/node_modules/**"]}),n=[];for(let a of i){let o=Un(e.cwd,a),r=o.replace(/\.test\.yaml$/,".yaml.spec.ts"),s=Eo(o,"utf-8");try{let l=Hn(s,o,e.projectRoot??e.cwd),c=Hc(e.cwd,o),d=e.actionEntityStores?.get(c)??e.actionEntityStores?.get("*");if(!(d&&Object.keys(d.entries).length>0)&&Bc(r,[o,...l.referencedTemplatePaths]))continue;let p=ko(s,o,{version:Wn,actionEntityStore:d,parsed:l});if(!p.valid)throw new Error(p.errors.join("; "))}catch(l){console.error(`[shiplight] Failed to transpile ${a}:`,l),n.push({file:a,error:l})}}if(n.length>0){let a=`[shiplight] Transpilation failed for ${n.length} file(s):
4370
4370
  `+n.map(o=>` - ${o.file}`).join(`
4371
4371
  `);if(t)throw new Error(a);console.warn(a+" (skipped)")}}import*as ae from"fs";import*as ft from"path";import{globSync as ed}from"glob";Si();function Lo(e){let t=ki().SHIPLIGHT_API_TOKEN;return process.env.CI&&t?new zn:new Kn(e)}var td=".shiplight/action-cache";function Oo(e){return e.replace(/\//g,"__")+".json"}function id(e){return e.replace(/\.json$/,"").replace(/__/g,"/")}var Kn=class{constructor(t){this.cwd=t;this.cacheDir=ft.join(t,td)}isCloud=!1;cacheDir;async lookup(t){let i=new Map;if(t.length===0||!ae.existsSync(this.cacheDir))return i;for(let n of t){let a=ft.join(this.cacheDir,Oo(n));try{if(ae.existsSync(a)){let o=ae.readFileSync(a,"utf-8");i.set(n,JSON.parse(o))}}catch{}}return i}async update(t){if(t.size===0)return 0;ae.mkdirSync(this.cacheDir,{recursive:!0});let i=0;for(let[n,a]of t)try{let o=ft.join(this.cacheDir,Oo(n)),r=Cn();if(ae.existsSync(o))try{r=JSON.parse(ae.readFileSync(o,"utf-8"))}catch{}let s={...r,entries:{...r.entries,...a.entries}};ae.writeFileSync(o,JSON.stringify(s,null,2)),i++}catch{}return i}loadAll(){if(!ae.existsSync(this.cacheDir))return;let t=ed("*.json",{cwd:this.cacheDir});if(t.length===0)return;let i=new Map,n=0;for(let a of t)try{let o=ae.readFileSync(ft.join(this.cacheDir,a),"utf-8"),r=JSON.parse(o),s=id(a);i.set(s,r),n+=Object.keys(r.entries??{}).length}catch{}if(i.size!==0)return console.log(`[shiplight] Cache: loaded ${n} cached action entit${n===1?"y":"ies"} for ${i.size} test file${i.size!==1?"s":""}`),i}},zn=class{isCloud=!0;async lookup(t){let{lookupActionStores:i}=await Promise.resolve().then(()=>(jn(),Gn));return i(t)}async update(t){let{updateActionStores:i}=await Promise.resolve().then(()=>(jn(),Gn));return i(t)}loadAll(){}};Si();function od(e={}){e.dotenv!==!1&&sd(e.scanDir||process.cwd());let t=e.scanDir||process.cwd(),n=Lo(t).loadAll();return Ao({cwd:t,projectRoot:process.cwd(),actionEntityStores:n}),{reporter:[["list"],["shiplightai/reporter",{outputFolder:"shiplight-report",open:"never"}]]}}function rd(e,...t){return ad(e,...t)}function sd(e){Mo(e);for(let t of Bn(e))nd.config({path:t})}R();R();Lt();Qe();import{z as tl}from"zod";var Th=tl.object({instruction:tl.string().describe('The instruction of the operation to perform. Can only include one operation. Do not inlcude element indexes just describe the element, e.g. "select the text "Hello, world!" in "Hello, world!""')});function il(e){e.register({name:"perform_accurate_operation",description:"Perform an operation that requires accurate interaction like dragging or interacting with a specific area of an element. Only use this action when neccecary.",schema:Th,usesElementIndex:!1,async execute(t,i){let{instruction:n}=t,a={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await Ze(n,a,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:n,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:n}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,s=await Ct(r,a);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}Te();R();import{generateText as Ah}from"ai";import{convert as $h}from"html-to-text";async function Mh(e,t,i){let{apiKey:n,domain:a}=e;if(!n||!a)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=[];try{let r=`https://api.mailgun.net/v3/${a}/events`,s={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(s.from=i.from_email),i.since)s.begin=Math.floor(i.since/1e3).toString();else{let d=new Date(Date.now()-6e5);s.begin=Math.floor(d.getTime()/1e3).toString()}u.info(`Mailgun params: ${JSON.stringify(s)}`);let l=await fetch(r+"?"+new URLSearchParams(s),{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${n}`).toString("base64")}`}});if(!l.ok){let d=await l.text();throw new Error(`Mailgun events API error: ${d}`)}let c=(await l.json()).items||[];for(let d of c.slice(0,10)){if(d.event!=="accepted")continue;let h=(d.storage||{}).url;if(u.info(`message_url: ${h}`),!h){let f=(d.message||{}).headers||{},y=f.subject||"",b=f.from||"",m=f.to||"";if(i.from_email&&!b.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!m.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!y.toLowerCase().includes(i.subject.toLowerCase()))continue;o.push({subject:y,from:b,to:m,date:new Date(d.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:f["message-id"]||""});continue}let p=h.split("/"),g=p[p.length-1];if(u.info(`Storage key: ${g}`),g){let f=`https://api.mailgun.net/v3/domains/${a}/messages/${g}`;try{let y=await fetch(f,{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${n}`).toString("base64")}`,Accept:"application/json"}});if(y.ok){let b=await y.json(),m=b.Subject||"",x=b.From||"",_=b.To||"",E=b.Date||"",A=b["Message-Id"]||"";u.info(`subject: ${m}`),u.info(`from_addr: ${x}`),u.info(`to_addr: ${_}`),u.info(`date: ${E}`),u.info(`message_id: ${A}`);let $=b["body-html"]||b["body-plain"]||"";if($&&$.includes("<")&&($=$h($)),u.info(`Body: ${$.substring(0,200)}...`),i.subject&&!m.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!$.toLowerCase().includes(i.body_contains.toLowerCase()))continue;o.push({subject:m,from:x,to:_,date:E,body:$,message_id:A});continue}else u.warn(`Messages API returned ${y.status}`)}catch(y){u.warn(`Failed to parse JSON response: ${y}`)}}try{let f=await fetch(h,{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${n}`).toString("base64")}`}});if(!f.ok){u.warn(`Could not fetch stored message: ${f.status}`);continue}let y=await f.text();u.info(`Fallback: Raw email length: ${y.length}`);let b=y.split(`
package/dist/reporter.js CHANGED
@@ -1,10 +1,10 @@
1
- import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z as s}from"zod";var Q=s.enum(["JS_CODE","AI_MODE"]),z=s.object({type:Q,expression:s.string()}),ee=s.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),F=s.object({uid:s.string(),type:ee,comment:s.string().optional()}),te=s.object({action_data:s.object({action_name:s.string(),kwargs:s.record(s.any()).optional(),args:s.array(s.any()).optional()}),action_description:s.string().optional(),url:s.string().optional(),xpath:s.string().nullable().optional(),locator:s.string().nullable().optional(),css_selector:s.string().nullable().optional(),unique_selector:s.string().nullable().optional(),element_index:s.number().nullable().optional(),frame_path:s.array(s.any()).optional(),artifacts:s.record(s.any()).optional(),feedback:s.string().optional(),original_browser_use_action:s.any().optional()}).passthrough(),re=F.extend({type:s.literal("DRAFT"),description:s.string()}),ie=F.extend({type:s.literal("ACTION"),description:s.string(),action_entity:te.optional(),locator:s.string().optional(),use_pure_vision:s.boolean().optional()}),E=s.lazy(()=>s.union([re,ie,F.extend({type:s.literal("STEP"),description:s.string().optional().default(""),statements:s.array(E),reference_id:s.number().optional(),template_path:s.string().optional(),template_params:s.record(s.string()).optional()}),F.extend({type:s.literal("IF_ELSE"),description:s.string().optional(),condition:z,then:s.array(E),else:s.array(E).optional()}),F.extend({type:s.literal("WHILE_LOOP"),description:s.string().optional(),condition:z,body:s.array(E),timeout_ms:s.number().optional()})])),ne=s.object({name:s.string(),statements:s.array(E),teardown:s.array(E).optional(),skip:s.union([s.boolean(),s.string()]).optional(),timeout:s.number().optional(),fail:s.union([s.boolean(),s.string()]).optional(),only:s.boolean().optional(),slow:s.boolean().optional()}),H=s.object({tests:s.array(ne).min(1),beforeAll:s.array(E).optional(),afterAll:s.array(E).optional(),beforeEach:s.array(E).optional(),afterEach:s.array(E).optional()}),Y=s.object({comment:s.string().optional(),version:s.string().optional(),goal:s.string().optional(),url:s.string().optional(),baseURL:s.string().optional(),final_feedback:s.string().optional(),completed:s.boolean().optional(),success:s.boolean().optional(),statements:s.array(E).optional(),teardown:s.array(E).optional(),last_modified_at:s.string().optional(),testGroup:H.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});import{stringify as $t,parse as Me,parseAllDocuments as Et,parseDocument as Pe,Document as Mt,isMap as U,isSeq as W}from"yaml";import{v4 as O}from"uuid";function J(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(J);let t=e,r=Object.keys(t);if(r.length===1){let n=r[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let i={};for(let[n,a]of Object.entries(t))i[n]=J(a);return i}var oe=1024*1024;function L(e){if(e.length>oe)throw new Error(`YAML input too large (${e.length} bytes, max ${oe})`);let t=J(Me(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Oe(t);let r={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:P(t.statements??[])};t.final_feedback&&(r.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(r.teardown=P(t.teardown));let i=Y.safeParse(r);if(!i.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(i.error.errors)}`);let n=i.data;return ce(e,n),n}function Oe(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let r=t.tests;if(!Array.isArray(r)||r.length===0)throw new Error('Suite must have a non-empty "tests" array');let n={tests:r.map(c=>{if(!c.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(c.statements)||c.statements.length===0)throw new Error(`Suite test "${c.name}" must have a non-empty "statements" array`);let l={name:c.name,statements:P(c.statements)};return Array.isArray(c.teardown)&&c.teardown.length>0&&(l.teardown=P(c.teardown)),c.skip!==void 0&&(l.skip=c.skip),typeof c.timeout=="number"&&(l.timeout=c.timeout),c.fail!==void 0&&(l.fail=c.fail),c.only===!0&&(l.only=!0),c.slow===!0&&(l.slow=!0),l})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(n.beforeAll=P(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=P(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=P(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=P(t.afterEach));let a=H.safeParse(n);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:a.data}}function P(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Ie)}function Ie(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Le(t);if("WHILE"in t)return Ne(t);if("STEP"in t)return Ce(t);if("VERIFY"in t){let r=t.VERIFY,i={statement:typeof r=="string"?r:String(r)};return typeof t.js=="string"&&(i.code=t.js),{uid:O(),type:"ACTION",description:String(r),action_entity:{action_description:String(r),action_data:{action_name:"verify",kwargs:i}}}}if("URL"in t){let r=t.URL,i=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof r=="string"?r:String(r)};return i&&(a.new_tab=!0),n!==void 0&&(a.timeout_seconds=n),{uid:O(),type:"ACTION",description:`Navigate to ${r}`,action_entity:{action_description:`Navigate to ${r}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let r=t.WAIT_UNTIL,i=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:O(),type:"ACTION",description:`Wait until: ${r}`,action_entity:{action_description:`Wait until: ${r}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof r=="string"?r:String(r),timeout_seconds:i}}}}}if("WAIT"in t){let r=t.WAIT,i=typeof t.seconds=="number"?t.seconds:3;return{uid:O(),type:"ACTION",description:typeof r=="string"?r:`Wait ${i}s`,action_entity:{action_description:typeof r=="string"?r:`Wait ${i}s`,action_data:{action_name:"wait",kwargs:{seconds:i}}}}}if("CODE"in t){let r=t.CODE;if(r==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let i=typeof t.description=="string"?t.description:"Code block";return{uid:O(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof r=="string"?r:String(r)}}}}}if("js"in t&&!("VERIFY"in t)&&!("action"in t)){if("intent"in t||"desc"in t)throw new Error("A `js:` statement uses `description:`, not `intent:`. Raw JS does not self-heal \u2014 use `description: + js:` for code, or express it as a structured action (`intent:` + `action:`/`locator:`) to keep self-healing.");let r=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",i=t.js;return{uid:O(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:r,...i}=t;return ae({...i,action:"function",functionName:r})}if("action"in t)return ae(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:O(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function se(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function Le(e){let t=se(e.IF),r=e.THEN;if(!Array.isArray(r))throw new Error("IF_ELSE requires a THEN array");let i={uid:O(),type:"IF_ELSE",condition:t,then:P(r)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(i.else=P(e.ELSE)),i}function Ne(e){let t=se(e.WHILE),r=e.DO;if(!Array.isArray(r))throw new Error("WHILE_LOOP requires a DO array");let i={uid:O(),type:"WHILE_LOOP",condition:t,body:P(r)};return typeof e.timeout_ms=="number"&&(i.timeout_ms=e.timeout_ms),i}function Ce(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let r={uid:O(),type:"STEP",description:t,statements:P(e.statements)};if(typeof e.reference_id=="number"&&(r.reference_id=e.reference_id),typeof e.template_path=="string"&&(r.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let i=e.template_params,n={};for(let[a,o]of Object.entries(i))n[a]=String(o);r.template_params=n}return r}var De=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function ae(e){let t=typeof e.action=="string"?e.action:String(e.action),r=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",i=typeof e.locator=="string"?e.locator:void 0,n=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,o={};for(let[u,y]of Object.entries(e))De.has(u)||(o[u]=y);t==="verify"&&typeof o.js=="string"&&(o.code=o.js,delete o.js);let c={action_description:r,action_data:{action_name:t,kwargs:Object.keys(o).length>0?o:{}}};i&&(c.locator=i),n&&(c.xpath=n);let l={uid:O(),type:"ACTION",description:r,action_entity:c};return a&&(l.use_pure_vision=!0),l}function ce(e,t){let r;try{r=Pe(e)}catch{return}let i=r.contents;if(!i||!U(i))return;if(r.commentBefore)t.comment=r.commentBefore;else{let l=i.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let n=i,a=n.get("statements",!0);W(a)&&t.statements&&B(a,t.statements);let o=n.get("teardown",!0);W(o)&&t.teardown&&B(o,t.teardown)}function B(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let r=0;r<Math.min(e.items.length,t.length);r++){let i=e.items[r];i.commentBefore&&!(r===0&&e.commentBefore)&&(t[r].comment=i.commentBefore);let n=t[r];if(n.type==="STEP"&&U(i)){let a=i.get("statements",!0);W(a)&&B(a,n.statements)}else if(n.type==="IF_ELSE"&&U(i)){let a=i.get("THEN",!0);W(a)&&B(a,n.then);let o=i.get("ELSE",!0);W(o)&&n.else&&B(o,n.else)}else if(n.type==="WHILE_LOOP"&&U(i)){let a=i.get("DO",!0);W(a)&&B(a,n.body)}}}import{parse as Nt,stringify as Ct}from"yaml";var N=(e,t,r)=>{e.forEach((i,n)=>{let a=`${t}.${n}`;i.type==="DRAFT"?r[a]={description:i.description||"Draft",action_entity:void 0}:i.type==="ACTION"?r[a]={description:i.description||"Action",action_entity:i.action_entity,locator:i.locator}:i.type==="STEP"&&i.statements?N(i.statements,a,r):i.type==="IF_ELSE"?(r[a]={description:"IF "+(i.condition?.expression||""),action_entity:void 0},i.then&&N(i.then,`${a}.then`,r),i.else&&N(i.else,`${a}.else`,r)):i.type==="WHILE_LOOP"&&(r[a]={description:"WHILE "+(i.condition?.expression||""),action_entity:void 0},i.body&&N(i.body,`${a}.body`,r))})};function K(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return N(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&N(e.teardown,"teardown",t),t}var le=112;var Be=1080-le;var de={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}};var pe={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},R=(e,t=!1)=>{let r=["chromium"];return t&&r.push("webkit"),pe[e].map(i=>de[i]).filter(i=>i.defaultBrowserType&&r.includes(i.defaultBrowserType))};var Ge={desktop:{label:"Desktop",type:"desktop",devices:R("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:R("mobile")}},Re={desktop:{label:"Desktop",type:"desktop",devices:R("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:R("mobile",!0)}};var C=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(C||{});import{stringify as on}from"yaml";import{createHash as Je}from"crypto";import{parse as Xe,stringify as ye}from"yaml";import{readFileSync as qe,existsSync as Ze}from"fs";import{resolve as X,dirname as Qe}from"path";import{parse as he,stringify as et}from"yaml";var me=5e3;function ze(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Ye(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function ge(e){let t=ze(e),r=e.locator;if(typeof r=="string"&&r.trim())return r=r.trim(),r.endsWith("first()")?`${t}.${r}`:`${t}.${r}.first()`;let i=Ye(e);if(i){let n=JSON.stringify(i);return`${t}.locator(${n}).first()`}return null}var $=new Map;function m(e,t){$.set(e,t)}function D(e,t,r=[]){let i=[...r];return t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`),i.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}m("click",e=>{let t=ge(e);if(!t)return['await agent.execAction("click", page, {});'];let r=e.action_data?.kwargs?.timeout_ms??me;return[`await ${t}.click({ timeout: ${r} });`]});m("click_element",$.get("click"));m("click_element_by_index",$.get("click"));m("double_click",e=>D("double_click",e));m("double_click_on_element",$.get("double_click"));m("right_click",e=>D("right_click",e));m("right_click_on_element",$.get("right_click"));m("hover",e=>D("hover",e));m("hover_element_by_index",$.get("hover"));m("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return D("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});m("fill",$.get("input_text"));m("clear_input",e=>D("clear_input",e));m("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});m("send_keys",$.get("press"));m("send_keys_on_element",e=>{let t=ge(e),r=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(r)} } },`,"});"];let i=e.action_data?.kwargs?.timeout_ms??me;return[`await ${t}.press(${JSON.stringify(r)}, { timeout: ${i} });`]});m("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return D("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});m("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});m("scroll_down",$.get("scroll"));m("scroll_up",$.get("scroll"));m("scroll_element",$.get("scroll"));m("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});m("scroll_on_element",e=>D("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));m("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});m("open_tab",$.get("go_to_url"));m("go_back",()=>['await agent.execAction("go_back", page, {});']);m("reload_page",()=>['await agent.execAction("reload_page", page, {});']);m("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);m("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);m("verify",(e,t)=>{let r=e.action_data?.kwargs,i=typeof r?.code=="string",n=i?r?.statement||e.action_description:e.action_description||r?.statement;if(i&&n){let o=r.code.split(`
2
- `),c=JSON.stringify(n);return["{ const _t = Date.now(); try {",...o.map(l=>` ${l}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${c}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${c}\`);`,` await agent.assert(page, ${c}, ${JSON.stringify(t||"")});`,"} }"]}return i?r.code.split(`
1
+ import*as T from"fs";import*as v from"path";import{v4 as St}from"uuid";import{z as s}from"zod";var Q=s.enum(["JS_CODE","AI_MODE"]),z=s.object({type:Q,expression:s.string()}),ee=s.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),F=s.object({uid:s.string(),type:ee,comment:s.string().optional()}),te=s.object({action_data:s.object({action_name:s.string(),kwargs:s.record(s.any()).optional(),args:s.array(s.any()).optional()}),action_description:s.string().optional(),url:s.string().optional(),xpath:s.string().nullable().optional(),locator:s.string().nullable().optional(),css_selector:s.string().nullable().optional(),unique_selector:s.string().nullable().optional(),element_index:s.number().nullable().optional(),frame_path:s.array(s.any()).optional(),artifacts:s.record(s.any()).optional(),feedback:s.string().optional(),original_browser_use_action:s.any().optional()}).passthrough(),re=F.extend({type:s.literal("DRAFT"),description:s.string()}),ie=F.extend({type:s.literal("ACTION"),description:s.string(),action_entity:te.optional(),locator:s.string().optional(),use_pure_vision:s.boolean().optional()}),E=s.lazy(()=>s.union([re,ie,F.extend({type:s.literal("STEP"),description:s.string().optional().default(""),statements:s.array(E),reference_id:s.number().optional(),template_path:s.string().optional(),template_params:s.record(s.string()).optional()}),F.extend({type:s.literal("IF_ELSE"),description:s.string().optional(),condition:z,then:s.array(E),else:s.array(E).optional()}),F.extend({type:s.literal("WHILE_LOOP"),description:s.string().optional(),condition:z,body:s.array(E),timeout_ms:s.number().optional()})])),ne=s.object({name:s.string(),statements:s.array(E),teardown:s.array(E).optional(),skip:s.union([s.boolean(),s.string()]).optional(),timeout:s.number().optional(),fail:s.union([s.boolean(),s.string()]).optional(),only:s.boolean().optional(),slow:s.boolean().optional()}),H=s.object({tests:s.array(ne).min(1),beforeAll:s.array(E).optional(),afterAll:s.array(E).optional(),beforeEach:s.array(E).optional(),afterEach:s.array(E).optional()}),Y=s.object({comment:s.string().optional(),version:s.string().optional(),goal:s.string().optional(),url:s.string().optional(),baseURL:s.string().optional(),final_feedback:s.string().optional(),completed:s.boolean().optional(),success:s.boolean().optional(),statements:s.array(E).optional(),teardown:s.array(E).optional(),last_modified_at:s.string().optional(),testGroup:H.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});import{stringify as Et,parse as Ee,parseAllDocuments as Mt,parseDocument as Me,Document as Pt,isMap as U,isSeq as W}from"yaml";import{v4 as P}from"uuid";function J(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(J);let t=e,r=Object.keys(t);if(r.length===1){let n=r[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let i={};for(let[n,a]of Object.entries(t))i[n]=J(a);return i}var oe=1024*1024;function L(e){if(e.length>oe)throw new Error(`YAML input too large (${e.length} bytes, max ${oe})`);let t=J(Ee(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Pe(t);let r={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:M(t.statements??[])};t.final_feedback&&(r.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(r.teardown=M(t.teardown));let i=Y.safeParse(r);if(!i.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(i.error.errors)}`);let n=i.data;return ce(e,n),n}function Pe(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let r=t.tests;if(!Array.isArray(r)||r.length===0)throw new Error('Suite must have a non-empty "tests" array');let n={tests:r.map(d=>{if(!d.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(d.statements)||d.statements.length===0)throw new Error(`Suite test "${d.name}" must have a non-empty "statements" array`);let c={name:d.name,statements:M(d.statements)};return Array.isArray(d.teardown)&&d.teardown.length>0&&(c.teardown=M(d.teardown)),d.skip!==void 0&&(c.skip=d.skip),typeof d.timeout=="number"&&(c.timeout=d.timeout),d.fail!==void 0&&(c.fail=d.fail),d.only===!0&&(c.only=!0),d.slow===!0&&(c.slow=!0),c})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(n.beforeAll=M(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=M(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=M(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=M(t.afterEach));let a=H.safeParse(n);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:a.data}}function M(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Oe)}function Oe(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Ie(t);if("WHILE"in t)return Le(t);if("STEP"in t)return Ne(t);if("VERIFY"in t){let r=t.VERIFY,i={statement:typeof r=="string"?r:String(r)};return typeof t.js=="string"&&(i.code=t.js),{uid:P(),type:"ACTION",description:String(r),action_entity:{action_description:String(r),action_data:{action_name:"verify",kwargs:i}}}}if("URL"in t){let r=t.URL,i=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof r=="string"?r:String(r)};return i&&(a.new_tab=!0),n!==void 0&&(a.timeout_seconds=n),{uid:P(),type:"ACTION",description:`Navigate to ${r}`,action_entity:{action_description:`Navigate to ${r}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let r=t.WAIT_UNTIL,i=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:P(),type:"ACTION",description:`Wait until: ${r}`,action_entity:{action_description:`Wait until: ${r}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof r=="string"?r:String(r),timeout_seconds:i}}}}}if("WAIT"in t){let r=t.WAIT,i=typeof t.seconds=="number"?t.seconds:3;return{uid:P(),type:"ACTION",description:typeof r=="string"?r:`Wait ${i}s`,action_entity:{action_description:typeof r=="string"?r:`Wait ${i}s`,action_data:{action_name:"wait",kwargs:{seconds:i}}}}}if("CODE"in t){let r=t.CODE;if(r==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let i=typeof t.description=="string"?t.description:"Code block";return{uid:P(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof r=="string"?r:String(r)}}}}}if("js"in t&&!("VERIFY"in t)&&!("action"in t)){if("intent"in t||"desc"in t)throw new Error("A `js:` statement uses `description:`, not `intent:`. Raw JS does not self-heal \u2014 use `description: + js:` for code, or express it as a structured action (`intent:` + `action:`/`locator:`) to keep self-healing.");let r=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",i=t.js;return{uid:P(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:r,...i}=t;return ae({...i,action:"function",functionName:r})}if("action"in t)return ae(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:P(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function se(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function Ie(e){let t=se(e.IF),r=e.THEN;if(!Array.isArray(r))throw new Error("IF_ELSE requires a THEN array");let i={uid:P(),type:"IF_ELSE",condition:t,then:M(r)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(i.else=M(e.ELSE)),i}function Le(e){let t=se(e.WHILE),r=e.DO;if(!Array.isArray(r))throw new Error("WHILE_LOOP requires a DO array");let i={uid:P(),type:"WHILE_LOOP",condition:t,body:M(r)};return typeof e.timeout_ms=="number"&&(i.timeout_ms=e.timeout_ms),i}function Ne(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let r={uid:P(),type:"STEP",description:t,statements:M(e.statements)};if(typeof e.reference_id=="number"&&(r.reference_id=e.reference_id),typeof e.template_path=="string"&&(r.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let i=e.template_params,n={};for(let[a,o]of Object.entries(i))n[a]=String(o);r.template_params=n}return r}var Ce=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function ae(e){let t=typeof e.action=="string"?e.action:String(e.action),r=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",i=typeof e.locator=="string"?e.locator:void 0,n=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,o={};for(let[f,w]of Object.entries(e))Ce.has(f)||(o[f]=w);t==="verify"&&typeof o.js=="string"&&(o.code=o.js,delete o.js);let d={action_description:r,action_data:{action_name:t,kwargs:Object.keys(o).length>0?o:{}}};i&&(d.locator=i),n&&(d.xpath=n);let c={uid:P(),type:"ACTION",description:r,action_entity:d};return a&&(c.use_pure_vision=!0),c}function ce(e,t){let r;try{r=Me(e)}catch{return}let i=r.contents;if(!i||!U(i))return;if(r.commentBefore)t.comment=r.commentBefore;else{let c=i.items?.[0];c?.key&&c.key.commentBefore&&(t.comment=c.key.commentBefore)}let n=i,a=n.get("statements",!0);W(a)&&t.statements&&B(a,t.statements);let o=n.get("teardown",!0);W(o)&&t.teardown&&B(o,t.teardown)}function B(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let r=0;r<Math.min(e.items.length,t.length);r++){let i=e.items[r];i.commentBefore&&!(r===0&&e.commentBefore)&&(t[r].comment=i.commentBefore);let n=t[r];if(n.type==="STEP"&&U(i)){let a=i.get("statements",!0);W(a)&&B(a,n.statements)}else if(n.type==="IF_ELSE"&&U(i)){let a=i.get("THEN",!0);W(a)&&B(a,n.then);let o=i.get("ELSE",!0);W(o)&&n.else&&B(o,n.else)}else if(n.type==="WHILE_LOOP"&&U(i)){let a=i.get("DO",!0);W(a)&&B(a,n.body)}}}import{parse as Ct,stringify as Dt}from"yaml";var N=(e,t,r)=>{e.forEach((i,n)=>{let a=`${t}.${n}`;i.type==="DRAFT"?r[a]={description:i.description||"Draft",action_entity:void 0}:i.type==="ACTION"?r[a]={description:i.description||"Action",action_entity:i.action_entity,locator:i.locator}:i.type==="STEP"&&i.statements?N(i.statements,a,r):i.type==="IF_ELSE"?(r[a]={description:"IF "+(i.condition?.expression||""),action_entity:void 0},i.then&&N(i.then,`${a}.then`,r),i.else&&N(i.else,`${a}.else`,r)):i.type==="WHILE_LOOP"&&(r[a]={description:"WHILE "+(i.condition?.expression||""),action_entity:void 0},i.body&&N(i.body,`${a}.body`,r))})};function K(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return N(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&N(e.teardown,"teardown",t),t}var le=112;var We=1080-le;var de={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}};var pe={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},G=(e,t=!1)=>{let r=["chromium"];return t&&r.push("webkit"),pe[e].map(i=>de[i]).filter(i=>i.defaultBrowserType&&r.includes(i.defaultBrowserType))};var Be={desktop:{label:"Desktop",type:"desktop",devices:G("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:G("mobile")}},Re={desktop:{label:"Desktop",type:"desktop",devices:G("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:G("mobile",!0)}};var C=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(C||{});import{stringify as an}from"yaml";import{createHash as Ye}from"crypto";import{parse as Je,stringify as ye}from"yaml";import{readFileSync as Xe,existsSync as qe}from"fs";import{resolve as X,dirname as Ze}from"path";import{parse as he,stringify as Qe}from"yaml";var me=5e3;function Ve(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function ze(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function ge(e){let t=Ve(e),r=e.locator;if(typeof r=="string"&&r.trim())return r=r.trim(),r.endsWith("first()")?`${t}.${r}`:`${t}.${r}.first()`;let i=ze(e);if(i){let n=JSON.stringify(i);return`${t}.locator(${n}).first()`}return null}var $=new Map;function m(e,t){$.set(e,t)}function D(e,t,r=[]){let i=[...r];return t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`),i.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}m("click",e=>{let t=ge(e);if(!t)return['await agent.execAction("click", page, {});'];let r=e.action_data?.kwargs?.timeout_ms??me;return[`await ${t}.click({ timeout: ${r} });`]});m("click_element",$.get("click"));m("click_element_by_index",$.get("click"));m("double_click",e=>D("double_click",e));m("double_click_on_element",$.get("double_click"));m("right_click",e=>D("right_click",e));m("right_click_on_element",$.get("right_click"));m("hover",e=>D("hover",e));m("hover_element_by_index",$.get("hover"));m("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return D("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});m("fill",$.get("input_text"));m("clear_input",e=>D("clear_input",e));m("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});m("send_keys",$.get("press"));m("send_keys_on_element",e=>{let t=ge(e),r=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(r)} } },`,"});"];let i=e.action_data?.kwargs?.timeout_ms??me;return[`await ${t}.press(${JSON.stringify(r)}, { timeout: ${i} });`]});m("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return D("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});m("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});m("scroll_down",$.get("scroll"));m("scroll_up",$.get("scroll"));m("scroll_element",$.get("scroll"));m("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});m("scroll_on_element",e=>D("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));m("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});m("open_tab",$.get("go_to_url"));m("go_back",()=>['await agent.execAction("go_back", page, {});']);m("reload_page",()=>['await agent.execAction("reload_page", page, {});']);m("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);m("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);m("verify",(e,t)=>{let r=e.action_data?.kwargs,i=typeof r?.code=="string",n=i?r?.statement||e.action_description:e.action_description||r?.statement;if(i&&n){let o=r.code.split(`
2
+ `),d=JSON.stringify(n);return["{ const _t = Date.now(); try {",...o.map(c=>` ${c}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${d}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${d}\`);`,` await agent.assert(page, ${d}, ${JSON.stringify(t||"")});`,"} }"]}return i?r.code.split(`
3
3
  `):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});m("ai_assert",$.get("verify"));m("assert",$.get("verify"));m("ai_action",(e,t)=>{let r=e.action_data?.kwargs?.statement;if(!r)return["// Skipping ai_action: missing statement"];let i=JSON.stringify(r),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${i}, '${t||""}', ${n});`]});m("ai_step",(e,t)=>{let r=e.action_data?.kwargs?.statement;return r?[`await agent.run(page, ${JSON.stringify(r)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});m("ai_extract",(e,t)=>{let r=e.action_data?.kwargs?.element_description,i=e.action_data?.kwargs?.variable_name;if(!r||!i)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(r),a=JSON.stringify(i);return[`await agent.extract(page, ${n}, ${a}, '${t||""}');`]});m("ai_wait_until",(e,t)=>{let r=e.action_data?.kwargs?.condition,i=e.action_data?.kwargs?.timeout_seconds||60;return r?[`await agent.waitUntilCondition(page, ${JSON.stringify(r)}, ${i}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});m("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",r=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(r)} } },`,"});"]});m("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let r=["{"],i=t.split(`
4
- `);for(let n of i)r.push(` ${n}`);return r.push("}"),r});m("function",(e,t,r)=>{let i=e.action_data?.kwargs||{},n=i.functionName;if(n&&n.includes("#")){let[o,c]=n.split("#");if(o&&c){let l=o.replace(/\.(ts|js|mjs)$/,""),u=`import { ${c} } from '${l}';`;r?.imports?.add(u);let y={...i,functionName:c},b=ue(y);return b?[b.endsWith(";")?b:`${b};`]:["// Skipping function: invalid export pattern"]}}let a=ue(i);return a?[a.endsWith(";")?a:`${a};`]:["// Skipping function: missing functionName"]});m("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});m("upload_file",e=>{let t=e.action_data?.kwargs||{},r=[],i={};return t.paths?i.paths=t.paths:t.path&&(i.path=t.path),t.use_file_input&&(i.use_file_input=!0),r.push(`action_data: { kwargs: ${JSON.stringify(i)} }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...r.map(n=>` ${n},`),"});"]});m("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);m("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);m("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});m("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",r=[];return r.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...r.map(i=>` ${i},`),"});"]});m("done",()=>["// Done - no action needed"]);m("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
5
- `):["// Skipping js_action: missing code"]});function ue(e){let t=e.functionName;if(!t)return null;let r=Array.isArray(e.args)?e.args.map(String):[];if(r.length===0)return`await ${t}()`;let i=["page","testContext","request","agent"],n=["undefined","null","true","false"],a=r.map(o=>i.includes(o)||n.includes(o)||/^-?\d+(\.\d+)?$/.test(o)?o:o.startsWith("$")?`agent.agentServices.readVariable('${o.substring(1)}')`:`"${o}"`);return`await ${t}(${a.join(", ")})`}var fe=5;function be(e,t,r){let i={expandingPaths:new Set([X(t)]),depth:0,referencedPaths:new Set,basePath:r},n={...e};Array.isArray(n.statements)&&(n.statements=I(n.statements,t,i)),Array.isArray(n.teardown)&&(n.teardown=I(n.teardown,t,i));for(let a of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[a])&&(n[a]=I(n[a],t,i));return{doc:n,referencedTemplatePaths:Array.from(i.referencedPaths)}}function I(e,t,r){let i=[];for(let n of e)if(tt(n)){let a=rt(n,t,r);i.push(a)}else i.push(it(n,t,r));return i}function tt(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function rt(e,t,r){if(r.depth>=fe)throw new Error(`Template expansion exceeded maximum depth of ${fe}. Check for deeply nested or circular template references.`);let i=X(Qe(t),e.template),n=!Ze(i)&&r.basePath?X(r.basePath,e.template):i;if(r.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(r.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);r.referencedPaths.add(n);let a;try{a=qe(n,"utf-8")}catch(f){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${f.message}`)}let o=he(a);if(!o||typeof o!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let c=o.params||[],l=e.params||{};for(let f of c)if(!(f in l))throw new Error(`Template ${e.template} requires param "${f}" but it was not provided. Required params: [${c.join(", ")}]`);let u=o.statements;if(!Array.isArray(u))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let p=et(u);for(let[S,_]of Object.entries(l))p=p.split(`<<${S}>>`).join(String(_));u=he(p)}let y={expandingPaths:new Set([...r.expandingPaths,n]),depth:r.depth+1,referencedPaths:r.referencedPaths},b=I(u,n,y),h={STEP:o.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:b};return Object.keys(l).length>0&&(h.template_params=l),h}function it(e,t,r){if(typeof e!="object"||e===null)return e;let i={...e};return Array.isArray(i.statements)&&(i.statements=I(i.statements,t,r)),Array.isArray(i.THEN)&&(i.THEN=I(i.THEN,t,r)),Array.isArray(i.ELSE)&&(i.ELSE=I(i.ELSE,t,r)),Array.isArray(i.DO)&&(i.DO=I(i.DO,t,r)),i}var we=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function _e(e,t,r){let i=Xe(e),n=i?.name,a=i?.tags,o=i?.use;if(i&&(i.name!==void 0||i.tags!==void 0||i.use!==void 0)&&(delete i.name,delete i.tags,delete i.use),i?.suite){if(i.goal||i.statements)throw new we('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return ot(i,n,a,o,t,r)}return nt(i,n,a,o,t,r)}function nt(e,t,r,i,n,a){let o=e?.beforeEach,c=e?.afterEach,l=ve(e?.parameters),u=e?.timeout,y=e?.skip,b=e?.fail,d=e?.only,h=e?.slow,f=e?.settings,p=i;if(f){let g={};f.auto_dismiss_modal!==void 0&&(g.autoDismissModal=!!f.auto_dismiss_modal),f.browser_timezone!==void 0&&f.browser_timezone!==null&&(g.timezoneId=String(f.browser_timezone)),f.browser_language!==void 0&&f.browser_language!==null&&(g.locale=String(f.browser_language)),f.extra_http_headers!==void 0&&f.extra_http_headers!==null&&typeof f.extra_http_headers=="object"&&(g.extraHTTPHeaders=f.extra_http_headers),Object.keys(g).length>0&&(p={...p,...g})}if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow,delete e.settings),e?.url)throw new we(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let S=[];if(n&&e&&typeof e=="object"){let g=be(e,n,a);e=g.doc,S=g.referencedTemplatePaths}let _=ye(e),w=L(_);return n&&(G(w.statements??[],n,"main"),w.teardown&&G(w.teardown,n,"teardown")),{testFlow:w,name:t,tags:r,use:p,beforeEach:o,afterEach:c,parameters:l,timeout:u,skip:y,fail:b,only:d,slow:h,referencedTemplatePaths:S}}function ot(e,t,r,i,n,a){let o=e.suite;if(!Array.isArray(o.tests)||o.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let c=o.beforeAll,l=o.afterAll,u=o.beforeEach,y=o.afterEach,b=[],d=o.tests.map(p=>{if(!p.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(p.statements)||p.statements.length===0)throw new Error(`Suite test "${p.name}" must have a non-empty "statements" array.`);let S={goal:p.name,statements:p.statements};p.teardown&&(S.teardown=p.teardown);let _=[],w=S;if(n&&typeof S=="object"){let A=be(S,n,a);w=A.doc,_=A.referencedTemplatePaths,b.push(..._)}let g=ye(w),T=L(g),M=ve(p.parameters);return{testFlow:T,name:p.name,tags:Array.isArray(p.tags)?p.tags:void 0,parameters:M,timeout:p.timeout,skip:p.skip,fail:p.fail,only:p.only,slow:p.slow}}),h=o.base_url,f=h?{...i,baseURL:h}:i;return{suite:{beforeAll:c,afterAll:l,beforeEach:u,afterEach:y,tests:d},name:t,tags:r,use:f,referencedTemplatePaths:b}}function ve(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,r)=>{if(!t.name)throw new Error(`Parameter set at index ${r} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function G(e,t,r){for(let i=0;i<e.length;i++){let n=e[i],a=`${r}.${i}`,o=n.description||"";if(n.uid=at(t,a,o),n.type===C.STEP)G(n.statements,t,a);else if(n.type===C.IF_ELSE){let c=n;G(c.then,t,`${a}.then`),c.else&&G(c.else,t,`${a}.else`)}else n.type===C.WHILE_LOOP&&G(n.body,t,`${a}.body`)}}function at(e,t,r){let i=Je("sha256").update(`${e}:${t}:${r}`).digest("hex");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`}function x(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function V(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),r=(e%6e4/1e3).toFixed(0);return`${t}m ${r}s`}function Se(e){return`passed after ${e||"?"} ${e===1?"retry":"retries"}`}function j(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">&#x2714;</span>';case"flaky":return'<span class="status-icon flaky">&#x21BB;</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">&#x2718;</span>';case"skipped":return'<span class="status-icon skipped">&#x2500;</span>';case"interrupted":return'<span class="status-icon failed">&#x26A0;</span>';default:return'<span class="status-icon pending">&#x25CB;</span>'}}function st(e){return`<span class="badge badge-${e}">${e}</span>`}function ct(e){if(!e.code)return"";let t=e.code.split(`
6
- `);return e.codeStartLine!=null&&e.codeLine!=null?`<div class="step-code"><pre class="code-block">${t.map((n,a)=>{let o=e.codeStartLine+a,c=o===e.codeLine,l=String(o).padStart(4);return`<span class="code-line${c?" code-line-active":""}">${l} \u2502 ${x(n)}</span>`}).join("")}</pre></div>`:`<div class="step-code"><pre class="code-block">${t.map(i=>`<span class="code-line code-line-body">${x(i)}</span>`).join("")}</pre></div>`}function lt(e){let t=e.duration!=null?`<span class="step-duration">${V(e.duration)}</span>`:"",r=j(e.status);if(e.screenshot||e.message||e.error||e.code){let n="";e.screenshot&&(n=`<img src="${x(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let a=e.screenshot?"":ct(e),o="";e.error&&(o=`<div class="step-error"><pre>${x(e.error)}</pre></div>`);let c="";e.message&&!e.error&&(c=`<div class="step-message">${x(e.message)}</div>`);let l=e.status==="failure"?" open":"";return`
7
- <details class="step-details step step-${e.status}"${l}>
4
+ `);for(let n of i)r.push(` ${n}`);return r.push("}"),r});m("function",(e,t,r)=>{let i=e.action_data?.kwargs||{},n=i.functionName;if(n&&n.includes("#")){let[o,d]=n.split("#");if(o&&d){let c=o.replace(/\.(ts|js|mjs)$/,""),f=`import { ${d} } from '${c}';`;r?.imports?.add(f);let w={...i,functionName:d},b=ue(w);return b?[b.endsWith(";")?b:`${b};`]:["// Skipping function: invalid export pattern"]}}let a=ue(i);return a?[a.endsWith(";")?a:`${a};`]:["// Skipping function: missing functionName"]});m("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});m("upload_file",e=>{let t=e.action_data?.kwargs||{},r=[],i={};return t.paths?i.paths=t.paths:t.path&&(i.path=t.path),t.use_file_input&&(i.use_file_input=!0),r.push(`action_data: { kwargs: ${JSON.stringify(i)} }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...r.map(n=>` ${n},`),"});"]});m("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);m("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);m("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});m("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",r=[];return r.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...r.map(i=>` ${i},`),"});"]});m("done",()=>["// Done - no action needed"]);m("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
5
+ `):["// Skipping js_action: missing code"]});function ue(e){let t=e.functionName;if(!t)return null;let r=Array.isArray(e.args)?e.args.map(String):[];if(r.length===0)return`await ${t}()`;let i=["page","testContext","request","agent"],n=["undefined","null","true","false"],a=r.map(o=>i.includes(o)||n.includes(o)||/^-?\d+(\.\d+)?$/.test(o)?o:o.startsWith("$")?`agent.agentServices.readVariable('${o.substring(1)}')`:`"${o}"`);return`await ${t}(${a.join(", ")})`}var fe=5;function be(e,t,r){let i={expandingPaths:new Set([X(t)]),depth:0,referencedPaths:new Set,basePath:r},n={...e};Array.isArray(n.statements)&&(n.statements=I(n.statements,t,i)),Array.isArray(n.teardown)&&(n.teardown=I(n.teardown,t,i));for(let a of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[a])&&(n[a]=I(n[a],t,i));return{doc:n,referencedTemplatePaths:Array.from(i.referencedPaths)}}function I(e,t,r){let i=[];for(let n of e)if(et(n)){let a=tt(n,t,r);i.push(a)}else i.push(rt(n,t,r));return i}function et(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function tt(e,t,r){if(r.depth>=fe)throw new Error(`Template expansion exceeded maximum depth of ${fe}. Check for deeply nested or circular template references.`);let i=X(Ze(t),e.template),n=!qe(i)&&r.basePath?X(r.basePath,e.template):i;if(r.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(r.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);r.referencedPaths.add(n);let a;try{a=Xe(n,"utf-8")}catch(h){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${h.message}`)}let o=he(a);if(!o||typeof o!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let d=o.params||[],c=e.params||{};for(let h of d)if(!(h in c))throw new Error(`Template ${e.template} requires param "${h}" but it was not provided. Required params: [${d.join(", ")}]`);let f=o.statements;if(!Array.isArray(f))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(c).length>0){let p=Qe(f);for(let[S,_]of Object.entries(c))p=p.split(`<<${S}>>`).join(String(_));f=he(p)}let w={expandingPaths:new Set([...r.expandingPaths,n]),depth:r.depth+1,referencedPaths:r.referencedPaths},b=I(f,n,w),u={STEP:o.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:b};return Object.keys(c).length>0&&(u.template_params=c),u}function rt(e,t,r){if(typeof e!="object"||e===null)return e;let i={...e};return Array.isArray(i.statements)&&(i.statements=I(i.statements,t,r)),Array.isArray(i.THEN)&&(i.THEN=I(i.THEN,t,r)),Array.isArray(i.ELSE)&&(i.ELSE=I(i.ELSE,t,r)),Array.isArray(i.DO)&&(i.DO=I(i.DO,t,r)),i}var we=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function _e(e,t,r){let i=Je(e),n=i?.name,a=i?.tags,o=i?.use;if(i&&(i.name!==void 0||i.tags!==void 0||i.use!==void 0)&&(delete i.name,delete i.tags,delete i.use),i?.suite){if(i.goal||i.statements)throw new we('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return nt(i,n,a,o,t,r)}return it(i,n,a,o,t,r)}function it(e,t,r,i,n,a){let o=e?.beforeEach,d=e?.afterEach,c=ve(e?.parameters),f=e?.timeout,w=e?.skip,b=e?.fail,l=e?.only,u=e?.slow,h=e?.settings,p=i;if(h){let y={};h.auto_dismiss_modal!==void 0&&(y.autoDismissModal=!!h.auto_dismiss_modal),h.browser_timezone!==void 0&&h.browser_timezone!==null&&(y.timezoneId=String(h.browser_timezone)),h.browser_language!==void 0&&h.browser_language!==null&&(y.locale=String(h.browser_language)),h.extra_http_headers!==void 0&&h.extra_http_headers!==null&&typeof h.extra_http_headers=="object"&&(y.extraHTTPHeaders=h.extra_http_headers),Object.keys(y).length>0&&(p={...p,...y})}if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow,delete e.settings),e?.url)throw new we(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let S=[];if(n&&e&&typeof e=="object"){let y=be(e,n,a);e=y.doc,S=y.referencedTemplatePaths}let _=ye(e),g=L(_);return n&&(R(g.statements??[],n,"main"),g.teardown&&R(g.teardown,n,"teardown")),{testFlow:g,name:t,tags:r,use:p,beforeEach:o,afterEach:d,parameters:c,timeout:f,skip:w,fail:b,only:l,slow:u,referencedTemplatePaths:S}}function nt(e,t,r,i,n,a){let o=e.suite;if(!Array.isArray(o.tests)||o.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let d=o.beforeAll,c=o.afterAll,f=o.beforeEach,w=o.afterEach,b=[],l=o.tests.map(p=>{if(!p.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(p.statements)||p.statements.length===0)throw new Error(`Suite test "${p.name}" must have a non-empty "statements" array.`);let S={goal:p.name,statements:p.statements};p.teardown&&(S.teardown=p.teardown);let _=[],g=S;if(n&&typeof S=="object"){let O=be(S,n,a);g=O.doc,_=O.referencedTemplatePaths,b.push(..._)}let y=ye(g),k=L(y),A=ve(p.parameters);return{testFlow:k,name:p.name,tags:Array.isArray(p.tags)?p.tags:void 0,parameters:A,timeout:p.timeout,skip:p.skip,fail:p.fail,only:p.only,slow:p.slow}}),u=o.base_url,h=u?{...i,baseURL:u}:i;return{suite:{beforeAll:d,afterAll:c,beforeEach:f,afterEach:w,tests:l},name:t,tags:r,use:h,referencedTemplatePaths:b}}function ve(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,r)=>{if(!t.name)throw new Error(`Parameter set at index ${r} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function R(e,t,r){for(let i=0;i<e.length;i++){let n=e[i],a=`${r}.${i}`,o=n.description||"";if(n.uid=ot(t,a,o),n.type===C.STEP)R(n.statements,t,a);else if(n.type===C.IF_ELSE){let d=n;R(d.then,t,`${a}.then`),d.else&&R(d.else,t,`${a}.else`)}else n.type===C.WHILE_LOOP&&R(n.body,t,`${a}.body`)}}function ot(e,t,r){let i=Ye("sha256").update(`${e}:${t}:${r}`).digest("hex");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`}function x(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function V(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),r=(e%6e4/1e3).toFixed(0);return`${t}m ${r}s`}function at(e){return`passed after ${e||"?"} ${e===1?"retry":"retries"}`}function st(e,t){let r=e||"?",i=e===1?"retry":"retries";return t==="passed"?`passed after ${r} ${i}`:`failed after ${r} ${i}`}function j(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">&#x2714;</span>';case"flaky":return'<span class="status-icon flaky">&#x21BB;</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">&#x2718;</span>';case"skipped":return'<span class="status-icon skipped">&#x2500;</span>';case"interrupted":return'<span class="status-icon failed">&#x26A0;</span>';default:return'<span class="status-icon pending">&#x25CB;</span>'}}function ct(e){return`<span class="badge badge-${e}">${e}</span>`}function lt(e){if(!e.code)return"";let t=e.code.split(`
6
+ `);return e.codeStartLine!=null&&e.codeLine!=null?`<div class="step-code"><pre class="code-block">${t.map((n,a)=>{let o=e.codeStartLine+a,d=o===e.codeLine,c=String(o).padStart(4);return`<span class="code-line${d?" code-line-active":""}">${c} \u2502 ${x(n)}</span>`}).join("")}</pre></div>`:`<div class="step-code"><pre class="code-block">${t.map(i=>`<span class="code-line code-line-body">${x(i)}</span>`).join("")}</pre></div>`}function dt(e){let t=e.duration!=null?`<span class="step-duration">${V(e.duration)}</span>`:"",r=j(e.status);if(e.screenshot||e.message||e.error||e.code){let n="";e.screenshot&&(n=`<img src="${x(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let a=e.screenshot?"":lt(e),o="";e.error&&(o=`<div class="step-error"><pre>${x(e.error)}</pre></div>`);let d="";e.message&&!e.error&&(d=`<div class="step-message">${x(e.message)}</div>`);let c=e.status==="failure"?" open":"";return`
7
+ <details class="step-details step step-${e.status}"${c}>
8
8
  <summary class="step-header">
9
9
  ${r}
10
10
  <span class="step-id">${x(e.stepId)}</span>
@@ -15,7 +15,7 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
15
15
  ${n}
16
16
  ${a}
17
17
  <div class="step-description-full">${x(e.description)}</div>
18
- ${c}
18
+ ${d}
19
19
  ${o}
20
20
  </div>
21
21
  </details>`}return`
@@ -26,7 +26,7 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
26
26
  <span class="step-description">${x(e.description)}</span>
27
27
  ${t}
28
28
  </div>
29
- </div>`}function dt(e,t,r,i){let n=[];e&&n.push(`
29
+ </div>`}function pt(e,t,r,i){let n=[];e&&n.push(`
30
30
  <details class="artifact-section">
31
31
  <summary class="artifact-summary">Video</summary>
32
32
  <div class="artifact-content">
@@ -37,15 +37,15 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
37
37
  <button class="enlarge-btn" onclick="openVideoOverlay(this)" title="Enlarge">&#x26F6;</button>
38
38
  </div>
39
39
  </div>
40
- </details>`);let a=r.filter(o=>o.screenshot).map(o=>({src:o.screenshot,stepId:o.stepId,description:o.description,status:o.status,message:o.message||o.error||""}));if(a.length>0){let o=x(JSON.stringify(a)),c=a.map((l,u)=>`
41
- <div class="screenshot-thumb" onclick="openGalleryAt(this, ${u})" data-gallery="${o}">
42
- <img src="${x(l.src)}" alt="${x(l.stepId)}" />
43
- <span class="thumb-label">${x(l.stepId)}</span>
40
+ </details>`);let a=r.filter(o=>o.screenshot).map(o=>({src:o.screenshot,stepId:o.stepId,description:o.description,status:o.status,message:o.message||o.error||""}));if(a.length>0){let o=x(JSON.stringify(a)),d=a.map((c,f)=>`
41
+ <div class="screenshot-thumb" onclick="openGalleryAt(this, ${f})" data-gallery="${o}">
42
+ <img src="${x(c.src)}" alt="${x(c.stepId)}" />
43
+ <span class="thumb-label">${x(c.stepId)}</span>
44
44
  </div>`).join("");n.push(`
45
45
  <details class="artifact-section">
46
46
  <summary class="artifact-summary">Screenshots (${a.length})</summary>
47
47
  <div class="artifact-content">
48
- <div class="screenshot-grid">${c}</div>
48
+ <div class="screenshot-grid">${d}</div>
49
49
  </div>
50
50
  </details>`)}if(t){let o=x(t);n.push(`
51
51
  <details class="artifact-section">
@@ -58,40 +58,38 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
58
58
  <p class="trace-hint">Run this command in your terminal to open the interactive Trace Viewer</p>
59
59
  <p class="trace-hint"><a href="${o}" class="attachment-link" download>Download trace.zip</a></p>
60
60
  </div>
61
- </details>`)}return n.length===0?"":`<div class="test-artifacts">${n.join("")}</div>`}function xe(e,t,r,i,n){let a=e.map(lt).join(`
62
- `),o="";t&&!e.some(l=>l.error)&&(o=`<div class="test-error"><pre>${x(t)}</pre></div>`);let c=dt(r,i,e,n);return`
61
+ </details>`)}return n.length===0?"":`<div class="test-artifacts">${n.join("")}</div>`}function Se(e,t,r,i,n){let a=e.map(dt).join(`
62
+ `),o="";t&&!e.some(c=>c.error)&&(o=`<div class="test-error"><pre>${x(t)}</pre></div>`);let d=pt(r,i,e,n);return`
63
63
  ${o}
64
64
  <div class="steps-list">
65
65
  ${a||'<div class="no-steps">No YAML step details available</div>'}
66
66
  </div>
67
- ${c}`}function pt(e,t){let r=e.flaky?"flaky":e.status,i=j(r),n;if(e.flaky&&e.attempts&&e.attempts.length>1){let a=`tabs-${t}`,o=e.attempts.length,c=e.attempts.map((u,y)=>{let b=y===o-1,d=u.status==="passed"?"passed":"failed",h=`Attempt ${u.attemptNumber}`;return`<button class="attempt-tab ${b?"active":""} attempt-tab-${d}"
68
- onclick="switchAttemptTab('${a}', ${y})"
69
- data-tab-index="${y}">${j(d)} ${h} <span class="attempt-tab-badge badge-${d}">${u.status}</span></button>`}).join(""),l=e.attempts.map((u,y)=>{let b=y===o-1,d=xe(u.steps,u.error,u.videoPath,u.tracePath,`${t}-attempt-${y}`);return`<div class="attempt-panel ${b?"active":""}" data-panel-index="${y}">
67
+ ${d}`}function ut(e,t){let r=e.flaky?"flaky":e.status,i=j(r),n;if(e.attempts&&e.attempts.length>1){let a=`tabs-${t}`,d=e.attempts.length-1,c=e.attempts.map((l,u)=>{let h=u===d,p=l.status==="passed"?"passed":"failed",S=`Attempt ${l.attemptNumber}`;return`<button class="attempt-tab ${h?"active":""} attempt-tab-${p}"
68
+ onclick="switchAttemptTab('${a}', ${u})"
69
+ data-tab-index="${u}">${j(p)} ${S} <span class="attempt-tab-badge badge-${p}">${l.status}</span></button>`}).join(""),f=e.attempts.map((l,u)=>{let h=u===d,p=Se(l.steps,l.error,l.videoPath,l.tracePath,`${t}-attempt-${u}`);return`<div class="attempt-panel ${h?"active":""}" data-panel-index="${u}">
70
70
  <div class="attempt-meta">
71
- ${j(u.status==="passed"?"passed":"failed")}
72
- <span class="attempt-meta-text">Attempt ${u.attemptNumber} &mdash; ${u.status} in ${V(u.duration)}</span>
71
+ ${j(l.status==="passed"?"passed":"failed")}
72
+ <span class="attempt-meta-text">Attempt ${l.attemptNumber} &mdash; ${l.status} in ${V(l.duration)}</span>
73
73
  </div>
74
- ${d}
75
- </div>`}).join("");n=`
76
- <div class="flaky-note">Flaky &mdash; ${Se(e.retries)}</div>
74
+ ${p}
75
+ </div>`}).join(""),w=e.flaky?`Flaky &mdash; ${at(e.retries)}`:`Retried &mdash; ${st(e.retries,e.status)}`;n=`
76
+ <div class="${e.flaky?"flaky-note":"retried-note"}">${w}</div>
77
77
  <div class="attempt-tabs" id="${a}">
78
78
  <div class="attempt-tab-bar">${c}</div>
79
- ${l}
80
- </div>`}else n=`
81
- ${e.flaky?`<div class="flaky-note">Flaky &mdash; ${Se(e.retries)}</div>`:""}
82
- ${xe(e.steps,e.error,e.videoPath,e.tracePath,String(t))}`;return`
79
+ ${f}
80
+ </div>`}else n=Se(e.steps,e.error,e.videoPath,e.tracePath,String(t));return`
83
81
  <details class="test-details" ${e.status==="failed"||e.status==="timedOut"?"open":""}>
84
82
  <summary class="test-summary test-${r}">
85
83
  ${i}
86
84
  <span class="test-title">${x(e.title)}</span>
87
85
  <span class="test-file">${x(e.file)}</span>
88
- ${st(r)}
86
+ ${ct(r)}
89
87
  <span class="test-duration">${V(e.duration)}</span>
90
88
  </summary>
91
89
  <div class="test-body">
92
90
  ${n}
93
91
  </div>
94
- </details>`}function ke(e){let t=e.tests.filter(c=>c.flaky).length,r=e.tests.filter(c=>c.status==="passed"&&!c.flaky).length,i=e.tests.filter(c=>c.status==="failed"||c.status==="timedOut").length,n=e.tests.filter(c=>c.status==="skipped").length,a=e.tests.length,o=e.tests.map((c,l)=>pt(c,l)).join(`
92
+ </details>`}function xe(e){let t=e.tests.filter(c=>c.flaky).length,r=e.tests.filter(c=>!c.flaky&&c.retries!=null&&c.retries>0).length,i=e.tests.filter(c=>c.status==="passed"&&!c.flaky).length,n=e.tests.filter(c=>c.status==="failed"||c.status==="timedOut").length,a=e.tests.filter(c=>c.status==="skipped").length,o=e.tests.length,d=e.tests.map((c,f)=>ut(c,f)).join(`
95
93
  `);return`<!DOCTYPE html>
96
94
  <html lang="en">
97
95
  <head>
@@ -156,6 +154,7 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
156
154
  .summary-stat.passed { border-color: var(--color-passed); }
157
155
  .summary-stat.flaky { border-color: var(--color-flaky); }
158
156
  .summary-stat.failed { border-color: var(--color-failed); }
157
+ .summary-stat.retried { border-color: var(--color-flaky); }
159
158
  .summary-stat.skipped { border-color: var(--color-skipped); }
160
159
 
161
160
  .test-list { display: flex; flex-direction: column; gap: 8px; }
@@ -232,6 +231,16 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
232
231
  color: var(--color-flaky);
233
232
  }
234
233
 
234
+ .retried-note {
235
+ background: rgba(255,171,64,0.1);
236
+ border: 1px solid rgba(255,171,64,0.3);
237
+ border-radius: 4px;
238
+ padding: 6px 12px;
239
+ margin-bottom: 8px;
240
+ font-size: 13px;
241
+ color: var(--color-flaky);
242
+ }
243
+
235
244
  .attempt-tabs { margin-top: 4px; }
236
245
 
237
246
  .attempt-tab-bar {
@@ -724,11 +733,12 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
724
733
  <div class="header">
725
734
  <h1>Shiplight Test Report</h1>
726
735
  <div class="summary">
727
- <span class="summary-stat">${a} test${a!==1?"s":""}</span>
728
- ${r>0?`<span class="summary-stat passed">${r} passed</span>`:""}
736
+ <span class="summary-stat">${o} test${o!==1?"s":""}</span>
737
+ ${i>0?`<span class="summary-stat passed">${i} passed</span>`:""}
729
738
  ${t>0?`<span class="summary-stat flaky">${t} flaky</span>`:""}
730
- ${i>0?`<span class="summary-stat failed">${i} failed</span>`:""}
731
- ${n>0?`<span class="summary-stat skipped">${n} skipped</span>`:""}
739
+ ${r>0?`<span class="summary-stat retried">${r} retried</span>`:""}
740
+ ${n>0?`<span class="summary-stat failed">${n} failed</span>`:""}
741
+ ${a>0?`<span class="summary-stat skipped">${a} skipped</span>`:""}
732
742
  <span class="summary-stat">${V(e.totalDuration)}</span>
733
743
  ${e.timestamp?`<span class="summary-stat" style="margin-left:auto;color:var(--color-text-secondary)">${new Date(e.timestamp).toLocaleString()}</span>`:""}
734
744
  </div>
@@ -743,7 +753,7 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
743
753
  </div>
744
754
  </div>`:""}
745
755
  <div class="test-list">
746
- ${o}
756
+ ${d}
747
757
  </div>
748
758
  <div class="footer">
749
759
  Generated by Shiplight Reporter${e.shiplightVersion?` \xB7 shiplightai v${x(e.shiplightVersion)}`:""}
@@ -873,9 +883,9 @@ import*as k from"fs";import*as v from"path";import{v4 as vt}from"uuid";import{z
873
883
  });
874
884
  </script>
875
885
  </body>
876
- </html>`}var Te="0.1.67",Ae=Te!=="dev"?Te:void 0;var yn=3600*1e3,bn=10080*60*1e3;var ut={before:0,main:1,teardown:2,after:3};function $e(e){let t=e.split(".")[0];return ut[t]??1}function Ee(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function ht(e){return[...e].sort(([t],[r])=>{let i=$e(t),n=$e(r);if(i!==n)return i-n;let a=Ee(t),o=Ee(r);for(let c=0;c<Math.max(a.length,o.length);c++){let l=a[c]??-1,u=o[c]??-1;if(l!==u)return l-u}return 0})}function ft(e){let t=new Set;for(let r of e)if(t.add(r.category),r.category==="hook")for(let i of r.steps)t.add(i.category);return t}function mt(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function q(e,t="main",r,i,n){r===void 0&&(r=!ft(e).has("test.step")),n||(n=new Map);let a=[];for(let o of e){if(o.category==="fixture"||o.category==="test.attach")continue;if(o.category==="hook"){let l=mt(o.title,t);a.push(...q(o.steps,l,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let l=n.get(t)??0;n.set(t,l+1);let u=`${t}.${l}`,y={stepId:u,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(y.error=o.error.message??o.error.stack),i&&o.location&&i.set(u,o.location),a.push(y),o.steps.length>0&&a.push(...q(o.steps,u,r,i,n))}}return a}var Z=class{outputFolder;openMode;collected=[];config;runStartTime;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure"}onBegin(t,r){this.config=t,this.runStartTime=new Date().toISOString()}onTestEnd(t,r){this.collected.push({test:t,result:r})}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let u of this.collected){let y=u.test.titlePath().join(" > "),b=r.get(y);b||(b=[],r.set(y,b)),b.push(u)}let i=[];for(let[,u]of r.entries()){let y=u[0].test.location.file,b=[],d,h,f;for(let g=0;g<u.length;g++){let{test:T,result:M}=u[g],A=await this.buildReportTest(T,M,y);d=A,h||(h=A.startTime),f=A.endTime,b.push({attemptNumber:g+1,status:M.status,duration:M.duration,steps:A.steps,error:A.error,videoPath:A.videoPath,tracePath:A.tracePath})}let p=b[b.length-1],{test:S}=u[u.length-1],_={title:S.title,baseTitle:d?.baseTitle,file:v.relative(process.cwd(),y),status:p.status,duration:p.duration,steps:p.steps,error:p.error,videoPath:p.videoPath,tracePath:p.tracePath,actionStepsMap:d?.actionStepsMap,tags:d?.tags,baseUrl:d?.baseUrl,skip:d?.skip,slow:d?.slow,timeout:d?.timeout,parameterSetName:d?.parameterSetName,startTime:h,endTime:f,suiteName:d?.suiteName},w=b.some(g=>g.status==="failed"||g.status==="timedOut");b.length>1&&w&&p.status==="passed"&&(_.flaky=!0,_.retries=b.length-1,_.attempts=b),i.push(_)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:Ae},a=v.isAbsolute(this.outputFolder)?this.outputFolder:v.join(process.cwd(),this.outputFolder);k.mkdirSync(a,{recursive:!0});let o=v.join(a,"screenshots");for(let u=0;u<n.tests.length;u++){let y=n.tests[u],b=y.attempts&&y.attempts.length>0,d=[{obj:y,prefix:b?`test-${u}-attempt-0`:`test-${u}`,screenshotSubDir:`test-${u}`}];if(y.attempts)for(let h=0;h<y.attempts.length;h++)d.push({obj:y.attempts[h],prefix:`test-${u}-attempt-${h+1}`,screenshotSubDir:`test-${u}/attempt-${h}`});for(let{obj:h,prefix:f,screenshotSubDir:p}of d){let S=v.join(o,p),_=!1;for(let w of h.steps)if(w.screenshot&&v.isAbsolute(w.screenshot))try{_||(k.mkdirSync(S,{recursive:!0}),_=!0);let g=`${w.stepId.replace(/\./g,"-")}.png`;k.copyFileSync(w.screenshot,v.join(S,g)),w.screenshot=`screenshots/${p}/${g}`}catch(g){console.warn(`[reporter] Failed to copy screenshot for ${w.stepId}:`,g)}if(h.videoPath&&v.isAbsolute(h.videoPath)){let w=v.extname(h.videoPath)||".webm",g=`${f}-video${w}`;try{k.copyFileSync(h.videoPath,v.join(a,g)),h.videoPath=g}catch{h.videoPath=void 0}}if(h.tracePath&&v.isAbsolute(h.tracePath)){let w=v.extname(h.tracePath)||".zip",g=`${f}-trace${w}`;try{k.copyFileSync(h.tracePath,v.join(a,g)),h.tracePath=g}catch{h.tracePath=void 0}}}}let c=v.join(a,"report-data.json");k.writeFileSync(c,JSON.stringify(n,null,2),"utf-8");let l=v.join(a,"index.html");if(k.writeFileSync(l,ke(n),"utf-8"),console.log(`
877
- Shiplight report written to: ${l}`),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let u=(await import("open")).default;await u(l)}catch{}}printsToStdio(){return!1}async buildReportTest(t,r,i){let n={title:t.title,file:v.relative(process.cwd(),i),status:r.status,duration:r.duration,steps:[],startTime:new Date(r.startTime).toISOString(),endTime:new Date(r.startTime.getTime()+r.duration).toISOString()};r.errors.length>0&&(n.error=r.errors.map(d=>d.message||d.stack||String(d)).join(`
886
+ </html>`}var ke="0.1.68",Te=ke!=="dev"?ke:void 0;var bn=3600*1e3,wn=10080*60*1e3;var ht={before:0,main:1,teardown:2,after:3};function Ae(e){let t=e.split(".")[0];return ht[t]??1}function $e(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function ft(e){return[...e].sort(([t],[r])=>{let i=Ae(t),n=Ae(r);if(i!==n)return i-n;let a=$e(t),o=$e(r);for(let d=0;d<Math.max(a.length,o.length);d++){let c=a[d]??-1,f=o[d]??-1;if(c!==f)return c-f}return 0})}function mt(e){let t=new Set;for(let r of e)if(t.add(r.category),r.category==="hook")for(let i of r.steps)t.add(i.category);return t}function gt(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function q(e,t="main",r,i,n){r===void 0&&(r=!mt(e).has("test.step")),n||(n=new Map);let a=[];for(let o of e){if(o.category==="fixture"||o.category==="test.attach")continue;if(o.category==="hook"){let c=gt(o.title,t);a.push(...q(o.steps,c,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let c=n.get(t)??0;n.set(t,c+1);let f=`${t}.${c}`,w={stepId:f,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(w.error=o.error.message??o.error.stack),i&&o.location&&i.set(f,o.location),a.push(w),o.steps.length>0&&a.push(...q(o.steps,f,r,i,n))}}return a}var Z=class{outputFolder;openMode;collected=[];config;runStartTime;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure"}onBegin(t,r){this.config=t,this.runStartTime=new Date().toISOString()}onTestEnd(t,r){this.collected.push({test:t,result:r})}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let f of this.collected){let w=f.test.titlePath().join(" > "),b=r.get(w);b||(b=[],r.set(w,b)),b.push(f)}let i=[];for(let[,f]of r.entries()){let w=f[0].test.location.file,b=[],l,u,h;for(let g=0;g<f.length;g++){let{test:y,result:k}=f[g],A=await this.buildReportTest(y,k,w);l=A,u||(u=A.startTime),h=A.endTime,b.push({attemptNumber:g+1,status:k.status,duration:k.duration,steps:A.steps,error:A.error,videoPath:A.videoPath,tracePath:A.tracePath})}let p=b[b.length-1],{test:S}=f[f.length-1],_={title:S.title,baseTitle:l?.baseTitle,file:v.relative(process.cwd(),w),status:p.status,duration:p.duration,steps:p.steps,error:p.error,videoPath:p.videoPath,tracePath:p.tracePath,actionStepsMap:l?.actionStepsMap,tags:l?.tags,baseUrl:l?.baseUrl,skip:l?.skip,slow:l?.slow,timeout:l?.timeout,parameterSetName:l?.parameterSetName,startTime:u,endTime:h,suiteName:l?.suiteName};b.length>1&&(_.retries=b.length-1,_.attempts=b,b.some(y=>y.status==="failed"||y.status==="timedOut")&&p.status==="passed"&&(_.flaky=!0)),i.push(_)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:Te},a=v.isAbsolute(this.outputFolder)?this.outputFolder:v.join(process.cwd(),this.outputFolder);T.mkdirSync(a,{recursive:!0});let o=v.join(a,"screenshots");for(let f=0;f<n.tests.length;f++){let w=n.tests[f],b=w.attempts&&w.attempts.length>0,l=[{obj:w,prefix:b?`test-${f}-attempt-0`:`test-${f}`,screenshotSubDir:`test-${f}`}];if(w.attempts)for(let u=0;u<w.attempts.length;u++)l.push({obj:w.attempts[u],prefix:`test-${f}-attempt-${u+1}`,screenshotSubDir:`test-${f}/attempt-${u}`});for(let{obj:u,prefix:h,screenshotSubDir:p}of l){let S=v.join(o,p),_=!1;for(let g of u.steps)if(g.screenshot&&v.isAbsolute(g.screenshot))try{_||(T.mkdirSync(S,{recursive:!0}),_=!0);let y=`${g.stepId.replace(/\./g,"-")}.png`;T.copyFileSync(g.screenshot,v.join(S,y)),g.screenshot=`screenshots/${p}/${y}`}catch(y){console.warn(`[reporter] Failed to copy screenshot for ${g.stepId}:`,y)}if(u.videoPath&&v.isAbsolute(u.videoPath)){let g=v.extname(u.videoPath)||".webm",y=`${h}-video${g}`;try{T.copyFileSync(u.videoPath,v.join(a,y)),u.videoPath=y}catch{u.videoPath=void 0}}if(u.tracePath&&v.isAbsolute(u.tracePath)){let g=v.extname(u.tracePath)||".zip",y=`${h}-trace${g}`;try{T.copyFileSync(u.tracePath,v.join(a,y)),u.tracePath=y}catch{u.tracePath=void 0}}}}let d=v.join(a,"report-data.json");T.writeFileSync(d,JSON.stringify(n,null,2),"utf-8");let c=v.join(a,"index.html");if(T.writeFileSync(c,xe(n),"utf-8"),console.log(`
887
+ Shiplight report written to: ${c}`),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let f=(await import("open")).default;await f(c)}catch{}}printsToStdio(){return!1}async buildReportTest(t,r,i){let n={title:t.title,file:v.relative(process.cwd(),i),status:r.status,duration:r.duration,steps:[],startTime:new Date(r.startTime).toISOString(),endTime:new Date(r.startTime.getTime()+r.duration).toISOString()};r.errors.length>0&&(n.error=r.errors.map(l=>l.message||l.stack||String(l)).join(`
878
888
 
879
- `)),r.stdout.length>0&&(n.stdout=r.stdout.map(d=>typeof d=="string"?d:d.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(d=>typeof d=="string"?d:d.toString()).join(""));for(let d of r.attachments)d.name==="video"&&d.path&&(n.videoPath=d.path),d.name==="trace"&&d.path&&(n.tracePath=d.path);let a=r.attachments.find(d=>d.name==="shiplight-results"),o=null;if(a)try{if(a.body)o=JSON.parse(a.body.toString("utf-8"));else if(a.path){let d=k.readFileSync(a.path,"utf-8");o=JSON.parse(d)}}catch{}let c=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),l={},u=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),y=u?u[1]:t.title,b=u?u[2]:void 0;if(b&&(n.parameterSetName=b),k.existsSync(c))try{let d=k.readFileSync(c,"utf-8"),h=_e(d,c);if(h.suite){let f=h.suite.tests.find(p=>p.name===y);f&&(l=K(f.testFlow),f.tags?.length&&(n.tags=f.tags),f.skip!==void 0&&(n.skip=f.skip),f.slow&&(n.slow=f.slow),f.timeout!==void 0&&(n.timeout=f.timeout),n.baseTitle=f.name||f.testFlow?.goal),n.suiteName=h.name,h.tags?.length&&(n.suiteTags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL)}else h.testFlow&&(l=K(h.testFlow),n.baseTitle=h.name||h.testFlow?.goal,h.tags?.length&&(n.tags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL))}catch{}if(o||Object.keys(l).length>0){let d=new Set([...Object.keys(l),...Object.keys(o||{})]),h=Array.from(d).map(p=>[p,null]),f=ht(h);for(let[p]of f){let S=l[p],_=o?.[p],w=S?.description;if(!w||w==="Action"||w==="Draft"){let T=S?.action_entity;w=T?.action_description||T?.action_data?.kwargs?.description||_?.description||p}let g={stepId:p,description:w,status:_?.status||"pending",duration:_?.duration};if(_?.message){let T=typeof _.message=="string"?_.message:JSON.stringify(_.message,null,2);_.status==="failure"?g.error=T:g.message=T}if(_?.screenshot){let T=_.screenshot,M=a?.path?v.dirname(a.path):"",A=v.isAbsolute(T)?T:v.join(M,T);k.existsSync(A)&&(g.screenshot=A)}_?.code&&(g.code=_.code),n.steps.push(g)}}if(o===null&&Object.keys(l).length===0&&!i.endsWith(".yaml.spec.ts")){let d=new Map;if(n.steps=q(r.steps,"main",void 0,d),n.steps.length>0){let h=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(f=>{let p=d.get(f.stepId),S;if(p?.file){if(!h.has(p.file))try{h.set(p.file,k.readFileSync(p.file,"utf-8").split(`
880
- `))}catch{h.set(p.file,[])}let w=h.get(p.file);S=w[p.line-1]?.trim();let g=p.line-2,T=p.line,M=[],A=p.line;g>=0&&(M.push(w[g]??""),A=p.line-1),M.push(w[p.line-1]??""),T<w.length&&M.push(w[T]??""),f.code=M.join(`
881
- `),f.codeStartLine=A,f.codeLine=p.line}let _={description:f.description,...S&&{action_entity:{action_description:f.description,action_data:{action_name:"js_code",args:[],kwargs:{code:S}}}}};return[f.stepId,_]}))}}return Object.keys(l).length>0?n.actionStepsMap=l:o&&n.steps.length>0&&(n.actionStepsMap=Object.fromEntries(n.steps.map(d=>{let h=o[d.stepId],f=h?.type,p={description:d.description,...f&&{action_entity:{action_description:d.description,action_data:{action_name:f==="step"?"js_code":f,args:[],kwargs:f==="step"?{code:h?.code??d.description}:{statement:d.description}}}}};return[d.stepId,p]}))),n}},gt=Z;export{gt as default};
889
+ `)),r.stdout.length>0&&(n.stdout=r.stdout.map(l=>typeof l=="string"?l:l.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(l=>typeof l=="string"?l:l.toString()).join(""));for(let l of r.attachments)l.name==="video"&&l.path&&(n.videoPath=l.path),l.name==="trace"&&l.path&&(n.tracePath=l.path);let a=r.attachments.find(l=>l.name==="shiplight-results"),o=null;if(a)try{if(a.body)o=JSON.parse(a.body.toString("utf-8"));else if(a.path){let l=T.readFileSync(a.path,"utf-8");o=JSON.parse(l)}}catch{}let d=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),c={},f=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),w=f?f[1]:t.title,b=f?f[2]:void 0;if(b&&(n.parameterSetName=b),T.existsSync(d))try{let l=T.readFileSync(d,"utf-8"),u=_e(l,d);if(u.suite){let h=u.suite.tests.find(p=>p.name===w);h&&(c=K(h.testFlow),h.tags?.length&&(n.tags=h.tags),h.skip!==void 0&&(n.skip=h.skip),h.slow&&(n.slow=h.slow),h.timeout!==void 0&&(n.timeout=h.timeout),n.baseTitle=h.name||h.testFlow?.goal),n.suiteName=u.name,u.tags?.length&&(n.suiteTags=u.tags),u.use?.baseURL&&(n.baseUrl=u.use.baseURL)}else u.testFlow&&(c=K(u.testFlow),n.baseTitle=u.name||u.testFlow?.goal,u.tags?.length&&(n.tags=u.tags),u.use?.baseURL&&(n.baseUrl=u.use.baseURL))}catch{}if(o||Object.keys(c).length>0){let l=new Set([...Object.keys(c),...Object.keys(o||{})]),u=Array.from(l).map(p=>[p,null]),h=ft(u);for(let[p]of h){let S=c[p],_=o?.[p],g=S?.description;if(!g||g==="Action"||g==="Draft"){let k=S?.action_entity;g=k?.action_description||k?.action_data?.kwargs?.description||_?.description||p}let y={stepId:p,description:g,status:_?.status||"pending",duration:_?.duration};if(_?.message){let k=typeof _.message=="string"?_.message:JSON.stringify(_.message,null,2);_.status==="failure"?y.error=k:y.message=k}if(_?.screenshot){let k=_.screenshot,A=a?.path?v.dirname(a.path):"",O=v.isAbsolute(k)?k:v.join(A,k);T.existsSync(O)&&(y.screenshot=O)}_?.code&&(y.code=_.code),n.steps.push(y)}}if(o===null&&Object.keys(c).length===0&&!i.endsWith(".yaml.spec.ts")){let l=new Map;if(n.steps=q(r.steps,"main",void 0,l),n.steps.length>0){let u=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(h=>{let p=l.get(h.stepId),S;if(p?.file){if(!u.has(p.file))try{u.set(p.file,T.readFileSync(p.file,"utf-8").split(`
890
+ `))}catch{u.set(p.file,[])}let g=u.get(p.file);S=g[p.line-1]?.trim();let y=p.line-2,k=p.line,A=[],O=p.line;y>=0&&(A.push(g[y]??""),O=p.line-1),A.push(g[p.line-1]??""),k<g.length&&A.push(g[k]??""),h.code=A.join(`
891
+ `),h.codeStartLine=O,h.codeLine=p.line}let _={description:h.description,...S&&{action_entity:{action_description:h.description,action_data:{action_name:"js_code",args:[],kwargs:{code:S}}}}};return[h.stepId,_]}))}}return Object.keys(c).length>0?n.actionStepsMap=c:o&&n.steps.length>0&&(n.actionStepsMap=Object.fromEntries(n.steps.map(l=>{let u=o[l.stepId],h=u?.type,p={description:l.description,...h&&{action_entity:{action_description:l.description,action_data:{action_name:h==="step"?"js_code":h,args:[],kwargs:h==="step"?{code:u?.code??l.description}:{statement:l.description}}}}};return[l.stepId,p]}))),n}},yt=Z;export{yt as default};