expect-cli 0.0.6 → 0.0.7
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/README.md +5 -5
- package/dist/assets/resolver.darwin-arm64-DG19oi97.node +0 -0
- package/dist/browser-mcp.js +1 -1
- package/dist/index.js +45 -43
- package/dist/index.js.map +1 -1
- package/dist/{server-D-3IipQn.js → server-DsSVRZK1.js} +41 -41
- package/dist/server-DsSVRZK1.js.map +1 -0
- package/package.json +4 -4
- package/dist/server-D-3IipQn.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{n as e,r as t,t as n}from"./chunk-wdO_pP5q.js";import{$ as r,$i as i,$n as a,$r as o,$t as s,Ai as c,An as l,Ar as u,At as d,B as f,Bi as p,Bn as m,Br as h,Bt as g,C as _,Ci as v,Cn as y,Cr as b,Ct as x,D as ee,Di as S,Dn as C,Dr as w,Dt as te,E as T,Ei as E,En as D,Er as ne,Et as re,F as O,Fi as k,Fn as A,Fr as ie,Ft as j,G as ae,Gi as oe,Gn as M,Gr as se,Gt as ce,H as N,Hi as le,Hn as ue,Ht as de,I as fe,Ii as P,Ir as pe,It as me,J as he,Ji as ge,Jn as _e,Jr as ve,Jt as ye,K as F,Ki as be,Kn as xe,Kt as Se,L as Ce,Li as we,Ln as Te,Lr as Ee,Lt as De,M as Oe,Mi as ke,Mn as Ae,Mr as je,Mt as Me,N as Ne,Ni as Pe,Nn as Fe,Nr as Ie,Nt as Le,O as Re,Oi as ze,On as Be,Or as Ve,Ot as He,P as Ue,Pi as We,Pn as I,Pr as Ge,Pt as Ke,Q as qe,Qi as Je,Qn as Ye,Qr as Xe,Qt as Ze,R as Qe,Ri as $e,Rn as et,Rr as tt,Rt as nt,Si as rt,Sn as it,Sr as at,St as ot,T as st,Ti as ct,Tn as lt,Tr as ut,Tt as dt,U as ft,Ui as pt,Un as mt,Ur as ht,Ut as gt,V as _t,Vi as vt,Vn as yt,Vt as bt,W as xt,Wi as St,Wn as Ct,Wr as wt,Wt as Tt,X as Et,Xi as Dt,Xn as Ot,Xr as kt,Xt as At,Y as jt,Yi as Mt,Yn as Nt,Yr as Pt,Yt as Ft,Z as It,Zi as Lt,Zn as Rt,Zr as zt,Zt as Bt,_ as Vt,_i as Ht,_n as Ut,_r as Wt,_t as Gt,a as Kt,ai as qt,an as Jt,ar as Yt,at as Xt,bi as Zt,bn as L,br as Qt,bt as $t,c as en,ci as tn,cn as nn,cr as rn,ct as R,d as an,di as on,dn as sn,dr as cn,dt as ln,ea as un,ei as dn,en as fn,er as z,et as pn,f as mn,fi as hn,fn as B,fr as gn,ft as _n,g as vn,gi as yn,gn as bn,gr as xn,gt as Sn,h as Cn,hi as wn,hn as Tn,hr as En,ht as Dn,i as On,ii as kn,in as An,ir as jn,it as Mn,j as Nn,ji as Pn,jn as Fn,jr as In,jt as Ln,k as Rn,ki as zn,kn as Bn,kr as Vn,kt as Hn,l as Un,li as Wn,ln as Gn,lr as Kn,lt as V,m as qn,mi as Jn,mn as Yn,mr as Xn,mt as Zn,na as Qn,ni as $n,nn as er,nr as tr,nt as nr,o as rr,on as ir,or as ar,ot as or,p as sr,pi as cr,pn as lr,pr as ur,pt as dr,q as fr,qi as pr,qn as mr,qr as hr,qt as gr,ri as _r,rn as vr,rr as yr,rt as br,s as xr,si as Sr,sn as Cr,sr as wr,st as Tr,ta as Er,ti as Dr,tn as Or,tr as kr,tt as Ar,u as jr,ui as Mr,un as Nr,ur as Pr,ut as Fr,v as Ir,vi as Lr,vn as Rr,vr as zr,vt as Br,wi as Vr,wn as Hr,wr as Ur,wt as Wr,x as Gr,xi as Kr,xn as qr,xr as Jr,xt as Yr,y as Xr,yi as Zr,yn as Qr,yr as $r,yt as ei,z as ti,zi as ni,zn as ri,zr as ii,zt as ai}from"./server-D-3IipQn.js";import{createRequire as oi}from"node:module";import{Command as si}from"commander";import{Box as H,Static as ci,Text as U,render as li,useInput as ui,useStdout as di}from"ink";import{QueryClient as fi,QueryClientProvider as pi,useMutation as mi,useQuery as hi}from"@tanstack/react-query";import{c as gi}from"react/compiler-runtime";import{createContext as _i,useCallback as vi,useContext as yi,useEffect as bi,useMemo as xi,useRef as Si,useState as W}from"react";import{Fragment as Ci,jsx as G,jsxs as K}from"react/jsx-runtime";import q from"figures";import wi from"picocolors";import*as Ti from"node:path";import Ei,{join as Di,normalize as Oi}from"node:path";import*as ki from"node:url";import{fileURLToPath as Ai,pathToFileURL as ji}from"node:url";import{z as Mi}from"zod";import{z as J}from"zod/v4";import{NodeFileSystem as Ni,NodeServices as Pi}from"@effect/platform-node";import*as Fi from"node:child_process";import{exec as Ii,execFile as Li,execSync as Ri}from"node:child_process";import*as zi from"node:crypto";import{createHash as Bi}from"node:crypto";import{Buffer as Vi}from"node:buffer";import{execSync as Hi,spawn as Ui}from"child_process";import{EventEmitter as Wi}from"node:events";import*as Gi from"node:os";import{platform as Ki}from"node:os";import{request as qi}from"node:http";import*as Ji from"node:fs/promises";import Yi from"ink-spinner";import Xi from"cli-truncate";import Zi from"string-width";import{create as Qi}from"zustand";import{dirname as $i,posix as ea,sep as ta}from"path";import*as na from"node:fs";import{createReadStream as ra}from"node:fs";import{createInterface as ia}from"node:readline";import{AsyncLocalStorage as aa}from"node:async_hooks";import{createJSONStorage as oa,persist as sa}from"zustand/middleware";import{RegistryProvider as ca,useAtom as la,useAtomSet as ua,useAtomValue as da}from"@effect/atom-react";import fa from"pretty-ms";import{detectTerminal as pa}from"detect-terminal";import ma from"supports-terminal-graphics";import ha from"ink-link";import{Hono as ga}from"hono";import{proxy as _a}from"hono/proxy";import{serve as va}from"@hono/node-server";import"node-notifier";import ya from"prompts";import ba from"ora";const xa=e=>()=>{let t=$t(Ar(e));return te((e,n)=>z(Qr(e,e=>t(e))))},Sa=e=>()=>{let t=Gt(Ar(e));return te((e,n)=>z(Qr(e,e=>t(e))))},Ca=Je(2,(e,t)=>xa(t.inputSchema)().pipe(d(e),d(Sa(t.outputSchema)()))),wa=`~effect/FiberMap`,Ta=e=>pr(e,wa),Ea={[wa]:wa,[Symbol.iterator](){return this.state._tag===`Closed`?S():this.state.backing[Symbol.iterator]()},...p,toJSON(){return{_id:`FiberMap`,state:this.state}}},Da=(e,t)=>{let n=Object.create(Ea);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Oa=()=>Or(tr(()=>Da(gr(),h())),e=>kr(()=>{let t=e.state;return t._tag===`Closed`?gn:(e.state={_tag:`Closed`},Tt(Ze(t.backing)).pipe(tt(e.deferred)))})),ka=wn(cr(kt,Jn(-1))),Aa=Je(e=>Ta(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(-1);return}let i=ye(e.state.backing,t);if(i._tag===`Some`){if(r?.onlyIfMissing===!0){n.interruptUnsafe(-1);return}else if(i.value===n)return;i.value.interruptUnsafe(-1)}Bt(e.state.backing,t,n),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=ye(e.state.backing,t);k(a)&&n===a.value&&At(e.state.backing,t),wt(i)&&(r?.propagateInterruption===!0?!ka(i.cause):!o(i.cause))&&Ee(e.deferred,i)})}),ja=Je(2,(e,t)=>e.state._tag===`Closed`?!1:Ft(e.state.backing,t)),Ma=function(){let e;return()=>(e===void 0&&(e=mt(Be)),e)}(),Na=function(){let e=arguments[0];if(Bn(arguments[2]))return Pa(e,arguments[1],arguments[2],arguments[3]);let t=arguments[1],n=arguments[2];return r=>Pa(e,t,r,n)},Pa=(e,t,n,r)=>Xn(i=>{if(e.state._tag===`Closed`)return Be;if(r?.onlyIfMissing===!0&&ja(e,t))return tr(Ma);let a=Ct(i.services)(n);return Aa(e,t,a,r),z(a)});var Fa=class extends tn()(`effect/reactivity/Reactivity`){};const Ia=tr(()=>{let e=new Map,t=t=>{Ha(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>a(n=>{let r=n.mapUnsafe.get(La.key);return r?Ha(e,e=>{r.add(e)}):t(e),gn}),r=(e,t)=>yr(t,n(e)),o=(t,n)=>{let r=[];return Ha(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},s=(e,t)=>D(function*(){let n=yield*Ye(),r=on(n,In),a=yield*me(),s=i(Ct(n),Se(r)),c=!1,l=!1,u=e=>{e._tag===`Failure`?j(a,e.cause):nt(a,e.value),l?(l=!1,s(t).addObserver(u)):c=!1};function d(){if(c){l=!0;return}c=!0,s(t).addObserver(u)}return yield*je(r,tr(o(e,d))),d(),a});return Fa.of({mutation:r,query:s,stream:(e,t)=>s(e,t).pipe(I(T),xt),invalidateUnsafe:t,invalidate:n,registerUnsafe:o,withBatch:t=>kr(()=>{let n=new Set;return t.pipe(yt(La,n),Te(t=>tr(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})});var La=class extends tn()(`effect/reactivity/Reactivity/PendingInvalidation`){};const Ra=Je(2,(e,t)=>Fa.use(n=>n.mutation(t,e))),za=e=>Fa.use(t=>t.invalidate(e)),Ba=b(Fa)(Ia);function Va(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return St(e)}}const Ha=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Va(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Va(r[e])}`)}},Ua=e=>pr(e,`~effect/SubscriptionRef`);({...p});const Wa=e=>st(e.pubsub),Ga=e=>tr(()=>e.value),Ka=(e,t)=>{e.value=t,bt(e.pubsub,t)},qa=Je(2,(e,t)=>e.semaphore.withPermit(tr(()=>Ka(e,t)))),Ja=`0.0.6`,Ya=`\x1B[?1049l`,Xa=process.env.SUPPORT_CLICK===`true`||process.env.SUPPORT_CLICK===`1`,Za=[`lint`,`check`,`format`,`typecheck`,`type-check`],Qa={"pnpm-lock.yaml":`pnpm`,"pnpm-workspace.yaml":`pnpm`,"yarn.lock":`yarn`,"package-lock.json":`npm`,"npm-shrinkwrap.json":`npm`,"bun.lock":`bun`,"bun.lockb":`bun`,"deno.lock":`deno`},$a=()=>{},eo=_i({subscribeClick:()=>$a}),to=/\x1b\[<(\d+);(\d+);(\d+)([Mm])|\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\d+;\d+R|\[\?[\d;]+[a-z]/g,no=({children:e})=>{if(!Xa)return G(Ci,{children:e});let t=Si(new Set),n=Si(!1);if(!n.current){n.current=!0,process.stdout.write(`\x1B[?1003l\x1B[?1002l\x1B[?1000h\x1B[?1006h`);let e=process.stdin.emit.bind(process.stdin);process.stdin.emit=function(n,...r){if(n===`data`){let i=(typeof r[0]==`string`?r[0]:String(r[0])).replace(to,(e,n,r,i,a)=>{if(n===`0`)for(let e of t.current)e({x:Number(r),y:Number(i)},a===`M`?`press`:`release`);return``});return i.length===0?!0:e(n,i)}return e(n,...r)}}let r=vi(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]);return G(eo.Provider,{value:{subscribeClick:r},children:e})},ro=()=>{let e=gi(1);if(e[0]!==`35703fbc37b9d963e330527161df9fe36b70875a77771f1d737994ab88cecbb3`){for(let t=0;t<1;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`35703fbc37b9d963e330527161df9fe36b70875a77771f1d737994ab88cecbb3`}return yi(eo)},io=/\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\?[\d;]+[a-z]|\[\d+;\d+R/g,ao=e=>Xa?e.replace(io,``):e,oo=e=>e&&e>0?e:80,so=e=>e&&e>0?e:24,co=()=>{let{stdout:e}=di(),[t,n]=W([oo(e.columns),so(e.rows)]),r=Si(!1);return r.current||(r.current=!0,e.on(`resize`,()=>n([oo(e.columns),so(e.rows)]))),t},Y={primary:`whiteBright`,secondary:`gray`,accent:`white`,error:`red`,warning:`yellow`,success:`green`,info:`gray`,text:`white`,textMuted:`gray`,border:`gray`,borderActive:`white`,borderSubtle:`blackBright`,shimmerBase:`#555555`,shimmerHighlight:`#ffffff`,inputBg:`#1e1e1e`,bannerBg:`#332b00`},lo={TEXT:Y.text,DIM:Y.textMuted,GREEN:Y.success,PRIMARY:Y.primary,SELECTION:Y.accent,RED:Y.error,BORDER:Y.border,DIVIDER:Y.borderSubtle,YELLOW:Y.warning,PURPLE:Y.secondary,CYAN:Y.info,INPUT_BG:Y.inputBg,BANNER_BG:Y.bannerBg},uo=()=>lo,fo=e=>{let t=gi(21);if(t[0]!==`c91257771a99332d5805ee6c49b36d74b00fa9357a1ef3353879ee4c78179ae7`){for(let e=0;e<21;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`c91257771a99332d5805ee6c49b36d74b00fa9357a1ef3353879ee4c78179ae7`}let{color:n,children:r,marginTop:i,marginBottom:a,paddingX:o,ref:s}=e,c=o===void 0?1:o,[l]=co(),u;t[1]===l?u=t[2]:(u=`─`.repeat(l),t[1]=l,t[2]=u);let d;t[3]!==n||t[4]!==u?(d=G(U,{color:n,wrap:`truncate`,children:u}),t[3]=n,t[4]=u,t[5]=d):d=t[5];let f;t[6]!==r||t[7]!==c?(f=G(H,{flexDirection:`column`,paddingX:c,children:r}),t[6]=r,t[7]=c,t[8]=f):f=t[8];let p;t[9]===l?p=t[10]:(p=`─`.repeat(l),t[9]=l,t[10]=p);let m;t[11]!==n||t[12]!==p?(m=G(U,{color:n,wrap:`truncate`,children:p}),t[11]=n,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==f||t[19]!==m?(h=K(H,{flexDirection:`column`,width:`100%`,marginTop:i,marginBottom:a,ref:s,children:[d,f,m]}),t[14]=a,t[15]=i,t[16]=s,t[17]=d,t[18]=f,t[19]=m,t[20]=h):h=t[20],h},po=e=>{let t=e,n=1,r=1;for(;t;){if(!t.yogaNode)return{left:n,top:r};let e=t.yogaNode.getComputedLayout();n+=e.left,r+=e.top,t=t.parentNode}return{left:n,top:r}},mo=({onClick:e,children:t,fullWidth:n=!0})=>{let{subscribeClick:r}=ro(),i=Si(e);return i.current=e,G(H,{ref:vi(e=>{if(e)return r((t,n)=>{if(n!==`press`||!e.yogaNode)return;let r=po(e),a=e.yogaNode.getComputedLayout(),o=t.x<r.left||t.x>=r.left+a.width,s=t.y<r.top||t.y>=r.top+a.height;!o&&!s&&i.current?.()})},[r]),width:n?`100%`:void 0,children:t})},ho=e=>/\w/.test(e),go=(e,t)=>{let n=t-1;for(;n>0&&!ho(e[n]);)n--;for(;n>0&&ho(e[n-1]);)n--;return n},_o=(e,t)=>{let n=t;for(;n<e.length&&ho(e[n]);)n++;for(;n<e.length&&!ho(e[n]);)n++;return n},vo=(e,t)=>{let n=e.split(`
|
|
3
|
-
`),r=0;for(let e=0;e<n.length;e++){let i=n[e].length;if(t<=r+i)return{lineIndex:e,column:t-r,lines:n};r+=i+1}let i=n.length-1;return{lineIndex:i,column:n[i].length,lines:n}},
|
|
4
|
-
`?v+=
|
|
5
|
-
`:v+=n?
|
|
6
|
-
`+e.slice(p),r++;else{c&&c(e);return}else n.leftArrow?a&&r--:n.rightArrow?a&&r++:n.backspace||n.delete?p>0&&(i=e.slice(0,p-1)+e.slice(p,e.length),r--):(i=e.slice(0,p)+t+e.slice(p,e.length),r+=t.length,t.length>1&&(d=t.length));r<0&&(r=0),r>i.length&&(r=i.length),f({cursorOffset:r,cursorWidth:d}),i!==e&&s(i)},{isActive:n}),G(U,{children:t?_.length>0?v:y:v})},xo=e=>{let t=gi(13);if(t[0]!==`ed5db14495474995e96712c30462d38da6b6aa36bffcbec475f62d8824e8125d`){for(let e=0;e<13;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`ed5db14495474995e96712c30462d38da6b6aa36bffcbec475f62d8824e8125d`}let{isSearching:n,query:r,onChange:i,onSubmit:a}=e,o=uo();if(n){let e;t[1]===o.DIM?e=t[2]:(e=G(U,{color:o.DIM,children:`/`}),t[1]=o.DIM,t[2]=e);let n;t[3]!==i||t[4]!==a||t[5]!==r?(n=G(bo,{focus:!0,value:r,onChange:i,onSubmit:a}),t[3]=i,t[4]=a,t[5]=r,t[6]=n):n=t[6];let s;return t[7]!==e||t[8]!==n?(s=K(H,{marginTop:1,children:[e,n]}),t[7]=e,t[8]=n,t[9]=s):s=t[9],s}if(r){let e;return t[10]!==o.DIM||t[11]!==r?(e=G(H,{marginTop:1,children:K(U,{color:o.DIM,children:[`/`,r]})}),t[10]=o.DIM,t[11]=r,t[12]=e):e=t[12],e}return null},So=pn([`pending`,`in_progress`,`completed`,`failed`]),Co=pn([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);pn([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const wo=Zn([V({type:r(`text`),text:R}),V({type:r(`image`),data:R,mimeType:R}),V({type:r(`resource_link`),uri:R}),V({type:r(`resource`),uri:R})]),To=Zn([V({type:r(`content`),content:wo}),V({type:r(`diff`),path:R,oldText:ot(nr(R)),newText:ot(nr(R))}),V({type:r(`terminal`),terminalId:R})]),Eo=V({path:R,lineNumber:ot(nr(br))});var Do=class extends jt(`AcpAgentMessageChunk`)({sessionUpdate:r(`agent_message_chunk`),content:wo,messageId:ot(nr(R))}){},Oo=class extends jt(`AcpAgentThoughtChunk`)({sessionUpdate:r(`agent_thought_chunk`),content:wo,messageId:ot(nr(R))}){},ko=class extends jt(`AcpUserMessageChunk`)({sessionUpdate:r(`user_message_chunk`),content:wo,messageId:ot(nr(R))}){},Ao=class extends jt(`AcpToolCall`)({sessionUpdate:r(`tool_call`),toolCallId:R,title:R,kind:ot(Co),status:ot(So),content:ot(F(To)),locations:ot(F(Eo)),rawInput:ot(Dn),rawOutput:ot(Dn)}){},jo=class extends jt(`AcpToolCallUpdate`)({sessionUpdate:r(`tool_call_update`),toolCallId:R,title:ot(nr(R)),kind:ot(nr(Co)),status:ot(nr(So)),content:ot(nr(F(To))),locations:ot(nr(F(Eo))),rawInput:ot(Dn),rawOutput:ot(Dn)}){};const Mo=pn([`pending`,`in_progress`,`completed`]),No=pn([`high`,`medium`,`low`]),Po=Zn([Do,Oo,ko,Ao,jo,class extends jt(`AcpPlanUpdate`)({sessionUpdate:r(`plan`),entries:F(V({content:R,priority:No,status:Mo}))}){},class extends jt(`AcpAvailableCommandsUpdate`)({sessionUpdate:r(`available_commands_update`)}){},class extends jt(`AcpCurrentModeUpdate`)({sessionUpdate:r(`current_mode_update`)}){},class extends jt(`AcpConfigOptionUpdate`)({sessionUpdate:r(`config_option_update`)}){},class extends jt(`AcpSessionInfoUpdate`)({sessionUpdate:r(`session_info_update`)}){},class extends jt(`AcpUsageUpdate`)({sessionUpdate:r(`usage_update`)}){}]);V({inputTokens:br,outputTokens:br,cachedReadTokens:ot(nr(br)),cachedWriteTokens:ot(nr(br)),thoughtTokens:ot(nr(br))}),pn([`claude`,`codex`,`cursor`]);var Fo=class extends jt(`@ami/FileStat`)({relativePath:R,added:br,removed:br}){},Io=class extends jt(`@supervisor/GitState`)({isGitRepo:he,currentBranch:R,mainBranch:dr(R),isOnMain:he,hasChangesFromMain:he,hasUnstagedChanges:he,hasBranchCommits:he,branchCommitCount:br,fileStats:F(Fo),workingTreeFileStats:F(Fo),fingerprint:dr(R),savedFingerprint:dr(R)}){get hasUntestedChanges(){return this.hasChangesFromMain||this.hasUnstagedChanges}get totalChangedLines(){return this.fileStats.reduce((e,t)=>e+t.added+t.removed,0)}get isCurrentStateTested(){return!this.fingerprint||!this.savedFingerprint?!1:this.fingerprint===this.savedFingerprint}};const Lo=R.pipe(Sn(`StepId`)),Ro=R.pipe(Sn(`PlanId`)),zo=ln({WorkingTree:{},Branch:{mainBranch:R},Changes:{mainBranch:R},Commit:{hash:R}}),Bo=e=>qn(e).pipe(sr({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),Vo=V({number:br,headRefName:R,author:V({login:R}),state:R,updatedAt:R}),Ho=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var Uo=class extends jt(`@supervisor/RemoteBranch`)({name:R,author:R,prNumber:nr(br),prStatus:nr(pn([`open`,`draft`,`merged`])),updatedAt:nr(R)}){static filterBranches(e,t,n){let r=e.filter(e=>t===`recent`||t===`all`?!0:t===`no-pr`?e.prStatus===null:e.prStatus===t);if(n){let e=n.toLowerCase();r=r.filter(t=>t.name.toLowerCase().includes(e))}return t===`recent`&&(r=[...r].filter(e=>e.updatedAt!==null).sort((e,t)=>{let n=new Date(e.updatedAt??0).getTime();return new Date(t.updatedAt??0).getTime()-n})),r}};const Wo=pn([`pending`,`active`,`passed`,`failed`]);var Go=class e extends jt(`@supervisor/TestPlanStep`)({id:Lo,title:R,instruction:R,expectedOutcome:R,routeHint:Xt(R),status:Wo,summary:Xt(R),startedAt:Xt(Et),endedAt:Xt(Et)}){update(t){return new e({...this,...t})}};const Ko=R.pipe(Sn(`DraftId`));var qo=class e extends jt(`@supervisor/TestPlanDraft`)({id:Ko,changesFor:zo,currentBranch:R,diffPreview:R,fileStats:F(Fo),instruction:R,baseUrl:Mn(R),isHeadless:he,requiresCookies:he}){update(t){return new e({...this,...t})}},Jo=class e extends qo.extend(`@supervisor/TestPlan`)({id:Ro,title:R,rationale:R,steps:F(Go)}){update(t){return new e({...this,...t})}updateStep(t,n){return new e({...this,steps:this.steps.map((e,r)=>r===t?n(e):e)})}get stepCount(){return this.steps.length}get resetForRerun(){return new e({...this,steps:this.steps.map(e=>new Go({...e,status:`pending`,summary:$e(),startedAt:$e(),endedAt:$e()}))})}},Yo=class extends Fr()(`RunStarted`,{plan:Jo}){get id(){return`run-started-${this.plan.id}`}},Xo=class extends Fr()(`StepStarted`,{stepId:Lo,title:R}){get id(){return`step-started-${this.stepId}`}},Zo=class extends Fr()(`StepCompleted`,{stepId:Lo,summary:R}){get id(){return`step-completed-${this.stepId}`}},Qo=class extends Fr()(`StepFailed`,{stepId:Lo,message:R}){get id(){return`step-failed-${this.stepId}`}},$o=class extends Fr()(`ToolCall`,{toolName:R,input:Dn}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return Mt(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},es=class extends Fr()(`ToolProgress`,{toolName:R,outputSize:br}){get id(){return`tool-progress-${this.toolName}-${this.outputSize}`}},ts=class extends Fr()(`ToolResult`,{toolName:R,result:R,isError:he}){get id(){return`tool-result-${this.toolName}-${this.result}`}},ns=class extends Fr()(`AgentThinking`,{text:R}){get id(){return`agent-thinking-${this.text}`}},rs=class extends Fr()(`AgentText`,{text:R}){get id(){return`agent-text-${this.text}`}},is=class extends Fr()(`RunFinished`,{status:pn([`passed`,`failed`]),summary:R}){get id(){return`run-finished-${this.status}`}};const as=e=>{if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},os=e=>{let t=e.indexOf(`|`);if(t===-1)return;let n=e.slice(0,t),r=e.slice(t+1),i=r.indexOf(`|`),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i+1);if(n===`STEP_START`)return new Xo({stepId:Lo.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new Zo({stepId:Lo.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new Qo({stepId:Lo.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new is({status:a===`failed`?`failed`:`passed`,summary:o})},ss=Zn([Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is]),cs=Zn([Yo,Xo,Zo,Qo,$o,ts,ns,is,class extends Fr()(`RunCompleted`,{report:x(()=>vs)}){}]);var ls=class extends jt(`@supervisor/Update`)({content:cs,receivedAt:Et}){},us=class extends jt(`@supervisor/PullRequest`)({number:br,url:R,title:R,headRefName:R}){};const ds=ln({WorkingTree:{},Branch:{branch:Uo},PullRequest:{branch:Uo},Commit:{hash:R,shortHash:R,subject:R}}),fs=e=>qn(e).pipe(sr({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),ps=e=>qn(e).pipe(sr({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),ms=e=>qn(e).pipe(sr({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),hs=e=>qn(e).pipe(sr({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),gs=e=>qn(e).pipe(sr({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));ln({Branch:{branchName:R}});var _s=class e extends Jo.extend(`@supervisor/ExecutedTestPlan`)({events:F(ss)}){addEvent(t){if(t.sessionUpdate===`agent_thought_chunk`){if(t.content.type!==`text`||t.content.text===void 0)return this;let n=this.finalizeTextBlock(),r=n.events.at(-1);return r?._tag===`AgentThinking`?new e({...n,events:[...n.events.slice(0,-1),new ns({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new ns({text:t.content.text})]})}if(t.sessionUpdate===`agent_message_chunk`){if(t.content.type!==`text`||t.content.text===void 0)return this;let n=this.events.at(-1);return n?._tag===`AgentText`?new e({...this,events:[...this.events.slice(0,-1),new rs({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new rs({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new $o({toolName:t.title,input:JSON.stringify(t.rawInput??{})})]})}if(t.sessionUpdate===`tool_call_update`){let n=this;if(t.rawInput!==void 0){let r=[...n.events];for(let e=r.length-1;e>=0;e--){let n=r[e];if(n._tag===`ToolCall`&&n.toolName===(t.title??``)){r[e]=new $o({toolName:n.toolName,input:JSON.stringify(t.rawInput)});break}}n=new e({...n,events:r})}if(t.status===`completed`||t.status===`failed`)return new e({...n,events:[...n.events,new ts({toolName:t.title??``,result:as(t.rawOutput),isError:t.status===`failed`})]});if(t.rawOutput!==void 0){let r=as(t.rawOutput).length;return new e({...n,events:[...n.events.filter(e=>!(e._tag===`ToolProgress`&&e.toolName===(t.title??``))),new es({toolName:t.title??``,outputSize:r})]})}return n}return this}finalizeTextBlock(){let t=this.events.at(-1);if(t?._tag!==`AgentText`)return this;let n=t.text.split(`
|
|
7
|
-
`).map(
|
|
8
|
-
`)}},ys=class extends tn()(`@supervisor/Updates`,{make:D(function*(){let e=yield*de();return{publish:L(`Updates.publish`)(function*(t){yield*g(e,new ls({content:t,receivedAt:s()}))}),stream:L(`Updates.stream`)(function*(){return st(e)})}})}){static layer=b(this)(this.make)};const bs=V({name:R,value:R});var xs=class extends jt(`AgentStreamOptions`)({cwd:R,sessionId:Mn(R),prompt:R,systemPrompt:Mn(R),mcpEnv:ot(F(bs))}){};const Ss={authenticate:`authenticate`,initialize:`initialize`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},Cs={fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},ws=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),terminal:J.boolean().optional().default(!1)}),Ts=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),label:J.string().nullish(),name:J.string(),optional:J.boolean().optional().default(!1),secret:J.boolean().optional().default(!0)}),Es=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string().nullish(),id:J.string(),name:J.string()}),Ds=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string().nullish(),id:J.string(),link:J.string().nullish(),name:J.string(),vars:J.array(Ts)}),Os=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),args:J.array(J.string()).optional(),description:J.string().nullish(),env:J.record(J.string(),J.string()).optional(),id:J.string(),name:J.string()}),ks=J.union([Ds.and(J.object({type:J.literal(`env_var`)})),Os.and(J.object({type:J.literal(`terminal`)})),Es]),As=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),methodId:J.string()}),js=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Ms=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),blob:J.string(),mimeType:J.string().nullish(),uri:J.string()}),Ns=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Ps=J.object({amount:J.number(),currency:J.string()}),Fs=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),terminalId:J.string()}),Is=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),newText:J.string(),oldText:J.string().nullish(),path:J.string()}),Ls=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),name:J.string(),value:J.string()}),Rs=J.union([J.literal(-32700),J.literal(-32600),J.literal(-32601),J.literal(-32602),J.literal(-32603),J.literal(-32800),J.literal(-32e3),J.literal(-32002),J.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),zs=J.object({code:Rs,data:J.unknown().optional(),message:J.string()}),Bs=J.unknown(),Vs=J.unknown(),Hs=J.unknown(),Us=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),readTextFile:J.boolean().optional().default(!1),writeTextFile:J.boolean().optional().default(!1)}),Ws=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),auth:ws.optional().default({terminal:!1}),fs:Us.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:J.boolean().optional().default(!1)}),Gs=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),name:J.string(),value:J.string()}),Ks=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),name:J.string(),title:J.string().nullish(),version:J.string()}),qs=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Js=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cursor:J.string().nullish(),cwd:J.string().nullish()}),Ys=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),http:J.boolean().optional().default(!1),sse:J.boolean().optional().default(!1)}),Xs=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),headers:J.array(Gs),name:J.string(),url:J.string()}),Zs=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),headers:J.array(Gs),name:J.string(),url:J.string()}),Qs=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),args:J.array(J.string()),command:J.string(),env:J.array(Ls),name:J.string()}),$s=J.union([Xs.and(J.object({type:J.literal(`http`)})),Zs.and(J.object({type:J.literal(`sse`)})),Qs]),ec=J.string(),tc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string().nullish(),modelId:ec,name:J.string()}),nc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cwd:J.string(),mcpServers:J.array($s)}),rc=J.string(),ic=J.union([J.literal(`allow_once`),J.literal(`allow_always`),J.literal(`reject_once`),J.literal(`reject_always`)]),ac=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),kind:ic,name:J.string(),optionId:rc}),oc=J.union([J.literal(`high`),J.literal(`medium`),J.literal(`low`)]),sc=J.union([J.literal(`pending`),J.literal(`in_progress`),J.literal(`completed`)]),cc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:J.string(),priority:oc,status:sc}),lc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),entries:J.array(cc)}),uc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),audio:J.boolean().optional().default(!1),embeddedContext:J.boolean().optional().default(!1),image:J.boolean().optional().default(!1)}),dc=J.number().int().gte(0).lte(65535),fc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),clientCapabilities:Ws.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Ks.nullish(),protocolVersion:dc}),pc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:J.string()}),mc=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),hc=J.union([J.number(),J.string()]).nullable();J.object({_meta:J.record(J.string(),J.unknown()).nullish(),requestId:hc});const gc=J.enum([`assistant`,`user`]),_c=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),audience:J.array(gc).nullish(),lastModified:J.string().nullish(),priority:J.number().nullish()}),vc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),annotations:_c.nullish(),data:J.string(),mimeType:J.string()}),yc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),annotations:_c.nullish(),data:J.string(),mimeType:J.string(),uri:J.string().nullish()}),bc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),annotations:_c.nullish(),description:J.string().nullish(),mimeType:J.string().nullish(),name:J.string(),size:J.number().nullish(),title:J.string().nullish(),uri:J.string()}),xc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),optionId:rc}),Sc=J.union([J.object({outcome:J.literal(`cancelled`)}),xc.and(J.object({outcome:J.literal(`selected`)}))]),Cc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),outcome:Sc}),wc=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Tc=J.object({currentValue:J.boolean()}),Ec=J.string(),Dc=J.string(),Oc=J.union([J.literal(`mode`),J.literal(`model`),J.literal(`thought_level`),J.string()]),kc=J.string(),Ac=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string().nullish(),name:J.string(),value:kc}),jc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),group:Ec,name:J.string(),options:J.array(Ac)}),Mc=J.union([J.array(Ac),J.array(jc)]),Nc=J.object({currentValue:kc,options:Mc}),Pc=J.intersection(J.union([Nc.and(J.object({type:J.literal(`select`)})),Tc.and(J.object({type:J.literal(`boolean`)}))]),J.object({_meta:J.record(J.string(),J.unknown()).nullish(),category:Oc.nullish(),description:J.string().nullish(),id:Dc,name:J.string()})),Fc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc)}),Ic=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Lc=J.string(),Rc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc});J.object({method:J.string(),params:J.union([Rc,Bs]).nullish()});const zc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc}),Bc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),args:J.array(J.string()).optional(),command:J.string(),cwd:J.string().nullish(),env:J.array(Ls).optional(),outputByteLimit:J.number().nullish(),sessionId:Lc}),Vc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cwd:J.string(),mcpServers:J.array($s).optional(),sessionId:Lc}),Hc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc,terminalId:J.string()}),Uc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cwd:J.string(),mcpServers:J.array($s),sessionId:Lc}),Wc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),limit:J.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:J.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:J.string(),sessionId:Lc}),Gc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc,terminalId:J.string()}),Kc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cwd:J.string(),mcpServers:J.array($s).optional(),sessionId:Lc}),qc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cwd:J.string(),sessionId:Lc,title:J.string().nullish(),updatedAt:J.string().nullish()}),Jc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),nextCursor:J.string().nullish(),sessions:J.array(qc)}),Yc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),title:J.string().nullish(),updatedAt:J.string().nullish()}),Xc=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),Zc=J.string(),Qc=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),currentModeId:Zc}),$c=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string().nullish(),id:Zc,name:J.string()}),el=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),availableModes:J.array($c),currentModeId:Zc}),tl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),availableModels:J.array(tc),currentModelId:ec}),nl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc).nullish(),models:tl.nullish(),modes:el.nullish(),sessionId:Lc}),rl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc).nullish(),models:tl.nullish(),modes:el.nullish()}),il=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc).nullish(),models:tl.nullish(),modes:el.nullish(),sessionId:Lc}),al=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc).nullish(),models:tl.nullish(),modes:el.nullish()}),ol=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),sl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),close:wc.nullish(),fork:Ic.nullish(),list:Xc.nullish(),resume:ol.nullish()}),cl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),loadSession:J.boolean().optional().default(!1),mcpCapabilities:Ys.optional().default({http:!1,sse:!1}),promptCapabilities:uc.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:sl.optional().default({})}),ll=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),agentCapabilities:cl.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Ks.nullish(),authMethods:J.array(ks).optional().default([]),protocolVersion:dc}),ul=J.intersection(J.union([J.object({type:J.literal(`boolean`),value:J.boolean()}),J.object({value:kc})]),J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configId:Dc,sessionId:Lc})),dl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),configOptions:J.array(Pc)}),fl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),modeId:Zc,sessionId:Lc}),pl=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),ml=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),modelId:ec,sessionId:Lc}),hl=J.object({_meta:J.record(J.string(),J.unknown()).nullish()}),gl=J.union([J.literal(`end_turn`),J.literal(`max_tokens`),J.literal(`max_turn_requests`),J.literal(`refusal`),J.literal(`cancelled`)]),_l=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),terminalId:J.string()}),vl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),exitCode:J.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:J.string().nullish()}),yl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc,terminalId:J.string()}),bl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),exitStatus:vl.nullish(),output:J.string(),truncated:J.boolean()}),xl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),annotations:_c.nullish(),text:J.string()}),Sl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),mimeType:J.string().nullish(),text:J.string(),uri:J.string()}),Cl=J.union([Sl,Ms]),wl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),annotations:_c.nullish(),resource:Cl}),Tl=J.union([xl.and(J.object({type:J.literal(`text`)})),yc.and(J.object({type:J.literal(`image`)})),vc.and(J.object({type:J.literal(`audio`)})),bc.and(J.object({type:J.literal(`resource_link`)})),wl.and(J.object({type:J.literal(`resource`)}))]),El=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:Tl}),Dl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:Tl,messageId:J.string().nullish()}),Ol=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),messageId:J.string().nullish(),prompt:J.array(Tl),sessionId:Lc});J.object({id:hc,method:J.string(),params:J.union([fc,As,nc,Uc,Js,Vc,Kc,zc,fl,ul,Ol,ml,Vs]).nullish()});const kl=J.union([El.and(J.object({type:J.literal(`content`)})),Is.and(J.object({type:J.literal(`diff`)})),_l.and(J.object({type:J.literal(`terminal`)}))]),Al=J.string(),jl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),line:J.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:J.string()}),Ml=J.union([J.literal(`pending`),J.literal(`in_progress`),J.literal(`completed`),J.literal(`failed`)]),Nl=J.union([J.literal(`read`),J.literal(`edit`),J.literal(`delete`),J.literal(`move`),J.literal(`search`),J.literal(`execute`),J.literal(`think`),J.literal(`fetch`),J.literal(`switch_mode`),J.literal(`other`)]),Pl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:J.array(kl).optional(),kind:Nl.optional(),locations:J.array(jl).optional(),rawInput:J.unknown().optional(),rawOutput:J.unknown().optional(),status:Ml.optional(),title:J.string(),toolCallId:Al}),Fl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:J.array(kl).nullish(),kind:Nl.nullish(),locations:J.array(jl).nullish(),rawInput:J.unknown().optional(),rawOutput:J.unknown().optional(),status:Ml.nullish(),title:J.string().nullish(),toolCallId:Al}),Il=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),options:J.array(ac),sessionId:Lc,toolCall:Fl}),Ll=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),hint:J.string()}),Rl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),description:J.string(),input:Ll.nullish(),name:J.string()}),zl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),availableCommands:J.array(Rl)}),Bl=J.object({cachedReadTokens:J.number().nullish(),cachedWriteTokens:J.number().nullish(),inputTokens:J.number(),outputTokens:J.number(),thoughtTokens:J.number().nullish(),totalTokens:J.number()}),Vl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),stopReason:gl,usage:Bl.nullish(),userMessageId:J.string().nullish()});J.union([J.object({id:hc,result:J.union([ll,js,il,rl,Jc,nl,al,Ns,pl,dl,Vl,hl,Hs])}),J.object({error:zs,id:hc})]);const Hl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),cost:Ps.nullish(),size:J.number(),used:J.number()}),Ul=J.union([Dl.and(J.object({sessionUpdate:J.literal(`user_message_chunk`)})),Dl.and(J.object({sessionUpdate:J.literal(`agent_message_chunk`)})),Dl.and(J.object({sessionUpdate:J.literal(`agent_thought_chunk`)})),Pl.and(J.object({sessionUpdate:J.literal(`tool_call`)})),Fl.and(J.object({sessionUpdate:J.literal(`tool_call_update`)})),lc.and(J.object({sessionUpdate:J.literal(`plan`)})),zl.and(J.object({sessionUpdate:J.literal(`available_commands_update`)})),Qc.and(J.object({sessionUpdate:J.literal(`current_mode_update`)})),Fc.and(J.object({sessionUpdate:J.literal(`config_option_update`)})),Yc.and(J.object({sessionUpdate:J.literal(`session_info_update`)})),Hl.and(J.object({sessionUpdate:J.literal(`usage_update`)}))]),Wl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc,update:Ul});J.object({method:J.string(),params:J.union([Wl,Bs]).nullish()});const Gl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),sessionId:Lc,terminalId:J.string()}),Kl=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),exitCode:J.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:J.string().nullish()}),ql=J.object({_meta:J.record(J.string(),J.unknown()).nullish(),content:J.string(),path:J.string(),sessionId:Lc});J.object({id:hc,method:J.string(),params:J.union([ql,Wc,Il,Bc,yl,Gc,Gl,Hc,Vs]).nullish()});const Jl=J.object({_meta:J.record(J.string(),J.unknown()).nullish()});J.union([J.object({id:hc,result:J.union([Jl,pc,Cc,Fs,bl,mc,Kl,qs,Hs])}),J.object({error:zs,id:hc})]);function Yl(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a)break;if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
|
|
2
|
+
import{n as e,r as t,t as n}from"./chunk-wdO_pP5q.js";import{$ as r,$i as i,$n as a,$r as o,$t as s,Ai as c,An as l,Ar as u,At as d,B as f,Bi as p,Bn as m,Br as h,Bt as g,C as _,Ci as v,Cn as y,Cr as b,Ct as x,D as ee,Di as S,Dn as C,Dr as w,Dt as T,E,Ei as D,En as O,Er as te,Et as ne,F as k,Fi as A,Fn as j,Fr as re,Ft as M,G as ie,Gi as ae,Gn as N,Gr as oe,Gt as se,H as P,Hi as ce,Hn as le,Ht as ue,I as de,Ii as F,Ir as fe,It as pe,J as me,Ji as he,Jn as ge,Jr as _e,Jt as ve,K as I,Ki as ye,Kn as be,Kt as xe,L as Se,Li as Ce,Ln as we,Lr as Te,Lt as Ee,M as De,Mi as Oe,Mn as ke,Mr as Ae,Mt as je,N as Me,Ni as Ne,Nn as Pe,Nr as Fe,Nt as Ie,O as Le,Oi as Re,On as ze,Or as Be,Ot as Ve,P as He,Pi as Ue,Pn as L,Pr as We,Pt as Ge,Q as Ke,Qi as qe,Qn as Je,Qr as Ye,Qt as Xe,R as Ze,Ri as Qe,Rn as $e,Rr as et,Rt as tt,Si as nt,Sn as rt,Sr as it,St as at,T as ot,Ti as st,Tn as ct,Tr as lt,Tt as ut,U as dt,Ui as ft,Un as pt,Ur as mt,Ut as ht,V as gt,Vi as _t,Vn as vt,Vt as yt,W as bt,Wi as xt,Wn as St,Wr as Ct,Wt as wt,X as Tt,Xi as Et,Xn as Dt,Xr as Ot,Xt as kt,Y as At,Yi as jt,Yn as Mt,Yr as Nt,Yt as Pt,Z as Ft,Zi as It,Zn as Lt,Zr as Rt,Zt as zt,_ as Bt,_i as Vt,_n as Ht,_r as Ut,_t as Wt,a as Gt,aa as Kt,ai as qt,an as Jt,ar as Yt,at as Xt,bi as Zt,bn as R,br as Qt,bt as $t,c as en,ci as tn,cn as nn,cr as rn,ct as z,d as an,di as on,dn as sn,dr as cn,dt as ln,ea as un,ei as dn,en as fn,er as B,et as pn,f as mn,fi as hn,fn as V,fr as gn,ft as _n,g as vn,gi as yn,gn as bn,gr as xn,gt as Sn,h as Cn,hi as wn,hn as Tn,hr as En,ht as Dn,i as On,ia as kn,ii as An,in as jn,ir as Mn,it as Nn,j as Pn,ji as Fn,jn as In,jr as Ln,jt as Rn,k as zn,ki as Bn,kn as Vn,kr as Hn,kt as Un,l as Wn,li as Gn,ln as Kn,lr as qn,lt as Jn,m as Yn,mi as Xn,mn as Zn,mr as Qn,mt as $n,na as er,ni as tr,nn as nr,nr as rr,nt as ir,o as ar,on as or,or as sr,ot as cr,p as lr,pi as ur,pn as dr,pr as fr,pt as pr,q as mr,qi as hr,qn as gr,qr as _r,qt as vr,ra as yr,ri as br,rn as xr,rr as Sr,rt as H,s as Cr,si as wr,sn as Tr,sr as Er,st as Dr,ta as Or,ti as kr,tn as Ar,tr as jr,tt as Mr,u as Nr,ui as Pr,un as Fr,ur as Ir,ut as Lr,v as Rr,vi as zr,vn as Br,vr as Vr,vt as Hr,wi as Ur,wn as Wr,wr as Gr,wt as Kr,x as qr,xi as Jr,xn as Yr,xr as Xr,xt as Zr,y as Qr,yi as $r,yn as ei,yr as ti,yt as ni,z as ri,zi as ii,zn as ai,zr as oi,zt as si}from"./server-DsSVRZK1.js";import{createRequire as ci}from"node:module";import{Command as li}from"commander";import{Box as U,Static as ui,Text as W,render as di,useInput as fi,useStdout as pi}from"ink";import{QueryClient as mi,QueryClientProvider as hi,useMutation as gi,useQuery as _i}from"@tanstack/react-query";import{c as vi}from"react/compiler-runtime";import{createContext as yi,useCallback as bi,useContext as xi,useEffect as Si,useMemo as Ci,useRef as wi,useState as G}from"react";import{Fragment as Ti,jsx as K,jsxs as q}from"react/jsx-runtime";import J from"figures";import Ei from"picocolors";import*as Di from"node:path";import Oi,{join as ki,normalize as Ai}from"node:path";import*as ji from"node:url";import{fileURLToPath as Mi,pathToFileURL as Ni}from"node:url";import{z as Pi}from"zod";import{z as Y}from"zod/v4";import{NodeFileSystem as Fi,NodeServices as Ii}from"@effect/platform-node";import*as Li from"node:child_process";import{exec as Ri,execFile as zi,execSync as Bi}from"node:child_process";import*as Vi from"node:crypto";import{createHash as Hi}from"node:crypto";import{Buffer as Ui}from"node:buffer";import{execSync as Wi,spawn as Gi}from"child_process";import{EventEmitter as Ki}from"node:events";import*as qi from"node:os";import{platform as Ji}from"node:os";import{request as Yi}from"node:http";import*as Xi from"node:fs/promises";import*as Zi from"node:fs";import{createReadStream as Qi}from"node:fs";import $i from"ink-spinner";import ea from"cli-truncate";import ta from"string-width";import{create as na}from"zustand";import{dirname as ra,posix as ia,sep as aa}from"path";import{createInterface as oa}from"node:readline";import{AsyncLocalStorage as sa}from"node:async_hooks";import{createJSONStorage as ca,persist as la}from"zustand/middleware";import{RegistryProvider as ua,useAtom as da,useAtomSet as fa,useAtomValue as pa}from"@effect/atom-react";import ma from"pretty-ms";import{detectTerminal as ha}from"detect-terminal";import ga from"supports-terminal-graphics";import _a from"ink-link";import{Hono as va}from"hono";import{proxy as ya}from"hono/proxy";import{serve as ba}from"@hono/node-server";import"node-notifier";import xa from"prompts";import Sa from"ora";const Ca=e=>()=>{let t=$t(Mr(e));return T((e,n)=>B(ei(e,e=>t(e))))},wa=e=>()=>{let t=Wt(Mr(e));return T((e,n)=>B(ei(e,e=>t(e))))},Ta=Or(2,(e,t)=>Ca(t.inputSchema)().pipe(d(e),d(wa(t.outputSchema)()))),Ea=`~effect/FiberMap`,Da=e=>jt(e,Ea),Oa={[Ea]:Ea,[Symbol.iterator](){return this.state._tag===`Closed`?S():this.state.backing[Symbol.iterator]()},...p,toJSON(){return{_id:`FiberMap`,state:this.state}}},ka=(e,t)=>{let n=Object.create(Oa);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Aa=()=>Ar(rr(()=>ka(vr(),h())),e=>jr(()=>{let t=e.state;return t._tag===`Closed`?gn:(e.state={_tag:`Closed`},wt(Xe(t.backing)).pipe(et(e.deferred)))})),ja=wn(ur(Ot,Xn(-1))),Ma=Or(e=>Da(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(-1);return}let i=ve(e.state.backing,t);if(i._tag===`Some`){if(r?.onlyIfMissing===!0){n.interruptUnsafe(-1);return}else if(i.value===n)return;i.value.interruptUnsafe(-1)}zt(e.state.backing,t,n),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=ve(e.state.backing,t);A(a)&&n===a.value&&kt(e.state.backing,t),Ct(i)&&(r?.propagateInterruption===!0?!ja(i.cause):!o(i.cause))&&Te(e.deferred,i)})}),Na=Or(2,(e,t)=>e.state._tag===`Closed`?!1:Pt(e.state.backing,t)),Pa=function(){let e;return()=>(e===void 0&&(e=pt(ze)),e)}(),Fa=function(){let e=arguments[0];if(Vn(arguments[2]))return Ia(e,arguments[1],arguments[2],arguments[3]);let t=arguments[1],n=arguments[2];return r=>Ia(e,t,r,n)},Ia=(e,t,n,r)=>Qn(i=>{if(e.state._tag===`Closed`)return ze;if(r?.onlyIfMissing===!0&&Na(e,t))return rr(Pa);let a=St(i.services)(n);return Ma(e,t,a,r),B(a)});var La=class extends tn()(`effect/reactivity/Reactivity`){};const Ra=rr(()=>{let e=new Map,t=t=>{Wa(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>a(n=>{let r=n.mapUnsafe.get(za.key);return r?Wa(e,e=>{r.add(e)}):t(e),gn}),r=(e,t)=>Sr(t,n(e)),i=(t,n)=>{let r=[];return Wa(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},o=(e,t)=>O(function*(){let n=yield*Je(),r=on(n,Ln),a=yield*pe(),o=er(St(n),xe(r)),s=!1,c=!1,l=e=>{e._tag===`Failure`?M(a,e.cause):tt(a,e.value),c?(c=!1,o(t).addObserver(l)):s=!1};function u(){if(s){c=!0;return}s=!0,o(t).addObserver(l)}return yield*Ae(r,rr(i(e,u))),u(),a});return La.of({mutation:r,query:o,stream:(e,t)=>o(e,t).pipe(L(E),bt),invalidateUnsafe:t,invalidate:n,registerUnsafe:i,withBatch:t=>jr(()=>{let n=new Set;return t.pipe(vt(za,n),we(t=>rr(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})});var za=class extends tn()(`effect/reactivity/Reactivity/PendingInvalidation`){};const Ba=Or(2,(e,t)=>La.use(n=>n.mutation(t,e))),Va=e=>La.use(t=>t.invalidate(e)),Ha=b(La)(Ra);function Ua(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return xt(e)}}const Wa=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Ua(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Ua(r[e])}`)}},Ga=e=>jt(e,`~effect/SubscriptionRef`);({...p});const Ka=e=>ot(e.pubsub),qa=e=>rr(()=>e.value),Ja=(e,t)=>{e.value=t,yt(e.pubsub,t)},Ya=Or(2,(e,t)=>e.semaphore.withPermit(rr(()=>Ja(e,t)))),Xa=`0.0.7`,Za=`\x1B[?1049l`,Qa=process.env.SUPPORT_CLICK===`true`||process.env.SUPPORT_CLICK===`1`,$a=[`lint`,`check`,`format`,`typecheck`,`type-check`],eo={"pnpm-lock.yaml":`pnpm`,"pnpm-workspace.yaml":`pnpm`,"yarn.lock":`yarn`,"package-lock.json":`npm`,"npm-shrinkwrap.json":`npm`,"bun.lock":`bun`,"bun.lockb":`bun`,"deno.lock":`deno`},to=()=>{},no=yi({subscribeClick:()=>to}),ro=/\x1b\[<(\d+);(\d+);(\d+)([Mm])|\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\d+;\d+R|\[\?[\d;]+[a-z]/g,io=({children:e})=>{if(!Qa)return K(Ti,{children:e});let t=wi(new Set),n=wi(!1);if(!n.current){n.current=!0,process.stdout.write(`\x1B[?1003l\x1B[?1002l\x1B[?1000h\x1B[?1006h`);let e=process.stdin.emit.bind(process.stdin);process.stdin.emit=function(n,...r){if(n===`data`){let i=(typeof r[0]==`string`?r[0]:String(r[0])).replace(ro,(e,n,r,i,a)=>{if(n===`0`)for(let e of t.current)e({x:Number(r),y:Number(i)},a===`M`?`press`:`release`);return``});return i.length===0?!0:e(n,i)}return e(n,...r)}}let r=bi(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]);return K(no.Provider,{value:{subscribeClick:r},children:e})},ao=()=>{let e=vi(1);if(e[0]!==`35703fbc37b9d963e330527161df9fe36b70875a77771f1d737994ab88cecbb3`){for(let t=0;t<1;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`35703fbc37b9d963e330527161df9fe36b70875a77771f1d737994ab88cecbb3`}return xi(no)},oo=/\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\?[\d;]+[a-z]|\[\d+;\d+R/g,so=e=>Qa?e.replace(oo,``):e,co=e=>e&&e>0?e:80,lo=e=>e&&e>0?e:24,uo=()=>{let{stdout:e}=pi(),[t,n]=G([co(e.columns),lo(e.rows)]),r=wi(!1);return r.current||(r.current=!0,e.on(`resize`,()=>n([co(e.columns),lo(e.rows)]))),t},fo={primary:`whiteBright`,secondary:`gray`,accent:`white`,error:`red`,warning:`yellow`,success:`green`,info:`gray`,text:`white`,textMuted:`gray`,border:`gray`,borderActive:`white`,borderSubtle:`blackBright`,shimmerBase:`#555555`,shimmerHighlight:`#ffffff`,inputBg:`#1e1e1e`,bannerBg:`#332b00`,errorBg:`#330b0b`},po={TEXT:fo.text,DIM:fo.textMuted,GREEN:fo.success,PRIMARY:fo.primary,SELECTION:fo.accent,RED:fo.error,BORDER:fo.border,DIVIDER:fo.borderSubtle,YELLOW:fo.warning,PURPLE:fo.secondary,CYAN:fo.info,INPUT_BG:fo.inputBg,BANNER_BG:fo.bannerBg,ERROR_BG:fo.errorBg},mo=()=>po,ho=e=>{let t=vi(21);if(t[0]!==`c91257771a99332d5805ee6c49b36d74b00fa9357a1ef3353879ee4c78179ae7`){for(let e=0;e<21;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`c91257771a99332d5805ee6c49b36d74b00fa9357a1ef3353879ee4c78179ae7`}let{color:n,children:r,marginTop:i,marginBottom:a,paddingX:o,ref:s}=e,c=o===void 0?1:o,[l]=uo(),u;t[1]===l?u=t[2]:(u=`─`.repeat(l),t[1]=l,t[2]=u);let d;t[3]!==n||t[4]!==u?(d=K(W,{color:n,wrap:`truncate`,children:u}),t[3]=n,t[4]=u,t[5]=d):d=t[5];let f;t[6]!==r||t[7]!==c?(f=K(U,{flexDirection:`column`,paddingX:c,children:r}),t[6]=r,t[7]=c,t[8]=f):f=t[8];let p;t[9]===l?p=t[10]:(p=`─`.repeat(l),t[9]=l,t[10]=p);let m;t[11]!==n||t[12]!==p?(m=K(W,{color:n,wrap:`truncate`,children:p}),t[11]=n,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==f||t[19]!==m?(h=q(U,{flexDirection:`column`,width:`100%`,marginTop:i,marginBottom:a,ref:s,children:[d,f,m]}),t[14]=a,t[15]=i,t[16]=s,t[17]=d,t[18]=f,t[19]=m,t[20]=h):h=t[20],h},go=e=>{let t=e,n=1,r=1;for(;t;){if(!t.yogaNode)return{left:n,top:r};let e=t.yogaNode.getComputedLayout();n+=e.left,r+=e.top,t=t.parentNode}return{left:n,top:r}},_o=({onClick:e,children:t,fullWidth:n=!0})=>{let{subscribeClick:r}=ao(),i=wi(e);return i.current=e,K(U,{ref:bi(e=>{if(e)return r((t,n)=>{if(n!==`press`||!e.yogaNode)return;let r=go(e),a=e.yogaNode.getComputedLayout(),o=t.x<r.left||t.x>=r.left+a.width,s=t.y<r.top||t.y>=r.top+a.height;!o&&!s&&i.current?.()})},[r]),width:n?`100%`:void 0,children:t})},vo=e=>/\w/.test(e),yo=(e,t)=>{let n=t-1;for(;n>0&&!vo(e[n]);)n--;for(;n>0&&vo(e[n-1]);)n--;return n},bo=(e,t)=>{let n=t;for(;n<e.length&&vo(e[n]);)n++;for(;n<e.length&&!vo(e[n]);)n++;return n},xo=(e,t)=>{let n=e.split(`
|
|
3
|
+
`),r=0;for(let e=0;e<n.length;e++){let i=n[e].length;if(t<=r+i)return{lineIndex:e,column:t-r,lines:n};r+=i+1}let i=n.length-1;return{lineIndex:i,column:n[i].length,lines:n}},So=(e,t,n)=>{let r=0;for(let n=0;n<t;n++)r+=e[n].length+1;return r+Math.min(n,e[t].length)},Co=({value:e,placeholder:t=``,focus:n=!0,mask:r,highlightPastedText:i=!1,showCursor:a=!0,multiline:o=!1,onChange:s,onSubmit:c,onUpArrowAtTop:l,onDownArrowAtBottom:u})=>{let[d,f]=G({cursorOffset:(e||``).length,cursorWidth:0}),{cursorOffset:p,cursorWidth:m}=d,h=wi({originalValue:e,focus:n,showCursor:a});(h.current.originalValue!==e||h.current.focus!==n||h.current.showCursor!==a)&&(h.current={originalValue:e,focus:n,showCursor:a},f(t=>{if(!n||!a)return t;let r=e||``;return t.cursorOffset>r.length-1?{cursorOffset:r.length,cursorWidth:0}:t}));let g=i?m:0,_=r?r.repeat(e.length):e,v=_,y=t?Ei.gray(t):void 0;if(a&&n){y=t.length>0?Ei.inverse(t[0])+Ei.gray(t.slice(1)):Ei.inverse(` `),v=_.length>0?``:Ei.inverse(` `);let e=0;for(let t of _){let n=e>=p-g&&e<=p;n&&t===`
|
|
4
|
+
`?v+=Ei.inverse(` `)+`
|
|
5
|
+
`:v+=n?Ei.inverse(t):t,e++}_.length>0&&p===_.length&&(v+=Ei.inverse(` `))}return fi((t,n)=>{if(!o&&(n.upArrow||n.downArrow)||n.ctrl&&t===`c`||n.tab||n.shift&&n.tab)return;let r=p,i=e,d=0,m=!1;if(o&&n.upArrow&&a){let{lineIndex:t,column:n,lines:i}=xo(e,p);t>0?r=So(i,t-1,n):l?.(),m=!0}else if(o&&n.downArrow&&a){let{lineIndex:t,column:n,lines:i}=xo(e,p);t<i.length-1?r=So(i,t+1,n):u?.(),m=!0}else if(n.ctrl&&t===`a`&&a)r=0,m=!0;else if(n.ctrl&&t===`e`&&a)r=e.length,m=!0;else if(n.ctrl&&t===`f`&&a)r=p+1,m=!0;else if(n.ctrl&&t===`b`&&a)r=p-1,m=!0;else if(n.ctrl&&t===`k`)i=e.slice(0,p),m=!0;else if(n.ctrl&&t===`u`)p>0&&(i=e.slice(p),r=0),m=!0;else if(n.ctrl&&t===`w`){if(p>0){let t=yo(e,p);i=e.slice(0,t)+e.slice(p),r=t}m=!0}else if(n.ctrl&&t===`d`)p<e.length&&(i=e.slice(0,p)+e.slice(p+1)),m=!0;else if(n.ctrl&&t===`t`)p>0&&p<e.length&&(i=e.slice(0,p-1)+e[p]+e[p-1]+e.slice(p+1),r=p+1),m=!0;else if(n.meta&&t===`b`&&a)r=yo(e,p),m=!0;else if(n.meta&&t===`f`&&a)r=bo(e,p),m=!0;else if(n.meta&&(n.backspace||n.delete)){if(p>0){let t=yo(e,p);i=e.slice(0,t)+e.slice(p),r=t}m=!0}else if(n.meta)return;if(!m)if(n.return)if(o&&n.shift)i=e.slice(0,p)+`
|
|
6
|
+
`+e.slice(p),r++;else{c&&c(e);return}else n.leftArrow?a&&r--:n.rightArrow?a&&r++:n.backspace||n.delete?p>0&&(i=e.slice(0,p-1)+e.slice(p,e.length),r--):(i=e.slice(0,p)+t+e.slice(p,e.length),r+=t.length,t.length>1&&(d=t.length));r<0&&(r=0),r>i.length&&(r=i.length),f({cursorOffset:r,cursorWidth:d}),i!==e&&s(i)},{isActive:n}),K(W,{children:t?_.length>0?v:y:v})},wo=e=>{let t=vi(13);if(t[0]!==`ed5db14495474995e96712c30462d38da6b6aa36bffcbec475f62d8824e8125d`){for(let e=0;e<13;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`ed5db14495474995e96712c30462d38da6b6aa36bffcbec475f62d8824e8125d`}let{isSearching:n,query:r,onChange:i,onSubmit:a}=e,o=mo();if(n){let e;t[1]===o.DIM?e=t[2]:(e=K(W,{color:o.DIM,children:`/`}),t[1]=o.DIM,t[2]=e);let n;t[3]!==i||t[4]!==a||t[5]!==r?(n=K(Co,{focus:!0,value:r,onChange:i,onSubmit:a}),t[3]=i,t[4]=a,t[5]=r,t[6]=n):n=t[6];let s;return t[7]!==e||t[8]!==n?(s=q(U,{marginTop:1,children:[e,n]}),t[7]=e,t[8]=n,t[9]=s):s=t[9],s}if(r){let e;return t[10]!==o.DIM||t[11]!==r?(e=K(U,{marginTop:1,children:q(W,{color:o.DIM,children:[`/`,r]})}),t[10]=o.DIM,t[11]=r,t[12]=e):e=t[12],e}return null},To=pn([`pending`,`in_progress`,`completed`,`failed`]),Eo=pn([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);pn([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const Do=$n([Jn({type:r(`text`),text:z}),Jn({type:r(`image`),data:z,mimeType:z}),Jn({type:r(`resource_link`),uri:z}),Jn({type:r(`resource`),uri:z})]),Oo=$n([Jn({type:r(`content`),content:Do}),Jn({type:r(`diff`),path:z,oldText:at(ir(z)),newText:at(ir(z))}),Jn({type:r(`terminal`),terminalId:z})]),ko=Jn({path:z,lineNumber:at(ir(H))});var Ao=class extends At(`AcpAgentMessageChunk`)({sessionUpdate:r(`agent_message_chunk`),content:Do,messageId:at(ir(z))}){},jo=class extends At(`AcpAgentThoughtChunk`)({sessionUpdate:r(`agent_thought_chunk`),content:Do,messageId:at(ir(z))}){},Mo=class extends At(`AcpUserMessageChunk`)({sessionUpdate:r(`user_message_chunk`),content:Do,messageId:at(ir(z))}){},No=class extends At(`AcpToolCall`)({sessionUpdate:r(`tool_call`),toolCallId:z,title:z,kind:at(Eo),status:at(To),content:at(I(Oo)),locations:at(I(ko)),rawInput:at(Dn),rawOutput:at(Dn)}){},Po=class extends At(`AcpToolCallUpdate`)({sessionUpdate:r(`tool_call_update`),toolCallId:z,title:at(ir(z)),kind:at(ir(Eo)),status:at(ir(To)),content:at(ir(I(Oo))),locations:at(ir(I(ko))),rawInput:at(Dn),rawOutput:at(Dn)}){};const Fo=pn([`pending`,`in_progress`,`completed`]),Io=pn([`high`,`medium`,`low`]),Lo=$n([Ao,jo,Mo,No,Po,class extends At(`AcpPlanUpdate`)({sessionUpdate:r(`plan`),entries:I(Jn({content:z,priority:Io,status:Fo}))}){},class extends At(`AcpAvailableCommandsUpdate`)({sessionUpdate:r(`available_commands_update`)}){},class extends At(`AcpCurrentModeUpdate`)({sessionUpdate:r(`current_mode_update`)}){},class extends At(`AcpConfigOptionUpdate`)({sessionUpdate:r(`config_option_update`)}){},class extends At(`AcpSessionInfoUpdate`)({sessionUpdate:r(`session_info_update`)}){},class extends At(`AcpUsageUpdate`)({sessionUpdate:r(`usage_update`)}){}]);Jn({inputTokens:H,outputTokens:H,cachedReadTokens:at(ir(H)),cachedWriteTokens:at(ir(H)),thoughtTokens:at(ir(H))});const Ro=pn([`claude`,`codex`,`cursor`]);var zo=class extends At(`@ami/FileStat`)({relativePath:z,added:H,removed:H}){},Bo=class extends At(`@supervisor/GitState`)({isGitRepo:me,currentBranch:z,mainBranch:pr(z),isOnMain:me,hasChangesFromMain:me,hasUnstagedChanges:me,hasBranchCommits:me,branchCommitCount:H,fileStats:I(zo),workingTreeFileStats:I(zo),fingerprint:pr(z),savedFingerprint:pr(z)}){get hasUntestedChanges(){return this.hasChangesFromMain||this.hasUnstagedChanges}get totalChangedLines(){return this.fileStats.reduce((e,t)=>e+t.added+t.removed,0)}get isCurrentStateTested(){return!this.fingerprint||!this.savedFingerprint?!1:this.fingerprint===this.savedFingerprint}};const Vo=z.pipe(Sn(`StepId`)),Ho=z.pipe(Sn(`PlanId`)),Uo=ln({WorkingTree:{},Branch:{mainBranch:z},Changes:{mainBranch:z},Commit:{hash:z}}),Wo=e=>Yn(e).pipe(lr({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),Go=Jn({number:H,headRefName:z,author:Jn({login:z}),state:z,updatedAt:z}),Ko=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var qo=class extends At(`@supervisor/RemoteBranch`)({name:z,author:z,prNumber:ir(H),prStatus:ir(pn([`open`,`draft`,`merged`])),updatedAt:ir(z)}){static filterBranches(e,t,n){let r=e.filter(e=>t===`recent`||t===`all`?!0:t===`no-pr`?e.prStatus===null:e.prStatus===t);if(n){let e=n.toLowerCase();r=r.filter(t=>t.name.toLowerCase().includes(e))}return t===`recent`&&(r=[...r].filter(e=>e.updatedAt!==null).sort((e,t)=>{let n=new Date(e.updatedAt??0).getTime();return new Date(t.updatedAt??0).getTime()-n})),r}};const Jo=pn([`pending`,`active`,`passed`,`failed`]);var Yo=class e extends At(`@supervisor/TestPlanStep`)({id:Vo,title:z,instruction:z,expectedOutcome:z,routeHint:Xt(z),status:Jo,summary:Xt(z),startedAt:Xt(Tt),endedAt:Xt(Tt)}){update(t){return new e({...this,...t})}},Xo=class extends At(`@supervisor/TestCoverageEntry`)({path:z,testFiles:I(z),covered:me}){},Zo=class extends At(`@supervisor/TestCoverageReport`)({entries:I(Xo),coveredCount:H,totalCount:H,percent:H}){};const Qo=z.pipe(Sn(`DraftId`));var $o=class e extends At(`@supervisor/TestPlanDraft`)({id:Qo,changesFor:Uo,currentBranch:z,diffPreview:z,fileStats:I(zo),instruction:z,baseUrl:Nn(z),isHeadless:me,requiresCookies:me,testCoverage:Nn(Zo)}){update(t){return new e({...this,...t})}},es=class e extends $o.extend(`@supervisor/TestPlan`)({id:Ho,title:z,rationale:z,steps:I(Yo)}){update(t){return new e({...this,...t})}updateStep(t,n){return new e({...this,steps:this.steps.map((e,r)=>r===t?n(e):e)})}get stepCount(){return this.steps.length}get resetForRerun(){return new e({...this,steps:this.steps.map(e=>new Yo({...e,status:`pending`,summary:Qe(),startedAt:Qe(),endedAt:Qe()}))})}},ts=class extends Lr()(`RunStarted`,{plan:es}){get id(){return`run-started-${this.plan.id}`}},ns=class extends Lr()(`StepStarted`,{stepId:Vo,title:z}){get id(){return`step-started-${this.stepId}`}},rs=class extends Lr()(`StepCompleted`,{stepId:Vo,summary:z}){get id(){return`step-completed-${this.stepId}`}},is=class extends Lr()(`StepFailed`,{stepId:Vo,message:z}){get id(){return`step-failed-${this.stepId}`}},as=class extends Lr()(`ToolCall`,{toolName:z,input:Dn}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return It(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},os=class extends Lr()(`ToolProgress`,{toolName:z,outputSize:H}){get id(){return`tool-progress-${this.toolName}-${this.outputSize}`}},ss=class extends Lr()(`ToolResult`,{toolName:z,result:z,isError:me}){get id(){return`tool-result-${this.toolName}-${this.result}`}},cs=class extends Lr()(`AgentThinking`,{text:z}){get id(){return`agent-thinking-${this.text}`}},ls=class extends Lr()(`AgentText`,{text:z}){get id(){return`agent-text-${this.text}`}},us=class extends Lr()(`RunFinished`,{status:pn([`passed`,`failed`]),summary:z}){get id(){return`run-finished-${this.status}`}};const ds=e=>{if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},fs=e=>{let t=e.indexOf(`|`);if(t===-1)return;let n=e.slice(0,t),r=e.slice(t+1),i=r.indexOf(`|`),a=i===-1?r:r.slice(0,i),o=i===-1?``:r.slice(i+1);if(n===`STEP_START`)return new ns({stepId:Vo.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new rs({stepId:Vo.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new is({stepId:Vo.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new us({status:a===`failed`?`failed`:`passed`,summary:o})},ps=$n([ts,ns,rs,is,as,os,ss,cs,ls,us]),ms=$n([ts,ns,rs,is,as,ss,cs,us,class extends Lr()(`RunCompleted`,{report:x(()=>ws)}){}]);var hs=class extends At(`@supervisor/Update`)({content:ms,receivedAt:Tt}){},gs=class extends At(`@supervisor/PullRequest`)({number:H,url:z,title:z,headRefName:z}){};const _s=ln({WorkingTree:{},Branch:{branch:qo},PullRequest:{branch:qo},Commit:{hash:z,shortHash:z,subject:z}}),vs=e=>Yn(e).pipe(lr({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),ys=e=>Yn(e).pipe(lr({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),bs=e=>Yn(e).pipe(lr({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),xs=e=>Yn(e).pipe(lr({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),Ss=e=>Yn(e).pipe(lr({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));ln({Branch:{branchName:z}});var Cs=class e extends es.extend(`@supervisor/ExecutedTestPlan`)({events:I(ps)}){addEvent(t){if(t.sessionUpdate===`agent_thought_chunk`){if(t.content.type!==`text`||t.content.text===void 0)return this;let n=this.finalizeTextBlock(),r=n.events.at(-1);return r?._tag===`AgentThinking`?new e({...n,events:[...n.events.slice(0,-1),new cs({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new cs({text:t.content.text})]})}if(t.sessionUpdate===`agent_message_chunk`){if(t.content.type!==`text`||t.content.text===void 0)return this;let n=this.events.at(-1);return n?._tag===`AgentText`?new e({...this,events:[...this.events.slice(0,-1),new ls({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new ls({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new as({toolName:t.title,input:JSON.stringify(t.rawInput??{})})]})}if(t.sessionUpdate===`tool_call_update`){let n=this;if(t.rawInput!==void 0){let r=[...n.events];for(let e=r.length-1;e>=0;e--){let n=r[e];if(n._tag===`ToolCall`&&n.toolName===(t.title??``)){r[e]=new as({toolName:n.toolName,input:JSON.stringify(t.rawInput)});break}}n=new e({...n,events:r})}if(t.status===`completed`||t.status===`failed`)return new e({...n,events:[...n.events,new ss({toolName:t.title??``,result:ds(t.rawOutput),isError:t.status===`failed`})]});if(t.rawOutput!==void 0){let r=ds(t.rawOutput).length;return new e({...n,events:[...n.events.filter(e=>!(e._tag===`ToolProgress`&&e.toolName===(t.title??``))),new os({toolName:t.title??``,outputSize:r})]})}return n}return this}finalizeTextBlock(){let t=this.events.at(-1);if(t?._tag!==`AgentText`)return this;let n=t.text.split(`
|
|
7
|
+
`).map(fs).filter(Et);if(n.length===0)return this;let r=new e({...this,events:[...this.events,...n]});for(let e of n)r=r.applyMarker(e);return r}applyMarker(t){return t._tag===`StepStarted`?this.steps.some(e=>e.id===t.stepId)?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`active`,title:t.title,startedAt:ii(s())}):e)}):new e({...this,steps:[...this.steps,new Yo({id:t.stepId,title:t.title,instruction:t.title,expectedOutcome:``,routeHint:Qe(),status:`active`,summary:Qe(),startedAt:ii(s()),endedAt:Qe()})]}):t._tag===`StepCompleted`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`passed`,summary:ii(t.summary),expectedOutcome:t.summary,endedAt:ii(s())}):e)}):t._tag===`StepFailed`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`failed`,summary:ii(t.message),expectedOutcome:t.message,endedAt:ii(s())}):e)}):this}get activeStep(){return this.steps.find(e=>e.status===`active`)}get completedStepCount(){return this.steps.filter(e=>e.status===`passed`||e.status===`failed`).length}get lastToolCallDisplayText(){let e=this.events.findLast(e=>e._tag===`ToolCall`);if(!(!e||e._tag!==`ToolCall`))return e.displayText}},ws=class extends Cs.extend(`@supervisor/TestReport`)({summary:z,screenshotPaths:I(z),pullRequest:Nn(x(()=>gs)),testCoverageReport:Nn(Zo)}){get stepStatuses(){let e=new Map(this.steps.map(e=>[e.id,{status:`not-run`,summary:``}]));for(let t of this.events)t._tag===`StepCompleted`?e.set(t.stepId,{status:`passed`,summary:t.summary}):t._tag===`StepFailed`&&e.set(t.stepId,{status:`failed`,summary:t.message});return e}get status(){let e=this.stepStatuses;for(let{status:t}of e.values())if(t===`failed`)return`failed`;return`passed`}get toPlainText(){let e=this.stepStatuses,t=this.steps.filter(t=>e.get(t.id)?.status===`passed`).length,n=this.steps.filter(t=>e.get(t.id)?.status===`failed`).length,r=[`${this.status===`passed`?`✅`:`❌`} ${this.title} \u2014 ${this.status.toUpperCase()}`,``,this.summary,``,`${t} passed, ${n} failed out of ${this.steps.length} steps`,``];for(let t of this.steps){let n=e.get(t.id),i=n?.status??`not-run`,a=i===`passed`?`✓`:i===`failed`?`✗`:`–`;r.push(` ${a} ${t.title}`),n?.summary&&r.push(` ${n.summary}`)}if(A(this.testCoverageReport)){let e=this.testCoverageReport.value;r.push(``),r.push(`Test coverage: ${e.percent}% (${e.coveredCount}/${e.totalCount} changed files have tests)`);let t=e.entries.filter(e=>!e.covered);if(t.length>0){r.push(` Untested files:`);for(let e of t)r.push(` - ${e.path}`)}}return r.join(`
|
|
8
|
+
`)}},Ts=class extends tn()(`@supervisor/Updates`,{make:O(function*(){let e=yield*ue();return{publish:R(`Updates.publish`)(function*(t){yield*g(e,new hs({content:t,receivedAt:s()}))}),stream:R(`Updates.stream`)(function*(){return ot(e)})}})}){static layer=b(this)(this.make)};const Es=Jn({name:z,value:z});var Ds=class extends At(`AgentStreamOptions`)({cwd:z,sessionId:Nn(z),prompt:z,systemPrompt:Nn(z),mcpEnv:at(I(Es))}){};const Os={authenticate:`authenticate`,initialize:`initialize`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},ks={fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},As=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),terminal:Y.boolean().optional().default(!1)}),js=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),label:Y.string().nullish(),name:Y.string(),optional:Y.boolean().optional().default(!1),secret:Y.boolean().optional().default(!0)}),Ms=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string().nullish(),id:Y.string(),name:Y.string()}),Ns=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string().nullish(),id:Y.string(),link:Y.string().nullish(),name:Y.string(),vars:Y.array(js)}),Ps=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),args:Y.array(Y.string()).optional(),description:Y.string().nullish(),env:Y.record(Y.string(),Y.string()).optional(),id:Y.string(),name:Y.string()}),Fs=Y.union([Ns.and(Y.object({type:Y.literal(`env_var`)})),Ps.and(Y.object({type:Y.literal(`terminal`)})),Ms]),Is=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),methodId:Y.string()}),Ls=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),Rs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),blob:Y.string(),mimeType:Y.string().nullish(),uri:Y.string()}),zs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),Bs=Y.object({amount:Y.number(),currency:Y.string()}),Vs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),terminalId:Y.string()}),Hs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),newText:Y.string(),oldText:Y.string().nullish(),path:Y.string()}),Us=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),name:Y.string(),value:Y.string()}),Ws=Y.union([Y.literal(-32700),Y.literal(-32600),Y.literal(-32601),Y.literal(-32602),Y.literal(-32603),Y.literal(-32800),Y.literal(-32e3),Y.literal(-32002),Y.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),Gs=Y.object({code:Ws,data:Y.unknown().optional(),message:Y.string()}),Ks=Y.unknown(),qs=Y.unknown(),Js=Y.unknown(),Ys=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),readTextFile:Y.boolean().optional().default(!1),writeTextFile:Y.boolean().optional().default(!1)}),Xs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),auth:As.optional().default({terminal:!1}),fs:Ys.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:Y.boolean().optional().default(!1)}),Zs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),name:Y.string(),value:Y.string()}),Qs=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),name:Y.string(),title:Y.string().nullish(),version:Y.string()}),$s=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),ec=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cursor:Y.string().nullish(),cwd:Y.string().nullish()}),tc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),http:Y.boolean().optional().default(!1),sse:Y.boolean().optional().default(!1)}),nc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),headers:Y.array(Zs),name:Y.string(),url:Y.string()}),rc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),headers:Y.array(Zs),name:Y.string(),url:Y.string()}),ic=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),args:Y.array(Y.string()),command:Y.string(),env:Y.array(Us),name:Y.string()}),ac=Y.union([nc.and(Y.object({type:Y.literal(`http`)})),rc.and(Y.object({type:Y.literal(`sse`)})),ic]),oc=Y.string(),sc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string().nullish(),modelId:oc,name:Y.string()}),cc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cwd:Y.string(),mcpServers:Y.array(ac)}),lc=Y.string(),uc=Y.union([Y.literal(`allow_once`),Y.literal(`allow_always`),Y.literal(`reject_once`),Y.literal(`reject_always`)]),dc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),kind:uc,name:Y.string(),optionId:lc}),fc=Y.union([Y.literal(`high`),Y.literal(`medium`),Y.literal(`low`)]),pc=Y.union([Y.literal(`pending`),Y.literal(`in_progress`),Y.literal(`completed`)]),mc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:Y.string(),priority:fc,status:pc}),hc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),entries:Y.array(mc)}),gc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),audio:Y.boolean().optional().default(!1),embeddedContext:Y.boolean().optional().default(!1),image:Y.boolean().optional().default(!1)}),_c=Y.number().int().gte(0).lte(65535),vc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),clientCapabilities:Xs.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Qs.nullish(),protocolVersion:_c}),yc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:Y.string()}),bc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),xc=Y.union([Y.number(),Y.string()]).nullable();Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),requestId:xc});const Sc=Y.enum([`assistant`,`user`]),Cc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),audience:Y.array(Sc).nullish(),lastModified:Y.string().nullish(),priority:Y.number().nullish()}),wc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),annotations:Cc.nullish(),data:Y.string(),mimeType:Y.string()}),Tc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),annotations:Cc.nullish(),data:Y.string(),mimeType:Y.string(),uri:Y.string().nullish()}),Ec=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),annotations:Cc.nullish(),description:Y.string().nullish(),mimeType:Y.string().nullish(),name:Y.string(),size:Y.number().nullish(),title:Y.string().nullish(),uri:Y.string()}),Dc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),optionId:lc}),Oc=Y.union([Y.object({outcome:Y.literal(`cancelled`)}),Dc.and(Y.object({outcome:Y.literal(`selected`)}))]),kc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),outcome:Oc}),Ac=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),jc=Y.object({currentValue:Y.boolean()}),Mc=Y.string(),Nc=Y.string(),Pc=Y.union([Y.literal(`mode`),Y.literal(`model`),Y.literal(`thought_level`),Y.string()]),Fc=Y.string(),Ic=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string().nullish(),name:Y.string(),value:Fc}),Lc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),group:Mc,name:Y.string(),options:Y.array(Ic)}),Rc=Y.union([Y.array(Ic),Y.array(Lc)]),zc=Y.object({currentValue:Fc,options:Rc}),Bc=Y.intersection(Y.union([zc.and(Y.object({type:Y.literal(`select`)})),jc.and(Y.object({type:Y.literal(`boolean`)}))]),Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),category:Pc.nullish(),description:Y.string().nullish(),id:Nc,name:Y.string()})),Vc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc)}),Hc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),Uc=Y.string(),Wc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc});Y.object({method:Y.string(),params:Y.union([Wc,Ks]).nullish()});const Gc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc}),Kc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),args:Y.array(Y.string()).optional(),command:Y.string(),cwd:Y.string().nullish(),env:Y.array(Us).optional(),outputByteLimit:Y.number().nullish(),sessionId:Uc}),qc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cwd:Y.string(),mcpServers:Y.array(ac).optional(),sessionId:Uc}),Jc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc,terminalId:Y.string()}),Yc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cwd:Y.string(),mcpServers:Y.array(ac),sessionId:Uc}),Xc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),limit:Y.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:Y.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:Y.string(),sessionId:Uc}),Zc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc,terminalId:Y.string()}),Qc=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cwd:Y.string(),mcpServers:Y.array(ac).optional(),sessionId:Uc}),$c=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cwd:Y.string(),sessionId:Uc,title:Y.string().nullish(),updatedAt:Y.string().nullish()}),el=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),nextCursor:Y.string().nullish(),sessions:Y.array($c)}),tl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),title:Y.string().nullish(),updatedAt:Y.string().nullish()}),nl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),rl=Y.string(),il=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),currentModeId:rl}),al=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string().nullish(),id:rl,name:Y.string()}),ol=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),availableModes:Y.array(al),currentModeId:rl}),sl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),availableModels:Y.array(sc),currentModelId:oc}),cl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc).nullish(),models:sl.nullish(),modes:ol.nullish(),sessionId:Uc}),ll=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc).nullish(),models:sl.nullish(),modes:ol.nullish()}),ul=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc).nullish(),models:sl.nullish(),modes:ol.nullish(),sessionId:Uc}),dl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc).nullish(),models:sl.nullish(),modes:ol.nullish()}),fl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),pl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),close:Ac.nullish(),fork:Hc.nullish(),list:nl.nullish(),resume:fl.nullish()}),ml=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),loadSession:Y.boolean().optional().default(!1),mcpCapabilities:tc.optional().default({http:!1,sse:!1}),promptCapabilities:gc.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pl.optional().default({})}),hl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),agentCapabilities:ml.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Qs.nullish(),authMethods:Y.array(Fs).optional().default([]),protocolVersion:_c}),gl=Y.intersection(Y.union([Y.object({type:Y.literal(`boolean`),value:Y.boolean()}),Y.object({value:Fc})]),Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configId:Nc,sessionId:Uc})),_l=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),configOptions:Y.array(Bc)}),vl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),modeId:rl,sessionId:Uc}),yl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),bl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),modelId:oc,sessionId:Uc}),xl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()}),Sl=Y.union([Y.literal(`end_turn`),Y.literal(`max_tokens`),Y.literal(`max_turn_requests`),Y.literal(`refusal`),Y.literal(`cancelled`)]),Cl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),terminalId:Y.string()}),wl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),exitCode:Y.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:Y.string().nullish()}),Tl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc,terminalId:Y.string()}),El=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),exitStatus:wl.nullish(),output:Y.string(),truncated:Y.boolean()}),Dl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),annotations:Cc.nullish(),text:Y.string()}),Ol=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),mimeType:Y.string().nullish(),text:Y.string(),uri:Y.string()}),kl=Y.union([Ol,Rs]),Al=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),annotations:Cc.nullish(),resource:kl}),jl=Y.union([Dl.and(Y.object({type:Y.literal(`text`)})),Tc.and(Y.object({type:Y.literal(`image`)})),wc.and(Y.object({type:Y.literal(`audio`)})),Ec.and(Y.object({type:Y.literal(`resource_link`)})),Al.and(Y.object({type:Y.literal(`resource`)}))]),Ml=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:jl}),Nl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:jl,messageId:Y.string().nullish()}),Pl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),messageId:Y.string().nullish(),prompt:Y.array(jl),sessionId:Uc});Y.object({id:xc,method:Y.string(),params:Y.union([vc,Is,cc,Yc,ec,qc,Qc,Gc,vl,gl,Pl,bl,qs]).nullish()});const Fl=Y.union([Ml.and(Y.object({type:Y.literal(`content`)})),Hs.and(Y.object({type:Y.literal(`diff`)})),Cl.and(Y.object({type:Y.literal(`terminal`)}))]),Il=Y.string(),Ll=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),line:Y.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:Y.string()}),Rl=Y.union([Y.literal(`pending`),Y.literal(`in_progress`),Y.literal(`completed`),Y.literal(`failed`)]),zl=Y.union([Y.literal(`read`),Y.literal(`edit`),Y.literal(`delete`),Y.literal(`move`),Y.literal(`search`),Y.literal(`execute`),Y.literal(`think`),Y.literal(`fetch`),Y.literal(`switch_mode`),Y.literal(`other`)]),Bl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:Y.array(Fl).optional(),kind:zl.optional(),locations:Y.array(Ll).optional(),rawInput:Y.unknown().optional(),rawOutput:Y.unknown().optional(),status:Rl.optional(),title:Y.string(),toolCallId:Il}),Vl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:Y.array(Fl).nullish(),kind:zl.nullish(),locations:Y.array(Ll).nullish(),rawInput:Y.unknown().optional(),rawOutput:Y.unknown().optional(),status:Rl.nullish(),title:Y.string().nullish(),toolCallId:Il}),Hl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),options:Y.array(dc),sessionId:Uc,toolCall:Vl}),Ul=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),hint:Y.string()}),Wl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),description:Y.string(),input:Ul.nullish(),name:Y.string()}),Gl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),availableCommands:Y.array(Wl)}),Kl=Y.object({cachedReadTokens:Y.number().nullish(),cachedWriteTokens:Y.number().nullish(),inputTokens:Y.number(),outputTokens:Y.number(),thoughtTokens:Y.number().nullish(),totalTokens:Y.number()}),ql=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),stopReason:Sl,usage:Kl.nullish(),userMessageId:Y.string().nullish()});Y.union([Y.object({id:xc,result:Y.union([hl,Ls,ul,ll,el,cl,dl,zs,yl,_l,ql,xl,Js])}),Y.object({error:Gs,id:xc})]);const Jl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),cost:Bs.nullish(),size:Y.number(),used:Y.number()}),Yl=Y.union([Nl.and(Y.object({sessionUpdate:Y.literal(`user_message_chunk`)})),Nl.and(Y.object({sessionUpdate:Y.literal(`agent_message_chunk`)})),Nl.and(Y.object({sessionUpdate:Y.literal(`agent_thought_chunk`)})),Bl.and(Y.object({sessionUpdate:Y.literal(`tool_call`)})),Vl.and(Y.object({sessionUpdate:Y.literal(`tool_call_update`)})),hc.and(Y.object({sessionUpdate:Y.literal(`plan`)})),Gl.and(Y.object({sessionUpdate:Y.literal(`available_commands_update`)})),il.and(Y.object({sessionUpdate:Y.literal(`current_mode_update`)})),Vc.and(Y.object({sessionUpdate:Y.literal(`config_option_update`)})),tl.and(Y.object({sessionUpdate:Y.literal(`session_info_update`)})),Jl.and(Y.object({sessionUpdate:Y.literal(`usage_update`)}))]),Xl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc,update:Yl});Y.object({method:Y.string(),params:Y.union([Xl,Ks]).nullish()});const Zl=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),sessionId:Uc,terminalId:Y.string()}),Ql=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),exitCode:Y.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:Y.string().nullish()}),$l=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish(),content:Y.string(),path:Y.string(),sessionId:Uc});Y.object({id:xc,method:Y.string(),params:Y.union([$l,Xc,Hl,Kc,Tl,Zc,Zl,Jc,qs]).nullish()});const eu=Y.object({_meta:Y.record(Y.string(),Y.unknown()).nullish()});Y.union([Y.object({id:xc,result:Y.union([eu,yc,kc,Vs,El,bc,Ql,$s,Js])}),Y.object({error:Gs,id:xc})]);function tu(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a)break;if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
|
|
9
9
|
`);n=o.pop()||``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);e.enqueue(t)}catch(e){console.error(`Failed to parse JSON message:`,n,e)}}}}finally{i.releaseLock(),e.close()}}}),writable:new WritableStream({async write(t){let r=JSON.stringify(t)+`
|
|
10
|
-
`,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}Symbol.asyncDispose;var Xl=class{#e;constructor(e,t){let n=e(this);this.#e=new Zl(async(e,t)=>{switch(e){case Cs.fs_write_text_file:{let e=ql.parse(t);return n.writeTextFile?.(e)}case Cs.fs_read_text_file:{let e=Wc.parse(t);return n.readTextFile?.(e)}case Cs.session_request_permission:{let e=Il.parse(t);return n.requestPermission(e)}case Cs.terminal_create:{let e=Bc.parse(t);return n.createTerminal?.(e)}case Cs.terminal_output:{let e=yl.parse(t);return n.terminalOutput?.(e)}case Cs.terminal_release:{let e=Gc.parse(t);return await n.releaseTerminal?.(e)??{}}case Cs.terminal_wait_for_exit:{let e=Gl.parse(t);return n.waitForTerminalExit?.(e)}case Cs.terminal_kill:{let e=Hc.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw Ql.methodNotFound(e)}},async(e,t)=>{switch(e){case Cs.session_update:{let e=Wl.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw Ql.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(Ss.initialize,e)}async newSession(e){return await this.#e.sendRequest(Ss.session_new,e)}async loadSession(e){return await this.#e.sendRequest(Ss.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(Ss.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(Ss.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(Ss.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(Ss.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(Ss.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(Ss.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(Ss.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(Ss.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(Ss.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(Ss.session_cancel,e)}async extMethod(e,t){return await this.#e.sendRequest(e,t)}async extNotification(e,t){return await this.#e.sendNotification(e,t)}get signal(){return this.#e.signal}get closed(){return this.#e.closed}},Zl=class{#e=new Map;#t=0;#n;#r;#i;#a=Promise.resolve();#o=new AbortController;#s;constructor(e,t,n){this.#n=e,this.#r=t,this.#i=n,this.#s=new Promise(e=>{this.#o.signal.addEventListener(`abort`,()=>e())}),this.#c()}get signal(){return this.#o.signal}get closed(){return this.#s}async#c(){let e=this.#i.readable.getReader();try{for(;;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.#l(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.#p({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock(),this.#o.abort()}}async#l(e){if(`method`in e&&`id`in e){let t=await this.#u(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.#p({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.#d(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else `id`in e?this.#f(e):console.error(`Invalid message`,{message:e})}async#u(e,t){try{return{result:await this.#n(e,t)??null}}catch(e){if(e instanceof Ql)return e.toResult();if(e instanceof Mi.ZodError)return Ql.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return Ql.internalError(t?JSON.parse(t):{}).toResult()}catch{return Ql.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof Ql)return e.toResult();if(e instanceof Mi.ZodError)return Ql.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return Ql.internalError(t?JSON.parse(t):{}).toResult()}catch{return Ql.internalError({details:t}).toResult()}}}#f(e){let t=this.#e.get(e.id);t?(`result`in e?t.resolve(e.result):`error`in e&&t.reject(e.error),this.#e.delete(e.id)):console.error(`Got response to unknown request`,e.id)}async sendRequest(e,t){let n=this.#t++,r=new Promise((e,t)=>{this.#e.set(n,{resolve:e,reject:t})});return await this.#p({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){await this.#p({jsonrpc:`2.0`,method:e,params:t})}async#p(e){return this.#a=this.#a.then(async()=>{let t=this.#i.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{console.error(`ACP write error:`,e)}),this.#a}},Ql=class e extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.name=`RequestError`,this.data=n}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};const $l=R.pipe(Sn(`SessionId`));var eu=class extends qe(`AcpStreamError`)({_tag:Wr(`AcpStreamError`),cause:Dn}){message=`Streaming failed: ${this.cause}`},tu=class extends qe(`AcpSessionCreateError`)({_tag:Wr(`AcpSessionCreateError`),cause:Dn}){message=`Creating session failed: ${this.cause}`},nu=class extends qe(`AcpConnectionInitError`)({_tag:Wr(`AcpConnectionInitError`),cause:Dn}){message=`Init connection failed: ${this.cause}`},ru=class extends qe(`AcpAdapterNotFoundError`)({_tag:Wr(`AcpAdapterNotFoundError`),packageName:R}){message=`ACP adapter not found: ${this.packageName}`},iu=class e extends tn()(`@expect/AcpAdapter`){static layerCodex=b(e)(cn({try:()=>{let t=oi(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/codex-acp/bin/codex-acp.js`);return e.of({bin:process.execPath,args:[t],env:{}})},catch:()=>new ru({packageName:`@zed-industries/codex-acp`})}));static layerClaude=b(e)(cn({try:()=>{let t=oi(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/claude-agent-acp/dist/index.js`);return e.of({bin:process.execPath,args:[t],env:{}})},catch:()=>new ru({packageName:`@zed-industries/claude-agent-acp`})}))},au=class extends tn()(`@expect/AcpClient`,{make:D(function*(){let e=yield*iu;yield*Cr({adapter:e.args[0]}),yield*Ae(`Initializing AcpClient`);let t=yield*jr,n=yield*Oa(),r=yield*ai(),i=new Map,a={requestPermission:e=>Promise.resolve({outcome:{outcome:`selected`,optionId:e.options.find(e=>e.kind===`allow_always`||e.kind===`allow_once`)?.optionId??e.options[0].optionId}}),sessionUpdate:async({sessionId:e,update:t})=>{let n=i.get($l.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);nt(n,ei(Po)(t))}},o=yield*Un(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*Cr({pid:o.pid}),yield*l(`ACP adapter subprocess spawned`),yield*T(r).pipe(O(o.stdin),lt);let s=ft(o.stdout),c=new Xl(e=>a,Yl(new WritableStream({write:e=>void nt(r,e)}),s)),u=Ai(new URL(`./browser-mcp.js`,import.meta.url)),d=e=>[{command:process.execPath,args:[u],env:[...e],name:`browser`}];yield*Ae(`ACP connection initialized`,{capabilities:(yield*Pr({try:()=>c.initialize({protocolVersion:1}),catch:e=>new nu({cause:e})})).agentCapabilities});let f=L(`AcpClient.createSession`)(function*(e,t=[]){yield*Jt({cwd:e});let n=d(t);return yield*Pr({try:()=>c.newSession({cwd:e,mcpServers:n}),catch:e=>new tu({cause:e})}).pipe(I(({sessionId:e})=>$l.makeUnsafe(e)),yr(e=>D(function*(){let t=yield*ai();i.set(e,t),yield*Ae(`ACP session created`,{sessionId:e})})))}),p=L(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*Tn(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*ai();return i.set(e,t),t});return{createSession:f,stream:L(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r,mcpEnv:i=[]}){let a=k(t)?t.value:yield*f(r,i);yield*l(`ACP stream starting`,{sessionId:a});let o=yield*p(a);return yield*Pr({try:()=>c.prompt({sessionId:a,prompt:[{type:`text`,text:e}]}),catch:e=>new eu({cause:e})}).pipe(yr(()=>l(`ACP prompt completed`)),yr(()=>Le(o)),Na(n,a,{startImmediately:!0})),T(o)},xt)}})}){static layer=b(this)(this.make).pipe(w(Pi.layer));static layerCodex=this.layer.pipe(w(iu.layerCodex));static layerClaude=this.layer.pipe(w(iu.layerClaude))},ou=class e extends tn()(`@expect/Agent`){static layerAcp=b(e)(D(function*(){let t=yield*au;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:P(e.sessionId,e=>e),prompt:e.prompt,mcpEnv:e.mcpEnv})})})).pipe(w(au.layer));static layerCodex=e.layerAcp.pipe(w(iu.layerCodex));static layerClaude=e.layerAcp.pipe(w(iu.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>b(e,D(function*(){let n=yield*Xr,r=Br(Po);return e.of({stream:()=>n.stream(t).pipe(Gr(),ti,Re(e=>r(JSON.parse(e))),Ne),createSession:()=>Tn(`createSession not supported for test layer`)})})).pipe(w(Pi.layer))};const su=[`claude`,`codex`,`cursor`],cu=e=>{try{return Ri(`which ${e}`,{stdio:`pipe`}),!0}catch{return!1}},lu=()=>su.filter(cu),uu=12e3,du=e=>e?[`Saved flow guidance:`,`You are replaying a previously saved flow. Follow these steps as guidance, but adapt if the UI has changed.`,`Saved flow title: ${e.title}`,`Saved flow request: ${e.userInstruction}`,``,...e.steps.flatMap((e,t)=>[`Step ${t+1}: ${e.title}`,`Instruction: ${e.instruction}`,`Expected: ${e.expectedOutcome}`,``])]:[],fu=e=>{switch(e){case`Commit`:return[`- Start narrow and prove the selected commit's intended change works first.`,`- Treat the selected commit and its touched files as the primary testing hypothesis.`,`- After the primary flow, test 2-4 adjacent flows that could regress from the same change. Think about what else touches the same components, routes, or data.`,`- For UI changes, verify related views that render the same data or share the same components.`];case`WorkingTree`:return[`- Start with the exact user-requested flow against the local in-progress changes.`,`- After the primary flow, test related flows that exercise the same code paths — aim for 2-3 follow-ups.`,`- Pay extra attention to partially-implemented features: check that incomplete states don't break existing behavior.`];case`Changes`:return[`- Treat committed and uncommitted work as one body of change.`,`- Cover the requested flow first, then the highest-risk adjacent flows.`,`- Test 2-4 follow-up flows, prioritizing paths that share components or data with the changed files.`,`- If the changes touch shared utilities or layouts, verify multiple pages that use them.`];default:return[`- This is a branch-level review — be thorough. The goal is to catch regressions before merge, not to do a quick spot-check.`,`- Cover the requested flow first, then systematically test each area affected by the changed files.`,`- Aim for 5-8 total tested flows. Derive them from the changed files: each changed route, component, or data path should get its own verification.`,`- Test cross-cutting concerns: if shared components, layouts, or utilities changed, verify them on multiple pages that consume them.`,`- Include at least one negative/edge-case flow (e.g. invalid input, empty state, unauthorized access, broken link) relevant to the changes.`,`- Do not stop after the happy path passes. The value of a branch review is catching what the developer might have missed.`]}},pu=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>uu?i.slice(0,uu)+`
|
|
11
|
-
... (truncated)`:i;return[`You are executing a browser regression test directly from repository context.`,`You have browser tools via the MCP server named "${t}":`,``,`1. open — Launch a browser and navigate to a URL.`,`2. playwright — Execute Playwright code in Node. Globals: page (Page), context (BrowserContext), browser (Browser), ref(id) (resolves a snapshot ref like 'e4' to a Playwright Locator). Supports await. Return a value to get it back as JSON.`,`3. screenshot — Capture page state. Set mode: 'snapshot' (ARIA accessibility tree, default and preferred), 'screenshot' (PNG image), or 'annotated' (PNG with numbered labels on interactive elements).`,`4. console_logs — Get browser console messages. Filter by type ('error', 'warning', 'log'). Use after navigation or interactions to catch errors.`,`5. network_requests — Get captured network requests. Filter by method, URL substring, or resource type ('xhr', 'fetch', 'document').`,`6. close — Close the browser and end the session.`,``,`Strongly prefer screenshot with mode 'snapshot' for observing page state — the ARIA tree is fast, cheap, and sufficient for almost all assertions.`,`Only use mode 'screenshot' or 'annotated' when you need to verify something purely visual (layout, colors, images) that the accessibility tree cannot capture.`,`After each step, check console_logs with type 'error' to catch unexpected errors.`,``,`Snapshot-driven workflow:`,`1. Call screenshot with mode 'snapshot' to get the ARIA tree with refs.`,`2. Read the tree to find your target elements. Every interactive element has a ref like [ref=e4].`,`3. Use ref() in one playwright call to perform multiple actions using the refs from the snapshot — fill forms, click buttons, wait, and return results all in one block.`,`4. Only take a new snapshot when the page structure has changed significantly (navigation, modal open, new content loaded) and you need fresh refs.`,``,`Example snapshot tree:`,` - navigation`,` - link "Home" [ref=e1]`,` - link "About" [ref=e2]`,` - main`,` - heading "Welcome"`,` - textbox "Email" [ref=e3]`,` - button "Submit" [ref=e4]`,``,`Acting on refs — use ref() to get a Locator directly from the snapshot ref ID:`,` await ref('e3').fill('test@example.com');`,` await ref('e4').click();`,` await ref('e1').click();`,``,`Always snapshot first, then use ref() to act. Never guess CSS selectors.`,``,`Batch as many actions as possible into a single playwright call to minimize round trips:`,` playwright: await ref('e3').fill('test@example.com'); await ref('e5').fill('secret'); await ref('e6').click(); await page.waitForLoadState('networkidle'); return await page.innerText('.result');`,` playwright: await ref('e1').click(); await page.waitForURL('**/about');`,` playwright: return { url: page.url(), title: await page.title() };`,``,`Execution strategy:`,`- First master the primary flow the developer asked for. Verify it thoroughly before moving on.`,`- Once the primary flow passes, test additional related flows suggested by the changed files and route context. The scope strategy below specifies how many — follow it.`,`- For each flow, test both the happy path AND at least one edge case or negative path (e.g. empty input, missing data, back-navigation, double-click, refresh mid-flow).`,`- Use the same browser session throughout unless the app forces you into a different path.`,`- Execution style is assertion-first: navigate, act, validate, recover once, then fail with evidence if still blocked.`,`- Create your own step structure while executing. Use stable sequential IDs like step-01, step-02, step-03.`,`- Take your time. A thorough run that catches real issues is more valuable than a fast run that misses them. Do not rush to RUN_COMPLETED.`,``,`Assertion depth — do not just confirm the page loaded. For each step, verify that the action produced the expected state change:`,`- Before acting, note what should change. After acting, confirm it actually changed.`,`- Check at least two independent signals per step (e.g. URL changed AND new content appeared, or item was added AND count updated).`,`- Verify absence when relevant: after a delete, the item is gone; after dismissing a modal, it no longer appears in the tree.`,`- Use playwright to return structured evidence rather than eyeballing snapshots: return { url: page.url(), title: await page.title(), visible: await ref('e5').isVisible() };`,`- If the changed files suggest specific behavior (e.g. a validation rule, a redirect, a computed value), test that specific behavior rather than just the surrounding UI.`,``,`Before and after each step, emit these exact status lines on their own lines:`,`STEP_START|<step-id>|<step-title>`,`STEP_DONE|<step-id>|<short-summary>`,`ASSERTION_FAILED|<step-id>|<why-it-failed>`,`RUN_COMPLETED|passed|<final-summary>`,`RUN_COMPLETED|failed|<final-summary>`,``,`Allowed failure categories: app-bug, env-issue, auth-blocked, missing-test-data, selector-drift, agent-misread.`,`When a step fails, gather structured evidence before emitting ASSERTION_FAILED:`,`- Call screenshot with mode 'snapshot' to capture the ARIA tree.`,`- Use playwright to gather diagnostics: return { url: page.url(), title: await page.title(), text: await page.innerText('body').then(t => t.slice(0, 500)) };`,`- Only take a visual screenshot if the failure might be layout/rendering related.`,`- Summarize the failure category and the most important evidence inside <why-it-failed>.`,``,`Stability heuristics:`,`- After navigation or major UI changes, use playwright to wait for the page to settle (e.g. await page.waitForLoadState('networkidle')).`,`- Use screenshot with mode 'snapshot' to inspect the accessibility tree before interactions that depend on current UI state.`,`- Avoid interacting while the UI is visibly loading or transitioning.`,`- Confirm you reached the expected page or route before continuing.`,`- When waiting for page changes (navigation, content loading, animations), prefer short incremental waits (1-3 seconds) with snapshot checks in between rather than a single long wait. For example, instead of waiting 10 seconds: wait 2s, take a snapshot, check if ready, if not wait 2s more and snapshot again. This lets you proceed as soon as the page is ready.`,``,`Recovery policy for each blocked step:`,`- Take a new snapshot to re-inspect the page and get fresh refs.`,`- Use playwright with ref() to scroll the target into view or retry the interaction once.`,`- If still blocked, classify the blocker with one allowed failure category and include that classification in ASSERTION_FAILED.`,``,`Avoid rabbit holes:`,`- Do not repeat the same failing action more than once without new evidence such as a fresh snapshot, a different ref, a changed page state, or a clear new hypothesis.`,`- If four attempts fail or progress stalls, stop acting and report what you observed, what blocked progress, and the most likely next step.`,`- Prefer gathering evidence over brute force. If the page is confusing, use screenshot with mode 'snapshot', playwright for console or network diagnostics, or a visual screenshot to understand it before trying more actions.`,`- If you encounter a blocker such as login, passkey/manual user interaction, permissions, captchas, destructive confirmations, missing data, or an unexpected state, stop and report it instead of improvising repeated actions.`,`- Do not get stuck in wait-action-wait loops. Every retry should be justified by something newly observed.`,``,`Before emitting RUN_COMPLETED, call the close tool exactly once so the browser session flushes the video to disk.`,``,`Environment:`,`- Base URL: ${e.baseUrl??`not provided`}`,`- Headed mode preference: ${e.isHeadless?`headless`:`headed`}`,`- Reuse browser cookies: ${e.requiresCookies?`yes`:`no`}`,``,`Testing target context:`,`- Scope: ${e.scope}`,`- Current branch: ${e.currentBranch}`,`- Main branch: ${e.mainBranch??`unknown`}`,``,`Developer request:`,e.userInstruction,``,...
|
|
12
|
-
`):`- No changed files detected
|
|
13
|
-
`):`- No recent commits available`,``,`Diff preview:`,a||`No diff preview available`,``,`Scope strategy:`,...
|
|
14
|
-
`)};var
|
|
10
|
+
`,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}Symbol.asyncDispose;var nu=class{#e;constructor(e,t){let n=e(this);this.#e=new ru(async(e,t)=>{switch(e){case ks.fs_write_text_file:{let e=$l.parse(t);return n.writeTextFile?.(e)}case ks.fs_read_text_file:{let e=Xc.parse(t);return n.readTextFile?.(e)}case ks.session_request_permission:{let e=Hl.parse(t);return n.requestPermission(e)}case ks.terminal_create:{let e=Kc.parse(t);return n.createTerminal?.(e)}case ks.terminal_output:{let e=Tl.parse(t);return n.terminalOutput?.(e)}case ks.terminal_release:{let e=Zc.parse(t);return await n.releaseTerminal?.(e)??{}}case ks.terminal_wait_for_exit:{let e=Zl.parse(t);return n.waitForTerminalExit?.(e)}case ks.terminal_kill:{let e=Jc.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw iu.methodNotFound(e)}},async(e,t)=>{switch(e){case ks.session_update:{let e=Xl.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw iu.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(Os.initialize,e)}async newSession(e){return await this.#e.sendRequest(Os.session_new,e)}async loadSession(e){return await this.#e.sendRequest(Os.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(Os.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(Os.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(Os.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(Os.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(Os.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(Os.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(Os.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(Os.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(Os.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(Os.session_cancel,e)}async extMethod(e,t){return await this.#e.sendRequest(e,t)}async extNotification(e,t){return await this.#e.sendNotification(e,t)}get signal(){return this.#e.signal}get closed(){return this.#e.closed}},ru=class{#e=new Map;#t=0;#n;#r;#i;#a=Promise.resolve();#o=new AbortController;#s;constructor(e,t,n){this.#n=e,this.#r=t,this.#i=n,this.#s=new Promise(e=>{this.#o.signal.addEventListener(`abort`,()=>e())}),this.#c()}get signal(){return this.#o.signal}get closed(){return this.#s}async#c(){let e=this.#i.readable.getReader();try{for(;;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.#l(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.#p({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock(),this.#o.abort()}}async#l(e){if(`method`in e&&`id`in e){let t=await this.#u(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.#p({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.#d(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else `id`in e?this.#f(e):console.error(`Invalid message`,{message:e})}async#u(e,t){try{return{result:await this.#n(e,t)??null}}catch(e){if(e instanceof iu)return e.toResult();if(e instanceof Pi.ZodError)return iu.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return iu.internalError(t?JSON.parse(t):{}).toResult()}catch{return iu.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof iu)return e.toResult();if(e instanceof Pi.ZodError)return iu.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return iu.internalError(t?JSON.parse(t):{}).toResult()}catch{return iu.internalError({details:t}).toResult()}}}#f(e){let t=this.#e.get(e.id);t?(`result`in e?t.resolve(e.result):`error`in e&&t.reject(e.error),this.#e.delete(e.id)):console.error(`Got response to unknown request`,e.id)}async sendRequest(e,t){let n=this.#t++,r=new Promise((e,t)=>{this.#e.set(n,{resolve:e,reject:t})});return await this.#p({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){await this.#p({jsonrpc:`2.0`,method:e,params:t})}async#p(e){return this.#a=this.#a.then(async()=>{let t=this.#i.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{console.error(`ACP write error:`,e)}),this.#a}},iu=class e extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.name=`RequestError`,this.data=n}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};const au=he(It,he(jt(`message`),hr({message:qe}))),ou=z.pipe(Sn(`SessionId`));var su=class extends Ke(`AcpStreamError`)({_tag:Kr(`AcpStreamError`),cause:Dn}){displayName=`An unexpected error occurred while streaming`;message=`Streaming failed: ${this.cause}`},cu=class extends Ke(`AcpProviderUnauthenticatedError`)({_tag:Kr(`AcpProviderUnauthenticatedError`),provider:Ro}){displayName=`Your ${this.provider} agent is not authenticated`;message=Yn(this.provider).pipe(Cn(`claude`,()=>"Please log in using `claude login`, and then re-run expect."),Cn(`codex`,()=>"Please log in using `codex login`, and then re-run expect."),mn(()=>`Please sign in to your coding agent, and then re-run expect.`))},lu=class extends Ke(`AcpProviderUsageLimitError`)({_tag:Kr(`AcpProviderUsageLimitError`),provider:Ro}){displayName=`Your ${this.provider} agent has exceeded its usage limits`;message=`Usage limits exceeded for ${this.provider}. Please check your plan and billing.`},uu=class extends Ke(`AcpSessionCreateError`)({_tag:Kr(`AcpSessionCreateError`),cause:Dn}){displayName=`Creating a chat session failed`;message=`Creating session failed: ${kr(Nt(this.cause))}`},du=class extends Ke(`AcpConnectionInitError`)({_tag:Kr(`AcpConnectionInitError`),cause:Dn}){message=`Init connection failed: ${this.cause}`},fu=class extends Ke(`AcpAdapterNotFoundError`)({_tag:Kr(`AcpAdapterNotFoundError`),packageName:z,cause:Dn}){message=`ACP adapter not found: ${this.packageName}. Error: ${kr(Nt(this.cause))}`},pu=class e extends tn()(`@expect/AcpAdapter`){static layerCodex=b(e)(cn({try:()=>{let t=ci(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/codex-acp/bin/codex-acp.js`);return e.of({provider:`codex`,bin:process.execPath,args:[t],env:{}})},catch:e=>new fu({packageName:`@zed-industries/codex-acp`,cause:e})}));static layerClaude=b(e)(O(function*(){let t=yield*Nr,n=Jn({loggedIn:me});return yield*Wn(`claude`,[`auth`,`status`]).pipe(t.string,ei(Wt(Zr(n))),ei(({loggedIn:e})=>e?gn:new cu({provider:`claude`}).asEffect())),yield*cn({try:()=>{let t=ci(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/claude-agent-acp/dist/index.js`);return e.of({provider:`claude`,bin:process.execPath,args:[t],env:{}})},catch:e=>new fu({packageName:`@zed-industries/claude-agent-acp`,cause:e})})})).pipe(w(Ii.layer))},mu=class extends tn()(`@expect/AcpClient`,{make:O(function*(){let e=yield*pu;yield*Tr({adapter:e.args[0]}),yield*ke(`Initializing AcpClient`);let t=yield*Nr,n=yield*Aa(),r=yield*si(),i=new Map,a={requestPermission:e=>Promise.resolve({outcome:{outcome:`selected`,optionId:e.options.find(e=>e.kind===`allow_always`||e.kind===`allow_once`)?.optionId??e.options[0].optionId}}),sessionUpdate:async({sessionId:e,update:t})=>{let n=i.get(ou.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);tt(n,ni(Lo)(t))}},o=yield*Wn(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*Tr({pid:o.pid}),yield*l(`ACP adapter subprocess spawned`),yield*E(r).pipe(k(o.stdin),ct);let s=dt(o.stdout),c=new nu(e=>a,tu(new WritableStream({write:e=>void tt(r,e)}),s)),u=Mi(new URL(`./browser-mcp.js`,import.meta.url)),d=e=>[{command:process.execPath,args:[u],env:[...e],name:`browser`}];yield*ke(`ACP connection initialized`,{capabilities:(yield*Ir({try:()=>c.initialize({protocolVersion:1}),catch:e=>new du({cause:e})})).agentCapabilities});let f=R(`AcpClient.createSession`)(function*(t,n=[]){yield*Jt({cwd:t});let r=d(n);return yield*Ir({try:()=>c.newSession({cwd:t,mcpServers:r}),catch:t=>{let n=au(t)?t.message:String(t);return[`authentication`].some(e=>n.toLowerCase().includes(e))?new cu({provider:e.provider}):[`out of usage`,`limits exceeded`,`usage exceeded`].some(e=>n.toLowerCase().includes(e))?new lu({provider:e.provider}):new uu({cause:t})}}).pipe(L(({sessionId:e})=>ou.makeUnsafe(e)),Sr(e=>O(function*(){let t=yield*si();i.set(e,t),yield*ke(`ACP session created`,{sessionId:e})})))}),p=R(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*Tn(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*si();return i.set(e,t),t});return{createSession:f,stream:R(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r,mcpEnv:i=[]}){let a=A(t)?t.value:yield*f(r,i);yield*l(`ACP stream starting`,{sessionId:a});let o=yield*p(a);return yield*Ir({try:()=>c.prompt({sessionId:a,prompt:[{type:`text`,text:e}]}),catch:e=>new su({cause:e})}).pipe(Sr(()=>l(`ACP prompt completed`)),Sr(()=>Ie(o)),Fa(n,a,{startImmediately:!0})),E(o)},bt)}})}){static layer=b(this)(this.make).pipe(w(Ii.layer));static layerCodex=this.layer.pipe(w(pu.layerCodex));static layerClaude=this.layer.pipe(w(pu.layerClaude))},hu=class e extends tn()(`@expect/Agent`){static layerAcp=b(e)(O(function*(){let t=yield*mu;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:F(e.sessionId,e=>e),prompt:e.prompt,mcpEnv:e.mcpEnv})})})).pipe(w(mu.layer));static layerCodex=e.layerAcp.pipe(w(pu.layerCodex));static layerClaude=e.layerAcp.pipe(w(pu.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>b(e,O(function*(){let n=yield*Qr,r=Hr(Lo);return e.of({stream:()=>n.stream(t).pipe(qr(),ri,Le(e=>r(JSON.parse(e))),Me),createSession:()=>Tn(`createSession not supported for test layer`)})})).pipe(w(Ii.layer))};const gu=[`claude`,`codex`,`cursor`],_u=e=>{try{return Bi(`which ${e}`,{stdio:`pipe`}),!0}catch{return!1}},vu=()=>gu.filter(_u),yu=12e3,bu=e=>e?[`Saved flow guidance:`,`You are replaying a previously saved flow. Follow these steps as guidance, but adapt if the UI has changed.`,`Saved flow title: ${e.title}`,`Saved flow request: ${e.userInstruction}`,``,...e.steps.flatMap((e,t)=>[`Step ${t+1}: ${e.title}`,`Instruction: ${e.instruction}`,`Expected: ${e.expectedOutcome}`,``])]:[],xu=e=>{switch(e){case`Commit`:return[`- Start narrow and prove the selected commit's intended change works first.`,`- Treat the selected commit and its touched files as the primary testing hypothesis.`,`- After the primary flow, test 2-4 adjacent flows that could regress from the same change. Think about what else touches the same components, routes, or data.`,`- For UI changes, verify related views that render the same data or share the same components.`];case`WorkingTree`:return[`- Start with the exact user-requested flow against the local in-progress changes.`,`- After the primary flow, test related flows that exercise the same code paths — aim for 2-3 follow-ups.`,`- Pay extra attention to partially-implemented features: check that incomplete states don't break existing behavior.`];case`Changes`:return[`- Treat committed and uncommitted work as one body of change.`,`- Cover the requested flow first, then the highest-risk adjacent flows.`,`- Test 2-4 follow-up flows, prioritizing paths that share components or data with the changed files.`,`- If the changes touch shared utilities or layouts, verify multiple pages that use them.`];default:return[`- This is a branch-level review — be thorough. The goal is to catch regressions before merge, not to do a quick spot-check.`,`- Cover the requested flow first, then systematically test each area affected by the changed files.`,`- Aim for 5-8 total tested flows. Derive them from the changed files: each changed route, component, or data path should get its own verification.`,`- Test cross-cutting concerns: if shared components, layouts, or utilities changed, verify them on multiple pages that consume them.`,`- Include at least one negative/edge-case flow (e.g. invalid input, empty state, unauthorized access, broken link) relevant to the changes.`,`- Do not stop after the happy path passes. The value of a branch review is catching what the developer might have missed.`]}},Su=e=>{if(!e||e.totalCount===0)return[];let t=[`Test coverage of changed files: ${e.percent}% (${e.coveredCount}/${e.totalCount} files have tests)`],n=e.entries.filter(e=>e.covered),r=e.entries.filter(e=>!e.covered);for(let e of n)t.push(` [covered] ${e.path} (tested by: ${e.testFiles.slice(0,3).join(`, `)})`);for(let e of r)t.push(` [no test] ${e.path}`);return r.length>0&&t.push(`Prioritize browser-testing files WITHOUT existing test coverage.`),t.push(``),t},Cu=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>yu?i.slice(0,yu)+`
|
|
11
|
+
... (truncated)`:i;return[`You are executing a browser regression test directly from repository context.`,`You have browser tools via the MCP server named "${t}":`,``,`1. open — Launch a browser and navigate to a URL.`,`2. playwright — Execute Playwright code in Node. Globals: page (Page), context (BrowserContext), browser (Browser), ref(id) (resolves a snapshot ref like 'e4' to a Playwright Locator). Supports await. Return a value to get it back as JSON.`,`3. screenshot — Capture page state. Set mode: 'snapshot' (ARIA accessibility tree, default and preferred), 'screenshot' (PNG image), or 'annotated' (PNG with numbered labels on interactive elements).`,`4. console_logs — Get browser console messages. Filter by type ('error', 'warning', 'log'). Use after navigation or interactions to catch errors.`,`5. network_requests — Get captured network requests. Filter by method, URL substring, or resource type ('xhr', 'fetch', 'document').`,`6. close — Close the browser and end the session.`,``,`Strongly prefer screenshot with mode 'snapshot' for observing page state — the ARIA tree is fast, cheap, and sufficient for almost all assertions.`,`Only use mode 'screenshot' or 'annotated' when you need to verify something purely visual (layout, colors, images) that the accessibility tree cannot capture.`,`After each step, check console_logs with type 'error' to catch unexpected errors.`,``,`Snapshot-driven workflow:`,`1. Call screenshot with mode 'snapshot' to get the ARIA tree with refs.`,`2. Read the tree to find your target elements. Every interactive element has a ref like [ref=e4].`,`3. Use ref() in one playwright call to perform multiple actions using the refs from the snapshot — fill forms, click buttons, wait, and return results all in one block.`,`4. Only take a new snapshot when the page structure has changed significantly (navigation, modal open, new content loaded) and you need fresh refs.`,``,`Example snapshot tree:`,` - navigation`,` - link "Home" [ref=e1]`,` - link "About" [ref=e2]`,` - main`,` - heading "Welcome"`,` - textbox "Email" [ref=e3]`,` - button "Submit" [ref=e4]`,``,`Acting on refs — use ref() to get a Locator directly from the snapshot ref ID:`,` await ref('e3').fill('test@example.com');`,` await ref('e4').click();`,` await ref('e1').click();`,``,`Always snapshot first, then use ref() to act. Never guess CSS selectors.`,``,`Batch as many actions as possible into a single playwright call to minimize round trips:`,` playwright: await ref('e3').fill('test@example.com'); await ref('e5').fill('secret'); await ref('e6').click(); await page.waitForLoadState('networkidle'); return await page.innerText('.result');`,` playwright: await ref('e1').click(); await page.waitForURL('**/about');`,` playwright: return { url: page.url(), title: await page.title() };`,``,`Execution strategy:`,`- First master the primary flow the developer asked for. Verify it thoroughly before moving on.`,`- Once the primary flow passes, test additional related flows suggested by the changed files and route context. The scope strategy below specifies how many — follow it.`,`- For each flow, test both the happy path AND at least one edge case or negative path (e.g. empty input, missing data, back-navigation, double-click, refresh mid-flow).`,`- Use the same browser session throughout unless the app forces you into a different path.`,`- Execution style is assertion-first: navigate, act, validate, recover once, then fail with evidence if still blocked.`,`- Create your own step structure while executing. Use stable sequential IDs like step-01, step-02, step-03.`,`- Take your time. A thorough run that catches real issues is more valuable than a fast run that misses them. Do not rush to RUN_COMPLETED.`,``,`Assertion depth — do not just confirm the page loaded. For each step, verify that the action produced the expected state change:`,`- Before acting, note what should change. After acting, confirm it actually changed.`,`- Check at least two independent signals per step (e.g. URL changed AND new content appeared, or item was added AND count updated).`,`- Verify absence when relevant: after a delete, the item is gone; after dismissing a modal, it no longer appears in the tree.`,`- Use playwright to return structured evidence rather than eyeballing snapshots: return { url: page.url(), title: await page.title(), visible: await ref('e5').isVisible() };`,`- If the changed files suggest specific behavior (e.g. a validation rule, a redirect, a computed value), test that specific behavior rather than just the surrounding UI.`,``,`Before and after each step, emit these exact status lines on their own lines:`,`STEP_START|<step-id>|<step-title>`,`STEP_DONE|<step-id>|<short-summary>`,`ASSERTION_FAILED|<step-id>|<why-it-failed>`,`RUN_COMPLETED|passed|<final-summary>`,`RUN_COMPLETED|failed|<final-summary>`,``,`Allowed failure categories: app-bug, env-issue, auth-blocked, missing-test-data, selector-drift, agent-misread.`,`When a step fails, gather structured evidence before emitting ASSERTION_FAILED:`,`- Call screenshot with mode 'snapshot' to capture the ARIA tree.`,`- Use playwright to gather diagnostics: return { url: page.url(), title: await page.title(), text: await page.innerText('body').then(t => t.slice(0, 500)) };`,`- Only take a visual screenshot if the failure might be layout/rendering related.`,`- Summarize the failure category and the most important evidence inside <why-it-failed>.`,``,`Stability heuristics:`,`- After navigation or major UI changes, use playwright to wait for the page to settle (e.g. await page.waitForLoadState('networkidle')).`,`- Use screenshot with mode 'snapshot' to inspect the accessibility tree before interactions that depend on current UI state.`,`- Avoid interacting while the UI is visibly loading or transitioning.`,`- Confirm you reached the expected page or route before continuing.`,`- When waiting for page changes (navigation, content loading, animations), prefer short incremental waits (1-3 seconds) with snapshot checks in between rather than a single long wait. For example, instead of waiting 10 seconds: wait 2s, take a snapshot, check if ready, if not wait 2s more and snapshot again. This lets you proceed as soon as the page is ready.`,``,`Recovery policy for each blocked step:`,`- Take a new snapshot to re-inspect the page and get fresh refs.`,`- Use playwright with ref() to scroll the target into view or retry the interaction once.`,`- If still blocked, classify the blocker with one allowed failure category and include that classification in ASSERTION_FAILED.`,``,`Avoid rabbit holes:`,`- Do not repeat the same failing action more than once without new evidence such as a fresh snapshot, a different ref, a changed page state, or a clear new hypothesis.`,`- If four attempts fail or progress stalls, stop acting and report what you observed, what blocked progress, and the most likely next step.`,`- Prefer gathering evidence over brute force. If the page is confusing, use screenshot with mode 'snapshot', playwright for console or network diagnostics, or a visual screenshot to understand it before trying more actions.`,`- If you encounter a blocker such as login, passkey/manual user interaction, permissions, captchas, destructive confirmations, missing data, or an unexpected state, stop and report it instead of improvising repeated actions.`,`- Do not get stuck in wait-action-wait loops. Every retry should be justified by something newly observed.`,``,`Before emitting RUN_COMPLETED, call the close tool exactly once so the browser session flushes the video to disk.`,``,`Environment:`,`- Base URL: ${e.baseUrl??`not provided`}`,`- Headed mode preference: ${e.isHeadless?`headless`:`headed`}`,`- Reuse browser cookies: ${e.requiresCookies?`yes`:`no`}`,``,`Testing target context:`,`- Scope: ${e.scope}`,`- Current branch: ${e.currentBranch}`,`- Main branch: ${e.mainBranch??`unknown`}`,``,`Developer request:`,e.userInstruction,``,...bu(e.savedFlow),`Project learnings from previous runs:`,e.learnings?.trim()||`No learnings yet.`,``,`Changed files:`,n.length>0?n.map(e=>`- [${e.status}] ${e.path}`).join(`
|
|
12
|
+
`):`- No changed files detected`,``,...Su(e.testCoverage),`Recent commits:`,r.length>0?r.map(e=>`- ${e.shortHash} ${e.subject}`).join(`
|
|
13
|
+
`):`- No recent commits available`,``,`Diff preview:`,a||`No diff preview available`,``,`Scope strategy:`,...xu(e.scope)].join(`
|
|
14
|
+
`)};var wu=n(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),Tu=n(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=wu(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Eu=n(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=Tu()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Du=n(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),Ou=n(((t,n)=>{let r=e(`os`),i=e(`tty`),a=Du(),{env:o}=process,s;a(`no-color`)||a(`no-colors`)||a(`color=false`)||a(`color=never`)?s=0:(a(`color`)||a(`colors`)||a(`color=true`)||a(`color=always`))&&(s=1),`FORCE_COLOR`in o&&(s=o.FORCE_COLOR===`true`?1:o.FORCE_COLOR===`false`?0:o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function c(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(s===0)return 0;if(a(`color=16m`)||a(`color=full`)||a(`color=truecolor`))return 3;if(a(`color=256`))return 2;if(e&&!t&&s===void 0)return 0;let n=s||0;if(o.TERM===`dumb`)return n;if(process.platform===`win32`){let e=r.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in o)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in o)||o.CI_NAME===`codeship`?1:n;if(`TEAMCITY_VERSION`in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in o){let e=parseInt((o.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(o.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||`COLORTERM`in o?1:n}function u(e){return c(l(e,e&&e.isTTY))}n.exports={supportsColor:u,stdout:c(l(!0,i.isatty(1))),stderr:c(l(!0,i.isatty(2)))}})),ku=n(((t,n)=>{let r=e(`tty`),i=e(`util`);t.init=d,t.log=c,t.formatArgs=o,t.save=l,t.load=u,t.useColors=a,t.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{let e=Ou();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function a(){return`colors`in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(e){let{namespace:t,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${t} \u001B[0m`;e[0]=a+e[0].split(`
|
|
15
15
|
`).join(`
|
|
16
16
|
`+a),e.push(i+`m+`+n.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=s()+t+` `+e[0]}function s(){return t.inspectOpts.hideDate?``:new Date().toISOString()+` `}function c(...e){return process.stderr.write(i.formatWithOptions(t.inspectOpts,...e)+`
|
|
17
|
-
`)}function l(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function u(){return process.env.DEBUG}function d(e){e.inspectOpts={};let n=Object.keys(t.inspectOpts);for(let r=0;r<n.length;r++)e.inspectOpts[n[r]]=t.inspectOpts[n[r]]}n.exports=
|
|
18
|
-
`).map(e=>e.trim()).join(` `)},f.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}})),
|
|
19
|
-
`){return e.split(n).reduce((e,n)=>{let r=t?n.trim():n;return r&&e.push(r),e},[])}function
|
|
20
|
-
`)){let e=
|
|
21
|
-
`);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var If,Lf=X({"src/lib/responses/ConfigList.ts"(){Q(),If=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{}),this._all}addFile(e){if(!(e in this.values)){let t=Xu(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,n){let r=this.addFile(e);Object.hasOwn(r,t)?Array.isArray(r[t])?r[t].push(n):r[t]=[r[t],n]:r[t]=n,this._all=void 0}}}});function Rf(e,t){return typeof e==`string`&&Object.hasOwn(Uf,e)?e:t}function zf(e,t,n,r){let i=[`config`,`--${r}`];return n&&i.push(`--add`),i.push(e,t),{commands:i,format:`utf-8`,parser(e){return e}}}function Bf(e,t){let n=[`config`,`--null`,`--show-origin`,`--get-all`,e];return t&&n.splice(1,0,`--${t}`),{commands:n,format:`utf-8`,parser(t){return Nf(t,e)}}}function Vf(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return Mf(e)}}}function Hf(){return{addConfig(e,t,...n){return this._runTask(zf(e,t,n[0]===!0,Rf(n[1],`local`)),Vd(arguments))},getConfig(e,t){return this._runTask(Bf(e,Rf(t,void 0)),Vd(arguments))},listConfig(...e){return this._runTask(Vf(Rf(e[0],void 0)),Vd(arguments))}}}var Uf,Wf=X({"src/lib/tasks/config.ts"(){Lf(),Q(),Uf=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(Uf||{})}});function Gf(e){return qf.has(e)}var Kf,qf,Jf=X({"src/lib/tasks/diff-name-status.ts"(){Kf=(e=>(e.ADDED=`A`,e.COPIED=`C`,e.DELETED=`D`,e.MODIFIED=`M`,e.RENAMED=`R`,e.CHANGED=`T`,e.UNMERGED=`U`,e.UNKNOWN=`X`,e.BROKEN=`B`,e))(Kf||{}),qf=new Set(Object.values(Kf))}});function Yf(...e){return new tp().param(...e)}function Xf(e){let t=new Set,n={};return $u(e,e=>{let[r,i,a]=e.split(pd);t.add(r),(n[r]=n[r]||[]).push({line:sd(i),path:r,preview:a})}),{paths:t,results:n}}function Zf(){return{grep(e){let t=Vd(arguments),n=Rd(arguments);for(let e of Qf)if(n.includes(e))return this._runTask(df(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Yf().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return Xf(e)}},t)}}}var Qf,$f,ep,tp,np=X({"src/lib/tasks/grep.ts"(){Q(),_f(),Qf=[`-h`],$f=Symbol(`grepQuery`),tp=class{constructor(){this[ep]=[]}*[(ep=$f,Symbol.iterator)](){for(let e of this[$f])yield e}and(...e){return e.length&&this[$f].push(`--and`,`(`,...cd(e,`-e`),`)`),this}param(...e){return this[$f].push(...cd(e,`-e`)),this}}}}),rp={};Mu(rp,{ResetMode:()=>sp,getResetMode:()=>ap,resetTask:()=>ip});function ip(e,t){let n=[`reset`];return op(e)&&n.push(`--${e}`),n.push(...t),ff(n)}function ap(e){if(op(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function op(e){return typeof e==`string`&&cp.includes(e)}var sp,cp,lp=X({"src/lib/tasks/reset.ts"(){Q(),_f(),sp=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(sp||{}),cp=od(Object.values(sp))}});function up(){return(0,Tu.default)(`simple-git`)}function dp(e,t,n){return!t||!String(t).replace(/\s*/,``)?n?(t,...r)=>{e(t,...r),n(t,...r)}:e:(r,...i)=>{e(`%s ${r}`,t,...i),n&&n(r,...i)}}function fp(e,t,{namespace:n}){if(typeof e==`string`)return e;let r=t&&t.namespace||``;return r.startsWith(n)?r.substr(n.length+1):r||n}function pp(e,t,n,r=up()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=fp(_d(t,Cd),o,r);return l(n);function c(t,n){return td(a,pp(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&dp(o,n)||md,s=dp(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var mp=X({"src/lib/git-logger.ts"(){Q(),Tu.default.formatters.L=e=>String(Td(e)?e.length:`-`),Tu.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):hd(e)}}),hp,gp=X({"src/lib/runners/tasks-pending-queue.ts"(){Vu(),mp(),hp=class e{constructor(e=`GitExecutor`){this.logLabel=e,this._queue=new Map}withProgress(e){return this._queue.get(e)}createProgress(t){let n=e.getName(t.commands[0]);return{task:t,logger:pp(this.logLabel,n),name:n}}push(e){let t=this.createProgress(e);return t.logger(`Adding task to the queue, commands = %o`,e.commands),this._queue.set(e,t),t}fatal(e){for(let[t,{logger:n}]of Array.from(this._queue.entries()))t===e.task?(n.info(`Failed %o`,e),n(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`)):n.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`,e.message),this.complete(t);if(this._queue.size!==0)throw Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(e){this.withProgress(e)&&this._queue.delete(e)}attempt(e){let t=this.withProgress(e);if(!t)throw new Bu(void 0,`TasksPendingQueue: attempt called for an unknown task`);return t.logger(`Starting task`),t}static getName(t=`empty`){return`task:${t}:${++e.counter}`}static{this.counter=0}}}});function _p(e,t){return{method:Yu(e.commands)||``,commands:t}}function vp(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function yp(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var bp,xp=X({"src/lib/runners/git-executor-chain.ts"(){Vu(),_f(),Q(),gp(),bp=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new hp}get cwd(){return this._cwd||this._executor.cwd}set cwd(e){this._cwd=e}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(e){return this._queue.push(e),this._chain=this._chain.then(()=>this.attemptTask(e))}async attemptTask(e){let t=await this._scheduler.next(),n=()=>this._queue.complete(e);try{let{logger:t}=this._queue.attempt(e);return await(hf(e)?this.attemptEmptyTask(e,t):this.attemptRemoteTask(e,t))}catch(t){throw this.onFatalException(e,t)}finally{n(),t()}}onFatalException(e,t){let n=t instanceof Bu?Object.assign(t,{task:e}):new Bu(e,t&&String(t));return this._chain=Promise.resolve(),this._queue.fatal(n),n}async attemptRemoteTask(e,t){let n=this._plugins.exec(`spawn.binary`,``,_p(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],_p(e,e.commands)),i=await this.gitResponse(e,n,r,this.outputHandler,t.step(`SPAWN`)),a=await this.handleTaskData(e,r,i,t.step(`HANDLE`));return t(`passing response to task's parser as a %s`,e.format),mf(e)?Ud(e.parser,a):Ud(e.parser,a.asStrings())}async attemptEmptyTask(e,t){return t(`empty task bypassing child process to call to task's parser`),e.parser(this)}handleTaskData(e,t,n,r){let{exitCode:i,rejection:a,stdOut:o,stdErr:s}=n;return new Promise((c,l)=>{r(`Preparing to handle process response exitCode=%d stdOut=`,i);let{error:u}=this._plugins.exec(`task.error`,{error:a},{..._p(e,t),...n});if(u&&e.onError)return r.info(`exitCode=%s handling with custom error handler`),e.onError(n,u,e=>{r.info(`custom error handler treated as success`),r(`custom error returned a %s`,hd(e)),c(new kd(Array.isArray(e)?Buffer.concat(e):e,Buffer.concat(s)))},l);if(u)return r.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`,i,s.length,a),l(u);r.info(`retrieving task output complete`),c(new kd(Buffer.concat(o),Buffer.concat(s)))})}async gitResponse(e,t,n,r,i){let a=i.sibling(`output`),o=this._plugins.exec(`spawn.options`,{cwd:this.cwd,env:this.env,windowsHide:!0},_p(e,e.commands));return new Promise(s=>{let c=[],l=[];i.info(`%s %o`,t,n),i(`%O`,o);let u=this._beforeSpawn(e,n);if(u)return s({stdOut:c,stdErr:l,exitCode:9901,rejection:u});this._plugins.exec(`spawn.before`,void 0,{..._p(e,n),kill(e){u=e||u}});let d=Ui(t,n,o);d.stdout.on(`data`,yp(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,yp(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,vp(l,i)),r&&(i(`Passing child process stdOut/stdErr to custom outputHandler`),r(t,d.stdout,d.stderr,[...n])),this._plugins.exec(`spawn.after`,void 0,{..._p(e,n),spawned:d,close(e,t){s({stdOut:c,stdErr:l,exitCode:e,rejection:u||t})},kill(e){d.killed||(u=e,d.kill(`SIGINT`))}})})}_beforeSpawn(e,t){let n;return this._plugins.exec(`spawn.before`,void 0,{..._p(e,t),kill(e){n=e||n}}),n}}}}),Sp={};Mu(Sp,{GitExecutor:()=>Cp});var Cp,wp=X({"src/lib/runners/git-executor.ts"(){xp(),Cp=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new bp(this,this._scheduler,this._plugins)}chain(){return new bp(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function Tp(e,t,n=md){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof Hu?Ep(t):t,void 0)})}function Ep(e){let t=e=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${e} should be GitResponseError.git.${e}, this will no longer be available in version 3`),t=md};return Object.create(e,Object.getOwnPropertyNames(e.git).reduce(n,{}));function n(n,r){return r in e||(n[r]={enumerable:!1,configurable:!1,get(){return t(r),e.git[r]}}),n}}var Dp=X({"src/lib/task-callback.ts"(){Uu(),Q()}});function Op(e,t){return uf(n=>{if(!ed(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var kp=X({"src/lib/tasks/change-working-directory.ts"(){Q(),_f()}});function Ap(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=rd(t,`-B`)),ff(t)}function jp(){return{checkout(){return this._runTask(Ap(Rd(arguments,1)),Vd(arguments))},checkoutBranch(e,t){return this._runTask(Ap([`-b`,e,t,...Rd(arguments)]),Vd(arguments))},checkoutLocalBranch(e){return this._runTask(Ap([`-b`,e,...Rd(arguments)]),Vd(arguments))}}}var Mp=X({"src/lib/tasks/checkout.ts"(){Q(),_f()}});function Np(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function Pp(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return Wd(Np(),[Fp],e)}})}}}var Fp,Ip=X({"src/lib/tasks/count-objects.ts"(){Q(),Fp=new Z(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=ad(t);Object.hasOwn(e,r)&&(e[r]=sd(n))})}});function Lp(e){return Wd({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},Rp,e)}var Rp,zp=X({"src/lib/parsers/parse-commit.ts"(){Q(),Rp=[new Z(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new Z(/\s*Author:\s(.+)/i,(e,[t])=>{let n=t.split(`<`),r=n.pop();!r||!r.includes(`@`)||(e.author={email:r.substr(0,r.length-1),name:n.join(`<`).trim()})}),new Z(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0,e.summary.insertions=parseInt(n,10)||0,e.summary.deletions=parseInt(r,10)||0}),new Z(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0;let i=parseInt(n,10)||0;r===`-`?e.summary.deletions=i:r===`+`&&(e.summary.insertions=i)})]}});function Bp(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...cd(e,`-m`),...t,...n],format:`utf-8`,parser:Lp}}function Vp(){return{commit(t,...n){let r=Vd(arguments),i=e(t)||Bp(id(t),id(_d(n[0],wd,[])),[...od(_d(n[1],xd,[])),...Rd(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!wd(e)&&df(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var Hp=X({"src/lib/tasks/commit.ts"(){zp(),Q(),_f()}});function Up(){return{firstCommit(){return this._runTask(ff([`rev-list`,`--max-parents=0`,`HEAD`],!0),Vd(arguments))}}}var Wp=X({"src/lib/tasks/first-commit.ts"(){Q(),_f()}});function Gp(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),ff(n,!0)}var Kp=X({"src/lib/tasks/hash-object.ts"(){_f()}});function qp(e,t,n){let r=String(n).trim(),i;if(i=Yp.exec(r))return new Jp(e,t,!1,i[1]);if(i=Xp.exec(r))return new Jp(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new Jp(e,t,/^re/i.test(r),a)}var Jp,Yp,Xp,Zp=X({"src/lib/responses/InitSummary.ts"(){Jp=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},Yp=/^Init.+ repository in (.+)$/,Xp=/^Rein.+ in (.+)$/}});function Qp(e){return e.includes(em)}function $p(e=!1,t,n){let r=[`init`,...n];return e&&!Qp(r)&&r.splice(1,0,em),{commands:r,format:`utf-8`,parser(e){return qp(r.includes(`--bare`),t,e)}}}var em,tm=X({"src/lib/tasks/init.ts"(){Zp(),em=`--bare`}});function nm(e){for(let t=0;t<e.length;t++){let n=im.exec(e[t]);if(n)return`--${n[1]}`}return``}function rm(e){return im.test(e)}var im,am=X({"src/lib/args/log-format.ts"(){im=/^--(stat|numstat|name-only|name-status)(=|$)/}}),om,sm=X({"src/lib/responses/DiffSummary.ts"(){om=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function cm(e=``){let t=pm[e];return e=>Wd(new om,t,e,!1)}var lm,um,dm,fm,pm,mm=X({"src/lib/parsers/parse-diff-summary.ts"(){am(),sm(),Jf(),Q(),lm=[new Z(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:sd(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new Z(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:sd(n),after:sd(r),binary:!0})}),new Z(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=sd(t),e.insertions=sd(r?.[1]),e.deletions=sd(i?.[1])})],um=[new Z(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=sd(t),a=sd(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new Z(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],dm=[new Z(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],fm=[new Z(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(e,[t,n,r,i,a])=>{e.changed++,e.files.push({file:a??r,changes:0,insertions:0,deletions:0,binary:!1,status:fd(Gf(t)&&t),from:fd(!!a&&r!==a&&r),similarity:sd(n)})})],pm={"":lm,"--stat":lm,"--numstat":um,"--name-status":fm,"--name-only":dm}}});function hm(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function gm(e=ym,t=bm,n=``){let r=cm(n);return function(n){let i=Qu(n.trim(),!1,_m).map(function(n){let i=n.split(vm),a=hm(i[0].split(e),t);return i.length>1&&i[1].trim()&&(a.diff=r(i[1])),a});return{all:i,latest:i.length&&i[0]||null,total:i.length}}}var _m,vm,ym,bm,xm=X({"src/lib/parsers/parse-list-log-summary.ts"(){Q(),mm(),am(),_m=`òòòòòò `,vm=` òò`,ym=` ò `,bm=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),Sm={};Mu(Sm,{diffSummaryTask:()=>Cm,validateLogFormatConfig:()=>wm});function Cm(e){let t=nm(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),wm(n)||{commands:n,format:`utf-8`,parser:cm(t)}}function wm(e){let t=e.filter(rm);if(t.length>1)return df(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return df(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var Tm=X({"src/lib/tasks/diff.ts"(){am(),mm(),_f()}});function Em(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function Dm(e){return Object.keys(e).reduce((t,n)=>(n in jm||(t[n]=e[n]),t),{})}function Om(e={},t=[]){let n=_d(e.splitter,Cd,ym),[r,i]=Em(yd(e.format)?e.format:{hash:`%H`,date:e.strictDate===!1?`%ai`:`%aI`,message:`%s`,refs:`%D`,body:e.multiLine?`%B`:`%b`,author_name:e.mailMap===!1?`%an`:`%aN`,author_email:e.mailMap===!1?`%ae`:`%aE`},n),a=[],o=[`--pretty=format:${_m}${i}${vm}`,...t],s=e.n||e[`max-count`]||e.maxCount;if(s&&o.push(`--max-count=${s}`),e.from||e.to){let t=e.symmetric===!1?`..`:`...`;a.push(`${e.from||``}${t}${e.to||``}`)}return Cd(e.file)&&o.push(`--follow`,Fu(e.file)),Ld(Dm(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function km(e,t,n){let r=gm(e,t,nm(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function Am(){return{log(...n){let r=Vd(arguments),i=Om(Bd(arguments),od(_d(arguments[0],xd,[]))),a=t(...n)||wm(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return km(e.splitter,e.fields,e.commands)}function t(e,t){return Cd(e)&&Cd(t)&&df(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var jm,Mm=X({"src/lib/tasks/log.ts"(){am(),zu(),xm(),Q(),_f(),Tm(),jm=(e=>(e[e[`--pretty`]=0]=`--pretty`,e[e[`max-count`]=1]=`max-count`,e[e.maxCount=2]=`maxCount`,e[e.n=3]=`n`,e[e.file=4]=`file`,e[e.format=5]=`format`,e[e.from=6]=`from`,e[e.to=7]=`to`,e[e.splitter=8]=`splitter`,e[e.symmetric=9]=`symmetric`,e[e.mailMap=10]=`mailMap`,e[e.multiLine=11]=`multiLine`,e[e.strictDate=12]=`strictDate`,e))(jm||{})}}),Nm,Pm,Fm=X({"src/lib/responses/MergeSummary.ts"(){Nm=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},Pm=class{constructor(){this.conflicts=[],this.merges=[],this.result=`success`}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(`, `)}`:`OK`}}}}),Im,Lm,Rm=X({"src/lib/responses/PullSummary.ts"(){Im=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},Lm=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function zm(e){return e.objects=e.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function Bm(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:sd(t&&t[1]||`0`),delta:sd(n&&n[1]||`0`)}}var Vm,Hm=X({"src/lib/parsers/parse-remote-objects.ts"(){Q(),Vm=[new Md(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=zm(e.remoteMessages);Object.assign(i,{[r]:sd(n)})}),new Md(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=zm(e.remoteMessages);Object.assign(i,{[r]:sd(n)})}),new Md(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=zm(e.remoteMessages);i.total=Bm(t),i.reused=Bm(n),i.packReused=sd(r)})]}});function Um(e,t){return Wd({remoteMessages:new Gm},Wm,t)}var Wm,Gm,Km=X({"src/lib/parsers/parse-remote-messages.ts"(){Q(),Hm(),Wm=[new Md(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...Vm,new Md([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new Md([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:sd(t),summary:n,url:r}})],Gm=class{constructor(){this.all=[]}}}});function qm(e,t){let n=Wd(new Lm,Qm,[e,t]);return n.message&&n}var Jm,Ym,Xm,Zm,Qm,$m,eh,th=X({"src/lib/parsers/parse-pull.ts"(){Rm(),Q(),Km(),Jm=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Ym=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,Xm=/^(create|delete) mode \d+ (.+)/,Zm=[new Z(Jm,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Z(Ym,(e,[t,,n,,r])=>n!==void 0||r!==void 0?(e.summary.changes=+t||0,e.summary.insertions=+n||0,e.summary.deletions=+r||0,!0):!1),new Z(Xm,(e,[t,n])=>{td(e.files,n),td(t===`create`?e.created:e.deleted,n)})],Qm=[new Z(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new Z(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new Z(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(e,[t,n,r,i])=>{e.branch.local=r,e.hash.local=t,e.branch.remote=i,e.hash.remote=n})],$m=(e,t)=>Wd(new Im,Zm,[e,t]),eh=(e,t)=>Object.assign(new Im,$m(e,t),Um(e,t))}}),nh,rh,ih,ah=X({"src/lib/parsers/parse-merge.ts"(){Fm(),Q(),th(),nh=[new Z(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new Z(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new Nm(t,n))}),new Z(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new Nm(t,n,{deleteRef:r}))}),new Z(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new Nm(t,null))}),new Z(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],rh=(e,t)=>Object.assign(ih(e,t),eh(e,t)),ih=e=>Wd(new Pm,nh,e)}});function oh(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=rh(e,t);if(n.failed)throw new Hu(n);return n}}:df(`Git.merge requires at least one option`)}var sh=X({"src/lib/tasks/merge.ts"(){Uu(),ah(),_f()}});function ch(e,t,n){let r=n.includes(`deleted`),i=n.includes(`tag`)||/^refs\/tags/.test(e),a=!n.includes(`new`);return{deleted:r,tag:i,branch:!i,new:!a,alreadyUpdated:a,local:e,remote:t}}var lh,uh,dh,fh=X({"src/lib/parsers/parse-push.ts"(){Q(),Km(),lh=[new Z(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new Z(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new Z(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(ch(t,n,r))}),new Z(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new Z(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(e,[t,n,r,i])=>{e.update={head:{local:t,remote:n},hash:{from:r,to:i}}})],uh=(e,t)=>{let n=dh(e,t),r=Um(e,t);return{...n,...r}},dh=(e,t)=>Wd({pushed:[]},lh,[e,t])}}),ph={};Mu(ph,{pushTagsTask:()=>mh,pushTask:()=>hh});function mh(e={},t){return td(t,`--tags`),hh(e,t)}function hh(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),rd(n,`-v`),td(n,`--verbose`),td(n,`--porcelain`),{commands:n,format:`utf-8`,parser:uh}}var gh=X({"src/lib/tasks/push.ts"(){fh(),Q()}});function _h(){return{showBuffer(){let e=[`show`,...Rd(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(pf(e),Vd(arguments))},show(){let e=[`show`,...Rd(arguments,1)];return this._runTask(ff(e),Vd(arguments))}}}var vh=X({"src/lib/tasks/show.ts"(){Q(),_f()}}),yh,bh,xh=X({"src/lib/responses/FileStatusSummary.ts"(){yh=/^(.+)\0(.+)$/,bh=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=yh.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function Sh(e){let[t,n]=e.split(pd);return{from:n||t,to:t}}function Ch(e,t,n){return[`${e}${t}`,n]}function wh(e,...t){return t.map(t=>Ch(e,t,(e,t)=>e.conflicted.push(t)))}function Th(e,t){let n=t.trim();switch(` `){case n.charAt(2):return r(n.charAt(0),n.charAt(1),n.slice(3));case n.charAt(1):return r(` `,n.charAt(0),n.slice(2));default:return}function r(t,n,r){let i=`${t}${n}`,a=Dh.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new bh(r,t,n))}}var Eh,Dh,Oh,kh=X({"src/lib/responses/StatusSummary.ts"(){Q(),xh(),Eh=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},Dh=new Map([Ch(` `,`A`,(e,t)=>e.created.push(t)),Ch(` `,`D`,(e,t)=>e.deleted.push(t)),Ch(` `,`M`,(e,t)=>e.modified.push(t)),Ch(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),Ch(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),Ch(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),Ch(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Ch(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Ch(`R`,` `,(e,t)=>{e.renamed.push(Sh(t))}),Ch(`R`,`M`,(e,t)=>{let n=Sh(t);e.renamed.push(n),e.modified.push(n.to)}),Ch(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),Ch(`?`,`?`,(e,t)=>e.not_added.push(t)),...wh(`A`,`A`,`U`),...wh(`D`,`D`,`U`),...wh(`U`,`A`,`D`,`U`),[`##`,(e,t)=>{let n=/ahead (\d+)/,r=/behind (\d+)/,i=/^(.+?(?=(?:\.{3}|\s|$)))/,a=/\.{3}(\S*)/,o=/\son\s(\S+?)(?=\.{3}|$)/,s=n.exec(t);e.ahead=s&&+s[1]||0,s=r.exec(t),e.behind=s&&+s[1]||0,s=i.exec(t),e.current=_d(s?.[1],Cd,null),s=a.exec(t),e.tracking=_d(s?.[1],Cd,null),s=o.exec(t),s&&(e.current=_d(s?.[1],Cd,e.current)),e.detached=/\(no branch\)/.test(t)}]]),Oh=function(e){let t=e.split(pd),n=new Eh;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=pd+(t[e++]||``)),Th(n,r))}return n}}});function Ah(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!jh.includes(e))],parser(e){return Oh(e)}}}var jh,Mh=X({"src/lib/tasks/status.ts"(){kh(),jh=[`--null`,`-z`]}});function Nh(e=0,t=0,n=0,r=``,i=!0){return Object.defineProperty({major:e,minor:t,patch:n,agent:r,installed:i},`toString`,{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function Ph(){return Nh(0,0,0,``,!1)}function Fh(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:Ih,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(Lh));r(t)}})}}}function Ih(e){return e===Lh?Ph():Wd(Nh(0,0,0,e),Rh,e)}var Lh,Rh,zh=X({"src/lib/tasks/version.ts"(){Q(),Lh=`installed=false`,Rh=[new Z(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,Nh(sd(t),sd(n),sd(r),i))}),new Z(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,Nh(sd(t),sd(n),r,i))})]}});function Bh(e,t,n,...r){return Cd(n)?t(n,_d(r[0],Cd),Rd(arguments)):df(`git.${e}() requires a string 'repoPath'`)}function Vh(){return{clone(e,...t){return this._runTask(Bh(`clone`,Hh,_d(e,Cd),...t),Vd(arguments))},mirror(e,...t){return this._runTask(Bh(`mirror`,Uh,_d(e,Cd),...t),Vd(arguments))}}}var Hh,Uh,Wh=X({"src/lib/tasks/clone.ts"(){_f(),Q(),zu(),Hh=(e,t,n)=>{let r=[`clone`,...n];return Cd(e)&&r.push(Fu(e)),Cd(t)&&r.push(Fu(t)),ff(r)},Uh=(e,t,n)=>(td(n,`--mirror`),Hh(e,t,n))}}),Gh={};Mu(Gh,{SimpleGitApi:()=>Kh});var Kh,qh=X({"src/lib/simple-git-api.ts"(){Dp(),kp(),Mp(),Ip(),Hp(),Wf(),Wp(),np(),Kp(),tm(),Mm(),sh(),gh(),vh(),Mh(),_f(),zh(),Q(),Wh(),Kh=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&Tp(e,r,t),Object.create(this,{then:{value:r.then.bind(r)},catch:{value:r.catch.bind(r)},_executor:{value:n}})}add(e){return this._runTask(ff([`add`,...id(e)]),Vd(arguments))}cwd(e){let t=Vd(arguments);return typeof e==`string`?this._runTask(Op(e,this._executor),t):typeof e?.path==`string`?this._runTask(Op(e.path,e.root&&this._executor||void 0),t):this._runTask(df(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(Gp(e,t===!0),Vd(arguments))}init(e){return this._runTask($p(e===!0,this._executor.cwd,Rd(arguments)),Vd(arguments))}merge(){return this._runTask(oh(Rd(arguments)),Vd(arguments))}mergeFromTo(e,t){return Cd(e)&&Cd(t)?this._runTask(oh([e,t,...Rd(arguments)]),Vd(arguments,!1)):this._runTask(df(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=hh({remote:_d(arguments[0],Cd),branch:_d(arguments[1],Cd)},Rd(arguments));return this._runTask(e,Vd(arguments))}stash(){return this._runTask(ff([`stash`,...Rd(arguments)]),Vd(arguments))}status(){return this._runTask(Ah(Rd(arguments)),Vd(arguments))}},Object.assign(Kh.prototype,jp(),Vh(),Vp(),Hf(),Pp(),Up(),Zf(),Am(),_h(),Fh())}}),Jh={};Mu(Jh,{Scheduler:()=>Xh});var Yh,Xh,Zh=X({"src/lib/runners/scheduler.ts"(){Q(),mp(),Yh=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,Eu.createDeferred)();return{promise:t,done:n,id:e}}})(),Xh=class{constructor(e=2){this.concurrency=e,this.logger=pp(``,`scheduler`),this.pending=[],this.running=[],this.logger(`Constructed, concurrency=%s`,e)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`,this.pending.length,this.running.length,this.concurrency);return}let e=td(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),rd(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=td(this.pending,Yh());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),Qh={};Mu(Qh,{applyPatchTask:()=>$h});function $h(e,t){return ff([`apply`,...t,...e])}var eg=X({"src/lib/tasks/apply-patch.ts"(){_f()}});function tg(e,t){return{branch:e,hash:t,success:!0}}function ng(e){return{branch:e,hash:null,success:!1}}var rg,ig=X({"src/lib/responses/BranchDeleteSummary.ts"(){rg=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function ag(e,t){return t===1&&sg.test(e)}var og,sg,cg,lg,ug=X({"src/lib/parsers/parse-branch-delete.ts"(){ig(),Q(),og=/(\S+)\s+\(\S+\s([^)]+)\)/,sg=/^error[^']+'([^']+)'/m,cg=[new Z(og,(e,[t,n])=>{let r=tg(t,n);e.all.push(r),e.branches[t]=r}),new Z(sg,(e,[t])=>{let n=ng(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],lg=(e,t)=>Wd(new rg,cg,[e,t])}}),dg,fg=X({"src/lib/responses/BranchSummary.ts"(){dg=class{constructor(){this.all=[],this.branches={},this.current=``,this.detached=!1}push(e,t,n,r,i){e===`*`&&(this.detached=t,this.current=n),this.all.push(n),this.branches[n]={current:e===`*`,linkedWorkTree:e===`+`,name:n,commit:r,label:i}}}}});function pg(e){return e?e.charAt(0):``}function mg(e,t=!1){return Wd(new dg,t?[gg]:hg,e)}var hg,gg,_g=X({"src/lib/parsers/parse-branch.ts"(){fg(),Q(),hg=[new Z(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(pg(t),!0,n,r,i)}),new Z(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(pg(t),!1,n,r,i)})],gg=new Z(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),vg={};Mu(vg,{branchLocalTask:()=>xg,branchTask:()=>bg,containsDeleteBranchCommand:()=>yg,deleteBranchTask:()=>Cg,deleteBranchesTask:()=>Sg});function yg(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function bg(e){let t=yg(e),n=e.includes(`--show-current`),r=[`branch`,...e];return r.length===1&&r.push(`-a`),r.includes(`-v`)||r.splice(1,0,`-v`),{format:`utf-8`,commands:r,parser(e,r){return t?lg(e,r).all[0]:mg(e,n)}}}function xg(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return mg(e)}}}function Sg(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return lg(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!ag(String(n),e))return i(n);r(t)}}}function Cg(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return lg(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!ag(String(i),e))return o(i);throw new Hu(n.parser(ld(r),ld(t)),String(i))}};return n}var wg=X({"src/lib/tasks/branch.ts"(){Uu(),ug(),_g(),Q()}});function Tg(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&Oi(t)}var Eg,Dg=X({"src/lib/responses/CheckIgnore.ts"(){Eg=e=>e.split(/\n/g).map(Tg).filter(Boolean)}}),Og={};Mu(Og,{checkIgnoreTask:()=>kg});function kg(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:Eg}}var Ag=X({"src/lib/tasks/check-ignore.ts"(){Dg()}});function jg(e,t){return Wd({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},Mg,[e,t])}var Mg,Ng=X({"src/lib/parsers/parse-fetch.ts"(){Q(),Mg=[new Z(/From (.+)$/,(e,[t])=>{e.remote=t}),new Z(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new Z(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new Z(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new Z(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),Pg={};Mu(Pg,{fetchTask:()=>Ig});function Fg(e){return/^--upload-pack(=|$)/.test(e)}function Ig(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(Fg)?df(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:jg}}var Lg=X({"src/lib/tasks/fetch.ts"(){Ng(),_f()}});function Rg(e){return Wd({moves:[]},zg,e)}var zg,Bg=X({"src/lib/parsers/parse-move.ts"(){Q(),zg=[new Z(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),Vg={};Mu(Vg,{moveTask:()=>Hg});function Hg(e,t){return{commands:[`mv`,`-v`,...id(e),t],format:`utf-8`,parser:Rg}}var Ug=X({"src/lib/tasks/move.ts"(){Bg(),Q()}}),Wg={};Mu(Wg,{pullTask:()=>Gg});function Gg(e,t,n){let r=[`pull`,...n];return e&&t&&r.splice(1,0,e,t),{commands:r,format:`utf-8`,parser(e,t){return eh(e,t)},onError(e,t,n,r){let i=qm(ld(e.stdOut),ld(e.stdErr));if(i)return r(new Hu(i));r(t)}}}var Kg=X({"src/lib/tasks/pull.ts"(){Uu(),th(),Q()}});function qg(e){let t={};return Yg(e,([e])=>t[e]={name:e}),Object.values(t)}function Jg(e){let t={};return Yg(e,([e,n,r])=>{Object.hasOwn(t,e)||(t[e]={name:e,refs:{fetch:``,push:``}}),r&&n&&(t[e].refs[r.replace(/[^a-z]/g,``)]=n)}),Object.values(t)}function Yg(e,t){$u(e,e=>t(e.split(/\s+/)))}var Xg=X({"src/lib/responses/GetRemoteSummary.ts"(){Q()}}),Zg={};Mu(Zg,{addRemoteTask:()=>Qg,getRemotesTask:()=>$g,listRemotesTask:()=>e_,remoteTask:()=>t_,removeRemoteTask:()=>n_});function Qg(e,t,n){return ff([`remote`,`add`,...n,e,t])}function $g(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Jg:qg}}function e_(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),ff(t)}function t_(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),ff(t)}function n_(e){return ff([`remote`,`remove`,e])}var r_=X({"src/lib/tasks/remote.ts"(){Xg(),_f()}}),i_={};Mu(i_,{stashListTask:()=>a_});function a_(e={},t){let n=Om(e),r=[`stash`,`list`,...n.commands,...t],i=gm(n.splitter,n.fields,nm(r));return wm(r)||{commands:r,format:`utf-8`,parser:i}}var o_=X({"src/lib/tasks/stash-list.ts"(){am(),xm(),Tm(),Mm()}}),s_={};Mu(s_,{addSubModuleTask:()=>c_,initSubModuleTask:()=>l_,subModuleTask:()=>u_,updateSubModuleTask:()=>d_});function c_(e,t){return u_([`add`,e,t])}function l_(e){return u_([`init`,...e])}function u_(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),ff(t)}function d_(e){return u_([`update`,...e])}var f_=X({"src/lib/tasks/sub-module.ts"(){_f()}});function p_(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?m_(e,t):0:n?1:-1}function m_(e,t){return e===t?0:e>t?1:-1}function h_(e){return e.trim()}function g_(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var __,v_,y_=X({"src/lib/responses/TagList.ts"(){__=class{constructor(e,t){this.all=e,this.latest=t}},v_=function(e,t=!1){let n=e.split(`
|
|
22
|
-
`).map(h_).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return p_(g_(n[0]),g_(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=m_(g_(n[e]),g_(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new __(n,r)}}}),b_={};Mu(b_,{addAnnotatedTagTask:()=>C_,addTagTask:()=>S_,tagListTask:()=>x_});function x_(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return v_(e,t)}}}function S_(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function C_(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var w_=X({"src/lib/tasks/tag.ts"(){y_()}}),T_=ju({"src/git.js"(e,t){var{GitExecutor:n}=(wp(),Pu(Sp)),{SimpleGitApi:r}=(qh(),Pu(Gh)),{Scheduler:i}=(Zh(),Pu(Jh)),{adhocExecTask:a,configurationErrorTask:o}=(_f(),Pu(lf)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(Q(),Pu(Kd)),{applyPatchTask:g}=(eg(),Pu(Qh)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(wg(),Pu(vg)),{checkIgnoreTask:x}=(Ag(),Pu(Og)),{checkIsRepoTask:ee}=(tf(),Pu(qd)),{cleanWithOptionsTask:S,isCleanOptionsArray:C}=(jf(),Pu(vf)),{diffSummaryTask:w}=(Tm(),Pu(Sm)),{fetchTask:te}=(Lg(),Pu(Pg)),{moveTask:T}=(Ug(),Pu(Vg)),{pullTask:E}=(Kg(),Pu(Wg)),{pushTagsTask:D}=(gh(),Pu(ph)),{addRemoteTask:ne,getRemotesTask:re,listRemotesTask:O,remoteTask:k,removeRemoteTask:A}=(r_(),Pu(Zg)),{getResetMode:ie,resetTask:j}=(lp(),Pu(rp)),{stashListTask:ae}=(o_(),Pu(i_)),{addSubModuleTask:oe,initSubModuleTask:M,subModuleTask:se,updateSubModuleTask:ce}=(f_(),Pu(s_)),{addAnnotatedTagTask:N,addTagTask:le,tagListTask:ue}=(w_(),Pu(b_)),{straightThroughBufferTask:de,straightThroughStringTask:fe}=(_f(),Pu(lf));function P(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(P.prototype=Object.create(r.prototype)).constructor=P,P.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},P.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},P.prototype.stashList=function(e){return this._runTask(ae(h(arguments)||{},c(e)&&e||[]),m(arguments))},P.prototype.mv=function(e,t){return this._runTask(T(e,t),m(arguments))},P.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},P.prototype.pull=function(e,t,n,r){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},P.prototype.fetch=function(e,t){return this._runTask(te(f(e,u),f(t,u),p(arguments)),m(arguments))},P.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},P.prototype.tags=function(e,t){return this._runTask(ue(p(arguments)),m(arguments))},P.prototype.rebase=function(){return this._runTask(fe([`rebase`,...p(arguments)]),m(arguments))},P.prototype.reset=function(e){return this._runTask(j(ie(e),p(arguments)),m(arguments))},P.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(fe([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},P.prototype.addTag=function(e){let t=typeof e==`string`?le(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},P.prototype.addAnnotatedTag=function(e,t){return this._runTask(N(e,t),m(arguments))},P.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},P.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},P.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},P.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},P.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(fe(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},P.prototype.submoduleAdd=function(e,t,n){return this._runTask(oe(e,t),m(arguments))},P.prototype.submoduleUpdate=function(e,t){return this._runTask(ce(p(arguments,!0)),m(arguments))},P.prototype.submoduleInit=function(e,t){return this._runTask(M(p(arguments,!0)),m(arguments))},P.prototype.subModule=function(e,t){return this._runTask(se(p(arguments)),m(arguments))},P.prototype.listRemote=function(){return this._runTask(O(p(arguments)),m(arguments))},P.prototype.addRemote=function(e,t,n){return this._runTask(ne(e,t,p(arguments)),m(arguments))},P.prototype.removeRemote=function(e,t){return this._runTask(A(e),m(arguments))},P.prototype.getRemotes=function(e,t){return this._runTask(re(e===!0),m(arguments))},P.prototype.remote=function(e,t){return this._runTask(k(p(arguments)),m(arguments))},P.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(fe(n),m(arguments))},P.prototype.updateServerInfo=function(e){return this._runTask(fe([`update-server-info`]),m(arguments))},P.prototype.pushTags=function(e,t){let n=D({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},P.prototype.rm=function(e){return this._runTask(fe([`rm`,`-f`,...s(e)]),m(arguments))},P.prototype.rmKeepLocal=function(e){return this._runTask(fe([`rm`,`--cached`,...s(e)]),m(arguments))},P.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},P.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},P.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?de(r):fe(r);return this._runTask(a,n)},P.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):fe([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},P.prototype.diffSummary=function(){return this._runTask(w(p(arguments,1)),m(arguments))},P.prototype.applyPatch=function(e){let t=d(e)?g(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},P.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(fe(e,!0),m(arguments))},P.prototype.clean=function(e,t,n){let r=C(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(S(i,a),m(arguments))},P.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},P.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},P.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},P.prototype.checkIsRepo=function(e,t){return this._runTask(ee(f(e,u)),m(arguments))},t.exports=P}});zu(),Vu();var E_=class extends Bu{constructor(e,t){super(void 0,t),this.config=e}};Vu(),Vu();var D_=class extends Bu{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};Uu(),Gu(),tf(),jf(),Wf(),Jf(),np(),lp();function O_(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new D_(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new D_(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function k_(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function A_(e,t){if(typeof t!=`string`||!t.includes(e))return!1;let n=t.trim().replace(/\0/g,``);return/^(--no)?-{1,2}[\dlsqvnobucj]+(\s|$)/.test(n)}function j_(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&k_(i)&&r.test(a))throw new D_(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var M_=[j_(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),j_(`core.sshCommand`,`allowUnsafeSshCommand`),j_(`core.gitProxy`,`allowUnsafeGitProxy`),j_(`core.hooksPath`,`allowUnsafeHooksPath`),j_(`diff.external`,`allowUnsafeDiffExternal`)];function N_(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new D_(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&A_(`u`,e))throw new D_(void 0,`unsafe`,`Use of clone with option -u is not permitted without enabling allowUnsafePack`);if(t===`push`&&/^\s*--exec\b/.test(e))throw new D_(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function P_({allowUnsafePack:e=!1,...t}={}){return{type:`spawn.args`,action(n,r){return n.forEach((i,a)=>{let o=a<n.length?n[a+1]:``;e||N_(i,r.method),M_.forEach(e=>e(t,i,o))}),n}}}Q();function F_(e){let t=cd(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}Q();var I_=(0,Eu.deferred)().promise;function L_({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,Eu.deferred)(),closeTimeout:(0,Eu.deferred)(),exit:(0,Eu.deferred)(),exitTimeout:(0,Eu.deferred)()},a=Promise.race([e===!1?I_:i.closeTimeout.promise,t===!1?I_:i.exitTimeout.promise]);return r(e,i.close,i.closeTimeout),r(t,i.exit,i.exitTimeout),{close(e){n=e,i.close.done()},exit(e){n=e,i.exit.done()},get exitCode(){return n},result:a}}function r(e,t,n){e!==!1&&(e===!0?t.promise:t.promise.then(()=>dd(e))).then(n.done)}return{type:`spawn.after`,async action(e,{spawned:t,close:r}){let i=n(),a=!0,o=()=>void(a=!1);t.stdout?.on(`data`,o),t.stderr?.on(`data`,o),t.on(`error`,o),t.on(`close`,e=>i.close(e)),t.on(`exit`,e=>i.exit(e));try{await i.result,a&&await dd(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}Q();var R_=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,z_=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function B_(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function V_(e,t){if(e.length<1||e.length>2)throw new D_(void 0,`binary`,R_);if(e.some(B_))if(t)console.warn(z_);else throw new D_(void 0,`binary`,z_);let[n,r]=e;return{binary:n,prefix:r}}function H_(e,t=[`git`],n=!1){let r=V_(id(t),n);e.on(`binary`,e=>{r=V_(id(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}Vu();function U_(e){return!!(e.exitCode&&e.stdErr.length)}function W_(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function G_(e=!1,t=U_,n=W_){return(r,i)=>!e&&r||!t(i)?r:n(i)}function K_(e){return{type:`task.error`,action(t,n){let r=e(t.error,{stdErr:n.stdErr,stdOut:n.stdOut,exitCode:n.exitCode});return Buffer.isBuffer(r)?{error:new Bu(void 0,r.toString(`utf-8`))}:{error:r}}}}Q();var q_=class{constructor(){this.plugins=new Set,this.events=new Wi}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=td(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return id(e).forEach(e=>e&&this.plugins.add(td(t,e))),()=>{t.forEach(e=>this.plugins.delete(e))}}exec(e,t,n){let r=t,i=Object.freeze(Object.create(n));for(let t of this.plugins)t.type===e&&(r=t.action(r,i));return r}};Q();function J_(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?nd(e,t):e}},{type:`spawn.after`,action(n,r){r.commands.includes(t)&&r.spawned.stderr?.on(`data`,t=>{let n=/^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(t.toString(`utf8`));n&&e({method:r.method,stage:Y_(n[1]),progress:sd(n[2]),processed:sd(n[3]),total:sd(n[4])})})}}]}function Y_(e){return String(e.toLowerCase().split(` `,1))||`unknown`}Q();function X_(e){let t=ud(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function Z_({block:e,stdErr:t=!0,stdOut:n=!0}){if(e>0)return{type:`spawn.after`,action(r,i){let a;function o(){a&&clearTimeout(a),a=setTimeout(c,e)}function s(){i.spawned.stdout?.off(`data`,o),i.spawned.stderr?.off(`data`,o),i.spawned.off(`exit`,s),i.spawned.off(`close`,s),a&&clearTimeout(a)}function c(){s(),i.kill(new D_(void 0,`timeout`,`block timeout reached`))}n&&i.spawned.stdout?.on(`data`,o),t&&i.spawned.stderr?.on(`data`,o),i.spawned.on(`exit`,s),i.spawned.on(`close`,s),o()}}}zu();function Q_(){return{type:`spawn.args`,action(e){let t=[],n;function r(e){(n||=[]).push(...e)}for(let n=0;n<e.length;n++){let i=e[n];if(Iu(i)){r(Lu(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>Iu(e)&&Lu(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}Q();var $_=T_();function ev(e,t){let n=new q_,r=Pd(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!ed(r.baseDir))throw new E_(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(F_(r.config)),n.add(P_(r.unsafe)),n.add(L_(r.completion)),r.abort&&n.add(O_(r.abort)),r.progress&&n.add(J_(r.progress)),r.timeout&&n.add(Z_(r.timeout)),r.spawnOptions&&n.add(X_(r.spawnOptions)),n.add(Q_()),n.add(K_(G_(!0))),r.errors&&n.add(K_(r.errors)),H_(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new $_(r,n)}Uu();var tv=ev;const nv=`.expect`,rv=L(`ensureStateDir`)(function*(e){let t=yield*Xr,n=Ti.join(e,nv);yield*t.makeDirectory(n,{recursive:!0}).pipe(B(`PlatformError`,()=>gn));let r=Ti.join(n,`.gitignore`);return(yield*t.exists(r).pipe(B(`PlatformError`,()=>z(!1))))||(yield*t.writeFileString(r,`*
|
|
23
|
-
`)
|
|
24
|
-
`)),
|
|
25
|
-
`)),
|
|
26
|
-
`)),
|
|
27
|
-
`)),
|
|
28
|
-
`)
|
|
29
|
-
`)},
|
|
30
|
-
`)){if(e===`selected_commit: undefined`)continue;let t=e.indexOf(`: `);if(t===-1)continue;let n=e.slice(0,t),i=e.slice(t+2);r.set(n,i)}let i={formatVersion:Number(r.get(`format_version`)),title:pv(r.get(`title`)??``),description:pv(r.get(`description`)??``),slug:pv(r.get(`slug`)??``),savedTargetScope:pv(r.get(`saved_target_scope`)??``),savedTargetDisplayName:pv(r.get(`saved_target_display_name`)??``),flow:hv(JSON.parse(r.get(`flow`)??`{}`)),environment:gv(JSON.parse(r.get(`environment`)??`{}`))},a=r.get(`selected_commit`);return a!==void 0&&(i.selectedCommit=pv(a)),i},vv=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),yv=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:vv(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:Bo(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=Pn(e.summary,()=>``);return{id:e.id,title:e.title,instruction:e.instruction===e.title?t||e.title:e.instruction,expectedOutcome:e.expectedOutcome||t}})},environment:{baseUrl:Pn(e.baseUrl,()=>``),cookies:e.requiresCookies}});var bv=class extends tn()(`@supervisor/FlowStorage`,{make:D(function*(){let e=yield*Xr,t=D(function*(){let e=yield*rv(yield*ov);return Ti.join(e,`flows`)});return{save:L(`FlowStorage.save`)(function*(n){let r=yv(n),i=yield*t,a=Ti.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(B(`PlatformError`,()=>gn)),yield*e.writeFileString(a,fv(r)),yield*Ae(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:L(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(B(`PlatformError`,()=>z(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(B(`PlatformError`,()=>z([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(Ti.join(n,t)).pipe(B(`PlatformError`,()=>z(``)));if(!r)continue;let a=yield*cn({try:()=>_v(r),catch:()=>({_tag:`FlowParseError`})}).pipe(B(`FlowParseError`,()=>z(void 0)));a&&i.push(a)}return yield*l(`Flows listed`,{count:i.length}),i})}})}){static layer=b(this)(this.make).pipe(w(Pi.layer))};const xv=(e,t)=>{try{return Ri(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var Sv=class extends qe(`GitHubCommandError`)({_tag:Wr(`GitHubCommandError`),cause:R}){message=`GitHub CLI command failed: ${this.cause}`},Cv=class extends tn()(`@supervisor/GitHub`,{make:D(function*(){let e=yield*jr,t=yield*Xr,n=L(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(Un(`gh`,n,{cwd:t})).pipe(ar(15e3),lr({PlatformError:e=>bn(new Sv({cause:e.message})),TimeoutError:()=>bn(new Sv({cause:`command timed out`}))}),I(e=>e.trim()))}),r=L(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,qn(t).pipe(Cn({_tag:`Branch`},e=>e.branchName),an),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*Gt(Yr(F(us)))(r).pipe(I(rt),B(`SchemaError`,()=>z($e())))}),i=Yr(F(Vo));return{findPullRequest:r,listPullRequests:L(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(B(`GitHubCommandError`,()=>z(`[]`)));return(yield*Gt(i)(t).pipe(B(`SchemaError`,Tn))).map(e=>new Uo({name:e.headRefName,author:e.author.login,prNumber:e.number,prStatus:e.state===`OPEN`?`open`:e.state===`MERGED`||e.state===`CLOSED`?`merged`:null,updatedAt:e.updatedAt}))}),addComment:L(`GitHub.addComment`)(function*(e,r,i){yield*Ot(D(function*(){let a=Di(yield*t.makeTempDirectoryScoped({prefix:`expect-comment-`}),`pull-request-comment.md`);yield*t.writeFileString(a,i),yield*n(e,[`pr`,`comment`,String(r.number),`--body-file`,a])}))})}})}){static layer=b(this)(this.make).pipe(w(Pi.layer))};const wv=e=>Ti.join(Gi.homedir(),nv,`${e}.json`),Tv=new Map,Ev={getItem:async e=>{try{let t=await Ji.readFile(wv(e),`utf-8`);return Tv.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Tv.get(e)===t)return;Tv.set(e,t);let n=wv(e);await Ji.mkdir(Ti.dirname(n),{recursive:!0}),await Ji.writeFile(n,t,`utf-8`)},removeItem:async e=>{Tv.delete(e);try{await Ji.unlink(wv(e))}catch{}}},Dv=e=>Ti.join(process.cwd(),nv,`${e}.json`),Ov=new Map,kv={getItem:async e=>{try{let t=await Ji.readFile(Dv(e),`utf-8`);return Ov.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Ov.get(e)===t)return;Ov.set(e,t);let n=Dv(e);await Ji.mkdir(Ti.dirname(n),{recursive:!0}),await Ji.writeFile(n,t,`utf-8`)},removeItem:async e=>{Ov.delete(e);try{await Ji.unlink(Dv(e))}catch{}}},Av=e=>e.pipe(m(Cv.layer)),jv=async e=>{let t=[];if(e.hasUntestedChanges&&t.push(ds.makeUnsafe({_tag:`WorkingTree`})),e.mainBranch){let n=process.cwd(),r=await M(D(function*(){return yield*(yield*sv).getRecentCommits(`${e.mainBranch}..HEAD`)}).pipe(m(sv.withRepoRoot(n))));for(let e of r)t.push(ds.makeUnsafe({_tag:`Commit`,hash:e.hash,shortHash:e.shortHash,subject:e.subject}))}return t},Mv=e=>M(Av(Cv.use(t=>t.listPullRequests(e)))),Nv=async e=>{let t=await Mv(process.cwd()),n=t.filter(e=>e.prNumber!==null&&e.prStatus===`open`).map(e=>ds.makeUnsafe({_tag:`PullRequest`,branch:e})),r=t.filter(e=>e.prNumber!==null&&e.prStatus===`merged`).slice(0,5).map(e=>ds.makeUnsafe({_tag:`PullRequest`,branch:e})),i=t.filter(t=>t.name!==e.currentBranch&&t.prNumber===null).map(e=>ds.makeUnsafe({_tag:`Branch`,branch:e}));return[...n,...r,...i]},Pv=(e,t)=>e._tag===`WorkingTree`&&t&&!t.isOnMain?t.currentBranch:ms(e),Fv=(e,t)=>{if(e._tag===`WorkingTree`&&t){let e=[];if(t.fileStats.length>0){let n=t.fileStats.reduce((e,t)=>e+t.added,0),r=t.fileStats.reduce((e,t)=>e+t.removed,0),i=t.fileStats.length,a=[];n>0&&a.push(`+${n}`),r>0&&a.push(`-${r}`),a.length>0?e.push(`${a.join(` `)} in ${i} file${i===1?``:`s`}`):e.push(`${i} file${i===1?``:`s`}`)}if(t.branchCommitCount>0&&e.push(`${t.branchCommitCount} commit${t.branchCommitCount===1?``:`s`}`),e.length>0)return e.join(`, `)}return hs(e)},Iv=(e,t)=>e._tag===`WorkingTree`?Pv(e,t):gs(e),Lv=(e,t,n)=>{if(!t)return[...e];let r=t.toLowerCase();return e.filter(e=>(e._tag===`WorkingTree`?`local changes ${n?.currentBranch??``}`:ps(e)).toLowerCase().includes(r))},Rv=()=>hi({queryKey:[`remote-branches`],queryFn:()=>Mv(process.cwd())}),zv=e=>{let t=gi(10);if(t[0]!==`19aae044389a98cd743b540aea8d28df87ba20582cdcc28d3b06005d495ed4de`){for(let e=0;e<10;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`19aae044389a98cd743b540aea8d28df87ba20582cdcc28d3b06005d495ed4de`}let{message:n}=e,r=uo(),i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=G(Yi,{type:`dots`}),t[1]=i):i=t[1];let a;t[2]===r.SELECTION?a=t[3]:(a=G(U,{color:r.SELECTION,children:i}),t[2]=r.SELECTION,t[3]=a);let o;t[4]===n?o=t[5]:(o=n?K(U,{children:[` `,n]}):null,t[4]=n,t[5]=o);let s;return t[6]!==r.DIM||t[7]!==a||t[8]!==o?(s=K(U,{color:r.DIM,children:[a,o]}),t[6]=r.DIM,t[7]=a,t[8]=o,t[9]=s):s=t[9],s},Bv=(e,t)=>{let n=Math.max(0,t-Zi(e));return e+` `.repeat(n)},Vv=({itemCount:e,visibleCount:t,initialIndex:n})=>{let[r,i]=W(n??0),a=Si(e);return a.current!==e&&(a.current=e,i(t=>Math.min(t,Math.max(0,e-1)))),{highlightedIndex:r,setHighlightedIndex:i,scrollOffset:xi(()=>{if(e<=t)return 0;let n=Math.floor(t/2),i=e-t;return Math.min(i,Math.max(0,r-n))},[e,t,r]),handleNavigation:vi((t,n)=>n.downArrow||t===`j`||n.ctrl&&t===`n`?(i(t=>Math.min(e-1,t+1)),!0):n.upArrow||t===`k`||n.ctrl&&t===`p`?(i(e=>Math.max(0,e-1)),!0):!1,[e])}},Hv=/(?:https?:\/\/|localhost[:/]|[\w-]+\.[\w-]+\.[\w]+|[\w-]+\.(com|org|net|io|dev|app|co|me|ai))\S*/i,Uv=e=>Hv.test(e),Wv=Jr(),Gv=e=>Uv(e.instruction)?Wv.Testing(e):Wv.PortPicker(e),Kv=Qi(e=>({screen:Wv.Main(),previousScreen:Wv.Main(),navigateTo:t=>e(e=>({screen:t,previousScreen:e.screen})),setScreen:t=>e({screen:t})})),qv=new fi({defaultOptions:{queries:{staleTime:1/0,retry:!1}}}),Jv=e=>{let t=gi(18);if(t[0]!==`ebd3be31f5201c04dd238bf1bd9d32bf671ecbefa6ad88d45037fbe949e8bb0c`){for(let e=0;e<18;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`ebd3be31f5201c04dd238bf1bd9d32bf671ecbefa6ad88d45037fbe949e8bb0c`}let{title:n,subtitle:r,showDivider:i}=e,a=i===void 0?!0:i,[o]=co(),s,c,l;t[1]!==r||t[2]!==n?(l=n.toUpperCase(),s=r?` │ ${r}`:``,c=Zi(l),t[1]=r,t[2]=n,t[3]=s,t[4]=c,t[5]=l):(s=t[3],c=t[4],l=t[5]);let u=c+Zi(s),d=a?Math.max(0,o-u-3):0,f;t[6]===l?f=t[7]:(f=G(U,{bold:!0,color:Y.text,children:l}),t[6]=l,t[7]=f);let p;t[8]!==r||t[9]!==s?(p=r?G(U,{color:Y.textMuted,children:s}):null,t[8]=r,t[9]=s,t[10]=p):p=t[10];let m;t[11]!==d||t[12]!==a?(m=a?K(U,{color:Y.border,children:[` `,`─`.repeat(d)]}):null,t[11]=d,t[12]=a,t[13]=m):m=t[13];let h;return t[14]!==f||t[15]!==p||t[16]!==m?(h=K(U,{children:[f,p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h},Yv=()=>{let e=gi(39);if(e[0]!==`155bac1331928275f0977c44c5021af2a99f257236d72aa818a512bae62664a8`){for(let t=0;t<39;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`155bac1331928275f0977c44c5021af2a99f257236d72aa818a512bae62664a8`}let[t]=co(),n=Kv(Xv),r=uo(),[i,a]=W(null),[o,s]=W(``),[c,l]=W(`recent`),[u,d]=W(!1),[f,p]=W(void 0),{data:m,isLoading:h}=Rv(),g=m===void 0?[]:m,_=Uo.filterBranches(g,c,o),{highlightedIndex:v,setHighlightedIndex:y,scrollOffset:b,handleNavigation:x}=Vv({itemCount:_.length,visibleCount:15}),ee=t-2-32-16-2,S=_.slice(b,b+15),C;e[1]===y?C=e[2]:(C=e=>{s(ao(e)),y(0)},e[1]=y,e[2]=C);let w=C,te;e[3]===n?te=e[4]:(te=e=>{xv(process.cwd(),e)?(p(void 0),qv.invalidateQueries({queryKey:[`git-state`]}),n(Wv.Main())):p(`Could not checkout "${e}". You may have uncommitted changes or the branch may not exist locally.`)},e[3]=n,e[4]=te);let T=te,E;e[5]!==c||e[6]!==y?(E=e=>{l(Ho[(Ho.indexOf(c)+e+Ho.length)%Ho.length]),y(0)},e[5]=c,e[6]=y,e[7]=E):E=e[7];let D=E;ui((e,t)=>{if(u){t.escape&&d(!1);return}if(!x(e,t)){if(t.rightArrow&&D(1),t.leftArrow&&D(-1),t.return){let e=_[v];e&&(p(void 0),T(e.name))}e===`/`&&d(!0)}});let ne;e[8]!==i||e[9]!==T?(ne=(e,t)=>{i&&(e.toLowerCase()===`y`&&(p(void 0),T(i.name),a(null)),(e.toLowerCase()===`n`||t.escape)&&a(null))},e[8]=i,e[9]=T,e[10]=ne):ne=e[10];let re=i!==null,O;e[11]===re?O=e[12]:(O={isActive:re},e[11]=re,e[12]=O),ui(ne,O);let k=H,A=`${_.length} branches`,ie;e[13]===A?ie=e[14]:(ie=G(H,{paddingX:1,children:G(Jv,{title:`Select a PR or branch to test`,subtitle:A})}),e[13]=A,e[14]=ie);let j;e[15]!==r||e[16]!==c||e[17]!==y?(j=Ho.map((e,t)=>{let n=e===c,i=t<Ho.length-1?` · `:``,a={recent:r.CYAN,all:r.TEXT,open:r.GREEN,draft:r.DIM,merged:r.PURPLE,"no-pr":r.YELLOW};return K(H,{children:[G(mo,{fullWidth:!1,onClick:()=>{l(e),y(0)},children:G(U,{color:n?a[e]:r.DIM,children:n?`[${e}]`:e})}),G(U,{color:r.DIM,children:i})]},e)}),e[15]=r,e[16]=c,e[17]=y,e[18]=j):j=e[18];let ae;e[19]===j?ae=e[20]:(ae=G(H,{marginTop:1,paddingX:1,children:j}),e[19]=j,e[20]=ae);let oe=h?G(H,{marginTop:1,paddingX:1,children:G(zv,{message:`Fetching PRs...`})}):K(H,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:[S.map((e,t)=>{let n=t+b,i=n===v;return K(mo,{onClick:()=>{y(n),T(e.name)},children:[G(U,{color:i?r.PRIMARY:r.DIM,children:i?`${q.pointer} `:` `}),G(U,{color:i?r.PRIMARY:r.DIM,bold:i,children:Bv(Xi(e.name,31),32)}),G(U,{color:r.CYAN,children:Bv(Xi(e.author||`—`,15),16)}),e.prNumber&&e.prStatus?G(U,{color:e.prStatus===`open`?r.GREEN:e.prStatus===`merged`?r.PURPLE:r.DIM,children:Xi(`#${e.prNumber} ${e.prStatus}`,ee)}):G(U,{color:r.DIM,children:`—`})]},e.name)}),_.length===0&&G(U,{color:r.DIM,children:`No matching branches`})]}),M;e[21]!==r||e[22]!==f?(M=f?G(H,{marginTop:1,paddingX:1,children:G(U,{color:r.RED,children:f})}):null,e[21]=r,e[22]=f,e[23]=M):M=e[23];let se;e[24]!==r||e[25]!==i?(se=i?K(fo,{color:r.YELLOW,marginTop:1,children:[K(U,{color:r.YELLOW,bold:!0,children:[`Switch to `,i.name,`?`]}),K(U,{color:r.DIM,children:[`Press `,G(U,{color:r.PRIMARY,children:`y`}),` to continue or`,` `,G(U,{color:r.PRIMARY,children:`n`}),` to cancel.`]})]}):null,e[24]=r,e[25]=i,e[26]=se):se=e[26];let ce;e[27]!==w||e[28]!==u||e[29]!==o?(ce=G(H,{paddingX:1,children:G(xo,{isSearching:u,query:o,onChange:w})}),e[27]=w,e[28]=u,e[29]=o,e[30]=ce):ce=e[30];let N;return e[31]!==k||e[32]!==ie||e[33]!==ae||e[34]!==oe||e[35]!==M||e[36]!==se||e[37]!==ce?(N=K(k,{flexDirection:`column`,width:`100%`,paddingY:1,children:[ie,ae,oe,M,se,ce]}),e[31]=k,e[32]=ie,e[33]=ae,e[34]=oe,e[35]=M,e[36]=se,e[37]=ce,e[38]=N):N=e[38],N};function Xv(e){return e.setScreen}const Zv=Ei.join(process.cwd(),`.expect`,`logs.md`),Qv=vn.pipe(Ir(Zv)),$v=ne(Ur(D(function*(){let e=yield*Xr;yield*e.makeDirectory(Ei.dirname(Zv),{recursive:!0}),yield*e.writeFileString(Ei.join(Ei.dirname(Zv),`.gitignore`),`*
|
|
31
|
-
`)})),Vt([Qv])).pipe(w(Ni.layer));var ey=n(((t,n)=>{(function(r,i){typeof t==`object`&&typeof n==`object`?n.exports=i(e(`child_process`),e(`crypto`)):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],i):typeof t==`object`?t[`electron-machine-id`]=i(e(`child_process`),e(`crypto`)):r[`electron-machine-id`]=i(r.child_process,r.crypto)})(t,function(t,n){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,S,C,w=function(e){if(!p&&e in D)return D[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},te=t+` Iterator`,T=y==g,E=!1,D=e.prototype,ne=D[f]||D[m]||y&&D[y],re=ne||w(y),O=y?T?w(`entries`):re:void 0,k=t==`Array`&&D.entries||ne;if(k&&(C=d(k.call(new e)),C!==Object.prototype&&(u(C,te,!0),r||s(C,f)||o(C,f,_))),T&&ne&&ne.name!==g&&(E=!0,re=function(){return ne.call(this)}),r&&!x||!p&&!E&&D[f]||o(D,f,re),c[t]=re,c[te]=_,y)if(ee={values:T?re:w(g),keys:b?re:w(h),entries:O},x)for(S in ee)S in D||a(D,S,ee[S]);else i(i.P+i.F*(p||E),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
|
|
32
|
-
`)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,`__esModule`,{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,S=function(){},C=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(S,S)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(S)instanceof t}catch{}}(),w=function(e,t){return e===t||e===x&&t===a},te=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},T=function(e){return w(x,e)?new E(e):new i(e)},E=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},D=function(e){try{e()}catch(e){return{error:e}}},ne=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&k(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=te(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&re(e)})}},re=function(e){g.call(s,function(){var t,n,r,i=e._v;if(O(e)&&(t=D(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||O(e)?2:1),e._a=void 0,t)throw t.error})},O=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!O(t.promise))return!1;return!0},k=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},A=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),ne(t,!0))},ie=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=te(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(ie,r,1),c(A,r,1))}catch(e){A.call(r,e)}}):(n._v=e,n._s=1,ne(n,!1))}catch(e){A.call({_w:n,_d:!1},e)}}};C||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(ie,this,1),c(A,this,1))}catch(e){A.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=T(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&ne(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),E=function(){var e=new r;this.promise=e,this.resolve=c(ie,e,1),this.reject=c(A,e,1)}),u(u.G+u.W+u.F*!C,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!C,v,{reject:function(e){var t=T(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!C),v,{resolve:function(e){if(e instanceof x&&w(e.constructor,this))return e;var t=T(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(C&&n(46)(function(e){x.all(e).catch(S)})),v,{all:function(e){var t=this,n=T(t),r=n.resolve,i=n.reject,a=D(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=T(t),r=n.reject,i=D(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(t,n){t.exports=e(`child_process`)},function(t,n){t.exports=e(`crypto`)}])})}))();function ty(e){return typeof e==`string`?`'${e}'`:new ny().serialize(e)}const ny=function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?e.localeCompare(t):n===`number`&&r===`number`?e-t:String.prototype.localeCompare.call(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}return this.serializeObjectEntries(r,Object.entries(e))}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t?.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`,`)}]`};for(let t of[`BigInt64Array`,`BigUint64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`n,`)}${e.length>0?`n`:``}]`};return e}(),ry=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,iy=`sha256`,ay=`base64url`;function oy(e){if(ry)return ry(iy,e,ay);let t=Bi(iy).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(ay):t.digest(ay)}function sy(e){return oy(ty(e))}function cy(){let e=ly();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function ly(e=process.argv[1]?$i(process.argv[1]):process.cwd(),t=ta===`\\`){let n=t?uy(e):e;return e=>{if(!e)return;let r=t?uy(e):e,{dir:i,base:a,ext:o}=ea.parse(r);(o===`.js`||o===`.mjs`||o===`.cjs`)&&(a=a.slice(0,-1*o.length));let s=decodeURIComponent(a);i||=`.`;let c=i.lastIndexOf(`/node_modules`);if(c>-1)return`${i.slice(c+14).replace(/\//g,`.`)}:${s}`;if(i.startsWith(n)){let e=i.slice(n.length+1).replace(/\//g,`.`);return e?`${e}:${s}`:s}return s}}function uy(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const dy=e=>{if(`flags`in e){let t=py(e.flags),n=my(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,gy(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,fy(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function fy(e,t,n){return{key:e,enabled:typeof t==`string`?!0:t,variant:typeof t==`string`?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:n?JSON.stringify(n):void 0,description:void 0}}}const py=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,hy(t)]).filter(([,e])=>e!==void 0)),my=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(e=>{let n=t[e];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(e=>{let n=t[e].metadata?.payload;return[e,n?gy(n):void 0]}))},hy=e=>e===void 0?void 0:e.variant??e.enabled,gy=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},_y=`0123456789abcdef`;var vy=class e{constructor(e){this.bytes=e}static ofInner(t){if(t.length===16)return new e(t);throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let n;switch(t.length){case 32:n=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:n=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join(``);break;case 38:n=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join(``);break;case 45:n=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join(``);break;default:break}if(n){let t=new Uint8Array(16);for(let e=0;e<16;e+=4){let r=parseInt(n.substring(2*e,2*e+8),16);t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r}return new e(t)}throw SyntaxError(`could not parse UUID string`)}toString(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=_y.charAt(this.bytes[t]>>>4),e+=_y.charAt(15&this.bytes[t]),(t===3||t===5||t===7||t===9)&&(e+=`-`);return e}toHex(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=_y.charAt(this.bytes[t]>>>4),e+=_y.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){let e=this.bytes[8]>>>4;if(e<0)throw Error(`unreachable`);if(e<=7)return this.bytes.every(e=>e===0)?`NIL`:`VAR_0`;if(e<=11)return`VAR_10`;if(e<=13)return`VAR_110`;if(e<=15)return this.bytes.every(e=>e===255)?`MAX`:`VAR_RESERVED`;throw Error(`unreachable`)}getVersion(){return this.getVariant()===`VAR_10`?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;t<16;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},yy=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??by()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){let n=this.generateOrAbortCore(e,t);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(e,t)),n}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return vy.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,vy.ofInner(e)}};const by=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let xy;const Sy=()=>Cy().toString(),Cy=()=>(xy||=new yy).generate();var wy=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e}({});const Ty=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),Ey=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return Ty.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},Dy=Array.isArray,Oy=Object.prototype;Oy.hasOwnProperty;const ky=Oy.toString,Ay=Dy||function(e){return ky.call(e)===`[object Array]`},jy=e=>e===Object(e)&&!Ay(e),My=e=>e===void 0,Ny=e=>ky.call(e)==`[object String]`,Py=e=>Ny(e)&&e.trim().length===0,Fy=e=>ky.call(e)==`[object Number]`&&e===e,Iy=e=>e instanceof Error;function Ly(e){return typeof e!=`object`||!e}function Ry(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function zy(e){return!My(Event)&&Vy(e,Event)}function By(e){return Ry(e,`Object`)}function Vy(e,t){try{return e instanceof t}catch{return!1}}function Hy(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Fy(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):e<t?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),Hy(i||n,t,n,r))}var Uy=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Hy(e.bucketSize,0,100,e._logger),this._refillRate=Hy(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Hy(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){let n=t-e.lastAccess,r=Math.floor(n/this._refillInterval);if(r>0){let t=r*this._refillRate;e.tokens=Math.min(e.tokens+t,this._bucketSize),e.lastAccess+=r*this._refillInterval}}consumeRateLimit(e){let t=Date.now(),n=String(e),r=this._buckets[n];return r?this._applyRefill(r,t):(r={tokens:this._bucketSize,lastAccess:t},this._buckets[n]=r),r.tokens===0?!0:(r.tokens--,r.tokens===0&&this._onBucketRateLimited?.(e),r.tokens===0)}stop(){this._buckets={}}},Wy=class{add(e){let t=Sy();return this.promiseByIds[t]=e,e.catch(()=>{}).finally(()=>{delete this.promiseByIds[t]}),e}async join(){let e=Object.values(this.promiseByIds),t=e.length;for(;t>0;)await Promise.all(e),e=Object.values(this.promiseByIds),t=e.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function Gy(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const Ky=(e,t,n)=>{function r(r,...i){t(()=>{let t=n[r];t(e,...i)})}return{info:(...e)=>{r(`log`,...e)},warn:(...e)=>{r(`warn`,...e)},error:(...e)=>{r(`error`,...e)},critical:(...t)=>{n.error(e,...t)},createLogger:r=>Ky(`${e} ${r}`,t,n)}},qy=e=>e();function Jy(e,t=qy){return Ky(e,t,Gy())}const Yy=`Android`;Yy+``;const Xy=`BlackBerry`,Zy=`Samsung`;Zy+``,Zy+``;const Qy=`Chrome`;Qy+``,Qy+``;const $y=`Opera`;$y+``;const eb=`Edge`;``+eb;const tb=`Firefox`;tb+``;const nb=`Nintendo`,rb=`PlayStation`,ib=`Xbox`;Yy+``;const ab=`Windows`;ab+``;const ob=`Generic`;ob+``,ob+``;const sb=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+sb),new RegExp(ib,`i`),RegExp(rb+` \\w+`,`i`),RegExp(nb+` \\w+`,`i`),RegExp(Xy+`|PlayBook|BB10`,`i`),RegExp(`rv:`+sb),RegExp(eb+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+Qy+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+sb),RegExp(`(UCBrowser|UCWEB)\\/`+sb),RegExp(`(`+$y+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp(tb+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+sb),RegExp(`Konqueror[:/]?`+sb,`i`),RegExp(Xy+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+sb,`i`),RegExp(`(rv:|MSIE )`+sb),RegExp(`rv:`+sb),RegExp(ib+`; Xbox (.*?)[);]`,`i`),new RegExp(nb,`i`),new RegExp(rb,`i`),new RegExp(ab,`i`),RegExp(`(`+Yy+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function cb(e,t){if(!e||typeof e!=`string`||lb(e))throw Error(t)}function lb(e){return e.trim().length===0}function ub(e){return e?.replace(/\/+$/,``)}async function db(e,t){let n=null;for(let r=0;r<t.retryCount+1;r++){r>0&&await new Promise(e=>setTimeout(e,t.retryDelay));try{return await e()}catch(e){if(n=e,!t.retryCheck(e))throw e}}throw n}function fb(){return new Date().toISOString()}function pb(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const mb=e=>e instanceof Error;function hb(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var gb=class{constructor(){this.events={},this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.events[e]||[])n(t);for(let n of this.events[`*`]||[])n(e,t)}};function _b(){return`CompressionStream`in globalThis}async function vb(e,t=!0){try{let t=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return await new Response(t).blob()}catch(e){return t&&console.error(`Failed to gzip compress data`,e),null}}var yb=class extends Error{constructor(e,t){super(`HTTP error while fetching PostHog: status=`+e.status+`, reqByteLength=`+t),this.response=e,this.reqByteLength=t,this.name=`PostHogFetchHttpError`}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},bb=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function xb(e){if(e instanceof yb){let t=``;try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error(`Error while flushing PostHog`,e);return Promise.resolve()}function Sb(e){return typeof e==`object`&&(e instanceof yb||e instanceof bb)}function Cb(e){return typeof e==`object`&&e instanceof yb&&e.status===413}var wb=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new Wy,this._events=new gb,this._isInitialized=!1,cb(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=ub(t.host||`https://us.i.posthog.com`),this.flushAt=t.flushAt?Math.max(t.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,t.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,t.maxQueueSize??1e3),this.flushInterval=t.flushInterval??1e4,this.preloadFeatureFlags=t.preloadFeatureFlags??!0,this.defaultOptIn=t.defaultOptIn??!0,this.disableSurveys=t.disableSurveys??!1,this._retryOptions={retryCount:t.fetchRetryCount??3,retryDelay:t.fetchRetryDelay??3e3,retryCheck:Sb},this.requestTimeout=t.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=t.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=t.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=t.disableGeoip??!0,this.disabled=t.disabled??!1,this.historicalMigration=t?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=Jy(`[PostHog]`,this.logMsgIfDebug.bind(this)),this.evaluationContexts=t?.evaluationContexts??t?.evaluationEnvironments,t?.evaluationEnvironments&&!t?.evaluationContexts&&this._logger.warn(`evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version.`),this.disableCompression=!_b()||(t?.disableCompression??!1)}logMsgIfDebug(e){this.isDebug&&e()}wrap(e){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized)return e();this._initPromise.then(()=>e())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(wy.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(wy.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(wy.OptedOut,!0)})}on(e,t){return this._events.on(e,t)}debug(e=!0){if(this.removeDebugCallback?.(),e){let e=this.on(`*`,(e,t)=>this._logger.info(e,t));this.removeDebugCallback=()=>{e(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(e){return{distinct_id:e.distinct_id,event:e.event,properties:{...e.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(e){return this.promiseQueue.add(e)}identifyStateless(e,t,n){this.wrap(()=>{let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};this.enqueue(`identify`,r,n)})}async identifyStatelessImmediate(e,t,n){let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};await this.sendImmediate(`identify`,r,n)}captureStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({distinct_id:e,event:t,properties:n});this.enqueue(`capture`,i,r)})}async captureStatelessImmediate(e,t,n,r){let i=this.buildPayload({distinct_id:e,event:t,properties:n});await this.sendImmediate(`capture`,i,r)}aliasStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});this.enqueue(`alias`,i,r)})}async aliasStatelessImmediate(e,t,n,r){let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});await this.sendImmediate(`alias`,i,r)}groupIdentifyStateless(e,t,n,r,i,a){this.wrap(()=>{let o=this.buildPayload({distinct_id:i||`$${e}_${t}`,event:`$groupidentify`,properties:{$group_type:e,$group_key:t,$group_set:n||{},...a||{}}});this.enqueue(`capture`,o,r)})}async getRemoteConfig(){await this._initPromise;let e=this.host;e===`https://us.i.posthog.com`?e=`https://us-assets.i.posthog.com`:e===`https://eu.i.posthog.com`&&(e=`https://eu-assets.i.posthog.com`);let t=`${e}/array/${this.apiKey}/config`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}};return this.fetchWithRetry(t,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(e=>e.json()).catch(e=>{this._logger.error(`Remote config could not be loaded`,e),this._events.emit(`error`,e)})}async getFlags(e,t={},n={},r={},i={},a=!1){await this._initPromise;let o=a?`&config=true`:``,s=`${this.host}/flags/?v=2${o}`,c={token:this.apiKey,distinct_id:e,groups:t,person_properties:n,group_properties:r,...i};this.evaluationContexts&&this.evaluationContexts.length>0&&(c.evaluation_contexts=this.evaluationContexts);let l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`},body:JSON.stringify(c)};return this._logger.info(`Flags URL`,s),this.fetchWithRetry(s,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(e=>e.json()).then(e=>({success:!0,response:dy(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof yb)return{type:`api_error`,statusCode:e.status};if(e instanceof bb){let t=e.error;return t instanceof Error&&(t.name===`AbortError`||t.name===`TimeoutError`)?{type:`timeout`}:{type:`connection_error`}}return{type:`unknown_error`}}async getFeatureFlagStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailStateless(e,t,n,r,i,a);if(o===void 0)return{response:void 0,requestId:void 0};let s=hy(o.response);return s===void 0&&(s=!1),{response:s,requestId:o.requestId}}async getFeatureFlagDetailStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(t,n,r,i,a,[e]);if(o!==void 0)return{response:o.flags[e],requestId:o.requestId,evaluatedAt:o.evaluatedAt}}async getFeatureFlagPayloadStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagPayloadsStateless(t,n,r,i,a,[e]);if(!o)return;let s=o[e];return s===void 0?null:s}async getFeatureFlagPayloadsStateless(e,t={},n={},r={},i,a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)).payloads}async getFeatureFlagsStateless(e,t={},n={},r={},i,a){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)}async getFeatureFlagsAndPayloadsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(e,t,n,r,i,a);return o?{flags:o.featureFlags,payloads:o.featureFlagPayloads,requestId:o.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o={};(i??this.disableGeoip)&&(o.geoip_disable=!0),a&&(o.flag_keys_to_evaluate=a);let s=await this.getFlags(e,t,n,r,o);if(!s.success)return;let c=s.response;return c.errorsWhileComputingFlags&&console.error(`[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices`),c.quotaLimited?.includes(`feature_flags`)?(console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:c?.requestId,quotaLimited:c.quotaLimited}):c}async getSurveysStateless(){if(await this._initPromise,!0===this.disableSurveys)return this._logger.info(`Loading surveys is disabled.`),[];let e=`${this.host}/api/surveys/?token=${this.apiKey}`,t={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}},n=(await this.fetchWithRetry(e,t).then(e=>{if(e.status!==200||!e.json){let t=`Surveys API could not be loaded: ${e.status}`,n=Error(t);this._logger.error(n),this._events.emit(`error`,Error(t));return}return e.json()}).catch(e=>{this._logger.error(`Surveys API could not be loaded`,e),this._events.emit(`error`,e)}))?.surveys;return n&&this._logger.info(`Surveys fetched from API: `,JSON.stringify(n)),n??[]}get props(){return this._props||=this.getPersistedProperty(wy.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(wy.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(wy.Props,this.props)})}processBeforeEnqueue(e){return e}async flushStorage(){}enqueue(e,t,n){this.wrap(()=>{if(this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r=this.prepareMessage(e,t,n);if(r=this.processBeforeEnqueue(r),r===null)return;let i=this.getPersistedProperty(wy.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(wy.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=pb(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(e,t,n){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r=this.prepareMessage(e,t,n);if(r=this.processBeforeEnqueue(r),r===null)return;let i={api_key:this.apiKey,batch:[r],sent_at:fb()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await vb(a,this.isDebug),c={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...s!==null&&{"Content-Encoding":`gzip`}},body:s||a};try{await this.fetchWithRetry(o,c)}catch(e){this._events.emit(`error`,e)}}prepareMessage(e,t,n){let r={...t,type:e,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:fb(),uuid:n?.uuid?n.uuid:Sy()};return(n?.disableGeoip??this.disableGeoip)&&(r.properties||={},r.properties.$geoip_disable=!0),r.distinctId&&(r.distinct_id=r.distinctId,delete r.distinctId),r}clearFlushTimer(){this._flushTimer&&=(clearTimeout(this._flushTimer),void 0)}flushBackground(){this.flush().catch(async e=>{await xb(e)})}async flush(){let e=hb([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),hb([e]).then(()=>{this.flushPromise===e&&(this.flushPromise=null)}),e}getCustomHeaders(){let e=this.getCustomUserAgent(),t={};return e&&e!==``&&(t[`User-Agent`]=e),t}async _flush(){this.clearFlushTimer(),await this._initPromise;let e=this.getPersistedProperty(wy.Queue)||[];if(!e.length)return;let t=[],n=e.length;for(;e.length>0&&t.length<n;){let n=e.slice(0,this.maxBatchSize),r=n.map(e=>e.message),i=async()=>{let t=(this.getPersistedProperty(wy.Queue)||[]).slice(n.length);this.setPersistedProperty(wy.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:fb()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await vb(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>Cb(e)?!1:Sb(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(Cb(e)&&r.length>1){this.maxBatchSize=Math.max(1,Math.floor(r.length/2)),this._logger.warn(`Received 413 when sending batch of size ${r.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw e instanceof bb||await i(),this._events.emit(`error`,e),e}await i(),t.push(...r)}this._events.emit(`flush`,t)}async fetchWithRetry(e,t,n,r){let i=t.body?t.body:``,a=-1;try{a=i instanceof Blob?i.size:Buffer.byteLength(i,`utf8`)}catch{a=i instanceof Blob?i.size:new TextEncoder().encode(i).length}return await db(async()=>{let n=new AbortController,i=pb(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new bb(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new yb(o,a);return o},{...this._retryOptions,...n})}async _shutdown(e=3e4){await this._initPromise;let t=!1;this.clearFlushTimer();let n=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(wy.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!Sb(e))throw e;await xb(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=pb(()=>{this._logger.error(`Timed out while shutting down PostHog`),t=!0,i(`Timeout while shutting down PostHog. Some events may not have been sent.`)},e)}),n()])}finally{clearTimeout(r)}}async shutdown(e=3e4){return this.shutdownPromise?this._logger.warn(`shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup`):this.shutdownPromise=this._shutdown(e).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}};let Tb,Eb,Db;function Ob(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Db&&n.length===Eb?Db:(Eb=n.length,Db=n.reduce((n,r)=>{Tb||={};let i=Tb[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,Tb[r]=[a,o];break}}}return n},{}),Db)}var kb=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}async modifyFrames(e){for(let t of e)t.stacktrace&&t.stacktrace.frames&&Ay(t.stacktrace.frames)&&(t.stacktrace.frames=await this.applyModifiers(t.stacktrace.frames));return e}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n;e.cause!=null&&(n=this.parseStacktrace(e.cause,t));let r;return e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),{...e,cause:n,stack:r}}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}async applyModifiers(e){let t=e;for(let e of this.modifiers)t=await e(t);return t}convertToExceptionList(e,t){let n={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:t.handled??!0,synthetic:e.synthetic??!1}};e.stack&&(n.stacktrace={type:`raw`,frames:e.stack});let r=[n];return e.cause!=null&&r.push(...this.convertToExceptionList(e.cause,{...t,handled:!0})),r}buildParsingContext(e){return{chunkIdMap:Ob(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n=0){let r=(n,r)=>{if(r<=4){let i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return{...t,syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)}}};const Ab=/^\s*[-]{4,}$/,jb=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,Mb=(e,t)=>{let n=e.match(jb);if(n){let e,r,i,a,o;if(n[1]){i=n[1];let t=i.lastIndexOf(`.`);if(i[t-1]===`.`&&t--,t>0){e=i.slice(0,t),r=i.slice(t+1);let n=e.indexOf(`.Module`);n>0&&(i=i.slice(n+1),e=e.slice(0,n))}a=void 0}r&&(a=e,o=r),r===`<anonymous>`&&(o=void 0,i=void 0),i===void 0&&(o||=`?`,i=a?`${a}.${o}`:o);let s=n[2]?.startsWith(`file://`)?n[2].slice(7):n[2],c=n[5]===`native`;return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&n[5]&&!c&&(s=n[5]),{filename:s?decodeURI(s):void 0,module:void 0,function:i,lineno:Pb(n[3]),colno:Pb(n[4]),in_app:Nb(s||``,c),platform:t}}if(e.match(Ab))return{filename:e,platform:t}};function Nb(e,t=!1){return!(t||e&&!e.startsWith(`/`)&&!e.match(/^[A-Z]:/)&&!e.startsWith(`.`)&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes(`node_modules/`)}function Pb(e){return parseInt(e||``,10)||void 0}const Fb=/\(error: (.*)\)/;function Ib(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||Lb(t).filename,function:e.function||`?`}))}function Lb(e){return e[e.length-1]||{}}function Rb(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
|
|
33
|
-
`);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=Fb.test(r)?r.replace(Fb,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);break}}if(i.length>=50)break}}return Ib(i)}}var zb=class{match(e){return Iy(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return n.error&&typeof n.error.message==`string`?String(n.error.message):String(n)}getStack(e){return e.stacktrace||e.stack||void 0}};const Bb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Vb=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(Bb);return r&&(t=r[1],n=r[2]),[t,n]}};const Hb=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Ub(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(!(r.length>t))return e===n.length||r.length<=t?r:`${r.slice(0,t)}...`}return``}var Wb=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return zy(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e),n=Ub(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return Ny(e)&&!Py(e)&&Hb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(mb(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Gb=class{match(e){return zy(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Ub(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},Kb=class{match(e){return Ly(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},qb=class{constructor(e){this._maxSize=e,this._cache=new Map}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.set(e,t)}reduce(){for(;this._cache.size>=this._maxSize;){let e=this._cache.keys().next().value;e&&this._cache.delete(e)}}};const Jb=new qb(25),Yb=new qb(20);async function Xb(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n],i=r?.filename;!r||typeof i!=`string`||typeof r.lineno!=`number`||tx(i)||nx(r)||(t[i]||(t[i]=[]),t[i].push(r.lineno))}let n=Object.keys(t);if(n.length==0)return e;let r=[];for(let e of n){if(Yb.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=ix(n);if(i.every(t=>rx(e,t)))continue;let a=cx(Jb,e,{});r.push(Zb(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&Qb(e,Jb),Jb.reduce(),e}function Zb(e,t,n){return new Promise(r=>{let i=ra(e),a=ia({input:i});function o(){i.destroy(),r()}let s=0,c=0,l=t[c];if(l===void 0)return void o();let u=l[0],d=l[1];function f(){Yb.set(e,1),a.close(),a.removeAllListeners(),o()}i.on(`error`,f),a.on(`error`,f),a.on(`close`,o),a.on(`line`,e=>{if(s++,!(s<u)&&(n[s]=lx(e,0),s>=d)){if(c===t.length-1){a.close(),a.removeAllListeners();return}c++;let e=t[c];if(e===void 0){a.close(),a.removeAllListeners();return}u=e[0],d=e[1]}})})}function Qb(e,t){for(let n of e)if(n.filename&&n.context_line===void 0&&typeof n.lineno==`number`){let e=t.get(n.filename);if(e===void 0)continue;$b(n.lineno,n,e)}}function $b(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=ox(e);r<e;r++){let e=n[r];if(e===void 0)return void ex(t);t.pre_context.push(e)}if(n[e]===void 0)return void ex(t);t.context_line=n[e];let r=sx(e);t.post_context=[];for(let i=e+1;i<=r;i++){let e=n[i];if(e===void 0)break;t.post_context.push(e)}}function ex(e){delete e.pre_context,delete e.context_line,delete e.post_context}function tx(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function nx(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function rx(e,t){let n=Jb.get(e);if(n===void 0)return!1;for(let e=t[0];e<=t[1];e++)if(n[e]===void 0)return!1;return!0}function ix(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=ax(n),i=[];for(;;){if(t===e.length-1){i.push(r);break}let n=e[t+1];if(typeof n!=`number`)break;n<=r[1]?r[1]=n+7:(i.push(r),r=ax(n)),t++}return i}function ax(e){return[ox(e),sx(e)]}function ox(e){return Math.max(1,e-7)}function sx(e){return e+7}function cx(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function lx(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`...${n}`),a<r&&(n+=`...`),n}function ux(e,t){let n=!1;return Object.assign(r=>{let i=global.process.listeners(`uncaughtException`).filter(e=>e.name!==`domainUncaughtExceptionClear`&&!0!==e._posthogErrorHandler).length===0;e(r,{mechanism:{type:`onuncaughtexception`,handled:!1}}),!n&&i&&(n=!0,t(r))},{_posthogErrorHandler:!0})}function dx(e,t){globalThis.process?.on(`uncaughtException`,ux(e,t))}function fx(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var px=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Uy({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return jy(e)&&`__posthog_previously_captured_error`in e&&!0===e.__posthog_previously_captured_error}static async buildEventMessage(e,t,n,r){let i={...r};n||(i.$process_person_profile=!1);let a=this.errorPropertiesBuilder.buildFromUnknown(e,t);return a.$exception_list=await this.errorPropertiesBuilder.modifyFrames(a.$exception_list),{event:`$exception`,distinctId:n||Sy(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(dx(this.onException.bind(this),this.onFatalError.bind(this)),fx(this.onException.bind(this)))}onException(t,n){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let r=await e.buildEventMessage(t,n),i=r.properties?.$exception_list[0]?.type??`Exception`;return this._rateLimiter.consumeRateLimit(i)?void this._logger.info(`Skipping exception capture because of client rate limiting.`,{exception:i}):this.client.capture(r)}})())}async onFatalError(e){console.error(e),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};const mx={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function hx(e){let t=globalThis.crypto?.subtle;if(!t)throw Error(`SubtleCrypto API not available`);let n=await t.digest(`SHA-1`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}const gx=[`is_not`];var _x=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},$=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},vx=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},yx=class{constructor({pollingInterval:e,personalApiKey:t,projectApiKey:n,timeout:r,host:i,customHeaders:a,...o}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=e,this.personalApiKey=t,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=r,this.projectApiKey=n,this.host=i,this.poller=void 0,this.fetch=o.fetch||fetch,this.onError=o.onError,this.customHeaders=a,this.onLoad=o.onLoad,this.cacheProvider=o.cacheProvider,this.strictLocalEvaluation=o.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(e=!0){this.debugMode=e}logMsgIfDebug(e){this.debugMode&&e()}createEvaluationContext(e,t={},n={},r={},i={}){return{distinctId:e,groups:t,personProperties:n,groupProperties:r,evaluationCache:i}}async getFeatureFlag(e,t,n={},r={},i={}){await this.loadFeatureFlags();let a,o;if(!this.loadedSuccessfullyOnce)return a;if(o=this.featureFlagsByKey[e],o!==void 0){let s=this.createEvaluationContext(t,n,r,i);try{a=(await this.computeFlagAndPayloadLocally(o,s)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${e} -> ${a}`))}catch(t){t instanceof vx||t instanceof $?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e}: ${t.message}`)):t instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${e}: ${t}`))}}return a}async getAllFlagsAndPayloads(e,t){await this.loadFeatureFlags();let n={},r={},i=this.featureFlags.length==0,a=t?t.map(e=>this.featureFlagsByKey[e]).filter(Boolean):this.featureFlags,o={...e,evaluationCache:e.evaluationCache??{}};return await Promise.all(a.map(async e=>{try{let{value:t,payload:i}=await this.computeFlagAndPayloadLocally(e,o);n[e.key]=t,i&&(r[e.key]=i)}catch(t){t instanceof vx||t instanceof $?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e.key}: ${t.message}`)):t instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${e.key}: ${t}`)),i=!0}})),{response:n,payloads:r,fallbackToFlags:i}}async computeFlagAndPayloadLocally(e,t,n={}){let{matchValue:r,skipLoadCheck:i=!1}=n;if(i||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let a;a=r===void 0?await this.computeFlagValueLocally(e,t):r;let o=this.getFeatureFlagPayload(e.key,a);return{value:a,payload:o}}async computeFlagValueLocally(e,t){let{distinctId:n,groups:r,personProperties:i,groupProperties:a}=t;if(e.ensure_experience_continuity)throw new $(`Flag has experience continuity enabled`);if(!e.active)return!1;let o=(e.filters||{}).aggregation_group_type_index;if(o!=null){let n=this.groupTypeMapping[String(o)];if(!n)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${o} for feature flag ${e.key}`)),new $(`Flag has unknown group type index`);if(!(n in r))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${e.key} without group names passed in`)),!1;e.bucketing_identifier===`device_id`&&(i?.$device_id===void 0||i?.$device_id===null||i?.$device_id===``)&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${e.key}`));let s=a[n];return await this.matchFeatureFlagProperties(e,r[n],s,t)}{let r=this.getBucketingValueForFlag(e,n,i);if(r===void 0)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${e.key} without $device_id, falling back to server evaluation`)),new $(`Can't compute feature flag: ${e.key} without $device_id`);return await this.matchFeatureFlagProperties(e,r,i,t)}}getBucketingValueForFlag(e,t,n){if(e.filters?.aggregation_group_type_index!=null)return t;if(e.bucketing_identifier===`device_id`){let e=n?.$device_id;return e==null||e===``?void 0:e}return t}getFeatureFlagPayload(e,t){let n=null;if(!1!==t&&t!=null&&(typeof t==`boolean`?n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t.toString()]||null:typeof t==`string`&&(n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t]||null),n!=null)){if(typeof n==`object`)return n;if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(e,t,n){let{evaluationCache:r}=n,i=e.key;if(!this.featureFlagsByKey)throw new $(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new $(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new $(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new $(`Circular dependency detected for flag '${i}' (empty dependency chain)`);for(let e of a){if(!(e in r)){let t=this.featureFlagsByKey[e];if(t)if(t.active)try{r[e]=await this.computeFlagValueLocally(t,n)}catch(t){throw new $(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1;else throw new $(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new $(`Dependency '${e}' could not be evaluated`)}let o=r[i];return this.flagEvaluatesToExpectedValue(e.value,o)}flagEvaluatesToExpectedValue(e,t){return typeof e==`boolean`?e===t||typeof t==`string`&&t!==``&&!0===e:typeof e==`string`?t===e:!1}async matchFeatureFlagProperties(e,t,n,r){let i=e.filters||{},a=i.groups||[],o=!1,s;for(let c of a)try{if(await this.isConditionMatch(e,t,c,n,r)){let n=c.variant,r=i.multivariate?.variants||[];s=n&&r.some(e=>e.key===n)?n:await this.getMatchingVariant(e,t)||!0;break}}catch(e){if(e instanceof vx)throw e;if(e instanceof $)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new $(`Can't determine if feature flag is enabled or not with given properties`);return!1}async isConditionMatch(e,t,n,r,i){let a=n.rollout_percentage,o=e=>{this.logMsgIfDebug(()=>console.warn(e))};if((n.properties||[]).length>0){for(let e of n.properties){let t=e.type,n=!1;if(n=t===`cohort`?Cx(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):xx(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await bx(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await bx(e.key,t,`variant`),r=this.variantLookupTable(e).find(e=>n>=e.valueMin&&n<e.valueMax);if(r)return r.key}variantLookupTable(e){let t=[],n=0,r=0;return((e.filters||{}).multivariate?.variants||[]).forEach(e=>{r=n+e.rollout_percentage/100,t.push({valueMin:n,valueMax:r,key:e.key}),n=r}),t}updateFlagState(e){this.featureFlags=e.flags,this.featureFlagsByKey=e.flags.reduce((e,t)=>(e[t.key]=t,e),{}),this.groupTypeMapping=e.groupTypeMapping,this.cohorts=e.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(e){if(this.strictLocalEvaluation)return;let t=e.filter(e=>e.ensure_experience_continuity);t.length>0&&console.warn(`[PostHog] You are using local evaluation but ${t.length} flag(s) have experience continuity enabled: ${t.map(e=>e.key).join(`, `)}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(e){if(!this.cacheProvider)return!1;try{let t=await this.cacheProvider.getFlagDefinitions();return t?(this.updateFlagState(t),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${e} (${t.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(t.flags),!0):!1}catch(e){return this.onError?.(Error(`Failed to load from cache: ${e}`)),!1}}async loadFeatureFlags(e=!1){if(!(this.loadedSuccessfullyOnce&&!e))return!e&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Skipping fetch, in backoff period`)):(this.loadingPromise||=this._loadFeatureFlags().catch(e=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${e}`))).finally(()=>{this.loadingPromise=void 0}),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&=(clearTimeout(this.poller),void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let e=!0;if(this.cacheProvider)try{e=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(e){this.onError?.(Error(`Error in shouldFetchFlagDefinitions: ${e}`))}if(!e&&(await this.loadFromCache(`Loaded flags from cache (skipped fetch)`)||this.loadedSuccessfullyOnce))return;let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 304:this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Flags not modified (304), using cached data`)),this.flagsEtag=t.headers?.get(`ETag`)??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new _x(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new _x(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new _x(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let n=await t.json()??{};if(!(`flags`in n))return void this.onError?.(Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=t.headers?.get(`ETag`)??void 0;let r={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(r),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&e)try{await this.cacheProvider.onFlagDefinitionsReceived(r)}catch(e){this.onError?.(Error(`Failed to store in cache: ${e}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags);break}default:return}}catch(e){e instanceof _x&&this.onError?.(e)}}getPersonalApiKeyRequestOptions(e=`GET`,t){let n={...this.customHeaders,"Content-Type":`application/json`,Authorization:`Bearer ${this.personalApiKey}`};return t&&(n[`If-None-Match`]=t),{method:e,headers:n}}_requestFeatureFlagDefinitions(){let e=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,t=this.getPersonalApiKeyRequestOptions(`GET`,this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout==`number`){let e=new AbortController;n=pb(()=>{e.abort()},this.timeout),t.signal=e.signal}try{let n=this.fetch;return n(e,t)}finally{clearTimeout(n)}}async stopPoller(e=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let t=this.cacheProvider.shutdown();t instanceof Promise&&await Promise.race([t,new Promise((t,n)=>setTimeout(()=>n(Error(`Cache shutdown timeout after ${e}ms`)),e))])}catch(e){this.onError?.(Error(`Error during cache shutdown: ${e}`))}}};async function bx(e,t,n=``){let r=await hx(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function xx(e,t,n){let r=e.key,i=e.value,a=e.operator||`exact`;if(r in t){if(a===`is_not_set`)throw new $(`Operator is_not_set is not supported`)}else throw new $(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!gx.includes(a))return n&&n(`Property ${r} cannot have a value of null/undefined with the ${a} operator`),!1;function s(e,t){return Array.isArray(e)?e.map(e=>String(e).toLowerCase()).includes(String(t).toLowerCase()):String(e).toLowerCase()===String(t).toLowerCase()}function c(e,t,n){if(n===`gt`)return e>t;if(n===`gte`)return e>=t;if(n===`lt`)return e<t;if(n===`lte`)return e<=t;throw Error(`Invalid operator: ${n}`)}switch(a){case`exact`:return s(i,o);case`is_not`:return!s(i,o);case`is_set`:return r in t;case`icontains`:return String(o).toLowerCase().includes(String(i).toLowerCase());case`not_icontains`:return!String(o).toLowerCase().includes(String(i).toLowerCase());case`regex`:return Tx(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return Tx(String(i))&&String(o).match(String(i))===null;case`gt`:case`gte`:case`lt`:case`lte`:{let e=typeof i==`number`?i:null;if(typeof i==`string`)try{e=parseFloat(i)}catch{}return e==null||o==null?c(String(o),String(i),a):typeof o==`string`?c(o,String(i),a):c(o,e,a)}case`is_date_after`:case`is_date_before`:{if(typeof i==`boolean`)throw new $(`Date operations cannot be performed on boolean values`);let e=Mx(String(i));if(e??=jx(i),e==null)throw new $(`Invalid date: ${i}`);let t=jx(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return Dx(Ex(String(o)),Ex(String(i)))===0;case`semver_neq`:return Dx(Ex(String(o)),Ex(String(i)))!==0;case`semver_gt`:return Dx(Ex(String(o)),Ex(String(i)))>0;case`semver_gte`:return Dx(Ex(String(o)),Ex(String(i)))>=0;case`semver_lt`:return Dx(Ex(String(o)),Ex(String(i)))<0;case`semver_lte`:return Dx(Ex(String(o)),Ex(String(i)))<=0;case`semver_tilde`:{let e=Ex(String(o)),{lower:t,upper:n}=Ox(String(i));return Dx(e,t)>=0&&Dx(e,n)<0}case`semver_caret`:{let e=Ex(String(o)),{lower:t,upper:n}=kx(String(i));return Dx(e,t)>=0&&Dx(e,n)<0}case`semver_wildcard`:{let e=Ex(String(o)),{lower:t,upper:n}=Ax(String(i));return Dx(e,t)>=0&&Dx(e,n)<0}default:throw new $(`Unknown operator: ${a}`)}}function Sx(e,t){if(!(e in t))throw new vx(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function Cx(e,t,n,r=!1){let i=String(e.value);Sx(i,n);let a=n[i];return wx(a,t,n,r)}function wx(e,t,n,r=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if(`values`in a[0]){for(let e of a)try{let a=wx(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof vx)throw t;if(t instanceof $)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $(`Can't match cohort without a given cohort property value`);return i===`AND`}for(let e of a)try{let a;if(e.type===`cohort`)a=Cx(e,t,n,r);else if(e.type===`flag`){r&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${e.key||`unknown`}'`);continue}else a=xx(e,t);let o=e.negation||!1;if(i===`AND`){if(!a&&!o||a&&o)return!1}else if(a&&!o||!a&&o)return!0}catch(t){if(t instanceof vx)throw t;if(t instanceof $)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $(`can't match cohort without a given cohort property value`);return i===`AND`}function Tx(e){try{return new RegExp(e),!0}catch{return!1}}function Ex(e){let t=String(e).trim().replace(/^[vV]/,``).split(`-`)[0].split(`+`)[0];if(!t||t.startsWith(`.`))throw new $(`Invalid semver: ${e}`);let n=t.split(`.`),r=t=>{if(t===void 0||t===``)return 0;if(!/^\d+$/.test(t))throw new $(`Invalid semver: ${e}`);return parseInt(t,10)};return[r(n[0]),r(n[1]),r(n[2])]}function Dx(e,t){for(let n=0;n<3;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return 0}function Ox(e){let t=Ex(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function kx(e){let[t,n,r]=Ex(e),i=[t,n,r],a;return a=t>0?[t+1,0,0]:n>0?[0,n+1,0]:[0,0,r+1],{lower:i,upper:a}}function Ax(e){let t=String(e).trim().replace(/^[vV]/,``).replace(/\.\*$/,``).replace(/\*$/,``);if(!t)throw new $(`Invalid wildcard semver: ${e}`);let n=t.split(`.`),r=parseInt(n[0],10);if(isNaN(r))throw new $(`Invalid wildcard semver: ${e}`);let i,a;if(n.length===1)i=[r,0,0],a=[r+1,0,0];else{let t=parseInt(n[1],10);if(isNaN(t))throw new $(`Invalid wildcard semver: ${e}`);i=[r,t,0],a=[r,t+1,0]}return{lower:i,upper:a}}function jx(e){if(e instanceof Date)return e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new $(`${e} is in an invalid date format`)}throw new $(`The date provided ${e} must be a string, number, or date object`)}function Mx(e){let t=e.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),n=new Date(new Date().toISOString());if(!t)return null;{if(!t.groups)return null;let e=parseInt(t.groups.number);if(e>=1e4)return null;let r=t.groups.interval;if(r==`h`)n.setUTCHours(n.getUTCHours()-e);else if(r==`d`)n.setUTCDate(n.getUTCDate()-e);else if(r==`w`)n.setUTCDate(n.getUTCDate()-7*e);else if(r==`m`)n.setUTCMonth(n.getUTCMonth()-e);else{if(r!=`y`)return null;n.setUTCFullYear(n.getUTCFullYear()-e)}return n}}var Nx=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const Px=3e4;var Fx=class extends wb{constructor(e,t={}){if(super(e,t),this._memoryStorage=new Nx,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):Px,typeof t.waitUntilDebounceMs==`number`&&(this.options.waitUntilDebounceMs=Math.max(t.waitUntilDebounceMs,0)),typeof t.waitUntilMaxWaitMs==`number`&&(this.options.waitUntilMaxWaitMs=Math.max(t.waitUntilMaxWaitMs,0)),t.personalApiKey){if(t.personalApiKey.includes(`phc_`))throw Error(`Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.`);!1!==t.enableLocalEvaluation&&(this.featureFlagsPoller=new yx({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:t.personalApiKey,projectApiKey:e,timeout:t.requestTimeout??1e4,host:this.host,fetch:t.fetch,onError:e=>{this._events.emit(`error`,e)},onLoad:e=>{this._events.emit(`localEvaluationFlagsLoaded`,e)},customHeaders:this.getCustomHeaders(),cacheProvider:t.flagDefinitionCacheProvider,strictLocalEvaluation:t.strictLocalEvaluation}))}this.errorTracking=new px(this,t,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=t.maxCacheSize||5e4}enqueue(e,t,n){super.enqueue(e,t,n),this.scheduleDebouncedFlush()}async flush(){let e=super.flush(),t=this.options.waitUntil;if(t&&!this._waitUntilCycle)try{t(e.catch(()=>{}))}catch{}return e}scheduleDebouncedFlush(){let e=this.options.waitUntil;if(!e||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let t,n=new Promise(e=>{t=e});try{e(n)}catch{return}this._waitUntilCycle={resolve:t,startedAt:Date.now(),timer:void 0}}let t=Date.now()-this._waitUntilCycle.startedAt>=(this.options.waitUntilMaxWaitMs??500);if(this._waitUntilCycle.timer!==void 0&&clearTimeout(this._waitUntilCycle.timer),t)return void this.resolveWaitUntilFlush();let n=this.options.waitUntilDebounceMs??50;this._waitUntilCycle.timer=pb(()=>{this.resolveWaitUntilFlush()},n)}_consumeWaitUntilCycle(){let e=this._waitUntilCycle;return e&&(clearTimeout(e.timer),this._waitUntilCycle=void 0),e?.resolve}async resolveWaitUntilFlush(){let e=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{e?.()}}getPersistedProperty(e){return this._memoryStorage.getProperty(e)}setPersistedProperty(e,t){return this._memoryStorage.setProperty(e,t)}fetch(e,t){return this.options.fetch?this.options.fetch(e,t):fetch(e,t)}getLibraryVersion(){return`5.28.5`}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(e=!0){super.debug(e),this.featureFlagsPoller?.debug(e)}capture(e){typeof e==`string`&&this._logger.warn(`Called capture() with a string as the first argument when an object was expected.`),e.event===`$exception`&&!e._originatedFromCaptureException&&this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStateless(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}async captureImmediate(e){return typeof e==`string`&&this._logger.warn(`Called captureImmediate() with a string as the first argument when an object was expected.`),e.event===`$exception`&&!e._originatedFromCaptureException&&this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStatelessImmediate(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}identify({distinctId:e,properties:t={},disableGeoip:n}){let{$set:r,$set_once:i,$anon_distinct_id:a,...o}=t,s={$set:r||o,$set_once:i||{},$anon_distinct_id:a??void 0};super.identifyStateless(e,s,{disableGeoip:n})}async identifyImmediate({distinctId:e,properties:t={},disableGeoip:n}){let{$set:r,$set_once:i,$anon_distinct_id:a,...o}=t,s={$set:r||o,$set_once:i||{},$anon_distinct_id:a??void 0};super.identifyStatelessImmediate(e,s,{disableGeoip:n})}alias(e){super.aliasStateless(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}async aliasImmediate(e){await super.aliasStatelessImmediate(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(e=Px){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(t=>{let n=setTimeout(()=>{r(),t(!1)},e),r=this._events.on(`localEvaluationFlagsLoaded`,e=>{clearTimeout(n),r(),t(e>0)})})}_resolveDistinctId(e,t){return typeof e==`string`?{distinctId:e,options:t}:{distinctId:this.context?.get()?.distinctId,options:e}}async _getFeatureFlagResult(e,t,n={},r){let i=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&e in this._flagOverrides){let t=this._flagOverrides[e];if(t===void 0)return;let n=this._payloadOverrides?.[e];return{key:e,enabled:!1!==t,variant:typeof t==`string`?t:void 0,payload:n}}let{groups:a,disableGeoip:o}=n,{onlyEvaluateLocally:s,personProperties:c,groupProperties:l}=n,u=this.addLocalPersonAndGroupProperties(t,a,c,l);c=u.allPersonProperties,l=u.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(t,a,c,l);s??=this.options.strictLocalEvaluation??!1;let f,p=!1,m,h,g,_,v,y;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let t=this.featureFlagsPoller?.featureFlagsByKey[e];if(t)try{let n=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(t,d,{matchValue:r});if(n){p=!0;let r=n.value;_=t.id,y=`Evaluated locally`,f={key:e,enabled:!1!==r,variant:typeof r==`string`?r:void 0,payload:n.payload??void 0}}}catch(t){if(t instanceof vx||t instanceof $)this._logger?.info(`${t.name} when computing flag locally: ${e}: ${t.message}`);else throw t}}if(!p&&!s){let t=await super.getFeatureFlagDetailsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,o,[e]);if(t===void 0)g=mx.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(mx.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(mx.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(mx.FLAG_MISSING);else{_=r.metadata?.id,v=r.metadata?.version,y=r.reason?.description??r.reason?.code;let t;if(r.metadata?.payload!==void 0)try{t=JSON.parse(r.metadata.payload)}catch{t=r.metadata.payload}f={key:e,enabled:r.enabled,variant:r.variant,payload:t}}n.length>0&&(g=n.join(`,`))}}if(i){let n=f===void 0?void 0:!1===f.enabled?!1:f.variant??!0,r=`${e}_${n}`;if(!(t in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[t].includes(r)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[t])?this.distinctIdHasSentFlagCalls[t].push(r):this.distinctIdHasSentFlagCalls[t]=[r];let i={$feature_flag:e,$feature_flag_response:n,$feature_flag_id:_,$feature_flag_version:v,$feature_flag_reason:y,locally_evaluated:p,[`$feature/${e}`]:n,$feature_flag_request_id:m,$feature_flag_evaluated_at:p?Date.now():h};if(p&&this.featureFlagsPoller){let e=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();e!==void 0&&(i.$feature_flag_definitions_loaded_at=e)}g&&(i.$feature_flag_error=g),this.capture({distinctId:t,event:`$feature_flag_called`,properties:i,groups:a,disableGeoip:o})}}return f!==void 0&&this._payloadOverrides!==void 0&&e in this._payloadOverrides&&(f={...f,payload:this._payloadOverrides[e]}),f}async getFeatureFlag(e,t,n){let r=await this._getFeatureFlagResult(e,t,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(r!==void 0)return!1===r.enabled?!1:r.variant??!0}async getFeatureFlagPayload(e,t,n,r){if(this._payloadOverrides!==void 0&&e in this._payloadOverrides)return this._payloadOverrides[e];let i=await this._getFeatureFlagResult(e,t,{...r,sendFeatureFlagEvents:!1},n);if(i!==void 0)return i.payload??null}async getFeatureFlagResult(e,t,n){let{distinctId:r,options:i}=this._resolveDistinctId(t,n);return r?this._getFeatureFlagResult(e,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn(`[PostHog] distinctId is required — pass it explicitly or use withContext()`)}async getRemoteConfigPayload(e){if(!this.options.personalApiKey)throw Error(`Personal API key is required for remote config payload decryption`);let t=await this._requestRemoteConfigPayload(e);if(!t)return;let n=await t.json();if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(e,t,n){let r=await this.getFeatureFlag(e,t,n);if(r!==void 0)return!!r||!1}async getAllFlags(e,t){let{distinctId:n,options:r}=this._resolveDistinctId(e,t);return n?(await this.getAllFlagsAndPayloads(n,r)).featureFlags||{}:(this._logger.warn(`[PostHog] distinctId is required to get feature flags — pass it explicitly or use withContext()`),{})}async getAllFlagsAndPayloads(e,t){let{distinctId:n,options:r}=this._resolveDistinctId(e,t);if(!n)return this._logger.warn(`[PostHog] distinctId is required to get feature flags and payloads — pass it explicitly or use withContext()`),{featureFlags:{},featureFlagPayloads:{}};let{groups:i,disableGeoip:a,flagKeys:o}=r||{},{onlyEvaluateLocally:s,personProperties:c,groupProperties:l}=r||{},u=this.addLocalPersonAndGroupProperties(n,i,c,l);c=u.allPersonProperties,l=u.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(n,i,c,l);s??=this.options.strictLocalEvaluation??!1;let f=await this.featureFlagsPoller?.getAllFlagsAndPayloads(d,o),p={},m={},h=!0;if(f&&(p=f.response,m=f.payloads,h=f.fallbackToFlags),h&&!s){let e=await super.getFeatureFlagsAndPayloadsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,a,o);p={...p,...e.flags||{}},m={...m,...e.payloads||{}}}return this._flagOverrides!==void 0&&(p={...p,...this._flagOverrides}),this._payloadOverrides!==void 0&&(m={...m,...this._payloadOverrides}),{featureFlags:p,featureFlagPayloads:m}}groupIdentify({groupType:e,groupKey:t,properties:n,distinctId:r,disableGeoip:i}){super.groupIdentifyStateless(e,t,n,{disableGeoip:i},r)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(e){let t=e=>Object.fromEntries(e.map(e=>[e,!0]));if(!1===e){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(e)){this._flagOverrides=t(e);return}if(this._isFeatureFlagOverrideOptions(e)){`flags`in e&&(!1===e.flags?this._flagOverrides=void 0:Array.isArray(e.flags)?this._flagOverrides=t(e.flags):e.flags!==void 0&&(this._flagOverrides={...e.flags})),`payloads`in e&&(!1===e.payloads?this._payloadOverrides=void 0:e.payloads!==void 0&&(this._payloadOverrides={...e.payloads}));return}this._flagOverrides={...e}}_isFeatureFlagOverrideOptions(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;if(`flags`in t){let e=t.flags;if(!1===e||Array.isArray(e)||typeof e==`object`&&e)return!0}if(`payloads`in t){let e=t.payloads;if(!1===e||typeof e==`object`&&e)return!0}return!1}withContext(e,t,n){return this.context?this.context.run(e,t,n):t()}getContext(){return this.context?.get()}enterContext(e,t){this.context?.enter(e,t)}async _shutdown(e){let t=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(e),this.errorTracking.shutdown();try{return await super._shutdown(e)}finally{t?.()}}async _requestRemoteConfigPayload(e){if(!this.options.personalApiKey)return;let t=`${this.host}/api/projects/@current/feature_flags/${e}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,Authorization:`Bearer ${this.options.personalApiKey}`}},r=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout==`number`){let e=new AbortController;r=pb(()=>{e.abort()},this.options.requestTimeout),n.signal=e.signal}try{return await this.fetch(t,n)}catch(e){this._events.emit(`error`,e);return}finally{r&&clearTimeout(r)}}extractPropertiesFromEvent(e,t){if(!e)return{personProperties:{},groupProperties:{}};let n={},r={};for(let[i,a]of Object.entries(e))if(By(a)&&t&&i in t){let e={};for(let[t,n]of Object.entries(a))e[String(t)]=String(n);r[String(i)]=e}else n[String(i)]=String(a);return{personProperties:n,groupProperties:r}}async getFeatureFlagsForEvent(e,t,n,r){let i=r?.personProperties||{},a=r?.groupProperties||{},o=r?.flagKeys;if(r?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return(await super.getFeatureFlagsStateless(e,t,i,a,n)).flags}addLocalPersonAndGroupProperties(e,t,n,r){let i={distinct_id:e,...n||{}},a={};if(t)for(let e of Object.keys(t))a[e]={$group_key:t[e],...r?.[e]||{}};return{allPersonProperties:i,allGroupProperties:a}}createFeatureFlagEvaluationContext(e,t,n,r){return{distinctId:e,groups:t||{},personProperties:n||{},groupProperties:r||{},evaluationCache:{}}}captureException(e,t,n,r){if(!px.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(px.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!px.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(px.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.captureImmediate(e)))}}async prepareEventMessage(e){let{distinctId:t,event:n,properties:r,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c}=e,l=this.context?.get(),u=t||l?.distinctId,d={...this.props,...l?.properties||{},...r||{}};u||(u=Sy(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:u,event:n,properties:d,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c});if(!f)return Promise.reject(null);let p=await Promise.resolve().then(async()=>{if(a){let e=typeof a==`object`?a:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,i,s,e)}return f.event,{}}).then(e=>{let t={};if(e)for(let[n,r]of Object.entries(e))t[`$feature/${n}`]=r;let n=Object.keys(e||{}).filter(t=>e?.[t]!==!1).sort();return n.length>0&&(t.$active_feature_flags=n),t}).catch(()=>({})).then(e=>({...e,...f.properties||{},$groups:f.groups||i}));return f.event===`$pageview`&&this.options.__preview_capture_bot_pageviews&&typeof p.$raw_user_agent==`string`&&Ey(p.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event=`$bot_pageview`,p.$browser_type=`bot`),{distinctId:f.distinctId,event:f.event,properties:p,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(e){let t=this.options.before_send;if(!t)return e;let n=Array.isArray(t)?t:[t],r=e;for(let t of n){if(r=t(r),!r)return this._logger.info(`Event '${e.event}' was rejected in beforeSend function`),null;if(!r.properties||Object.keys(r.properties).length===0){let e=`Event '${r.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(e)}}return r}},Ix=class{constructor(){this.storage=new aa}get(){return this.storage.getStore()}run(e,t,n){return this.storage.run(this.resolve(e,n),t)}enter(e,t){this.storage.enterWith(this.resolve(e,t))}resolve(e,t){if(t?.fresh===!0)return e;let n=this.get()||{};return{distinctId:e.distinctId??n.distinctId,sessionId:e.sessionId??n.sessionId,properties:{...n.properties||{},...e.properties||{}}}}};const Lx=`posthog-node`;function Rx(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(i===`*`||i.includes(o.level)))return o;o.tags||={};let s=o.tags[zx.POSTHOG_ID_TAG];if(s===void 0)return o;let c=e.options.host??`https://us.i.posthog.com`,l=new URL(`/project/${e.apiKey}/person/${s}`,c).toString();o.tags[`PostHog Person URL`]=l;let u=o.exception?.values||[],d=u.map(e=>({...e,stacktrace:e.stacktrace?{...e.stacktrace,type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>({...e,platform:`node:javascript`}))}:void 0})),f={$exception_message:u[0]?.value||o.message,$exception_type:u[0]?.type,$exception_level:o.level,$exception_list:d,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:u[0]?.value||o.message,$sentry_exception_type:u[0]?.type,$sentry_tags:o.tags};return t&&n&&(f.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&e.capture({event:`$exception`,distinctId:s,properties:f}),o}}var zx=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=Lx,this.name=Lx,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(Rx(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};px.errorPropertiesBuilder=new kb([new Gb,new zb,new Wb,new Vb,new Kb],Rb(`node:javascript`,Mb),[cy(),Xb]);const Bx=new class extends Fx{getLibraryId(){return`posthog-node`}initializeContext(){return new Ix}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`}),Vx=V({email:R}),Hx=L(`getClaudeCodeEmail`)(function*(){let e=yield*(yield*jr).string(Un(`claude`,[`auth`,`status`])).pipe(ar(`5 seconds`));return(yield*Gt(Yr(Vx))(e)).email}),Ux=L(`getGitEmail`)(function*(){let e=yield*(yield*jr).string(Un(`git`,[`config`,`user.email`])).pipe(ar(`5 seconds`),I(e=>e.trim()));return e.length===0?yield*bn(`empty`):e}),Wx=L(`getGitName`)(function*(){let e=yield*(yield*jr).string(Un(`git`,[`config`,`user.name`])).pipe(ar(`5 seconds`),I(e=>e.trim()));return e.length===0?yield*bn(`empty`):e});var Gx=class extends tn()(`@expect/AnalyticsProvider`){static layerPostHog=Vn(this)({capture:e=>tr(()=>{Bx.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>tr(()=>{Bx.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:Pr({try:()=>Bx.flush(),catch:e=>e}).pipe(C)});static layerDev=Vn(this)({capture:e=>Ae(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(ir({module:`Analytics`})),identify:e=>Ae(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(ir({module:`Analytics`})),flush:gn})},Kx=class extends tn()(`@expect/Analytics`,{make:D(function*(){let e=yield*Gx,t=yield*Pr({try:()=>(0,ey.machineId)(),catch:()=>`unknown`}),n=sy(process.cwd());yield*vr({email:Hx().pipe(B(`PlatformError`,()=>Ux()),B(`TimeoutError`,()=>Ux()),B(`SchemaError`,()=>Ux())),name:Wx().pipe(sn(()=>z(void 0)))}).pipe(yr(({email:n,name:r})=>e.identify({distinctId:t,email:n,name:r})),sn(()=>gn),Hr);let r=(r,...[i])=>D(function*(){let a={timestamp:new Date().toISOString(),projectId:n};yield*e.capture({eventName:r,properties:{...a,...i??{}},distinctId:t})}).pipe(sn(e=>Fe(`Analytics capture failed`,{eventName:r,cause:e}).pipe(ir({module:`Analytics`}))));return{capture:r,track:((e,t)=>n=>yr(n,n=>{let i=t?t(n):void 0;return r.call(void 0,e,...i===void 0?[]:[i])})),flush:e.flush}})}){static layerPostHog=b(this)(this.make).pipe(w(Gx.layerPostHog),w(Pi.layer));static layerDev=b(this)(this.make).pipe(w(Gx.layerDev),w(Pi.layer))};const qx=e=>{let t=$n(e);return{error_tag:pr(t,`_tag`)?String(t._tag):`Unknown`,error_message:Dr(e)}};(class extends tn()(`@expect/ErrorHandler`,{make:D(function*(){let e=yield*Kx;return{orDie:t=>t.pipe(jn(t=>e.capture(`error:unexpected`,qx(t))),et),streamOrDie:t=>t.pipe(_t(t=>e.capture(`error:unexpected`,qx(t))),Ne),tapCause:(...t)=>n=>n.pipe(jn(n=>vr([e.capture(`error:expected`,qx(n)),Fn(...t,n)],{discard:!0})))}})}){static layer=b(this)(this.make)});const Jx=Qi()(sa(e=>({agentBackend:`claude`,browserHeaded:!1,replayHost:`https://expect.dev`,autoSaveFlows:!0,notifications:void 0,instructionHistory:[],setAgentBackend:t=>e({agentBackend:t}),toggleAutoSave:()=>e(e=>({autoSaveFlows:!e.autoSaveFlows})),toggleNotifications:()=>e(e=>({notifications:e.notifications!==!0})),rememberInstruction:t=>{t&&e(e=>({instructionHistory:[t,...e.instructionHistory.filter(e=>e!==t)].slice(0,20)}))}}),{name:`prompt-history`,storage:oa(()=>Ev),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),Yx=Kx.layerPostHog,Xx=(e,...[t])=>M(D(function*(){let n=yield*Kx;yield*n.capture.call(n,e,...t===void 0?[]:[t])}).pipe(sn(()=>gn),m(Yx))),Zx=()=>Xx(`session:started`,{mode:`interactive`,skip_planning:!1,browser_headed:Jx.getState().browserHeaded}),Qx=e=>M(D(function*(){let t=yield*Kx;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush}).pipe(m(Yx))),$x=()=>{let e=gi(11);if(e[0]!==`22e44f7492e404ec9264543e8c0bccc53524e2de50e4e8b699cdcbe65e792e34`){for(let t=0;t<11;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`22e44f7492e404ec9264543e8c0bccc53524e2de50e4e8b699cdcbe65e792e34`}let t=uo(),n,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=G(U,{color:`red`,children:q.cross}),r=G(U,{color:`green`,children:q.tick}),e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]===t.PRIMARY?i=e[4]:(i=G(U,{bold:!0,color:t.PRIMARY,children:` Expect`}),e[3]=t.PRIMARY,e[4]=i);let a;e[5]===t.DIM?a=e[6]:(a=G(U,{color:t.DIM,children:` v${Ja}`}),e[5]=t.DIM,e[6]=a);let o;return e[7]!==t.BORDER||e[8]!==i||e[9]!==a?(o=G(H,{children:K(U,{color:t.BORDER,children:[n,r,i,a]})}),e[7]=t.BORDER,e[8]=i,e[9]=a,e[10]=o):o=e[10],o},eS=[{id:`enable-sync`,label:`Use existing cookies`,detail:`Recommended. Uses your browser session as-is.`},{id:`run-without-sync`,label:`Skip cookies`,detail:`Not recommended. Tests requiring login will fail.`}],tS=e=>{let t=gi(34);if(t[0]!==`e3c7abb53538ed236081ea9ec92e2272ee1c8b466fbb62e1c8ec442744cd59e3`){for(let e=0;e<34;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e3c7abb53538ed236081ea9ec92e2272ee1c8b466fbb62e1c8ec442744cd59e3`}let{changesFor:n,instruction:r,savedFlow:i}=e,a=uo(),o=Kv(nS),[s,c]=W(0),l;t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==o?(l=e=>{let t=e.id===`enable-sync`;Xx(`cookies:sync_choice`,{choice:t?`use_cookies`:`skip_cookies`}),o(Gv({changesFor:n,instruction:r,savedFlow:i,requiresCookies:t}))},t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=l):l=t[5];let u=l,d;t[6]!==u||t[7]!==s?(d=(e,t)=>{(t.downArrow||e===`j`||t.ctrl&&e===`n`)&&c(rS),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&c(iS),e===`c`&&u(eS[0]),e===`a`&&u(eS[1]),t.return&&u(eS[s])},t[6]=u,t[7]=s,t[8]=d):d=t[8],ui(d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=G($x,{}),t[9]=f):f=t[9];let p;t[10]===a.DIM?p=t[11]:(p=G(U,{color:a.DIM,children:q.pointerSmall}),t[10]=a.DIM,t[11]=p);let m;t[12]!==a.TEXT||t[13]!==r?(m=G(U,{color:a.TEXT,children:r}),t[12]=a.TEXT,t[13]=r,t[14]=m):m=t[14];let h;t[15]!==p||t[16]!==m?(h=K(H,{children:[f,K(U,{wrap:`truncate`,children:[` `,p,` `,m]})]}),t[15]=p,t[16]=m,t[17]=h):h=t[17];let g;t[18]!==a.GREEN||t[19]!==a.YELLOW||t[20]!==s?(g=G(H,{marginTop:1,children:s===0?K(U,{color:a.GREEN,children:[q.tick,` Your signed-in session will be synced to the browser. Cookies stay on device.`]}):K(U,{color:a.YELLOW,children:[q.warning,` The browser won`,`'`,`t inherit your signed-in session without cookies.`]})}),t[18]=a.GREEN,t[19]=a.YELLOW,t[20]=s,t[21]=g):g=t[21];let _;t[22]!==a.DIM||t[23]!==a.PRIMARY||t[24]!==a.TEXT||t[25]!==u||t[26]!==s?(_=eS.map((e,t)=>{let n=t===s;return G(mo,{onClick:()=>{c(t),u(e)},children:K(H,{flexDirection:`column`,marginBottom:1,children:[K(U,{children:[G(U,{color:n?a.PRIMARY:a.DIM,children:n?`${q.pointer} `:` `}),G(U,{color:n?a.PRIMARY:a.TEXT,bold:n,children:e.label})]}),K(U,{color:a.DIM,children:[` `,e.detail]})]})},e.id)}),t[22]=a.DIM,t[23]=a.PRIMARY,t[24]=a.TEXT,t[25]=u,t[26]=s,t[27]=_):_=t[27];let v;t[28]===_?v=t[29]:(v=G(H,{flexDirection:`column`,marginTop:1,children:_}),t[28]=_,t[29]=v);let y;return t[30]!==h||t[31]!==g||t[32]!==v?(y=K(H,{flexDirection:`column`,width:`100%`,paddingY:1,paddingX:1,children:[h,g,v]}),t[30]=h,t[31]=g,t[32]=v,t[33]=y):y=t[33],y};function nS(e){return e.setScreen}function rS(e){return Math.min(eS.length-1,e+1)}function iS(e){return Math.max(0,e-1)}const aS=Qi()(sa(e=>({cookiesEnabled:!1,setCookiesEnabled:t=>e({cookiesEnabled:t}),toggleCookies:()=>e(e=>({cookiesEnabled:!e.cookiesEnabled})),lastBaseUrl:void 0,setLastBaseUrl:t=>e({lastBaseUrl:t})}),{name:`project-preferences`,storage:oa(()=>kv)})),oS=`spotify,raycast,google,controlce,controlcenter,cursor,electron,slack,discord,figma,redis,postgres,mysqld,mongod,mongos,memcached,dockerd,containerd,com.docke,docker,code,rapportd,wifiagent,airplayxpc,identitys,sharingd,bluetoothd,screencap,loginwind,systempol,corespeec,apsd,mds_store,spotlight,lsd`.split(`,`),sS=[[/next[\\/]dist[\\/]/,`next`],[/next-server/,`next`],[/vite[\\/]/,`vite`],[/vite-plus[\\/]/,`vite`],[/react-scripts[\\/]/,`react-scripts`],[/angular[\\/]cli[\\/]/,`angular`],[/remix[\\/]/,`remix`],[/astro[\\/]/,`astro`],[/nuxt[\\/]/,`nuxt`],[/svelte[\\/]/,`svelte`],[/webpack[\\/]/,`webpack`],[/webpack-dev-server/,`webpack`],[/turbopack[\\/]/,`turbopack`],[/remotion[\\/]/,`remotion`],[/gatsby[\\/]/,`gatsby`],[/parcel[\\/]/,`parcel`],[/http-server/,`http-server`],[/live-server/,`live-server`],[/serve[\\/]/,`serve`],[/express[\\/]/,`express`],[/fastify[\\/]/,`fastify`],[/hono[\\/]/,`hono`],[/elysia[\\/]/,`elysia`]],cS=e=>{let t=e.toLowerCase();return oS.some(e=>t.startsWith(e))},lS=e=>{if(!/^\d+$/.test(e))return``;try{let t=Hi(`lsof -p ${e} -a -d cwd -Fn`,{encoding:`utf-8`,timeout:1e3}).split(`
|
|
34
|
-
`).find(e=>e.startsWith(`n`));return t?t.slice(1):``}catch{return``}},uS=(e,t)=>{if(!/^\d+$/.test(e)||cS(t))return;let n=lS(e);try{let t=Hi(`ps -p ${e} -o command=`,{encoding:`utf-8`,timeout:1e3}).trim();for(let[e,r]of sS)if(e.test(t))return{name:r,isFramework:!0,cwd:n}}catch{}return{name:t,isFramework:!1,cwd:n}},dS=e=>{let t=new Set,n=[];for(let r of e.split(`
|
|
35
|
-
`)){let e=r.trim().split(/\s+/);if(e.length<9)continue;let i=e[0]??``,a=e[1]??``,o=(e[8]??``).match(/:(\d+)$/);if(!o)continue;let s=Number(o[1]);s<1024||s>65535||t.has(s)||(t.add(s),n.push({port:s,pid:a,commandName:i}))}return n},fS=()=>{try{let e=dS(Hi(`lsof -iTCP -sTCP:LISTEN -nP`,{encoding:`utf-8`,timeout:3e3})),t=[];for(let n of e){let e=uS(n.pid,n.commandName);e!==void 0&&(n.port>=32768&&!e.isFramework||t.push({port:n.port,processName:e.name,cwd:e.cwd}))}return t.sort((e,t)=>e.port-t.port)}catch{return[]}},pS=()=>hi({queryKey:[`listening-ports`],queryFn:()=>fS(),refetchInterval:5e3}),mS=e=>`http://localhost:${e}`,hS=(e,t)=>{let n=t.toLowerCase();return String(e.port).includes(n)||e.processName.toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n)},gS=e=>{let t=e.trim(),n=Number(t);if(Number.isInteger(n)&&n>=1&&n<=65535)return n;let r=t.match(/:(\d+)\/?$/);if(r){let e=Number(r[1]);if(Number.isInteger(e)&&e>=1&&e<=65535)return e}},_S=e=>{let t=gi(178);if(t[0]!==`84a93f0b7994a0f9318ab42167dadcad0ffba85a300830ca86b74045fc7574ce`){for(let e=0;e<178;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`84a93f0b7994a0f9318ab42167dadcad0ffba85a300830ca86b74045fc7574ce`}let{changesFor:n,instruction:r,savedFlow:i,requiresCookies:a}=e,o=uo(),s=Kv(vS),c=aS(yS),l=aS(bS),{data:u}=pS(),d=u===void 0?[]:u,[f,p]=W(!1),[m,h]=W(``),[g,_]=W(!1),[v,y]=W(``),b;t[1]===c?b=t[2]:(b=()=>{if(!c)return new Set;let e=c.match(/:(\d+)/);return e?new Set([Number(e[1])]):new Set},t[1]=c,t[2]=b);let[x,ee]=W(b),S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=new Set,t[3]=S):S=t[3];let[C,w]=W(S),te=d.map(xS),T=m?te.filter(e=>hS(e,m)):te,E=T.length,D=T.length+1,ne=T.length+2,re;t[4]===ne?re=t[5]:(re={itemCount:ne,visibleCount:10},t[4]=ne,t[5]=re);let{highlightedIndex:O,setHighlightedIndex:k,scrollOffset:A,handleNavigation:ie}=Vv(re),j;t[6]!==n||t[7]!==C||t[8]!==r||t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==s?(j=e=>{let t=[...e,...C];l(t.length>0?t[0]:void 0),t.length===0?Xx(`port:skipped`):Xx(`port:selected`,{port_count:t.length,has_custom_url:C.size>0}),s(Wv.Testing({changesFor:n,instruction:r,savedFlow:i,requiresCookies:a,baseUrls:t.length>0?t:void 0}))},t[6]=n,t[7]=C,t[8]=r,t[9]=a,t[10]=i,t[11]=l,t[12]=s,t[13]=j):j=t[13];let ae=j,oe;t[14]===ee?oe=t[15]:(oe=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[14]=ee,t[15]=oe);let M=oe,se;t[16]!==E||t[17]!==C||t[18]!==T||t[19]!==O||t[20]!==ae||t[21]!==x||t[22]!==_||t[23]!==D?(se=()=>{if(O===D){ae([]);return}if(x.size>0||C.size>0){ae([...x].sort(SS).map(mS));return}if(O===E){_(!0);return}let e=T[O];e&&ae([mS(e.port)])},t[16]=E,t[17]=C,t[18]=T,t[19]=O,t[20]=ae,t[21]=x,t[22]=_,t[23]=D,t[24]=se):se=t[24];let ce=se,N=CS,le;t[25]!==y||t[26]!==w||t[27]!==_?(le=e=>{let t=e.trim();if(!t){_(!1);return}let n=N(t);w(e=>new Set([...e,n])),y(``),_(!1)},t[25]=y,t[26]=w,t[27]=_,t[28]=le):le=t[28];let ue=le,de;t[29]===w?de=t[30]:(de=e=>{w(t=>{let n=new Set(t);return n.delete(e),n})},t[29]=w,t[30]=de);let fe=de,P;t[31]!==k||t[32]!==h?(P=e=>{h(e),k(0)},t[31]=k,t[32]=h,t[33]=P):P=t[33];let pe=P,me;t[34]!==p||t[35]!==h||t[36]!==M?(me=e=>{let t=gS(e);if(t){M(t),p(!1),h(``);return}p(!1)},t[34]=p,t[35]=h,t[36]=M,t[37]=me):me=t[37];let he=me,ge;t[38]!==ce||t[39]!==E||t[40]!==T||t[41]!==ie||t[42]!==O||t[43]!==g||t[44]!==f||t[45]!==y||t[46]!==_||t[47]!==p||t[48]!==M?(ge=(e,t)=>{if(g){if(t.escape){_(!1),y(``);return}return}if(f){if(t.escape){p(!1);return}return}if(!ie(e,t)){if(e===`/`){p(!0);return}if(e===` `){if(O===E){_(!0);return}let e=T[O];e&&M(e.port);return}t.return&&ce()}},t[38]=ce,t[39]=E,t[40]=T,t[41]=ie,t[42]=O,t[43]=g,t[44]=f,t[45]=y,t[46]=_,t[47]=p,t[48]=M,t[49]=ge):ge=t[49],ui(ge);let _e,ve,ye,F,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je;if(t[50]!==o.DIM||t[51]!==o.GREEN||t[52]!==o.PRIMARY||t[53]!==o.TEXT||t[54]!==o.YELLOW||t[55]!==E||t[56]!==C||t[57]!==T||t[58]!==O||t[59]!==r||t[60]!==A||t[61]!==x||t[62]!==k||t[63]!==D||t[64]!==M){let e=T.slice(A,A+8);ye=A+8>=T.length,xe=ye;let n=T[O];F=O===E,be=O===D;let i;t[81]!==C||t[82]!==x?(i=[...[...x].sort(wS).map(mS),...C],t[81]=C,t[82]=x,t[83]=i):i=t[83];let a=i;ve=H,Te=`column`,Ee=`100%`,De=1,Oe=1;let s;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(s=G($x,{}),t[84]=s):s=t[84];let c;t[85]===o.DIM?c=t[86]:(c=G(U,{color:o.DIM,children:q.pointerSmall}),t[85]=o.DIM,t[86]=c);let l;t[87]!==o.TEXT||t[88]!==r?(l=G(U,{color:o.TEXT,children:r}),t[87]=o.TEXT,t[88]=r,t[89]=l):l=t[89],t[90]!==c||t[91]!==l?(ke=K(H,{children:[s,K(U,{wrap:`truncate`,children:[` `,c,` `,l]})]}),t[90]=c,t[91]=l,t[92]=ke):ke=t[92],t[93]===o.DIM?Ae=t[94]:(Ae=G(H,{marginTop:1,children:G(U,{color:o.DIM,children:`Pick the dev server the agent should open in the browser.`})}),t[93]=o.DIM,t[94]=Ae);let u;t[95]!==o.GREEN||t[96]!==a?(u=a.length>0&&K(U,{color:o.GREEN,children:[q.tick,` `,a.join(`, `)]}),t[95]=o.GREEN,t[96]=a,t[97]=u):u=t[97];let d;t[98]!==o.DIM||t[99]!==a.length||t[100]!==n||t[101]!==F||t[102]!==be?(d=a.length===0&&!be&&!F&&n&&K(U,{color:o.DIM,children:[q.arrowRight,` `,mS(n.port)]}),t[98]=o.DIM,t[99]=a.length,t[100]=n,t[101]=F,t[102]=be,t[103]=d):d=t[103];let f;t[104]!==o.YELLOW||t[105]!==a.length||t[106]!==be?(f=a.length===0&&be&&K(U,{color:o.YELLOW,children:[q.warning,` No base URL. The agent won`,`'`,`t know where your dev server is.`]}),t[104]=o.YELLOW,t[105]=a.length,t[106]=be,t[107]=f):f=t[107],t[108]!==u||t[109]!==d||t[110]!==f?(je=K(H,{marginTop:1,children:[u,d,f]}),t[108]=u,t[109]=d,t[110]=f,t[111]=je):je=t[111],_e=H,Se=`column`,Ce=1;let p;t[112]!==o.DIM||t[113]!==o.PRIMARY||t[114]!==o.TEXT||t[115]!==O||t[116]!==A||t[117]!==x||t[118]!==k||t[119]!==M?(p=(e,t)=>{let n=t+A,r=n===O,i=x.has(e.port);return G(mo,{onClick:()=>{k(n),M(e.port)},children:K(H,{children:[G(U,{color:r?o.PRIMARY:o.DIM,children:r?`${q.pointer} `:` `}),K(U,{color:i?o.PRIMARY:o.DIM,children:[i?q.checkboxOn:q.checkboxOff,` `]}),K(U,{color:r?o.PRIMARY:o.TEXT,bold:r,children:[`:`,e.port]}),e.processName&&K(U,{color:o.DIM,children:[` `,e.processName]}),e.cwd&&K(U,{color:o.DIM,children:[` `,e.cwd]})]})},e.port)},t[112]=o.DIM,t[113]=o.PRIMARY,t[114]=o.TEXT,t[115]=O,t[116]=A,t[117]=x,t[118]=k,t[119]=M,t[120]=p):p=t[120],we=e.map(p),t[50]=o.DIM,t[51]=o.GREEN,t[52]=o.PRIMARY,t[53]=o.TEXT,t[54]=o.YELLOW,t[55]=E,t[56]=C,t[57]=T,t[58]=O,t[59]=r,t[60]=A,t[61]=x,t[62]=k,t[63]=D,t[64]=M,t[65]=_e,t[66]=ve,t[67]=ye,t[68]=F,t[69]=be,t[70]=xe,t[71]=Se,t[72]=Ce,t[73]=we,t[74]=Te,t[75]=Ee,t[76]=De,t[77]=Oe,t[78]=ke,t[79]=Ae,t[80]=je}else _e=t[65],ve=t[66],ye=t[67],F=t[68],be=t[69],xe=t[70],Se=t[71],Ce=t[72],we=t[73],Te=t[74],Ee=t[75],De=t[76],Oe=t[77],ke=t[78],Ae=t[79],je=t[80];let Me;t[121]!==o.DIM||t[122]!==o.PRIMARY||t[123]!==o.TEXT||t[124]!==E||t[125]!==v||t[126]!==ye||t[127]!==ue||t[128]!==F||t[129]!==g||t[130]!==y||t[131]!==k||t[132]!==_?(Me=ye&&G(mo,{onClick:()=>{k(E),_(!0)},children:K(H,{children:[G(U,{color:F?o.PRIMARY:o.DIM,children:F?`${q.pointer} `:` `}),g&&K(H,{children:[G(U,{color:o.PRIMARY,children:`URL: `}),G(bo,{focus:!0,value:v,placeholder:`http://localhost:4000 or staging.example.com`,onChange:y,onSubmit:ue})]}),!g&&K(U,{color:F?o.PRIMARY:o.TEXT,bold:F,children:[`Enter a custom URL`,q.ellipsis]})]})}),t[121]=o.DIM,t[122]=o.PRIMARY,t[123]=o.TEXT,t[124]=E,t[125]=v,t[126]=ye,t[127]=ue,t[128]=F,t[129]=g,t[130]=y,t[131]=k,t[132]=_,t[133]=Me):Me=t[133];let Ne;t[134]!==o.DIM||t[135]!==o.PRIMARY||t[136]!==o.TEXT||t[137]!==ye||t[138]!==C||t[139]!==fe?(Ne=ye&&[...C].map(e=>G(mo,{onClick:()=>fe(e),children:K(H,{children:[G(U,{children:` `}),K(U,{color:o.PRIMARY,children:[q.checkboxOn,` `]}),G(U,{color:o.TEXT,children:e}),G(U,{color:o.DIM,children:` (click to remove)`})]})},e)),t[134]=o.DIM,t[135]=o.PRIMARY,t[136]=o.TEXT,t[137]=ye,t[138]=C,t[139]=fe,t[140]=Ne):Ne=t[140];let Pe;t[141]!==o.DIM||t[142]!==o.PRIMARY||t[143]!==be||t[144]!==ae||t[145]!==k||t[146]!==D||t[147]!==xe?(Pe=xe&&G(mo,{onClick:()=>{k(D),ae([])},children:K(H,{children:[G(U,{color:be?o.PRIMARY:o.DIM,children:be?`${q.pointer} `:` `}),K(U,{color:be?o.PRIMARY:o.DIM,bold:be,children:[`Skip `,q.arrowRight,` no base URL`]})]})}),t[141]=o.DIM,t[142]=o.PRIMARY,t[143]=be,t[144]=ae,t[145]=k,t[146]=D,t[147]=xe,t[148]=Pe):Pe=t[148];let Fe;t[149]!==o.DIM||t[150]!==T.length||t[151]!==xe?(Fe=T.length===0&&!xe&&G(U,{color:o.DIM,children:`No matching ports`}),t[149]=o.DIM,t[150]=T.length,t[151]=xe,t[152]=Fe):Fe=t[152];let Ie;t[153]!==_e||t[154]!==Se||t[155]!==Ce||t[156]!==we||t[157]!==Me||t[158]!==Ne||t[159]!==Pe||t[160]!==Fe?(Ie=K(_e,{flexDirection:Se,marginTop:Ce,children:[we,Me,Ne,Pe,Fe]}),t[153]=_e,t[154]=Se,t[155]=Ce,t[156]=we,t[157]=Me,t[158]=Ne,t[159]=Pe,t[160]=Fe,t[161]=Ie):Ie=t[161];let Le;t[162]!==pe||t[163]!==he||t[164]!==f||t[165]!==m?(Le=G(xo,{isSearching:f,query:m,onChange:pe,onSubmit:he}),t[162]=pe,t[163]=he,t[164]=f,t[165]=m,t[166]=Le):Le=t[166];let Re;return t[167]!==ve||t[168]!==Te||t[169]!==Ee||t[170]!==De||t[171]!==Oe||t[172]!==ke||t[173]!==Ae||t[174]!==je||t[175]!==Ie||t[176]!==Le?(Re=K(ve,{flexDirection:Te,width:Ee,paddingY:De,paddingX:Oe,children:[ke,Ae,je,Ie,Le]}),t[167]=ve,t[168]=Te,t[169]=Ee,t[170]=De,t[171]=Oe,t[172]=ke,t[173]=Ae,t[174]=je,t[175]=Ie,t[176]=Le,t[177]=Re):Re=t[177],Re};function vS(e){return e.setScreen}function yS(e){return e.lastBaseUrl}function bS(e){return e.setLastBaseUrl}function xS(e){return{port:e.port,processName:e.processName,cwd:e.cwd}}function SS(e,t){return e-t}function CS(e){let t=e.trim(),n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?mS(n):/^https?:\/\//i.test(t)?t:`http://${t}`}function wS(e,t){return e-t}const TS={"~effect/reactivity/AsyncResult":{E:un,A:un},pipe(){return Qn(this,arguments)},[le](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return vt(this.value,e.value);case`Failure`:return vt(this.cause,e.cause)}},[be](){let e=oe(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:pt(e)(this._tag===`Success`?St(this.value):St(this.cause))}},ES=e=>e.waiting,DS=(e,t)=>e._tag===`Success`?MS(e.value):FS(e.cause,{previous:t}),OS=e=>e._tag===`None`?AS(!0):LS(e.value),kS=e=>e._tag===`Initial`,AS=(e=!1)=>{let t=Object.create(TS);return t._tag=`Initial`,t.waiting=e,t},jS=e=>e._tag===`Success`,MS=(e,t)=>{let n=Object.create(TS);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},NS=e=>e._tag===`Failure`,PS=(e,t)=>{let n=Object.create(TS);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??$e(),n.waiting=t?.waiting??!1,n},FS=(e,t)=>PS(e,{previousSuccess:c(t.previous,e=>jS(e)?ni(e):NS(e)?e.previousSuccess:$e()),waiting:t.waiting}),IS=(e,t)=>FS(Pt(e),t),LS=(e,t)=>{if(e.waiting)return t?.touch?RS(e):e;let n=Object.assign(Object.create(TS),e);return n.waiting=!0,t?.touch&&jS(n)&&(n.timestamp=Date.now()),n},RS=e=>jS(e)?MS(e.value,{waiting:e.waiting}):e,zS=(e,t)=>e._tag===`Failure`?FS(e.cause,{previous:t,waiting:e.waiting}):e,BS=e=>e._tag===`Success`?ni(e.value):e._tag===`Failure`?P(e.previousSuccess,e=>e.value):$e(),VS=e=>Pe(BS(e),()=>new ve(`AsyncResult.getOrThrow: no value found`)),HS=e=>new US(e);var US=class{constructor(e){this.result=e}result;output=$e();when(e,t){if(We(this.output)&&e(this.result)){let e=t(this.result);k(e)&&(this.output=e)}return this}pipe(){return Qn(this,arguments)}onWaiting(e){return this.when(e=>e.waiting,t=>ni(e(t)))}onInitialOrWaiting(e){return this.when(e=>kS(e)||e.waiting,t=>ni(e(t)))}onInitial(e){return this.when(kS,t=>ni(e(t)))}onSuccess(e){return this.when(jS,t=>ni(e(t.value,t)))}onFailure(e){return this.when(NS,t=>ni(e(t.cause,t)))}onError(e){return this.onErrorIf(Dt,e)}onErrorIf(e,t){return this.when(NS,n=>Xe(n.cause).pipe(zn(e),P(e=>t(e,n))))}onErrorTag(e,t){return this.onErrorIf(t=>pr(t,`_tag`)&&(Array.isArray(e)?e.includes(t._tag):t._tag===e),t)}onDefect(e){return this.when(NS,t=>{let n=zt(t.cause);return ze(n)?$e():ni(e(n.success,t))})}orElse(e){return Pn(this.output,e)}orNull(){return ke(this.output)}render(){if(k(this.output))return this.output.value;if(NS(this.result))throw $n(this.result.cause);return null}};const WS=tn(`~effect/reactivity/AtomRegistry`),GS={alive:1,initialized:2,waitingForValue:4},KS={uninitialized:GS.alive|GS.waitingForValue,stale:GS.alive|GS.initialized|GS.waitingForValue,valid:GS.alive|GS.initialized,removed:0},qS={disabled:0,collect:1,commit:2},JS={phase:qS.disabled,depth:0,stale:[],notify:new Set};function YS(e){JS.phase=qS.collect,JS.depth++;try{if(e(),JS.depth===1){for(let e=0;e<JS.stale.length;e++)XS(JS.stale[e]);JS.phase=qS.commit;for(let e of JS.notify)e.notify();JS.notify.clear()}}finally{JS.depth--,JS.depth===0&&(JS.phase=qS.disabled,JS.stale=[])}}function XS(e){if(e.state!==KS.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==KS.valid&&XS(n)}e.state!==KS.valid&&e.value()}}const ZS=`~effect/reactivity/Atom`,QS=e=>pr(e,ZS),$S=`~effect/reactivity/Atom/Writable`,eC=Je(2,(e,t)=>{let n=yn(t),r=Ht(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?Lr(n):void 0})})(0),tC={[ZS]:ZS,...p,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},nC={...tC,atom(e,t){let n=uC(e,t);return oC(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):zS(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>rC(this,e,t):rC(this,e,t)},pull(e,t){let n=eC(pC(0));return EC(n,oC(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?hC(r,TC(r,n,e,t),AS(!0),a.value):zS(a,i)}))},subscriptionRef(e){return xC(eC(oC(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return zS(r,n);let i=typeof e==`function`?e(t):e;return Ua(i)?i:hC(t,i,AS(!0),r.value)})),(e,t)=>bC(e,t,VS(e(this))))}},rC=(e,t,n)=>{let[r,i,a]=wC(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return Bn(i)?Ra(i,n.reactivityKeys):_(i,za(n.reactivityKeys))}:t,n);return sC(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):zS(i,n)},i)},iC={...tC,[$S]:$S},aC=e=>$S in e,oC=(e,t)=>{let n=Object.create(tC);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},sC=(e,t,n)=>{let r=Object.create(iC);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function cC(e,t){e.setSelf(t)}const lC=(e,t)=>{let n=uC(e,t);return`~effect/reactivity/Atom`in n?n:oC(n)},uC=(e,t)=>{if(typeof e==`function`&&!Bn(e)&&!ee(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:dC in i?mC(e,i,t,r):fC in i?vC(e,i,t,r):i;default:return i}}}else if(Bn(e))return function(n,r){return mC(n,e,t,r)};else if(ee(e))return function(n,r){return vC(n,e,t,r)};return pC(e)},dC=`~effect/Effect`,fC=`~effect/Stream`,pC=e=>sC(function(t){return e},cC),mC=(e,t,n,r)=>hC(e,t,n?.initialValue===void 0?AS():MS(n.initialValue),r,n?.uninterruptible);function hC(e,t,n,r=Mr(),i=!1){let a=e.self(),o=Ge();e.addFinalizer(()=>{Ct(r)(Ie(o,hr))});let s=new Map(r.mapUnsafe);s.set(In.key,o),s.set(WS.key,e.registry),s.set(Sr.key,e.registry.scheduler);let c,l=!1,u=gC(hn(s),t,function(t){c=DS(t,a),l&&e.setSelf(c)},i);return l=!0,u!==void 0&&e.addFinalizer(u),c===void 0?a._tag===`Some`?OS(a):LS(n):c}function gC(e,t,n,r=!1){if(ht(t)){n(t);return}let i=Ct(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}const _C=(e=>{let t=Ba;function n(r){let i=Object.create(nC);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=DC(oC(typeof r==`function`?e=>Ve(r(e),t):()=>Ve(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return mC(t,Qr(Nt,t=>at(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=Ve(t,w(e,Ba))};let r=eC(lC(a(t=>at(Ba,e.memoMap,on(t,In))).pipe(I(on(Fa)))));return n.withReactivity=e=>t=>OC(t,n=>{let i=VS(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:ut()});_C.withReactivity;const vC=(e,t,n,r)=>yC(e,t,n?.initialValue===void 0?AS():MS(n.initialValue),r);function yC(e,t,n,r=Mr()){let i=e.self();r=Wn(r,WS,e.registry);let a=Rt(n=>Qr(Me(t.channel,n),t=>ur({while:Dt,body:()=>t,step(t){e.setSelf(MS(Vr(t),{waiting:!0}))}}))).pipe(sn(t=>(xn(t)?Er(e.self(),c(BS),we({onNone:()=>e.setSelf(IS(new ve,{previous:e.self()})),onSome:t=>e.setSelf(MS(t))})):e.setSelf(FS(t,{previous:e.self()})),gn))),o=new Map(r.mapUnsafe);o.set(WS.key,e.registry),o.set(Sr.key,e.registry.scheduler);let s=gC(hn(o),a,Lt,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?OS(i):LS(n)}const bC=(e,t,n=Mr())=>Ua(t)?(e.addFinalizer(Wa(t).pipe(Ce(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return gn}),ue(n))),_e(n)(Ga(t))):t._tag===`Success`?yC(e,Wa(t.value),AS(!0),n):t,xC=(e,t)=>{function n(t,n){let r=t.get(e);Ua(r)?mr(qa(r,n)):jS(r)&&mr(qa(r.value,n))}return sC(n=>{let r=n(e);return Ua(r)||jS(r)?t(n,r):r},n)},SC=Symbol.for(`effect/reactivity/atom/Atom/Reset`),CC=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`);function wC(e,t){let n=eC(pC([0,void 0])),r=t?.initialValue===void 0?AS():MS(t.initialValue),i=t?.concurrent?eC(oC(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===CC)return FS(dn(),{previous:t.self()});let l=e(c,t);return dC in l?(o&&(l=Qr(Hr(l,{startImmediately:!0}),e=>(o.add(e),e.addObserver(()=>o.delete(e)),I(ce(o),e=>e[0])))),hC(t,l,r,a,!1)):yC(t,l,r,a)}function o(e,t){AC(()=>{t===SC?e.set(n,[0,void 0]):t===CC?e.set(n,[e.get(n)[0]+1,CC]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}const TC=(e,t,n,r)=>Qr(N(typeof n==`function`?n(e):n),n=>{let i=gt().services,a=Zt(),o=A(n,{onFailure(e){return xn(e)?v(a)?z({done:!0,items:a}):bn(new ve(`Atom.pull: no items`)):Ut(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=Zr(a,e),a=t),z({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(OS(e.self()));let t;t=gC(i,o,n=>{t&&s.delete(t);let r=DS(n,e.self()),i=s.size>0;e.setSelf(i?LS(r):r)}),t&&s.add(t)}),o}),EC=(e,t)=>sC(t.read,function(t,n){t.set(e,t.get(e)+1)}),DC=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),OC=Je(e=>QS(e[0]),(e,t,n)=>{let r=eC(aC(e)?sC(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):oC(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=kC(n.initialValueTarget)),r}),kC=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},AC=YS,jC=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},MC=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,NC=(e,t,n)=>e+(t-e)*n,PC=(e,t,n)=>{let[r,i,a]=jC(e),[o,s,c]=jC(t);return MC(NC(r,o,n),NC(i,s,n),NC(a,c,n))},FC=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[i,a]=W(-16),o=Si(r);o.current=r;let s=Si(e.length);s.current=e.length;let c=Si(!1);return c.current||(c.current=!0,setTimeout(()=>{setInterval(()=>{let e=s.current+16;a(t=>t>=e?-16:t+o.current)},50)},0)),G(U,{children:[...e].map((e,r)=>{let a=Math.abs(r-i),o=Math.max(0,1-a/16);return G(U,{color:o>0?PC(t,n,o):t,children:e},r)})})},IC=Qi(e=>({executedPlan:void 0,expanded:!1,setExecutedPlan:t=>e({executedPlan:t}),setExpanded:t=>e({expanded:t}),toggleExpanded:()=>e(e=>({expanded:!e.expanded}))})),LC=e=>fa(Math.max(0,e),{secondsDecimalDigits:0}),RC=new Set([`warpterminal`]),zC=ma.stdout,BC=pa({preferOuter:!0}),VC=process.stdout.isTTY&&!RC.has(BC??``),HC=VC&&zC.kitty,UC=VC&&zC.iterm2,WC=HC||UC,GC=pa(),KC=GC===`tmux`||GC===`screen`,qC=e=>KC?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,JC=(e,t)=>{let n=Buffer.from(e).toString(`base64`),r=`a=T,t=f`;return t.width&&(r+=`,c=${t.width}`),t.height&&(r+=`,r=${t.height}`),qC(`_G${r};${n}\\`)},YC=(e,t)=>{let n=`\x1B]1337;File=inline=1`;return t.width&&(n+=`;width=${t.width}`),t.height&&(n+=`;height=${t.height}`),n+=`;size=${e.byteLength}:${e.toString(`base64`)}`,qC(n)},XC=(e,t={})=>{if(!na.existsSync(e))return null;if(HC)return JC(e,t);if(UC)try{return YC(na.readFileSync(e),t)}catch{return null}return null},ZC=e=>e.startsWith(`file://`),QC=e=>{let t=gi(9);if(t[0]!==`edb58922a19f7cd34125950b48961a70defca0454a8de685a54dc50281109929`){for(let e=0;e<9;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`edb58922a19f7cd34125950b48961a70defca0454a8de685a54dc50281109929`}let{path:n,label:r}=e,i,a;t[1]===n?(i=t[2],a=t[3]):(i=ZC(n)?ki.fileURLToPath(n):Ti.resolve(n),a=ZC(n)?n:ki.pathToFileURL(i).href,t[1]=n,t[2]=i,t[3]=a);let o=a,s=r??i,c;t[4]===s?c=t[5]:(c=G(U,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==o||t[7]!==c?(l=G(ha,{url:o,children:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l},$C=({src:e,alt:t,width:n,height:r})=>{let i=Ti.resolve(e),{write:a}=di(),o=Si(!1);if(!o.current){let e=XC(i,{width:n,height:r});e&&(a(e+`
|
|
36
|
-
`)
|
|
17
|
+
`)}function l(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function u(){return process.env.DEBUG}function d(e){e.inspectOpts={};let n=Object.keys(t.inspectOpts);for(let r=0;r<n.length;r++)e.inspectOpts[n[r]]=t.inspectOpts[n[r]]}n.exports=Tu()(t);let{formatters:f}=n.exports;f.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split(`
|
|
18
|
+
`).map(e=>e.trim()).join(` `)},f.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}})),Au=n(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=Eu():t.exports=ku()})),ju=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0});let r=e(`fs`),i=n(Au()).default(`@kwsites/file-exists`);function a(e,t,n){i(`checking %s`,e);try{let a=r.statSync(e);return a.isFile()&&t?(i(`[OK] path represents a file`),!0):a.isDirectory()&&n?(i(`[OK] path represents a directory`),!0):(i(`[FAIL] path represents something other than a file or directory`),!1)}catch(e){if(e.code===`ENOENT`)return i(`[FAIL] path is not accessible: %o`,e),!1;throw i(`[FATAL] %o`,e),e}}function o(e,n=t.READABLE){return a(e,(n&t.FILE)>0,(n&t.FOLDER)>0)}t.exists=o,t.FILE=1,t.FOLDER=2,t.READABLE=t.FILE+t.FOLDER})),Mu=n((e=>{function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,`__esModule`,{value:!0}),t(ju())})),Nu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createDeferred=e.deferred=void 0;function t(){let e,t,n=`pending`;return{promise:new Promise((n,r)=>{e=n,t=r}),done(t){n===`pending`&&(n=`resolved`,e(t))},fail(e){n===`pending`&&(n=`rejected`,t(e))},get fulfilled(){return n!==`pending`},get status(){return n}}}e.deferred=t,e.createDeferred=t})),Pu=Mu(),Fu=t(Au(),1),Iu=Nu(),Lu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,zu=Object.getOwnPropertyNames,Bu=Object.prototype.hasOwnProperty,X=(e,t)=>function(){return e&&(t=(0,e[zu(e)[0]])(e=0)),t},Vu=(e,t)=>function(){return t||(0,e[zu(e)[0]])((t={exports:{}}).exports,t),t.exports},Hu=(e,t)=>{for(var n in t)Lu(e,n,{get:t[n],enumerable:!0})},Uu=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of zu(t))!Bu.call(e,i)&&i!==n&&Lu(e,i,{get:()=>t[i],enumerable:!(r=Ru(t,i))||r.enumerable});return e},Wu=e=>Uu(Lu({},`__esModule`,{value:!0}),e);function Gu(...e){let t=new String(e);return Ju.set(t,e),t}function Ku(e){return e instanceof String&&Ju.has(e)}function qu(e){return Ju.get(e)||[]}var Ju,Yu=X({"src/lib/args/pathspec.ts"(){Ju=new WeakMap}}),Xu,Zu=X({"src/lib/errors/git-error.ts"(){Xu=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),Qu,$u=X({"src/lib/errors/git-response-error.ts"(){Zu(),Qu=class extends Xu{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),ed,td=X({"src/lib/errors/task-configuration-error.ts"(){Zu(),ed=class extends Xu{constructor(e){super(void 0,e)}}}});function nd(e){return typeof e==`function`?e:wd}function rd(e){return typeof e==`function`&&e!==wd}function id(e,t){let n=e.indexOf(t);return n<=0?[e,``]:[e.substr(0,n),e.substr(n+1)]}function ad(e,t=0){return sd(e)&&e.length>t?e[t]:void 0}function od(e,t=0){if(sd(e)&&e.length>t)return e[e.length-1-t]}function sd(e){return Fd(e)}function cd(e=``,t=!0,n=`
|
|
19
|
+
`){return e.split(n).reduce((e,n)=>{let r=t?n.trim():n;return r&&e.push(r),e},[])}function ld(e,t){return cd(e,!0).map(e=>t(e))}function ud(e){return(0,Pu.exists)(e,Pu.FOLDER)}function dd(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function fd(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function pd(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function md(e){return Array.isArray(e)?e:[e]}function hd(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function gd(e){return md(e).map(e=>e instanceof String?e:String(e))}function _d(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function vd(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function yd(e){return(Array.isArray(e)?Ui.concat(e):e).toString(`utf-8`)}function bd(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function xd(e=0){return new Promise(t=>setTimeout(t,e))}function Sd(e){if(e!==!1)return e}var Cd,wd,Td,Ed=X({"src/lib/utils/util.ts"(){Id(),Cd=`\0`,wd=()=>{},Td=Object.prototype.toString.call.bind(Object.prototype.toString)}});function Dd(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function Od(e,t){let n=Ku(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function kd(e){return!!e&&Td(e)===`[object Object]`}function Ad(e){return typeof e==`function`}var jd,Md,Nd,Pd,Fd,Id=X({"src/lib/utils/argument-filters.ts"(){Yu(),Ed(),jd=e=>Array.isArray(e),Md=e=>typeof e==`number`,Nd=e=>typeof e==`string`||Ku(e),Pd=e=>Nd(e)||Array.isArray(e)&&e.every(Nd),Fd=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),Ld,Rd=X({"src/lib/utils/exit-codes.ts"(){Ld=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(Ld||{})}}),zd,Bd=X({"src/lib/utils/git-output-streams.ts"(){zd=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function Vd(){throw Error(`LineParser:useMatches not implemented`)}var Z,Hd,Ud=X({"src/lib/utils/line-parser.ts"(){Z=class{constructor(e,t){this.matches=[],this.useMatches=Vd,this.parse=(e,t)=>(this.resetMatches(),this._regExp.every((t,n)=>this.addMatch(t,n,e(n)))?this.useMatches(t,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(e)?e:[e],t&&(this.useMatches=t)}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(e,t,n){let r=n&&e.exec(n);return r&&this.pushMatch(t,r),!!r}pushMatch(e,t){this.matches.push(...t.slice(1))}},Hd=class extends Z{addMatch(e,t,n){return/^remote:\s/.test(String(n))&&super.addMatch(e,t,n)}pushMatch(e,t){(e>0||t.length>1)&&super.pushMatch(e,t)}}}});function Wd(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...Gd},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var Gd,Kd=X({"src/lib/utils/simple-git-options.ts"(){Gd={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function qd(e,t=[]){return kd(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(Ku(r))t.push(r);else if(Od(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)Od(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function Jd(e,t=0,n=!1){let r=[];for(let n=0,i=t<0?e.length:t;n<i;n++)`string|number`.includes(typeof e[n])&&r.push(String(e[n]));return qd(Xd(e),r),n||r.push(...Yd(e)),r}function Yd(e){return gd(Dd(od(e,typeof od(e)==`function`?1:0),jd,[]))}function Xd(e){return Dd(od(e,Ad(od(e))?1:0),kd)}function Zd(e,t=!0){let n=nd(od(e));return t||rd(n)?n:void 0}var Qd=X({"src/lib/utils/task-options.ts"(){Id(),Ed(),Yu()}});function $d(e,t){return e(t.stdOut,t.stdErr)}function ef(e,t,n,r=!0){return md(n).forEach(n=>{for(let i=cd(n,r),a=0,o=i.length;a<o;a++){let n=(e=0)=>{if(!(a+e>=o))return i[a+e]};t.some(({parse:t})=>t(n,e))}}),e}var tf=X({"src/lib/utils/task-parser.ts"(){Ed()}}),nf={};Hu(nf,{ExitCodes:()=>Ld,GitOutputStreams:()=>zd,LineParser:()=>Z,NOOP:()=>wd,NULL:()=>Cd,RemoteLineParser:()=>Hd,append:()=>dd,appendTaskOptions:()=>qd,asArray:()=>md,asCamelCase:()=>hd,asFunction:()=>nd,asNumber:()=>_d,asStringArray:()=>gd,bufferToString:()=>yd,callTaskParser:()=>$d,createInstanceConfig:()=>Wd,delay:()=>xd,filterArray:()=>jd,filterFunction:()=>Ad,filterHasLength:()=>Fd,filterNumber:()=>Md,filterPlainObject:()=>kd,filterPrimitives:()=>Od,filterString:()=>Nd,filterStringOrStringArray:()=>Pd,filterType:()=>Dd,first:()=>ad,folderExists:()=>ud,forEachLineWithContent:()=>ld,getTrailingOptions:()=>Jd,including:()=>fd,isUserFunction:()=>rd,last:()=>od,objectToString:()=>Td,orVoid:()=>Sd,parseStringResponse:()=>ef,pick:()=>bd,prefixedArray:()=>vd,remove:()=>pd,splitOn:()=>id,toLinesWithContent:()=>cd,trailingFunctionArgument:()=>Zd,trailingOptionsArgument:()=>Xd});var Q=X({"src/lib/utils/index.ts"(){Id(),Rd(),Bd(),Ud(),Kd(),Qd(),tf(),Ed()}}),rf={};Hu(rf,{CheckRepoActions:()=>lf,checkIsBareRepoTask:()=>sf,checkIsRepoRootTask:()=>of,checkIsRepoTask:()=>af});function af(e){switch(e){case`bare`:return sf();case`root`:return of()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:uf,parser:df}}function of(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:uf,parser(e){return/^\.(git)?$/.test(e.trim())}}}function sf(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:uf,parser:df}}function cf(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var lf,uf,df,ff=X({"src/lib/tasks/check-is-repo.ts"(){Q(),lf=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(lf||{}),uf=({exitCode:e},t,n,r)=>{if(e===128&&cf(t))return n(Buffer.from(`false`));r(t)},df=e=>e.trim()===`true`}});function pf(e,t){let n=new mf(e),r=e?gf:hf;return cd(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(_f.test(t)?n.folders:n.files).push(t)}),n}var mf,hf,gf,_f,vf=X({"src/lib/responses/CleanSummary.ts"(){Q(),mf=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},hf=/^[a-z]+\s*/i,gf=/^[a-z]+\s+[a-z]+\s*/i,_f=/\/$/}}),yf={};Hu(yf,{EMPTY_COMMANDS:()=>Ef,adhocExecTask:()=>bf,configurationErrorTask:()=>xf,isBufferTask:()=>wf,isEmptyTask:()=>Tf,straightThroughBufferTask:()=>Cf,straightThroughStringTask:()=>Sf});function bf(e){return{commands:Ef,format:`empty`,parser:e}}function xf(e){return{commands:Ef,format:`empty`,parser(){throw typeof e==`string`?new ed(e):e}}}function Sf(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function Cf(e){return{commands:e,format:`buffer`,parser(e){return e}}}function wf(e){return e.format===`buffer`}function Tf(e){return e.format===`empty`||!e.commands.length}var Ef,Df=X({"src/lib/tasks/task.ts"(){td(),Ef=[]}}),Of={};Hu(Of,{CONFIG_ERROR_INTERACTIVE_MODE:()=>If,CONFIG_ERROR_MODE_REQUIRED:()=>Lf,CONFIG_ERROR_UNKNOWN_OPTION:()=>Rf,CleanOptions:()=>zf,cleanTask:()=>Af,cleanWithOptionsTask:()=>kf,isCleanOptionsArray:()=>jf});function kf(e,t){let{cleanMode:n,options:r,valid:i}=Mf(e);return n?i.options?(r.push(...t),r.some(Ff)?xf(If):Af(n,r)):xf(Rf+JSON.stringify(e)):xf(Lf)}function Af(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return pf(e===`n`,t)}}}function jf(e){return Array.isArray(e)&&e.every(e=>Bf.has(e))}function Mf(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{Nf(e)?(t=e,r.cleanMode=!0):r.options=r.options&&Pf(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function Nf(e){return e===`f`||e===`n`}function Pf(e){return/^-[a-z]$/i.test(e)&&Bf.has(e.charAt(1))}function Ff(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var If,Lf,Rf,zf,Bf,Vf=X({"src/lib/tasks/clean.ts"(){vf(),Q(),Df(),If=`Git clean interactive mode is not supported`,Lf=`Git clean mode parameter ("n" or "f") is required`,Rf=`Git clean unknown option found in: `,zf=(e=>(e.DRY_RUN=`n`,e.FORCE=`f`,e.IGNORED_INCLUDED=`x`,e.IGNORED_ONLY=`X`,e.EXCLUDING=`e`,e.QUIET=`q`,e.RECURSIVE=`d`,e))(zf||{}),Bf=new Set([`i`,...gd(Object.values(zf))])}});function Hf(e){let t=new Kf;for(let n of Gf(e))t.addValue(n.file,String(n.key),n.value);return t}function Uf(e,t){let n=null,r=[],i=new Map;for(let a of Gf(e,t))a.key===t&&(r.push(n=a.value),i.has(a.file)||i.set(a.file,[]),i.get(a.file).push(n));return{key:t,paths:Array.from(i.keys()),scopes:i,value:n,values:r}}function Wf(e){return e.replace(/^(file):/,``)}function*Gf(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=Wf(n[e++]),i=n[e++],a=t;if(i.includes(`
|
|
20
|
+
`)){let e=id(i,`
|
|
21
|
+
`);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var Kf,qf=X({"src/lib/responses/ConfigList.ts"(){Q(),Kf=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{}),this._all}addFile(e){if(!(e in this.values)){let t=od(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,n){let r=this.addFile(e);Object.hasOwn(r,t)?Array.isArray(r[t])?r[t].push(n):r[t]=[r[t],n]:r[t]=n,this._all=void 0}}}});function Jf(e,t){return typeof e==`string`&&Object.hasOwn($f,e)?e:t}function Yf(e,t,n,r){let i=[`config`,`--${r}`];return n&&i.push(`--add`),i.push(e,t),{commands:i,format:`utf-8`,parser(e){return e}}}function Xf(e,t){let n=[`config`,`--null`,`--show-origin`,`--get-all`,e];return t&&n.splice(1,0,`--${t}`),{commands:n,format:`utf-8`,parser(t){return Uf(t,e)}}}function Zf(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return Hf(e)}}}function Qf(){return{addConfig(e,t,...n){return this._runTask(Yf(e,t,n[0]===!0,Jf(n[1],`local`)),Zd(arguments))},getConfig(e,t){return this._runTask(Xf(e,Jf(t,void 0)),Zd(arguments))},listConfig(...e){return this._runTask(Zf(Jf(e[0],void 0)),Zd(arguments))}}}var $f,ep=X({"src/lib/tasks/config.ts"(){qf(),Q(),$f=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))($f||{})}});function tp(e){return rp.has(e)}var np,rp,ip=X({"src/lib/tasks/diff-name-status.ts"(){np=(e=>(e.ADDED=`A`,e.COPIED=`C`,e.DELETED=`D`,e.MODIFIED=`M`,e.RENAMED=`R`,e.CHANGED=`T`,e.UNMERGED=`U`,e.UNKNOWN=`X`,e.BROKEN=`B`,e))(np||{}),rp=new Set(Object.values(np))}});function ap(...e){return new dp().param(...e)}function op(e){let t=new Set,n={};return ld(e,e=>{let[r,i,a]=e.split(Cd);t.add(r),(n[r]=n[r]||[]).push({line:_d(i),path:r,preview:a})}),{paths:t,results:n}}function sp(){return{grep(e){let t=Zd(arguments),n=Jd(arguments);for(let e of cp)if(n.includes(e))return this._runTask(xf(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=ap().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return op(e)}},t)}}}var cp,lp,up,dp,fp=X({"src/lib/tasks/grep.ts"(){Q(),Df(),cp=[`-h`],lp=Symbol(`grepQuery`),dp=class{constructor(){this[up]=[]}*[(up=lp,Symbol.iterator)](){for(let e of this[lp])yield e}and(...e){return e.length&&this[lp].push(`--and`,`(`,...vd(e,`-e`),`)`),this}param(...e){return this[lp].push(...vd(e,`-e`)),this}}}}),pp={};Hu(pp,{ResetMode:()=>_p,getResetMode:()=>hp,resetTask:()=>mp});function mp(e,t){let n=[`reset`];return gp(e)&&n.push(`--${e}`),n.push(...t),Sf(n)}function hp(e){if(gp(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function gp(e){return typeof e==`string`&&vp.includes(e)}var _p,vp,yp=X({"src/lib/tasks/reset.ts"(){Q(),Df(),_p=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(_p||{}),vp=gd(Object.values(_p))}});function bp(){return(0,Fu.default)(`simple-git`)}function xp(e,t,n){return!t||!String(t).replace(/\s*/,``)?n?(t,...r)=>{e(t,...r),n(t,...r)}:e:(r,...i)=>{e(`%s ${r}`,t,...i),n&&n(r,...i)}}function Sp(e,t,{namespace:n}){if(typeof e==`string`)return e;let r=t&&t.namespace||``;return r.startsWith(n)?r.substr(n.length+1):r||n}function Cp(e,t,n,r=bp()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=Sp(Dd(t,Nd),o,r);return l(n);function c(t,n){return dd(a,Cp(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&xp(o,n)||wd,s=xp(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var wp=X({"src/lib/git-logger.ts"(){Q(),Fu.default.formatters.L=e=>String(Fd(e)?e.length:`-`),Fu.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):Td(e)}}),Tp,Ep=X({"src/lib/runners/tasks-pending-queue.ts"(){Zu(),wp(),Tp=class e{constructor(e=`GitExecutor`){this.logLabel=e,this._queue=new Map}withProgress(e){return this._queue.get(e)}createProgress(t){let n=e.getName(t.commands[0]);return{task:t,logger:Cp(this.logLabel,n),name:n}}push(e){let t=this.createProgress(e);return t.logger(`Adding task to the queue, commands = %o`,e.commands),this._queue.set(e,t),t}fatal(e){for(let[t,{logger:n}]of Array.from(this._queue.entries()))t===e.task?(n.info(`Failed %o`,e),n(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`)):n.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`,e.message),this.complete(t);if(this._queue.size!==0)throw Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(e){this.withProgress(e)&&this._queue.delete(e)}attempt(e){let t=this.withProgress(e);if(!t)throw new Xu(void 0,`TasksPendingQueue: attempt called for an unknown task`);return t.logger(`Starting task`),t}static getName(t=`empty`){return`task:${t}:${++e.counter}`}static{this.counter=0}}}});function Dp(e,t){return{method:ad(e.commands)||``,commands:t}}function Op(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function kp(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var Ap,jp=X({"src/lib/runners/git-executor-chain.ts"(){Zu(),Df(),Q(),Ep(),Ap=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new Tp}get cwd(){return this._cwd||this._executor.cwd}set cwd(e){this._cwd=e}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(e){return this._queue.push(e),this._chain=this._chain.then(()=>this.attemptTask(e))}async attemptTask(e){let t=await this._scheduler.next(),n=()=>this._queue.complete(e);try{let{logger:t}=this._queue.attempt(e);return await(Tf(e)?this.attemptEmptyTask(e,t):this.attemptRemoteTask(e,t))}catch(t){throw this.onFatalException(e,t)}finally{n(),t()}}onFatalException(e,t){let n=t instanceof Xu?Object.assign(t,{task:e}):new Xu(e,t&&String(t));return this._chain=Promise.resolve(),this._queue.fatal(n),n}async attemptRemoteTask(e,t){let n=this._plugins.exec(`spawn.binary`,``,Dp(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],Dp(e,e.commands)),i=await this.gitResponse(e,n,r,this.outputHandler,t.step(`SPAWN`)),a=await this.handleTaskData(e,r,i,t.step(`HANDLE`));return t(`passing response to task's parser as a %s`,e.format),wf(e)?$d(e.parser,a):$d(e.parser,a.asStrings())}async attemptEmptyTask(e,t){return t(`empty task bypassing child process to call to task's parser`),e.parser(this)}handleTaskData(e,t,n,r){let{exitCode:i,rejection:a,stdOut:o,stdErr:s}=n;return new Promise((c,l)=>{r(`Preparing to handle process response exitCode=%d stdOut=`,i);let{error:u}=this._plugins.exec(`task.error`,{error:a},{...Dp(e,t),...n});if(u&&e.onError)return r.info(`exitCode=%s handling with custom error handler`),e.onError(n,u,e=>{r.info(`custom error handler treated as success`),r(`custom error returned a %s`,Td(e)),c(new zd(Array.isArray(e)?Buffer.concat(e):e,Buffer.concat(s)))},l);if(u)return r.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`,i,s.length,a),l(u);r.info(`retrieving task output complete`),c(new zd(Buffer.concat(o),Buffer.concat(s)))})}async gitResponse(e,t,n,r,i){let a=i.sibling(`output`),o=this._plugins.exec(`spawn.options`,{cwd:this.cwd,env:this.env,windowsHide:!0},Dp(e,e.commands));return new Promise(s=>{let c=[],l=[];i.info(`%s %o`,t,n),i(`%O`,o);let u=this._beforeSpawn(e,n);if(u)return s({stdOut:c,stdErr:l,exitCode:9901,rejection:u});this._plugins.exec(`spawn.before`,void 0,{...Dp(e,n),kill(e){u=e||u}});let d=Gi(t,n,o);d.stdout.on(`data`,kp(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,kp(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,Op(l,i)),r&&(i(`Passing child process stdOut/stdErr to custom outputHandler`),r(t,d.stdout,d.stderr,[...n])),this._plugins.exec(`spawn.after`,void 0,{...Dp(e,n),spawned:d,close(e,t){s({stdOut:c,stdErr:l,exitCode:e,rejection:u||t})},kill(e){d.killed||(u=e,d.kill(`SIGINT`))}})})}_beforeSpawn(e,t){let n;return this._plugins.exec(`spawn.before`,void 0,{...Dp(e,t),kill(e){n=e||n}}),n}}}}),Mp={};Hu(Mp,{GitExecutor:()=>Np});var Np,Pp=X({"src/lib/runners/git-executor.ts"(){jp(),Np=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new Ap(this,this._scheduler,this._plugins)}chain(){return new Ap(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function Fp(e,t,n=wd){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof Qu?Ip(t):t,void 0)})}function Ip(e){let t=e=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${e} should be GitResponseError.git.${e}, this will no longer be available in version 3`),t=wd};return Object.create(e,Object.getOwnPropertyNames(e.git).reduce(n,{}));function n(n,r){return r in e||(n[r]={enumerable:!1,configurable:!1,get(){return t(r),e.git[r]}}),n}}var Lp=X({"src/lib/task-callback.ts"(){$u(),Q()}});function Rp(e,t){return bf(n=>{if(!ud(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var zp=X({"src/lib/tasks/change-working-directory.ts"(){Q(),Df()}});function Bp(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=pd(t,`-B`)),Sf(t)}function Vp(){return{checkout(){return this._runTask(Bp(Jd(arguments,1)),Zd(arguments))},checkoutBranch(e,t){return this._runTask(Bp([`-b`,e,t,...Jd(arguments)]),Zd(arguments))},checkoutLocalBranch(e){return this._runTask(Bp([`-b`,e,...Jd(arguments)]),Zd(arguments))}}}var Hp=X({"src/lib/tasks/checkout.ts"(){Q(),Df()}});function Up(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function Wp(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return ef(Up(),[Gp],e)}})}}}var Gp,Kp=X({"src/lib/tasks/count-objects.ts"(){Q(),Gp=new Z(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=hd(t);Object.hasOwn(e,r)&&(e[r]=_d(n))})}});function qp(e){return ef({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},Jp,e)}var Jp,Yp=X({"src/lib/parsers/parse-commit.ts"(){Q(),Jp=[new Z(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new Z(/\s*Author:\s(.+)/i,(e,[t])=>{let n=t.split(`<`),r=n.pop();!r||!r.includes(`@`)||(e.author={email:r.substr(0,r.length-1),name:n.join(`<`).trim()})}),new Z(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0,e.summary.insertions=parseInt(n,10)||0,e.summary.deletions=parseInt(r,10)||0}),new Z(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0;let i=parseInt(n,10)||0;r===`-`?e.summary.deletions=i:r===`+`&&(e.summary.insertions=i)})]}});function Xp(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...vd(e,`-m`),...t,...n],format:`utf-8`,parser:qp}}function Zp(){return{commit(t,...n){let r=Zd(arguments),i=e(t)||Xp(md(t),md(Dd(n[0],Pd,[])),[...gd(Dd(n[1],jd,[])),...Jd(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!Pd(e)&&xf(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var Qp=X({"src/lib/tasks/commit.ts"(){Yp(),Q(),Df()}});function $p(){return{firstCommit(){return this._runTask(Sf([`rev-list`,`--max-parents=0`,`HEAD`],!0),Zd(arguments))}}}var em=X({"src/lib/tasks/first-commit.ts"(){Q(),Df()}});function tm(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),Sf(n,!0)}var nm=X({"src/lib/tasks/hash-object.ts"(){Df()}});function rm(e,t,n){let r=String(n).trim(),i;if(i=am.exec(r))return new im(e,t,!1,i[1]);if(i=om.exec(r))return new im(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new im(e,t,/^re/i.test(r),a)}var im,am,om,sm=X({"src/lib/responses/InitSummary.ts"(){im=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},am=/^Init.+ repository in (.+)$/,om=/^Rein.+ in (.+)$/}});function cm(e){return e.includes(um)}function lm(e=!1,t,n){let r=[`init`,...n];return e&&!cm(r)&&r.splice(1,0,um),{commands:r,format:`utf-8`,parser(e){return rm(r.includes(`--bare`),t,e)}}}var um,dm=X({"src/lib/tasks/init.ts"(){sm(),um=`--bare`}});function fm(e){for(let t=0;t<e.length;t++){let n=mm.exec(e[t]);if(n)return`--${n[1]}`}return``}function pm(e){return mm.test(e)}var mm,hm=X({"src/lib/args/log-format.ts"(){mm=/^--(stat|numstat|name-only|name-status)(=|$)/}}),gm,_m=X({"src/lib/responses/DiffSummary.ts"(){gm=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function vm(e=``){let t=Cm[e];return e=>ef(new gm,t,e,!1)}var ym,bm,xm,Sm,Cm,wm=X({"src/lib/parsers/parse-diff-summary.ts"(){hm(),_m(),ip(),Q(),ym=[new Z(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:_d(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new Z(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:_d(n),after:_d(r),binary:!0})}),new Z(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=_d(t),e.insertions=_d(r?.[1]),e.deletions=_d(i?.[1])})],bm=[new Z(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=_d(t),a=_d(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new Z(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],xm=[new Z(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],Sm=[new Z(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(e,[t,n,r,i,a])=>{e.changed++,e.files.push({file:a??r,changes:0,insertions:0,deletions:0,binary:!1,status:Sd(tp(t)&&t),from:Sd(!!a&&r!==a&&r),similarity:_d(n)})})],Cm={"":ym,"--stat":ym,"--numstat":bm,"--name-status":Sm,"--name-only":xm}}});function Tm(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function Em(e=km,t=Am,n=``){let r=vm(n);return function(n){let i=cd(n.trim(),!1,Dm).map(function(n){let i=n.split(Om),a=Tm(i[0].split(e),t);return i.length>1&&i[1].trim()&&(a.diff=r(i[1])),a});return{all:i,latest:i.length&&i[0]||null,total:i.length}}}var Dm,Om,km,Am,jm=X({"src/lib/parsers/parse-list-log-summary.ts"(){Q(),wm(),hm(),Dm=`òòòòòò `,Om=` òò`,km=` ò `,Am=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),Mm={};Hu(Mm,{diffSummaryTask:()=>Nm,validateLogFormatConfig:()=>Pm});function Nm(e){let t=fm(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),Pm(n)||{commands:n,format:`utf-8`,parser:vm(t)}}function Pm(e){let t=e.filter(pm);if(t.length>1)return xf(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return xf(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var Fm=X({"src/lib/tasks/diff.ts"(){hm(),wm(),Df()}});function Im(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function Lm(e){return Object.keys(e).reduce((t,n)=>(n in Vm||(t[n]=e[n]),t),{})}function Rm(e={},t=[]){let n=Dd(e.splitter,Nd,km),[r,i]=Im(kd(e.format)?e.format:{hash:`%H`,date:e.strictDate===!1?`%ai`:`%aI`,message:`%s`,refs:`%D`,body:e.multiLine?`%B`:`%b`,author_name:e.mailMap===!1?`%an`:`%aN`,author_email:e.mailMap===!1?`%ae`:`%aE`},n),a=[],o=[`--pretty=format:${Dm}${i}${Om}`,...t],s=e.n||e[`max-count`]||e.maxCount;if(s&&o.push(`--max-count=${s}`),e.from||e.to){let t=e.symmetric===!1?`..`:`...`;a.push(`${e.from||``}${t}${e.to||``}`)}return Nd(e.file)&&o.push(`--follow`,Gu(e.file)),qd(Lm(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function zm(e,t,n){let r=Em(e,t,fm(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function Bm(){return{log(...n){let r=Zd(arguments),i=Rm(Xd(arguments),gd(Dd(arguments[0],jd,[]))),a=t(...n)||Pm(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return zm(e.splitter,e.fields,e.commands)}function t(e,t){return Nd(e)&&Nd(t)&&xf(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var Vm,Hm=X({"src/lib/tasks/log.ts"(){hm(),Yu(),jm(),Q(),Df(),Fm(),Vm=(e=>(e[e[`--pretty`]=0]=`--pretty`,e[e[`max-count`]=1]=`max-count`,e[e.maxCount=2]=`maxCount`,e[e.n=3]=`n`,e[e.file=4]=`file`,e[e.format=5]=`format`,e[e.from=6]=`from`,e[e.to=7]=`to`,e[e.splitter=8]=`splitter`,e[e.symmetric=9]=`symmetric`,e[e.mailMap=10]=`mailMap`,e[e.multiLine=11]=`multiLine`,e[e.strictDate=12]=`strictDate`,e))(Vm||{})}}),Um,Wm,Gm=X({"src/lib/responses/MergeSummary.ts"(){Um=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},Wm=class{constructor(){this.conflicts=[],this.merges=[],this.result=`success`}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(`, `)}`:`OK`}}}}),Km,qm,Jm=X({"src/lib/responses/PullSummary.ts"(){Km=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},qm=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function Ym(e){return e.objects=e.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function Xm(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:_d(t&&t[1]||`0`),delta:_d(n&&n[1]||`0`)}}var Zm,Qm=X({"src/lib/parsers/parse-remote-objects.ts"(){Q(),Zm=[new Hd(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ym(e.remoteMessages);Object.assign(i,{[r]:_d(n)})}),new Hd(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ym(e.remoteMessages);Object.assign(i,{[r]:_d(n)})}),new Hd(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=Ym(e.remoteMessages);i.total=Xm(t),i.reused=Xm(n),i.packReused=_d(r)})]}});function $m(e,t){return ef({remoteMessages:new th},eh,t)}var eh,th,nh=X({"src/lib/parsers/parse-remote-messages.ts"(){Q(),Qm(),eh=[new Hd(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...Zm,new Hd([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new Hd([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:_d(t),summary:n,url:r}})],th=class{constructor(){this.all=[]}}}});function rh(e,t){let n=ef(new qm,ch,[e,t]);return n.message&&n}var ih,ah,oh,sh,ch,lh,uh,dh=X({"src/lib/parsers/parse-pull.ts"(){Jm(),Q(),nh(),ih=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,ah=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,oh=/^(create|delete) mode \d+ (.+)/,sh=[new Z(ih,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Z(ah,(e,[t,,n,,r])=>n!==void 0||r!==void 0?(e.summary.changes=+t||0,e.summary.insertions=+n||0,e.summary.deletions=+r||0,!0):!1),new Z(oh,(e,[t,n])=>{dd(e.files,n),dd(t===`create`?e.created:e.deleted,n)})],ch=[new Z(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new Z(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new Z(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(e,[t,n,r,i])=>{e.branch.local=r,e.hash.local=t,e.branch.remote=i,e.hash.remote=n})],lh=(e,t)=>ef(new Km,sh,[e,t]),uh=(e,t)=>Object.assign(new Km,lh(e,t),$m(e,t))}}),fh,ph,mh,hh=X({"src/lib/parsers/parse-merge.ts"(){Gm(),Q(),dh(),fh=[new Z(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new Z(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new Um(t,n))}),new Z(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new Um(t,n,{deleteRef:r}))}),new Z(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new Um(t,null))}),new Z(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],ph=(e,t)=>Object.assign(mh(e,t),uh(e,t)),mh=e=>ef(new Wm,fh,e)}});function gh(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=ph(e,t);if(n.failed)throw new Qu(n);return n}}:xf(`Git.merge requires at least one option`)}var _h=X({"src/lib/tasks/merge.ts"(){$u(),hh(),Df()}});function vh(e,t,n){let r=n.includes(`deleted`),i=n.includes(`tag`)||/^refs\/tags/.test(e),a=!n.includes(`new`);return{deleted:r,tag:i,branch:!i,new:!a,alreadyUpdated:a,local:e,remote:t}}var yh,bh,xh,Sh=X({"src/lib/parsers/parse-push.ts"(){Q(),nh(),yh=[new Z(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new Z(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new Z(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(vh(t,n,r))}),new Z(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new Z(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(e,[t,n,r,i])=>{e.update={head:{local:t,remote:n},hash:{from:r,to:i}}})],bh=(e,t)=>{let n=xh(e,t),r=$m(e,t);return{...n,...r}},xh=(e,t)=>ef({pushed:[]},yh,[e,t])}}),Ch={};Hu(Ch,{pushTagsTask:()=>wh,pushTask:()=>Th});function wh(e={},t){return dd(t,`--tags`),Th(e,t)}function Th(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),pd(n,`-v`),dd(n,`--verbose`),dd(n,`--porcelain`),{commands:n,format:`utf-8`,parser:bh}}var Eh=X({"src/lib/tasks/push.ts"(){Sh(),Q()}});function Dh(){return{showBuffer(){let e=[`show`,...Jd(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(Cf(e),Zd(arguments))},show(){let e=[`show`,...Jd(arguments,1)];return this._runTask(Sf(e),Zd(arguments))}}}var Oh=X({"src/lib/tasks/show.ts"(){Q(),Df()}}),kh,Ah,jh=X({"src/lib/responses/FileStatusSummary.ts"(){kh=/^(.+)\0(.+)$/,Ah=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=kh.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function Mh(e){let[t,n]=e.split(Cd);return{from:n||t,to:t}}function Nh(e,t,n){return[`${e}${t}`,n]}function Ph(e,...t){return t.map(t=>Nh(e,t,(e,t)=>e.conflicted.push(t)))}function Fh(e,t){let n=t.trim();switch(` `){case n.charAt(2):return r(n.charAt(0),n.charAt(1),n.slice(3));case n.charAt(1):return r(` `,n.charAt(0),n.slice(2));default:return}function r(t,n,r){let i=`${t}${n}`,a=Lh.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new Ah(r,t,n))}}var Ih,Lh,Rh,zh=X({"src/lib/responses/StatusSummary.ts"(){Q(),jh(),Ih=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},Lh=new Map([Nh(` `,`A`,(e,t)=>e.created.push(t)),Nh(` `,`D`,(e,t)=>e.deleted.push(t)),Nh(` `,`M`,(e,t)=>e.modified.push(t)),Nh(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),Nh(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),Nh(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),Nh(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Nh(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Nh(`R`,` `,(e,t)=>{e.renamed.push(Mh(t))}),Nh(`R`,`M`,(e,t)=>{let n=Mh(t);e.renamed.push(n),e.modified.push(n.to)}),Nh(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),Nh(`?`,`?`,(e,t)=>e.not_added.push(t)),...Ph(`A`,`A`,`U`),...Ph(`D`,`D`,`U`),...Ph(`U`,`A`,`D`,`U`),[`##`,(e,t)=>{let n=/ahead (\d+)/,r=/behind (\d+)/,i=/^(.+?(?=(?:\.{3}|\s|$)))/,a=/\.{3}(\S*)/,o=/\son\s(\S+?)(?=\.{3}|$)/,s=n.exec(t);e.ahead=s&&+s[1]||0,s=r.exec(t),e.behind=s&&+s[1]||0,s=i.exec(t),e.current=Dd(s?.[1],Nd,null),s=a.exec(t),e.tracking=Dd(s?.[1],Nd,null),s=o.exec(t),s&&(e.current=Dd(s?.[1],Nd,e.current)),e.detached=/\(no branch\)/.test(t)}]]),Rh=function(e){let t=e.split(Cd),n=new Ih;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=Cd+(t[e++]||``)),Fh(n,r))}return n}}});function Bh(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!Vh.includes(e))],parser(e){return Rh(e)}}}var Vh,Hh=X({"src/lib/tasks/status.ts"(){zh(),Vh=[`--null`,`-z`]}});function Uh(e=0,t=0,n=0,r=``,i=!0){return Object.defineProperty({major:e,minor:t,patch:n,agent:r,installed:i},`toString`,{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function Wh(){return Uh(0,0,0,``,!1)}function Gh(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:Kh,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(qh));r(t)}})}}}function Kh(e){return e===qh?Wh():ef(Uh(0,0,0,e),Jh,e)}var qh,Jh,Yh=X({"src/lib/tasks/version.ts"(){Q(),qh=`installed=false`,Jh=[new Z(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,Uh(_d(t),_d(n),_d(r),i))}),new Z(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,Uh(_d(t),_d(n),r,i))})]}});function Xh(e,t,n,...r){return Nd(n)?t(n,Dd(r[0],Nd),Jd(arguments)):xf(`git.${e}() requires a string 'repoPath'`)}function Zh(){return{clone(e,...t){return this._runTask(Xh(`clone`,Qh,Dd(e,Nd),...t),Zd(arguments))},mirror(e,...t){return this._runTask(Xh(`mirror`,$h,Dd(e,Nd),...t),Zd(arguments))}}}var Qh,$h,eg=X({"src/lib/tasks/clone.ts"(){Df(),Q(),Yu(),Qh=(e,t,n)=>{let r=[`clone`,...n];return Nd(e)&&r.push(Gu(e)),Nd(t)&&r.push(Gu(t)),Sf(r)},$h=(e,t,n)=>(dd(n,`--mirror`),Qh(e,t,n))}}),tg={};Hu(tg,{SimpleGitApi:()=>ng});var ng,rg=X({"src/lib/simple-git-api.ts"(){Lp(),zp(),Hp(),Kp(),Qp(),ep(),em(),fp(),nm(),dm(),Hm(),_h(),Eh(),Oh(),Hh(),Df(),Yh(),Q(),eg(),ng=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&Fp(e,r,t),Object.create(this,{then:{value:r.then.bind(r)},catch:{value:r.catch.bind(r)},_executor:{value:n}})}add(e){return this._runTask(Sf([`add`,...md(e)]),Zd(arguments))}cwd(e){let t=Zd(arguments);return typeof e==`string`?this._runTask(Rp(e,this._executor),t):typeof e?.path==`string`?this._runTask(Rp(e.path,e.root&&this._executor||void 0),t):this._runTask(xf(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(tm(e,t===!0),Zd(arguments))}init(e){return this._runTask(lm(e===!0,this._executor.cwd,Jd(arguments)),Zd(arguments))}merge(){return this._runTask(gh(Jd(arguments)),Zd(arguments))}mergeFromTo(e,t){return Nd(e)&&Nd(t)?this._runTask(gh([e,t,...Jd(arguments)]),Zd(arguments,!1)):this._runTask(xf(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=Th({remote:Dd(arguments[0],Nd),branch:Dd(arguments[1],Nd)},Jd(arguments));return this._runTask(e,Zd(arguments))}stash(){return this._runTask(Sf([`stash`,...Jd(arguments)]),Zd(arguments))}status(){return this._runTask(Bh(Jd(arguments)),Zd(arguments))}},Object.assign(ng.prototype,Vp(),Zh(),Zp(),Qf(),Wp(),$p(),sp(),Bm(),Dh(),Gh())}}),ig={};Hu(ig,{Scheduler:()=>og});var ag,og,sg=X({"src/lib/runners/scheduler.ts"(){Q(),wp(),ag=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,Iu.createDeferred)();return{promise:t,done:n,id:e}}})(),og=class{constructor(e=2){this.concurrency=e,this.logger=Cp(``,`scheduler`),this.pending=[],this.running=[],this.logger(`Constructed, concurrency=%s`,e)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`,this.pending.length,this.running.length,this.concurrency);return}let e=dd(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),pd(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=dd(this.pending,ag());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),cg={};Hu(cg,{applyPatchTask:()=>lg});function lg(e,t){return Sf([`apply`,...t,...e])}var ug=X({"src/lib/tasks/apply-patch.ts"(){Df()}});function dg(e,t){return{branch:e,hash:t,success:!0}}function fg(e){return{branch:e,hash:null,success:!1}}var pg,mg=X({"src/lib/responses/BranchDeleteSummary.ts"(){pg=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function hg(e,t){return t===1&&_g.test(e)}var gg,_g,vg,yg,bg=X({"src/lib/parsers/parse-branch-delete.ts"(){mg(),Q(),gg=/(\S+)\s+\(\S+\s([^)]+)\)/,_g=/^error[^']+'([^']+)'/m,vg=[new Z(gg,(e,[t,n])=>{let r=dg(t,n);e.all.push(r),e.branches[t]=r}),new Z(_g,(e,[t])=>{let n=fg(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],yg=(e,t)=>ef(new pg,vg,[e,t])}}),xg,Sg=X({"src/lib/responses/BranchSummary.ts"(){xg=class{constructor(){this.all=[],this.branches={},this.current=``,this.detached=!1}push(e,t,n,r,i){e===`*`&&(this.detached=t,this.current=n),this.all.push(n),this.branches[n]={current:e===`*`,linkedWorkTree:e===`+`,name:n,commit:r,label:i}}}}});function Cg(e){return e?e.charAt(0):``}function wg(e,t=!1){return ef(new xg,t?[Eg]:Tg,e)}var Tg,Eg,Dg=X({"src/lib/parsers/parse-branch.ts"(){Sg(),Q(),Tg=[new Z(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(Cg(t),!0,n,r,i)}),new Z(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(Cg(t),!1,n,r,i)})],Eg=new Z(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),Og={};Hu(Og,{branchLocalTask:()=>jg,branchTask:()=>Ag,containsDeleteBranchCommand:()=>kg,deleteBranchTask:()=>Ng,deleteBranchesTask:()=>Mg});function kg(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function Ag(e){let t=kg(e),n=e.includes(`--show-current`),r=[`branch`,...e];return r.length===1&&r.push(`-a`),r.includes(`-v`)||r.splice(1,0,`-v`),{format:`utf-8`,commands:r,parser(e,r){return t?yg(e,r).all[0]:wg(e,n)}}}function jg(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return wg(e)}}}function Mg(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return yg(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!hg(String(n),e))return i(n);r(t)}}}function Ng(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return yg(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!hg(String(i),e))return o(i);throw new Qu(n.parser(yd(r),yd(t)),String(i))}};return n}var Pg=X({"src/lib/tasks/branch.ts"(){$u(),bg(),Dg(),Q()}});function Fg(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&Ai(t)}var Ig,Lg=X({"src/lib/responses/CheckIgnore.ts"(){Ig=e=>e.split(/\n/g).map(Fg).filter(Boolean)}}),Rg={};Hu(Rg,{checkIgnoreTask:()=>zg});function zg(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:Ig}}var Bg=X({"src/lib/tasks/check-ignore.ts"(){Lg()}});function Vg(e,t){return ef({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},Hg,[e,t])}var Hg,Ug=X({"src/lib/parsers/parse-fetch.ts"(){Q(),Hg=[new Z(/From (.+)$/,(e,[t])=>{e.remote=t}),new Z(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new Z(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new Z(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new Z(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),Wg={};Hu(Wg,{fetchTask:()=>Kg});function Gg(e){return/^--upload-pack(=|$)/.test(e)}function Kg(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(Gg)?xf(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:Vg}}var qg=X({"src/lib/tasks/fetch.ts"(){Ug(),Df()}});function Jg(e){return ef({moves:[]},Yg,e)}var Yg,Xg=X({"src/lib/parsers/parse-move.ts"(){Q(),Yg=[new Z(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),Zg={};Hu(Zg,{moveTask:()=>Qg});function Qg(e,t){return{commands:[`mv`,`-v`,...md(e),t],format:`utf-8`,parser:Jg}}var $g=X({"src/lib/tasks/move.ts"(){Xg(),Q()}}),e_={};Hu(e_,{pullTask:()=>t_});function t_(e,t,n){let r=[`pull`,...n];return e&&t&&r.splice(1,0,e,t),{commands:r,format:`utf-8`,parser(e,t){return uh(e,t)},onError(e,t,n,r){let i=rh(yd(e.stdOut),yd(e.stdErr));if(i)return r(new Qu(i));r(t)}}}var n_=X({"src/lib/tasks/pull.ts"(){$u(),dh(),Q()}});function r_(e){let t={};return a_(e,([e])=>t[e]={name:e}),Object.values(t)}function i_(e){let t={};return a_(e,([e,n,r])=>{Object.hasOwn(t,e)||(t[e]={name:e,refs:{fetch:``,push:``}}),r&&n&&(t[e].refs[r.replace(/[^a-z]/g,``)]=n)}),Object.values(t)}function a_(e,t){ld(e,e=>t(e.split(/\s+/)))}var o_=X({"src/lib/responses/GetRemoteSummary.ts"(){Q()}}),s_={};Hu(s_,{addRemoteTask:()=>c_,getRemotesTask:()=>l_,listRemotesTask:()=>u_,remoteTask:()=>d_,removeRemoteTask:()=>f_});function c_(e,t,n){return Sf([`remote`,`add`,...n,e,t])}function l_(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?i_:r_}}function u_(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),Sf(t)}function d_(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),Sf(t)}function f_(e){return Sf([`remote`,`remove`,e])}var p_=X({"src/lib/tasks/remote.ts"(){o_(),Df()}}),m_={};Hu(m_,{stashListTask:()=>h_});function h_(e={},t){let n=Rm(e),r=[`stash`,`list`,...n.commands,...t],i=Em(n.splitter,n.fields,fm(r));return Pm(r)||{commands:r,format:`utf-8`,parser:i}}var g_=X({"src/lib/tasks/stash-list.ts"(){hm(),jm(),Fm(),Hm()}}),__={};Hu(__,{addSubModuleTask:()=>v_,initSubModuleTask:()=>y_,subModuleTask:()=>b_,updateSubModuleTask:()=>x_});function v_(e,t){return b_([`add`,e,t])}function y_(e){return b_([`init`,...e])}function b_(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),Sf(t)}function x_(e){return b_([`update`,...e])}var S_=X({"src/lib/tasks/sub-module.ts"(){Df()}});function C_(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?w_(e,t):0:n?1:-1}function w_(e,t){return e===t?0:e>t?1:-1}function T_(e){return e.trim()}function E_(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var D_,O_,k_=X({"src/lib/responses/TagList.ts"(){D_=class{constructor(e,t){this.all=e,this.latest=t}},O_=function(e,t=!1){let n=e.split(`
|
|
22
|
+
`).map(T_).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return C_(E_(n[0]),E_(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=w_(E_(n[e]),E_(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new D_(n,r)}}}),A_={};Hu(A_,{addAnnotatedTagTask:()=>N_,addTagTask:()=>M_,tagListTask:()=>j_});function j_(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return O_(e,t)}}}function M_(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function N_(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var P_=X({"src/lib/tasks/tag.ts"(){k_()}}),F_=Vu({"src/git.js"(e,t){var{GitExecutor:n}=(Pp(),Wu(Mp)),{SimpleGitApi:r}=(rg(),Wu(tg)),{Scheduler:i}=(sg(),Wu(ig)),{adhocExecTask:a,configurationErrorTask:o}=(Df(),Wu(yf)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(Q(),Wu(nf)),{applyPatchTask:g}=(ug(),Wu(cg)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(Pg(),Wu(Og)),{checkIgnoreTask:x}=(Bg(),Wu(Rg)),{checkIsRepoTask:ee}=(ff(),Wu(rf)),{cleanWithOptionsTask:S,isCleanOptionsArray:C}=(Vf(),Wu(Of)),{diffSummaryTask:w}=(Fm(),Wu(Mm)),{fetchTask:T}=(qg(),Wu(Wg)),{moveTask:E}=($g(),Wu(Zg)),{pullTask:D}=(n_(),Wu(e_)),{pushTagsTask:O}=(Eh(),Wu(Ch)),{addRemoteTask:te,getRemotesTask:ne,listRemotesTask:k,remoteTask:A,removeRemoteTask:j}=(p_(),Wu(s_)),{getResetMode:re,resetTask:M}=(yp(),Wu(pp)),{stashListTask:ie}=(g_(),Wu(m_)),{addSubModuleTask:ae,initSubModuleTask:N,subModuleTask:oe,updateSubModuleTask:se}=(S_(),Wu(__)),{addAnnotatedTagTask:P,addTagTask:ce,tagListTask:le}=(P_(),Wu(A_)),{straightThroughBufferTask:ue,straightThroughStringTask:de}=(Df(),Wu(yf));function F(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(F.prototype=Object.create(r.prototype)).constructor=F,F.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},F.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},F.prototype.stashList=function(e){return this._runTask(ie(h(arguments)||{},c(e)&&e||[]),m(arguments))},F.prototype.mv=function(e,t){return this._runTask(E(e,t),m(arguments))},F.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},F.prototype.pull=function(e,t,n,r){return this._runTask(D(f(e,u),f(t,u),p(arguments)),m(arguments))},F.prototype.fetch=function(e,t){return this._runTask(T(f(e,u),f(t,u),p(arguments)),m(arguments))},F.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},F.prototype.tags=function(e,t){return this._runTask(le(p(arguments)),m(arguments))},F.prototype.rebase=function(){return this._runTask(de([`rebase`,...p(arguments)]),m(arguments))},F.prototype.reset=function(e){return this._runTask(M(re(e),p(arguments)),m(arguments))},F.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(de([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},F.prototype.addTag=function(e){let t=typeof e==`string`?ce(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},F.prototype.addAnnotatedTag=function(e,t){return this._runTask(P(e,t),m(arguments))},F.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},F.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},F.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},F.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},F.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(de(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},F.prototype.submoduleAdd=function(e,t,n){return this._runTask(ae(e,t),m(arguments))},F.prototype.submoduleUpdate=function(e,t){return this._runTask(se(p(arguments,!0)),m(arguments))},F.prototype.submoduleInit=function(e,t){return this._runTask(N(p(arguments,!0)),m(arguments))},F.prototype.subModule=function(e,t){return this._runTask(oe(p(arguments)),m(arguments))},F.prototype.listRemote=function(){return this._runTask(k(p(arguments)),m(arguments))},F.prototype.addRemote=function(e,t,n){return this._runTask(te(e,t,p(arguments)),m(arguments))},F.prototype.removeRemote=function(e,t){return this._runTask(j(e),m(arguments))},F.prototype.getRemotes=function(e,t){return this._runTask(ne(e===!0),m(arguments))},F.prototype.remote=function(e,t){return this._runTask(A(p(arguments)),m(arguments))},F.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(de(n),m(arguments))},F.prototype.updateServerInfo=function(e){return this._runTask(de([`update-server-info`]),m(arguments))},F.prototype.pushTags=function(e,t){let n=O({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},F.prototype.rm=function(e){return this._runTask(de([`rm`,`-f`,...s(e)]),m(arguments))},F.prototype.rmKeepLocal=function(e){return this._runTask(de([`rm`,`--cached`,...s(e)]),m(arguments))},F.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},F.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},F.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?ue(r):de(r);return this._runTask(a,n)},F.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):de([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},F.prototype.diffSummary=function(){return this._runTask(w(p(arguments,1)),m(arguments))},F.prototype.applyPatch=function(e){let t=d(e)?g(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},F.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(de(e,!0),m(arguments))},F.prototype.clean=function(e,t,n){let r=C(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(S(i,a),m(arguments))},F.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},F.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},F.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},F.prototype.checkIsRepo=function(e,t){return this._runTask(ee(f(e,u)),m(arguments))},t.exports=F}});Yu(),Zu();var I_=class extends Xu{constructor(e,t){super(void 0,t),this.config=e}};Zu(),Zu();var L_=class extends Xu{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};$u(),td(),ff(),Vf(),ep(),ip(),fp(),yp();function R_(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new L_(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new L_(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function z_(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function B_(e,t){if(typeof t!=`string`||!t.includes(e))return!1;let n=t.trim().replace(/\0/g,``);return/^(--no)?-{1,2}[\dlsqvnobucj]+(\s|$)/.test(n)}function V_(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&z_(i)&&r.test(a))throw new L_(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var H_=[V_(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),V_(`core.sshCommand`,`allowUnsafeSshCommand`),V_(`core.gitProxy`,`allowUnsafeGitProxy`),V_(`core.hooksPath`,`allowUnsafeHooksPath`),V_(`diff.external`,`allowUnsafeDiffExternal`)];function U_(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new L_(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&B_(`u`,e))throw new L_(void 0,`unsafe`,`Use of clone with option -u is not permitted without enabling allowUnsafePack`);if(t===`push`&&/^\s*--exec\b/.test(e))throw new L_(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function W_({allowUnsafePack:e=!1,...t}={}){return{type:`spawn.args`,action(n,r){return n.forEach((i,a)=>{let o=a<n.length?n[a+1]:``;e||U_(i,r.method),H_.forEach(e=>e(t,i,o))}),n}}}Q();function G_(e){let t=vd(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}Q();var K_=(0,Iu.deferred)().promise;function q_({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,Iu.deferred)(),closeTimeout:(0,Iu.deferred)(),exit:(0,Iu.deferred)(),exitTimeout:(0,Iu.deferred)()},a=Promise.race([e===!1?K_:i.closeTimeout.promise,t===!1?K_:i.exitTimeout.promise]);return r(e,i.close,i.closeTimeout),r(t,i.exit,i.exitTimeout),{close(e){n=e,i.close.done()},exit(e){n=e,i.exit.done()},get exitCode(){return n},result:a}}function r(e,t,n){e!==!1&&(e===!0?t.promise:t.promise.then(()=>xd(e))).then(n.done)}return{type:`spawn.after`,async action(e,{spawned:t,close:r}){let i=n(),a=!0,o=()=>void(a=!1);t.stdout?.on(`data`,o),t.stderr?.on(`data`,o),t.on(`error`,o),t.on(`close`,e=>i.close(e)),t.on(`exit`,e=>i.exit(e));try{await i.result,a&&await xd(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}Q();var J_=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,Y_=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function X_(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function Z_(e,t){if(e.length<1||e.length>2)throw new L_(void 0,`binary`,J_);if(e.some(X_))if(t)console.warn(Y_);else throw new L_(void 0,`binary`,Y_);let[n,r]=e;return{binary:n,prefix:r}}function Q_(e,t=[`git`],n=!1){let r=Z_(md(t),n);e.on(`binary`,e=>{r=Z_(md(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}Zu();function $_(e){return!!(e.exitCode&&e.stdErr.length)}function ev(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function tv(e=!1,t=$_,n=ev){return(r,i)=>!e&&r||!t(i)?r:n(i)}function nv(e){return{type:`task.error`,action(t,n){let r=e(t.error,{stdErr:n.stdErr,stdOut:n.stdOut,exitCode:n.exitCode});return Buffer.isBuffer(r)?{error:new Xu(void 0,r.toString(`utf-8`))}:{error:r}}}}Q();var rv=class{constructor(){this.plugins=new Set,this.events=new Ki}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=dd(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return md(e).forEach(e=>e&&this.plugins.add(dd(t,e))),()=>{t.forEach(e=>this.plugins.delete(e))}}exec(e,t,n){let r=t,i=Object.freeze(Object.create(n));for(let t of this.plugins)t.type===e&&(r=t.action(r,i));return r}};Q();function iv(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?fd(e,t):e}},{type:`spawn.after`,action(n,r){r.commands.includes(t)&&r.spawned.stderr?.on(`data`,t=>{let n=/^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(t.toString(`utf8`));n&&e({method:r.method,stage:av(n[1]),progress:_d(n[2]),processed:_d(n[3]),total:_d(n[4])})})}}]}function av(e){return String(e.toLowerCase().split(` `,1))||`unknown`}Q();function ov(e){let t=bd(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function sv({block:e,stdErr:t=!0,stdOut:n=!0}){if(e>0)return{type:`spawn.after`,action(r,i){let a;function o(){a&&clearTimeout(a),a=setTimeout(c,e)}function s(){i.spawned.stdout?.off(`data`,o),i.spawned.stderr?.off(`data`,o),i.spawned.off(`exit`,s),i.spawned.off(`close`,s),a&&clearTimeout(a)}function c(){s(),i.kill(new L_(void 0,`timeout`,`block timeout reached`))}n&&i.spawned.stdout?.on(`data`,o),t&&i.spawned.stderr?.on(`data`,o),i.spawned.on(`exit`,s),i.spawned.on(`close`,s),o()}}}Yu();function cv(){return{type:`spawn.args`,action(e){let t=[],n;function r(e){(n||=[]).push(...e)}for(let n=0;n<e.length;n++){let i=e[n];if(Ku(i)){r(qu(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>Ku(e)&&qu(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}Q();var lv=F_();function uv(e,t){let n=new rv,r=Wd(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!ud(r.baseDir))throw new I_(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(G_(r.config)),n.add(W_(r.unsafe)),n.add(q_(r.completion)),r.abort&&n.add(R_(r.abort)),r.progress&&n.add(iv(r.progress)),r.timeout&&n.add(sv(r.timeout)),r.spawnOptions&&n.add(ov(r.spawnOptions)),n.add(cv()),n.add(nv(tv(!0))),r.errors&&n.add(nv(r.errors)),Q_(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new lv(r,n)}$u();var dv=uv;const fv=`.expect`,pv=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`,`.cts`,`.cjs`],mv=new Set([`node_modules`,`dist`,`build`,`.git`,`.next`,`.turbo`,`coverage`,`.nyc_output`,`.cache`,`.repos`,`.specs`,`__snapshots__`,`__fixtures__`]);var hv=class extends Ke(`GitError`)({_tag:Kr(`GitError`),operation:z,cause:Ft}){message=`Git error during "${this.operation}"`},gv=class extends Ke(`FindRepoRootError`)({_tag:Kr(`FindRepoRootError`),cause:Ft}){message=`Could not find git repository root`},_v=class extends tn()(`@supervisor/GitRepoRoot`){},vv=class e extends tn()(`@supervisor/Git`,{make:O(function*(){let e=yield*Qr,t=e=>O(function*(){let t=yield*_v;return yield*Ir({try:()=>dv(t).raw(e.args),catch:t=>new hv({operation:e.operation,cause:t})}).pipe(L(e.trim?ti:yr))}),n=e=>Ir({try:()=>dv(e).revparse([`--show-toplevel`]),catch:e=>new gv({cause:e})}).pipe(L(ti)),r=e=>t=>O(function*(){let r=yield*n(e);return yield*t.pipe(vt(_v,r))}),i=t({args:[`symbolic-ref`,`refs/remotes/origin/HEAD`],operation:`getting main branch`,trim:!0}).pipe(L(e=>e.replace(`refs/remotes/origin/`,``)),V(`GitError`,()=>t({args:[`revparse`,`--verify`,`origin/main`],operation:`getting main branch (origin/main)`,trim:!0}).pipe(nn(`main`))),V(`GitError`,()=>t({args:[`rev-parse`,`--verify`,`main`],operation:`getting main branch (main)`,trim:!0}).pipe(nn(`main`))),V(`GitError`,()=>B(`main`))),a=t({args:[`rev-parse`,`--abbrev-ref`,`HEAD`],operation:`getting current branch`,trim:!0}).pipe(V(`GitError`,()=>B(`HEAD`))),o=t({args:[`rev-parse`,`--is-inside-work-tree`],operation:`checking if inside work tree`,trim:!0}).pipe(L(e=>e===`true`),V(`GitError`,()=>B(!1))),s=e=>{let[t,n,r]=e.split(` `);return new zo({relativePath:r??``,added:Number.parseInt(t??`0`,10)||0,removed:Number.parseInt(n??`0`,10)||0})},c=R(`Git.getFileStats`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`,`--numstat`],operation:`getting working tree file stats`}).pipe(L(Vr(`
|
|
23
|
+
`)),L(st(ti)),L(Jr(Ut)),L(st(s)),V(`GitError`,()=>B([]))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`,`--numstat`],operation:`getting file stats`}).pipe(L(Vr(`
|
|
24
|
+
`)),L(st(ti)),L(Jr(Ut)),L(st(s)),V(`GitError`,()=>B([])))}),l=e=>e===`A`?`A`:e===`D`?`D`:e===`R`?`R`:e===`C`?`C`:e===`?`?`?`:`M`,u=R(`Git.getChangedFiles`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`status`,`--porcelain`],operation:`getting working tree changes`}).pipe(L(Vr(`
|
|
25
|
+
`)),L(Jr(Ut)),L(st(e=>{let t=e.at(0)??`M`;return{path:e.slice(3).trim(),status:l(t)}})),V(`GitError`,()=>B([]))):yield*t({args:[`diff`,`--name-status`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`],operation:`getting changed files`,trim:!0}).pipe(L(Vr(`
|
|
26
|
+
`)),L(st(ti)),L(Jr(Ut)),L(st(e=>{let t=e.split(` `),n=(t[0]??`M`).at(0)??`M`;return{path:(n===`R`||n===`C`?t[2]:t[1])??``,status:l(n)}})),V(`GitError`,()=>B([])))}),d=R(`Git.getDiffPreview`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`],operation:`getting diff preview`,trim:!0}).pipe(V(`GitError`,()=>B(``))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`],operation:`getting diff preview`,trim:!0}).pipe(V(`GitError`,()=>B(``)))}),f=R(`Git.getRecentCommits`)(function*(e){return yield*t({args:[`log`,`--format=%H %h %s`,e],operation:`getting recent commits`,trim:!0}).pipe(L(Vr(`
|
|
27
|
+
`)),L(st(ti)),L(Jr(Ut)),L(st(e=>{let[t,n,...r]=e.split(` `);return{hash:t??``,shortHash:n??``,subject:r.join(` `)}})),V(`GitError`,()=>B([])))}),p=R(`Git.getCommitSummary`)(function*(e){return yield*t({args:[`log`,`-1`,`--format=%H %h %s`,e],operation:`getting commit summary`,trim:!0}).pipe(L(e=>{let[t,n,...r]=e.split(` `);if(!(!t||!n))return{hash:t,shortHash:n,subject:r.join(` `)}}),V(`GitError`,()=>B(void 0)))}),m=R(`Git.computeFingerprint`)(function*(){let e=yield*t({args:[`rev-parse`,`HEAD`],operation:`getting HEAD for fingerprint`,trim:!0}).pipe(V(`GitError`,()=>B(``)));if(!e)return;let n=yield*t({args:[`diff`],operation:`getting unstaged diff for fingerprint`}).pipe(V(`GitError`,()=>B(``))),r=yield*t({args:[`diff`,`--cached`],operation:`getting staged diff for fingerprint`}).pipe(V(`GitError`,()=>B(``)));return Vi.createHash(`sha256`).update(e).update(`\0`).update(n).update(`\0`).update(r).digest(`hex`)}),h=R(`ensureStateDir`)(function*(t){let n=Di.join(t,fv);yield*e.makeDirectory(n,{recursive:!0}).pipe(V(`PlatformError`,()=>gn));let r=Di.join(n,`.gitignore`);return(yield*e.exists(r).pipe(V(`PlatformError`,()=>B(!1))))||(yield*e.writeFileString(r,`*
|
|
28
|
+
`).pipe(V(`PlatformError`,()=>gn))),n}),g=O(function*(){let e=yield*h(yield*_v);return Di.join(e,`last-tested`)}),_=R(`Git.loadSavedFingerprint`)(function*(){let t=yield*g;return yield*e.readFileString(t).pipe(L(ti),V(`PlatformError`,()=>B(void 0)))}),v=R(`Git.saveTestedFingerprint`)(function*(){let t=yield*m();if(!t)return;let n=yield*g;yield*e.writeFileString(n,t)});return{withRepoRoot:r,getMainBranch:i,getCurrentBranch:a,isInsideWorkTree:o,getFileStats:c,getChangedFiles:u,getDiffPreview:d,getRecentCommits:f,getCommitSummary:p,getState:R(`Git.getState`)(function*(){if(!(yield*o))return new Bo({isGitRepo:!1,currentBranch:`HEAD`,mainBranch:void 0,isOnMain:!1,hasChangesFromMain:!1,hasUnstagedChanges:!1,hasBranchCommits:!1,branchCommitCount:0,fileStats:[],workingTreeFileStats:[],fingerprint:void 0,savedFingerprint:void 0});let[e,t,n,r]=yield*xr([a,i,m(),_()],{concurrency:`unbounded`}),s=e===t,[l,u,d]=yield*xr([c(Uo.makeUnsafe({_tag:`Changes`,mainBranch:t})),c(Uo.makeUnsafe({_tag:`WorkingTree`})),f(`${t}..HEAD`)],{concurrency:`unbounded`});return new Bo({isGitRepo:!0,currentBranch:e,mainBranch:t,isOnMain:s,hasChangesFromMain:l.length>0,hasUnstagedChanges:u.length>0,hasBranchCommits:d.length>0,branchCommitCount:d.length,fileStats:l,workingTreeFileStats:u,fingerprint:n,savedFingerprint:r})}),computeFingerprint:m,saveTestedFingerprint:v}})}){static layer=b(this)(this.make).pipe(w(Ii.layer));static withRepoRoot=t=>{let n=b(_v)(Ir({try:()=>dv(t).revparse([`--show-toplevel`]),catch:e=>new gv({cause:e})}).pipe(L(e=>e.trim())));return te(e.layer.pipe(w(n)),n)}},yv=class extends Ke(`@supervisor/ExecutionError`)({_tag:Kr(`ExecutionError`),reason:$n([su,uu,cu,lu])}){displayName=this.reason.displayName??`Browser testing failed`;message=this.reason.message},bv=class extends tn()(`@supervisor/Executor`,{make:O(function*(){let e=yield*hu,t=yield*vv,n=R(`Executor.gatherContext`)(function*(e){let n=yield*t.getCurrentBranch,r=yield*t.getMainBranch,i=yield*t.getChangedFiles(e),a=yield*t.getDiffPreview(e),o=e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:e._tag===`Commit`?`-1 ${e.hash}`:`HEAD~5..HEAD`,s=yield*t.getRecentCommits(o);return{currentBranch:n,mainBranch:r,changedFiles:i.slice(0,12),recentCommits:s.slice(0,5),diffPreview:a}});return{execute:R(`Executor.execute`)(function*(t){let r=yield*n(t.changesFor),i=Cu({userInstruction:t.instruction,scope:t.changesFor._tag,currentBranch:r.currentBranch,mainBranch:r.mainBranch,changedFiles:r.changedFiles,recentCommits:r.recentCommits,diffPreview:r.diffPreview,baseUrl:t.baseUrl,isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,savedFlow:t.savedFlow,learnings:t.learnings,testCoverage:t.testCoverage}),a=Ho.makeUnsafe(crypto.randomUUID()),o=Di.join(process.cwd(),fv,`replays`,`${a}.ndjson`),s=new es({id:a,changesFor:t.changesFor,currentBranch:r.currentBranch,diffPreview:r.diffPreview,fileStats:[],instruction:t.instruction,baseUrl:t.baseUrl?ii(t.baseUrl):Qe(),isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,testCoverage:t.testCoverage?ii(t.testCoverage):Qe(),title:t.instruction,rationale:`Direct execution`,steps:[]}),c=new Cs({...s,events:[new ts({plan:s})]}),l=[{name:`EXPECT_REPLAY_OUTPUT_PATH`,value:o}];t.liveViewUrl&&l.push({name:en,value:t.liveViewUrl});let u=new Ds({cwd:process.cwd(),sessionId:Qe(),prompt:i,systemPrompt:Qe(),mcpEnv:l});return e.stream(u).pipe(zn(()=>c,(e,t)=>{let n=e.addEvent(t);return[n,[n]]}),Pn(e=>new yv({reason:e})))},bt)}})}){static layer=b(this)(this.make).pipe(w(Ii.layer))},xv=class extends tn()(`@supervisor/Reporter`,{make:O(function*(){return{report:R(`Reporter.report`)(function*(e){let t=e.events.filter(e=>e._tag===`StepFailed`),n=e.events.filter(e=>e._tag===`StepCompleted`),r=e.events.find(e=>e._tag===`RunFinished`),i=r?r.summary:t.length>0?`${t.length} step(s) failed, ${n.length} passed`:`${n.length} step(s) completed`,a=e.events.filter(e=>e._tag===`ToolResult`&&e.toolName.endsWith(`__screenshot`)&&!e.isError).map(e=>e._tag===`ToolResult`?e.result:``).filter(Boolean);return new ws({...e,summary:i,screenshotPaths:a,pullRequest:Qe(),testCoverageReport:e.testCoverage})})}})}){static layer=b(this)(this.make)};const Sv=e=>{let t=[`format_version: ${e.formatVersion}`,`title: ${JSON.stringify(e.title)}`,`description: ${JSON.stringify(e.description)}`,`slug: ${JSON.stringify(e.slug)}`,`saved_target_scope: ${JSON.stringify(e.savedTargetScope)}`,`saved_target_display_name: ${JSON.stringify(e.savedTargetDisplayName)}`];return e.selectedCommit!==void 0&&t.push(`selected_commit: ${JSON.stringify(e.selectedCommit)}`),t.push(`flow: ${JSON.stringify(e.flow)}`),t.push(`environment: ${JSON.stringify(e.environment)}`),t.join(`
|
|
29
|
+
`)},Cv=e=>`---\n${Sv(e)}\n---\n`,wv=e=>e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e,Tv=e=>It(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.instruction==`string`&&typeof e.expectedOutcome==`string`,Ev=e=>It(e)?{title:typeof e.title==`string`?e.title:``,userInstruction:typeof e.userInstruction==`string`?e.userInstruction:``,steps:Array.isArray(e.steps)?e.steps.filter(Tv):[]}:{title:``,userInstruction:``,steps:[]},Dv=e=>It(e)?{baseUrl:typeof e.baseUrl==`string`?e.baseUrl:``,cookies:typeof e.cookies==`boolean`?e.cookies:!1}:{baseUrl:``,cookies:!1},Ov=e=>{let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)throw Error(`Invalid saved flow file: no frontmatter found`);let n=t[1],r=new Map;for(let e of n.split(`
|
|
30
|
+
`)){if(e===`selected_commit: undefined`)continue;let t=e.indexOf(`: `);if(t===-1)continue;let n=e.slice(0,t),i=e.slice(t+2);r.set(n,i)}let i={formatVersion:Number(r.get(`format_version`)),title:wv(r.get(`title`)??``),description:wv(r.get(`description`)??``),slug:wv(r.get(`slug`)??``),savedTargetScope:wv(r.get(`saved_target_scope`)??``),savedTargetDisplayName:wv(r.get(`saved_target_display_name`)??``),flow:Ev(JSON.parse(r.get(`flow`)??`{}`)),environment:Dv(JSON.parse(r.get(`environment`)??`{}`))},a=r.get(`selected_commit`);return a!==void 0&&(i.selectedCommit=wv(a)),i},kv=R(`ensureStateDir`)(function*(e,t){let n=Di.join(t,fv);yield*e.makeDirectory(n,{recursive:!0}).pipe(V(`PlatformError`,()=>gn));let r=Di.join(n,`.gitignore`);return(yield*e.exists(r).pipe(V(`PlatformError`,()=>B(!1))))||(yield*e.writeFileString(r,`*
|
|
31
|
+
`).pipe(V(`PlatformError`,()=>gn))),n}),Av=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),jv=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:Av(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:Wo(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=Fn(e.summary,()=>``);return{id:e.id,title:e.title,instruction:e.instruction===e.title?t||e.title:e.instruction,expectedOutcome:e.expectedOutcome||t}})},environment:{baseUrl:Fn(e.baseUrl,()=>``),cookies:e.requiresCookies}});var Mv=class extends tn()(`@supervisor/FlowStorage`,{make:O(function*(){let e=yield*Qr,t=O(function*(){let t=yield*kv(e,yield*_v);return Di.join(t,`flows`)});return{save:R(`FlowStorage.save`)(function*(n){let r=jv(n),i=yield*t,a=Di.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(V(`PlatformError`,()=>gn)),yield*e.writeFileString(a,Cv(r)),yield*ke(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:R(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(V(`PlatformError`,()=>B(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(V(`PlatformError`,()=>B([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(Di.join(n,t)).pipe(V(`PlatformError`,()=>B(``)));if(!r)continue;let a=yield*cn({try:()=>Ov(r),catch:()=>({_tag:`FlowParseError`})}).pipe(V(`FlowParseError`,()=>B(void 0)));a&&i.push(a)}return yield*l(`Flows listed`,{count:i.length}),i})}})}){static layer=b(this)(this.make).pipe(w(Ii.layer))};const Nv=(e,t)=>{try{return Bi(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var Pv=class extends Ke(`GitHubCommandError`)({_tag:Kr(`GitHubCommandError`),cause:z}){message=`GitHub CLI command failed: ${this.cause}`},Fv=class extends tn()(`@supervisor/GitHub`,{make:O(function*(){let e=yield*Nr,t=yield*Qr,n=R(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(Wn(`gh`,n,{cwd:t})).pipe(sr(15e3),dr({PlatformError:e=>bn(new Pv({cause:e.message})),TimeoutError:()=>bn(new Pv({cause:`command timed out`}))}),L(e=>e.trim()))}),r=R(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,Yn(t).pipe(Cn({_tag:`Branch`},e=>e.branchName),an),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*Wt(Zr(I(gs)))(r).pipe(L(nt),V(`SchemaError`,()=>B(Qe())))}),i=Zr(I(Go));return{findPullRequest:r,listPullRequests:R(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(V(`GitHubCommandError`,()=>B(`[]`)));return(yield*Wt(i)(t).pipe(V(`SchemaError`,Tn))).map(e=>new qo({name:e.headRefName,author:e.author.login,prNumber:e.number,prStatus:e.state===`OPEN`?`open`:e.state===`MERGED`||e.state===`CLOSED`?`merged`:null,updatedAt:e.updatedAt}))}),addComment:R(`GitHub.addComment`)(function*(e,r,i){yield*Dt(O(function*(){let a=ki(yield*t.makeTempDirectoryScoped({prefix:`expect-comment-`}),`pull-request-comment.md`);yield*t.writeFileString(a,i),yield*n(e,[`pr`,`comment`,String(r.number),`--body-file`,a])}))})}})}){static layer=b(this)(this.make).pipe(w(Ii.layer))};const Iv=e=>Di.join(qi.homedir(),fv,`${e}.json`),Lv=new Map,Rv={getItem:async e=>{try{let t=await Xi.readFile(Iv(e),`utf-8`);return Lv.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Lv.get(e)===t)return;Lv.set(e,t);let n=Iv(e);await Xi.mkdir(Di.dirname(n),{recursive:!0}),await Xi.writeFile(n,t,`utf-8`)},removeItem:async e=>{Lv.delete(e);try{await Xi.unlink(Iv(e))}catch{}}},zv=e=>Di.join(process.cwd(),fv,`${e}.json`),Bv=new Map,Vv={getItem:async e=>{try{let t=await Xi.readFile(zv(e),`utf-8`);return Bv.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Bv.get(e)===t)return;Bv.set(e,t);let n=zv(e);await Xi.mkdir(Di.dirname(n),{recursive:!0}),await Xi.writeFile(n,t,`utf-8`)},removeItem:async e=>{Bv.delete(e);try{await Xi.unlink(zv(e))}catch{}}};var Hv=n(((e,t)=>{t.exports={name:`@oxc-resolver/binding-darwin-arm64`,version:`11.19.1`,cpu:[`arm64`],main:`resolver.darwin-arm64.node`,files:[`resolver.darwin-arm64.node`],description:`Oxc Resolver Node API`,homepage:`https://oxc.rs`,license:`MIT`,repository:{type:`git`,url:`git+https://github.com/oxc-project/oxc-resolver.git`},publishConfig:{registry:`https://registry.npmjs.org/`,access:`public`},os:[`darwin`]}})),Uv=n(((t,n)=>{let r=e(`node:fs`),i=e(`node:child_process`),a=JSON.parse(r.readFileSync(e.resolve(`oxc-resolver/package.json`),`utf-8`)).version,o=`/tmp/oxc-resolver-${a}`,s=`${o}/node_modules/@oxc-resolver/binding-wasm32-wasi/resolver.wasi.cjs`;if(!r.existsSync(s)){r.rmSync(o,{recursive:!0,force:!0}),r.mkdirSync(o,{recursive:!0});let e=`@oxc-resolver/binding-wasm32-wasi@${a}`;console.log(`[oxc-resolver] Downloading ${e} on WebContainer...`),i.execFileSync(`pnpm`,[`i`,e],{cwd:o,stdio:`inherit`})}n.exports=e(s)})),Wv=n(((t,n)=>{let{readFileSync:r}=e(`node:fs`),i=null,a=[],o=()=>{let e=!1;return process.platform===`linux`&&(e=c(),e===null&&(e=l()),e===null&&(e=u())),e},s=e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`),c=()=>{try{return r(`/usr/bin/ldd`,`utf-8`).includes(`musl`)}catch{return null}},l=()=>{let e=null;return typeof process.report?.getReport==`function`&&(process.report.excludeNetwork=!0,e=process.report.getReport()),e?e.header&&e.header.glibcVersionRuntime?!1:!!(Array.isArray(e.sharedObjects)&&e.sharedObjects.some(s)):null},u=()=>{try{return e(`child_process`).execSync(`ldd --version`,{encoding:`utf8`}).includes(`musl`)}catch{return!1}};function d(){if(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)try{return e(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)}catch(e){a.push(e)}else if(process.platform===`android`)if(process.arch===`arm64`){try{return e(`./resolver.android-arm64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-android-arm64`),n=e(`@oxc-resolver/binding-android-arm64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm`){try{return e(`./resolver.android-arm-eabi.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-android-arm-eabi`),n=e(`@oxc-resolver/binding-android-arm-eabi/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on Android ${process.arch}`));else if(process.platform===`win32`)if(process.arch===`x64`)if(process.config?.variables?.shlib_suffix===`dll.a`||process.config?.variables?.node_target_type===`shared_library`){try{return e(`./resolver.win32-x64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-win32-x64-gnu`),n=e(`@oxc-resolver/binding-win32-x64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.win32-x64-msvc.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-win32-x64-msvc`),n=e(`@oxc-resolver/binding-win32-x64-msvc/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`ia32`){try{return e(`./resolver.win32-ia32-msvc.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-win32-ia32-msvc`),n=e(`@oxc-resolver/binding-win32-ia32-msvc/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return e(`./resolver.win32-arm64-msvc.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-win32-arm64-msvc`),n=e(`@oxc-resolver/binding-win32-arm64-msvc/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on Windows: ${process.arch}`));else if(process.platform===`darwin`){try{return e(`./resolver.darwin-universal.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-darwin-universal`),n=e(`@oxc-resolver/binding-darwin-universal/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}if(process.arch===`x64`){try{return e(`./resolver.darwin-x64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-darwin-x64`),n=e(`@oxc-resolver/binding-darwin-x64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return e(`./resolver.darwin-arm64.node`)}catch(e){a.push(e)}try{let t=e(`./assets/resolver.darwin-arm64-DG19oi97.node`),n=Hv().version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on macOS: ${process.arch}`))}else if(process.platform===`freebsd`)if(process.arch===`x64`){try{return e(`./resolver.freebsd-x64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-freebsd-x64`),n=e(`@oxc-resolver/binding-freebsd-x64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return e(`./resolver.freebsd-arm64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-freebsd-arm64`),n=e(`@oxc-resolver/binding-freebsd-arm64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on FreeBSD: ${process.arch}`));else if(process.platform===`linux`)if(process.arch===`x64`)if(o()){try{return e(`./resolver.linux-x64-musl.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-x64-musl`),n=e(`@oxc-resolver/binding-linux-x64-musl/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.linux-x64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-x64-gnu`),n=e(`@oxc-resolver/binding-linux-x64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm64`)if(o()){try{return e(`./resolver.linux-arm64-musl.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-arm64-musl`),n=e(`@oxc-resolver/binding-linux-arm64-musl/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.linux-arm64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-arm64-gnu`),n=e(`@oxc-resolver/binding-linux-arm64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm`)if(o()){try{return e(`./resolver.linux-arm-musleabihf.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-arm-musleabihf`),n=e(`@oxc-resolver/binding-linux-arm-musleabihf/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.linux-arm-gnueabihf.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-arm-gnueabihf`),n=e(`@oxc-resolver/binding-linux-arm-gnueabihf/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`loong64`)if(o()){try{return e(`./resolver.linux-loong64-musl.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-loong64-musl`),n=e(`@oxc-resolver/binding-linux-loong64-musl/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.linux-loong64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-loong64-gnu`),n=e(`@oxc-resolver/binding-linux-loong64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`riscv64`)if(o()){try{return e(`./resolver.linux-riscv64-musl.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-riscv64-musl`),n=e(`@oxc-resolver/binding-linux-riscv64-musl/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else{try{return e(`./resolver.linux-riscv64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-riscv64-gnu`),n=e(`@oxc-resolver/binding-linux-riscv64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`ppc64`){try{return e(`./resolver.linux-ppc64-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-ppc64-gnu`),n=e(`@oxc-resolver/binding-linux-ppc64-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`s390x`){try{return e(`./resolver.linux-s390x-gnu.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-linux-s390x-gnu`),n=e(`@oxc-resolver/binding-linux-s390x-gnu/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on Linux: ${process.arch}`));else if(process.platform===`openharmony`)if(process.arch===`arm64`){try{return e(`./resolver.openharmony-arm64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-openharmony-arm64`),n=e(`@oxc-resolver/binding-openharmony-arm64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`x64`){try{return e(`./resolver.openharmony-x64.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-openharmony-x64`),n=e(`@oxc-resolver/binding-openharmony-x64/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else if(process.arch===`arm`){try{return e(`./resolver.openharmony-arm.node`)}catch(e){a.push(e)}try{let t=e(`@oxc-resolver/binding-openharmony-arm`),n=e(`@oxc-resolver/binding-openharmony-arm/package.json`).version;if(n!==`11.19.1`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 11.19.1 but got ${n}. You can reinstall dependencies to fix this issue.`);return t}catch(e){a.push(e)}}else a.push(Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));else a.push(Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))}if(i=d(),!i||process.env.NAPI_RS_FORCE_WASI){let t=null,n=null;try{t=e(`./resolver.wasi.cjs`),i=t}catch(e){process.env.NAPI_RS_FORCE_WASI&&(n=e)}if(!i||process.env.NAPI_RS_FORCE_WASI)try{t=e(`@oxc-resolver/binding-wasm32-wasi`),i=t}catch(e){process.env.NAPI_RS_FORCE_WASI&&(n?n.cause=e:n=e,a.push(e))}if(process.env.NAPI_RS_FORCE_WASI===`error`&&!t){let e=Error(`WASI binding not found and NAPI_RS_FORCE_WASI is set to error`);throw e.cause=n,e}}if(!i&&globalThis.process?.versions?.webcontainer)try{i=Uv()}catch(e){a.push(e)}if(!i)throw a.length>0?Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.",{cause:a.reduce((e,t)=>(t.cause=e,t))}):Error(`Failed to load native binding`);n.exports=i,n.exports.ResolverFactory=i.ResolverFactory,n.exports.EnforceExtension=i.EnforceExtension,n.exports.ModuleType=i.ModuleType,n.exports.sync=i.sync,process.versions.pnp&&(process.env.OXC_RESOLVER_YARN_PNP=`1`)}))();const Gv=[/from\s+["']([^"']+)["']/g,/import\s*\(\s*["']([^"']+)["']\s*\)/g,/require\s*\(\s*["']([^"']+)["']\s*\)/g],Kv=/\.(?:test|spec|e2e)\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,qv=/(?:^|[/\\])(?:__tests?__|tests?)[/\\]/,Jv=/\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,Yv=e=>{let t=Di.extname(e).toLowerCase();return pv.includes(t)},Xv=e=>e.split(/[/\\]/).some(e=>mv.has(e)),Zv=e=>!!(Kv.test(e)||qv.test(e)&&Jv.test(e)),Qv=e=>{let t=[];for(let n of Gv){let r=new RegExp(n.source,n.flags),i;for(;(i=r.exec(e))!==null;){let e=i[1];e&&t.push(e)}}return t},$v=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.pop();if(n.has(t))continue;n.add(t);let i=e.get(t);if(i)for(let e of i)n.has(e)||r.push(e)}return n.delete(t),n},ey=e=>Ir({try:()=>new Promise(t=>{zi(`git`,[`ls-files`,`--cached`,`--others`,`--exclude-standard`],{cwd:e,maxBuffer:10*1024*1024},(e,n)=>{if(e){t([]);return}t(n.split(`
|
|
32
|
+
`).map(e=>e.trim()).filter(e=>e.length>0))})}),catch:()=>[]}),ty=e=>{try{return new Wv.ResolverFactory({tsconfig:{configFile:Di.join(e,`tsconfig.json`),references:`auto`},extensions:[...pv],mainFields:[`module`,`main`],conditionNames:[`import`,`require`,`default`]})}catch{return}},ny=(e,t,n)=>{try{return e.sync(t,n).path??void 0}catch{return}},ry=(e,t,n)=>O(function*(){let r=t.filter(e=>Yv(e)&&!Xv(e)),i=ty(e);if(!i)return new Map;let a=new Map;return yield*rt(r,t=>O(function*(){let r=Di.join(e,t),o=yield*n.readFileString(r).pipe(V(`PlatformError`,()=>B(``)));if(!o)return;let s=Qv(o),c=new Set;for(let t of s)if(t.startsWith(`.`)||t.startsWith(`@`)||t.startsWith(`~`)){let n=ny(i,Di.dirname(r),t);if(n){let t=Di.relative(e,n);Xv(t)||c.add(t)}}c.size>0&&a.set(t,c)}),{concurrency:50}),a}),iy=e=>e.filter(e=>!Xv(e)&&Zv(e)).slice(0,200);var ay=class extends tn()(`@supervisor/TestCoverage`,{make:O(function*(){let e=yield*Qr;return{analyze:R(`TestCoverage.analyze`)(function*(t){yield*Jt({changedFileCount:t.length});let n=yield*_v,r=yield*ey(n),i=iy(r),a=yield*ry(n,r,e),o=new Map;for(let e of i){let t=$v(a,e);t.add(e);for(let n of t){let t=o.get(n)??[];t.push(e),o.set(n,t)}}let s=t.filter(e=>Jv.test(e.path)&&!Zv(e.path)&&e.status!==`D`),c=s.map(e=>{let t=o.get(e.path)??[];return{path:e.path,testFiles:t,covered:t.length>0}}),l=c.filter(e=>e.covered).length,u=s.length,d=u>0?Math.round(l/u*100):100;return yield*ke(`Test coverage analyzed`,{coveredCount:l,totalCount:u,percent:d,testFileCount:i.length,graphEdgeCount:a.size}),{entries:c,coveredCount:l,totalCount:u,percent:d}})}})}){static layer=b(this)(this.make).pipe(w(Ii.layer))};const oy=e=>e.pipe(m(Fv.layer)),sy=async e=>{let t=[];if(e.hasUntestedChanges&&t.push(_s.makeUnsafe({_tag:`WorkingTree`})),e.mainBranch){let n=process.cwd(),r=await N(O(function*(){return yield*(yield*vv).getRecentCommits(`${e.mainBranch}..HEAD`)}).pipe(m(vv.withRepoRoot(n))));for(let e of r)t.push(_s.makeUnsafe({_tag:`Commit`,hash:e.hash,shortHash:e.shortHash,subject:e.subject}))}return t},cy=e=>N(oy(Fv.use(t=>t.listPullRequests(e)))),ly=async e=>{let t=await cy(process.cwd()),n=t.filter(e=>e.prNumber!==null&&e.prStatus===`open`).map(e=>_s.makeUnsafe({_tag:`PullRequest`,branch:e})),r=t.filter(e=>e.prNumber!==null&&e.prStatus===`merged`).slice(0,5).map(e=>_s.makeUnsafe({_tag:`PullRequest`,branch:e})),i=t.filter(t=>t.name!==e.currentBranch&&t.prNumber===null).map(e=>_s.makeUnsafe({_tag:`Branch`,branch:e}));return[...n,...r,...i]},uy=(e,t)=>e._tag===`WorkingTree`&&t&&!t.isOnMain?t.currentBranch:bs(e),dy=(e,t)=>{if(e._tag===`WorkingTree`&&t){let e=[];if(t.fileStats.length>0){let n=t.fileStats.reduce((e,t)=>e+t.added,0),r=t.fileStats.reduce((e,t)=>e+t.removed,0),i=t.fileStats.length,a=[];n>0&&a.push(`+${n}`),r>0&&a.push(`-${r}`),a.length>0?e.push(`${a.join(` `)} in ${i} file${i===1?``:`s`}`):e.push(`${i} file${i===1?``:`s`}`)}if(t.branchCommitCount>0&&e.push(`${t.branchCommitCount} commit${t.branchCommitCount===1?``:`s`}`),e.length>0)return e.join(`, `)}return xs(e)},fy=(e,t)=>e._tag===`WorkingTree`?uy(e,t):Ss(e),py=(e,t,n)=>{if(!t)return[...e];let r=t.toLowerCase();return e.filter(e=>(e._tag===`WorkingTree`?`local changes ${n?.currentBranch??``}`:ys(e)).toLowerCase().includes(r))},my=()=>_i({queryKey:[`remote-branches`],queryFn:()=>cy(process.cwd())}),hy=e=>{let t=vi(10);if(t[0]!==`19aae044389a98cd743b540aea8d28df87ba20582cdcc28d3b06005d495ed4de`){for(let e=0;e<10;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`19aae044389a98cd743b540aea8d28df87ba20582cdcc28d3b06005d495ed4de`}let{message:n}=e,r=mo(),i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=K($i,{type:`dots`}),t[1]=i):i=t[1];let a;t[2]===r.SELECTION?a=t[3]:(a=K(W,{color:r.SELECTION,children:i}),t[2]=r.SELECTION,t[3]=a);let o;t[4]===n?o=t[5]:(o=n?q(W,{children:[` `,n]}):null,t[4]=n,t[5]=o);let s;return t[6]!==r.DIM||t[7]!==a||t[8]!==o?(s=q(W,{color:r.DIM,children:[a,o]}),t[6]=r.DIM,t[7]=a,t[8]=o,t[9]=s):s=t[9],s},gy=(e,t)=>{let n=Math.max(0,t-ta(e));return e+` `.repeat(n)},_y=({itemCount:e,visibleCount:t,initialIndex:n})=>{let[r,i]=G(n??0),a=wi(e);return a.current!==e&&(a.current=e,i(t=>Math.min(t,Math.max(0,e-1)))),{highlightedIndex:r,setHighlightedIndex:i,scrollOffset:Ci(()=>{if(e<=t)return 0;let n=Math.floor(t/2),i=e-t;return Math.min(i,Math.max(0,r-n))},[e,t,r]),handleNavigation:bi((t,n)=>n.downArrow||t===`j`||n.ctrl&&t===`n`?(i(t=>Math.min(e-1,t+1)),!0):n.upArrow||t===`k`||n.ctrl&&t===`p`?(i(e=>Math.max(0,e-1)),!0):!1,[e])}},vy=/(?:https?:\/\/|localhost[:/]|[\w-]+\.[\w-]+\.[\w]+|[\w-]+\.(com|org|net|io|dev|app|co|me|ai))\S*/i,yy=e=>vy.test(e),by=Xr(),xy=e=>yy(e.instruction)?by.Testing(e):by.PortPicker(e),Sy=na(e=>({screen:by.Main(),previousScreen:by.Main(),navigateTo:t=>e(e=>({screen:t,previousScreen:e.screen})),setScreen:t=>e({screen:t})})),Cy=new mi({defaultOptions:{queries:{staleTime:1/0,retry:!1}}}),wy=e=>{let t=vi(18);if(t[0]!==`ebd3be31f5201c04dd238bf1bd9d32bf671ecbefa6ad88d45037fbe949e8bb0c`){for(let e=0;e<18;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`ebd3be31f5201c04dd238bf1bd9d32bf671ecbefa6ad88d45037fbe949e8bb0c`}let{title:n,subtitle:r,showDivider:i}=e,a=i===void 0?!0:i,[o]=uo(),s,c,l;t[1]!==r||t[2]!==n?(l=n.toUpperCase(),s=r?` │ ${r}`:``,c=ta(l),t[1]=r,t[2]=n,t[3]=s,t[4]=c,t[5]=l):(s=t[3],c=t[4],l=t[5]);let u=c+ta(s),d=a?Math.max(0,o-u-3):0,f;t[6]===l?f=t[7]:(f=K(W,{bold:!0,color:fo.text,children:l}),t[6]=l,t[7]=f);let p;t[8]!==r||t[9]!==s?(p=r?K(W,{color:fo.textMuted,children:s}):null,t[8]=r,t[9]=s,t[10]=p):p=t[10];let m;t[11]!==d||t[12]!==a?(m=a?q(W,{color:fo.border,children:[` `,`─`.repeat(d)]}):null,t[11]=d,t[12]=a,t[13]=m):m=t[13];let h;return t[14]!==f||t[15]!==p||t[16]!==m?(h=q(W,{children:[f,p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h},Ty=()=>{let e=vi(39);if(e[0]!==`155bac1331928275f0977c44c5021af2a99f257236d72aa818a512bae62664a8`){for(let t=0;t<39;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`155bac1331928275f0977c44c5021af2a99f257236d72aa818a512bae62664a8`}let[t]=uo(),n=Sy(Ey),r=mo(),[i,a]=G(null),[o,s]=G(``),[c,l]=G(`recent`),[u,d]=G(!1),[f,p]=G(void 0),{data:m,isLoading:h}=my(),g=m===void 0?[]:m,_=qo.filterBranches(g,c,o),{highlightedIndex:v,setHighlightedIndex:y,scrollOffset:b,handleNavigation:x}=_y({itemCount:_.length,visibleCount:15}),ee=t-2-32-16-2,S=_.slice(b,b+15),C;e[1]===y?C=e[2]:(C=e=>{s(so(e)),y(0)},e[1]=y,e[2]=C);let w=C,T;e[3]===n?T=e[4]:(T=e=>{Nv(process.cwd(),e)?(p(void 0),Cy.invalidateQueries({queryKey:[`git-state`]}),n(by.Main())):p(`Could not checkout "${e}". You may have uncommitted changes or the branch may not exist locally.`)},e[3]=n,e[4]=T);let E=T,D;e[5]!==c||e[6]!==y?(D=e=>{l(Ko[(Ko.indexOf(c)+e+Ko.length)%Ko.length]),y(0)},e[5]=c,e[6]=y,e[7]=D):D=e[7];let O=D;fi((e,t)=>{if(u){t.escape&&d(!1);return}if(!x(e,t)){if(t.rightArrow&&O(1),t.leftArrow&&O(-1),t.return){let e=_[v];e&&(p(void 0),E(e.name))}e===`/`&&d(!0)}});let te;e[8]!==i||e[9]!==E?(te=(e,t)=>{i&&(e.toLowerCase()===`y`&&(p(void 0),E(i.name),a(null)),(e.toLowerCase()===`n`||t.escape)&&a(null))},e[8]=i,e[9]=E,e[10]=te):te=e[10];let ne=i!==null,k;e[11]===ne?k=e[12]:(k={isActive:ne},e[11]=ne,e[12]=k),fi(te,k);let A=U,j=`${_.length} branches`,re;e[13]===j?re=e[14]:(re=K(U,{paddingX:1,children:K(wy,{title:`Select a PR or branch to test`,subtitle:j})}),e[13]=j,e[14]=re);let M;e[15]!==r||e[16]!==c||e[17]!==y?(M=Ko.map((e,t)=>{let n=e===c,i=t<Ko.length-1?` · `:``,a={recent:r.CYAN,all:r.TEXT,open:r.GREEN,draft:r.DIM,merged:r.PURPLE,"no-pr":r.YELLOW};return q(U,{children:[K(_o,{fullWidth:!1,onClick:()=>{l(e),y(0)},children:K(W,{color:n?a[e]:r.DIM,children:n?`[${e}]`:e})}),K(W,{color:r.DIM,children:i})]},e)}),e[15]=r,e[16]=c,e[17]=y,e[18]=M):M=e[18];let ie;e[19]===M?ie=e[20]:(ie=K(U,{marginTop:1,paddingX:1,children:M}),e[19]=M,e[20]=ie);let ae=h?K(U,{marginTop:1,paddingX:1,children:K(hy,{message:`Fetching PRs...`})}):q(U,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:[S.map((e,t)=>{let n=t+b,i=n===v;return q(_o,{onClick:()=>{y(n),E(e.name)},children:[K(W,{color:i?r.PRIMARY:r.DIM,children:i?`${J.pointer} `:` `}),K(W,{color:i?r.PRIMARY:r.DIM,bold:i,children:gy(ea(e.name,31),32)}),K(W,{color:r.CYAN,children:gy(ea(e.author||`—`,15),16)}),e.prNumber&&e.prStatus?K(W,{color:e.prStatus===`open`?r.GREEN:e.prStatus===`merged`?r.PURPLE:r.DIM,children:ea(`#${e.prNumber} ${e.prStatus}`,ee)}):K(W,{color:r.DIM,children:`—`})]},e.name)}),_.length===0&&K(W,{color:r.DIM,children:`No matching branches`})]}),N;e[21]!==r||e[22]!==f?(N=f?K(U,{marginTop:1,paddingX:1,children:K(W,{color:r.RED,children:f})}):null,e[21]=r,e[22]=f,e[23]=N):N=e[23];let oe;e[24]!==r||e[25]!==i?(oe=i?q(ho,{color:r.YELLOW,marginTop:1,children:[q(W,{color:r.YELLOW,bold:!0,children:[`Switch to `,i.name,`?`]}),q(W,{color:r.DIM,children:[`Press `,K(W,{color:r.PRIMARY,children:`y`}),` to continue or`,` `,K(W,{color:r.PRIMARY,children:`n`}),` to cancel.`]})]}):null,e[24]=r,e[25]=i,e[26]=oe):oe=e[26];let se;e[27]!==w||e[28]!==u||e[29]!==o?(se=K(U,{paddingX:1,children:K(wo,{isSearching:u,query:o,onChange:w})}),e[27]=w,e[28]=u,e[29]=o,e[30]=se):se=e[30];let P;return e[31]!==A||e[32]!==re||e[33]!==ie||e[34]!==ae||e[35]!==N||e[36]!==oe||e[37]!==se?(P=q(A,{flexDirection:`column`,width:`100%`,paddingY:1,children:[re,ie,ae,N,oe,se]}),e[31]=A,e[32]=re,e[33]=ie,e[34]=ae,e[35]=N,e[36]=oe,e[37]=se,e[38]=P):P=e[38],P};function Ey(e){return e.setScreen}const Dy=Oi.join(process.cwd(),`.expect`,`logs.md`),Oy=vn.pipe(Rr(Dy)),ky=te(Gr(O(function*(){let e=yield*Qr;yield*e.makeDirectory(Oi.dirname(Dy),{recursive:!0}),yield*e.writeFileString(Oi.join(Oi.dirname(Dy),`.gitignore`),`*
|
|
33
|
+
`)})),Bt([Oy])).pipe(w(Fi.layer));var Ay=n(((t,n)=>{(function(r,i){typeof t==`object`&&typeof n==`object`?n.exports=i(e(`child_process`),e(`crypto`)):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],i):typeof t==`object`?t[`electron-machine-id`]=i(e(`child_process`),e(`crypto`)):r[`electron-machine-id`]=i(r.child_process,r.crypto)})(t,function(t,n){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,S,C,w=function(e){if(!p&&e in O)return O[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},T=t+` Iterator`,E=y==g,D=!1,O=e.prototype,te=O[f]||O[m]||y&&O[y],ne=te||w(y),k=y?E?w(`entries`):ne:void 0,A=t==`Array`&&O.entries||te;if(A&&(C=d(A.call(new e)),C!==Object.prototype&&(u(C,T,!0),r||s(C,f)||o(C,f,_))),E&&te&&te.name!==g&&(D=!0,ne=function(){return te.call(this)}),r&&!x||!p&&!D&&O[f]||o(O,f,ne),c[t]=ne,c[T]=_,y)if(ee={values:E?ne:w(g),keys:b?ne:w(h),entries:k},x)for(S in ee)S in O||a(O,S,ee[S]);else i(i.P+i.F*(p||D),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
|
|
34
|
+
`)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,`__esModule`,{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,S=function(){},C=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(S,S)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(S)instanceof t}catch{}}(),w=function(e,t){return e===t||e===x&&t===a},T=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},E=function(e){return w(x,e)?new D(e):new i(e)},D=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},O=function(e){try{e()}catch(e){return{error:e}}},te=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&A(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=T(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&ne(e)})}},ne=function(e){g.call(s,function(){var t,n,r,i=e._v;if(k(e)&&(t=O(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||k(e)?2:1),e._a=void 0,t)throw t.error})},k=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!k(t.promise))return!1;return!0},A=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},j=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),te(t,!0))},re=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=T(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(re,r,1),c(j,r,1))}catch(e){j.call(r,e)}}):(n._v=e,n._s=1,te(n,!1))}catch(e){j.call({_w:n,_d:!1},e)}}};C||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(re,this,1),c(j,this,1))}catch(e){j.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=E(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&te(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),D=function(){var e=new r;this.promise=e,this.resolve=c(re,e,1),this.reject=c(j,e,1)}),u(u.G+u.W+u.F*!C,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!C,v,{reject:function(e){var t=E(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!C),v,{resolve:function(e){if(e instanceof x&&w(e.constructor,this))return e;var t=E(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(C&&n(46)(function(e){x.all(e).catch(S)})),v,{all:function(e){var t=this,n=E(t),r=n.resolve,i=n.reject,a=O(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=E(t),r=n.reject,i=O(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(t,n){t.exports=e(`child_process`)},function(t,n){t.exports=e(`crypto`)}])})}))();function jy(e){return typeof e==`string`?`'${e}'`:new My().serialize(e)}const My=function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?e.localeCompare(t):n===`number`&&r===`number`?e-t:String.prototype.localeCompare.call(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}return this.serializeObjectEntries(r,Object.entries(e))}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t?.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`,`)}]`};for(let t of[`BigInt64Array`,`BigUint64Array`])e.prototype[`$`+t]=function(e){return`${t}[${e.join(`n,`)}${e.length>0?`n`:``}]`};return e}(),Ny=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,Py=`sha256`,Fy=`base64url`;function Iy(e){if(Ny)return Ny(Py,e,Fy);let t=Hi(Py).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(Fy):t.digest(Fy)}function Ly(e){return Iy(jy(e))}function Ry(){let e=zy();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function zy(e=process.argv[1]?ra(process.argv[1]):process.cwd(),t=aa===`\\`){let n=t?By(e):e;return e=>{if(!e)return;let r=t?By(e):e,{dir:i,base:a,ext:o}=ia.parse(r);(o===`.js`||o===`.mjs`||o===`.cjs`)&&(a=a.slice(0,-1*o.length));let s=decodeURIComponent(a);i||=`.`;let c=i.lastIndexOf(`/node_modules`);if(c>-1)return`${i.slice(c+14).replace(/\//g,`.`)}:${s}`;if(i.startsWith(n)){let e=i.slice(n.length+1).replace(/\//g,`.`);return e?`${e}:${s}`:s}return s}}function By(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const Vy=e=>{if(`flags`in e){let t=Uy(e.flags),n=Wy(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,Ky(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Hy(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function Hy(e,t,n){return{key:e,enabled:typeof t==`string`?!0:t,variant:typeof t==`string`?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:n?JSON.stringify(n):void 0,description:void 0}}}const Uy=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,Gy(t)]).filter(([,e])=>e!==void 0)),Wy=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(e=>{let n=t[e];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(e=>{let n=t[e].metadata?.payload;return[e,n?Ky(n):void 0]}))},Gy=e=>e===void 0?void 0:e.variant??e.enabled,Ky=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},qy=`0123456789abcdef`;var Jy=class e{constructor(e){this.bytes=e}static ofInner(t){if(t.length===16)return new e(t);throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let n;switch(t.length){case 32:n=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:n=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join(``);break;case 38:n=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join(``);break;case 45:n=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join(``);break;default:break}if(n){let t=new Uint8Array(16);for(let e=0;e<16;e+=4){let r=parseInt(n.substring(2*e,2*e+8),16);t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r}return new e(t)}throw SyntaxError(`could not parse UUID string`)}toString(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=qy.charAt(this.bytes[t]>>>4),e+=qy.charAt(15&this.bytes[t]),(t===3||t===5||t===7||t===9)&&(e+=`-`);return e}toHex(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=qy.charAt(this.bytes[t]>>>4),e+=qy.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){let e=this.bytes[8]>>>4;if(e<0)throw Error(`unreachable`);if(e<=7)return this.bytes.every(e=>e===0)?`NIL`:`VAR_0`;if(e<=11)return`VAR_10`;if(e<=13)return`VAR_110`;if(e<=15)return this.bytes.every(e=>e===255)?`MAX`:`VAR_RESERVED`;throw Error(`unreachable`)}getVersion(){return this.getVariant()===`VAR_10`?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;t<16;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Yy=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??Xy()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){let n=this.generateOrAbortCore(e,t);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(e,t)),n}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return Jy.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,Jy.ofInner(e)}};const Xy=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let Zy;const Qy=()=>$y().toString(),$y=()=>(Zy||=new Yy).generate();var eb=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e}({});const tb=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),nb=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return tb.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},rb=Array.isArray,ib=Object.prototype;ib.hasOwnProperty;const ab=ib.toString,ob=rb||function(e){return ab.call(e)===`[object Array]`},sb=e=>e===Object(e)&&!ob(e),cb=e=>e===void 0,lb=e=>ab.call(e)==`[object String]`,ub=e=>lb(e)&&e.trim().length===0,db=e=>ab.call(e)==`[object Number]`&&e===e,fb=e=>e instanceof Error;function pb(e){return typeof e!=`object`||!e}function mb(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function hb(e){return!cb(Event)&&_b(e,Event)}function gb(e){return mb(e,`Object`)}function _b(e,t){try{return e instanceof t}catch{return!1}}function vb(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),db(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):e<t?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),vb(i||n,t,n,r))}var yb=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=vb(e.bucketSize,0,100,e._logger),this._refillRate=vb(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=vb(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){let n=t-e.lastAccess,r=Math.floor(n/this._refillInterval);if(r>0){let t=r*this._refillRate;e.tokens=Math.min(e.tokens+t,this._bucketSize),e.lastAccess+=r*this._refillInterval}}consumeRateLimit(e){let t=Date.now(),n=String(e),r=this._buckets[n];return r?this._applyRefill(r,t):(r={tokens:this._bucketSize,lastAccess:t},this._buckets[n]=r),r.tokens===0?!0:(r.tokens--,r.tokens===0&&this._onBucketRateLimited?.(e),r.tokens===0)}stop(){this._buckets={}}},bb=class{add(e){let t=Qy();return this.promiseByIds[t]=e,e.catch(()=>{}).finally(()=>{delete this.promiseByIds[t]}),e}async join(){let e=Object.values(this.promiseByIds),t=e.length;for(;t>0;)await Promise.all(e),e=Object.values(this.promiseByIds),t=e.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function xb(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const Sb=(e,t,n)=>{function r(r,...i){t(()=>{let t=n[r];t(e,...i)})}return{info:(...e)=>{r(`log`,...e)},warn:(...e)=>{r(`warn`,...e)},error:(...e)=>{r(`error`,...e)},critical:(...t)=>{n.error(e,...t)},createLogger:r=>Sb(`${e} ${r}`,t,n)}},Cb=e=>e();function wb(e,t=Cb){return Sb(e,t,xb())}const Tb=`Android`;Tb+``;const Eb=`BlackBerry`,Db=`Samsung`;Db+``,Db+``;const Ob=`Chrome`;Ob+``,Ob+``;const kb=`Opera`;kb+``;const Ab=`Edge`;``+Ab;const jb=`Firefox`;jb+``;const Mb=`Nintendo`,Nb=`PlayStation`,Pb=`Xbox`;Tb+``;const Fb=`Windows`;Fb+``;const Ib=`Generic`;Ib+``,Ib+``;const Lb=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+Lb),new RegExp(Pb,`i`),RegExp(Nb+` \\w+`,`i`),RegExp(Mb+` \\w+`,`i`),RegExp(Eb+`|PlayBook|BB10`,`i`),RegExp(`rv:`+Lb),RegExp(Ab+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+Ob+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+Lb),RegExp(`(UCBrowser|UCWEB)\\/`+Lb),RegExp(`(`+kb+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp(jb+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+Lb),RegExp(`Konqueror[:/]?`+Lb,`i`),RegExp(Eb+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+Lb,`i`),RegExp(`(rv:|MSIE )`+Lb),RegExp(`rv:`+Lb),RegExp(Pb+`; Xbox (.*?)[);]`,`i`),new RegExp(Mb,`i`),new RegExp(Nb,`i`),new RegExp(Fb,`i`),RegExp(`(`+Tb+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function Rb(e,t){if(!e||typeof e!=`string`||zb(e))throw Error(t)}function zb(e){return e.trim().length===0}function Bb(e){return e?.replace(/\/+$/,``)}async function Vb(e,t){let n=null;for(let r=0;r<t.retryCount+1;r++){r>0&&await new Promise(e=>setTimeout(e,t.retryDelay));try{return await e()}catch(e){if(n=e,!t.retryCheck(e))throw e}}throw n}function Hb(){return new Date().toISOString()}function Ub(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const Wb=e=>e instanceof Error;function Gb(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var Kb=class{constructor(){this.events={},this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.events[e]||[])n(t);for(let n of this.events[`*`]||[])n(e,t)}};function qb(){return`CompressionStream`in globalThis}async function Jb(e,t=!0){try{let t=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return await new Response(t).blob()}catch(e){return t&&console.error(`Failed to gzip compress data`,e),null}}var Yb=class extends Error{constructor(e,t){super(`HTTP error while fetching PostHog: status=`+e.status+`, reqByteLength=`+t),this.response=e,this.reqByteLength=t,this.name=`PostHogFetchHttpError`}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},Xb=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function Zb(e){if(e instanceof Yb){let t=``;try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error(`Error while flushing PostHog`,e);return Promise.resolve()}function Qb(e){return typeof e==`object`&&(e instanceof Yb||e instanceof Xb)}function $b(e){return typeof e==`object`&&e instanceof Yb&&e.status===413}var ex=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new bb,this._events=new Kb,this._isInitialized=!1,Rb(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=Bb(t.host||`https://us.i.posthog.com`),this.flushAt=t.flushAt?Math.max(t.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,t.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,t.maxQueueSize??1e3),this.flushInterval=t.flushInterval??1e4,this.preloadFeatureFlags=t.preloadFeatureFlags??!0,this.defaultOptIn=t.defaultOptIn??!0,this.disableSurveys=t.disableSurveys??!1,this._retryOptions={retryCount:t.fetchRetryCount??3,retryDelay:t.fetchRetryDelay??3e3,retryCheck:Qb},this.requestTimeout=t.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=t.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=t.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=t.disableGeoip??!0,this.disabled=t.disabled??!1,this.historicalMigration=t?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=wb(`[PostHog]`,this.logMsgIfDebug.bind(this)),this.evaluationContexts=t?.evaluationContexts??t?.evaluationEnvironments,t?.evaluationEnvironments&&!t?.evaluationContexts&&this._logger.warn(`evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version.`),this.disableCompression=!qb()||(t?.disableCompression??!1)}logMsgIfDebug(e){this.isDebug&&e()}wrap(e){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized)return e();this._initPromise.then(()=>e())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(eb.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(eb.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(eb.OptedOut,!0)})}on(e,t){return this._events.on(e,t)}debug(e=!0){if(this.removeDebugCallback?.(),e){let e=this.on(`*`,(e,t)=>this._logger.info(e,t));this.removeDebugCallback=()=>{e(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(e){return{distinct_id:e.distinct_id,event:e.event,properties:{...e.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(e){return this.promiseQueue.add(e)}identifyStateless(e,t,n){this.wrap(()=>{let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};this.enqueue(`identify`,r,n)})}async identifyStatelessImmediate(e,t,n){let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};await this.sendImmediate(`identify`,r,n)}captureStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({distinct_id:e,event:t,properties:n});this.enqueue(`capture`,i,r)})}async captureStatelessImmediate(e,t,n,r){let i=this.buildPayload({distinct_id:e,event:t,properties:n});await this.sendImmediate(`capture`,i,r)}aliasStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});this.enqueue(`alias`,i,r)})}async aliasStatelessImmediate(e,t,n,r){let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});await this.sendImmediate(`alias`,i,r)}groupIdentifyStateless(e,t,n,r,i,a){this.wrap(()=>{let o=this.buildPayload({distinct_id:i||`$${e}_${t}`,event:`$groupidentify`,properties:{$group_type:e,$group_key:t,$group_set:n||{},...a||{}}});this.enqueue(`capture`,o,r)})}async getRemoteConfig(){await this._initPromise;let e=this.host;e===`https://us.i.posthog.com`?e=`https://us-assets.i.posthog.com`:e===`https://eu.i.posthog.com`&&(e=`https://eu-assets.i.posthog.com`);let t=`${e}/array/${this.apiKey}/config`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}};return this.fetchWithRetry(t,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(e=>e.json()).catch(e=>{this._logger.error(`Remote config could not be loaded`,e),this._events.emit(`error`,e)})}async getFlags(e,t={},n={},r={},i={},a=!1){await this._initPromise;let o=a?`&config=true`:``,s=`${this.host}/flags/?v=2${o}`,c={token:this.apiKey,distinct_id:e,groups:t,person_properties:n,group_properties:r,...i};this.evaluationContexts&&this.evaluationContexts.length>0&&(c.evaluation_contexts=this.evaluationContexts);let l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`},body:JSON.stringify(c)};return this._logger.info(`Flags URL`,s),this.fetchWithRetry(s,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(e=>e.json()).then(e=>({success:!0,response:Vy(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof Yb)return{type:`api_error`,statusCode:e.status};if(e instanceof Xb){let t=e.error;return t instanceof Error&&(t.name===`AbortError`||t.name===`TimeoutError`)?{type:`timeout`}:{type:`connection_error`}}return{type:`unknown_error`}}async getFeatureFlagStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailStateless(e,t,n,r,i,a);if(o===void 0)return{response:void 0,requestId:void 0};let s=Gy(o.response);return s===void 0&&(s=!1),{response:s,requestId:o.requestId}}async getFeatureFlagDetailStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(t,n,r,i,a,[e]);if(o!==void 0)return{response:o.flags[e],requestId:o.requestId,evaluatedAt:o.evaluatedAt}}async getFeatureFlagPayloadStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagPayloadsStateless(t,n,r,i,a,[e]);if(!o)return;let s=o[e];return s===void 0?null:s}async getFeatureFlagPayloadsStateless(e,t={},n={},r={},i,a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)).payloads}async getFeatureFlagsStateless(e,t={},n={},r={},i,a){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)}async getFeatureFlagsAndPayloadsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(e,t,n,r,i,a);return o?{flags:o.featureFlags,payloads:o.featureFlagPayloads,requestId:o.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o={};(i??this.disableGeoip)&&(o.geoip_disable=!0),a&&(o.flag_keys_to_evaluate=a);let s=await this.getFlags(e,t,n,r,o);if(!s.success)return;let c=s.response;return c.errorsWhileComputingFlags&&console.error(`[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices`),c.quotaLimited?.includes(`feature_flags`)?(console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:c?.requestId,quotaLimited:c.quotaLimited}):c}async getSurveysStateless(){if(await this._initPromise,!0===this.disableSurveys)return this._logger.info(`Loading surveys is disabled.`),[];let e=`${this.host}/api/surveys/?token=${this.apiKey}`,t={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}},n=(await this.fetchWithRetry(e,t).then(e=>{if(e.status!==200||!e.json){let t=`Surveys API could not be loaded: ${e.status}`,n=Error(t);this._logger.error(n),this._events.emit(`error`,Error(t));return}return e.json()}).catch(e=>{this._logger.error(`Surveys API could not be loaded`,e),this._events.emit(`error`,e)}))?.surveys;return n&&this._logger.info(`Surveys fetched from API: `,JSON.stringify(n)),n??[]}get props(){return this._props||=this.getPersistedProperty(eb.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(eb.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(eb.Props,this.props)})}processBeforeEnqueue(e){return e}async flushStorage(){}enqueue(e,t,n){this.wrap(()=>{if(this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r=this.prepareMessage(e,t,n);if(r=this.processBeforeEnqueue(r),r===null)return;let i=this.getPersistedProperty(eb.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(eb.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Ub(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(e,t,n){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r=this.prepareMessage(e,t,n);if(r=this.processBeforeEnqueue(r),r===null)return;let i={api_key:this.apiKey,batch:[r],sent_at:Hb()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await Jb(a,this.isDebug),c={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...s!==null&&{"Content-Encoding":`gzip`}},body:s||a};try{await this.fetchWithRetry(o,c)}catch(e){this._events.emit(`error`,e)}}prepareMessage(e,t,n){let r={...t,type:e,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Hb(),uuid:n?.uuid?n.uuid:Qy()};return(n?.disableGeoip??this.disableGeoip)&&(r.properties||={},r.properties.$geoip_disable=!0),r.distinctId&&(r.distinct_id=r.distinctId,delete r.distinctId),r}clearFlushTimer(){this._flushTimer&&=(clearTimeout(this._flushTimer),void 0)}flushBackground(){this.flush().catch(async e=>{await Zb(e)})}async flush(){let e=Gb([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),Gb([e]).then(()=>{this.flushPromise===e&&(this.flushPromise=null)}),e}getCustomHeaders(){let e=this.getCustomUserAgent(),t={};return e&&e!==``&&(t[`User-Agent`]=e),t}async _flush(){this.clearFlushTimer(),await this._initPromise;let e=this.getPersistedProperty(eb.Queue)||[];if(!e.length)return;let t=[],n=e.length;for(;e.length>0&&t.length<n;){let n=e.slice(0,this.maxBatchSize),r=n.map(e=>e.message),i=async()=>{let t=(this.getPersistedProperty(eb.Queue)||[]).slice(n.length);this.setPersistedProperty(eb.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:Hb()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await Jb(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>$b(e)?!1:Qb(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if($b(e)&&r.length>1){this.maxBatchSize=Math.max(1,Math.floor(r.length/2)),this._logger.warn(`Received 413 when sending batch of size ${r.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw e instanceof Xb||await i(),this._events.emit(`error`,e),e}await i(),t.push(...r)}this._events.emit(`flush`,t)}async fetchWithRetry(e,t,n,r){let i=t.body?t.body:``,a=-1;try{a=i instanceof Blob?i.size:Buffer.byteLength(i,`utf8`)}catch{a=i instanceof Blob?i.size:new TextEncoder().encode(i).length}return await Vb(async()=>{let n=new AbortController,i=Ub(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new Xb(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new Yb(o,a);return o},{...this._retryOptions,...n})}async _shutdown(e=3e4){await this._initPromise;let t=!1;this.clearFlushTimer();let n=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(eb.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!Qb(e))throw e;await Zb(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=Ub(()=>{this._logger.error(`Timed out while shutting down PostHog`),t=!0,i(`Timeout while shutting down PostHog. Some events may not have been sent.`)},e)}),n()])}finally{clearTimeout(r)}}async shutdown(e=3e4){return this.shutdownPromise?this._logger.warn(`shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup`):this.shutdownPromise=this._shutdown(e).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}};let tx,nx,rx;function ix(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return rx&&n.length===nx?rx:(nx=n.length,rx=n.reduce((n,r)=>{tx||={};let i=tx[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,tx[r]=[a,o];break}}}return n},{}),rx)}var ax=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}async modifyFrames(e){for(let t of e)t.stacktrace&&t.stacktrace.frames&&ob(t.stacktrace.frames)&&(t.stacktrace.frames=await this.applyModifiers(t.stacktrace.frames));return e}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n;e.cause!=null&&(n=this.parseStacktrace(e.cause,t));let r;return e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),{...e,cause:n,stack:r}}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}async applyModifiers(e){let t=e;for(let e of this.modifiers)t=await e(t);return t}convertToExceptionList(e,t){let n={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:t.handled??!0,synthetic:e.synthetic??!1}};e.stack&&(n.stacktrace={type:`raw`,frames:e.stack});let r=[n];return e.cause!=null&&r.push(...this.convertToExceptionList(e.cause,{...t,handled:!0})),r}buildParsingContext(e){return{chunkIdMap:ix(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n=0){let r=(n,r)=>{if(r<=4){let i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return{...t,syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)}}};const ox=/^\s*[-]{4,}$/,sx=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,cx=(e,t)=>{let n=e.match(sx);if(n){let e,r,i,a,o;if(n[1]){i=n[1];let t=i.lastIndexOf(`.`);if(i[t-1]===`.`&&t--,t>0){e=i.slice(0,t),r=i.slice(t+1);let n=e.indexOf(`.Module`);n>0&&(i=i.slice(n+1),e=e.slice(0,n))}a=void 0}r&&(a=e,o=r),r===`<anonymous>`&&(o=void 0,i=void 0),i===void 0&&(o||=`?`,i=a?`${a}.${o}`:o);let s=n[2]?.startsWith(`file://`)?n[2].slice(7):n[2],c=n[5]===`native`;return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&n[5]&&!c&&(s=n[5]),{filename:s?decodeURI(s):void 0,module:void 0,function:i,lineno:ux(n[3]),colno:ux(n[4]),in_app:lx(s||``,c),platform:t}}if(e.match(ox))return{filename:e,platform:t}};function lx(e,t=!1){return!(t||e&&!e.startsWith(`/`)&&!e.match(/^[A-Z]:/)&&!e.startsWith(`.`)&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes(`node_modules/`)}function ux(e){return parseInt(e||``,10)||void 0}const dx=/\(error: (.*)\)/;function fx(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||px(t).filename,function:e.function||`?`}))}function px(e){return e[e.length-1]||{}}function mx(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
|
|
35
|
+
`);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=dx.test(r)?r.replace(dx,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);break}}if(i.length>=50)break}}return fx(i)}}var hx=class{match(e){return fb(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return n.error&&typeof n.error.message==`string`?String(n.error.message):String(n)}getStack(e){return e.stacktrace||e.stack||void 0}};const gx=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var _x=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(gx);return r&&(t=r[1],n=r[2]),[t,n]}};const vx=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function yx(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(!(r.length>t))return e===n.length||r.length<=t?r:`${r.slice(0,t)}...`}return``}var bx=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return hb(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e),n=yx(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return lb(e)&&!ub(e)&&vx.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(Wb(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},xx=class{match(e){return hb(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${yx(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},Sx=class{match(e){return pb(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},Cx=class{constructor(e){this._maxSize=e,this._cache=new Map}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.set(e,t)}reduce(){for(;this._cache.size>=this._maxSize;){let e=this._cache.keys().next().value;e&&this._cache.delete(e)}}};const wx=new Cx(25),Tx=new Cx(20);async function Ex(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n],i=r?.filename;!r||typeof i!=`string`||typeof r.lineno!=`number`||jx(i)||Mx(r)||(t[i]||(t[i]=[]),t[i].push(r.lineno))}let n=Object.keys(t);if(n.length==0)return e;let r=[];for(let e of n){if(Tx.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=Px(n);if(i.every(t=>Nx(e,t)))continue;let a=Rx(wx,e,{});r.push(Dx(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&Ox(e,wx),wx.reduce(),e}function Dx(e,t,n){return new Promise(r=>{let i=Qi(e),a=oa({input:i});function o(){i.destroy(),r()}let s=0,c=0,l=t[c];if(l===void 0)return void o();let u=l[0],d=l[1];function f(){Tx.set(e,1),a.close(),a.removeAllListeners(),o()}i.on(`error`,f),a.on(`error`,f),a.on(`close`,o),a.on(`line`,e=>{if(s++,!(s<u)&&(n[s]=zx(e,0),s>=d)){if(c===t.length-1){a.close(),a.removeAllListeners();return}c++;let e=t[c];if(e===void 0){a.close(),a.removeAllListeners();return}u=e[0],d=e[1]}})})}function Ox(e,t){for(let n of e)if(n.filename&&n.context_line===void 0&&typeof n.lineno==`number`){let e=t.get(n.filename);if(e===void 0)continue;kx(n.lineno,n,e)}}function kx(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=Ix(e);r<e;r++){let e=n[r];if(e===void 0)return void Ax(t);t.pre_context.push(e)}if(n[e]===void 0)return void Ax(t);t.context_line=n[e];let r=Lx(e);t.post_context=[];for(let i=e+1;i<=r;i++){let e=n[i];if(e===void 0)break;t.post_context.push(e)}}function Ax(e){delete e.pre_context,delete e.context_line,delete e.post_context}function jx(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function Mx(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function Nx(e,t){let n=wx.get(e);if(n===void 0)return!1;for(let e=t[0];e<=t[1];e++)if(n[e]===void 0)return!1;return!0}function Px(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=Fx(n),i=[];for(;;){if(t===e.length-1){i.push(r);break}let n=e[t+1];if(typeof n!=`number`)break;n<=r[1]?r[1]=n+7:(i.push(r),r=Fx(n)),t++}return i}function Fx(e){return[Ix(e),Lx(e)]}function Ix(e){return Math.max(1,e-7)}function Lx(e){return e+7}function Rx(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function zx(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`...${n}`),a<r&&(n+=`...`),n}function Bx(e,t){let n=!1;return Object.assign(r=>{let i=global.process.listeners(`uncaughtException`).filter(e=>e.name!==`domainUncaughtExceptionClear`&&!0!==e._posthogErrorHandler).length===0;e(r,{mechanism:{type:`onuncaughtexception`,handled:!1}}),!n&&i&&(n=!0,t(r))},{_posthogErrorHandler:!0})}function Vx(e,t){globalThis.process?.on(`uncaughtException`,Bx(e,t))}function Hx(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var Ux=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new yb({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return sb(e)&&`__posthog_previously_captured_error`in e&&!0===e.__posthog_previously_captured_error}static async buildEventMessage(e,t,n,r){let i={...r};n||(i.$process_person_profile=!1);let a=this.errorPropertiesBuilder.buildFromUnknown(e,t);return a.$exception_list=await this.errorPropertiesBuilder.modifyFrames(a.$exception_list),{event:`$exception`,distinctId:n||Qy(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(Vx(this.onException.bind(this),this.onFatalError.bind(this)),Hx(this.onException.bind(this)))}onException(t,n){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let r=await e.buildEventMessage(t,n),i=r.properties?.$exception_list[0]?.type??`Exception`;return this._rateLimiter.consumeRateLimit(i)?void this._logger.info(`Skipping exception capture because of client rate limiting.`,{exception:i}):this.client.capture(r)}})())}async onFatalError(e){console.error(e),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};const Wx={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function Gx(e){let t=globalThis.crypto?.subtle;if(!t)throw Error(`SubtleCrypto API not available`);let n=await t.digest(`SHA-1`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}const Kx=[`is_not`];var qx=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},$=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Jx=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Yx=class{constructor({pollingInterval:e,personalApiKey:t,projectApiKey:n,timeout:r,host:i,customHeaders:a,...o}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=e,this.personalApiKey=t,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=r,this.projectApiKey=n,this.host=i,this.poller=void 0,this.fetch=o.fetch||fetch,this.onError=o.onError,this.customHeaders=a,this.onLoad=o.onLoad,this.cacheProvider=o.cacheProvider,this.strictLocalEvaluation=o.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(e=!0){this.debugMode=e}logMsgIfDebug(e){this.debugMode&&e()}createEvaluationContext(e,t={},n={},r={},i={}){return{distinctId:e,groups:t,personProperties:n,groupProperties:r,evaluationCache:i}}async getFeatureFlag(e,t,n={},r={},i={}){await this.loadFeatureFlags();let a,o;if(!this.loadedSuccessfullyOnce)return a;if(o=this.featureFlagsByKey[e],o!==void 0){let s=this.createEvaluationContext(t,n,r,i);try{a=(await this.computeFlagAndPayloadLocally(o,s)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${e} -> ${a}`))}catch(t){t instanceof Jx||t instanceof $?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e}: ${t.message}`)):t instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${e}: ${t}`))}}return a}async getAllFlagsAndPayloads(e,t){await this.loadFeatureFlags();let n={},r={},i=this.featureFlags.length==0,a=t?t.map(e=>this.featureFlagsByKey[e]).filter(Boolean):this.featureFlags,o={...e,evaluationCache:e.evaluationCache??{}};return await Promise.all(a.map(async e=>{try{let{value:t,payload:i}=await this.computeFlagAndPayloadLocally(e,o);n[e.key]=t,i&&(r[e.key]=i)}catch(t){t instanceof Jx||t instanceof $?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e.key}: ${t.message}`)):t instanceof Error&&this.onError?.(Error(`Error computing flag locally: ${e.key}: ${t}`)),i=!0}})),{response:n,payloads:r,fallbackToFlags:i}}async computeFlagAndPayloadLocally(e,t,n={}){let{matchValue:r,skipLoadCheck:i=!1}=n;if(i||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let a;a=r===void 0?await this.computeFlagValueLocally(e,t):r;let o=this.getFeatureFlagPayload(e.key,a);return{value:a,payload:o}}async computeFlagValueLocally(e,t){let{distinctId:n,groups:r,personProperties:i,groupProperties:a}=t;if(e.ensure_experience_continuity)throw new $(`Flag has experience continuity enabled`);if(!e.active)return!1;let o=(e.filters||{}).aggregation_group_type_index;if(o!=null){let n=this.groupTypeMapping[String(o)];if(!n)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${o} for feature flag ${e.key}`)),new $(`Flag has unknown group type index`);if(!(n in r))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${e.key} without group names passed in`)),!1;e.bucketing_identifier===`device_id`&&(i?.$device_id===void 0||i?.$device_id===null||i?.$device_id===``)&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${e.key}`));let s=a[n];return await this.matchFeatureFlagProperties(e,r[n],s,t)}{let r=this.getBucketingValueForFlag(e,n,i);if(r===void 0)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${e.key} without $device_id, falling back to server evaluation`)),new $(`Can't compute feature flag: ${e.key} without $device_id`);return await this.matchFeatureFlagProperties(e,r,i,t)}}getBucketingValueForFlag(e,t,n){if(e.filters?.aggregation_group_type_index!=null)return t;if(e.bucketing_identifier===`device_id`){let e=n?.$device_id;return e==null||e===``?void 0:e}return t}getFeatureFlagPayload(e,t){let n=null;if(!1!==t&&t!=null&&(typeof t==`boolean`?n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t.toString()]||null:typeof t==`string`&&(n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t]||null),n!=null)){if(typeof n==`object`)return n;if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(e,t,n){let{evaluationCache:r}=n,i=e.key;if(!this.featureFlagsByKey)throw new $(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new $(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new $(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new $(`Circular dependency detected for flag '${i}' (empty dependency chain)`);for(let e of a){if(!(e in r)){let t=this.featureFlagsByKey[e];if(t)if(t.active)try{r[e]=await this.computeFlagValueLocally(t,n)}catch(t){throw new $(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1;else throw new $(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new $(`Dependency '${e}' could not be evaluated`)}let o=r[i];return this.flagEvaluatesToExpectedValue(e.value,o)}flagEvaluatesToExpectedValue(e,t){return typeof e==`boolean`?e===t||typeof t==`string`&&t!==``&&!0===e:typeof e==`string`?t===e:!1}async matchFeatureFlagProperties(e,t,n,r){let i=e.filters||{},a=i.groups||[],o=!1,s;for(let c of a)try{if(await this.isConditionMatch(e,t,c,n,r)){let n=c.variant,r=i.multivariate?.variants||[];s=n&&r.some(e=>e.key===n)?n:await this.getMatchingVariant(e,t)||!0;break}}catch(e){if(e instanceof Jx)throw e;if(e instanceof $)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new $(`Can't determine if feature flag is enabled or not with given properties`);return!1}async isConditionMatch(e,t,n,r,i){let a=n.rollout_percentage,o=e=>{this.logMsgIfDebug(()=>console.warn(e))};if((n.properties||[]).length>0){for(let e of n.properties){let t=e.type,n=!1;if(n=t===`cohort`?$x(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):Zx(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await Xx(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await Xx(e.key,t,`variant`),r=this.variantLookupTable(e).find(e=>n>=e.valueMin&&n<e.valueMax);if(r)return r.key}variantLookupTable(e){let t=[],n=0,r=0;return((e.filters||{}).multivariate?.variants||[]).forEach(e=>{r=n+e.rollout_percentage/100,t.push({valueMin:n,valueMax:r,key:e.key}),n=r}),t}updateFlagState(e){this.featureFlags=e.flags,this.featureFlagsByKey=e.flags.reduce((e,t)=>(e[t.key]=t,e),{}),this.groupTypeMapping=e.groupTypeMapping,this.cohorts=e.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(e){if(this.strictLocalEvaluation)return;let t=e.filter(e=>e.ensure_experience_continuity);t.length>0&&console.warn(`[PostHog] You are using local evaluation but ${t.length} flag(s) have experience continuity enabled: ${t.map(e=>e.key).join(`, `)}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(e){if(!this.cacheProvider)return!1;try{let t=await this.cacheProvider.getFlagDefinitions();return t?(this.updateFlagState(t),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${e} (${t.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(t.flags),!0):!1}catch(e){return this.onError?.(Error(`Failed to load from cache: ${e}`)),!1}}async loadFeatureFlags(e=!1){if(!(this.loadedSuccessfullyOnce&&!e))return!e&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Skipping fetch, in backoff period`)):(this.loadingPromise||=this._loadFeatureFlags().catch(e=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${e}`))).finally(()=>{this.loadingPromise=void 0}),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&=(clearTimeout(this.poller),void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let e=!0;if(this.cacheProvider)try{e=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(e){this.onError?.(Error(`Error in shouldFetchFlagDefinitions: ${e}`))}if(!e&&(await this.loadFromCache(`Loaded flags from cache (skipped fetch)`)||this.loadedSuccessfullyOnce))return;let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 304:this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Flags not modified (304), using cached data`)),this.flagsEtag=t.headers?.get(`ETag`)??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new qx(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new qx(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new qx(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let n=await t.json()??{};if(!(`flags`in n))return void this.onError?.(Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=t.headers?.get(`ETag`)??void 0;let r={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(r),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&e)try{await this.cacheProvider.onFlagDefinitionsReceived(r)}catch(e){this.onError?.(Error(`Failed to store in cache: ${e}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags);break}default:return}}catch(e){e instanceof qx&&this.onError?.(e)}}getPersonalApiKeyRequestOptions(e=`GET`,t){let n={...this.customHeaders,"Content-Type":`application/json`,Authorization:`Bearer ${this.personalApiKey}`};return t&&(n[`If-None-Match`]=t),{method:e,headers:n}}_requestFeatureFlagDefinitions(){let e=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,t=this.getPersonalApiKeyRequestOptions(`GET`,this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout==`number`){let e=new AbortController;n=Ub(()=>{e.abort()},this.timeout),t.signal=e.signal}try{let n=this.fetch;return n(e,t)}finally{clearTimeout(n)}}async stopPoller(e=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let t=this.cacheProvider.shutdown();t instanceof Promise&&await Promise.race([t,new Promise((t,n)=>setTimeout(()=>n(Error(`Cache shutdown timeout after ${e}ms`)),e))])}catch(e){this.onError?.(Error(`Error during cache shutdown: ${e}`))}}};async function Xx(e,t,n=``){let r=await Gx(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function Zx(e,t,n){let r=e.key,i=e.value,a=e.operator||`exact`;if(r in t){if(a===`is_not_set`)throw new $(`Operator is_not_set is not supported`)}else throw new $(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!Kx.includes(a))return n&&n(`Property ${r} cannot have a value of null/undefined with the ${a} operator`),!1;function s(e,t){return Array.isArray(e)?e.map(e=>String(e).toLowerCase()).includes(String(t).toLowerCase()):String(e).toLowerCase()===String(t).toLowerCase()}function c(e,t,n){if(n===`gt`)return e>t;if(n===`gte`)return e>=t;if(n===`lt`)return e<t;if(n===`lte`)return e<=t;throw Error(`Invalid operator: ${n}`)}switch(a){case`exact`:return s(i,o);case`is_not`:return!s(i,o);case`is_set`:return r in t;case`icontains`:return String(o).toLowerCase().includes(String(i).toLowerCase());case`not_icontains`:return!String(o).toLowerCase().includes(String(i).toLowerCase());case`regex`:return tS(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return tS(String(i))&&String(o).match(String(i))===null;case`gt`:case`gte`:case`lt`:case`lte`:{let e=typeof i==`number`?i:null;if(typeof i==`string`)try{e=parseFloat(i)}catch{}return e==null||o==null?c(String(o),String(i),a):typeof o==`string`?c(o,String(i),a):c(o,e,a)}case`is_date_after`:case`is_date_before`:{if(typeof i==`boolean`)throw new $(`Date operations cannot be performed on boolean values`);let e=cS(String(i));if(e??=sS(i),e==null)throw new $(`Invalid date: ${i}`);let t=sS(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return rS(nS(String(o)),nS(String(i)))===0;case`semver_neq`:return rS(nS(String(o)),nS(String(i)))!==0;case`semver_gt`:return rS(nS(String(o)),nS(String(i)))>0;case`semver_gte`:return rS(nS(String(o)),nS(String(i)))>=0;case`semver_lt`:return rS(nS(String(o)),nS(String(i)))<0;case`semver_lte`:return rS(nS(String(o)),nS(String(i)))<=0;case`semver_tilde`:{let e=nS(String(o)),{lower:t,upper:n}=iS(String(i));return rS(e,t)>=0&&rS(e,n)<0}case`semver_caret`:{let e=nS(String(o)),{lower:t,upper:n}=aS(String(i));return rS(e,t)>=0&&rS(e,n)<0}case`semver_wildcard`:{let e=nS(String(o)),{lower:t,upper:n}=oS(String(i));return rS(e,t)>=0&&rS(e,n)<0}default:throw new $(`Unknown operator: ${a}`)}}function Qx(e,t){if(!(e in t))throw new Jx(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function $x(e,t,n,r=!1){let i=String(e.value);Qx(i,n);let a=n[i];return eS(a,t,n,r)}function eS(e,t,n,r=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if(`values`in a[0]){for(let e of a)try{let a=eS(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof Jx)throw t;if(t instanceof $)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $(`Can't match cohort without a given cohort property value`);return i===`AND`}for(let e of a)try{let a;if(e.type===`cohort`)a=$x(e,t,n,r);else if(e.type===`flag`){r&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${e.key||`unknown`}'`);continue}else a=Zx(e,t);let o=e.negation||!1;if(i===`AND`){if(!a&&!o||a&&o)return!1}else if(a&&!o||!a&&o)return!0}catch(t){if(t instanceof Jx)throw t;if(t instanceof $)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $(`can't match cohort without a given cohort property value`);return i===`AND`}function tS(e){try{return new RegExp(e),!0}catch{return!1}}function nS(e){let t=String(e).trim().replace(/^[vV]/,``).split(`-`)[0].split(`+`)[0];if(!t||t.startsWith(`.`))throw new $(`Invalid semver: ${e}`);let n=t.split(`.`),r=t=>{if(t===void 0||t===``)return 0;if(!/^\d+$/.test(t))throw new $(`Invalid semver: ${e}`);return parseInt(t,10)};return[r(n[0]),r(n[1]),r(n[2])]}function rS(e,t){for(let n=0;n<3;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return 0}function iS(e){let t=nS(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function aS(e){let[t,n,r]=nS(e),i=[t,n,r],a;return a=t>0?[t+1,0,0]:n>0?[0,n+1,0]:[0,0,r+1],{lower:i,upper:a}}function oS(e){let t=String(e).trim().replace(/^[vV]/,``).replace(/\.\*$/,``).replace(/\*$/,``);if(!t)throw new $(`Invalid wildcard semver: ${e}`);let n=t.split(`.`),r=parseInt(n[0],10);if(isNaN(r))throw new $(`Invalid wildcard semver: ${e}`);let i,a;if(n.length===1)i=[r,0,0],a=[r+1,0,0];else{let t=parseInt(n[1],10);if(isNaN(t))throw new $(`Invalid wildcard semver: ${e}`);i=[r,t,0],a=[r,t+1,0]}return{lower:i,upper:a}}function sS(e){if(e instanceof Date)return e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new $(`${e} is in an invalid date format`)}throw new $(`The date provided ${e} must be a string, number, or date object`)}function cS(e){let t=e.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),n=new Date(new Date().toISOString());if(!t)return null;{if(!t.groups)return null;let e=parseInt(t.groups.number);if(e>=1e4)return null;let r=t.groups.interval;if(r==`h`)n.setUTCHours(n.getUTCHours()-e);else if(r==`d`)n.setUTCDate(n.getUTCDate()-e);else if(r==`w`)n.setUTCDate(n.getUTCDate()-7*e);else if(r==`m`)n.setUTCMonth(n.getUTCMonth()-e);else{if(r!=`y`)return null;n.setUTCFullYear(n.getUTCFullYear()-e)}return n}}var lS=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const uS=3e4;var dS=class extends ex{constructor(e,t={}){if(super(e,t),this._memoryStorage=new lS,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):uS,typeof t.waitUntilDebounceMs==`number`&&(this.options.waitUntilDebounceMs=Math.max(t.waitUntilDebounceMs,0)),typeof t.waitUntilMaxWaitMs==`number`&&(this.options.waitUntilMaxWaitMs=Math.max(t.waitUntilMaxWaitMs,0)),t.personalApiKey){if(t.personalApiKey.includes(`phc_`))throw Error(`Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.`);!1!==t.enableLocalEvaluation&&(this.featureFlagsPoller=new Yx({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:t.personalApiKey,projectApiKey:e,timeout:t.requestTimeout??1e4,host:this.host,fetch:t.fetch,onError:e=>{this._events.emit(`error`,e)},onLoad:e=>{this._events.emit(`localEvaluationFlagsLoaded`,e)},customHeaders:this.getCustomHeaders(),cacheProvider:t.flagDefinitionCacheProvider,strictLocalEvaluation:t.strictLocalEvaluation}))}this.errorTracking=new Ux(this,t,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=t.maxCacheSize||5e4}enqueue(e,t,n){super.enqueue(e,t,n),this.scheduleDebouncedFlush()}async flush(){let e=super.flush(),t=this.options.waitUntil;if(t&&!this._waitUntilCycle)try{t(e.catch(()=>{}))}catch{}return e}scheduleDebouncedFlush(){let e=this.options.waitUntil;if(!e||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let t,n=new Promise(e=>{t=e});try{e(n)}catch{return}this._waitUntilCycle={resolve:t,startedAt:Date.now(),timer:void 0}}let t=Date.now()-this._waitUntilCycle.startedAt>=(this.options.waitUntilMaxWaitMs??500);if(this._waitUntilCycle.timer!==void 0&&clearTimeout(this._waitUntilCycle.timer),t)return void this.resolveWaitUntilFlush();let n=this.options.waitUntilDebounceMs??50;this._waitUntilCycle.timer=Ub(()=>{this.resolveWaitUntilFlush()},n)}_consumeWaitUntilCycle(){let e=this._waitUntilCycle;return e&&(clearTimeout(e.timer),this._waitUntilCycle=void 0),e?.resolve}async resolveWaitUntilFlush(){let e=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{e?.()}}getPersistedProperty(e){return this._memoryStorage.getProperty(e)}setPersistedProperty(e,t){return this._memoryStorage.setProperty(e,t)}fetch(e,t){return this.options.fetch?this.options.fetch(e,t):fetch(e,t)}getLibraryVersion(){return`5.28.5`}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(e=!0){super.debug(e),this.featureFlagsPoller?.debug(e)}capture(e){typeof e==`string`&&this._logger.warn(`Called capture() with a string as the first argument when an object was expected.`),e.event===`$exception`&&!e._originatedFromCaptureException&&this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStateless(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}async captureImmediate(e){return typeof e==`string`&&this._logger.warn(`Called captureImmediate() with a string as the first argument when an object was expected.`),e.event===`$exception`&&!e._originatedFromCaptureException&&this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStatelessImmediate(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}identify({distinctId:e,properties:t={},disableGeoip:n}){let{$set:r,$set_once:i,$anon_distinct_id:a,...o}=t,s={$set:r||o,$set_once:i||{},$anon_distinct_id:a??void 0};super.identifyStateless(e,s,{disableGeoip:n})}async identifyImmediate({distinctId:e,properties:t={},disableGeoip:n}){let{$set:r,$set_once:i,$anon_distinct_id:a,...o}=t,s={$set:r||o,$set_once:i||{},$anon_distinct_id:a??void 0};super.identifyStatelessImmediate(e,s,{disableGeoip:n})}alias(e){super.aliasStateless(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}async aliasImmediate(e){await super.aliasStatelessImmediate(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(e=uS){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(t=>{let n=setTimeout(()=>{r(),t(!1)},e),r=this._events.on(`localEvaluationFlagsLoaded`,e=>{clearTimeout(n),r(),t(e>0)})})}_resolveDistinctId(e,t){return typeof e==`string`?{distinctId:e,options:t}:{distinctId:this.context?.get()?.distinctId,options:e}}async _getFeatureFlagResult(e,t,n={},r){let i=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&e in this._flagOverrides){let t=this._flagOverrides[e];if(t===void 0)return;let n=this._payloadOverrides?.[e];return{key:e,enabled:!1!==t,variant:typeof t==`string`?t:void 0,payload:n}}let{groups:a,disableGeoip:o}=n,{onlyEvaluateLocally:s,personProperties:c,groupProperties:l}=n,u=this.addLocalPersonAndGroupProperties(t,a,c,l);c=u.allPersonProperties,l=u.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(t,a,c,l);s??=this.options.strictLocalEvaluation??!1;let f,p=!1,m,h,g,_,v,y;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let t=this.featureFlagsPoller?.featureFlagsByKey[e];if(t)try{let n=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(t,d,{matchValue:r});if(n){p=!0;let r=n.value;_=t.id,y=`Evaluated locally`,f={key:e,enabled:!1!==r,variant:typeof r==`string`?r:void 0,payload:n.payload??void 0}}}catch(t){if(t instanceof Jx||t instanceof $)this._logger?.info(`${t.name} when computing flag locally: ${e}: ${t.message}`);else throw t}}if(!p&&!s){let t=await super.getFeatureFlagDetailsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,o,[e]);if(t===void 0)g=Wx.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(Wx.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(Wx.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(Wx.FLAG_MISSING);else{_=r.metadata?.id,v=r.metadata?.version,y=r.reason?.description??r.reason?.code;let t;if(r.metadata?.payload!==void 0)try{t=JSON.parse(r.metadata.payload)}catch{t=r.metadata.payload}f={key:e,enabled:r.enabled,variant:r.variant,payload:t}}n.length>0&&(g=n.join(`,`))}}if(i){let n=f===void 0?void 0:!1===f.enabled?!1:f.variant??!0,r=`${e}_${n}`;if(!(t in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[t].includes(r)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[t])?this.distinctIdHasSentFlagCalls[t].push(r):this.distinctIdHasSentFlagCalls[t]=[r];let i={$feature_flag:e,$feature_flag_response:n,$feature_flag_id:_,$feature_flag_version:v,$feature_flag_reason:y,locally_evaluated:p,[`$feature/${e}`]:n,$feature_flag_request_id:m,$feature_flag_evaluated_at:p?Date.now():h};if(p&&this.featureFlagsPoller){let e=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();e!==void 0&&(i.$feature_flag_definitions_loaded_at=e)}g&&(i.$feature_flag_error=g),this.capture({distinctId:t,event:`$feature_flag_called`,properties:i,groups:a,disableGeoip:o})}}return f!==void 0&&this._payloadOverrides!==void 0&&e in this._payloadOverrides&&(f={...f,payload:this._payloadOverrides[e]}),f}async getFeatureFlag(e,t,n){let r=await this._getFeatureFlagResult(e,t,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(r!==void 0)return!1===r.enabled?!1:r.variant??!0}async getFeatureFlagPayload(e,t,n,r){if(this._payloadOverrides!==void 0&&e in this._payloadOverrides)return this._payloadOverrides[e];let i=await this._getFeatureFlagResult(e,t,{...r,sendFeatureFlagEvents:!1},n);if(i!==void 0)return i.payload??null}async getFeatureFlagResult(e,t,n){let{distinctId:r,options:i}=this._resolveDistinctId(t,n);return r?this._getFeatureFlagResult(e,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn(`[PostHog] distinctId is required — pass it explicitly or use withContext()`)}async getRemoteConfigPayload(e){if(!this.options.personalApiKey)throw Error(`Personal API key is required for remote config payload decryption`);let t=await this._requestRemoteConfigPayload(e);if(!t)return;let n=await t.json();if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(e,t,n){let r=await this.getFeatureFlag(e,t,n);if(r!==void 0)return!!r||!1}async getAllFlags(e,t){let{distinctId:n,options:r}=this._resolveDistinctId(e,t);return n?(await this.getAllFlagsAndPayloads(n,r)).featureFlags||{}:(this._logger.warn(`[PostHog] distinctId is required to get feature flags — pass it explicitly or use withContext()`),{})}async getAllFlagsAndPayloads(e,t){let{distinctId:n,options:r}=this._resolveDistinctId(e,t);if(!n)return this._logger.warn(`[PostHog] distinctId is required to get feature flags and payloads — pass it explicitly or use withContext()`),{featureFlags:{},featureFlagPayloads:{}};let{groups:i,disableGeoip:a,flagKeys:o}=r||{},{onlyEvaluateLocally:s,personProperties:c,groupProperties:l}=r||{},u=this.addLocalPersonAndGroupProperties(n,i,c,l);c=u.allPersonProperties,l=u.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(n,i,c,l);s??=this.options.strictLocalEvaluation??!1;let f=await this.featureFlagsPoller?.getAllFlagsAndPayloads(d,o),p={},m={},h=!0;if(f&&(p=f.response,m=f.payloads,h=f.fallbackToFlags),h&&!s){let e=await super.getFeatureFlagsAndPayloadsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,a,o);p={...p,...e.flags||{}},m={...m,...e.payloads||{}}}return this._flagOverrides!==void 0&&(p={...p,...this._flagOverrides}),this._payloadOverrides!==void 0&&(m={...m,...this._payloadOverrides}),{featureFlags:p,featureFlagPayloads:m}}groupIdentify({groupType:e,groupKey:t,properties:n,distinctId:r,disableGeoip:i}){super.groupIdentifyStateless(e,t,n,{disableGeoip:i},r)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(e){let t=e=>Object.fromEntries(e.map(e=>[e,!0]));if(!1===e){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(e)){this._flagOverrides=t(e);return}if(this._isFeatureFlagOverrideOptions(e)){`flags`in e&&(!1===e.flags?this._flagOverrides=void 0:Array.isArray(e.flags)?this._flagOverrides=t(e.flags):e.flags!==void 0&&(this._flagOverrides={...e.flags})),`payloads`in e&&(!1===e.payloads?this._payloadOverrides=void 0:e.payloads!==void 0&&(this._payloadOverrides={...e.payloads}));return}this._flagOverrides={...e}}_isFeatureFlagOverrideOptions(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;if(`flags`in t){let e=t.flags;if(!1===e||Array.isArray(e)||typeof e==`object`&&e)return!0}if(`payloads`in t){let e=t.payloads;if(!1===e||typeof e==`object`&&e)return!0}return!1}withContext(e,t,n){return this.context?this.context.run(e,t,n):t()}getContext(){return this.context?.get()}enterContext(e,t){this.context?.enter(e,t)}async _shutdown(e){let t=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(e),this.errorTracking.shutdown();try{return await super._shutdown(e)}finally{t?.()}}async _requestRemoteConfigPayload(e){if(!this.options.personalApiKey)return;let t=`${this.host}/api/projects/@current/feature_flags/${e}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,Authorization:`Bearer ${this.options.personalApiKey}`}},r=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout==`number`){let e=new AbortController;r=Ub(()=>{e.abort()},this.options.requestTimeout),n.signal=e.signal}try{return await this.fetch(t,n)}catch(e){this._events.emit(`error`,e);return}finally{r&&clearTimeout(r)}}extractPropertiesFromEvent(e,t){if(!e)return{personProperties:{},groupProperties:{}};let n={},r={};for(let[i,a]of Object.entries(e))if(gb(a)&&t&&i in t){let e={};for(let[t,n]of Object.entries(a))e[String(t)]=String(n);r[String(i)]=e}else n[String(i)]=String(a);return{personProperties:n,groupProperties:r}}async getFeatureFlagsForEvent(e,t,n,r){let i=r?.personProperties||{},a=r?.groupProperties||{},o=r?.flagKeys;if(r?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return(await super.getFeatureFlagsStateless(e,t,i,a,n)).flags}addLocalPersonAndGroupProperties(e,t,n,r){let i={distinct_id:e,...n||{}},a={};if(t)for(let e of Object.keys(t))a[e]={$group_key:t[e],...r?.[e]||{}};return{allPersonProperties:i,allGroupProperties:a}}createFeatureFlagEvaluationContext(e,t,n,r){return{distinctId:e,groups:t||{},personProperties:n||{},groupProperties:r||{},evaluationCache:{}}}captureException(e,t,n,r){if(!Ux.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(Ux.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!Ux.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(Ux.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.captureImmediate(e)))}}async prepareEventMessage(e){let{distinctId:t,event:n,properties:r,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c}=e,l=this.context?.get(),u=t||l?.distinctId,d={...this.props,...l?.properties||{},...r||{}};u||(u=Qy(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:u,event:n,properties:d,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c});if(!f)return Promise.reject(null);let p=await Promise.resolve().then(async()=>{if(a){let e=typeof a==`object`?a:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,i,s,e)}return f.event,{}}).then(e=>{let t={};if(e)for(let[n,r]of Object.entries(e))t[`$feature/${n}`]=r;let n=Object.keys(e||{}).filter(t=>e?.[t]!==!1).sort();return n.length>0&&(t.$active_feature_flags=n),t}).catch(()=>({})).then(e=>({...e,...f.properties||{},$groups:f.groups||i}));return f.event===`$pageview`&&this.options.__preview_capture_bot_pageviews&&typeof p.$raw_user_agent==`string`&&nb(p.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event=`$bot_pageview`,p.$browser_type=`bot`),{distinctId:f.distinctId,event:f.event,properties:p,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(e){let t=this.options.before_send;if(!t)return e;let n=Array.isArray(t)?t:[t],r=e;for(let t of n){if(r=t(r),!r)return this._logger.info(`Event '${e.event}' was rejected in beforeSend function`),null;if(!r.properties||Object.keys(r.properties).length===0){let e=`Event '${r.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(e)}}return r}},fS=class{constructor(){this.storage=new sa}get(){return this.storage.getStore()}run(e,t,n){return this.storage.run(this.resolve(e,n),t)}enter(e,t){this.storage.enterWith(this.resolve(e,t))}resolve(e,t){if(t?.fresh===!0)return e;let n=this.get()||{};return{distinctId:e.distinctId??n.distinctId,sessionId:e.sessionId??n.sessionId,properties:{...n.properties||{},...e.properties||{}}}}};const pS=`posthog-node`;function mS(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(i===`*`||i.includes(o.level)))return o;o.tags||={};let s=o.tags[hS.POSTHOG_ID_TAG];if(s===void 0)return o;let c=e.options.host??`https://us.i.posthog.com`,l=new URL(`/project/${e.apiKey}/person/${s}`,c).toString();o.tags[`PostHog Person URL`]=l;let u=o.exception?.values||[],d=u.map(e=>({...e,stacktrace:e.stacktrace?{...e.stacktrace,type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>({...e,platform:`node:javascript`}))}:void 0})),f={$exception_message:u[0]?.value||o.message,$exception_type:u[0]?.type,$exception_level:o.level,$exception_list:d,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:u[0]?.value||o.message,$sentry_exception_type:u[0]?.type,$sentry_tags:o.tags};return t&&n&&(f.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&e.capture({event:`$exception`,distinctId:s,properties:f}),o}}var hS=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=pS,this.name=pS,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(mS(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};Ux.errorPropertiesBuilder=new ax([new xx,new hx,new bx,new _x,new Sx],mx(`node:javascript`,cx),[Ry(),Ex]);const gS=new class extends dS{getLibraryId(){return`posthog-node`}initializeContext(){return new fS}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`}),_S=Jn({email:z});var vS=class extends tn()(`@expect/AnalyticsProvider`){static layerPostHog=Hn(this)({capture:e=>rr(()=>{gS.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>rr(()=>{gS.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:Ir({try:()=>gS.flush(),catch:e=>e}).pipe(C)});static layerDev=Hn(this)({capture:e=>ke(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(or({module:`Analytics`})),identify:e=>ke(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(or({module:`Analytics`})),flush:gn})},yS=class extends tn()(`@expect/Analytics`,{make:O(function*(){let e=yield*vS,t=yield*Nr,n=yield*Ir(()=>(0,Ay.machineId)()).pipe($e),r=Ly(process.cwd()),i=R(`getClaudeCodeEmail`)(function*(){let e=yield*t.string(Wn(`claude`,[`auth`,`status`])).pipe(sr(`5 seconds`));return(yield*Wt(Zr(_S))(e)).email}),a=R(`getGitEmail`)(function*(){let e=yield*t.string(Wn(`git`,[`config`,`user.email`])).pipe(sr(`5 seconds`),L(e=>e.trim()));return e.length===0?yield*bn(`empty`):e}),o=R(`getGitName`)(function*(){let e=yield*t.string(Wn(`git`,[`config`,`user.name`])).pipe(sr(`5 seconds`),L(e=>e.trim()));return e.length===0?yield*bn(`empty`):e});yield*xr({email:i().pipe(V(`PlatformError`,()=>a()),V(`TimeoutError`,()=>a()),V(`SchemaError`,()=>a())),name:o().pipe(sn(()=>B(void 0)))}).pipe(Sr(({email:t,name:r})=>e.identify({distinctId:n,email:t,name:r})),sn(()=>gn),ct);let s=(t,...[i])=>O(function*(){let a={timestamp:new Date().toISOString(),projectId:r};yield*e.capture({eventName:t,properties:{...a,...i??{}},distinctId:n})}).pipe(sn(e=>Pe(`Analytics capture failed`,{eventName:t,cause:e}).pipe(or({module:`Analytics`}))));return{capture:s,track:((e,t)=>n=>Sr(n,n=>{let r=t?t(n):void 0;return s.call(void 0,e,...r===void 0?[]:[r])})),flush:e.flush}})}){static layerPostHog=b(this)(this.make).pipe(w(vS.layerPostHog),w(Ii.layer));static layerDev=b(this)(this.make).pipe(w(vS.layerDev),w(Ii.layer))};const bS=e=>{let t=tr(e);return{error_tag:jt(t,`_tag`)?String(t._tag):`Unknown`,error_message:kr(e)}};(class extends tn()(`@expect/ErrorHandler`,{make:O(function*(){let e=yield*yS;return{orDie:t=>t.pipe(Mn(t=>e.capture(`error:unexpected`,bS(t))),$e),streamOrDie:t=>t.pipe(gt(t=>e.capture(`error:unexpected`,bS(t))),Me),tapCause:(...t)=>n=>n.pipe(Mn(n=>xr([e.capture(`error:expected`,bS(n)),In(...t,n)],{discard:!0})))}})}){static layer=b(this)(this.make)});const xS=na()(la(e=>({agentBackend:`claude`,browserHeaded:!1,replayHost:`https://expect.dev`,autoSaveFlows:!0,notifications:void 0,instructionHistory:[],setAgentBackend:t=>e({agentBackend:t}),toggleAutoSave:()=>e(e=>({autoSaveFlows:!e.autoSaveFlows})),toggleNotifications:()=>e(e=>({notifications:e.notifications!==!0})),rememberInstruction:t=>{t&&e(e=>({instructionHistory:[t,...e.instructionHistory.filter(e=>e!==t)].slice(0,20)}))}}),{name:`prompt-history`,storage:ca(()=>Rv),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),SS=yS.layerPostHog,CS=(e,...[t])=>N(O(function*(){let n=yield*yS;yield*n.capture.call(n,e,...t===void 0?[]:[t])}).pipe(sn(()=>gn),m(SS))),wS=()=>CS(`session:started`,{mode:`interactive`,skip_planning:!1,browser_headed:xS.getState().browserHeaded}),TS=e=>N(O(function*(){let t=yield*yS;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush}).pipe(m(SS))),ES=()=>{let e=vi(11);if(e[0]!==`22e44f7492e404ec9264543e8c0bccc53524e2de50e4e8b699cdcbe65e792e34`){for(let t=0;t<11;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`22e44f7492e404ec9264543e8c0bccc53524e2de50e4e8b699cdcbe65e792e34`}let t=mo(),n,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=K(W,{color:`red`,children:J.cross}),r=K(W,{color:`green`,children:J.tick}),e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]===t.PRIMARY?i=e[4]:(i=K(W,{bold:!0,color:t.PRIMARY,children:` Expect`}),e[3]=t.PRIMARY,e[4]=i);let a;e[5]===t.DIM?a=e[6]:(a=K(W,{color:t.DIM,children:` v${Xa}`}),e[5]=t.DIM,e[6]=a);let o;return e[7]!==t.BORDER||e[8]!==i||e[9]!==a?(o=K(U,{children:q(W,{color:t.BORDER,children:[n,r,i,a]})}),e[7]=t.BORDER,e[8]=i,e[9]=a,e[10]=o):o=e[10],o},DS=[{id:`enable-sync`,label:`Use existing cookies`,detail:`Recommended. Uses your browser session as-is.`},{id:`run-without-sync`,label:`Skip cookies`,detail:`Not recommended. Tests requiring login will fail.`}],OS=e=>{let t=vi(34);if(t[0]!==`e3c7abb53538ed236081ea9ec92e2272ee1c8b466fbb62e1c8ec442744cd59e3`){for(let e=0;e<34;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e3c7abb53538ed236081ea9ec92e2272ee1c8b466fbb62e1c8ec442744cd59e3`}let{changesFor:n,instruction:r,savedFlow:i}=e,a=mo(),o=Sy(kS),[s,c]=G(0),l;t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==o?(l=e=>{let t=e.id===`enable-sync`;CS(`cookies:sync_choice`,{choice:t?`use_cookies`:`skip_cookies`}),o(xy({changesFor:n,instruction:r,savedFlow:i,requiresCookies:t}))},t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=l):l=t[5];let u=l,d;t[6]!==u||t[7]!==s?(d=(e,t)=>{(t.downArrow||e===`j`||t.ctrl&&e===`n`)&&c(AS),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&c(jS),e===`c`&&u(DS[0]),e===`a`&&u(DS[1]),t.return&&u(DS[s])},t[6]=u,t[7]=s,t[8]=d):d=t[8],fi(d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=K(ES,{}),t[9]=f):f=t[9];let p;t[10]===a.DIM?p=t[11]:(p=K(W,{color:a.DIM,children:J.pointerSmall}),t[10]=a.DIM,t[11]=p);let m;t[12]!==a.TEXT||t[13]!==r?(m=K(W,{color:a.TEXT,children:r}),t[12]=a.TEXT,t[13]=r,t[14]=m):m=t[14];let h;t[15]!==p||t[16]!==m?(h=q(U,{children:[f,q(W,{wrap:`truncate`,children:[` `,p,` `,m]})]}),t[15]=p,t[16]=m,t[17]=h):h=t[17];let g;t[18]!==a.GREEN||t[19]!==a.YELLOW||t[20]!==s?(g=K(U,{marginTop:1,children:s===0?q(W,{color:a.GREEN,children:[J.tick,` Your signed-in session will be synced to the browser. Cookies stay on device.`]}):q(W,{color:a.YELLOW,children:[J.warning,` The browser won`,`'`,`t inherit your signed-in session without cookies.`]})}),t[18]=a.GREEN,t[19]=a.YELLOW,t[20]=s,t[21]=g):g=t[21];let _;t[22]!==a.DIM||t[23]!==a.PRIMARY||t[24]!==a.TEXT||t[25]!==u||t[26]!==s?(_=DS.map((e,t)=>{let n=t===s;return K(_o,{onClick:()=>{c(t),u(e)},children:q(U,{flexDirection:`column`,marginBottom:1,children:[q(W,{children:[K(W,{color:n?a.PRIMARY:a.DIM,children:n?`${J.pointer} `:` `}),K(W,{color:n?a.PRIMARY:a.TEXT,bold:n,children:e.label})]}),q(W,{color:a.DIM,children:[` `,e.detail]})]})},e.id)}),t[22]=a.DIM,t[23]=a.PRIMARY,t[24]=a.TEXT,t[25]=u,t[26]=s,t[27]=_):_=t[27];let v;t[28]===_?v=t[29]:(v=K(U,{flexDirection:`column`,marginTop:1,children:_}),t[28]=_,t[29]=v);let y;return t[30]!==h||t[31]!==g||t[32]!==v?(y=q(U,{flexDirection:`column`,width:`100%`,paddingY:1,paddingX:1,children:[h,g,v]}),t[30]=h,t[31]=g,t[32]=v,t[33]=y):y=t[33],y};function kS(e){return e.setScreen}function AS(e){return Math.min(DS.length-1,e+1)}function jS(e){return Math.max(0,e-1)}const MS=na()(la(e=>({cookiesEnabled:!1,setCookiesEnabled:t=>e({cookiesEnabled:t}),toggleCookies:()=>e(e=>({cookiesEnabled:!e.cookiesEnabled})),lastBaseUrl:void 0,setLastBaseUrl:t=>e({lastBaseUrl:t})}),{name:`project-preferences`,storage:ca(()=>Vv)})),NS=`spotify,raycast,google,controlce,controlcenter,cursor,electron,slack,discord,figma,redis,postgres,mysqld,mongod,mongos,memcached,dockerd,containerd,com.docke,docker,code,rapportd,wifiagent,airplayxpc,identitys,sharingd,bluetoothd,screencap,loginwind,systempol,corespeec,apsd,mds_store,spotlight,lsd`.split(`,`),PS=[[/next[\\/]dist[\\/]/,`next`],[/next-server/,`next`],[/vite[\\/]/,`vite`],[/vite-plus[\\/]/,`vite`],[/react-scripts[\\/]/,`react-scripts`],[/angular[\\/]cli[\\/]/,`angular`],[/remix[\\/]/,`remix`],[/astro[\\/]/,`astro`],[/nuxt[\\/]/,`nuxt`],[/svelte[\\/]/,`svelte`],[/webpack[\\/]/,`webpack`],[/webpack-dev-server/,`webpack`],[/turbopack[\\/]/,`turbopack`],[/remotion[\\/]/,`remotion`],[/gatsby[\\/]/,`gatsby`],[/parcel[\\/]/,`parcel`],[/http-server/,`http-server`],[/live-server/,`live-server`],[/serve[\\/]/,`serve`],[/express[\\/]/,`express`],[/fastify[\\/]/,`fastify`],[/hono[\\/]/,`hono`],[/elysia[\\/]/,`elysia`]],FS=e=>{let t=e.toLowerCase();return NS.some(e=>t.startsWith(e))},IS=e=>{if(!/^\d+$/.test(e))return``;try{let t=Wi(`lsof -p ${e} -a -d cwd -Fn`,{encoding:`utf-8`,timeout:1e3}).split(`
|
|
36
|
+
`).find(e=>e.startsWith(`n`));return t?t.slice(1):``}catch{return``}},LS=(e,t)=>{if(!/^\d+$/.test(e)||FS(t))return;let n=IS(e);try{let t=Wi(`ps -p ${e} -o command=`,{encoding:`utf-8`,timeout:1e3}).trim();for(let[e,r]of PS)if(e.test(t))return{name:r,isFramework:!0,cwd:n}}catch{}return{name:t,isFramework:!1,cwd:n}},RS=e=>{let t=new Set,n=[];for(let r of e.split(`
|
|
37
|
+
`)){let e=r.trim().split(/\s+/);if(e.length<9)continue;let i=e[0]??``,a=e[1]??``,o=(e[8]??``).match(/:(\d+)$/);if(!o)continue;let s=Number(o[1]);s<1024||s>65535||t.has(s)||(t.add(s),n.push({port:s,pid:a,commandName:i}))}return n},zS=()=>{try{let e=RS(Wi(`lsof -iTCP -sTCP:LISTEN -nP`,{encoding:`utf-8`,timeout:3e3})),t=[];for(let n of e){let e=LS(n.pid,n.commandName);e!==void 0&&(n.port>=32768&&!e.isFramework||t.push({port:n.port,processName:e.name,cwd:e.cwd}))}return t.sort((e,t)=>e.port-t.port)}catch{return[]}},BS=()=>_i({queryKey:[`listening-ports`],queryFn:()=>zS(),refetchInterval:5e3}),VS=e=>`http://localhost:${e}`,HS=(e,t)=>{let n=t.toLowerCase();return String(e.port).includes(n)||e.processName.toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n)},US=e=>{let t=e.trim(),n=Number(t);if(Number.isInteger(n)&&n>=1&&n<=65535)return n;let r=t.match(/:(\d+)\/?$/);if(r){let e=Number(r[1]);if(Number.isInteger(e)&&e>=1&&e<=65535)return e}},WS=e=>{let t=vi(178);if(t[0]!==`84a93f0b7994a0f9318ab42167dadcad0ffba85a300830ca86b74045fc7574ce`){for(let e=0;e<178;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`84a93f0b7994a0f9318ab42167dadcad0ffba85a300830ca86b74045fc7574ce`}let{changesFor:n,instruction:r,savedFlow:i,requiresCookies:a}=e,o=mo(),s=Sy(GS),c=MS(KS),l=MS(qS),{data:u}=BS(),d=u===void 0?[]:u,[f,p]=G(!1),[m,h]=G(``),[g,_]=G(!1),[v,y]=G(``),b;t[1]===c?b=t[2]:(b=()=>{if(!c)return new Set;let e=c.match(/:(\d+)/);return e?new Set([Number(e[1])]):new Set},t[1]=c,t[2]=b);let[x,ee]=G(b),S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=new Set,t[3]=S):S=t[3];let[C,w]=G(S),T=d.map(JS),E=m?T.filter(e=>HS(e,m)):T,D=E.length,O=E.length+1,te=E.length+2,ne;t[4]===te?ne=t[5]:(ne={itemCount:te,visibleCount:10},t[4]=te,t[5]=ne);let{highlightedIndex:k,setHighlightedIndex:A,scrollOffset:j,handleNavigation:re}=_y(ne),M;t[6]!==n||t[7]!==C||t[8]!==r||t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==s?(M=e=>{let t=[...e,...C];l(t.length>0?t[0]:void 0),t.length===0?CS(`port:skipped`):CS(`port:selected`,{port_count:t.length,has_custom_url:C.size>0}),s(by.Testing({changesFor:n,instruction:r,savedFlow:i,requiresCookies:a,baseUrls:t.length>0?t:void 0}))},t[6]=n,t[7]=C,t[8]=r,t[9]=a,t[10]=i,t[11]=l,t[12]=s,t[13]=M):M=t[13];let ie=M,ae;t[14]===ee?ae=t[15]:(ae=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[14]=ee,t[15]=ae);let N=ae,oe;t[16]!==D||t[17]!==C||t[18]!==E||t[19]!==k||t[20]!==ie||t[21]!==x||t[22]!==_||t[23]!==O?(oe=()=>{if(k===O){ie([]);return}if(x.size>0||C.size>0){ie([...x].sort(YS).map(VS));return}if(k===D){_(!0);return}let e=E[k];e&&ie([VS(e.port)])},t[16]=D,t[17]=C,t[18]=E,t[19]=k,t[20]=ie,t[21]=x,t[22]=_,t[23]=O,t[24]=oe):oe=t[24];let se=oe,P=XS,ce;t[25]!==y||t[26]!==w||t[27]!==_?(ce=e=>{let t=e.trim();if(!t){_(!1);return}let n=P(t);w(e=>new Set([...e,n])),y(``),_(!1)},t[25]=y,t[26]=w,t[27]=_,t[28]=ce):ce=t[28];let le=ce,ue;t[29]===w?ue=t[30]:(ue=e=>{w(t=>{let n=new Set(t);return n.delete(e),n})},t[29]=w,t[30]=ue);let de=ue,F;t[31]!==A||t[32]!==h?(F=e=>{h(e),A(0)},t[31]=A,t[32]=h,t[33]=F):F=t[33];let fe=F,pe;t[34]!==p||t[35]!==h||t[36]!==N?(pe=e=>{let t=US(e);if(t){N(t),p(!1),h(``);return}p(!1)},t[34]=p,t[35]=h,t[36]=N,t[37]=pe):pe=t[37];let me=pe,he;t[38]!==se||t[39]!==D||t[40]!==E||t[41]!==re||t[42]!==k||t[43]!==g||t[44]!==f||t[45]!==y||t[46]!==_||t[47]!==p||t[48]!==N?(he=(e,t)=>{if(g){if(t.escape){_(!1),y(``);return}return}if(f){if(t.escape){p(!1);return}return}if(!re(e,t)){if(e===`/`){p(!0);return}if(e===` `){if(k===D){_(!0);return}let e=E[k];e&&N(e.port);return}t.return&&se()}},t[38]=se,t[39]=D,t[40]=E,t[41]=re,t[42]=k,t[43]=g,t[44]=f,t[45]=y,t[46]=_,t[47]=p,t[48]=N,t[49]=he):he=t[49],fi(he);let ge,_e,ve,I,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae;if(t[50]!==o.DIM||t[51]!==o.GREEN||t[52]!==o.PRIMARY||t[53]!==o.TEXT||t[54]!==o.YELLOW||t[55]!==D||t[56]!==C||t[57]!==E||t[58]!==k||t[59]!==r||t[60]!==j||t[61]!==x||t[62]!==A||t[63]!==O||t[64]!==N){let e=E.slice(j,j+8);ve=j+8>=E.length,be=ve;let n=E[k];I=k===D,ye=k===O;let i;t[81]!==C||t[82]!==x?(i=[...[...x].sort(ZS).map(VS),...C],t[81]=C,t[82]=x,t[83]=i):i=t[83];let a=i;_e=U,we=`column`,Te=`100%`,Ee=1,De=1;let s;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(s=K(ES,{}),t[84]=s):s=t[84];let c;t[85]===o.DIM?c=t[86]:(c=K(W,{color:o.DIM,children:J.pointerSmall}),t[85]=o.DIM,t[86]=c);let l;t[87]!==o.TEXT||t[88]!==r?(l=K(W,{color:o.TEXT,children:r}),t[87]=o.TEXT,t[88]=r,t[89]=l):l=t[89],t[90]!==c||t[91]!==l?(Oe=q(U,{children:[s,q(W,{wrap:`truncate`,children:[` `,c,` `,l]})]}),t[90]=c,t[91]=l,t[92]=Oe):Oe=t[92],t[93]===o.DIM?ke=t[94]:(ke=K(U,{marginTop:1,children:K(W,{color:o.DIM,children:`Pick the dev server the agent should open in the browser.`})}),t[93]=o.DIM,t[94]=ke);let u;t[95]!==o.GREEN||t[96]!==a?(u=a.length>0&&q(W,{color:o.GREEN,children:[J.tick,` `,a.join(`, `)]}),t[95]=o.GREEN,t[96]=a,t[97]=u):u=t[97];let d;t[98]!==o.DIM||t[99]!==a.length||t[100]!==n||t[101]!==I||t[102]!==ye?(d=a.length===0&&!ye&&!I&&n&&q(W,{color:o.DIM,children:[J.arrowRight,` `,VS(n.port)]}),t[98]=o.DIM,t[99]=a.length,t[100]=n,t[101]=I,t[102]=ye,t[103]=d):d=t[103];let f;t[104]!==o.YELLOW||t[105]!==a.length||t[106]!==ye?(f=a.length===0&&ye&&q(W,{color:o.YELLOW,children:[J.warning,` No base URL. The agent won`,`'`,`t know where your dev server is.`]}),t[104]=o.YELLOW,t[105]=a.length,t[106]=ye,t[107]=f):f=t[107],t[108]!==u||t[109]!==d||t[110]!==f?(Ae=q(U,{marginTop:1,children:[u,d,f]}),t[108]=u,t[109]=d,t[110]=f,t[111]=Ae):Ae=t[111],ge=U,xe=`column`,Se=1;let p;t[112]!==o.DIM||t[113]!==o.PRIMARY||t[114]!==o.TEXT||t[115]!==k||t[116]!==j||t[117]!==x||t[118]!==A||t[119]!==N?(p=(e,t)=>{let n=t+j,r=n===k,i=x.has(e.port);return K(_o,{onClick:()=>{A(n),N(e.port)},children:q(U,{children:[K(W,{color:r?o.PRIMARY:o.DIM,children:r?`${J.pointer} `:` `}),q(W,{color:i?o.PRIMARY:o.DIM,children:[i?J.checkboxOn:J.checkboxOff,` `]}),q(W,{color:r?o.PRIMARY:o.TEXT,bold:r,children:[`:`,e.port]}),e.processName&&q(W,{color:o.DIM,children:[` `,e.processName]}),e.cwd&&q(W,{color:o.DIM,children:[` `,e.cwd]})]})},e.port)},t[112]=o.DIM,t[113]=o.PRIMARY,t[114]=o.TEXT,t[115]=k,t[116]=j,t[117]=x,t[118]=A,t[119]=N,t[120]=p):p=t[120],Ce=e.map(p),t[50]=o.DIM,t[51]=o.GREEN,t[52]=o.PRIMARY,t[53]=o.TEXT,t[54]=o.YELLOW,t[55]=D,t[56]=C,t[57]=E,t[58]=k,t[59]=r,t[60]=j,t[61]=x,t[62]=A,t[63]=O,t[64]=N,t[65]=ge,t[66]=_e,t[67]=ve,t[68]=I,t[69]=ye,t[70]=be,t[71]=xe,t[72]=Se,t[73]=Ce,t[74]=we,t[75]=Te,t[76]=Ee,t[77]=De,t[78]=Oe,t[79]=ke,t[80]=Ae}else ge=t[65],_e=t[66],ve=t[67],I=t[68],ye=t[69],be=t[70],xe=t[71],Se=t[72],Ce=t[73],we=t[74],Te=t[75],Ee=t[76],De=t[77],Oe=t[78],ke=t[79],Ae=t[80];let je;t[121]!==o.DIM||t[122]!==o.PRIMARY||t[123]!==o.TEXT||t[124]!==D||t[125]!==v||t[126]!==ve||t[127]!==le||t[128]!==I||t[129]!==g||t[130]!==y||t[131]!==A||t[132]!==_?(je=ve&&K(_o,{onClick:()=>{A(D),_(!0)},children:q(U,{children:[K(W,{color:I?o.PRIMARY:o.DIM,children:I?`${J.pointer} `:` `}),g&&q(U,{children:[K(W,{color:o.PRIMARY,children:`URL: `}),K(Co,{focus:!0,value:v,placeholder:`http://localhost:4000 or staging.example.com`,onChange:y,onSubmit:le})]}),!g&&q(W,{color:I?o.PRIMARY:o.TEXT,bold:I,children:[`Enter a custom URL`,J.ellipsis]})]})}),t[121]=o.DIM,t[122]=o.PRIMARY,t[123]=o.TEXT,t[124]=D,t[125]=v,t[126]=ve,t[127]=le,t[128]=I,t[129]=g,t[130]=y,t[131]=A,t[132]=_,t[133]=je):je=t[133];let Me;t[134]!==o.DIM||t[135]!==o.PRIMARY||t[136]!==o.TEXT||t[137]!==ve||t[138]!==C||t[139]!==de?(Me=ve&&[...C].map(e=>K(_o,{onClick:()=>de(e),children:q(U,{children:[K(W,{children:` `}),q(W,{color:o.PRIMARY,children:[J.checkboxOn,` `]}),K(W,{color:o.TEXT,children:e}),K(W,{color:o.DIM,children:` (click to remove)`})]})},e)),t[134]=o.DIM,t[135]=o.PRIMARY,t[136]=o.TEXT,t[137]=ve,t[138]=C,t[139]=de,t[140]=Me):Me=t[140];let Ne;t[141]!==o.DIM||t[142]!==o.PRIMARY||t[143]!==ye||t[144]!==ie||t[145]!==A||t[146]!==O||t[147]!==be?(Ne=be&&K(_o,{onClick:()=>{A(O),ie([])},children:q(U,{children:[K(W,{color:ye?o.PRIMARY:o.DIM,children:ye?`${J.pointer} `:` `}),q(W,{color:ye?o.PRIMARY:o.DIM,bold:ye,children:[`Skip `,J.arrowRight,` no base URL`]})]})}),t[141]=o.DIM,t[142]=o.PRIMARY,t[143]=ye,t[144]=ie,t[145]=A,t[146]=O,t[147]=be,t[148]=Ne):Ne=t[148];let Pe;t[149]!==o.DIM||t[150]!==E.length||t[151]!==be?(Pe=E.length===0&&!be&&K(W,{color:o.DIM,children:`No matching ports`}),t[149]=o.DIM,t[150]=E.length,t[151]=be,t[152]=Pe):Pe=t[152];let Fe;t[153]!==ge||t[154]!==xe||t[155]!==Se||t[156]!==Ce||t[157]!==je||t[158]!==Me||t[159]!==Ne||t[160]!==Pe?(Fe=q(ge,{flexDirection:xe,marginTop:Se,children:[Ce,je,Me,Ne,Pe]}),t[153]=ge,t[154]=xe,t[155]=Se,t[156]=Ce,t[157]=je,t[158]=Me,t[159]=Ne,t[160]=Pe,t[161]=Fe):Fe=t[161];let Ie;t[162]!==fe||t[163]!==me||t[164]!==f||t[165]!==m?(Ie=K(wo,{isSearching:f,query:m,onChange:fe,onSubmit:me}),t[162]=fe,t[163]=me,t[164]=f,t[165]=m,t[166]=Ie):Ie=t[166];let Le;return t[167]!==_e||t[168]!==we||t[169]!==Te||t[170]!==Ee||t[171]!==De||t[172]!==Oe||t[173]!==ke||t[174]!==Ae||t[175]!==Fe||t[176]!==Ie?(Le=q(_e,{flexDirection:we,width:Te,paddingY:Ee,paddingX:De,children:[Oe,ke,Ae,Fe,Ie]}),t[167]=_e,t[168]=we,t[169]=Te,t[170]=Ee,t[171]=De,t[172]=Oe,t[173]=ke,t[174]=Ae,t[175]=Fe,t[176]=Ie,t[177]=Le):Le=t[177],Le};function GS(e){return e.setScreen}function KS(e){return e.lastBaseUrl}function qS(e){return e.setLastBaseUrl}function JS(e){return{port:e.port,processName:e.processName,cwd:e.cwd}}function YS(e,t){return e-t}function XS(e){let t=e.trim(),n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?VS(n):/^https?:\/\//i.test(t)?t:`http://${t}`}function ZS(e,t){return e-t}const QS={"~effect/reactivity/AsyncResult":{E:yr,A:yr},pipe(){return Kt(this,arguments)},[ce](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return _t(this.value,e.value);case`Failure`:return _t(this.cause,e.cause)}},[ye](){let e=ae(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:ft(e)(this._tag===`Success`?xt(this.value):xt(this.cause))}},$S=e=>e.waiting,eC=(e,t)=>e._tag===`Success`?aC(e.value):cC(e.cause,{previous:t}),tC=e=>e._tag===`None`?rC(!0):uC(e.value),nC=e=>e._tag===`Initial`,rC=(e=!1)=>{let t=Object.create(QS);return t._tag=`Initial`,t.waiting=e,t},iC=e=>e._tag===`Success`,aC=(e,t)=>{let n=Object.create(QS);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},oC=e=>e._tag===`Failure`,sC=(e,t)=>{let n=Object.create(QS);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??Qe(),n.waiting=t?.waiting??!1,n},cC=(e,t)=>sC(e,{previousSuccess:c(t.previous,e=>iC(e)?ii(e):oC(e)?e.previousSuccess:Qe()),waiting:t.waiting}),lC=(e,t)=>cC(Nt(e),t),uC=(e,t)=>{if(e.waiting)return t?.touch?dC(e):e;let n=Object.assign(Object.create(QS),e);return n.waiting=!0,t?.touch&&iC(n)&&(n.timestamp=Date.now()),n},dC=e=>iC(e)?aC(e.value,{waiting:e.waiting}):e,fC=(e,t)=>e._tag===`Failure`?cC(e.cause,{previous:t,waiting:e.waiting}):e,pC=e=>e._tag===`Success`?ii(e.value):e._tag===`Failure`?F(e.previousSuccess,e=>e.value):Qe(),mC=e=>Ne(pC(e),()=>new _e(`AsyncResult.getOrThrow: no value found`)),hC=e=>new gC(e);var gC=class{constructor(e){this.result=e}result;output=Qe();when(e,t){if(Ue(this.output)&&e(this.result)){let e=t(this.result);A(e)&&(this.output=e)}return this}pipe(){return Kt(this,arguments)}onWaiting(e){return this.when(e=>e.waiting,t=>ii(e(t)))}onInitialOrWaiting(e){return this.when(e=>nC(e)||e.waiting,t=>ii(e(t)))}onInitial(e){return this.when(nC,t=>ii(e(t)))}onSuccess(e){return this.when(iC,t=>ii(e(t.value,t)))}onFailure(e){return this.when(oC,t=>ii(e(t.cause,t)))}onError(e){return this.onErrorIf(i,e)}onErrorIf(e,t){return this.when(oC,n=>Ye(n.cause).pipe(Bn(e),F(e=>t(e,n))))}onErrorTag(e,t){return this.onErrorIf(t=>jt(t,`_tag`)&&(Array.isArray(e)?e.includes(t._tag):t._tag===e),t)}onDefect(e){return this.when(oC,t=>{let n=Rt(t.cause);return Re(n)?Qe():ii(e(n.success,t))})}orElse(e){return Fn(this.output,e)}orNull(){return Oe(this.output)}render(){if(A(this.output))return this.output.value;if(oC(this.result))throw tr(this.result.cause);return null}};const _C=tn(`~effect/reactivity/AtomRegistry`),vC={alive:1,initialized:2,waitingForValue:4},yC={uninitialized:vC.alive|vC.waitingForValue,stale:vC.alive|vC.initialized|vC.waitingForValue,valid:vC.alive|vC.initialized,removed:0},bC={disabled:0,collect:1,commit:2},xC={phase:bC.disabled,depth:0,stale:[],notify:new Set};function SC(e){xC.phase=bC.collect,xC.depth++;try{if(e(),xC.depth===1){for(let e=0;e<xC.stale.length;e++)CC(xC.stale[e]);xC.phase=bC.commit;for(let e of xC.notify)e.notify();xC.notify.clear()}}finally{xC.depth--,xC.depth===0&&(xC.phase=bC.disabled,xC.stale=[])}}function CC(e){if(e.state!==yC.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==yC.valid&&CC(n)}e.state!==yC.valid&&e.value()}}const wC=`~effect/reactivity/Atom`,TC=e=>jt(e,wC),EC=`~effect/reactivity/Atom/Writable`,DC=Or(2,(e,t)=>{let n=yn(t),r=Vt(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?zr(n):void 0})})(0),OC={[wC]:wC,...p,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},kC={...OC,atom(e,t){let n=LC(e,t);return NC(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):fC(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>AC(this,e,t):AC(this,e,t)},pull(e,t){let n=DC(BC(0));return $C(n,NC(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?HC(r,QC(r,n,e,t),rC(!0),a.value):fC(a,i)}))},subscriptionRef(e){return JC(DC(NC(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return fC(r,n);let i=typeof e==`function`?e(t):e;return Ga(i)?i:HC(t,i,rC(!0),r.value)})),(e,t)=>qC(e,t,mC(e(this))))}},AC=(e,t,n)=>{let[r,i,a]=ZC(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return Vn(i)?Ba(i,n.reactivityKeys):_(i,Va(n.reactivityKeys))}:t,n);return PC(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):fC(i,n)},i)},jC={...OC,[EC]:EC},MC=e=>EC in e,NC=(e,t)=>{let n=Object.create(OC);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},PC=(e,t,n)=>{let r=Object.create(jC);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function FC(e,t){e.setSelf(t)}const IC=(e,t)=>{let n=LC(e,t);return`~effect/reactivity/Atom`in n?n:NC(n)},LC=(e,t)=>{if(typeof e==`function`&&!Vn(e)&&!ee(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:RC in i?VC(e,i,t,r):zC in i?GC(e,i,t,r):i;default:return i}}}else if(Vn(e))return function(n,r){return VC(n,e,t,r)};else if(ee(e))return function(n,r){return GC(n,e,t,r)};return BC(e)},RC=`~effect/Effect`,zC=`~effect/Stream`,BC=e=>PC(function(t){return e},FC),VC=(e,t,n,r)=>HC(e,t,n?.initialValue===void 0?rC():aC(n.initialValue),r,n?.uninterruptible);function HC(e,t,n,r=Pr(),i=!1){let a=e.self(),o=We();e.addFinalizer(()=>{St(r)(Fe(o,_r))});let s=new Map(r.mapUnsafe);s.set(Ln.key,o),s.set(_C.key,e.registry),s.set(wr.key,e.registry.scheduler);let c,l=!1,u=UC(hn(s),t,function(t){c=eC(t,a),l&&e.setSelf(c)},i);return l=!0,u!==void 0&&e.addFinalizer(u),c===void 0?a._tag===`Some`?tC(a):uC(n):c}function UC(e,t,n,r=!1){if(mt(t)){n(t);return}let i=St(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}const WC=(e=>{let t=Ha;function n(r){let i=Object.create(kC);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=ew(NC(typeof r==`function`?e=>Be(r(e),t):()=>Be(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return VC(t,ei(Mt,t=>it(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=Be(t,w(e,Ha))};let r=DC(IC(a(t=>it(Ha,e.memoMap,on(t,Ln))).pipe(L(on(La)))));return n.withReactivity=e=>t=>tw(t,n=>{let i=mC(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:lt()});WC.withReactivity;const GC=(e,t,n,r)=>KC(e,t,n?.initialValue===void 0?rC():aC(n.initialValue),r);function KC(e,t,n,r=Pr()){let a=e.self();r=Gn(r,_C,e.registry);let o=Lt(n=>ei(je(t.channel,n),t=>fr({while:i,body:()=>t,step(t){e.setSelf(aC(Ur(t),{waiting:!0}))}}))).pipe(sn(t=>(xn(t)?kn(e.self(),c(pC),Ce({onNone:()=>e.setSelf(lC(new _e,{previous:e.self()})),onSome:t=>e.setSelf(aC(t))})):e.setSelf(cC(t,{previous:e.self()})),gn))),s=new Map(r.mapUnsafe);s.set(_C.key,e.registry),s.set(wr.key,e.registry.scheduler);let l=UC(hn(s),o,un,!1);return l!==void 0&&e.addFinalizer(l),a._tag===`Some`?tC(a):uC(n)}const qC=(e,t,n=Pr())=>Ga(t)?(e.addFinalizer(Ka(t).pipe(Se(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return gn}),le(n))),ge(n)(qa(t))):t._tag===`Success`?KC(e,Ka(t.value),rC(!0),n):t,JC=(e,t)=>{function n(t,n){let r=t.get(e);Ga(r)?gr(Ya(r,n)):iC(r)&&gr(Ya(r.value,n))}return PC(n=>{let r=n(e);return Ga(r)||iC(r)?t(n,r):r},n)},YC=Symbol.for(`effect/reactivity/atom/Atom/Reset`),XC=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`);function ZC(e,t){let n=DC(BC([0,void 0])),r=t?.initialValue===void 0?rC():aC(t.initialValue),i=t?.concurrent?DC(NC(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===XC)return cC(dn(),{previous:t.self()});let l=e(c,t);return RC in l?(o&&(l=ei(Wr(l,{startImmediately:!0}),e=>(o.add(e),e.addObserver(()=>o.delete(e)),L(se(o),e=>e[0])))),HC(t,l,r,a,!1)):KC(t,l,r,a)}function o(e,t){rw(()=>{t===YC?e.set(n,[0,void 0]):t===XC?e.set(n,[e.get(n)[0]+1,XC]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}const QC=(e,t,n,r)=>ei(P(typeof n==`function`?n(e):n),n=>{let i=ht().services,a=Zt(),o=j(n,{onFailure(e){return xn(e)?v(a)?B({done:!0,items:a}):bn(new _e(`Atom.pull: no items`)):Ht(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=$r(a,e),a=t),B({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(tC(e.self()));let t;t=UC(i,o,n=>{t&&s.delete(t);let r=eC(n,e.self()),i=s.size>0;e.setSelf(i?uC(r):r)}),t&&s.add(t)}),o}),$C=(e,t)=>PC(t.read,function(t,n){t.set(e,t.get(e)+1)}),ew=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),tw=Or(e=>TC(e[0]),(e,t,n)=>{let r=DC(MC(e)?PC(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):NC(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=nw(n.initialValueTarget)),r}),nw=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},rw=SC,iw=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},aw=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,ow=(e,t,n)=>e+(t-e)*n,sw=(e,t,n)=>{let[r,i,a]=iw(e),[o,s,c]=iw(t);return aw(ow(r,o,n),ow(i,s,n),ow(a,c,n))},cw=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[i,a]=G(-16),o=wi(r);o.current=r;let s=wi(e.length);s.current=e.length;let c=wi(!1);return c.current||(c.current=!0,setTimeout(()=>{setInterval(()=>{let e=s.current+16;a(t=>t>=e?-16:t+o.current)},50)},0)),K(W,{children:[...e].map((e,r)=>{let a=Math.abs(r-i),o=Math.max(0,1-a/16);return K(W,{color:o>0?sw(t,n,o):t,children:e},r)})})},lw=na(e=>({executedPlan:void 0,expanded:!1,setExecutedPlan:t=>e({executedPlan:t}),setExpanded:t=>e({expanded:t}),toggleExpanded:()=>e(e=>({expanded:!e.expanded}))})),uw=e=>ma(Math.max(0,e),{secondsDecimalDigits:0}),dw=new Set([`warpterminal`]),fw=ga.stdout,pw=ha({preferOuter:!0}),mw=process.stdout.isTTY&&!dw.has(pw??``),hw=mw&&fw.kitty,gw=mw&&fw.iterm2,_w=hw||gw,vw=ha(),yw=vw===`tmux`||vw===`screen`,bw=e=>yw?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,xw=(e,t)=>{let n=Buffer.from(e).toString(`base64`),r=`a=T,t=f`;return t.width&&(r+=`,c=${t.width}`),t.height&&(r+=`,r=${t.height}`),bw(`_G${r};${n}\\`)},Sw=(e,t)=>{let n=`\x1B]1337;File=inline=1`;return t.width&&(n+=`;width=${t.width}`),t.height&&(n+=`;height=${t.height}`),n+=`;size=${e.byteLength}:${e.toString(`base64`)}`,bw(n)},Cw=(e,t={})=>{if(!Zi.existsSync(e))return null;if(hw)return xw(e,t);if(gw)try{return Sw(Zi.readFileSync(e),t)}catch{return null}return null},ww=e=>e.startsWith(`file://`),Tw=e=>{let t=vi(9);if(t[0]!==`edb58922a19f7cd34125950b48961a70defca0454a8de685a54dc50281109929`){for(let e=0;e<9;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`edb58922a19f7cd34125950b48961a70defca0454a8de685a54dc50281109929`}let{path:n,label:r}=e,i,a;t[1]===n?(i=t[2],a=t[3]):(i=ww(n)?ji.fileURLToPath(n):Di.resolve(n),a=ww(n)?n:ji.pathToFileURL(i).href,t[1]=n,t[2]=i,t[3]=a);let o=a,s=r??i,c;t[4]===s?c=t[5]:(c=K(W,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==o||t[7]!==c?(l=K(_a,{url:o,children:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l},Ew=({src:e,alt:t,width:n,height:r})=>{let i=Di.resolve(e),{write:a}=pi(),o=wi(!1);if(!o.current){let e=Cw(i,{width:n,height:r});e&&(a(e+`
|
|
38
|
+
`),o.current=!0)}return _w?null:K(Tw,{path:i,label:t})},Dw=({error:e,type:t})=>{if(!e.message)return null;let n=mo(),r=t===`defect`;return q(U,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:n.ERROR_BG,width:`100%`,flexDirection:`column`,gap:0,children:[K(U,{paddingBottom:1,children:q(W,{color:n.RED,bold:!0,children:[J.warning,` `,e.displayName??e._tag]})}),K(U,{paddingBottom:1,children:K(W,{color:n.DIM,children:e.message})}),r&&q(W,{color:n.DIM,children:[`This is a bug. Report it at`,` `,K(W,{color:n.YELLOW,children:`https://github.com/millionco/expect/issues`})]}),q(W,{color:n.DIM,children:[`Press `,K(W,{color:n.RED,children:`esc`}),` to return`]})]})},Ow=e=>{let t=vi(4);if(t[0]!==`075a231297c9d0f078b6eb696b743c17a186b30f3122dd20bf9f0b0544337fab`){for(let e=0;e<4;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`075a231297c9d0f078b6eb696b743c17a186b30f3122dd20bf9f0b0544337fab`}let{message:n}=e,r=mo();if(!n)return null;let i;return t[1]!==r.RED||t[2]!==n?(i=K(U,{marginTop:1,children:K(W,{color:r.RED,children:n})}),t[1]=r.RED,t[2]=n,t[3]=i):i=t[3],i},kw=`~effect/encoding/Ndjson/NdjsonError`;var Aw=class extends Qt(`NdjsonError`){[kw]=kw;get message(){return this.kind}};const jw=()=>T((e,t)=>B(ei(e,e=>{try{return B(D(e.map(e=>JSON.stringify(e)).join(`
|
|
37
39
|
`)+`
|
|
38
|
-
`))}catch(e){return bn(new
|
|
39
|
-
`)),i.length>0&&t.write(i),n.length>0&&r.write(n),r.pipe(t),t.pipe(r),t.on(`error`,()=>r.destroy()),r.on(`error`,()=>t.destroy())}),a.on(`error`,()=>t.destroy()),a.end()},
|
|
40
|
-
`).map(e=>e.trim()).filter(e=>e.length>0),r=n.find(e=>e.startsWith(
|
|
41
|
-
`)?o:void 0}},
|
|
42
|
-
`);i.push(K(U,{color:r.DIM,wrap:`truncate`,children:[t,q.lineVertical,` `,G(U,{color:r.TEXT,children:o.tool.name}),`(`,o.isRunning&&K(U,{children:[` `,G(Yi,{type:`line`})]}),o.resultTokens!==void 0&&` ${q.arrowDown} ${Yw(o.resultTokens)} tokens`]},`${s}-h`));for(let n=0;n<e.length;n++)i.push(K(U,{color:r.DIM,children:[t,q.lineVertical,` `,` `,G(U,{color:r.TEXT,children:e[n]})]},`${s}-${n}`));i.push(K(U,{color:r.DIM,children:[t,q.lineVertical,` )`]},`${s}-c`))}else i.push(K(U,{color:r.DIM,wrap:`truncate`,children:[t,q.lineVertical,` `,G(U,{color:r.TEXT,children:o.tool.name}),`(`,o.tool.args,`)`,o.isRunning&&K(U,{children:[` `,G(Yi,{type:`line`})]}),o.resultTokens!==void 0&&` ${q.arrowDown} ${Yw(o.resultTokens)} tokens`]},s))}return i},aT=t=>{let n=gi(110);if(n[0]!==`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`){for(let e=0;e<110;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`}let{changesFor:r,instruction:i,savedFlow:a,requiresCookies:o,baseUrls:s}=t,c=o===void 0?!1:o,l=Kv(oT),u=uo(),[,d]=co(),f=Jx(sT),p=Jx(cT),m=Jx(lT),h=Jx(uT),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g={mode:`promiseExit`},n[1]=g):g=n[1];let[_,v]=la(Uw,g),y=da(Vw),[b,x]=W(void 0),ee;n[2]===_?ee=n[3]:(ee=ES(_),n[2]=_,n[3]=ee);let S=ee,C;n[4]===_?C=n[5]:(C=jS(_),n[4]=_,n[5]=C);let w=C,te=w?_.value.report:void 0,[T,E]=W(void 0),[D,ne]=W(void 0),[re,O]=W(0),[A,ie]=W(!1),j=IC(dT),ae=IC(fT),oe=IC(pT),M;n[6]===re?M=n[7]:(M=LC(re),n[6]=re,n[7]=M);let se=M,ce=T?.steps?T.steps.length:0,N;if(n[8]!==u||n[9]!==se||n[10]!==T||n[11]!==j||n[12]!==S){if(N=[],j&&T){let e=T.steps??[];if(e.length===0&&S){let e=$w(T.events,!0);N.push(...iT(e,` `,`planning`,u))}for(let t=0;t<e.length;t++){let n=e[t],r=k(n.summary)?n.summary.value:n.title,i=rT(n),a=i===void 0?void 0:LC(i),o=`${t+1}.`;if(n.status===`active`){N.push(K(H,{children:[K(U,{color:u.DIM,children:[` `,o,` `]}),G(zv,{}),G(U,{children:` `}),G(FC,{text:`${n.title} ${se}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]},`step-${t}`));let e=Qw(T.events,!0);N.push(...iT(e,` `,`s${t}`,u))}else if(n.status===`passed`){N.push(K(U,{children:[K(U,{color:u.DIM,children:[` `,o]}),K(U,{color:u.GREEN,children:[` `,q.tick,` `,Xi(r,100)]}),a&&K(U,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=tT(T.events,t);N.push(...iT(e,` `,`s${t}`,u))}else if(n.status===`failed`){N.push(K(U,{children:[K(U,{color:u.DIM,children:[` `,o]}),K(U,{color:u.RED,children:[` `,q.cross,` `,Xi(r,100)]}),a&&K(U,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=tT(T.events,t);N.push(...iT(e,` `,`s${t}`,u))}else N.push(K(U,{color:u.DIM,children:[` `,o,` `,q.circle,` `,n.title]},`step-${t}`))}}n[8]=u,n[9]=se,n[10]=T,n[11]=j,n[12]=S,n[13]=N}else N=n[13];let le=Math.max(1,d-6),ue;n[14]!==N.length||n[15]!==le?(ue={itemCount:N.length,visibleCount:le},n[14]=N.length,n[15]=le,n[16]=ue):ue=n[16];let de=Vv(ue),fe=Si(!1),P,pe;n[17]!==j||n[18]!==N.length||n[19]!==de?(P=()=>{j&&!fe.current&&N.length>0&&de.setHighlightedIndex(N.length-1),fe.current=j},pe=[j,N.length,de],n[17]=j,n[18]=N.length,n[19]=de,n[20]=P,n[21]=pe):(P=n[20],pe=n[21]),bi(P,pe);let me,he;n[22]!==f||n[23]!==s||n[24]!==p||n[25]!==r||n[26]!==i||n[27]!==m||n[28]!==c||n[29]!==a||n[30]!==v?(he=()=>{ne(Date.now());let e=s&&s.length>0?s.join(`, `):void 0,t=s?s.map(mT).join(` `):void 0;return v({options:{changesFor:r,instruction:t?`${i} ${t}`:i,isHeadless:!p,requiresCookies:c,savedFlow:a,baseUrl:e},agentBackend:f,replayHost:m,onUpdate:E,onReplayUrl:x}),()=>{v(CC)}},me=[v,f,p,r,i,a,c,s,m],n[22]=f,n[23]=s,n[24]=p,n[25]=r,n[26]=i,n[27]=m,n[28]=c,n[29]=a,n[30]=v,n[31]=me,n[32]=he):(me=n[31],he=n[32]),bi(he,me);let ge=w?_.value.replayUrl:void 0,_e=w?_.value.localReplayUrl:void 0,ve=w?_.value.videoUrl:void 0,ye,F;n[33]!==T||n[34]!==w||n[35]!==_e||n[36]!==ge||n[37]!==te||n[38]!==l||n[39]!==ve?(ye=()=>{w&&T&&te&&(IC.getState().setExecutedPlan(T),l(Wv.Results({report:te,replayUrl:ge,localReplayUrl:_e,videoUrl:ve})))},F=[w,T,te,ge,_e,ve,l],n[33]=T,n[34]=w,n[35]=_e,n[36]=ge,n[37]=te,n[38]=l,n[39]=ve,n[40]=ye,n[41]=F):(ye=n[40],F=n[41]),bi(ye,F);let be;n[42]===l?be=n[43]:(be=()=>{IC.getState().setExecutedPlan(void 0),l(Wv.Main())},n[42]=l,n[43]=be);let xe=be,Se,Ce;n[44]!==S||n[45]!==D?(Se=()=>{if(D===void 0||!S)return;let e=setInterval(()=>{O(Date.now()-D)},1e3);return()=>clearInterval(e)},Ce=[D,S],n[44]=S,n[45]=D,n[46]=Se,n[47]=Ce):(Se=n[46],Ce=n[47]),bi(Se,Ce);let we;n[48]!==T||n[49]!==_||n[50]!==j||n[51]!==de||n[52]!==xe||n[53]!==S||n[54]!==b||n[55]!==_e||n[56]!==ge||n[57]!==te||n[58]!==ae||n[59]!==l||n[60]!==A||n[61]!==oe||n[62]!==h||n[63]!==ve?(we=(t,n)=>{let r=t.toLowerCase();if(A){if(n.return||r===`y`){ie(!1),Xx(`run:cancelled`),xe();return}(n.escape||r===`n`)&&ie(!1);return}if(r===`o`&&!n.ctrl&&!n.meta&&b){let{exec:t}=e(`node:child_process`);t(`open "${b.replace(/"/g,`\\"`)}"`),Xx(`live_preview:opened`);return}if(n.ctrl&&t===`o`){oe();return}if(n.ctrl&&t===`n`){h();return}if(j){if(de.handleNavigation(t,n))return;if(n.escape){ae(!1);return}return}if(n.escape){if(NS(_)){xe();return}if(S){ie(!0);return}if(T&&te){IC.getState().setExecutedPlan(T),l(Wv.Results({report:te,replayUrl:ge,localReplayUrl:_e,videoUrl:ve}));return}xe()}},n[48]=T,n[49]=_,n[50]=j,n[51]=de,n[52]=xe,n[53]=S,n[54]=b,n[55]=_e,n[56]=ge,n[57]=te,n[58]=ae,n[59]=l,n[60]=A,n[61]=oe,n[62]=h,n[63]=ve,n[64]=we):we=n[64],ui(we);let Te;n[65]!==N||n[66]!==de.scrollOffset||n[67]!==le?(Te=N.slice(de.scrollOffset,de.scrollOffset+le),n[65]=N,n[66]=de.scrollOffset,n[67]=le,n[68]=Te):Te=n[68];let Ee=Te,De;n[69]===y?De=n[70]:(De=G(ci,{items:[...y],children:hT}),n[69]=y,n[70]=De);let Oe;n[71]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=G($x,{}),n[71]=Oe):Oe=n[71];let ke;n[72]===u.DIM?ke=n[73]:(ke=G(U,{color:u.DIM,children:q.pointerSmall}),n[72]=u.DIM,n[73]=ke);let Ae;n[74]!==u.TEXT||n[75]!==i?(Ae=G(U,{color:u.TEXT,children:i}),n[74]=u.TEXT,n[75]=i,n[76]=Ae):Ae=n[76];let je;n[77]!==ke||n[78]!==Ae?(je=K(H,{children:[Oe,K(U,{wrap:`truncate`,children:[` `,ke,` `,Ae]})]}),n[77]=ke,n[78]=Ae,n[79]=je):je=n[79];let Me;n[80]!==u.DIM||n[81]!==u.PRIMARY||n[82]!==S||n[83]!==b?(Me=b&&S&&G(H,{marginTop:0,children:K(U,{color:u.DIM,children:[` `,`Press `,G(U,{color:u.PRIMARY,children:`o`}),` to open live preview`]})}),n[80]=u.DIM,n[81]=u.PRIMARY,n[82]=S,n[83]=b,n[84]=Me):Me=n[84];let Ne;n[85]!==u.DIM||n[86]!==u.GREEN||n[87]!==u.RED||n[88]!==se||n[89]!==T||n[90]!==j||n[91]!==S||n[92]!==ce||n[93]!==Ee?(Ne=j?G(H,{flexDirection:`column`,marginTop:1,children:Ee}):K(Ci,{children:[ce===0&&S&&(()=>{let e=T?$w(T.events,!1):[];return K(H,{marginTop:1,flexDirection:`column`,children:[K(H,{children:[G(zv,{}),G(U,{children:` `}),G(FC,{text:`Starting${q.ellipsis} ${se}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),e.map(gT)]})})(),G(H,{flexDirection:`column`,marginTop:1,children:(T?.steps??[]).map((e,t)=>{let n=k(e.summary)?e.summary.value:e.title,r=rT(e),i=r===void 0?void 0:LC(r),a=`${t+1}.`;if(e.status===`active`){let t=T?Qw(T.events,!1):[];return K(H,{flexDirection:`column`,children:[K(H,{children:[K(U,{color:u.DIM,children:[` `,a,` `]}),G(zv,{}),G(U,{children:` `}),G(FC,{text:`${e.title} ${se}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),t.map(_T)]},e.id)}return e.status===`passed`?K(U,{children:[K(U,{color:u.DIM,children:[` `,a]}),K(U,{color:u.GREEN,children:[` `,q.tick,` `,Xi(n,100)]}),i&&K(U,{color:u.DIM,children:[` `,i]})]},e.id):e.status===`failed`?K(U,{children:[K(U,{color:u.DIM,children:[` `,a]}),K(U,{color:u.RED,children:[` `,q.cross,` `,Xi(n,100)]}),i&&K(U,{color:u.DIM,children:[` `,i]})]},e.id):K(U,{color:u.DIM,children:[` `,a,` `,q.circle,` `,e.title]},e.id)})})]}),n[85]=u.DIM,n[86]=u.GREEN,n[87]=u.RED,n[88]=se,n[89]=T,n[90]=j,n[91]=S,n[92]=ce,n[93]=Ee,n[94]=Ne):Ne=n[94];let Pe;n[95]!==u.PRIMARY||n[96]!==u.YELLOW||n[97]!==A?(Pe=A&&G(H,{marginTop:1,children:K(U,{color:u.YELLOW,children:[`Stop run? `,G(U,{color:u.PRIMARY,children:`enter`}),` to stop,`,` `,G(U,{color:u.PRIMARY,children:`esc`}),` to dismiss`]})}),n[95]=u.PRIMARY,n[96]=u.YELLOW,n[97]=A,n[98]=Pe):Pe=n[98];let Fe;n[99]===_?Fe=n[100]:(Fe=HS(_).onError(vT).orNull(),n[99]=_,n[100]=Fe);let Ie;n[101]!==je||n[102]!==Me||n[103]!==Ne||n[104]!==Pe||n[105]!==Fe?(Ie=K(H,{flexDirection:`column`,width:`100%`,paddingY:1,paddingX:1,children:[je,Me,Ne,Pe,Fe]}),n[101]=je,n[102]=Me,n[103]=Ne,n[104]=Pe,n[105]=Fe,n[106]=Ie):Ie=n[106];let Le;return n[107]!==De||n[108]!==Ie?(Le=K(Ci,{children:[De,Ie]}),n[107]=De,n[108]=Ie,n[109]=Le):Le=n[109],Le};function oT(e){return e.setScreen}function sT(e){return e.agentBackend}function cT(e){return e.browserHeaded}function lT(e){return e.replayHost}function uT(e){return e.toggleNotifications}function dT(e){return e.expanded}function fT(e){return e.setExpanded}function pT(e){return e.toggleExpanded}function mT(e){return`[url: ${e}]`}function hT(e){return G(H,{paddingX:1,children:G($C,{src:e,alt:e})},e)}function gT(e,t){return G(nT,{display:e,indent:` `},t)}function _T(e,t){return G(nT,{display:e,indent:` `},t)}function vT(e){return G(ew,{message:e instanceof Error?e.message:String(e)})}const yT=e=>{try{return Fi.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},bT=(e,t)=>M(Cv.use(n=>n.addComment(process.cwd(),e,t)).pipe(m(Cv.layer))),xT=()=>mi({mutationFn:({pullRequest:e,body:t})=>bT(e,t)}),ST=kw.fn(qr(function*(e,t){return yield*(yield*bv).save(e.plan)},ir({fn:`saveFlowFn`}),m(Pi.layer))),CT=e=>{if(!(We(e.startedAt)||We(e.endedAt)))return fn(e.endedAt.value)-fn(e.startedAt.value)},wT=e=>{let t=0;for(let n of e){let e=CT(n);e!==void 0&&(t+=e)}return t},TT=e=>{let t=gi(138);if(t[0]!==`99942357a453cbb5dc20454ff37ec4feb6c4634d202945566791064e1562399f`){for(let e=0;e<138;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`99942357a453cbb5dc20454ff37ec4feb6c4634d202945566791064e1562399f`}let{report:n,replayUrl:r,localReplayUrl:i,videoUrl:a}=e,o=uo(),s=Kv(ET),[c,l]=W(void 0),u=xT(),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d={mode:`promiseExit`},t[1]=d):d=t[1];let[f,p]=la(ST,d),m=f.waiting,h;t[2]===f?h=t[3]:(h=jS(f),t[2]=f,t[3]=h);let g=h,_;t[4]!==u||t[5]!==n.pullRequest||t[6]!==n.toPlainText?(_=()=>{k(n.pullRequest)&&(Xx(`results:posted_to_pr`),u.mutate({pullRequest:n.pullRequest.value,body:n.toPlainText}))},t[4]=u,t[5]=n.pullRequest,t[6]=n.toPlainText,t[7]=_):_=t[7];let v=_,y;t[8]!==o.GREEN||t[9]!==o.RED||t[10]!==n.toPlainText?(y=()=>{yT(n.toPlainText)?(Xx(`results:copied_to_clipboard`),l({text:`${q.tick} Copied to clipboard`,color:o.GREEN})):l({text:`${q.cross} Failed to copy to clipboard`,color:o.RED})},t[8]=o.GREEN,t[9]=o.RED,t[10]=n.toPlainText,t[11]=y):y=t[11];let b=y,x;t[12]!==n||t[13]!==m||t[14]!==g||t[15]!==p?(x=async()=>{m||g||(Xx(`flow:saved`,{step_count:n.steps.length}),await p({plan:n}))},t[12]=n,t[13]=m,t[14]=g,t[15]=p,t[16]=x):x=t[16];let ee=x,S;t[17]!==n.changesFor||t[18]!==n.instruction||t[19]!==s?(S=()=>{Xx(`results:restarted`),IC.getState().setExecutedPlan(void 0),s(Gv({changesFor:n.changesFor,instruction:n.instruction}))},t[17]=n.changesFor,t[18]=n.instruction,t[19]=s,t[20]=S):S=t[20];let C=S,w;t[21]!==b||t[22]!==v||t[23]!==C||t[24]!==ee?(w=e=>{let t=e.toLowerCase();t===`y`&&b(),t===`p`&&v(),t===`s`&&ee(),t===`r`&&C()},t[21]=b,t[22]=v,t[23]=C,t[24]=ee,t[25]=w):w=t[25],ui(w);let te=n.status===`passed`,T=te?o.GREEN:o.RED,E=te?q.tick:q.cross,D=te?`Passed`:`Failed`,ne,re,O,A,ie,j,ae,oe,M,se,ce;if(t[26]!==o.DIM||t[27]!==o.GREEN||t[28]!==o.RED||t[29]!==o.TEXT||t[30]!==i||t[31]!==r||t[32]!==n.instruction||t[33]!==n.stepStatuses||t[34]!==n.steps||t[35]!==T||t[36]!==E||t[37]!==D){let e=wT(n.steps);re=r??i,O=!!r&&!!i&&r!==i&&i!==void 0,ne=H,se=`column`,ce=`100%`,A=1,ie=1;let a;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(a=G($x,{}),t[49]=a):a=t[49];let s;t[50]===o.DIM?s=t[51]:(s=G(U,{color:o.DIM,children:q.pointerSmall}),t[50]=o.DIM,t[51]=s);let c;t[52]!==o.TEXT||t[53]!==n.instruction?(c=G(U,{color:o.TEXT,children:n.instruction}),t[52]=o.TEXT,t[53]=n.instruction,t[54]=c):c=t[54],t[55]!==s||t[56]!==c?(j=K(H,{children:[a,K(U,{wrap:`truncate`,children:[` `,s,` `,c]})]}),t[55]=s,t[56]=c,t[57]=j):j=t[57];let l;t[58]!==T||t[59]!==E||t[60]!==D?(l=K(U,{color:T,bold:!0,children:[E,` `,D]}),t[58]=T,t[59]=E,t[60]=D,t[61]=l):l=t[61];let u=n.steps.length===1?``:`s`,d;t[62]!==o.DIM||t[63]!==n.steps.length||t[64]!==u?(d=K(U,{color:o.DIM,children:[` `,n.steps.length,` step`,u]}),t[62]=o.DIM,t[63]=n.steps.length,t[64]=u,t[65]=d):d=t[65],t[66]!==l||t[67]!==d?(ae=K(H,{marginTop:1,children:[l,d]}),t[66]=l,t[67]=d,t[68]=ae):ae=t[68];let f;if(t[69]!==o.DIM||t[70]!==o.GREEN||t[71]!==o.RED||t[72]!==n.stepStatuses||t[73]!==n.steps){let e;t[75]!==o.DIM||t[76]!==o.GREEN||t[77]!==o.RED||t[78]!==n.stepStatuses?(e=(e,t)=>{let r=CT(e),i=r===void 0?void 0:LC(r),a=n.stepStatuses.get(e.id),s=a?.status===`failed`,c=s?o.RED:o.GREEN,l=s?q.cross:q.tick,u=`${t+1}.`;return K(H,{flexDirection:`column`,children:[K(U,{children:[K(U,{color:o.DIM,children:[` `,u]}),K(U,{color:c,children:[` `,l,` `,e.title]}),i&&K(U,{color:o.DIM,children:[` `,i]})]}),s&&a.summary&&K(U,{color:o.DIM,children:[` `,a.summary]})]},e.id)},t[75]=o.DIM,t[76]=o.GREEN,t[77]=o.RED,t[78]=n.stepStatuses,t[79]=e):e=t[79],f=n.steps.map(e),t[69]=o.DIM,t[70]=o.GREEN,t[71]=o.RED,t[72]=n.stepStatuses,t[73]=n.steps,t[74]=f}else f=t[74];t[80]===f?oe=t[81]:(oe=G(H,{flexDirection:`column`,marginTop:1,children:f}),t[80]=f,t[81]=oe),M=e>0&&G(H,{marginTop:1,children:K(U,{color:o.DIM,children:[`Worked for `,LC(e)]})}),t[26]=o.DIM,t[27]=o.GREEN,t[28]=o.RED,t[29]=o.TEXT,t[30]=i,t[31]=r,t[32]=n.instruction,t[33]=n.stepStatuses,t[34]=n.steps,t[35]=T,t[36]=E,t[37]=D,t[38]=ne,t[39]=re,t[40]=O,t[41]=A,t[42]=ie,t[43]=j,t[44]=ae,t[45]=oe,t[46]=M,t[47]=se,t[48]=ce}else ne=t[38],re=t[39],O=t[40],A=t[41],ie=t[42],j=t[43],ae=t[44],oe=t[45],M=t[46],se=t[47],ce=t[48];let N;t[82]===c?N=t[83]:(N=c&&G(H,{marginTop:1,children:G(U,{color:c.color,children:c.text})}),t[82]=c,t[83]=N);let le;t[84]!==o.DIM||t[85]!==u.isPending?(le=u.isPending&&G(H,{marginTop:1,children:K(U,{color:o.DIM,children:[`Posting to PR`,q.ellipsis]})}),t[84]=o.DIM,t[85]=u.isPending,t[86]=le):le=t[86];let ue;t[87]!==o.GREEN||t[88]!==u.isSuccess?(ue=u.isSuccess&&G(H,{marginTop:1,children:K(U,{color:o.GREEN,children:[q.tick,` Posted to PR`]})}),t[87]=o.GREEN,t[88]=u.isSuccess,t[89]=ue):ue=t[89];let de;t[90]!==o.RED||t[91]!==u.isError?(de=u.isError&&G(H,{marginTop:1,children:K(U,{color:o.RED,children:[q.cross,` Failed to post to PR`]})}),t[90]=o.RED,t[91]=u.isError,t[92]=de):de=t[92];let fe;t[93]!==o.DIM||t[94]!==m?(fe=m&&G(H,{marginTop:1,children:K(U,{color:o.DIM,children:[`Saving flow`,q.ellipsis]})}),t[93]=o.DIM,t[94]=m,t[95]=fe):fe=t[95];let P;t[96]!==o.GREEN||t[97]!==g?(P=g&&G(H,{marginTop:1,children:K(U,{color:o.GREEN,children:[q.tick,` Flow saved`]})}),t[96]=o.GREEN,t[97]=g,t[98]=P):P=t[98];let pe;t[99]!==o.RED||t[100]!==f?(pe=NS(f)&&G(H,{marginTop:1,children:K(U,{color:o.RED,children:[q.cross,` Failed to save flow`]})}),t[99]=o.RED,t[100]=f,t[101]=pe):pe=t[101];let me;t[102]!==o.DIM||t[103]!==o.PRIMARY||t[104]!==re?(me=re&&G(H,{flexDirection:`column`,paddingX:1,marginTop:1,children:K(U,{color:o.DIM,children:[`Replay:`,` `,G(U,{color:o.PRIMARY,bold:!0,children:re})]})}),t[102]=o.DIM,t[103]=o.PRIMARY,t[104]=re,t[105]=me):me=t[105];let he;t[106]!==o.DIM||t[107]!==o.PRIMARY||t[108]!==i||t[109]!==O?(he=O&&G(H,{flexDirection:`column`,paddingX:1,children:K(U,{color:o.DIM,children:[`Local Replay:`,` `,G(U,{color:o.PRIMARY,bold:!0,children:i})]})}),t[106]=o.DIM,t[107]=o.PRIMARY,t[108]=i,t[109]=O,t[110]=he):he=t[110];let ge;t[111]!==o.DIM||t[112]!==o.PRIMARY||t[113]!==a?(ge=a&&G(H,{flexDirection:`column`,paddingX:1,children:K(U,{color:o.DIM,children:[`Video:`,` `,G(U,{color:o.PRIMARY,bold:!0,children:a})]})}),t[111]=o.DIM,t[112]=o.PRIMARY,t[113]=a,t[114]=ge):ge=t[114];let _e;t[115]===n.screenshotPaths?_e=t[116]:(_e=n.screenshotPaths.map(DT),t[115]=n.screenshotPaths,t[116]=_e);let ve;return t[117]!==ne||t[118]!==A||t[119]!==ie||t[120]!==j||t[121]!==ae||t[122]!==oe||t[123]!==M||t[124]!==N||t[125]!==le||t[126]!==ue||t[127]!==de||t[128]!==fe||t[129]!==P||t[130]!==pe||t[131]!==me||t[132]!==he||t[133]!==ge||t[134]!==_e||t[135]!==se||t[136]!==ce?(ve=K(ne,{flexDirection:se,width:ce,paddingY:A,paddingX:ie,children:[j,ae,oe,M,N,le,ue,de,fe,P,pe,me,he,ge,_e]}),t[117]=ne,t[118]=A,t[119]=ie,t[120]=j,t[121]=ae,t[122]=oe,t[123]=M,t[124]=N,t[125]=le,t[126]=ue,t[127]=de,t[128]=fe,t[129]=P,t[130]=pe,t[131]=me,t[132]=he,t[133]=ge,t[134]=_e,t[135]=se,t[136]=ce,t[137]=ve):ve=t[137],ve};function ET(e){return e.setScreen}function DT(e){return G(H,{marginTop:1,children:G($C,{src:e,alt:`Screenshot: ${e}`})},e)}const OT=ne(bv.layer,sv.withRepoRoot(process.cwd())),kT=()=>hi({queryKey:[`saved-flows`],queryFn:()=>D(function*(){return yield*(yield*bv).list()}).pipe(m(OT),m(Pi.layer),B(`FindRepoRootError`,()=>z([])),M)}),AT=new Io({isGitRepo:!1,currentBranch:`HEAD`,mainBranch:void 0,isOnMain:!1,hasChangesFromMain:!1,hasUnstagedChanges:!1,hasBranchCommits:!1,branchCommitCount:0,fileStats:[],workingTreeFileStats:[],fingerprint:void 0,savedFingerprint:void 0}),jT=()=>hi({queryKey:[`git-state`],queryFn:async()=>{let e=await xe(D(function*(){return yield*(yield*sv).getState()}).pipe(m(sv.withRepoRoot(process.cwd())),B(`FindRepoRootError`,()=>z(AT)),rn({duration:1e4,onTimeout:()=>z(AT)}),m(Pi.layer)));return se(e)?e.value:AT}}),MT=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],NT=(e,t)=>{let n=zo.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=MT(e),i={title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r},a=e.environment.cookies;Xx(`flow:reused`,{slug:e.slug,step_count:r.length}),Kv.getState().setScreen(Gv({changesFor:n,instruction:e.flow.userInstruction,savedFlow:i,requiresCookies:a}))},PT=()=>{let e=gi(11);if(e[0]!==`53939b05c229418d7d52eba403172d78da52d4f06481f5625a9cf002fc443ae8`){for(let t=0;t<11;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`53939b05c229418d7d52eba403172d78da52d4f06481f5625a9cf002fc443ae8`}let t=uo(),[n]=co(),r=Kv(FT),{data:i}=jT(),{data:a,isLoading:o}=kT(),s=a===void 0?[]:a,{highlightedIndex:c,setHighlightedIndex:l,scrollOffset:u,handleNavigation:d}=Vv({itemCount:s.length,visibleCount:15}),f=Math.min(40,Math.floor(n*.35)),p=Math.max(20,n-f-8),m=s.slice(u,u+15);ui((e,t)=>{if(!d(e,t)){if(t.return){let e=s[c];e&&NT(e,i?.mainBranch??`main`)}t.escape&&r(Wv.Main())}});let h=H,g=`${s.length} flow${s.length===1?``:`s`}`,_;e[1]===g?_=e[2]:(_=G(H,{paddingX:1,children:G(Jv,{title:`Saved flows`,subtitle:g})}),e[1]=g,e[2]=_);let v;e[3]===o?v=e[4]:(v=o&&G(H,{marginTop:1,paddingX:1,children:G(zv,{message:`Loading saved flows...`})}),e[3]=o,e[4]=v);let y=!o&&s.length===0&&G(H,{marginTop:1,paddingX:1,flexDirection:`column`,children:K(U,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,G(U,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),b=!o&&s.length>0&&G(H,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:m.map((e,n)=>{let r=n+u,a=r===c,o=MT(e).length;return K(mo,{onClick:()=>{l(r),NT(e,i?.mainBranch??`main`)},children:[G(U,{color:a?t.PRIMARY:t.DIM,children:a?`${q.pointer} `:` `}),G(U,{color:a?t.PRIMARY:t.TEXT,bold:a,children:Bv(Xi(e.title,f-1),f)}),G(U,{color:t.DIM,children:Bv(`${o} step${o===1?``:`s`}`,10)}),G(U,{color:t.DIM,children:Xi(e.description,p)})]},e.slug)})}),x;return e[5]!==h||e[6]!==_||e[7]!==v||e[8]!==y||e[9]!==b?(x=K(h,{flexDirection:`column`,width:`100%`,paddingY:1,children:[_,v,y,b]}),e[5]=h,e[6]=_,e[7]=v,e[8]=y,e[9]=b,e[10]=x):x=e[10],x};function FT(e){return e.setScreen}const IT=e=>{let t=gi(7);if(t[0]!==`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`){for(let e=0;e<7;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`}let{status:n}=e,r=uo();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=K(U,{color:r.GREEN,children:[q.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=K(U,{color:r.PURPLE,children:[q.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=K(U,{color:r.DIM,children:[q.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},LT=e=>{let t=gi(30);if(t[0]!==`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`){for(let e=0;e<30;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`}let{options:n,selectedIndex:r,isLoading:i,gitState:a}=e,o=uo(),s;bb0:{if(n.length<=8){s=0;break bb0}let e=n.length-8;s=Math.min(e,Math.max(0,r-4))}let c=s,l,u,d,f;if(t[1]!==o||t[2]!==a||t[3]!==i||t[4]!==n||t[5]!==c||t[6]!==r){f=Symbol.for(`react.early_return_sentinel`);bb1:{let e=n.slice(c,c+8);if(n.length===0&&!i){let e;t[11]===o.DIM?e=t[12]:(e=G(H,{flexDirection:`column`,children:G(U,{color:o.DIM,children:`No matching results`})}),t[11]=o.DIM,t[12]=e),f=e;break bb1}l=H,u=`column`;let s;t[13]!==o||t[14]!==a||t[15]!==c||t[16]!==r?(s=(e,t)=>{let n=t+c===r,i=Pv(e,a),s=Fv(e,a),l=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prNumber:null,u=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prStatus:null;return K(U,{wrap:`truncate`,children:[G(U,{color:n?o.PRIMARY:o.DIM,children:n?`${q.pointer} `:` `}),e._tag===`WorkingTree`?K(U,{color:o.GREEN,children:[q.bullet,` `]}):null,u?G(IT,{status:u}):null,G(U,{color:n?o.PRIMARY:o.TEXT,bold:n,children:i}),l?K(U,{children:[` `,K(U,{color:u===`open`?o.GREEN:u===`merged`?o.PURPLE:o.DIM,children:[`#`,l]}),u?K(U,{color:o.DIM,children:[` `,u]}):null]}):null,s&&!l?K(U,{color:o.DIM,children:[` `,s]}):null]},fs(e))},t[13]=o,t[14]=a,t[15]=c,t[16]=r,t[17]=s):s=t[17],d=e.map(s)}t[1]=o,t[2]=a,t[3]=i,t[4]=n,t[5]=c,t[6]=r,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==o||t[19]!==i?(p=i?G(H,{children:K(U,{color:o.DIM,children:[` Loading PRs and branches`,q.ellipsis]})}):null,t[18]=o,t[19]=i,t[20]=p):p=t[20];let m;t[21]!==o||t[22]!==n.length?(m=n.length>8?G(H,{children:K(U,{color:o.DIM,children:[` `,n.length-8,` more `,q.arrowUp,`/`,q.arrowDown]})}):null,t[21]=o,t[22]=n.length,t[23]=m):m=t[23];let h;return t[24]!==l||t[25]!==u||t[26]!==d||t[27]!==p||t[28]!==m?(h=K(l,{flexDirection:u,children:[d,p,m]}),t[24]=l,t[25]=u,t[26]=d,t[27]=p,t[28]=m,t[29]=h):h=t[29],h},RT=({gitState:e,onSelect:t})=>{let[n,r]=W(!1),[i,a]=W(``),[o,s]=W(0),{data:c=[]}=hi({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>jv(e),enabled:!!e}),{data:l=[],isLoading:u}=hi({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>Nv(e),enabled:n&&!!e}),d=xi(()=>[...c,...l],[c,l]),f=xi(()=>Lv(d,i,e),[d,i,e]);bi(()=>{s(0)},[i]);let p=vi(()=>{r(!0),a(``),s(0)},[]),m=vi(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:f,localOptions:c,remoteLoading:u,openPicker:p,closePicker:m,handleContextSelect:vi(e=>{t(e),m()},[t,m]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=ao(r),o=e.current;if(i.length>o.length&&i[i.length-1]===`@`&&(o.length===0||i[i.length-2]===` `)){t(i.slice(0,-1)),p();return}if(n){i.length-o.length<0?(m(),t(i)):a(e=>{let n=i.slice(o.length);return n.includes(` `)?(m(),t(i),``):e+n});return}t(i)}}},zT=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],BT=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],VT=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],HT=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],UT=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],WT=(e,t)=>{if(!e)return zT;switch(e._tag){case`WorkingTree`:return BT;case`Branch`:return VT;case`PullRequest`:return HT;case`Commit`:return UT;default:return zT}},GT=({gitState:e})=>{let t=uo(),[n]=co(),r=Jx(e=>e.instructionHistory),i=Kv(e=>e.setScreen),[a,o]=W(void 0),[s,c]=W(``),[l,u]=W(0),[d,f]=W(0),[p,m]=W(!1),[h,g]=W(void 0),[_,v]=W(-1),[y,b]=W(``),x=aS(e=>e.cookiesEnabled),ee=aS(e=>e.toggleCookies),S=()=>{if(r.length===0)return;let e=_+1;e>=r.length||(_===-1&&b(s),v(e),c(r[e]),u(e=>e+1))},C=()=>{if(_<=-1)return;let e=_-1;v(e),c(e===-1?y:r[e]),u(e=>e+1)},w=RT({gitState:e??null,onSelect:e=>{o(e),Xx(`context:selected`,{context_type:{WorkingTree:`working_tree`,Branch:`branch`,PullRequest:`pull_request`,Commit:`commit`}[e._tag]})}}),te=w.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,T=a??te??null,E=WT(T,e??null);bi(()=>{f(0)},[T,e]);let D=t=>{let n=(t??s).trim();if(!n){g(`Describe what you want the browser agent to test.`);return}if(!e)return;let r=e.mainBranch??`main`,a;T?._tag===`Commit`?a=zo.makeUnsafe({_tag:`Commit`,hash:T.hash}):T?._tag===`Branch`||T?._tag===`PullRequest`?(T.branch.name&&(xv(process.cwd(),T.branch.name),qv.invalidateQueries({queryKey:[`git-state`]})),a=zo.makeUnsafe({_tag:`Branch`,mainBranch:r})):a=zo.makeUnsafe({_tag:`Changes`,mainBranch:r}),Jx.getState().rememberInstruction(n),x||Uv(n)?i(Gv({changesFor:a,instruction:n,requiresCookies:x})):i(Wv.CookieSyncConfirm({changesFor:a,instruction:n}))},ne=Si(s);ne.current=s;let re=w.createInputChangeHandler(ne,e=>{c(e),h&&g(void 0)}),O=!s.includes(`
|
|
43
|
-
`),k=s===``&&!w.pickerOpen&&E.length>0,A=k&&!p&&n>=80,ie=E[d%E.length];return ui((e,t)=>{if(w.pickerOpen){if(t.escape){w.closePicker();return}if(t.downArrow||t.ctrl&&e===`n`){w.setPickerIndex(Math.min(w.filteredOptions.length-1,w.pickerIndex+1));return}if(t.upArrow||t.ctrl&&e===`p`){w.setPickerIndex(Math.max(0,w.pickerIndex-1));return}if(t.return||t.tab){let e=w.filteredOptions[w.pickerIndex];e&&w.handleContextSelect(e);return}if(t.backspace||t.delete){w.pickerQuery.length===0?w.closePicker():w.setPickerQuery(w.pickerQuery.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&w.setPickerQuery(w.pickerQuery+e);return}if(O&&t.upArrow){S();return}if(O&&t.downArrow){C();return}if(t.ctrl&&e===`k`){ee(),Xx(`cookies:toggled`,{enabled:!x});return}if(t.tab&&!t.shift&&k&&ie){c(ie),u(e=>e+1),Xx(`suggestion:accepted`);return}if(!(t.tab&&t.shift)&&k){if(t.rightArrow){f(e=>(e+1)%E.length),m(!0);return}if(t.leftArrow){f(e=>(e-1+E.length)%E.length),m(!0);return}}},{isActive:!0}),K(H,{flexDirection:`column`,width:`100%`,paddingY:1,children:[G(H,{flexDirection:`column`,marginBottom:1,paddingX:1,children:G($x,{})}),e?.hasUntestedChanges&&K(H,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:t.BANNER_BG,width:`100%`,flexDirection:`column`,gap:0,children:[(()=>{let n=e.workingTreeFileStats,r=n.reduce((e,t)=>e+t.added,0),i=n.reduce((e,t)=>e+t.removed,0);return K(H,{children:[K(U,{color:t.YELLOW,bold:!0,children:[q.warning,` Untested changes detected`]}),n.length>0&&K(Ci,{children:[K(U,{color:t.DIM,children:[` `,n.length,` file`,n.length===1?``:`s`,` `]}),r>0&&K(U,{color:t.GREEN,children:[`+`,r]}),r>0&&i>0&&G(U,{color:t.DIM,children:` `}),i>0&&K(U,{color:t.RED,children:[`-`,i]})]})]})})(),K(U,{color:t.DIM,children:[`Describe what to test and hit `,G(U,{color:t.YELLOW,children:`enter`}),` to verify your changes.`]})]}),K(H,{flexDirection:`column`,width:`100%`,children:[K(H,{paddingX:1,children:[!e&&G(zv,{message:`loading context`}),e&&e.isGitRepo&&T&&G(mo,{fullWidth:!1,onClick:()=>{w.pickerOpen?w.closePicker():w.openPicker()},children:K(U,{color:t.DIM,children:[q.bullet,` `,K(U,{color:t.PRIMARY,children:[`@`,Iv(T,e)]}),Fv(T,e)&&` (${Fv(T,e)})`]})})]}),G(mo,{children:G(H,{flexDirection:`column`,marginTop:1,backgroundColor:t.INPUT_BG,width:`100%`,paddingX:1,paddingY:1,children:K(H,{children:[G(U,{color:t.PRIMARY,children:`❯ `}),G(H,{flexGrow:1,children:G(bo,{focus:!w.pickerOpen,multiline:!0,placeholder:ie?`${ie} [tab]`:``,value:s,onSubmit:D,onUpArrowAtTop:O?void 0:S,onDownArrowAtBottom:O?void 0:C,onChange:re},l)}),A?G(U,{color:t.DIM,children:` ←→ cycle test suggestions`}):null]})})}),e?.isGitRepo&&w.pickerOpen&&K(fo,{color:t.BORDER,children:[K(H,{marginBottom:0,children:[G(U,{color:t.DIM,children:`@ `}),G(U,{color:t.PRIMARY,children:w.pickerQuery}),G(U,{color:t.DIM,children:w.pickerQuery?``:`type to filter`})]}),G(LT,{options:w.filteredOptions,selectedIndex:w.pickerIndex,isLoading:w.remoteLoading,gitState:e})]}),e?.isGitRepo&&!w.pickerOpen&&G(H,{marginTop:1,paddingX:1,children:K(U,{color:t.DIM,children:[G(U,{color:t.PRIMARY,children:`@`}),` add context`]})})]}),G(ew,{message:h})]})},KT=e=>{let t=gi(10);if(t[0]!==`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`){for(let e=0;e<10;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`}let{segment:n,mutedColor:r}=e,i=n.color??r,a;t[1]!==n.label||t[2]!==i?(a=K(U,{color:i,children:[n.label,` `]}),t[1]=n.label,t[2]=i,t[3]=a):a=t[3];let o=n.color??r,s;t[4]!==n.key||t[5]!==o?(s=K(U,{color:o,children:[`[`,n.key,`]`]}),t[4]=n.key,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=K(Ci,{children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},qT=e=>{let t=gi(12);if(t[0]!==`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`){for(let e=0;e<12;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`}let{segments:n,color:r,mutedColor:i}=e,a;t[1]===r?a=t[2]:(a=G(U,{color:r,children:` `}),t[1]=r,t[2]=a);let o;if(t[3]!==i||t[4]!==n){let e;t[6]!==i||t[7]!==n.length?(e=(e,t)=>K(H,{children:[e.onClick?G(mo,{fullWidth:!1,onClick:e.onClick,children:G(KT,{segment:e,mutedColor:i})}):G(KT,{segment:e,mutedColor:i}),t<n.length-1&&G(U,{color:i,children:` `})]},e.key+e.label),t[6]=i,t[7]=n.length,t[8]=e):e=t[8],o=n.map(e),t[3]=i,t[4]=n,t[5]=o}else o=t[5];let s;return t[9]!==a||t[10]!==o?(s=K(H,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s},JT=(e,t)=>{let n=gi(87);if(n[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let e=0;e<87;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let r=uo(),i=Kv(ZT),a=aS(QT),o=aS($T),s=Jx(eE),c=Jx(tE),l=IC(nE);switch(e._tag){case`Main`:{let e=a?`cookies on`:`cookies off`,r;n[1]!==e||n[2]!==o?(r={key:`ctrl+k`,label:e,cta:!0,onClick:o},n[1]=e,n[2]=o,n[3]=r):r=n[3];let s;n[4]===i?s=n[5]:(s={key:`ctrl+r`,label:`saved flows`,cta:!0,onClick:()=>i(Wv.SavedFlowPicker())},n[4]=i,n[5]=s);let c;if(n[6]!==t?.isGitRepo||n[7]!==i||n[8]!==r||n[9]!==s){if(c=[r,s],t?.isGitRepo){let e;n[11]===i?e=n[12]:(e={key:`ctrl+p`,label:`pick pr`,cta:!0,onClick:()=>i(Wv.SelectPr())},n[11]=i,n[12]=e),c.push(e)}n[6]=t?.isGitRepo,n[7]=i,n[8]=r,n[9]=s,n[10]=c}else c=n[10];return c}case`SelectPr`:{let e,t,a;n[13]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},t={key:`←→`,label:`filter`},a={key:`/`,label:`search`},n[13]=e,n[14]=t,n[15]=a):(e=n[13],t=n[14],a=n[15]);let o;n[16]===i?o=n[17]:(o={key:`esc`,label:`back`,cta:!0,onClick:()=>i(Wv.Main())},n[16]=i,n[17]=o);let s;n[18]===r.PRIMARY?s=n[19]:(s={key:`enter`,label:`select`,color:r.PRIMARY,cta:!0},n[18]=r.PRIMARY,n[19]=s);let c;return n[20]!==o||n[21]!==s?(c=[e,t,a,o,s],n[20]=o,n[21]=s,n[22]=c):c=n[22],c}case`SavedFlowPicker`:{let e;n[23]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},n[23]=e):e=n[23];let t;n[24]===i?t=n[25]:(t={key:`esc`,label:`back`,cta:!0,onClick:()=>i(Wv.Main())},n[24]=i,n[25]=t);let a;n[26]===r.PRIMARY?a=n[27]:(a={key:`enter`,label:`select`,color:r.PRIMARY,cta:!0},n[26]=r.PRIMARY,n[27]=a);let o;return n[28]!==t||n[29]!==a?(o=[e,t,a],n[28]=t,n[29]=a,n[30]=o):o=n[30],o}case`CookieSyncConfirm`:{let t;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(t={key:`↑↓`,label:`nav`},n[31]=t):t=n[31];let a;n[32]===i?a=n[33]:(a={key:`esc`,label:`back`,onClick:()=>i(Wv.Main())},n[32]=i,n[33]=a);let o;n[34]!==e.changesFor||n[35]!==e.instruction||n[36]!==e.savedFlow||n[37]!==i?(o={key:`c`,label:`enable sync`,cta:!0,onClick:()=>{i(Gv({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow,requiresCookies:!0}))}},n[34]=e.changesFor,n[35]=e.instruction,n[36]=e.savedFlow,n[37]=i,n[38]=o):o=n[38];let s;n[39]!==e.changesFor||n[40]!==e.instruction||n[41]!==e.savedFlow||n[42]!==i?(s=()=>{i(Gv({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow,requiresCookies:!1}))},n[39]=e.changesFor,n[40]=e.instruction,n[41]=e.savedFlow,n[42]=i,n[43]=s):s=n[43];let c;n[44]!==r.PRIMARY||n[45]!==s?(c={key:`a`,label:`run anyway`,color:r.PRIMARY,cta:!0,onClick:s},n[44]=r.PRIMARY,n[45]=s,n[46]=c):c=n[46];let l;return n[47]!==a||n[48]!==o||n[49]!==c?(l=[t,a,o,c],n[47]=a,n[48]=o,n[49]=c,n[50]=l):l=n[50],l}case`PortPicker`:{let e,t,a;n[51]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},t={key:`space`,label:`toggle`},a={key:`/`,label:`custom port`},n[51]=e,n[52]=t,n[53]=a):(e=n[51],t=n[52],a=n[53]);let o;n[54]===i?o=n[55]:(o={key:`esc`,label:`back`,cta:!0,onClick:()=>i(Wv.Main())},n[54]=i,n[55]=o);let s;n[56]===r.PRIMARY?s=n[57]:(s={key:`enter`,label:`confirm`,color:r.PRIMARY,cta:!0},n[56]=r.PRIMARY,n[57]=s);let c;return n[58]!==o||n[59]!==s?(c=[e,t,a,o,s],n[58]=o,n[59]=s,n[60]=c):c=n[60],c}case`Testing`:{let e=s===!0?`notify on`:`notify off`,t=l?`collapse`:`expand`,r;n[61]!==e||n[62]!==c?(r={key:`ctrl+n`,label:e,cta:!0,onClick:c},n[61]=e,n[62]=c,n[63]=r):r=n[63];let i;n[64]===t?i=n[65]:(i={key:`ctrl+o`,label:t,cta:!0},n[64]=t,n[65]=i);let a=l?`collapse`:`cancel`,o;n[66]===a?o=n[67]:(o={key:`esc`,label:a},n[66]=a,n[67]=o);let u;return n[68]!==r||n[69]!==i||n[70]!==o?(u=[r,i,o],n[68]=r,n[69]=i,n[70]=o,n[71]=u):u=n[71],u}case`Results`:{let t;n[72]===Symbol.for(`react.memo_cache_sentinel`)?(t={key:`y`,label:`copy`,cta:!0},n[72]=t):t=n[72];let r;if(n[73]!==e.report.changesFor||n[74]!==e.report.instruction||n[75]!==e.report.pullRequest||n[76]!==i){if(r=[t],k(e.report.pullRequest)){let e;n[78]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`p`,label:`post to PR`,cta:!0},n[78]=e):e=n[78],r.push(e)}let a;n[79]===Symbol.for(`react.memo_cache_sentinel`)?(a={key:`s`,label:`save flow`,cta:!0},n[79]=a):a=n[79],r.push(a);let o;n[80]!==e.report.changesFor||n[81]!==e.report.instruction||n[82]!==i?(o={key:`r`,label:`restart`,cta:!0,onClick:()=>{IC.getState().setExecutedPlan(void 0),i(Gv({changesFor:e.report.changesFor,instruction:e.report.instruction}))}},n[80]=e.report.changesFor,n[81]=e.report.instruction,n[82]=i,n[83]=o):o=n[83],r.push(o);let s;n[84]===i?s=n[85]:(s={key:`esc`,label:`main menu`,cta:!0,onClick:()=>{IC.getState().setExecutedPlan(void 0),i(Wv.Main())}},n[84]=i,n[85]=s),r.push(s),n[73]=e.report.changesFor,n[74]=e.report.instruction,n[75]=e.report.pullRequest,n[76]=i,n[77]=r}else r=n[77];return r}default:{let e;return n[86]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[86]=e):e=n[86],e}}},YT=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,XT=()=>{let e=gi(35);if(e[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let t=0;t<35;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let[t]=co(),{data:n}=jT(),r=Kv(rE),i=JT(r,n),a,o;e[1]===i?(a=e[2],o=e[3]):(a=i.filter(iE),o=Zi(YT(a)),e[1]=i,e[2]=a,e[3]=o);let s=o,c=oE,l,u,d,f,p,m,h;if(e[4]!==i||e[5]!==t||e[6]!==s||e[7]!==r._tag){let n=i.filter(sE),a=c(n)+s+2>t?n.filter(cE):n,o=c(a);d=Math.max(0,t-o-s-2),u=H,m=`column`,e[15]!==t||e[16]!==r._tag?(h=r._tag===`Testing`?G(FC,{text:`─`.repeat(t),baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight,speed:3}):G(U,{color:Y.border,children:`─`.repeat(t)}),e[15]=t,e[16]=r._tag,e[17]=h):h=e[17],l=H,f=1,p=a.map(lE),e[4]=i,e[5]=t,e[6]=s,e[7]=r._tag,e[8]=l,e[9]=u,e[10]=d,e[11]=f,e[12]=p,e[13]=m,e[14]=h}else l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14];let g;e[18]===d?g=e[19]:(g=` `.repeat(d),e[18]=d,e[19]=g);let _;e[20]===g?_=e[21]:(_=G(U,{children:g}),e[20]=g,e[21]=_);let v;e[22]===a?v=e[23]:(v=a.length>0?G(qT,{segments:a,color:Y.primary,mutedColor:Y.textMuted}):null,e[22]=a,e[23]=v);let y;e[24]!==l||e[25]!==f||e[26]!==p||e[27]!==_||e[28]!==v?(y=K(l,{paddingX:f,children:[p,_,v]}),e[24]=l,e[25]=f,e[26]=p,e[27]=_,e[28]=v,e[29]=y):y=e[29];let b;return e[30]!==u||e[31]!==m||e[32]!==h||e[33]!==y?(b=K(u,{flexDirection:m,children:[h,y]}),e[30]=u,e[31]=m,e[32]=h,e[33]=y,e[34]=b):b=e[34],b};function ZT(e){return e.setScreen}function QT(e){return e.cookiesEnabled}function $T(e){return e.toggleCookies}function eE(e){return e.notifications}function tE(e){return e.toggleNotifications}function nE(e){return e.expanded}function rE(e){return e.screen}function iE(e){return!e.cta}function aE(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function oE(e){return Zi(e.map(aE).join(` `))}function sE(e){return e.cta}function cE(e){return e.key!==`ctrl+p`}function lE(e,t){let n=K(U,{children:[t>0?` `:``,e.color?K(U,{backgroundColor:e.color,color:`black`,children:[` `,G(U,{bold:!0,children:e.label}),` `,K(U,{children:[`[`,e.key,`]`]}),` `]}):K(U,{children:[K(U,{color:Y.textMuted,children:[e.label,` `]}),K(U,{color:Y.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?G(mo,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let uE=null;const dE=e=>{uE=e},fE=()=>uE?.clear(),pE=e=>{let t=gi(32);if(t[0]!==`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`){for(let e=0;e<32;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`}let{agent:n}=e,r=Kv(mE),i=Kv(hE),a=Kv(gE),{data:o}=jT(),s=ua(Ow),c,l;t[1]!==n||t[2]!==s?(c=()=>{s(ni(n))},l=[n,s],t[1]=n,t[2]=s,t[3]=c,t[4]=l):(c=t[3],l=t[4]),bi(c,l);let u;t[5]!==r._tag||t[6]!==i?(u=()=>{if(r._tag===`CookieSyncConfirm`){i(Wv.Main());return}if(r._tag===`PortPicker`){i(Wv.Main());return}if(r._tag===`Results`){IC.getState().setExecutedPlan(void 0),i(Wv.Main());return}r._tag!==`Testing`&&i(Wv.Main())},t[5]=r._tag,t[6]=i,t[7]=u):u=t[7];let d=u,[,f]=W(0),[,p]=co(),m;t[8]!==o?.isGitRepo||t[9]!==d||t[10]!==a||t[11]!==r._tag||t[12]!==f?(m=(e,t)=>{if(t.ctrl&&e===`l`){fE(),f(_E);return}t.escape&&r._tag!==`Main`&&d(),t.ctrl&&e===`p`&&r._tag===`Main`&&o?.isGitRepo&&a(Wv.SelectPr()),t.ctrl&&e===`r`&&r._tag===`Main`&&a(Wv.SavedFlowPicker())},t[8]=o?.isGitRepo,t[9]=d,t[10]=a,t[11]=r._tag,t[12]=f,t[13]=m):m=t[13],ui(m);let h;t[14]!==o||t[15]!==r._tag||t[16]!==r.baseUrls||t[17]!==r.changesFor||t[18]!==r.instruction||t[19]!==r.localReplayUrl||t[20]!==r.replayUrl||t[21]!==r.report||t[22]!==r.requiresCookies||t[23]!==r.savedFlow||t[24]!==r.videoUrl?(h=()=>{if(!o)return G(GT,{gitState:void 0});switch(r._tag){case`PortPicker`:return G(_S,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies});case`Testing`:return G(aT,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies,baseUrls:r.baseUrls});case`Results`:return G(TT,{report:r.report,replayUrl:r.replayUrl,localReplayUrl:r.localReplayUrl,videoUrl:r.videoUrl});case`SelectPr`:return G(Yv,{});case`CookieSyncConfirm`:return G(tS,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow});case`SavedFlowPicker`:return G(PT,{});default:return G(GT,{gitState:o})}},t[14]=o,t[15]=r._tag,t[16]=r.baseUrls,t[17]=r.changesFor,t[18]=r.instruction,t[19]=r.localReplayUrl,t[20]=r.replayUrl,t[21]=r.report,t[22]=r.requiresCookies,t[23]=r.savedFlow,t[24]=r.videoUrl,t[25]=h):h=t[25];let g=h,_;t[26]===g?_=t[27]:(_=G(H,{flexGrow:1,children:g()}),t[26]=g,t[27]=_);let v;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(v=G(XT,{}),t[28]=v):v=t[28];let y;return t[29]!==p||t[30]!==_?(y=G(no,{children:K(H,{flexDirection:`column`,width:`100%`,height:p,children:[_,v]})}),t[29]=p,t[30]=_,t[31]=y):y=t[31],y};function mE(e){return e.screen}function hE(e){return e.setScreen}function gE(e){return e.navigateTo}function _E(e){return e+1}const vE=()=>{let e=Ki();return e===`darwin`?`afplay /System/Library/Sounds/Glass.aiff`:e===`win32`?`powershell -c (New-Object Media.SoundPlayer 'C:\\Windows\\Media\\chimes.wav').PlaySync()`:`paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null || aplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null`},yE=()=>new Promise(e=>{Ii(vE(),()=>e())}),bE=e=>M(Aw(D(function*(){let t=yield*lv,n=yield*uv,r=yield*Kx,i=Date.now();yield*r.capture(`session:started`,{mode:`headless`,skip_planning:!1,browser_headed:e.headed}),console.log(`expect v${Ja}`),console.log(`Testing ${Bo(e.changesFor)}`),console.log(`Starting browser test...`);let a=Date.now();yield*r.capture(`run:started`,{plan_id:`direct`});let o=new Set,s=yield*t.execute({changesFor:e.changesFor,instruction:e.instruction,isHeadless:!e.headed,requiresCookies:!1}).pipe(f(e=>tr(()=>{for(let t of e.events)if(!o.has(t.id))switch(o.add(t.id),t._tag){case`RunStarted`:console.log(`Starting ${t.plan.title}`);break;case`StepStarted`:console.log(`${q.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${q.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${q.cross} ${t.stepId} ${t.message}`);break}})),Qe,I(t=>t._tag===`Some`?t.value:new _s({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!e.headed,requiresCookies:!1,title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),c=yield*n.report(s),l=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`passed`).length,u=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`failed`).length;yield*r.capture(`run:completed`,{plan_id:s.id??`direct`,passed:l,failed:u,step_count:s.steps.length,file_count:0,duration_ms:Date.now()-a}),yield*r.capture(`session:ended`,{session_ms:Date.now()-i}),yield*r.flush,console.error(`\n${c.toPlainText}`),yield*ri(()=>yE()),process.exit(c.status===`passed`?0:1)}).pipe(m(Dw({verbose:e.verbose,agent:e.agent}))))),xE={error:wi.red,warn:wi.yellow,info:wi.cyan,success:wi.green,dim:wi.dim},SE={error:(...e)=>{console.log(xE.error(e.join(` `)))},warn:(...e)=>{console.log(xE.warn(e.join(` `)))},info:(...e)=>{console.log(xE.info(e.join(` `)))},success:(...e)=>{console.log(xE.success(e.join(` `)))},dim:(...e)=>{console.log(xE.dim(e.join(` `)))},log:(...e)=>{console.log(e.join(` `))},break:()=>{console.log(``)}},CE=()=>{SE.break(),SE.log(`Cancelled.`),SE.break(),process.exit(0)},wE=e=>ya(e,{onCancel:CE}),TE=(e,t)=>ba({text:e,isSilent:t?.silent}),EE=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],DE=()=>EE.some(e=>!!process.env[e]),OE=()=>!process.stdin.isTTY,kE={npm:`npm install -g expect-cli@latest`,pnpm:`pnpm add -g expect-cli@latest`,yarn:`yarn global add expect-cli@latest`,bun:`bun add -g expect-cli@latest`,vp:`vp install -g expect-cli@latest`},AE=`npx skills add https://github.com/millionco/expect --skill expect-cli`,jE=()=>{if(process.env.VITE_PLUS_CLI_BIN)return`vp`;let e=process.env.npm_config_user_agent;if(e){if(e.startsWith(`pnpm`))return`pnpm`;if(e.startsWith(`yarn`))return`yarn`;if(e.startsWith(`bun`))return`bun`;if(e.startsWith(`npm`))return`npm`}return`npm`},ME=e=>e||DE()||OE(),NE=e=>new Promise(t=>{Ii(e,e=>{t(!e)})}),PE=async(e={})=>{let t=ME(e.yes??!1),n=kE[jE()];SE.break(),SE.log(` ${wi.red(q.cross)}${wi.green(q.tick)} ${wi.bold(`Expect`)} ${xE.dim(`v${Ja}`)}`),SE.break(),lu().length===0&&(SE.error(`No supported coding agent found. expect requires one of: Claude Code, Codex, or Cursor.`),SE.break(),SE.log(` Install one to get started:`),SE.log(` ${xE.info(`Claude Code`)} ${xE.dim(`https://docs.anthropic.com/en/docs/claude-code`)}`),SE.log(` ${xE.info(`Codex`)} ${xE.dim(`https://github.com/openai/codex`)}`),SE.log(` ${xE.info(`Cursor`)} ${xE.dim(`https://cursor.com`)}`),SE.break(),process.exit(1));let r=TE(`Installing expect-cli globally...`).start();await NE(n)?r.succeed(`Installed! You can now run ${xE.info(`expect-cli`)} from anywhere.`):(r.fail(`Failed to install globally.`),SE.dim(` Run manually: ${xE.info(n)}`)),SE.break();let i=t;if(t||(i=(await wE({type:`confirm`,name:`installSkill`,message:`Install the ${xE.info(`expect`)} skill for your coding agent?`,initial:!0})).installSkill),i){let e=TE(`Installing skill...`).start();await NE(AE)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),SE.dim(` Run manually: ${xE.info(AE)}`))}SE.break(),SE.success(`You're all set!`),SE.log(` Run ${xE.info(`expect-cli`)} in any project to start testing.`),SE.break()},FE=[`packages/*`,`apps/*`],IE=e=>Za.some(t=>e.includes(t)),LE=L(`detectAgent`)(function*(e){let t=yield*Xr;for(let[n,r]of Object.entries(Qa)){let i=Ti.join(e,n);if(yield*t.exists(i).pipe(B(`PlatformError`,()=>z(!1))))return r}let n=Ti.join(e,`package.json`),r=yield*t.readFileString(n).pipe(B(`PlatformError`,()=>z(``)));if(r){let e=yield*cn({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})}).pipe(B(`JsonParseError`,()=>z(void 0)));if(e?.packageManager){let t=e.packageManager.split(`@`)[0];if(t)return t}}return`npm`}),RE=L(`readPackageJson`)(function*(e){let t=yield*Xr,n=Ti.join(e,`package.json`),r=yield*t.readFileString(n);return yield*cn({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})})}),zE=L(`listWorkspaceDirectories`)(function*(e){let t=yield*Xr,n=[];for(let r of FE){let i=Ti.join(e,Ti.dirname(r)),a=yield*t.readDirectory(i).pipe(B(`PlatformError`,()=>z([])));for(let e of a){let r=Ti.join(i,e);(yield*t.stat(r).pipe(B(`PlatformError`,()=>z(void 0))))?.type===`Directory`&&n.push(r)}}return n}),BE=(e,t,n)=>new Promise(r=>{Li(e,[`run`,n],{cwd:t,timeout:12e4,maxBuffer:5*1024*1024},(e,t,i)=>{let a=(t+`
|
|
44
|
-
`+i).trim();r({script:n,passed:!e,output:a})})}),
|
|
40
|
+
`))}catch(e){return bn(new Aw({kind:`Pack`,cause:e}))}}))),Mw=e=>Un(Rn().pipe(e?.ignoreEmptyLines===!0?ne(e=>e.length>0):yr),e=>{try{return B(st(e,e=>JSON.parse(e)))}catch(e){return bn(new Aw({kind:`Unpack`,cause:e}))}}),Nw=Or(e=>Ve(e[0]),(e,t)=>d(d(jw(),e),Mw(t))),Pw=Or(2,(e,t)=>Ta(Nw(e,t),t)),Fw=$n([Jn({_tag:Kr(`Started`),startTime:mr}),Jn({_tag:Kr(`Ended`),startTime:mr,endTime:mr})]),Iw=Jn({_tag:Kr(`ExternalSpan`),spanId:z,traceId:z,sampled:me}),Lw=Jn({_tag:Kr(`Span`),spanId:z,traceId:z,name:z,sampled:me,attributes:cr(z,ie),status:Fw,parent:Nn(x(()=>zw))}),Rw=Jn({_tag:Kr(`SpanEvent`),traceId:z,spanId:z,name:z,startTime:mr,attributes:pr(Dr(z,ie))}),zw=$n([Lw,Iw]),Bw=Jn({_tag:Kr(`Ping`)}),Vw=Jn({_tag:Kr(`Pong`)}),Hw=Jn({_tag:Kr(`MetricsRequest`)}),Uw=(e,t)=>Jn({id:z,type:Kr(e),description:pr(z),attributes:pr(Dr(z,z)),state:t}),Ww=$n([Bw,Lw,Rw,Jn({_tag:Kr(`MetricsSnapshot`),metrics:I($n([Uw(`Counter`,Jn({count:$n([H,mr]),incremental:me})),Uw(`Frequency`,Jn({occurrences:cr(z,H)})),Uw(`Gauge`,Jn({value:$n([H,mr])})),Uw(`Histogram`,Jn({buckets:I(_n([H,H])),count:H,min:H,max:H,sum:H})),Uw(`Summary`,Jn({quantiles:I(_n([H,pr(H)])),count:H,min:H,max:H,sum:H}))]))})]),Gw=$n([Vw,Hw]),Kw=ut(Ww),qw=ut(Gw);var Jw=class extends tn()(`effect/devtools/DevToolsClient`){};const Yw=O(function*(){let e=yield*On,t=yield*Je(),n=yield*si(),r=yield*oi(),i=rr(()=>{tt(n,Xw(t))});return yield*E(n).pipe(He(Pw(Cr(e),{inputSchema:Kw,outputSchema:qw})),De(()=>fe(r,gn)),de(e=>{switch(e._tag){case`MetricsRequest`:return i;case`Pong`:return gn}}),ct),yield*nr(()=>i.pipe(jn(ei(Br,e=>Ge(n,dn(e)))))),yield*jr(()=>Ee(n,{_tag:`Ping`})).pipe(Zn(`3 seconds`),y,ct),yield*re(r).pipe(Er(`1 second`),Kn),Jw.of({sendUnsafe(e){tt(n,e)}})}),Xw=e=>({_tag:`MetricsSnapshot`,metrics:En(e)}),Zw=b(Jw,Yw.pipe(or({module:`DevTools`,service:`Client`}))),Qw=b(An,O(function*(){let e=yield*Jw,t=yield*qn;return qt({span(n){let r=t.span(n);e.sendUnsafe(r);let i=r.event;r.event=function(t,n,a){return e.sendUnsafe({_tag:`SpanEvent`,traceId:r.traceId,spanId:r.spanId,name:t,startTime:n,attributes:a}),i.call(this,t,n,a)};let a=r.end;return r.end=function(t,n){a.call(this,t,n),e.sendUnsafe(r)},r},context:t.context})}).pipe(or({module:`DevTools`,service:`Tracer`}))).pipe(w(Zw)),$w=(e=`ws://localhost:34437`)=>Qw.pipe(w(Gt(e))),eT=(e=`ws://localhost:34437`)=>$w(e).pipe(w(ar)),tT=({verbose:e,agent:t})=>{let n=vv.withRepoRoot(process.cwd());return te(bv.layer.pipe(w(n)),xv.layer,Ts.layer,Mv.layer,eT(),n,yS.layerPostHog).pipe(w(hu.layerFor(t??`claude`)),w(ky),Be(Hn(br,e?`All`:`Error`)))},nT=IC(Qe()),rT=WC(Yr(function*(e){return tT({verbose:!0,agent:yield*e.some(nT)})},u)).pipe(ew),iT=e=>e;var aT=class extends Ke(`ReplayProxyStartError`)({_tag:Kr(`ReplayProxyStartError`),cause:z}){message=`Failed to start replay proxy: ${this.cause}`};const oT=(e,t,n,r)=>{let i=new URL(e.url??`/`,r),a=Yi({hostname:i.hostname,port:i.port,path:i.pathname+i.search,method:`GET`,headers:{...e.headers,host:i.host}});a.on(`upgrade`,(e,r,i)=>{t.write([`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${e.headers[`sec-websocket-accept`]}`,``,``].join(`\r
|
|
41
|
+
`)),i.length>0&&t.write(i),n.length>0&&r.write(n),r.pipe(t),t.pipe(r),t.on(`error`,()=>r.destroy()),r.on(`error`,()=>t.destroy())}),a.on(`error`,()=>t.destroy()),a.end()},sT=R(`startReplayProxy`)(function*(e){let t=new va,n=[],r={title:``,status:`running`,steps:[]},i=!1,a=()=>{let e=r?.status;(e===`passed`||e===`failed`)&&(i=!0,r={...r,done:!0})};t.get(`/latest.json`,async t=>{if(i)return t.json(n);try{let r=await fetch(`${e.liveViewUrl}/latest.json`);if(!r.ok)return t.json(n);let i=await r.json();return Array.isArray(i)&&i.length>0&&(n=i),t.json(i)}catch{return t.json(n)}}),t.post(`/latest.json`,async e=>{try{let t=await e.req.json();return Array.isArray(t)&&(n=t),new Response(void 0,{status:204})}catch{return new Response(void 0,{status:400})}}),t.get(`/steps`,async t=>{if(i)return t.json(r);try{let n=await fetch(`${e.liveViewUrl}/steps`);return n.ok?(r=await n.json(),a(),t.json(r)):t.json(r)}catch{return t.json(r)}}),t.post(`/steps`,async t=>{try{let n=await t.req.text();r=JSON.parse(n),a();let i=await fetch(`${e.liveViewUrl}/steps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:n});return new Response(i.body,{status:i.status,headers:Object.fromEntries(i.headers.entries())})}catch{return new Response(void 0,{status:204})}});let o=/^https?:\/\//.test(e.replayHost)?e.replayHost:`http://${e.replayHost}`,s=new URL(o);t.all(`/*`,async e=>{let t=e.req.path;if(t===`/latest.json`||t===`/steps`)return e.text(`Not Found`,404);let n=new URL(t,o);n.search=new URL(e.req.url).search;try{return await ya(n.toString(),{headers:{"User-Agent":e.req.header(`user-agent`)??``,Accept:e.req.header(`accept`)??`*/*`,Host:s.host}})}catch(r){return console.error(`[replay-proxy] Failed to proxy ${t} to ${n}:`,r),e.text(`Bad Gateway: could not reach ${s.host}`,502)}}),t.onError((e,t)=>(console.error(`[replay-proxy] Unhandled error:`,e),t.text(`Internal Server Error`,500)));let c=yield*cn({try:()=>ba({fetch:t.fetch,port:0}),catch:e=>new aT({cause:String(e)})});c.on(`upgrade`,(e,t,n)=>{oT(e,t,n,o)});let l=c.address(),u=`http://localhost:${typeof l==`object`&&l?l.port:0}`;return yield*ke(`Replay proxy started`,{proxyUrl:u,liveViewUrl:e.liveViewUrl}),{url:u,close:Fr(e=>{c.close(()=>e(gn))})}}),cT=e=>A(e)?Number(fn(e.value)):void 0,lT=e=>e.length===0||!e.every(e=>e.status===`passed`||e.status===`failed`)?`running`:e.some(e=>e.status===`failed`)?`failed`:`passed`,uT=e=>{let t=e.events.find(e=>e._tag===`RunFinished`),n=t&&t._tag===`RunFinished`?t.status:lT(e.steps),r=t&&t._tag===`RunFinished`?t.summary:void 0,i=e.steps.map(e=>({stepId:e.id,title:e.title,status:e.status,summary:A(e.summary)?e.summary.value:void 0,startedAtMs:cT(e.startedAt),endedAtMs:cT(e.endedAt)}));return{title:e.title,status:n,summary:r,steps:i}},dT=R(`pushStepState`)(function*(e,t){yield*Ir(()=>fetch(`${e}/steps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).pipe(sn(()=>gn))}),fT=`rrweb report:`,pT=`Playwright video:`,mT=()=>5e4+Math.floor(Math.random()*1e4),hT=e=>{let t=e.slice().reverse().find(e=>e._tag===`ToolResult`&&e.toolName===`close`&&!e.isError&&e.result.length>0);if(!t||t._tag!==`ToolResult`)return{localReplayUrl:void 0,videoUrl:void 0};let n=t.result.split(`
|
|
42
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),r=n.find(e=>e.startsWith(fT))?.replace(fT,``),i=n.find(e=>e.startsWith(pT))?.replace(pT,``);return{localReplayUrl:r&&r.trim().length>0?Ni(r.trim()).href:void 0,videoUrl:i&&i.trim().length>0?Ni(i.trim()).href:void 0}},gT=IC([]),_T=Yr(function*(e,t){let n=yield*xv,r=yield*bv,i=yield*yS,a=yield*vv,o=Date.now(),s=`http://localhost:${mT()}`,c;e.replayHost&&(c=`${(yield*sT({replayHost:e.replayHost,liveViewUrl:s})).url}/replay?live=true`,yield*ke(`Replay viewer available`,{replayUrl:c}),yield*rr(()=>e.onReplayUrl?.(c)));let l={...e.options,liveViewUrl:s};yield*i.capture(`run:started`,{plan_id:`direct`});let u=yield*r.execute(l).pipe(f(t=>O(function*(){e.onUpdate(t),yield*dT(s,uT(t))})),Ze,L(t=>t._tag===`Some`?t.value:new Cs({...e.options,id:``,changesFor:e.options.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.options.instruction,baseUrl:void 0,isHeadless:e.options.isHeadless,requiresCookies:e.options.requiresCookies,testCoverage:Qe(),title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),d=hT(u.events);if(c){let e=c.split(`/replay`)[0];yield*Ir(()=>fetch(`${s}/latest.json`).then(async t=>{if(!t.ok)return;let n=await t.json();await fetch(`${e}/latest.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})})).pipe(sn(()=>gn)),yield*dT(e,uT(u))}let p=yield*n.report(u),m=p.steps.filter(e=>p.stepStatuses.get(e.id)?.status===`passed`).length,h=p.steps.filter(e=>p.stepStatuses.get(e.id)?.status===`failed`).length;return yield*i.capture(`run:completed`,{plan_id:u.id??`direct`,passed:m,failed:h,step_count:u.steps.length,file_count:0,duration_ms:Date.now()-o}),p.status===`passed`&&(yield*a.saveTestedFingerprint()),{executedPlan:u,report:p,replayUrl:c??d.localReplayUrl,localReplayUrl:d.localReplayUrl,videoUrl:d.videoUrl}},or({fn:`executeFn`})),vT=rT.fn()((e,t)=>iT(_T(e,t)).pipe(Yt(e=>O(function*(){let t=yield*yS,n=e instanceof Error?e.constructor.name:`UnknownError`;yield*t.capture(`run:failed`,{plan_id:`direct`,error_tag:n})}).pipe(sn(()=>gn))),m(Ii.layer)));rT.fn(Yr(function*(e,t){let n=yield*xv,r=yield*bv,i=yield*yS,a=yield*vv,o=Date.now(),s=`http://localhost:${mT()}`,c;e.replayHost&&(c=`${(yield*sT({replayHost:e.replayHost,liveViewUrl:s})).url}/replay?live=true`,yield*ke(`Replay viewer available`,{replayUrl:c}),yield*rr(()=>e.onReplayUrl?.(c)));let l={...e.options,liveViewUrl:s};yield*i.capture(`run:started`,{plan_id:`direct`});let u=yield*r.execute(l).pipe(f(t=>O(function*(){e.onUpdate(t),yield*dT(s,uT(t))})),Ze,L(t=>t._tag===`Some`?t.value:new Cs({...e.options,id:``,changesFor:e.options.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.options.instruction,baseUrl:void 0,isHeadless:e.options.isHeadless,requiresCookies:e.options.requiresCookies,testCoverage:Qe(),title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),d=hT(u.events);if(c){let e=c.split(`/replay`)[0];yield*Ir(()=>fetch(`${s}/latest.json`).then(async t=>{if(!t.ok)return;let n=await t.json();await fetch(`${e}/latest.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})})).pipe(sn(()=>gn)),yield*dT(e,uT(u))}let p=yield*n.report(u),m=p.steps.filter(e=>p.stepStatuses.get(e.id)?.status===`passed`).length,h=p.steps.filter(e=>p.stepStatuses.get(e.id)?.status===`failed`).length;return yield*i.capture(`run:completed`,{plan_id:u.id??`direct`,passed:m,failed:h,step_count:u.steps.length,file_count:0,duration_ms:Date.now()-o}),p.status===`passed`&&(yield*a.saveTestedFingerprint()),{executedPlan:u,report:p,replayUrl:c??d.localReplayUrl,localReplayUrl:d.localReplayUrl,videoUrl:d.videoUrl}},or({fn:`executeAtomFn`})));const yT=e=>{if(typeof e==`string`)try{let t=JSON.parse(e);if(It(t))return t}catch{return{}}return It(e)?e:{}},bT=e=>e.replace(/\s+/g,` `).trim(),xT=e=>{let t=e.match(/^mcp__.+__(.+)$/);return t?t[1]:e},ST=(e,t)=>{let n=xT(e),r=typeof t==`string`?t:JSON.stringify(t??{}),i=yT(t),a=Yn(n).pipe(Cn(`open`,()=>i.url?`"${i.url}"`:``),Cn(`screenshot`,()=>{let e=i.mode??`screenshot`;return e===`screenshot`?``:e}),Cn(`playwright`,()=>ea(bT(i.code??r),100)),Cn(`console_logs`,()=>i.type?`type: "${i.type}"`:``),Cn(`network_requests`,()=>{let e=[];return i.method&&e.push(i.method),i.url&&e.push(`"${i.url}"`),e.join(`, `)}),Cn(`performance_metrics`,()=>``),Cn(`close`,()=>``),mn(()=>CT(i))),o=(i.code??r).trim();return{name:n,args:a,multilineArgs:n===`playwright`&&o.includes(`
|
|
43
|
+
`)?o:void 0}},CT=e=>{let t=Object.values(e).filter(e=>typeof e==`string`&&e.length>0);return t.length===0?``:ea(bT(t.join(`, `)),100)},wT=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`,TT=(e,t,n=e.length)=>{let r=[];for(let i=t;i<n;i++){let t=e[i];if(t._tag===`ToolCall`&&r.push({tool:ST(t.toolName,t.input),isRunning:!1,resultTokens:void 0}),t._tag===`ToolProgress`&&r.length>0){let e=r[r.length-1];r[r.length-1]={...e,resultTokens:Math.round(t.outputSize/4)}}if(t._tag===`ToolResult`&&r.length>0){let e=r[r.length-1];r[r.length-1]={...e,resultTokens:Math.round(t.result.length/4)}}}return r},ET=(e,t)=>{if(e.length===0)return e;let n=t.at(-1)?._tag===`ToolResult`,r=[...e];return r[r.length-1]={...r[r.length-1],isRunning:!n},r},DT=(e,t=!1)=>{let n=-1;for(let t=e.length-1;t>=0;t--)if(e[t]._tag===`StepStarted`){n=t;break}if(n===-1)return[];let r=ET(TT(e,n+1),e);return t?r:r.slice(-5)},OT=(e,t=!1)=>{let n=ET(TT(e,0),e);return t?n:n.slice(-5)},kT=(e,t)=>{let n=-1,r=0;for(let i=0;i<e.length;i++)if(e[i]._tag===`StepStarted`&&(n++,n===t&&(r=i+1),n===t+1))return[r,i];return[r,e.length]},AT=(e,t)=>{let[n,r]=kT(e,t);return TT(e,n,r)},jT=e=>{let t=vi(15);if(t[0]!==`aae114b7641930417a1cbd1718a3ac8dfc1efc0ae0d19b36982b8420d1be52fa`){for(let e=0;e<15;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`aae114b7641930417a1cbd1718a3ac8dfc1efc0ae0d19b36982b8420d1be52fa`}let{display:n,indent:r}=e,i=mo(),a;t[1]!==i.TEXT||t[2]!==n.tool.name?(a=K(W,{color:i.TEXT,children:n.tool.name}),t[1]=i.TEXT,t[2]=n.tool.name,t[3]=a):a=t[3];let o;t[4]===n.isRunning?o=t[5]:(o=n.isRunning&&q(W,{children:[` `,K($i,{type:`line`})]}),t[4]=n.isRunning,t[5]=o);let s;t[6]===n.resultTokens?s=t[7]:(s=n.resultTokens!==void 0&&` ${J.arrowDown} ${wT(n.resultTokens)} tokens`,t[6]=n.resultTokens,t[7]=s);let c;return t[8]!==i.DIM||t[9]!==n.tool.args||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==s?(c=q(W,{color:i.DIM,wrap:`truncate`,children:[r,J.lineVertical,` `,a,`(`,n.tool.args,`)`,o,s]}),t[8]=i.DIM,t[9]=n.tool.args,t[10]=r,t[11]=a,t[12]=o,t[13]=s,t[14]=c):c=t[14],c},MT=e=>{if(!Ue(e.startedAt))return(A(e.endedAt)?fn(e.endedAt.value):Date.now())-fn(e.startedAt.value)},NT=(e,t,n,r)=>{let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=`${n}-t${a}`;if(o.tool.multilineArgs){let e=o.tool.multilineArgs.split(`
|
|
44
|
+
`);i.push(q(W,{color:r.DIM,wrap:`truncate`,children:[t,J.lineVertical,` `,K(W,{color:r.TEXT,children:o.tool.name}),`(`,o.isRunning&&q(W,{children:[` `,K($i,{type:`line`})]}),o.resultTokens!==void 0&&` ${J.arrowDown} ${wT(o.resultTokens)} tokens`]},`${s}-h`));for(let n=0;n<e.length;n++)i.push(q(W,{color:r.DIM,children:[t,J.lineVertical,` `,` `,K(W,{color:r.TEXT,children:e[n]})]},`${s}-${n}`));i.push(q(W,{color:r.DIM,children:[t,J.lineVertical,` )`]},`${s}-c`))}else i.push(q(W,{color:r.DIM,wrap:`truncate`,children:[t,J.lineVertical,` `,K(W,{color:r.TEXT,children:o.tool.name}),`(`,o.tool.args,`)`,o.isRunning&&q(W,{children:[` `,K($i,{type:`line`})]}),o.resultTokens!==void 0&&` ${J.arrowDown} ${wT(o.resultTokens)} tokens`]},s))}return i},PT=t=>{let n=vi(112);if(n[0]!==`aae114b7641930417a1cbd1718a3ac8dfc1efc0ae0d19b36982b8420d1be52fa`){for(let e=0;e<112;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`aae114b7641930417a1cbd1718a3ac8dfc1efc0ae0d19b36982b8420d1be52fa`}let{changesFor:r,instruction:i,savedFlow:a,requiresCookies:o,baseUrls:s}=t,c=o===void 0?!1:o,l=Sy(FT),u=mo(),[,d]=uo(),f=xS(IT),p=xS(LT),m=xS(RT),h=xS(zT),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g={mode:`promiseExit`},n[1]=g):g=n[1];let[_,v]=da(vT,g),y=pa(gT),[b,x]=G(void 0),ee;n[2]===_?ee=n[3]:(ee=$S(_),n[2]=_,n[3]=ee);let S=ee,C;n[4]===_?C=n[5]:(C=iC(_),n[4]=_,n[5]=C);let w=C,T=w?_.value.report:void 0,[E,D]=G(void 0),[O,te]=G(void 0),[ne,k]=G(0),[j,re]=G(!1),M=lw(BT),ie=lw(VT),ae=lw(HT),N;n[6]===ne?N=n[7]:(N=uw(ne),n[6]=ne,n[7]=N);let oe=N,se=E?.steps?E.steps.length:0,P;if(n[8]!==u||n[9]!==oe||n[10]!==E||n[11]!==M||n[12]!==S){if(P=[],M&&E){let e=E.steps??[];if(e.length===0&&S){let e=OT(E.events,!0);P.push(...NT(e,` `,`planning`,u))}for(let t=0;t<e.length;t++){let n=e[t],r=A(n.summary)?n.summary.value:n.title,i=MT(n),a=i===void 0?void 0:uw(i),o=`${t+1}.`;if(n.status===`active`){P.push(q(U,{children:[q(W,{color:u.DIM,children:[` `,o,` `]}),K(hy,{}),K(W,{children:` `}),K(cw,{text:`${n.title} ${oe}`,baseColor:fo.shimmerBase,highlightColor:fo.shimmerHighlight})]},`step-${t}`));let e=DT(E.events,!0);P.push(...NT(e,` `,`s${t}`,u))}else if(n.status===`passed`){P.push(q(W,{children:[q(W,{color:u.DIM,children:[` `,o]}),q(W,{color:u.GREEN,children:[` `,J.tick,` `,ea(r,100)]}),a&&q(W,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=AT(E.events,t);P.push(...NT(e,` `,`s${t}`,u))}else if(n.status===`failed`){P.push(q(W,{children:[q(W,{color:u.DIM,children:[` `,o]}),q(W,{color:u.RED,children:[` `,J.cross,` `,ea(r,100)]}),a&&q(W,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=AT(E.events,t);P.push(...NT(e,` `,`s${t}`,u))}else P.push(q(W,{color:u.DIM,children:[` `,o,` `,J.circle,` `,n.title]},`step-${t}`))}}n[8]=u,n[9]=oe,n[10]=E,n[11]=M,n[12]=S,n[13]=P}else P=n[13];let ce=Math.max(1,d-6),le;n[14]!==P.length||n[15]!==ce?(le={itemCount:P.length,visibleCount:ce},n[14]=P.length,n[15]=ce,n[16]=le):le=n[16];let ue=_y(le),de=wi(!1),F,fe;n[17]!==M||n[18]!==P.length||n[19]!==ue?(F=()=>{M&&!de.current&&P.length>0&&ue.setHighlightedIndex(P.length-1),de.current=M},fe=[M,P.length,ue],n[17]=M,n[18]=P.length,n[19]=ue,n[20]=F,n[21]=fe):(F=n[20],fe=n[21]),Si(F,fe);let pe,me;n[22]!==f||n[23]!==s||n[24]!==p||n[25]!==r||n[26]!==i||n[27]!==m||n[28]!==c||n[29]!==a||n[30]!==v?(me=()=>{te(Date.now());let e=s&&s.length>0?s.join(`, `):void 0,t=s?s.map(UT).join(` `):void 0;return v({options:{changesFor:r,instruction:t?`${i} ${t}`:i,isHeadless:!p,requiresCookies:c,savedFlow:a,baseUrl:e},agentBackend:f,replayHost:m,onUpdate:D,onReplayUrl:x}),()=>{v(XC)}},pe=[v,f,p,r,i,a,c,s,m],n[22]=f,n[23]=s,n[24]=p,n[25]=r,n[26]=i,n[27]=m,n[28]=c,n[29]=a,n[30]=v,n[31]=pe,n[32]=me):(pe=n[31],me=n[32]),Si(me,pe);let he=w?_.value.replayUrl:void 0,ge=w?_.value.localReplayUrl:void 0,_e=w?_.value.videoUrl:void 0,ve,I;n[33]!==E||n[34]!==w||n[35]!==ge||n[36]!==he||n[37]!==T||n[38]!==l||n[39]!==_e?(ve=()=>{w&&E&&T&&(lw.getState().setExecutedPlan(E),l(by.Results({report:T,replayUrl:he,localReplayUrl:ge,videoUrl:_e})))},I=[w,E,T,he,ge,_e,l],n[33]=E,n[34]=w,n[35]=ge,n[36]=he,n[37]=T,n[38]=l,n[39]=_e,n[40]=ve,n[41]=I):(ve=n[40],I=n[41]),Si(ve,I);let ye;n[42]===l?ye=n[43]:(ye=()=>{lw.getState().setExecutedPlan(void 0),l(by.Main())},n[42]=l,n[43]=ye);let be=ye,xe,Se;n[44]!==S||n[45]!==O?(xe=()=>{if(O===void 0||!S)return;let e=setInterval(()=>{k(Date.now()-O)},1e3);return()=>clearInterval(e)},Se=[O,S],n[44]=S,n[45]=O,n[46]=xe,n[47]=Se):(xe=n[46],Se=n[47]),Si(xe,Se);let Ce;n[48]!==E||n[49]!==_||n[50]!==M||n[51]!==ue||n[52]!==be||n[53]!==S||n[54]!==b||n[55]!==ge||n[56]!==he||n[57]!==T||n[58]!==ie||n[59]!==l||n[60]!==j||n[61]!==ae||n[62]!==h||n[63]!==_e?(Ce=(t,n)=>{let r=t.toLowerCase();if(j){if(n.return||r===`y`){re(!1),CS(`run:cancelled`),be();return}(n.escape||r===`n`)&&re(!1);return}if(r===`o`&&!n.ctrl&&!n.meta&&b){let{exec:t}=e(`node:child_process`);t(`open "${b.replace(/"/g,`\\"`)}"`),CS(`live_preview:opened`);return}if(n.ctrl&&t===`o`){ae();return}if(n.ctrl&&t===`n`){h();return}if(M){if(ue.handleNavigation(t,n))return;if(n.escape){ie(!1);return}return}if(n.escape){if(oC(_)){be();return}if(S){re(!0);return}if(E&&T){lw.getState().setExecutedPlan(E),l(by.Results({report:T,replayUrl:he,localReplayUrl:ge,videoUrl:_e}));return}be()}},n[48]=E,n[49]=_,n[50]=M,n[51]=ue,n[52]=be,n[53]=S,n[54]=b,n[55]=ge,n[56]=he,n[57]=T,n[58]=ie,n[59]=l,n[60]=j,n[61]=ae,n[62]=h,n[63]=_e,n[64]=Ce):Ce=n[64],fi(Ce);let we;n[65]!==P||n[66]!==ue.scrollOffset||n[67]!==ce?(we=P.slice(ue.scrollOffset,ue.scrollOffset+ce),n[65]=P,n[66]=ue.scrollOffset,n[67]=ce,n[68]=we):we=n[68];let Te=we,Ee;n[69]===y?Ee=n[70]:(Ee=K(ui,{items:[...y],children:WT}),n[69]=y,n[70]=Ee);let De;n[71]===Symbol.for(`react.memo_cache_sentinel`)?(De=K(ES,{}),n[71]=De):De=n[71];let Oe;n[72]===u.DIM?Oe=n[73]:(Oe=K(W,{color:u.DIM,children:J.pointerSmall}),n[72]=u.DIM,n[73]=Oe);let ke;n[74]!==u.TEXT||n[75]!==i?(ke=K(W,{color:u.TEXT,children:i}),n[74]=u.TEXT,n[75]=i,n[76]=ke):ke=n[76];let Ae;n[77]!==Oe||n[78]!==ke?(Ae=q(U,{children:[De,q(W,{wrap:`truncate`,children:[` `,Oe,` `,ke]})]}),n[77]=Oe,n[78]=ke,n[79]=Ae):Ae=n[79];let je;n[80]!==u.DIM||n[81]!==u.PRIMARY||n[82]!==S||n[83]!==b?(je=b&&S&&K(U,{marginTop:0,children:q(W,{color:u.DIM,children:[` `,`Press `,K(W,{color:u.PRIMARY,children:`o`}),` to open live preview`]})}),n[80]=u.DIM,n[81]=u.PRIMARY,n[82]=S,n[83]=b,n[84]=je):je=n[84];let Me;n[85]!==u.DIM||n[86]!==u.GREEN||n[87]!==u.RED||n[88]!==oe||n[89]!==E||n[90]!==M||n[91]!==S||n[92]!==se||n[93]!==Te?(Me=M?K(U,{flexDirection:`column`,marginTop:1,children:Te}):q(Ti,{children:[se===0&&S&&(()=>{let e=E?OT(E.events,!1):[];return q(U,{marginTop:1,flexDirection:`column`,children:[q(U,{children:[K(hy,{}),K(W,{children:` `}),K(cw,{text:`Starting${J.ellipsis} ${oe}`,baseColor:fo.shimmerBase,highlightColor:fo.shimmerHighlight})]}),e.map(GT)]})})(),K(U,{flexDirection:`column`,marginTop:1,children:(E?.steps??[]).map((e,t)=>{let n=A(e.summary)?e.summary.value:e.title,r=MT(e),i=r===void 0?void 0:uw(r),a=`${t+1}.`;if(e.status===`active`){let t=E?DT(E.events,!1):[];return q(U,{flexDirection:`column`,children:[q(U,{children:[q(W,{color:u.DIM,children:[` `,a,` `]}),K(hy,{}),K(W,{children:` `}),K(cw,{text:`${e.title} ${oe}`,baseColor:fo.shimmerBase,highlightColor:fo.shimmerHighlight})]}),t.map(KT)]},e.id)}return e.status===`passed`?q(W,{children:[q(W,{color:u.DIM,children:[` `,a]}),q(W,{color:u.GREEN,children:[` `,J.tick,` `,ea(n,100)]}),i&&q(W,{color:u.DIM,children:[` `,i]})]},e.id):e.status===`failed`?q(W,{children:[q(W,{color:u.DIM,children:[` `,a]}),q(W,{color:u.RED,children:[` `,J.cross,` `,ea(n,100)]}),i&&q(W,{color:u.DIM,children:[` `,i]})]},e.id):q(W,{color:u.DIM,children:[` `,a,` `,J.circle,` `,e.title]},e.id)})})]}),n[85]=u.DIM,n[86]=u.GREEN,n[87]=u.RED,n[88]=oe,n[89]=E,n[90]=M,n[91]=S,n[92]=se,n[93]=Te,n[94]=Me):Me=n[94];let Ne;n[95]!==u.PRIMARY||n[96]!==u.YELLOW||n[97]!==j?(Ne=j&&K(U,{marginTop:1,children:q(W,{color:u.YELLOW,children:[`Stop run? `,K(W,{color:u.PRIMARY,children:`enter`}),` to stop,`,` `,K(W,{color:u.PRIMARY,children:`esc`}),` to dismiss`]})}),n[95]=u.PRIMARY,n[96]=u.YELLOW,n[97]=j,n[98]=Ne):Ne=n[98];let Pe;n[99]!==Ae||n[100]!==je||n[101]!==Me||n[102]!==Ne?(Pe=q(U,{flexDirection:`column`,width:`100%`,paddingY:1,paddingX:1,children:[Ae,je,Me,Ne]}),n[99]=Ae,n[100]=je,n[101]=Me,n[102]=Ne,n[103]=Pe):Pe=n[103];let Fe;n[104]===_?Fe=n[105]:(Fe=hC(_).onError(qT).onDefect(JT).orNull(),n[104]=_,n[105]=Fe);let Ie;n[106]!==Pe||n[107]!==Fe?(Ie=q(U,{flexDirection:`column`,width:`100%`,children:[Pe,Fe]}),n[106]=Pe,n[107]=Fe,n[108]=Ie):Ie=n[108];let Le;return n[109]!==Ee||n[110]!==Ie?(Le=q(Ti,{children:[Ee,Ie]}),n[109]=Ee,n[110]=Ie,n[111]=Le):Le=n[111],Le};function FT(e){return e.setScreen}function IT(e){return e.agentBackend}function LT(e){return e.browserHeaded}function RT(e){return e.replayHost}function zT(e){return e.toggleNotifications}function BT(e){return e.expanded}function VT(e){return e.setExpanded}function HT(e){return e.toggleExpanded}function UT(e){return`[url: ${e}]`}function WT(e){return K(U,{paddingX:1,children:K(Ew,{src:e,alt:e})},e)}function GT(e,t){return K(jT,{display:e,indent:` `},t)}function KT(e,t){return K(jT,{display:e,indent:` `},t)}function qT(e){return K(Dw,{type:`error`,error:e})}function JT(e){return K(Dw,{type:`defect`,error:{_tag:`Defect`,message:kr(Nt(e))}})}const YT=e=>{try{return Li.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},XT=(e,t)=>N(Fv.use(n=>n.addComment(process.cwd(),e,t)).pipe(m(Fv.layer))),ZT=()=>gi({mutationFn:({pullRequest:e,body:t})=>XT(e,t)}),QT=rT.fn(Yr(function*(e,t){return yield*(yield*Mv).save(e.plan)},or({fn:`saveFlowFn`}),m(Ii.layer))),$T=e=>{if(!(Ue(e.startedAt)||Ue(e.endedAt)))return fn(e.endedAt.value)-fn(e.startedAt.value)},eE=e=>{let t=0;for(let n of e){let e=$T(n);e!==void 0&&(t+=e)}return t},tE=e=>{let t=vi(138);if(t[0]!==`99942357a453cbb5dc20454ff37ec4feb6c4634d202945566791064e1562399f`){for(let e=0;e<138;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`99942357a453cbb5dc20454ff37ec4feb6c4634d202945566791064e1562399f`}let{report:n,replayUrl:r,localReplayUrl:i,videoUrl:a}=e,o=mo(),s=Sy(nE),[c,l]=G(void 0),u=ZT(),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d={mode:`promiseExit`},t[1]=d):d=t[1];let[f,p]=da(QT,d),m=f.waiting,h;t[2]===f?h=t[3]:(h=iC(f),t[2]=f,t[3]=h);let g=h,_;t[4]!==u||t[5]!==n.pullRequest||t[6]!==n.toPlainText?(_=()=>{A(n.pullRequest)&&(CS(`results:posted_to_pr`),u.mutate({pullRequest:n.pullRequest.value,body:n.toPlainText}))},t[4]=u,t[5]=n.pullRequest,t[6]=n.toPlainText,t[7]=_):_=t[7];let v=_,y;t[8]!==o.GREEN||t[9]!==o.RED||t[10]!==n.toPlainText?(y=()=>{YT(n.toPlainText)?(CS(`results:copied_to_clipboard`),l({text:`${J.tick} Copied to clipboard`,color:o.GREEN})):l({text:`${J.cross} Failed to copy to clipboard`,color:o.RED})},t[8]=o.GREEN,t[9]=o.RED,t[10]=n.toPlainText,t[11]=y):y=t[11];let b=y,x;t[12]!==n||t[13]!==m||t[14]!==g||t[15]!==p?(x=async()=>{m||g||(CS(`flow:saved`,{step_count:n.steps.length}),await p({plan:n}))},t[12]=n,t[13]=m,t[14]=g,t[15]=p,t[16]=x):x=t[16];let ee=x,S;t[17]!==n.changesFor||t[18]!==n.instruction||t[19]!==s?(S=()=>{CS(`results:restarted`),lw.getState().setExecutedPlan(void 0),s(xy({changesFor:n.changesFor,instruction:n.instruction}))},t[17]=n.changesFor,t[18]=n.instruction,t[19]=s,t[20]=S):S=t[20];let C=S,w;t[21]!==b||t[22]!==v||t[23]!==C||t[24]!==ee?(w=e=>{let t=e.toLowerCase();t===`y`&&b(),t===`p`&&v(),t===`s`&&ee(),t===`r`&&C()},t[21]=b,t[22]=v,t[23]=C,t[24]=ee,t[25]=w):w=t[25],fi(w);let T=n.status===`passed`,E=T?o.GREEN:o.RED,D=T?J.tick:J.cross,O=T?`Passed`:`Failed`,te,ne,k,j,re,M,ie,ae,N,oe,se;if(t[26]!==o.DIM||t[27]!==o.GREEN||t[28]!==o.RED||t[29]!==o.TEXT||t[30]!==i||t[31]!==r||t[32]!==n.instruction||t[33]!==n.stepStatuses||t[34]!==n.steps||t[35]!==E||t[36]!==D||t[37]!==O){let e=eE(n.steps);ne=r??i,k=!!r&&!!i&&r!==i&&i!==void 0,te=U,oe=`column`,se=`100%`,j=1,re=1;let a;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(a=K(ES,{}),t[49]=a):a=t[49];let s;t[50]===o.DIM?s=t[51]:(s=K(W,{color:o.DIM,children:J.pointerSmall}),t[50]=o.DIM,t[51]=s);let c;t[52]!==o.TEXT||t[53]!==n.instruction?(c=K(W,{color:o.TEXT,children:n.instruction}),t[52]=o.TEXT,t[53]=n.instruction,t[54]=c):c=t[54],t[55]!==s||t[56]!==c?(M=q(U,{children:[a,q(W,{wrap:`truncate`,children:[` `,s,` `,c]})]}),t[55]=s,t[56]=c,t[57]=M):M=t[57];let l;t[58]!==E||t[59]!==D||t[60]!==O?(l=q(W,{color:E,bold:!0,children:[D,` `,O]}),t[58]=E,t[59]=D,t[60]=O,t[61]=l):l=t[61];let u=n.steps.length===1?``:`s`,d;t[62]!==o.DIM||t[63]!==n.steps.length||t[64]!==u?(d=q(W,{color:o.DIM,children:[` `,n.steps.length,` step`,u]}),t[62]=o.DIM,t[63]=n.steps.length,t[64]=u,t[65]=d):d=t[65],t[66]!==l||t[67]!==d?(ie=q(U,{marginTop:1,children:[l,d]}),t[66]=l,t[67]=d,t[68]=ie):ie=t[68];let f;if(t[69]!==o.DIM||t[70]!==o.GREEN||t[71]!==o.RED||t[72]!==n.stepStatuses||t[73]!==n.steps){let e;t[75]!==o.DIM||t[76]!==o.GREEN||t[77]!==o.RED||t[78]!==n.stepStatuses?(e=(e,t)=>{let r=$T(e),i=r===void 0?void 0:uw(r),a=n.stepStatuses.get(e.id),s=a?.status===`failed`,c=s?o.RED:o.GREEN,l=s?J.cross:J.tick,u=`${t+1}.`;return q(U,{flexDirection:`column`,children:[q(W,{children:[q(W,{color:o.DIM,children:[` `,u]}),q(W,{color:c,children:[` `,l,` `,e.title]}),i&&q(W,{color:o.DIM,children:[` `,i]})]}),s&&a.summary&&q(W,{color:o.DIM,children:[` `,a.summary]})]},e.id)},t[75]=o.DIM,t[76]=o.GREEN,t[77]=o.RED,t[78]=n.stepStatuses,t[79]=e):e=t[79],f=n.steps.map(e),t[69]=o.DIM,t[70]=o.GREEN,t[71]=o.RED,t[72]=n.stepStatuses,t[73]=n.steps,t[74]=f}else f=t[74];t[80]===f?ae=t[81]:(ae=K(U,{flexDirection:`column`,marginTop:1,children:f}),t[80]=f,t[81]=ae),N=e>0&&K(U,{marginTop:1,children:q(W,{color:o.DIM,children:[`Worked for `,uw(e)]})}),t[26]=o.DIM,t[27]=o.GREEN,t[28]=o.RED,t[29]=o.TEXT,t[30]=i,t[31]=r,t[32]=n.instruction,t[33]=n.stepStatuses,t[34]=n.steps,t[35]=E,t[36]=D,t[37]=O,t[38]=te,t[39]=ne,t[40]=k,t[41]=j,t[42]=re,t[43]=M,t[44]=ie,t[45]=ae,t[46]=N,t[47]=oe,t[48]=se}else te=t[38],ne=t[39],k=t[40],j=t[41],re=t[42],M=t[43],ie=t[44],ae=t[45],N=t[46],oe=t[47],se=t[48];let P;t[82]===c?P=t[83]:(P=c&&K(U,{marginTop:1,children:K(W,{color:c.color,children:c.text})}),t[82]=c,t[83]=P);let ce;t[84]!==o.DIM||t[85]!==u.isPending?(ce=u.isPending&&K(U,{marginTop:1,children:q(W,{color:o.DIM,children:[`Posting to PR`,J.ellipsis]})}),t[84]=o.DIM,t[85]=u.isPending,t[86]=ce):ce=t[86];let le;t[87]!==o.GREEN||t[88]!==u.isSuccess?(le=u.isSuccess&&K(U,{marginTop:1,children:q(W,{color:o.GREEN,children:[J.tick,` Posted to PR`]})}),t[87]=o.GREEN,t[88]=u.isSuccess,t[89]=le):le=t[89];let ue;t[90]!==o.RED||t[91]!==u.isError?(ue=u.isError&&K(U,{marginTop:1,children:q(W,{color:o.RED,children:[J.cross,` Failed to post to PR`]})}),t[90]=o.RED,t[91]=u.isError,t[92]=ue):ue=t[92];let de;t[93]!==o.DIM||t[94]!==m?(de=m&&K(U,{marginTop:1,children:q(W,{color:o.DIM,children:[`Saving flow`,J.ellipsis]})}),t[93]=o.DIM,t[94]=m,t[95]=de):de=t[95];let F;t[96]!==o.GREEN||t[97]!==g?(F=g&&K(U,{marginTop:1,children:q(W,{color:o.GREEN,children:[J.tick,` Flow saved`]})}),t[96]=o.GREEN,t[97]=g,t[98]=F):F=t[98];let fe;t[99]!==o.RED||t[100]!==f?(fe=oC(f)&&K(U,{marginTop:1,children:q(W,{color:o.RED,children:[J.cross,` Failed to save flow`]})}),t[99]=o.RED,t[100]=f,t[101]=fe):fe=t[101];let pe;t[102]!==o.DIM||t[103]!==o.PRIMARY||t[104]!==ne?(pe=ne&&K(U,{flexDirection:`column`,paddingX:1,marginTop:1,children:q(W,{color:o.DIM,children:[`Replay:`,` `,K(W,{color:o.PRIMARY,bold:!0,children:ne})]})}),t[102]=o.DIM,t[103]=o.PRIMARY,t[104]=ne,t[105]=pe):pe=t[105];let me;t[106]!==o.DIM||t[107]!==o.PRIMARY||t[108]!==i||t[109]!==k?(me=k&&K(U,{flexDirection:`column`,paddingX:1,children:q(W,{color:o.DIM,children:[`Local Replay:`,` `,K(W,{color:o.PRIMARY,bold:!0,children:i})]})}),t[106]=o.DIM,t[107]=o.PRIMARY,t[108]=i,t[109]=k,t[110]=me):me=t[110];let he;t[111]!==o.DIM||t[112]!==o.PRIMARY||t[113]!==a?(he=a&&K(U,{flexDirection:`column`,paddingX:1,children:q(W,{color:o.DIM,children:[`Video:`,` `,K(W,{color:o.PRIMARY,bold:!0,children:a})]})}),t[111]=o.DIM,t[112]=o.PRIMARY,t[113]=a,t[114]=he):he=t[114];let ge;t[115]===n.screenshotPaths?ge=t[116]:(ge=n.screenshotPaths.map(rE),t[115]=n.screenshotPaths,t[116]=ge);let _e;return t[117]!==te||t[118]!==j||t[119]!==re||t[120]!==M||t[121]!==ie||t[122]!==ae||t[123]!==N||t[124]!==P||t[125]!==ce||t[126]!==le||t[127]!==ue||t[128]!==de||t[129]!==F||t[130]!==fe||t[131]!==pe||t[132]!==me||t[133]!==he||t[134]!==ge||t[135]!==oe||t[136]!==se?(_e=q(te,{flexDirection:oe,width:se,paddingY:j,paddingX:re,children:[M,ie,ae,N,P,ce,le,ue,de,F,fe,pe,me,he,ge]}),t[117]=te,t[118]=j,t[119]=re,t[120]=M,t[121]=ie,t[122]=ae,t[123]=N,t[124]=P,t[125]=ce,t[126]=le,t[127]=ue,t[128]=de,t[129]=F,t[130]=fe,t[131]=pe,t[132]=me,t[133]=he,t[134]=ge,t[135]=oe,t[136]=se,t[137]=_e):_e=t[137],_e};function nE(e){return e.setScreen}function rE(e){return K(U,{marginTop:1,children:K(Ew,{src:e,alt:`Screenshot: ${e}`})},e)}const iE=te(Mv.layer,vv.withRepoRoot(process.cwd())),aE=()=>_i({queryKey:[`saved-flows`],queryFn:()=>O(function*(){return yield*(yield*Mv).list()}).pipe(m(iE),m(Ii.layer),V(`FindRepoRootError`,()=>B([])),N)}),oE=new Bo({isGitRepo:!1,currentBranch:`HEAD`,mainBranch:void 0,isOnMain:!1,hasChangesFromMain:!1,hasUnstagedChanges:!1,hasBranchCommits:!1,branchCommitCount:0,fileStats:[],workingTreeFileStats:[],fingerprint:void 0,savedFingerprint:void 0}),sE=()=>_i({queryKey:[`git-state`],queryFn:async()=>{let e=await be(O(function*(){return yield*(yield*vv).getState()}).pipe(m(vv.withRepoRoot(process.cwd())),V(`FindRepoRootError`,()=>B(oE)),rn({duration:1e4,onTimeout:()=>B(oE)}),m(Ii.layer)));return oe(e)?e.value:oE}}),cE=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],lE=(e,t)=>{let n=Uo.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=cE(e),i={title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r},a=e.environment.cookies;CS(`flow:reused`,{slug:e.slug,step_count:r.length}),Sy.getState().setScreen(xy({changesFor:n,instruction:e.flow.userInstruction,savedFlow:i,requiresCookies:a}))},uE=()=>{let e=vi(11);if(e[0]!==`53939b05c229418d7d52eba403172d78da52d4f06481f5625a9cf002fc443ae8`){for(let t=0;t<11;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`53939b05c229418d7d52eba403172d78da52d4f06481f5625a9cf002fc443ae8`}let t=mo(),[n]=uo(),r=Sy(dE),{data:i}=sE(),{data:a,isLoading:o}=aE(),s=a===void 0?[]:a,{highlightedIndex:c,setHighlightedIndex:l,scrollOffset:u,handleNavigation:d}=_y({itemCount:s.length,visibleCount:15}),f=Math.min(40,Math.floor(n*.35)),p=Math.max(20,n-f-8),m=s.slice(u,u+15);fi((e,t)=>{if(!d(e,t)){if(t.return){let e=s[c];e&&lE(e,i?.mainBranch??`main`)}t.escape&&r(by.Main())}});let h=U,g=`${s.length} flow${s.length===1?``:`s`}`,_;e[1]===g?_=e[2]:(_=K(U,{paddingX:1,children:K(wy,{title:`Saved flows`,subtitle:g})}),e[1]=g,e[2]=_);let v;e[3]===o?v=e[4]:(v=o&&K(U,{marginTop:1,paddingX:1,children:K(hy,{message:`Loading saved flows...`})}),e[3]=o,e[4]=v);let y=!o&&s.length===0&&K(U,{marginTop:1,paddingX:1,flexDirection:`column`,children:q(W,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,K(W,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),b=!o&&s.length>0&&K(U,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:m.map((e,n)=>{let r=n+u,a=r===c,o=cE(e).length;return q(_o,{onClick:()=>{l(r),lE(e,i?.mainBranch??`main`)},children:[K(W,{color:a?t.PRIMARY:t.DIM,children:a?`${J.pointer} `:` `}),K(W,{color:a?t.PRIMARY:t.TEXT,bold:a,children:gy(ea(e.title,f-1),f)}),K(W,{color:t.DIM,children:gy(`${o} step${o===1?``:`s`}`,10)}),K(W,{color:t.DIM,children:ea(e.description,p)})]},e.slug)})}),x;return e[5]!==h||e[6]!==_||e[7]!==v||e[8]!==y||e[9]!==b?(x=q(h,{flexDirection:`column`,width:`100%`,paddingY:1,children:[_,v,y,b]}),e[5]=h,e[6]=_,e[7]=v,e[8]=y,e[9]=b,e[10]=x):x=e[10],x};function dE(e){return e.setScreen}const fE=e=>{let t=vi(7);if(t[0]!==`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`){for(let e=0;e<7;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`}let{status:n}=e,r=mo();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=q(W,{color:r.GREEN,children:[J.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=q(W,{color:r.PURPLE,children:[J.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=q(W,{color:r.DIM,children:[J.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},pE=e=>{let t=vi(30);if(t[0]!==`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`){for(let e=0;e<30;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`4fad32b1608f5dc4d90407ad58143bc83cfcba6f2b87af31eb3b6ad187111fee`}let{options:n,selectedIndex:r,isLoading:i,gitState:a}=e,o=mo(),s;bb0:{if(n.length<=8){s=0;break bb0}let e=n.length-8;s=Math.min(e,Math.max(0,r-4))}let c=s,l,u,d,f;if(t[1]!==o||t[2]!==a||t[3]!==i||t[4]!==n||t[5]!==c||t[6]!==r){f=Symbol.for(`react.early_return_sentinel`);bb1:{let e=n.slice(c,c+8);if(n.length===0&&!i){let e;t[11]===o.DIM?e=t[12]:(e=K(U,{flexDirection:`column`,children:K(W,{color:o.DIM,children:`No matching results`})}),t[11]=o.DIM,t[12]=e),f=e;break bb1}l=U,u=`column`;let s;t[13]!==o||t[14]!==a||t[15]!==c||t[16]!==r?(s=(e,t)=>{let n=t+c===r,i=uy(e,a),s=dy(e,a),l=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prNumber:null,u=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prStatus:null;return q(W,{wrap:`truncate`,children:[K(W,{color:n?o.PRIMARY:o.DIM,children:n?`${J.pointer} `:` `}),e._tag===`WorkingTree`?q(W,{color:o.GREEN,children:[J.bullet,` `]}):null,u?K(fE,{status:u}):null,K(W,{color:n?o.PRIMARY:o.TEXT,bold:n,children:i}),l?q(W,{children:[` `,q(W,{color:u===`open`?o.GREEN:u===`merged`?o.PURPLE:o.DIM,children:[`#`,l]}),u?q(W,{color:o.DIM,children:[` `,u]}):null]}):null,s&&!l?q(W,{color:o.DIM,children:[` `,s]}):null]},vs(e))},t[13]=o,t[14]=a,t[15]=c,t[16]=r,t[17]=s):s=t[17],d=e.map(s)}t[1]=o,t[2]=a,t[3]=i,t[4]=n,t[5]=c,t[6]=r,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==o||t[19]!==i?(p=i?K(U,{children:q(W,{color:o.DIM,children:[` Loading PRs and branches`,J.ellipsis]})}):null,t[18]=o,t[19]=i,t[20]=p):p=t[20];let m;t[21]!==o||t[22]!==n.length?(m=n.length>8?K(U,{children:q(W,{color:o.DIM,children:[` `,n.length-8,` more `,J.arrowUp,`/`,J.arrowDown]})}):null,t[21]=o,t[22]=n.length,t[23]=m):m=t[23];let h;return t[24]!==l||t[25]!==u||t[26]!==d||t[27]!==p||t[28]!==m?(h=q(l,{flexDirection:u,children:[d,p,m]}),t[24]=l,t[25]=u,t[26]=d,t[27]=p,t[28]=m,t[29]=h):h=t[29],h},mE=({gitState:e,onSelect:t})=>{let[n,r]=G(!1),[i,a]=G(``),[o,s]=G(0),{data:c=[]}=_i({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>sy(e),enabled:!!e}),{data:l=[],isLoading:u}=_i({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>ly(e),enabled:n&&!!e}),d=Ci(()=>[...c,...l],[c,l]),f=Ci(()=>py(d,i,e),[d,i,e]);Si(()=>{s(0)},[i]);let p=bi(()=>{r(!0),a(``),s(0)},[]),m=bi(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:f,localOptions:c,remoteLoading:u,openPicker:p,closePicker:m,handleContextSelect:bi(e=>{t(e),m()},[t,m]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=so(r),o=e.current;if(i.length>o.length&&i[i.length-1]===`@`&&(o.length===0||i[i.length-2]===` `)){t(i.slice(0,-1)),p();return}if(n){i.length-o.length<0?(m(),t(i)):a(e=>{let n=i.slice(o.length);return n.includes(` `)?(m(),t(i),``):e+n});return}t(i)}}},hE=e=>{let t=new Set;return e.filter(e=>t.has(e.path)?!1:(t.add(e.path),!0))},gE=e=>_i({queryKey:[`test-coverage`,e?.fingerprint],queryFn:async()=>{if(!e?.isGitRepo||!e.hasChangesFromMain&&!e.hasUnstagedChanges)return;let t=e.mainBranch??`main`,n=await be(O(function*(){let e=yield*vv,n=yield*ay,r=yield*e.getChangedFiles(Uo.makeUnsafe({_tag:`WorkingTree`})),i=yield*e.getChangedFiles(Uo.makeUnsafe({_tag:`Changes`,mainBranch:t})),a=hE([...r,...i]);if(a.length!==0)return yield*n.analyze(a)}).pipe(m(vv.withRepoRoot(process.cwd())),m(ay.layer),rn({duration:15e3,onTimeout:()=>B(void 0)}),m(Ii.layer)));if(oe(n))return n.value},enabled:!!(e?.isGitRepo&&(e.hasChangesFromMain||e.hasUnstagedChanges)),staleTime:3e4}),_E=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],vE=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],yE=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],bE=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],xE=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],SE=(e,t)=>{if(!e)return _E;switch(e._tag){case`WorkingTree`:return vE;case`Branch`:return yE;case`PullRequest`:return bE;case`Commit`:return xE;default:return _E}},CE=e=>e>=70?`green`:e>=40?`yellow`:`#e06c50`,wE=e=>e>=70?`#0a2b0a`:e>=40?`#332b00`:`#331510`,TE=e=>`Use Expect to test your changes.`,EE=e=>{let t=Math.round(e/100*10),n=10-t;return{filled:`█`.repeat(t),empty:`░`.repeat(n)}},DE=({gitState:e})=>{let t=mo(),[n]=uo(),r=xS(e=>e.instructionHistory),i=Sy(e=>e.setScreen),[a,o]=G(void 0),[s,c]=G(``),[l,u]=G(0),[d,f]=G(0),[p,m]=G(!1),[h,g]=G(void 0),[_,v]=G(-1),[y,b]=G(``),x=MS(e=>e.cookiesEnabled),ee=MS(e=>e.toggleCookies),{data:S}=gE(e),C=()=>{if(r.length===0)return;let e=_+1;e>=r.length||(_===-1&&b(s),v(e),c(r[e]),u(e=>e+1))},w=()=>{if(_<=-1)return;let e=_-1;v(e),c(e===-1?y:r[e]),u(e=>e+1)},T=mE({gitState:e??null,onSelect:e=>{o(e),CS(`context:selected`,{context_type:{WorkingTree:`working_tree`,Branch:`branch`,PullRequest:`pull_request`,Commit:`commit`}[e._tag]})}}),E=T.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,D=a??E??null,O=SE(D,e??null);Si(()=>{f(0)},[D,e]);let te=t=>{let n=(t??s).trim();if(!n){g(`Describe what you want the browser agent to test.`);return}if(!e)return;let r=e.mainBranch??`main`,a;D?._tag===`Commit`?a=Uo.makeUnsafe({_tag:`Commit`,hash:D.hash}):D?._tag===`Branch`||D?._tag===`PullRequest`?(D.branch.name&&(Nv(process.cwd(),D.branch.name),Cy.invalidateQueries({queryKey:[`git-state`]})),a=Uo.makeUnsafe({_tag:`Branch`,mainBranch:r})):a=Uo.makeUnsafe({_tag:`Changes`,mainBranch:r}),xS.getState().rememberInstruction(n),x||yy(n)?i(xy({changesFor:a,instruction:n,requiresCookies:x})):i(by.CookieSyncConfirm({changesFor:a,instruction:n}))},ne=wi(s);ne.current=s;let k=T.createInputChangeHandler(ne,e=>{c(e),h&&g(void 0)}),A=!s.includes(`
|
|
45
|
+
`),j=s===``&&!T.pickerOpen&&O.length>0,re=j&&!p&&n>=80,M=O[d%O.length];return fi((e,t)=>{if(T.pickerOpen){if(t.escape){T.closePicker();return}if(t.downArrow||t.ctrl&&e===`n`){T.setPickerIndex(Math.min(T.filteredOptions.length-1,T.pickerIndex+1));return}if(t.upArrow||t.ctrl&&e===`p`){T.setPickerIndex(Math.max(0,T.pickerIndex-1));return}if(t.return||t.tab){let e=T.filteredOptions[T.pickerIndex];e&&T.handleContextSelect(e);return}if(t.backspace||t.delete){T.pickerQuery.length===0?T.closePicker():T.setPickerQuery(T.pickerQuery.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&T.setPickerQuery(T.pickerQuery+e);return}if(A&&t.upArrow){C();return}if(A&&t.downArrow){w();return}if(t.ctrl&&e===`k`){ee(),CS(`cookies:toggled`,{enabled:!x});return}if(t.tab&&!t.shift&&j&&M){c(M),u(e=>e+1),CS(`suggestion:accepted`);return}if(!(t.tab&&t.shift)&&j){if(t.rightArrow){f(e=>(e+1)%O.length),m(!0);return}if(t.leftArrow){f(e=>(e-1+O.length)%O.length),m(!0);return}}},{isActive:!0}),q(U,{flexDirection:`column`,width:`100%`,paddingY:1,children:[K(U,{flexDirection:`column`,marginBottom:1,paddingX:1,children:K(ES,{})}),(e?.hasUntestedChanges||S&&S.totalCount>0)&&!(S&&S.totalCount>0&&S.percent>=90)&&q(U,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:S&&S.totalCount>0?wE(S.percent):t.BANNER_BG,width:`100%`,flexDirection:`column`,gap:0,children:[(()=>{if(S&&S.totalCount>0)return q(U,{children:[q(W,{color:CE(S.percent),bold:!0,children:[J.warning,` Untested changes`]}),K(W,{children:` `}),K(W,{color:CE(S.percent),children:EE(S.percent).filled}),K(W,{color:t.DIM,children:EE(S.percent).empty}),q(W,{color:CE(S.percent),children:[` `,S.percent,`% test coverage`]})]});let n=e.workingTreeFileStats,r=n.reduce((e,t)=>e+t.added,0),i=n.reduce((e,t)=>e+t.removed,0);return q(U,{children:[q(W,{color:t.YELLOW,bold:!0,children:[J.warning,` Untested changes detected`]}),n.length>0&&q(Ti,{children:[q(W,{color:t.DIM,children:[` `,n.length,` file`,n.length===1?``:`s`,` `]}),r>0&&q(W,{color:t.GREEN,children:[`+`,r]}),r>0&&i>0&&K(W,{color:t.DIM,children:` `}),i>0&&q(W,{color:t.RED,children:[`-`,i]})]})]})})(),K(W,{color:t.DIM,children:S&&S.totalCount>0?TE(S.percent):`Describe what to test and hit enter to verify your changes.`})]}),q(U,{flexDirection:`column`,width:`100%`,children:[q(U,{paddingX:1,children:[!e&&K(hy,{message:`loading context`}),e&&e.isGitRepo&&D&&K(_o,{fullWidth:!1,onClick:()=>{T.pickerOpen?T.closePicker():T.openPicker()},children:q(W,{color:t.DIM,children:[J.bullet,` `,q(W,{color:t.PRIMARY,children:[`@`,fy(D,e)]}),dy(D,e)&&` (${dy(D,e)})`]})})]}),K(_o,{children:K(U,{flexDirection:`column`,marginTop:1,backgroundColor:t.INPUT_BG,width:`100%`,paddingX:1,paddingY:1,children:q(U,{children:[K(W,{color:t.PRIMARY,children:`❯ `}),K(U,{flexGrow:1,children:K(Co,{focus:!T.pickerOpen,multiline:!0,placeholder:M?`${M} [tab]`:``,value:s,onSubmit:te,onUpArrowAtTop:A?void 0:C,onDownArrowAtBottom:A?void 0:w,onChange:k},l)}),re?K(W,{color:t.DIM,children:` ←→ cycle test suggestions`}):null]})})}),e?.isGitRepo&&T.pickerOpen&&q(ho,{color:t.BORDER,children:[q(U,{marginBottom:0,children:[K(W,{color:t.DIM,children:`@ `}),K(W,{color:t.PRIMARY,children:T.pickerQuery}),K(W,{color:t.DIM,children:T.pickerQuery?``:`type to filter`})]}),K(pE,{options:T.filteredOptions,selectedIndex:T.pickerIndex,isLoading:T.remoteLoading,gitState:e})]}),e?.isGitRepo&&!T.pickerOpen&&K(U,{marginTop:1,paddingX:1,children:q(W,{color:t.DIM,children:[K(W,{color:t.PRIMARY,children:`@`}),` add context`]})})]}),K(Ow,{message:h})]})},OE=e=>{let t=vi(10);if(t[0]!==`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`){for(let e=0;e<10;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`}let{segment:n,mutedColor:r}=e,i=n.color??r,a;t[1]!==n.label||t[2]!==i?(a=q(W,{color:i,children:[n.label,` `]}),t[1]=n.label,t[2]=i,t[3]=a):a=t[3];let o=n.color??r,s;t[4]!==n.key||t[5]!==o?(s=q(W,{color:o,children:[`[`,n.key,`]`]}),t[4]=n.key,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=q(Ti,{children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},kE=e=>{let t=vi(12);if(t[0]!==`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`){for(let e=0;e<12;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e8c3ad7624de558f1292f5717cd6dbce82fb6c0767dc4ab19348dc7a7975d8f5`}let{segments:n,color:r,mutedColor:i}=e,a;t[1]===r?a=t[2]:(a=K(W,{color:r,children:` `}),t[1]=r,t[2]=a);let o;if(t[3]!==i||t[4]!==n){let e;t[6]!==i||t[7]!==n.length?(e=(e,t)=>q(U,{children:[e.onClick?K(_o,{fullWidth:!1,onClick:e.onClick,children:K(OE,{segment:e,mutedColor:i})}):K(OE,{segment:e,mutedColor:i}),t<n.length-1&&K(W,{color:i,children:` `})]},e.key+e.label),t[6]=i,t[7]=n.length,t[8]=e):e=t[8],o=n.map(e),t[3]=i,t[4]=n,t[5]=o}else o=t[5];let s;return t[9]!==a||t[10]!==o?(s=q(U,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s},AE=(e,t)=>{let n=vi(87);if(n[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let e=0;e<87;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let r=mo(),i=Sy(NE),a=MS(PE),o=MS(FE),s=xS(IE),c=xS(LE),l=lw(RE);switch(e._tag){case`Main`:{let e=a?`cookies on`:`cookies off`,r;n[1]!==e||n[2]!==o?(r={key:`ctrl+k`,label:e,cta:!0,onClick:o},n[1]=e,n[2]=o,n[3]=r):r=n[3];let s;n[4]===i?s=n[5]:(s={key:`ctrl+r`,label:`saved flows`,cta:!0,onClick:()=>i(by.SavedFlowPicker())},n[4]=i,n[5]=s);let c;if(n[6]!==t?.isGitRepo||n[7]!==i||n[8]!==r||n[9]!==s){if(c=[r,s],t?.isGitRepo){let e;n[11]===i?e=n[12]:(e={key:`ctrl+p`,label:`pick pr`,cta:!0,onClick:()=>i(by.SelectPr())},n[11]=i,n[12]=e),c.push(e)}n[6]=t?.isGitRepo,n[7]=i,n[8]=r,n[9]=s,n[10]=c}else c=n[10];return c}case`SelectPr`:{let e,t,a;n[13]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},t={key:`←→`,label:`filter`},a={key:`/`,label:`search`},n[13]=e,n[14]=t,n[15]=a):(e=n[13],t=n[14],a=n[15]);let o;n[16]===i?o=n[17]:(o={key:`esc`,label:`back`,cta:!0,onClick:()=>i(by.Main())},n[16]=i,n[17]=o);let s;n[18]===r.PRIMARY?s=n[19]:(s={key:`enter`,label:`select`,color:r.PRIMARY,cta:!0},n[18]=r.PRIMARY,n[19]=s);let c;return n[20]!==o||n[21]!==s?(c=[e,t,a,o,s],n[20]=o,n[21]=s,n[22]=c):c=n[22],c}case`SavedFlowPicker`:{let e;n[23]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},n[23]=e):e=n[23];let t;n[24]===i?t=n[25]:(t={key:`esc`,label:`back`,cta:!0,onClick:()=>i(by.Main())},n[24]=i,n[25]=t);let a;n[26]===r.PRIMARY?a=n[27]:(a={key:`enter`,label:`select`,color:r.PRIMARY,cta:!0},n[26]=r.PRIMARY,n[27]=a);let o;return n[28]!==t||n[29]!==a?(o=[e,t,a],n[28]=t,n[29]=a,n[30]=o):o=n[30],o}case`CookieSyncConfirm`:{let t;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(t={key:`↑↓`,label:`nav`},n[31]=t):t=n[31];let a;n[32]===i?a=n[33]:(a={key:`esc`,label:`back`,onClick:()=>i(by.Main())},n[32]=i,n[33]=a);let o;n[34]!==e.changesFor||n[35]!==e.instruction||n[36]!==e.savedFlow||n[37]!==i?(o={key:`c`,label:`enable sync`,cta:!0,onClick:()=>{i(xy({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow,requiresCookies:!0}))}},n[34]=e.changesFor,n[35]=e.instruction,n[36]=e.savedFlow,n[37]=i,n[38]=o):o=n[38];let s;n[39]!==e.changesFor||n[40]!==e.instruction||n[41]!==e.savedFlow||n[42]!==i?(s=()=>{i(xy({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow,requiresCookies:!1}))},n[39]=e.changesFor,n[40]=e.instruction,n[41]=e.savedFlow,n[42]=i,n[43]=s):s=n[43];let c;n[44]!==r.PRIMARY||n[45]!==s?(c={key:`a`,label:`run anyway`,color:r.PRIMARY,cta:!0,onClick:s},n[44]=r.PRIMARY,n[45]=s,n[46]=c):c=n[46];let l;return n[47]!==a||n[48]!==o||n[49]!==c?(l=[t,a,o,c],n[47]=a,n[48]=o,n[49]=c,n[50]=l):l=n[50],l}case`PortPicker`:{let e,t,a;n[51]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},t={key:`space`,label:`toggle`},a={key:`/`,label:`custom port`},n[51]=e,n[52]=t,n[53]=a):(e=n[51],t=n[52],a=n[53]);let o;n[54]===i?o=n[55]:(o={key:`esc`,label:`back`,cta:!0,onClick:()=>i(by.Main())},n[54]=i,n[55]=o);let s;n[56]===r.PRIMARY?s=n[57]:(s={key:`enter`,label:`confirm`,color:r.PRIMARY,cta:!0},n[56]=r.PRIMARY,n[57]=s);let c;return n[58]!==o||n[59]!==s?(c=[e,t,a,o,s],n[58]=o,n[59]=s,n[60]=c):c=n[60],c}case`Testing`:{let e=s===!0?`notify on`:`notify off`,t=l?`collapse`:`expand`,r;n[61]!==e||n[62]!==c?(r={key:`ctrl+n`,label:e,cta:!0,onClick:c},n[61]=e,n[62]=c,n[63]=r):r=n[63];let i;n[64]===t?i=n[65]:(i={key:`ctrl+o`,label:t,cta:!0},n[64]=t,n[65]=i);let a=l?`collapse`:`cancel`,o;n[66]===a?o=n[67]:(o={key:`esc`,label:a},n[66]=a,n[67]=o);let u;return n[68]!==r||n[69]!==i||n[70]!==o?(u=[r,i,o],n[68]=r,n[69]=i,n[70]=o,n[71]=u):u=n[71],u}case`Results`:{let t;n[72]===Symbol.for(`react.memo_cache_sentinel`)?(t={key:`y`,label:`copy`,cta:!0},n[72]=t):t=n[72];let r;if(n[73]!==e.report.changesFor||n[74]!==e.report.instruction||n[75]!==e.report.pullRequest||n[76]!==i){if(r=[t],A(e.report.pullRequest)){let e;n[78]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`p`,label:`post to PR`,cta:!0},n[78]=e):e=n[78],r.push(e)}let a;n[79]===Symbol.for(`react.memo_cache_sentinel`)?(a={key:`s`,label:`save flow`,cta:!0},n[79]=a):a=n[79],r.push(a);let o;n[80]!==e.report.changesFor||n[81]!==e.report.instruction||n[82]!==i?(o={key:`r`,label:`restart`,cta:!0,onClick:()=>{lw.getState().setExecutedPlan(void 0),i(xy({changesFor:e.report.changesFor,instruction:e.report.instruction}))}},n[80]=e.report.changesFor,n[81]=e.report.instruction,n[82]=i,n[83]=o):o=n[83],r.push(o);let s;n[84]===i?s=n[85]:(s={key:`esc`,label:`main menu`,cta:!0,onClick:()=>{lw.getState().setExecutedPlan(void 0),i(by.Main())}},n[84]=i,n[85]=s),r.push(s),n[73]=e.report.changesFor,n[74]=e.report.instruction,n[75]=e.report.pullRequest,n[76]=i,n[77]=r}else r=n[77];return r}default:{let e;return n[86]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[86]=e):e=n[86],e}}},jE=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,ME=()=>{let e=vi(35);if(e[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let t=0;t<35;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let[t]=uo(),{data:n}=sE(),r=Sy(zE),i=AE(r,n),a,o;e[1]===i?(a=e[2],o=e[3]):(a=i.filter(BE),o=ta(jE(a)),e[1]=i,e[2]=a,e[3]=o);let s=o,c=HE,l,u,d,f,p,m,h;if(e[4]!==i||e[5]!==t||e[6]!==s||e[7]!==r._tag){let n=i.filter(UE),a=c(n)+s+2>t?n.filter(WE):n,o=c(a);d=Math.max(0,t-o-s-2),u=U,m=`column`,e[15]!==t||e[16]!==r._tag?(h=r._tag===`Testing`?K(cw,{text:`─`.repeat(t),baseColor:fo.shimmerBase,highlightColor:fo.shimmerHighlight,speed:3}):K(W,{color:fo.border,children:`─`.repeat(t)}),e[15]=t,e[16]=r._tag,e[17]=h):h=e[17],l=U,f=1,p=a.map(GE),e[4]=i,e[5]=t,e[6]=s,e[7]=r._tag,e[8]=l,e[9]=u,e[10]=d,e[11]=f,e[12]=p,e[13]=m,e[14]=h}else l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14];let g;e[18]===d?g=e[19]:(g=` `.repeat(d),e[18]=d,e[19]=g);let _;e[20]===g?_=e[21]:(_=K(W,{children:g}),e[20]=g,e[21]=_);let v;e[22]===a?v=e[23]:(v=a.length>0?K(kE,{segments:a,color:fo.primary,mutedColor:fo.textMuted}):null,e[22]=a,e[23]=v);let y;e[24]!==l||e[25]!==f||e[26]!==p||e[27]!==_||e[28]!==v?(y=q(l,{paddingX:f,children:[p,_,v]}),e[24]=l,e[25]=f,e[26]=p,e[27]=_,e[28]=v,e[29]=y):y=e[29];let b;return e[30]!==u||e[31]!==m||e[32]!==h||e[33]!==y?(b=q(u,{flexDirection:m,children:[h,y]}),e[30]=u,e[31]=m,e[32]=h,e[33]=y,e[34]=b):b=e[34],b};function NE(e){return e.setScreen}function PE(e){return e.cookiesEnabled}function FE(e){return e.toggleCookies}function IE(e){return e.notifications}function LE(e){return e.toggleNotifications}function RE(e){return e.expanded}function zE(e){return e.screen}function BE(e){return!e.cta}function VE(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function HE(e){return ta(e.map(VE).join(` `))}function UE(e){return e.cta}function WE(e){return e.key!==`ctrl+p`}function GE(e,t){let n=q(W,{children:[t>0?` `:``,e.color?q(W,{backgroundColor:e.color,color:`black`,children:[` `,K(W,{bold:!0,children:e.label}),` `,q(W,{children:[`[`,e.key,`]`]}),` `]}):q(W,{children:[q(W,{color:fo.textMuted,children:[e.label,` `]}),q(W,{color:fo.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?K(_o,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let KE=null;const qE=e=>{KE=e},JE=()=>KE?.clear(),YE=e=>{let t=vi(32);if(t[0]!==`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`){for(let e=0;e<32;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`}let{agent:n}=e,r=Sy(XE),i=Sy(ZE),a=Sy(QE),{data:o}=sE(),s=fa(nT),c,l;t[1]!==n||t[2]!==s?(c=()=>{s(ii(n))},l=[n,s],t[1]=n,t[2]=s,t[3]=c,t[4]=l):(c=t[3],l=t[4]),Si(c,l);let u;t[5]!==r._tag||t[6]!==i?(u=()=>{if(r._tag===`CookieSyncConfirm`){i(by.Main());return}if(r._tag===`PortPicker`){i(by.Main());return}if(r._tag===`Results`){lw.getState().setExecutedPlan(void 0),i(by.Main());return}r._tag!==`Testing`&&i(by.Main())},t[5]=r._tag,t[6]=i,t[7]=u):u=t[7];let d=u,[,f]=G(0),[,p]=uo(),m;t[8]!==o?.isGitRepo||t[9]!==d||t[10]!==a||t[11]!==r._tag||t[12]!==f?(m=(e,t)=>{if(t.ctrl&&e===`l`){JE(),f($E);return}t.escape&&r._tag!==`Main`&&d(),t.ctrl&&e===`p`&&r._tag===`Main`&&o?.isGitRepo&&a(by.SelectPr()),t.ctrl&&e===`r`&&r._tag===`Main`&&a(by.SavedFlowPicker())},t[8]=o?.isGitRepo,t[9]=d,t[10]=a,t[11]=r._tag,t[12]=f,t[13]=m):m=t[13],fi(m);let h;t[14]!==o||t[15]!==r._tag||t[16]!==r.baseUrls||t[17]!==r.changesFor||t[18]!==r.instruction||t[19]!==r.localReplayUrl||t[20]!==r.replayUrl||t[21]!==r.report||t[22]!==r.requiresCookies||t[23]!==r.savedFlow||t[24]!==r.videoUrl?(h=()=>{if(!o)return K(DE,{gitState:void 0});switch(r._tag){case`PortPicker`:return K(WS,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies});case`Testing`:return K(PT,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies,baseUrls:r.baseUrls});case`Results`:return K(tE,{report:r.report,replayUrl:r.replayUrl,localReplayUrl:r.localReplayUrl,videoUrl:r.videoUrl});case`SelectPr`:return K(Ty,{});case`CookieSyncConfirm`:return K(OS,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow});case`SavedFlowPicker`:return K(uE,{});default:return K(DE,{gitState:o})}},t[14]=o,t[15]=r._tag,t[16]=r.baseUrls,t[17]=r.changesFor,t[18]=r.instruction,t[19]=r.localReplayUrl,t[20]=r.replayUrl,t[21]=r.report,t[22]=r.requiresCookies,t[23]=r.savedFlow,t[24]=r.videoUrl,t[25]=h):h=t[25];let g=h,_;t[26]===g?_=t[27]:(_=K(U,{flexGrow:1,children:g()}),t[26]=g,t[27]=_);let v;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(ME,{}),t[28]=v):v=t[28];let y;return t[29]!==p||t[30]!==_?(y=K(io,{children:q(U,{flexDirection:`column`,width:`100%`,height:p,children:[_,v]})}),t[29]=p,t[30]=_,t[31]=y):y=t[31],y};function XE(e){return e.screen}function ZE(e){return e.setScreen}function QE(e){return e.navigateTo}function $E(e){return e+1}const eD=()=>{let e=Ji();return e===`darwin`?`afplay /System/Library/Sounds/Glass.aiff`:e===`win32`?`powershell -c (New-Object Media.SoundPlayer 'C:\\Windows\\Media\\chimes.wav').PlaySync()`:`paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null || aplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null`},tD=()=>new Promise(e=>{Ri(eD(),()=>e())}),nD=e=>N(iT(O(function*(){let t=yield*bv,n=yield*xv,r=yield*yS,i=Date.now();yield*r.capture(`session:started`,{mode:`headless`,skip_planning:!1,browser_headed:e.headed}),console.log(`expect v${Xa}`),console.log(`Testing ${Wo(e.changesFor)}`),console.log(`Starting browser test...`);let a=Date.now();yield*r.capture(`run:started`,{plan_id:`direct`});let o=new Set,s=yield*t.execute({changesFor:e.changesFor,instruction:e.instruction,isHeadless:!e.headed,requiresCookies:!1}).pipe(f(e=>rr(()=>{for(let t of e.events)if(!o.has(t.id))switch(o.add(t.id),t._tag){case`RunStarted`:console.log(`Starting ${t.plan.title}`);break;case`StepStarted`:console.log(`${J.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${J.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${J.cross} ${t.stepId} ${t.message}`);break}})),Ze,L(t=>t._tag===`Some`?t.value:new Cs({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!e.headed,requiresCookies:!1,testCoverage:Qe(),title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),c=yield*n.report(s),l=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`passed`).length,u=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`failed`).length;yield*r.capture(`run:completed`,{plan_id:s.id??`direct`,passed:l,failed:u,step_count:s.steps.length,file_count:0,duration_ms:Date.now()-a}),yield*r.capture(`session:ended`,{session_ms:Date.now()-i}),yield*r.flush,console.error(`\n${c.toPlainText}`),yield*ai(()=>tD()),process.exit(c.status===`passed`?0:1)}).pipe(m(tT({verbose:e.verbose,agent:e.agent}))))),rD={error:Ei.red,warn:Ei.yellow,info:Ei.cyan,success:Ei.green,dim:Ei.dim},iD={error:(...e)=>{console.log(rD.error(e.join(` `)))},warn:(...e)=>{console.log(rD.warn(e.join(` `)))},info:(...e)=>{console.log(rD.info(e.join(` `)))},success:(...e)=>{console.log(rD.success(e.join(` `)))},dim:(...e)=>{console.log(rD.dim(e.join(` `)))},log:(...e)=>{console.log(e.join(` `))},break:()=>{console.log(``)}},aD=()=>{iD.break(),iD.log(`Cancelled.`),iD.break(),process.exit(0)},oD=e=>xa(e,{onCancel:aD}),sD=(e,t)=>Sa({text:e,isSilent:t?.silent}),cD=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],lD=()=>cD.some(e=>!!process.env[e]),uD=()=>!process.stdin.isTTY,dD={npm:`npm install -g expect-cli@latest`,pnpm:`pnpm add -g expect-cli@latest`,yarn:`yarn global add expect-cli@latest`,bun:`bun add -g expect-cli@latest`,vp:`vp install -g expect-cli@latest`},fD=`npx skills add https://github.com/millionco/expect --skill expect-cli`,pD=()=>{if(process.env.VITE_PLUS_CLI_BIN)return`vp`;let e=process.env.npm_config_user_agent;if(e){if(e.startsWith(`pnpm`))return`pnpm`;if(e.startsWith(`yarn`))return`yarn`;if(e.startsWith(`bun`))return`bun`;if(e.startsWith(`npm`))return`npm`}return`npm`},mD=e=>e||lD()||uD(),hD=e=>new Promise(t=>{Ri(e,e=>{t(!e)})}),gD=async(e={})=>{let t=mD(e.yes??!1),n=dD[pD()];iD.break(),iD.log(` ${Ei.red(J.cross)}${Ei.green(J.tick)} ${Ei.bold(`Expect`)} ${rD.dim(`v${Xa}`)}`),iD.break(),vu().length===0&&(iD.error(`No supported coding agent found. expect requires one of: Claude Code, Codex, or Cursor.`),iD.break(),iD.log(` Install one to get started:`),iD.log(` ${rD.info(`Claude Code`)} ${rD.dim(`https://docs.anthropic.com/en/docs/claude-code`)}`),iD.log(` ${rD.info(`Codex`)} ${rD.dim(`https://github.com/openai/codex`)}`),iD.log(` ${rD.info(`Cursor`)} ${rD.dim(`https://cursor.com`)}`),iD.break(),process.exit(1));let r=sD(`Installing expect-cli globally...`).start();await hD(n)?r.succeed(`Installed! You can now run ${rD.info(`expect-cli`)} from anywhere.`):(r.fail(`Failed to install globally.`),iD.dim(` Run manually: ${rD.info(n)}`)),iD.break();let i=t;if(t||(i=(await oD({type:`confirm`,name:`installSkill`,message:`Install the ${rD.info(`expect`)} skill for your coding agent?`,initial:!0})).installSkill),i){let e=sD(`Installing skill...`).start();await hD(fD)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),iD.dim(` Run manually: ${rD.info(fD)}`))}iD.break(),iD.success(`You're all set!`),iD.log(` Run ${rD.info(`expect-cli`)} in any project to start testing.`),iD.break()},_D=[`packages/*`,`apps/*`],vD=e=>$a.some(t=>e.includes(t)),yD=R(`detectAgent`)(function*(e){let t=yield*Qr;for(let[n,r]of Object.entries(eo)){let i=Di.join(e,n);if(yield*t.exists(i).pipe(V(`PlatformError`,()=>B(!1))))return r}let n=Di.join(e,`package.json`),r=yield*t.readFileString(n).pipe(V(`PlatformError`,()=>B(``)));if(r){let e=yield*cn({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})}).pipe(V(`JsonParseError`,()=>B(void 0)));if(e?.packageManager){let t=e.packageManager.split(`@`)[0];if(t)return t}}return`npm`}),bD=R(`readPackageJson`)(function*(e){let t=yield*Qr,n=Di.join(e,`package.json`),r=yield*t.readFileString(n);return yield*cn({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})})}),xD=R(`listWorkspaceDirectories`)(function*(e){let t=yield*Qr,n=[];for(let r of _D){let i=Di.join(e,Di.dirname(r)),a=yield*t.readDirectory(i).pipe(V(`PlatformError`,()=>B([])));for(let e of a){let r=Di.join(i,e);(yield*t.stat(r).pipe(V(`PlatformError`,()=>B(void 0))))?.type===`Directory`&&n.push(r)}}return n}),SD=(e,t,n)=>new Promise(r=>{zi(e,[`run`,n],{cwd:t,timeout:12e4,maxBuffer:5*1024*1024},(e,t,i)=>{let a=(t+`
|
|
46
|
+
`+i).trim();r({script:n,passed:!e,output:a})})}),CD=R(`discoverPackages`)(function*(e){let t=yield*xD(e),n=[];for(let e of t){let t=yield*bD(e).pipe(V(`PlatformError`,()=>B(void 0)),V(`JsonParseError`,()=>B(void 0)));if(!t?.scripts)continue;let r=Object.keys(t.scripts).filter(vD);r.length!==0&&n.push({packageName:t.name??Di.basename(e),directory:e,scripts:r})}return n}),wD=async(e,t)=>N(O(function*(){let n=yield*yD(e);return yield*rt(yield*CD(e),e=>O(function*(){t.onPackageStart(e.packageName,e.scripts);let r=[];for(let i of e.scripts){let a=yield*ai(()=>SD(n,e.directory,i));t.onScriptDone(e.packageName,a),r.push(a)}return{packageName:e.packageName,directory:e.directory,results:r}}),{concurrency:4})}).pipe(m(Ii.layer))),TD=e=>{let t=vi(5);if(t[0]!==`2d9c928ad4631c339250b8fd0f4c153b8184fa5a47421a54f29b7df14a1f0cc5`){for(let e=0;e<5;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`2d9c928ad4631c339250b8fd0f4c153b8184fa5a47421a54f29b7df14a1f0cc5`}let{statusMap:n}=e,r;if(t[1]!==n){let e=Array.from(n.entries()),i,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=K(W,{bold:!0,children:`expect audit`}),a=K(W,{children:` `}),t[3]=i,t[4]=a):(i=t[3],a=t[4]),r=q(U,{flexDirection:`column`,paddingY:1,children:[i,a,e.map(ND)]}),t[1]=n,t[2]=r}else r=t[2];return r},ED=e=>{let t=vi(12);if(t[0]!==`2d9c928ad4631c339250b8fd0f4c153b8184fa5a47421a54f29b7df14a1f0cc5`){for(let e=0;e<12;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`2d9c928ad4631c339250b8fd0f4c153b8184fa5a47421a54f29b7df14a1f0cc5`}let{results:n}=e,r=0,i=0;for(let e of n)for(let t of e.results)t.passed?r++:i++;let a=`${r} passed, ${i} failed`,o=i>0?`red`:`green`,s;t[1]!==a||t[2]!==o?(s=K(W,{bold:!0,color:o,children:a}),t[1]=a,t[2]=o,t[3]=s):s=t[3];let c;t[4]===i?c=t[5]:(c=i>0&&q(W,{color:`yellow`,children:[`Run `,K(W,{bold:!0,children:`expect`}),` to test your changes in a real browser and catch issues before they ship.`]}),t[4]=i,t[5]=c);let l;t[6]===i?l=t[7]:(l=i===0&&q(W,{color:`green`,children:[`Looking good! Run `,K(W,{bold:!0,children:`expect`}),` to verify your changes work end-to-end in the browser.`]}),t[6]=i,t[7]=l);let u;return t[8]!==s||t[9]!==c||t[10]!==l?(u=q(U,{flexDirection:`column`,gap:1,children:[s,c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u},DD=async()=>{let e=process.cwd(),t={current:new Map},n,r,i=di(K(()=>{let[e,t]=G(new Map),[i,a]=G();return n=e=>t(new Map(e)),r=a,q(U,{flexDirection:`column`,children:[K(TD,{statusMap:e}),i&&K(ED,{results:i})]})},{})),a=await wD(e,{onPackageStart:(e,r)=>{t.current.set(e,{scripts:r,completed:[],done:!1}),n?.(t.current)},onScriptDone:(e,r)=>{let i=t.current.get(e);i&&(i.completed.push(r),i.done=i.completed.length===i.scripts.length),n?.(t.current)}});r?.(a),setTimeout(()=>{i.unmount(),a.reduce((e,t)=>e+t.results.filter(e=>!e.passed).length,0)>0&&process.exit(1)},100)},OD=async()=>{let e=process.cwd();console.log(``),console.log(Ei.bold(`expect audit`)),console.log(``);let t=await wD(e,{onPackageStart:(e,t)=>{console.log(`${J.arrowRight} ${Ei.bold(e)} (${t.join(`, `)})`)},onScriptDone:(e,t)=>{let n=t.passed?Ei.green(J.tick):Ei.red(J.cross);if(console.log(` ${n} ${t.script}`),!t.passed){let e=t.output.split(`
|
|
45
47
|
`).slice(-3).join(`
|
|
46
|
-
`);console.log(
|
|
48
|
+
`);console.log(Ei.dim(` ${e.split(`
|
|
47
49
|
`).join(`
|
|
48
|
-
`)}`))}}}),n=0,r=0;for(let e of t)for(let t of e.results)t.passed?n++:r++;console.log(``);let i=`${n} passed, ${r} failed`,a=r>0?
|
|
50
|
+
`)}`))}}}),n=0,r=0;for(let e of t)for(let t of e.results)t.passed?n++:r++;console.log(``);let i=`${n} passed, ${r} failed`,a=r>0?Ei.red:Ei.green;console.log(a(Ei.bold(i))),r>0?(console.log(``),console.log(Ei.yellow(`Run ${Ei.bold(`expect`)} to test your changes in a real browser and catch issues before they ship.`))):(console.log(``),console.log(Ei.green(`Looking good! Run ${Ei.bold(`expect`)} to verify your changes work end-to-end in the browser.`))),console.log(``),r>0&&process.exit(1)},kD=async()=>{lD()||uD()?await OD():await DD()};function AD(e){return e.passed}function jD(e){return q(U,{flexDirection:`column`,children:[q(W,{children:[` `,e.passed?K(W,{color:`green`,children:J.tick}):K(W,{color:`red`,children:J.cross}),` `,e.script]}),!e.passed&&q(W,{color:`gray`,children:[` `,e.output.split(`
|
|
49
51
|
`).slice(-3).join(`
|
|
50
|
-
`)]})]},e.script)}function
|
|
52
|
+
`)]})]},e.script)}function MD(e){return q(W,{color:`gray`,children:[` `,K($i,{type:`dots`}),` `,e]},e)}function ND(e){let[t,n]=e;return q(U,{flexDirection:`column`,children:[q(U,{children:[n.done&&K(W,{children:n.completed.every(AD)?K(W,{color:`green`,children:J.tick}):K(W,{color:`red`,children:J.cross})}),!n.done&&K(W,{color:`white`,children:K($i,{type:`dots`})}),q(W,{bold:!0,children:[` `,t]})]}),n.completed.map(jD),!n.done&&n.scripts.filter(e=>!n.completed.some(t=>t.script===e)).slice(0,1).map(MD)]},t)}const PD=[`unstaged`,`branch`,`changes`],FD=new li().name(`expect`).description(`AI-powered browser testing for your changes`).version(Xa,`-v, --version`).option(`-m, --message <instruction>`,`natural language instruction for what to test`).option(`-f, --flow <slug>`,`reuse a saved flow by its slug`).option(`-y, --yes`,`run immediately without confirmation`).option(`-a, --agent <provider>`,`agent provider to use (claude or codex)`).option(`-t, --target <target>`,`what to test: unstaged, branch, or changes`,`changes`).option(`--verbose`,`enable verbose logging`).option(`--headed`,`show a visible browser window during tests`).option(`--replay-host <url>`,`website host for live replay viewer`,`https://expect.dev`).addHelpText(`after`,`
|
|
51
53
|
Examples:
|
|
52
54
|
$ expect open interactive TUI
|
|
53
55
|
$ expect -m "test the login flow" -y run immediately
|
|
54
56
|
$ expect --headed -m "smoke test" -y run with a visible browser
|
|
55
57
|
$ expect --target branch test all branch changes
|
|
56
|
-
$ expect --target unstaged test unstaged changes`),
|
|
58
|
+
$ expect --target unstaged test unstaged changes`),ID=`\x1B[?1000l\x1B[?1006l`,LD=async e=>{let t=Date.now();await wS(),process.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`),process.on(`exit`,()=>process.stdout.write(ID+Za));let n=di(K(ua,{initialValues:[[nT,ii(e)]],children:K(hi,{client:Cy,children:K(YE,{agent:e})})}));qE(n),await n.waitUntilExit(),await TS(t),process.stdout.write(ID+Za),process.exit(0)},RD=async e=>{let t=process.cwd();return N(O(function*(){let t=yield*vv,n=yield*t.getMainBranch,r=yield*t.getCurrentBranch;return e===`branch`?{changesFor:Uo.makeUnsafe({_tag:`Branch`,mainBranch:n}),currentBranch:r}:e===`changes`?{changesFor:Uo.makeUnsafe({_tag:`Changes`,mainBranch:n}),currentBranch:r}:{changesFor:Uo.makeUnsafe({_tag:`WorkingTree`}),currentBranch:r}}).pipe(m(vv.withRepoRoot(t))))},zD=(e,t)=>{xS.setState({...e.agent?{agentBackend:e.agent}:{},browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),e.message?Sy.setState({screen:by.Testing({changesFor:t,instruction:e.message})}):Sy.setState({screen:by.Main()})},BD=async(e,t)=>{let{changesFor:n}=await RD(e);return nD({changesFor:n,instruction:t.message??`Test all changes from main in the browser and verify they work correctly.`,agent:t.agent??`claude`,verbose:t.verbose??!1,headed:t.headed??!1})},VD=async(e,t)=>{let{changesFor:n}=await RD(e);zD(t,n),LD(t.agent??`claude`)};FD.command(`init`).description(`set up expect for your coding agent`).option(`-y, --yes`,`skip confirmation prompts`).action(async e=>{await gD(e)}),FD.command(`audit`).description(`audit your workspace for lint, type, and formatting issues`).action(async()=>{await kD()}),FD.action(async()=>{let e=FD.opts(),t=e.target??`changes`;if(PD.includes(t)||FD.error(`Unknown target: ${t}. Use ${PD.join(`, `)}.`),lD()||uD())return BD(t,e);e.message||e.flow||e.yes?await VD(t,e):(xS.setState({browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),LD(e.agent??`claude`))}),FD.parse();export{};
|
|
57
59
|
//# sourceMappingURL=index.js.map
|