File: /var/www/quadcode.com/node_modules/playwright-core/lib/webpack/traceViewer/uiMode.88e19691.js
import{u as ve,r as z,e as be,_ as we,f as Te,g as ke,a as f,R as g,h as Ee,c as xe,s as fe,j as T,S as Ce,i as Q,T as M,t as ye,E as Me,m as Re,k as ae,W as Be,M as Ne,l as Pe,b as De,d as Fe}from"./assets/wsPort-131455ca.js";class ce{constructor(){this._stringCache=new Map}internString(e){let t=this._stringCache.get(e);return t||(this._stringCache.set(e,e),t=e),t}}class Le{constructor(e,t,s,i){this._tests=new Map,this._listOnly=!1,this._clearPreviousResultsWhenTestBegins=!1,this._stringPool=new ce,this._rootSuite=new W("","root"),this._pathSeparator=e,this._reporter=t,this._reuseTestCases=s,this._reportConfig=i}dispatch(e){const{method:t,params:s}=e;if(t==="onConfigure"){this._onConfigure(s.config);return}if(t==="onProject"){this._onProject(s.project);return}if(t==="onBegin"){this._onBegin();return}if(t==="onTestBegin"){this._onTestBegin(s.testId,s.result);return}if(t==="onTestEnd"){this._onTestEnd(s.test,s.result);return}if(t==="onStepBegin"){this._onStepBegin(s.testId,s.resultId,s.step);return}if(t==="onStepEnd"){this._onStepEnd(s.testId,s.resultId,s.step);return}if(t==="onError"){this._onError(s.error);return}if(t==="onStdIO"){this._onStdIO(s.type,s.testId,s.resultId,s.data,s.isBase64);return}if(t==="onEnd")return this._onEnd(s.result);if(t==="onExit")return this._onExit()}_setClearPreviousResultsWhenTestBegins(){this._clearPreviousResultsWhenTestBegins=!0}_onConfigure(e){var t;this._rootDir=((t=this._reportConfig)==null?void 0:t.rootDir)||e.rootDir,this._listOnly=e.listOnly,this._config=this._parseConfig(e),this._reporter.onConfigure(this._config)}_onProject(e){let t=this._rootSuite.suites.find(i=>i.project().__projectId===e.id);t||(t=new W(e.name,"project"),this._rootSuite.suites.push(t),t.parent=this._rootSuite);const s=this._parseProject(e);if(t.project=()=>s,this._mergeSuitesInto(e.suites,t),this._listOnly){const i=new Set,r=a=>{a.tests.map(c=>c.testId).forEach(c=>i.add(c)),a.suites.forEach(r)};e.suites.forEach(r);const o=a=>{a.tests=a.tests.filter(c=>i.has(c.id)),a.suites.forEach(o)};o(t)}}_onBegin(){var e,t;(t=(e=this._reporter).onBegin)==null||t.call(e,this._rootSuite)}_onTestBegin(e,t){var r,o;const s=this._tests.get(e);this._clearPreviousResultsWhenTestBegins&&s._clearResults();const i=s._createTestResult(t.id);i.retry=t.retry,i.workerIndex=t.workerIndex,i.parallelIndex=t.parallelIndex,i.setStartTimeNumber(t.startTime),i.statusEx="running",(o=(r=this._reporter).onTestBegin)==null||o.call(r,s,i)}_onTestEnd(e,t){var r,o,a;const s=this._tests.get(e.testId);s.timeout=e.timeout,s.expectedStatus=e.expectedStatus,s.annotations=e.annotations;const i=s.resultsMap.get(t.id);i.duration=t.duration,i.status=t.status,i.statusEx=t.status,i.errors=t.errors,i.error=(r=i.errors)==null?void 0:r[0],i.attachments=this._parseAttachments(t.attachments),(a=(o=this._reporter).onTestEnd)==null||a.call(o,s,i),i.stepMap=new Map}_onStepBegin(e,t,s){var p,u;const i=this._tests.get(e),r=i.resultsMap.get(t),o=s.parentStepId?r.stepMap.get(s.parentStepId):void 0,a=this._absoluteLocation(s.location),c=new We(s,o,a);o?o.steps.push(c):r.steps.push(c),r.stepMap.set(s.id,c),(u=(p=this._reporter).onStepBegin)==null||u.call(p,i,r,c)}_onStepEnd(e,t,s){var a,c;const i=this._tests.get(e),r=i.resultsMap.get(t),o=r.stepMap.get(s.id);o.duration=s.duration,o.error=s.error,(c=(a=this._reporter).onStepEnd)==null||c.call(a,i,r,o)}_onError(e){var t,s;(s=(t=this._reporter).onError)==null||s.call(t,e)}_onStdIO(e,t,s,i,r){var p,u,S,h;const o=r?globalThis.Buffer?Buffer.from(i,"base64"):atob(i):i,a=t?this._tests.get(t):void 0,c=a&&s?a.resultsMap.get(s):void 0;e==="stdout"?(c==null||c.stdout.push(o),(u=(p=this._reporter).onStdOut)==null||u.call(p,o,a,c)):(c==null||c.stderr.push(o),(h=(S=this._reporter).onStdErr)==null||h.call(S,o,a,c))}_onEnd(e){var t,s;return(s=(t=this._reporter).onEnd)==null?void 0:s.call(t,e)}_onExit(){var e,t;return this._stringPool=new ce,(t=(e=this._reporter).onExit)==null?void 0:t.call(e)}_parseConfig(e){const t={...he,...e};return this._reportConfig&&(t.configFile=this._reportConfig.configFile,t.rootDir=this._reportConfig.rootDir,t.reportSlowTests=this._reportConfig.reportSlowTests,t.quiet=this._reportConfig.quiet),t}_parseProject(e){return{__projectId:e.id,metadata:e.metadata,name:e.name,outputDir:this._absolutePath(e.outputDir),repeatEach:e.repeatEach,retries:e.retries,testDir:this._absolutePath(e.testDir),testIgnore:J(e.testIgnore),testMatch:J(e.testMatch),timeout:e.timeout,grep:J(e.grep),grepInvert:J(e.grepInvert),dependencies:e.dependencies,teardown:e.teardown,snapshotDir:this._absolutePath(e.snapshotDir),use:{}}}_parseAttachments(e){return e.map(t=>({...t,body:t.base64&&globalThis.Buffer?Buffer.from(t.base64,"base64"):void 0}))}_mergeSuitesInto(e,t){for(const s of e){let i=t.suites.find(r=>r.title===s.title);i||(i=new W(s.title,s.type),i.parent=t,t.suites.push(i)),i.location=this._absoluteLocation(s.location),i._fileId=s.fileId,i._parallelMode=s.parallelMode,this._mergeSuitesInto(s.suites,i),this._mergeTestsInto(s.tests,i)}}_mergeTestsInto(e,t){for(const s of e){let i=this._reuseTestCases?t.tests.find(r=>r.title===s.title):void 0;i||(i=new Oe(s.testId,s.title,this._absoluteLocation(s.location)),i.parent=t,t.tests.push(i),this._tests.set(i.id,i)),this._updateTest(s,i)}}_updateTest(e,t){return t.id=e.testId,t.location=this._absoluteLocation(e.location),t.retries=e.retries,t}_absoluteLocation(e){return e&&{...e,file:this._absolutePath(e.file)}}_absolutePath(e){return e&&this._stringPool.internString(this._rootDir+this._pathSeparator+e)}}class W{constructor(e,t){this._requireFile="",this.suites=[],this.tests=[],this._parallelMode="none",this.title=e,this._type=t}allTests(){const e=[],t=s=>{for(const i of[...s.suites,...s.tests])i instanceof W?t(i):e.push(i)};return t(this),e}titlePath(){const e=this.parent?this.parent.titlePath():[];return(this.title||this._type!=="describe")&&e.push(this.title),e}project(){}}class Oe{constructor(e,t,s){this.fn=()=>{},this.results=[],this.expectedStatus="passed",this.timeout=0,this.annotations=[],this.retries=0,this.repeatEachIndex=0,this.resultsMap=new Map,this.id=e,this.title=t,this.location=s}titlePath(){const e=this.parent?this.parent.titlePath():[];return e.push(this.title),e}outcome(){const e=this.results.filter(t=>t.status!=="skipped"&&t.status!=="interrupted");return e.length?e.every(t=>t.status===this.expectedStatus)?"expected":e.some(t=>t.status===this.expectedStatus)?"flaky":"unexpected":"skipped"}ok(){const e=this.outcome();return e==="expected"||e==="flaky"||e==="skipped"}_clearResults(){this.results=[],this.resultsMap.clear()}_createTestResult(e){const t=new Ie(this.results.length);return this.results.push(t),this.resultsMap.set(e,t),t}}class We{constructor(e,t,s){this.duration=-1,this.steps=[],this._startTime=0,this.title=e.title,this.category=e.category,this.location=s,this.parent=t,this._startTime=e.startTime}titlePath(){var t;return[...((t=this.parent)==null?void 0:t.titlePath())||[],this.title]}get startTime(){return new Date(this._startTime)}set startTime(e){this._startTime=+e}}class Ie{constructor(e){this.parallelIndex=-1,this.workerIndex=-1,this.duration=-1,this.stdout=[],this.stderr=[],this.attachments=[],this.status="skipped",this.steps=[],this.errors=[],this.stepMap=new Map,this.statusEx="scheduled",this._startTime=0,this.retry=e}setStartTimeNumber(e){this._startTime=e}get startTime(){return new Date(this._startTime)}set startTime(e){this._startTime=+e}}const he={forbidOnly:!1,fullyParallel:!1,globalSetup:null,globalTeardown:null,globalTimeout:0,grep:/.*/,grepInvert:null,maxFailures:0,metadata:{},preserveOutput:"always",projects:[],reporter:[[{}.CI?"dot":"list"]],reportSlowTests:{max:5,threshold:15e3},configFile:"",rootDir:"",quiet:!1,shard:null,updateSnapshots:"missing",version:"",workers:0,webServer:null};function J(n){return n.map(e=>e.s?e.s:new RegExp(e.r.source,e.r.flags))}const je=({source:n})=>{const[e,t]=ve(),[s,i]=z.useState(be()),[r]=z.useState(we(()=>import("./assets/xtermModule-443332e6.js"),["./assets/xtermModule-443332e6.js","./xtermModule.6428296b.css"],import.meta.url).then(a=>a.default)),o=z.useRef(null);return z.useEffect(()=>(Te(i),()=>ke(i)),[]),z.useEffect(()=>{const a=n.write,c=n.clear;return(async()=>{const{Terminal:p,FitAddon:u}=await r,S=t.current;if(!S)return;const h=s==="dark-mode"?ze:Ae;if(o.current&&o.current.terminal.options.theme===h)return;o.current&&(S.textContent="");const d=new p({convertEol:!0,fontSize:13,scrollback:1e4,fontFamily:"var(--vscode-editor-font-family)",theme:h}),m=new u;d.loadAddon(m);for(const v of n.pending)d.write(v);n.write=v=>{n.pending.push(v),d.write(v)},n.clear=()=>{n.pending=[],d.clear()},d.open(S),m.fit(),o.current={terminal:d,fitAddon:m}})(),()=>{n.clear=c,n.write=a}},[r,o,t,n,s]),z.useEffect(()=>{setTimeout(()=>{o.current&&(o.current.fitAddon.fit(),n.resize(o.current.terminal.cols,o.current.terminal.rows))},250)},[e,n]),f("div",{"data-testid":"output",className:"xterm-wrapper",style:{flex:"auto"},ref:t})},Ae={foreground:"#383a42",background:"#fafafa",cursor:"#383a42",black:"#000000",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a0a0",brightBlack:"#000000",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#d19a66",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#383a42",selectionBackground:"#d7d7d7",selectionForeground:"#383a42"},ze={foreground:"#f8f8f2",background:"#1e1e1e",cursor:"#f8f8f0",black:"#000000",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#bfbfbf",brightBlack:"#4d4d4d",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#e6e6e6",selectionBackground:"#44475a",selectionForeground:"#f8f8f2"};function Ve(n){return`.playwright-artifacts-${n}`}let oe=()=>{},pe=n=>{},ge={cols:80,rows:24},H=async()=>{};const I={pending:[],clear:()=>{},write:n=>I.pending.push(n),resize:(n,e)=>{ge={cols:n,rows:e},q("resizeTerminal",{cols:n,rows:e})}},Ke=({})=>{var le;const[n,e]=g.useState(""),[t,s]=g.useState(!1),[i,r]=g.useState(new Map([["passed",!1],["failed",!1],["skipped",!1]])),[o,a]=g.useState(new Map),[c,p]=g.useState({config:void 0,rootSuite:void 0,loadErrors:[]}),[u,S]=g.useState(),[h,d]=g.useState({}),[m,v]=g.useState(new Set),[k,C]=g.useState(!1),[y,B]=g.useState(),[R,Y]=Ee("watch-all",!1),[ee,V]=g.useState({value:new Set}),l=g.useRef(Promise.resolve()),w=g.useRef(new Set),[_,b]=g.useState(0),[E,x]=g.useState(!1),te=g.useRef(null),se=g.useCallback(()=>{C(!0),V({value:new Set}),oe(he,new W("","root"),[],void 0),me(!0).then(()=>{C(!1)})},[]);g.useEffect(()=>{var D;(D=te.current)==null||D.focus(),C(!0),xe({onEvent:Ye,onClose:()=>x(!0)}).then(F=>{H=F,se()})},[se]),oe=g.useCallback((D,F,L,A)=>{const O=D.configFile?fe.getObject(D.configFile+":projects",void 0):void 0;for(const N of o.keys())F.suites.find(X=>X.title===N)||o.delete(N);for(const N of F.suites)o.has(N.title)||o.set(N.title,!!(O!=null&&O.includes(N.title)));!O&&o.size&&![...o.values()].includes(!0)&&o.set(o.entries().next().value[0],!0),p({config:D,rootSuite:F,loadErrors:L}),a(new Map(o)),y&&A?S({...A,total:y.testIds.size}):A||S(void 0)},[o,y]);const ie=g.useCallback((D,F)=>{D==="bounce-if-busy"&&y||(w.current=new Set([...w.current,...F]),l.current=l.current.then(async()=>{var O,N,X;const L=w.current;if(w.current=new Set,!L.size)return;{for(const P of((O=c.rootSuite)==null?void 0:O.allTests())||[])L.has(P.id)&&(P._clearResults(),P._createTestResult("pending"));p({...c})}const A=" ["+new Date().toLocaleTimeString()+"]";I.write("\x1B[2m—".repeat(Math.max(0,ge.cols-A.length))+A+"\x1B[22m"),S({total:L.size,passed:0,failed:0,skipped:0}),B({testIds:L}),await H("run",{testIds:[...L],projects:[...o].filter(([P,Se])=>Se).map(([P])=>P)});for(const P of((N=c.rootSuite)==null?void 0:N.allTests())||[])((X=P.results[0])==null?void 0:X.duration)===-1&&P._clearResults();p({...c}),B(void 0)}))},[o,y,c]),j=!!y;return T("div",{className:"vbox ui-mode",children:[E&&T("div",{className:"drop-target",children:[f("div",{className:"title",children:"UI Mode disconnected"}),T("div",{children:[f("a",{href:"#",onClick:()=>window.location.reload(),children:"Reload the page"})," to reconnect"]})]}),T(Ce,{sidebarSize:250,minSidebarSize:125,orientation:"horizontal",sidebarIsFirst:!0,children:[T("div",{className:"vbox",children:[T("div",{className:"vbox"+(t?"":" hidden"),children:[T(Q,{children:[f("div",{className:"section-title",style:{flex:"none"},children:"Output"}),f(M,{icon:"circle-slash",title:"Clear output",onClick:()=>I.clear()}),f("div",{className:"spacer"}),f(M,{icon:"close",title:"Close",onClick:()=>s(!1)})]}),f(je,{source:I})]}),f("div",{className:"vbox"+(t?" hidden":""),children:f(He,{item:h,rootDir:(le=c.config)==null?void 0:le.rootDir})})]}),T("div",{className:"vbox ui-mode-sidebar",children:[T(Q,{noShadow:!0,noMinHeight:!0,children:[f("img",{src:"icon-32x32.png"}),f("div",{className:"section-title",children:"Playwright"}),f(M,{icon:"color-mode",title:"Toggle color mode",onClick:()=>ye()}),f(M,{icon:"refresh",title:"Reload",onClick:()=>se(),disabled:j||k}),f(M,{icon:"terminal",title:"Toggle output",toggled:t,onClick:()=>{s(!t)}})]}),f(Ue,{filterText:n,setFilterText:e,statusFilters:i,setStatusFilters:r,projectFilters:o,setProjectFilters:a,testModel:c,runTests:()=>ie("bounce-if-busy",m)}),T(Q,{noMinHeight:!0,children:[!j&&!u&&f("div",{className:"section-title",children:"Tests"}),!j&&u&&f("div",{"data-testid":"status-line",className:"status-line",children:T("div",{children:[u.passed,"/",u.total," passed (",u.passed/u.total*100|0,"%)"]})}),j&&u&&f("div",{"data-testid":"status-line",className:"status-line",children:T("div",{children:["Running ",u.passed,"/",y.testIds.size," passed (",u.passed/y.testIds.size*100|0,"%)"]})}),f(M,{icon:"play",title:"Run all",onClick:()=>ie("bounce-if-busy",m),disabled:j||k}),f(M,{icon:"debug-stop",title:"Stop",onClick:()=>q("stop"),disabled:!j||k}),f(M,{icon:"eye",title:"Watch all",toggled:R,onClick:()=>Y(!R)}),f(M,{icon:"collapse-all",title:"Collapse all",onClick:()=>{b(_+1)}})]}),f(qe,{statusFilters:i,projectFilters:o,filterText:n,testModel:c,runningState:y,runTests:ie,onItemSelected:d,setVisibleTestIds:v,watchAll:R,watchedTreeIds:ee,setWatchedTreeIds:V,isLoading:k,requestedCollapseAllCount:_})]})]})]})},Ue=({filterText:n,setFilterText:e,statusFilters:t,setStatusFilters:s,projectFilters:i,setProjectFilters:r,testModel:o,runTests:a})=>{const[c,p]=g.useState(!1),u=g.useRef(null);g.useEffect(()=>{var d;(d=u.current)==null||d.focus()},[]);const S=[...t.entries()].filter(([d,m])=>m).map(([d])=>d).join(" ")||"all",h=[...i.entries()].filter(([d,m])=>m).map(([d])=>d).join(" ")||"all";return T("div",{className:"filters",children:[f(Me,{expanded:c,setExpanded:p,title:f("input",{ref:u,type:"search",placeholder:"Filter (e.g. text, @tag)",spellCheck:!1,value:n,onChange:d=>{e(d.target.value)},onKeyDown:d=>{d.key==="Enter"&&a()}})}),T("div",{className:"filter-summary",title:"Status: "+S+`
Projects: `+h,onClick:()=>p(!c),children:[f("span",{className:"filter-label",children:"Status:"})," ",S,f("span",{className:"filter-label",children:"Projects:"})," ",h]}),c&&T("div",{className:"hbox",style:{marginLeft:14},children:[f("div",{className:"filter-list",children:[...t.entries()].map(([d,m])=>f("div",{className:"filter-entry",children:T("label",{children:[f("input",{type:"checkbox",checked:m,onClick:()=>{const v=new Map(t);v.set(d,!v.get(d)),s(v)}}),f("div",{children:d})]})}))}),f("div",{className:"filter-list",children:[...i.entries()].map(([d,m])=>f("div",{className:"filter-entry",children:T("label",{children:[f("input",{type:"checkbox",checked:m,onClick:()=>{var C;const v=new Map(i);v.set(d,!v.get(d)),r(v);const k=(C=o==null?void 0:o.config)==null?void 0:C.configFile;k&&fe.setObject(k+":projects",[...v.entries()].filter(([y,B])=>B).map(([y])=>y))}}),f("div",{children:d})]})}))})]})]})},$e=Pe,qe=({statusFilters:n,projectFilters:e,filterText:t,testModel:s,runTests:i,runningState:r,watchAll:o,watchedTreeIds:a,setWatchedTreeIds:c,isLoading:p,onItemSelected:u,setVisibleTestIds:S,requestedCollapseAllCount:h})=>{const[d,m]=g.useState({expandedItems:new Map}),[v,k]=g.useState(),[C,y]=g.useState(h),{rootItem:B,treeItemMap:R,fileNames:Y}=g.useMemo(()=>{let l=Qe(s.rootSuite,s.loadErrors,e);Ze(l,t,n,r==null?void 0:r.testIds),_e(l),l=Ge(l),et(l);const w=new Map,_=new Set,b=new Set,E=x=>{x.kind==="group"&&x.location.file&&b.add(x.location.file),x.kind==="case"&&x.tests.forEach(te=>_.add(te.id)),x.children.forEach(E),w.set(x.id,x)};return E(l),S(_),{rootItem:l,treeItemMap:w,fileNames:b}},[t,s,n,e,S,r]);g.useEffect(()=>{if(C!==h){d.expandedItems.clear();for(const _ of R.keys())d.expandedItems.set(_,!1);y(h),k(void 0),m({...d});return}if(!r||r.itemSelectedByUser)return;let l;const w=_=>{var b;_.children.forEach(w),!l&&_.status==="failed"&&(_.kind==="test"&&r.testIds.has(_.test.id)||_.kind==="case"&&r.testIds.has((b=_.tests[0])==null?void 0:b.id))&&(l=_)};w(B),l&&k(l.id)},[r,k,B,C,y,h,d,m,R]);const{selectedTreeItem:ee}=g.useMemo(()=>{const l=v?R.get(v):void 0;let w;l&&(w={file:l.location.file,line:l.location.line,source:{errors:s.loadErrors.filter(b=>{var E;return((E=b.location)==null?void 0:E.file)===l.location.file}).map(b=>({line:b.location.line,message:b.message})),content:void 0}});let _;return(l==null?void 0:l.kind)==="test"?_=l.test:(l==null?void 0:l.kind)==="case"&&l.tests.length===1&&(_=l.tests[0]),u({testCase:_,testFile:w}),{selectedTreeItem:l}},[u,v,s,R]);g.useEffect(()=>{if(!p)if(o)q("watch",{fileNames:[...Y]});else{const l=new Set;for(const w of a.value){const _=R.get(w),b=_==null?void 0:_.location.file;b&&l.add(b)}q("watch",{fileNames:[...l]})}},[p,B,Y,o,a,R]);const V=l=>{k(l.id),i("bounce-if-busy",ne(l))};return pe=l=>{const w=[],_=new Set(l);if(o){const b=E=>{const x=E.location.file;x&&_.has(x)&&w.push(...ne(E)),E.kind==="group"&&E.subKind==="folder"&&E.children.forEach(b)};b(B)}else for(const b of a.value){const E=R.get(b),x=E==null?void 0:E.location.file;x&&_.has(x)&&w.push(...ne(E))}i("queue-if-busy",new Set(w))},f($e,{treeState:d,setTreeState:m,rootItem:B,dataTestId:"test-tree",render:l=>T("div",{className:"hbox ui-mode-list-item",children:[f("div",{className:"ui-mode-list-item-title",children:l.title}),!!l.duration&&l.status!=="skipped"&&f("div",{className:"ui-mode-list-item-time",children:Re(l.duration)}),T(Q,{noMinHeight:!0,noShadow:!0,children:[f(M,{icon:"play",title:"Run",onClick:()=>V(l),disabled:!!r}),f(M,{icon:"go-to-file",title:"Open in VS Code",onClick:()=>q("open",{location:Je(l)}),style:l.kind==="group"&&l.subKind==="folder"?{visibility:"hidden"}:{}}),!o&&f(M,{icon:"eye",title:"Watch",onClick:()=>{a.value.has(l.id)?a.value.delete(l.id):a.value.add(l.id),c({...a})},toggled:a.value.has(l.id)})]})]}),icon:l=>l.status==="scheduled"?"codicon-clock":l.status==="running"?"codicon-loading":l.status==="failed"?"codicon-error":l.status==="passed"?"codicon-check":l.status==="skipped"?"codicon-circle-slash":"codicon-circle-outline",selectedItem:ee,onAccepted:V,onSelected:l=>{r&&(r.itemSelectedByUser=!0),k(l.id)},isError:l=>l.kind==="group"?l.hasLoadErrors:!1,autoExpandDepth:t?5:1,noItemsMessage:p?"Loading…":"No tests"})},He=({item:n,rootDir:e})=>{const[t,s]=g.useState(),[i,r]=g.useState(0),o=g.useRef(null),{outputDir:a}=g.useMemo(()=>({outputDir:n.testCase?Xe(n.testCase):void 0}),[n]),[c,p]=g.useState(),u=g.useCallback(h=>p(ae(h)),[p]),S=c?t==null?void 0:t.model.actions.find(h=>ae(h)===c):void 0;return g.useEffect(()=>{var v,k;o.current&&clearTimeout(o.current);const h=(v=n.testCase)==null?void 0:v.results[0];if(!h){s(void 0);return}const d=h&&h.duration>=0&&h.attachments.find(C=>C.name==="trace");if(d&&d.path){de(d.path).then(C=>s({model:C,isLive:!1}));return}if(!a){s(void 0);return}const m=`${a}/${Ve(h.workerIndex)}/traces/${(k=n.testCase)==null?void 0:k.id}.json`;return o.current=setTimeout(async()=>{try{const C=await de(m);s({model:C,isLive:!0})}catch{s(void 0)}finally{r(i+1)}},500),()=>{o.current&&clearTimeout(o.current)}},[a,n,s,i,r]),f(Be,{model:t==null?void 0:t.model,hideTimelineBars:!0,hideStackFrames:!0,showSourcesFirst:!0,rootDir:e,initialSelection:S,onSelectionChanged:u,fallbackLocation:n.testFile,isLive:t==null?void 0:t.isLive,drawer:"bottom"},"workbench")};let $,Z,U;const ue=()=>{clearTimeout(Z),Z=void 0,oe(U.config,U.rootSuite,U.loadErrors,U.progress)},K=(n,e,t,s,i=!1)=>{U={config:n,rootSuite:e,loadErrors:t,progress:s},i?ue():Z||(Z=setTimeout(ue,250))},me=n=>{if(!n)return H("list",{});let e;const t=[],s={passed:0,failed:0,skipped:0};let i;return $=new Le(G,{version:()=>"v2",onConfigure:r=>{i=r},onBegin:r=>{e||(e=r),s.passed=0,s.failed=0,s.skipped=0,K(i,e,t,s,!0)},onEnd:()=>{K(i,e,t,s,!0)},onTestBegin:()=>{K(i,e,t,s)},onTestEnd:r=>{r.outcome()==="skipped"?++s.skipped:r.outcome()==="unexpected"?++s.failed:++s.passed,K(i,e,t,s)},onError:r=>{I.write((r.stack||r.value||"")+`
`),t.push(r),K(i,e??new W("","root"),t,s)},printsToStdio:()=>!1,onStdOut:()=>{},onStdErr:()=>{},onExit:()=>{},onStepBegin:()=>{},onStepEnd:()=>{}},!0),$._setClearPreviousResultsWhenTestBegins(),H("list",{})},q=(n,e)=>{if(window._overrideProtocolForTest){window._overrideProtocolForTest({method:n,params:e}).catch(()=>{});return}H(n,e).catch(t=>{console.error(t)})},Ye=(n,e)=>{var t;if(n==="listChanged"){me(!1).catch(()=>{});return}if(n==="testFilesChanged"){pe(e.testFileNames);return}if(n==="stdio"){if(e.buffer){const s=atob(e.buffer);I.write(s)}else I.write(e.text);return}(t=$==null?void 0:$.dispatch({method:n,params:e}))==null||t.catch(()=>{})},Xe=n=>{var e;for(let t=n.parent;t;t=t.parent)if(t.project())return(e=t.project())==null?void 0:e.outputDir},Je=n=>{if(n)return n.location.file+":"+n.location.line},ne=n=>{const e=new Set;if(!n)return e;const t=s=>{var i;s.kind==="case"?s.tests.map(r=>r.id).forEach(r=>e.add(r)):s.kind==="test"?e.add(s.id):(i=s.children)==null||i.forEach(t)};return t(n),e};function re(n,e,t,s){if(e.length===0)return n;const i=e.join(G),r=s.get(i);if(r)return r;const o=re(n,e.slice(0,e.length-1),!1,s),a={kind:"group",subKind:t?"file":"folder",id:i,title:e[e.length-1],location:{file:i,line:0,column:0},duration:0,parent:o,children:[],status:"none",hasLoadErrors:!1};return o.children.push(a),s.set(i,a),a}function Qe(n,e,t){const s=[...t.values()].some(Boolean),i={kind:"group",subKind:"folder",id:"root",title:"",location:{file:"",line:0,column:0},duration:0,parent:void 0,children:[],status:"none",hasLoadErrors:!1},r=(a,c,p)=>{for(const u of c.suites){const S=u.title||"<anonymous>";let h=p.children.find(d=>d.title===S);h||(h={kind:"group",subKind:"describe",id:p.id+""+S,title:S,location:u.location,duration:0,parent:p,children:[],status:"none",hasLoadErrors:!1},p.children.push(h)),r(a,u,h)}for(const u of c.tests){const S=u.title;let h=p.children.find(v=>v.title===S);h||(h={kind:"case",id:p.id+""+S,title:S,parent:p,children:[],tests:[],location:u.location,duration:0,status:"none"},p.children.push(h));const d=u.results[0];let m="none";(d==null?void 0:d.statusEx)==="scheduled"?m="scheduled":(d==null?void 0:d.statusEx)==="running"?m="running":(d==null?void 0:d.status)==="skipped"?m="skipped":(d==null?void 0:d.status)==="interrupted"?m="none":d&&u.outcome()!=="expected"?m="failed":d&&u.outcome()==="expected"&&(m="passed"),h.tests.push(u),h.children.push({kind:"test",id:u.id,title:a,location:u.location,test:u,parent:h,children:[],status:m,duration:u.results.length?Math.max(0,u.results[0].duration):0,project:a}),h.duration=h.children.reduce((v,k)=>v+k.duration,0)}},o=new Map;for(const a of(n==null?void 0:n.suites)||[])if(!(s&&!t.get(a.title)))for(const c of a.suites){const p=re(i,c.location.file.split(G),!0,o);r(a.title,c,p)}for(const a of e){if(!a.location)continue;const c=re(i,a.location.file.split(G),!0,o);c.hasLoadErrors=!0}return i}function Ze(n,e,t,s){const i=e.trim().toLowerCase().split(" "),r=[...t.values()].some(Boolean),o=c=>{const p=c.tests[0].titlePath().join(" ").toLowerCase();return!i.every(u=>p.includes(u))&&!c.tests.some(u=>s==null?void 0:s.has(u.id))?!1:(c.children=c.children.filter(u=>!r||(s==null?void 0:s.has(u.id))||t.get(u.status)),c.tests=c.children.map(u=>u.test),!!c.children.length)},a=c=>{const p=[];for(const u of c.children)u.kind==="case"?o(u)&&p.push(u):(a(u),(u.children.length||u.hasLoadErrors)&&p.push(u));c.children=p};a(n)}function _e(n){for(const o of n.children)_e(o);n.kind==="group"&&n.children.sort((o,a)=>o.location.file.localeCompare(a.location.file)||o.location.line-a.location.line);let e=n.children.length>0,t=n.children.length>0,s=!1,i=!1,r=!1;for(const o of n.children)t=t&&o.status==="skipped",e=e&&(o.status==="passed"||o.status==="skipped"),s=s||o.status==="failed",i=i||o.status==="running",r=r||o.status==="scheduled";i?n.status="running":r?n.status="scheduled":s?n.status="failed":t?n.status="skipped":e&&(n.status="passed")}function Ge(n){let e=n;for(;e.children.length===1&&e.children[0].kind==="group"&&e.children[0].subKind==="folder";)e=e.children[0];return e.location=n.location,e}function et(n){const e=t=>{t.kind==="case"&&t.children.length===1?t.children=[]:t.children.forEach(e)};e(n)}async function de(n){const e=new URLSearchParams;e.set("trace",n);const s=await(await fetch(`contexts?${e.toString()}`)).json();return new Ne(s)}const G=navigator.userAgent.toLowerCase().includes("windows")?"\\":"/";(async()=>(De(),window.location.protocol!=="file:"&&(window.location.href.includes("isUnderTest=true")&&await new Promise(n=>setTimeout(n,1e3)),navigator.serviceWorker.register("sw.bundle.js"),navigator.serviceWorker.controller||await new Promise(n=>{navigator.serviceWorker.oncontrollerchange=()=>n()}),setInterval(function(){fetch("ping")},1e4)),Fe.render(f(Ke,{}),document.querySelector("#root"))))();