expect-cli 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{n as e,r as t,t as n}from"./chunk-wdO_pP5q.js";import{i as r}from"./server-D8tFfvqo.js";import{createRequire as i}from"node:module";import{Array as a,Cause as o,
|
|
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}),V(E,{children:t?_.length>0?v:y:v})},Rt=e=>{let t=ne(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=Ot();if(n){let e;t[1]===o.DIM?e=t[2]:(e=V(E,{color:o.DIM,children:`/`}),t[1]=o.DIM,t[2]=e);let n;t[3]!==i||t[4]!==a||t[5]!==r?(n=V(Lt,{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=H(w,{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=V(w,{marginTop:1,children:H(E,{color:o.DIM,children:[`/`,r]})}),t[10]=o.DIM,t[11]=r,t[12]=e):e=t[12],e}return null},zt=b.Literals([`pending`,`in_progress`,`completed`,`failed`]),Bt=b.Literals([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);b.Literals([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const Vt=b.Union([b.Struct({type:b.Literal(`text`),text:b.String}),b.Struct({type:b.Literal(`image`),data:b.String,mimeType:b.String}),b.Struct({type:b.Literal(`resource_link`),uri:b.String}),b.Struct({type:b.Literal(`resource`),uri:b.String})]),Ht=b.Union([b.Struct({type:b.Literal(`content`),content:Vt}),b.Struct({type:b.Literal(`diff`),path:b.String,oldText:b.optional(b.NullOr(b.String)),newText:b.optional(b.NullOr(b.String))}),b.Struct({type:b.Literal(`terminal`),terminalId:b.String})]),Ut=b.Struct({path:b.String,lineNumber:b.optional(b.NullOr(b.Number))});var Wt=class extends b.Class(`AcpAgentMessageChunk`)({sessionUpdate:b.Literal(`agent_message_chunk`),content:Vt,messageId:b.optional(b.NullOr(b.String))}){},Gt=class extends b.Class(`AcpAgentThoughtChunk`)({sessionUpdate:b.Literal(`agent_thought_chunk`),content:Vt,messageId:b.optional(b.NullOr(b.String))}){},Kt=class extends b.Class(`AcpUserMessageChunk`)({sessionUpdate:b.Literal(`user_message_chunk`),content:Vt,messageId:b.optional(b.NullOr(b.String))}){},qt=class extends b.Class(`AcpToolCall`)({sessionUpdate:b.Literal(`tool_call`),toolCallId:b.String,title:b.String,kind:b.optional(Bt),status:b.optional(zt),content:b.optional(b.Array(Ht)),locations:b.optional(b.Array(Ut)),rawInput:b.optional(b.Unknown),rawOutput:b.optional(b.Unknown)}){},Jt=class extends b.Class(`AcpToolCallUpdate`)({sessionUpdate:b.Literal(`tool_call_update`),toolCallId:b.String,title:b.optional(b.NullOr(b.String)),kind:b.optional(b.NullOr(Bt)),status:b.optional(b.NullOr(zt)),content:b.optional(b.NullOr(b.Array(Ht))),locations:b.optional(b.NullOr(b.Array(Ut))),rawInput:b.optional(b.Unknown),rawOutput:b.optional(b.Unknown)}){};const Yt=b.Literals([`pending`,`in_progress`,`completed`]),Xt=b.Literals([`high`,`medium`,`low`]);var Zt=class extends b.Class(`AcpPlanUpdate`)({sessionUpdate:b.Literal(`plan`),entries:b.Array(b.Struct({content:b.String,priority:Xt,status:Yt}))}){},Qt=class extends b.Class(`AcpAvailableCommandsUpdate`)({sessionUpdate:b.Literal(`available_commands_update`)}){},$t=class extends b.Class(`AcpCurrentModeUpdate`)({sessionUpdate:b.Literal(`current_mode_update`)}){},en=class extends b.Class(`AcpConfigOptionUpdate`)({sessionUpdate:b.Literal(`config_option_update`)}){},tn=class extends b.Class(`AcpSessionInfoUpdate`)({sessionUpdate:b.Literal(`session_info_update`)}){},nn=class extends b.Class(`AcpUsageUpdate`)({sessionUpdate:b.Literal(`usage_update`)}){};const rn=b.Union([Wt,Gt,Kt,qt,Jt,Zt,Qt,$t,en,tn,nn]);b.Struct({inputTokens:b.Number,outputTokens:b.Number,cachedReadTokens:b.optional(b.NullOr(b.Number)),cachedWriteTokens:b.optional(b.NullOr(b.Number)),thoughtTokens:b.optional(b.NullOr(b.Number))});const an=b.Literals([`claude`,`codex`,`cursor`]);var on=class extends b.Class(`@ami/FileStat`)({relativePath:b.String,added:b.Number,removed:b.Number}){},sn=class extends b.Class(`@supervisor/GitState`)({isGitRepo:b.Boolean,currentBranch:b.String,mainBranch:b.UndefinedOr(b.String),isOnMain:b.Boolean,hasChangesFromMain:b.Boolean,hasUnstagedChanges:b.Boolean,hasBranchCommits:b.Boolean,branchCommitCount:b.Number,fileStats:b.Array(on),workingTreeFileStats:b.Array(on),fingerprint:b.UndefinedOr(b.String),savedFingerprint:b.UndefinedOr(b.String)}){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 cn=b.String.pipe(b.brand(`StepId`)),ln=b.String.pipe(b.brand(`PlanId`)),un=b.TaggedUnion({WorkingTree:{},Branch:{mainBranch:b.String},Changes:{mainBranch:b.String},Commit:{hash:b.String}}),dn=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),fn=b.Struct({number:b.Number,headRefName:b.String,author:b.Struct({login:b.String}),state:b.String,updatedAt:b.String}),pn=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var mn=class extends b.Class(`@supervisor/RemoteBranch`)({name:b.String,author:b.String,prNumber:b.NullOr(b.Number),prStatus:b.NullOr(b.Literals([`open`,`draft`,`merged`])),updatedAt:b.NullOr(b.String)}){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 hn=b.Literals([`pending`,`active`,`passed`,`failed`]);var gn=class e extends b.Class(`@supervisor/TestPlanStep`)({id:cn,title:b.String,instruction:b.String,expectedOutcome:b.String,routeHint:b.OptionFromNullOr(b.String),status:hn,summary:b.OptionFromNullOr(b.String),startedAt:b.OptionFromNullOr(b.DateTimeUtc),endedAt:b.OptionFromNullOr(b.DateTimeUtc)}){update(t){return new e({...this,...t})}},_n=class extends b.Class(`@supervisor/TestCoverageEntry`)({path:b.String,testFiles:b.Array(b.String),covered:b.Boolean}){},vn=class extends b.Class(`@supervisor/TestCoverageReport`)({entries:b.Array(_n),coveredCount:b.Number,totalCount:b.Number,percent:b.Number}){};const yn=b.String.pipe(b.brand(`DraftId`));var bn=class e extends b.Class(`@supervisor/TestPlanDraft`)({id:yn,changesFor:un,currentBranch:b.String,diffPreview:b.String,fileStats:b.Array(on),instruction:b.String,baseUrl:b.Option(b.String),isHeadless:b.Boolean,requiresCookies:b.Boolean,testCoverage:b.Option(vn)}){update(t){return new e({...this,...t})}},xn=class e extends bn.extend(`@supervisor/TestPlan`)({id:ln,title:b.String,rationale:b.String,steps:b.Array(gn)}){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 gn({...e,status:`pending`,summary:h.none(),startedAt:h.none(),endedAt:h.none()}))})}},Sn=class extends b.TaggedClass()(`RunStarted`,{plan:xn}){get id(){return`run-started-${this.plan.id}`}},Cn=class extends b.TaggedClass()(`StepStarted`,{stepId:cn,title:b.String}){get id(){return`step-started-${this.stepId}`}},wn=class extends b.TaggedClass()(`StepCompleted`,{stepId:cn,summary:b.String}){get id(){return`step-completed-${this.stepId}`}},Tn=class extends b.TaggedClass()(`StepFailed`,{stepId:cn,message:b.String}){get id(){return`step-failed-${this.stepId}`}},En=class extends b.TaggedClass()(`ToolCall`,{toolName:b.String,input:b.Unknown}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return g.isObject(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},Dn=class extends b.TaggedClass()(`ToolProgress`,{toolName:b.String,outputSize:b.Number}){get id(){return`tool-progress-${this.toolName}-${this.outputSize}`}},On=class extends b.TaggedClass()(`ToolResult`,{toolName:b.String,result:b.String,isError:b.Boolean}){get id(){return`tool-result-${this.toolName}-${this.result}`}},kn=class extends b.TaggedClass()(`AgentThinking`,{text:b.String}){get id(){return`agent-thinking-${this.text}`}},An=class extends b.TaggedClass()(`AgentText`,{text:b.String}){get id(){return`agent-text-${this.text}`}},jn=class extends b.TaggedClass()(`RunFinished`,{status:b.Literals([`passed`,`failed`]),summary:b.String}){get id(){return`run-finished-${this.status}`}};const Mn=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)}},Nn=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 Cn({stepId:cn.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new wn({stepId:cn.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new Tn({stepId:cn.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new jn({status:a===`failed`?`failed`:`passed`,summary:o})},Pn=b.Union([Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn]);var Fn=class extends b.TaggedClass()(`RunCompleted`,{report:b.suspend(()=>Kn)}){};const In=b.Union([Sn,Cn,wn,Tn,En,On,kn,jn,Fn]);var Ln=class extends b.Class(`@supervisor/Update`)({content:In,receivedAt:b.DateTimeUtc}){},Rn=class extends b.Class(`@supervisor/PullRequest`)({number:b.Number,url:b.String,title:b.String,headRefName:b.String}){};const zn=b.TaggedUnion({WorkingTree:{},Branch:{branch:mn},PullRequest:{branch:mn},Commit:{hash:b.String,shortHash:b.String,subject:b.String}}),Bn=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),Vn=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),Hn=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),Un=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),Wn=e=>m.value(e).pipe(m.tagsExhaustive({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));b.TaggedUnion({Branch:{branchName:b.String}});var Gn=class e extends xn.extend(`@supervisor/ExecutedTestPlan`)({events:b.Array(Pn)}){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 kn({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new kn({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 An({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new An({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new En({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 En({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 On({toolName:t.title??``,result:Mn(t.rawOutput),isError:t.status===`failed`})]});if(t.rawOutput!==void 0){let r=Mn(t.rawOutput).length;return new e({...n,events:[...n.events.filter(e=>!(e._tag===`ToolProgress`&&e.toolName===(t.title??``))),new Dn({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
|
-
`)}},qn=class extends x.Service()(`@supervisor/Updates`,{make:c.gen(function*(){let e=yield*_.unbounded();return{publish:c.fn(`Updates.publish`)(function*(t){yield*_.publish(e,new Ln({content:t,receivedAt:s.nowUnsafe()}))}),stream:c.fn(`Updates.stream`)(function*(){return S.fromPubSub(e)})}})}){static layer=f.effect(this)(this.make)};const Jn=b.Struct({name:b.String,value:b.String});var Yn=class extends b.Class(`AgentStreamOptions`)({cwd:b.String,sessionId:b.Option(b.String),prompt:b.String,systemPrompt:b.Option(b.String),mcpEnv:b.optional(b.Array(Jn))}){};const Xn={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`},Zn={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`},Qn=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminal:q.boolean().optional().default(!1)}),$n=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),label:q.string().nullish(),name:q.string(),optional:q.boolean().optional().default(!1),secret:q.boolean().optional().default(!0)}),er=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:q.string(),name:q.string()}),tr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:q.string(),link:q.string().nullish(),name:q.string(),vars:q.array($n)}),nr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()).optional(),description:q.string().nullish(),env:q.record(q.string(),q.string()).optional(),id:q.string(),name:q.string()}),rr=q.union([tr.and(q.object({type:q.literal(`env_var`)})),nr.and(q.object({type:q.literal(`terminal`)})),er]),ir=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),methodId:q.string()}),ar=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),or=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),blob:q.string(),mimeType:q.string().nullish(),uri:q.string()}),sr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),cr=q.object({amount:q.number(),currency:q.string()}),lr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminalId:q.string()}),ur=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),newText:q.string(),oldText:q.string().nullish(),path:q.string()}),dr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),value:q.string()}),fr=q.union([q.literal(-32700),q.literal(-32600),q.literal(-32601),q.literal(-32602),q.literal(-32603),q.literal(-32800),q.literal(-32e3),q.literal(-32002),q.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),pr=q.object({code:fr,data:q.unknown().optional(),message:q.string()}),mr=q.unknown(),hr=q.unknown(),gr=q.unknown(),_r=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),readTextFile:q.boolean().optional().default(!1),writeTextFile:q.boolean().optional().default(!1)}),vr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),auth:Qn.optional().default({terminal:!1}),fs:_r.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:q.boolean().optional().default(!1)}),yr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),value:q.string()}),br=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),title:q.string().nullish(),version:q.string()}),xr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Sr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cursor:q.string().nullish(),cwd:q.string().nullish()}),Cr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),http:q.boolean().optional().default(!1),sse:q.boolean().optional().default(!1)}),wr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),headers:q.array(yr),name:q.string(),url:q.string()}),Tr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),headers:q.array(yr),name:q.string(),url:q.string()}),Er=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()),command:q.string(),env:q.array(dr),name:q.string()}),Dr=q.union([wr.and(q.object({type:q.literal(`http`)})),Tr.and(q.object({type:q.literal(`sse`)})),Er]),Or=q.string(),kr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),modelId:Or,name:q.string()}),Ar=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Dr)}),jr=q.string(),Mr=q.union([q.literal(`allow_once`),q.literal(`allow_always`),q.literal(`reject_once`),q.literal(`reject_always`)]),Nr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),kind:Mr,name:q.string(),optionId:jr}),Pr=q.union([q.literal(`high`),q.literal(`medium`),q.literal(`low`)]),Fr=q.union([q.literal(`pending`),q.literal(`in_progress`),q.literal(`completed`)]),Ir=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string(),priority:Pr,status:Fr}),Lr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),entries:q.array(Ir)}),Rr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),audio:q.boolean().optional().default(!1),embeddedContext:q.boolean().optional().default(!1),image:q.boolean().optional().default(!1)}),zr=q.number().int().gte(0).lte(65535),Br=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),clientCapabilities:vr.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:br.nullish(),protocolVersion:zr}),Vr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string()}),Hr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Ur=q.union([q.number(),q.string()]).nullable();q.object({_meta:q.record(q.string(),q.unknown()).nullish(),requestId:Ur});const Wr=q.enum([`assistant`,`user`]),Gr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),audience:q.array(Wr).nullish(),lastModified:q.string().nullish(),priority:q.number().nullish()}),Kr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Gr.nullish(),data:q.string(),mimeType:q.string()}),qr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Gr.nullish(),data:q.string(),mimeType:q.string(),uri:q.string().nullish()}),Jr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Gr.nullish(),description:q.string().nullish(),mimeType:q.string().nullish(),name:q.string(),size:q.number().nullish(),title:q.string().nullish(),uri:q.string()}),Yr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),optionId:jr}),Xr=q.union([q.object({outcome:q.literal(`cancelled`)}),Yr.and(q.object({outcome:q.literal(`selected`)}))]),Zr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),outcome:Xr}),Qr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),$r=q.object({currentValue:q.boolean()}),ei=q.string(),ti=q.string(),ni=q.union([q.literal(`mode`),q.literal(`model`),q.literal(`thought_level`),q.string()]),ri=q.string(),ii=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),name:q.string(),value:ri}),ai=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),group:ei,name:q.string(),options:q.array(ii)}),oi=q.union([q.array(ii),q.array(ai)]),si=q.object({currentValue:ri,options:oi}),ci=q.intersection(q.union([si.and(q.object({type:q.literal(`select`)})),$r.and(q.object({type:q.literal(`boolean`)}))]),q.object({_meta:q.record(q.string(),q.unknown()).nullish(),category:ni.nullish(),description:q.string().nullish(),id:ti,name:q.string()})),li=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci)}),ui=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),di=q.string(),fi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di});q.object({method:q.string(),params:q.union([fi,mr]).nullish()});const pi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di}),mi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()).optional(),command:q.string(),cwd:q.string().nullish(),env:q.array(dr).optional(),outputByteLimit:q.number().nullish(),sessionId:di}),hi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Dr).optional(),sessionId:di}),gi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di,terminalId:q.string()}),_i=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Dr),sessionId:di}),vi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),limit:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:q.string(),sessionId:di}),yi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di,terminalId:q.string()}),bi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Dr).optional(),sessionId:di}),xi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),sessionId:di,title:q.string().nullish(),updatedAt:q.string().nullish()}),Si=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),nextCursor:q.string().nullish(),sessions:q.array(xi)}),Ci=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),title:q.string().nullish(),updatedAt:q.string().nullish()}),wi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Ti=q.string(),Ei=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),currentModeId:Ti}),Di=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:Ti,name:q.string()}),Oi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableModes:q.array(Di),currentModeId:Ti}),ki=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableModels:q.array(kr),currentModelId:Or}),Ai=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci).nullish(),models:ki.nullish(),modes:Oi.nullish(),sessionId:di}),ji=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci).nullish(),models:ki.nullish(),modes:Oi.nullish()}),Mi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci).nullish(),models:ki.nullish(),modes:Oi.nullish(),sessionId:di}),Ni=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci).nullish(),models:ki.nullish(),modes:Oi.nullish()}),Pi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Fi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),close:Qr.nullish(),fork:ui.nullish(),list:wi.nullish(),resume:Pi.nullish()}),Ii=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),loadSession:q.boolean().optional().default(!1),mcpCapabilities:Cr.optional().default({http:!1,sse:!1}),promptCapabilities:Rr.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Fi.optional().default({})}),Li=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),agentCapabilities:Ii.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:br.nullish(),authMethods:q.array(rr).optional().default([]),protocolVersion:zr}),Ri=q.intersection(q.union([q.object({type:q.literal(`boolean`),value:q.boolean()}),q.object({value:ri})]),q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configId:ti,sessionId:di})),zi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(ci)}),Bi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),modeId:Ti,sessionId:di}),Vi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Hi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),modelId:Or,sessionId:di}),Ui=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Wi=q.union([q.literal(`end_turn`),q.literal(`max_tokens`),q.literal(`max_turn_requests`),q.literal(`refusal`),q.literal(`cancelled`)]),Gi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminalId:q.string()}),Ki=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitCode:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:q.string().nullish()}),qi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di,terminalId:q.string()}),Ji=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitStatus:Ki.nullish(),output:q.string(),truncated:q.boolean()}),Yi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Gr.nullish(),text:q.string()}),Xi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),mimeType:q.string().nullish(),text:q.string(),uri:q.string()}),Zi=q.union([Xi,or]),Qi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Gr.nullish(),resource:Zi}),$i=q.union([Yi.and(q.object({type:q.literal(`text`)})),qr.and(q.object({type:q.literal(`image`)})),Kr.and(q.object({type:q.literal(`audio`)})),Jr.and(q.object({type:q.literal(`resource_link`)})),Qi.and(q.object({type:q.literal(`resource`)}))]),ea=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:$i}),ta=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:$i,messageId:q.string().nullish()}),na=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),messageId:q.string().nullish(),prompt:q.array($i),sessionId:di});q.object({id:Ur,method:q.string(),params:q.union([Br,ir,Ar,_i,Sr,hi,bi,pi,Bi,Ri,na,Hi,hr]).nullish()});const ra=q.union([ea.and(q.object({type:q.literal(`content`)})),ur.and(q.object({type:q.literal(`diff`)})),Gi.and(q.object({type:q.literal(`terminal`)}))]),ia=q.string(),aa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),line:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:q.string()}),oa=q.union([q.literal(`pending`),q.literal(`in_progress`),q.literal(`completed`),q.literal(`failed`)]),sa=q.union([q.literal(`read`),q.literal(`edit`),q.literal(`delete`),q.literal(`move`),q.literal(`search`),q.literal(`execute`),q.literal(`think`),q.literal(`fetch`),q.literal(`switch_mode`),q.literal(`other`)]),ca=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.array(ra).optional(),kind:sa.optional(),locations:q.array(aa).optional(),rawInput:q.unknown().optional(),rawOutput:q.unknown().optional(),status:oa.optional(),title:q.string(),toolCallId:ia}),la=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.array(ra).nullish(),kind:sa.nullish(),locations:q.array(aa).nullish(),rawInput:q.unknown().optional(),rawOutput:q.unknown().optional(),status:oa.nullish(),title:q.string().nullish(),toolCallId:ia}),ua=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),options:q.array(Nr),sessionId:di,toolCall:la}),da=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),hint:q.string()}),fa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string(),input:da.nullish(),name:q.string()}),pa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableCommands:q.array(fa)}),ma=q.object({cachedReadTokens:q.number().nullish(),cachedWriteTokens:q.number().nullish(),inputTokens:q.number(),outputTokens:q.number(),thoughtTokens:q.number().nullish(),totalTokens:q.number()}),ha=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),stopReason:Wi,usage:ma.nullish(),userMessageId:q.string().nullish()});q.union([q.object({id:Ur,result:q.union([Li,ar,Mi,ji,Si,Ai,Ni,sr,Vi,zi,ha,Ui,gr])}),q.object({error:pr,id:Ur})]);const ga=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cost:cr.nullish(),size:q.number(),used:q.number()}),_a=q.union([ta.and(q.object({sessionUpdate:q.literal(`user_message_chunk`)})),ta.and(q.object({sessionUpdate:q.literal(`agent_message_chunk`)})),ta.and(q.object({sessionUpdate:q.literal(`agent_thought_chunk`)})),ca.and(q.object({sessionUpdate:q.literal(`tool_call`)})),la.and(q.object({sessionUpdate:q.literal(`tool_call_update`)})),Lr.and(q.object({sessionUpdate:q.literal(`plan`)})),pa.and(q.object({sessionUpdate:q.literal(`available_commands_update`)})),Ei.and(q.object({sessionUpdate:q.literal(`current_mode_update`)})),li.and(q.object({sessionUpdate:q.literal(`config_option_update`)})),Ci.and(q.object({sessionUpdate:q.literal(`session_info_update`)})),ga.and(q.object({sessionUpdate:q.literal(`usage_update`)}))]),va=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di,update:_a});q.object({method:q.string(),params:q.union([va,mr]).nullish()});const ya=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:di,terminalId:q.string()}),ba=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitCode:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:q.string().nullish()}),xa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string(),path:q.string(),sessionId:di});q.object({id:Ur,method:q.string(),params:q.union([xa,vi,ua,mi,qi,yi,ya,gi,hr]).nullish()});const Sa=q.object({_meta:q.record(q.string(),q.unknown()).nullish()});q.union([q.object({id:Ur,result:q.union([Sa,Vr,Zr,lr,Ji,Hr,ba,xr,gr])}),q.object({error:pr,id:Ur})]);function Ca(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{i as r}from"./server-D8tFfvqo.js";import{createRequire as i}from"node:module";import{Array as a,Cause as o,Config as s,DateTime as c,Effect as l,Exit as u,FiberMap as d,FileSystem as f,Layer as p,Logger as m,Match as h,Option as g,Predicate as _,PubSub as v,Queue as y,References as b,Schema as x,ServiceMap as S,Stream as C}from"effect";import{Command as w}from"commander";import{Box as T,Static as ee,Text as E,render as D,useApp as O,useInput as te,useStdout as k}from"ink";import{QueryClient as A,QueryClientProvider as ne,useMutation as j,useQuery as M}from"@tanstack/react-query";import{c as N}from"react/compiler-runtime";import{createContext as P,useCallback as re,useContext as F,useEffect as ie,useMemo as I,useRef as L,useState as R}from"react";import*as z from"node:child_process";import{exec as ae,execFile as B,execSync as V,spawnSync as oe}from"node:child_process";import{Fragment as se,jsx as H,jsxs as U}from"react/jsx-runtime";import W from"figures";import G from"picocolors";import*as K from"node:path";import ce,{join as le,normalize as ue}from"node:path";import*as de from"node:url";import{fileURLToPath as fe,pathToFileURL as pe}from"node:url";import{z as me}from"zod";import{z as q}from"zod/v4";import{ChildProcess as he,ChildProcessSpawner as ge}from"effect/unstable/process";import{NodeFileSystem as _e,NodeServices as ve}from"@effect/platform-node";import*as ye from"effect/Array";import*as J from"effect/String";import*as be from"effect/Function";import*as xe from"node:crypto";import{createHash as Se}from"node:crypto";import{Buffer as Ce}from"node:buffer";import{execSync as we,spawn as Te}from"child_process";import{EventEmitter as Ee}from"node:events";import{FileSystem as De}from"effect/FileSystem";import*as Oe from"node:os";import{platform as ke}from"node:os";import*as Ae from"@effect/platform-node/NodeSocket";import{ChildProcessSpawner as je}from"effect/unstable/process/ChildProcessSpawner";import{request as Me}from"node:http";import*as Ne from"node:fs/promises";import*as Pe from"node:fs";import{createReadStream as Fe}from"node:fs";import Ie from"ink-spinner";import Le from"cli-truncate";import Re from"string-width";import{create as ze}from"zustand";import*as Be from"effect/Data";import{dirname as Ve,posix as He,sep as Ue}from"path";import{createInterface as We}from"node:readline";import{AsyncLocalStorage as Ge}from"node:async_hooks";import*as Ke from"@effect/platform-node/NodeHttpClient";import{DevTools as qe}from"effect/unstable/devtools";import*as Je from"effect/unstable/observability/Otlp";import{createJSONStorage as Ye,persist as Xe}from"zustand/middleware";import*as Ze from"effect/unstable/reactivity/AsyncResult";import*as Qe from"effect/unstable/reactivity/Atom";import{RegistryProvider as $e,useAtom as et,useAtomSet as tt,useAtomValue as nt}from"@effect/atom-react";import rt from"pretty-ms";import{detectTerminal as it}from"detect-terminal";import at from"supports-terminal-graphics";import ot from"ink-link";import{Hono as st}from"hono";import{proxy as ct}from"hono/proxy";import{serve as lt}from"@hono/node-server";import"node-notifier";import ut from"prompts";import dt from"ora";const ft=`0.0.9`,pt=`\x1B[?1049l`,mt=process.env.SUPPORT_CLICK===`true`||process.env.SUPPORT_CLICK===`1`,ht=[`lint`,`check`,`format`,`typecheck`,`type-check`],gt=`expect-cli`,_t={"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`},vt=()=>{},yt=P({subscribeClick:()=>vt}),bt=/\x1b\[<(\d+);(\d+);(\d+)([Mm])|\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\d+;\d+R|\[\?[\d;]+[a-z]/g,xt=({children:e})=>{if(!mt)return H(se,{children:e});let t=L(new Set),n=L(!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(bt,(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=re(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]);return H(yt.Provider,{value:{subscribeClick:r},children:e})},St=()=>{let e=N(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 F(yt)},Ct=/\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\?[\d;]+[a-z]|\[\d+;\d+R/g,wt=e=>mt?e.replace(Ct,``):e,Tt=e=>e&&e>0?e:80,Et=e=>e&&e>0?e:24,Dt=()=>{let{stdout:e}=k(),[t,n]=R([Tt(e.columns),Et(e.rows)]),r=L(!1);return r.current||(r.current=!0,e.on(`resize`,()=>n([Tt(e.columns),Et(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`,errorBg:`#330b0b`},Ot={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,ERROR_BG:Y.errorBg},kt=()=>Ot,At=e=>{let t=N(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]=Dt(),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=H(E,{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=H(T,{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=H(E,{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=U(T,{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},jt=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}},Mt=({onClick:e,children:t,fullWidth:n=!0})=>{let{subscribeClick:r}=St(),i=L(e);return i.current=e,H(T,{ref:re(e=>{if(e)return r((t,n)=>{if(n!==`press`||!e.yogaNode)return;let r=jt(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})},Nt=e=>/\w/.test(e),Pt=(e,t)=>{let n=t-1;for(;n>0&&!Nt(e[n]);)n--;for(;n>0&&Nt(e[n-1]);)n--;return n},Ft=(e,t)=>{let n=t;for(;n<e.length&&Nt(e[n]);)n++;for(;n<e.length&&!Nt(e[n]);)n++;return n},It=(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}},Lt=(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)},Rt=({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]=R({cursorOffset:(e||``).length,cursorWidth:0}),{cursorOffset:p,cursorWidth:m}=d,h=L({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?G.gray(t):void 0;if(a&&n){y=t.length>0?G.inverse(t[0])+G.gray(t.slice(1)):G.inverse(` `),v=_.length>0?``:G.inverse(` `);let e=0;for(let t of _){let n=e>=p-g&&e<=p;n&&t===`
|
|
4
|
+
`?v+=G.inverse(` `)+`
|
|
5
|
+
`:v+=n?G.inverse(t):t,e++}_.length>0&&p===_.length&&(v+=G.inverse(` `))}return te((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}=It(e,p);t>0?r=Lt(i,t-1,n):l?.(),m=!0}else if(o&&n.downArrow&&a){let{lineIndex:t,column:n,lines:i}=It(e,p);t<i.length-1?r=Lt(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=Pt(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=Pt(e,p),m=!0;else if(n.meta&&t===`f`&&a)r=Ft(e,p),m=!0;else if(n.meta&&(n.backspace||n.delete)){if(p>0){let t=Pt(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}),H(E,{children:t?_.length>0?v:y:v})},zt=e=>{let t=N(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=kt();if(n){let e;t[1]===o.DIM?e=t[2]:(e=H(E,{color:o.DIM,children:`/`}),t[1]=o.DIM,t[2]=e);let n;t[3]!==i||t[4]!==a||t[5]!==r?(n=H(Rt,{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=U(T,{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=H(T,{marginTop:1,children:U(E,{color:o.DIM,children:[`/`,r]})}),t[10]=o.DIM,t[11]=r,t[12]=e):e=t[12],e}return null},Bt=x.Literals([`pending`,`in_progress`,`completed`,`failed`]),Vt=x.Literals([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);x.Literals([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const Ht=x.Union([x.Struct({type:x.Literal(`text`),text:x.String}),x.Struct({type:x.Literal(`image`),data:x.String,mimeType:x.String}),x.Struct({type:x.Literal(`resource_link`),uri:x.String}),x.Struct({type:x.Literal(`resource`),uri:x.String})]),Ut=x.Union([x.Struct({type:x.Literal(`content`),content:Ht}),x.Struct({type:x.Literal(`diff`),path:x.String,oldText:x.optional(x.NullOr(x.String)),newText:x.optional(x.NullOr(x.String))}),x.Struct({type:x.Literal(`terminal`),terminalId:x.String})]),Wt=x.Struct({path:x.String,lineNumber:x.optional(x.NullOr(x.Number))});var Gt=class extends x.Class(`AcpAgentMessageChunk`)({sessionUpdate:x.Literal(`agent_message_chunk`),content:Ht,messageId:x.optional(x.NullOr(x.String))}){},Kt=class extends x.Class(`AcpAgentThoughtChunk`)({sessionUpdate:x.Literal(`agent_thought_chunk`),content:Ht,messageId:x.optional(x.NullOr(x.String))}){},qt=class extends x.Class(`AcpUserMessageChunk`)({sessionUpdate:x.Literal(`user_message_chunk`),content:Ht,messageId:x.optional(x.NullOr(x.String))}){},Jt=class extends x.Class(`AcpToolCall`)({sessionUpdate:x.Literal(`tool_call`),toolCallId:x.String,title:x.String,kind:x.optional(Vt),status:x.optional(Bt),content:x.optional(x.Array(Ut)),locations:x.optional(x.Array(Wt)),rawInput:x.optional(x.Unknown),rawOutput:x.optional(x.Unknown)}){},Yt=class extends x.Class(`AcpToolCallUpdate`)({sessionUpdate:x.Literal(`tool_call_update`),toolCallId:x.String,title:x.optional(x.NullOr(x.String)),kind:x.optional(x.NullOr(Vt)),status:x.optional(x.NullOr(Bt)),content:x.optional(x.NullOr(x.Array(Ut))),locations:x.optional(x.NullOr(x.Array(Wt))),rawInput:x.optional(x.Unknown),rawOutput:x.optional(x.Unknown)}){};const Xt=x.Literals([`pending`,`in_progress`,`completed`]),Zt=x.Literals([`high`,`medium`,`low`]);var Qt=class extends x.Class(`AcpPlanUpdate`)({sessionUpdate:x.Literal(`plan`),entries:x.Array(x.Struct({content:x.String,priority:Zt,status:Xt}))}){},$t=class extends x.Class(`AcpAvailableCommandsUpdate`)({sessionUpdate:x.Literal(`available_commands_update`)}){},en=class extends x.Class(`AcpCurrentModeUpdate`)({sessionUpdate:x.Literal(`current_mode_update`)}){},tn=class extends x.Class(`AcpConfigOptionUpdate`)({sessionUpdate:x.Literal(`config_option_update`)}){},nn=class extends x.Class(`AcpSessionInfoUpdate`)({sessionUpdate:x.Literal(`session_info_update`)}){},rn=class extends x.Class(`AcpUsageUpdate`)({sessionUpdate:x.Literal(`usage_update`)}){};const an=x.Union([Gt,Kt,qt,Jt,Yt,Qt,$t,en,tn,nn,rn]);x.Struct({inputTokens:x.Number,outputTokens:x.Number,cachedReadTokens:x.optional(x.NullOr(x.Number)),cachedWriteTokens:x.optional(x.NullOr(x.Number)),thoughtTokens:x.optional(x.NullOr(x.Number))});const on=x.Literals([`claude`,`codex`,`cursor`]);var sn=class extends x.Class(`@ami/FileStat`)({relativePath:x.String,added:x.Number,removed:x.Number}){},cn=class extends x.Class(`@supervisor/GitState`)({isGitRepo:x.Boolean,currentBranch:x.String,mainBranch:x.UndefinedOr(x.String),isOnMain:x.Boolean,hasChangesFromMain:x.Boolean,hasUnstagedChanges:x.Boolean,hasBranchCommits:x.Boolean,branchCommitCount:x.Number,fileStats:x.Array(sn),workingTreeFileStats:x.Array(sn),fingerprint:x.UndefinedOr(x.String),savedFingerprint:x.UndefinedOr(x.String)}){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 ln=x.String.pipe(x.brand(`StepId`)),un=x.String.pipe(x.brand(`PlanId`)),dn=x.TaggedUnion({WorkingTree:{},Branch:{mainBranch:x.String},Changes:{mainBranch:x.String},Commit:{hash:x.String}}),fn=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),pn=x.Struct({number:x.Number,headRefName:x.String,author:x.Struct({login:x.String}),state:x.String,updatedAt:x.String}),mn=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var hn=class extends x.Class(`@supervisor/RemoteBranch`)({name:x.String,author:x.String,prNumber:x.NullOr(x.Number),prStatus:x.NullOr(x.Literals([`open`,`draft`,`merged`])),updatedAt:x.NullOr(x.String)}){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 gn=x.Literals([`pending`,`active`,`passed`,`failed`]);var _n=class e extends x.Class(`@supervisor/TestPlanStep`)({id:ln,title:x.String,instruction:x.String,expectedOutcome:x.String,routeHint:x.OptionFromNullOr(x.String),status:gn,summary:x.OptionFromNullOr(x.String),startedAt:x.OptionFromNullOr(x.DateTimeUtc),endedAt:x.OptionFromNullOr(x.DateTimeUtc)}){update(t){return new e({...this,...t})}},vn=class extends x.Class(`@supervisor/TestCoverageEntry`)({path:x.String,testFiles:x.Array(x.String),covered:x.Boolean}){},yn=class extends x.Class(`@supervisor/TestCoverageReport`)({entries:x.Array(vn),coveredCount:x.Number,totalCount:x.Number,percent:x.Number}){};const bn=x.String.pipe(x.brand(`DraftId`));var xn=class e extends x.Class(`@supervisor/TestPlanDraft`)({id:bn,changesFor:dn,currentBranch:x.String,diffPreview:x.String,fileStats:x.Array(sn),instruction:x.String,baseUrl:x.Option(x.String),isHeadless:x.Boolean,requiresCookies:x.Boolean,testCoverage:x.Option(yn)}){update(t){return new e({...this,...t})}},Sn=class e extends xn.extend(`@supervisor/TestPlan`)({id:un,title:x.String,rationale:x.String,steps:x.Array(_n)}){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 _n({...e,status:`pending`,summary:g.none(),startedAt:g.none(),endedAt:g.none()}))})}},Cn=class extends x.TaggedClass()(`RunStarted`,{plan:Sn}){get id(){return`run-started-${this.plan.id}`}},wn=class extends x.TaggedClass()(`StepStarted`,{stepId:ln,title:x.String}){get id(){return`step-started-${this.stepId}`}},Tn=class extends x.TaggedClass()(`StepCompleted`,{stepId:ln,summary:x.String}){get id(){return`step-completed-${this.stepId}`}},En=class extends x.TaggedClass()(`StepFailed`,{stepId:ln,message:x.String}){get id(){return`step-failed-${this.stepId}`}},Dn=class extends x.TaggedClass()(`ToolCall`,{toolName:x.String,input:x.Unknown}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return _.isObject(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},On=class extends x.TaggedClass()(`ToolProgress`,{toolName:x.String,outputSize:x.Number}){get id(){return`tool-progress-${this.toolName}-${this.outputSize}`}},kn=class extends x.TaggedClass()(`ToolResult`,{toolName:x.String,result:x.String,isError:x.Boolean}){get id(){return`tool-result-${this.toolName}-${this.result}`}},An=class extends x.TaggedClass()(`AgentThinking`,{text:x.String}){get id(){return`agent-thinking-${this.text}`}},jn=class extends x.TaggedClass()(`AgentText`,{text:x.String}){get id(){return`agent-text-${this.text}`}},Mn=class extends x.TaggedClass()(`RunFinished`,{status:x.Literals([`passed`,`failed`]),summary:x.String}){get id(){return`run-finished-${this.status}`}};const Nn=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)}},Pn=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 wn({stepId:ln.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new Tn({stepId:ln.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new En({stepId:ln.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new Mn({status:a===`failed`?`failed`:`passed`,summary:o})},Fn=x.Union([Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn]);var In=class extends x.TaggedClass()(`RunCompleted`,{report:x.suspend(()=>qn)}){};const Ln=x.Union([Cn,wn,Tn,En,Dn,kn,An,Mn,In]);var Rn=class extends x.Class(`@supervisor/Update`)({content:Ln,receivedAt:x.DateTimeUtc}){},zn=class extends x.Class(`@supervisor/PullRequest`)({number:x.Number,url:x.String,title:x.String,headRefName:x.String}){};const Bn=x.TaggedUnion({WorkingTree:{},Branch:{branch:hn},PullRequest:{branch:hn},Commit:{hash:x.String,shortHash:x.String,subject:x.String}}),Vn=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),Hn=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),Un=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),Wn=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),Gn=e=>h.value(e).pipe(h.tagsExhaustive({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));x.TaggedUnion({Branch:{branchName:x.String}});var Kn=class e extends Sn.extend(`@supervisor/ExecutedTestPlan`)({events:x.Array(Fn)}){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 An({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new An({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 jn({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new jn({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new Dn({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 Dn({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 kn({toolName:t.title??``,result:Nn(t.rawOutput),isError:t.status===`failed`})]});if(t.rawOutput!==void 0){let r=Nn(t.rawOutput).length;return new e({...n,events:[...n.events.filter(e=>!(e._tag===`ToolProgress`&&e.toolName===(t.title??``))),new On({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(Pn).filter(_.isNotUndefined);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:g.some(c.nowUnsafe())}):e)}):new e({...this,steps:[...this.steps,new _n({id:t.stepId,title:t.title,instruction:t.title,expectedOutcome:``,routeHint:g.none(),status:`active`,summary:g.none(),startedAt:g.some(c.nowUnsafe()),endedAt:g.none()})]}):t._tag===`StepCompleted`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`passed`,summary:g.some(t.summary),expectedOutcome:t.summary,endedAt:g.some(c.nowUnsafe())}):e)}):t._tag===`StepFailed`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`failed`,summary:g.some(t.message),expectedOutcome:t.message,endedAt:g.some(c.nowUnsafe())}):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}},qn=class extends Kn.extend(`@supervisor/TestReport`)({summary:x.String,screenshotPaths:x.Array(x.String),pullRequest:x.Option(x.suspend(()=>zn)),testCoverageReport:x.Option(yn)}){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(g.isSome(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
|
+
`)}},Jn=class extends S.Service()(`@supervisor/Updates`,{make:l.gen(function*(){let e=yield*v.unbounded();return{publish:l.fn(`Updates.publish`)(function*(t){yield*v.publish(e,new Rn({content:t,receivedAt:c.nowUnsafe()}))}),stream:l.fn(`Updates.stream`)(function*(){return C.fromPubSub(e)})}})}){static layer=p.effect(this)(this.make)};const Yn=x.Struct({name:x.String,value:x.String});var Xn=class extends x.Class(`AgentStreamOptions`)({cwd:x.String,sessionId:x.Option(x.String),prompt:x.String,systemPrompt:x.Option(x.String),mcpEnv:x.optional(x.Array(Yn))}){};const Zn={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`},Qn={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`},$n=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminal:q.boolean().optional().default(!1)}),er=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),label:q.string().nullish(),name:q.string(),optional:q.boolean().optional().default(!1),secret:q.boolean().optional().default(!0)}),tr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:q.string(),name:q.string()}),nr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:q.string(),link:q.string().nullish(),name:q.string(),vars:q.array(er)}),rr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()).optional(),description:q.string().nullish(),env:q.record(q.string(),q.string()).optional(),id:q.string(),name:q.string()}),ir=q.union([nr.and(q.object({type:q.literal(`env_var`)})),rr.and(q.object({type:q.literal(`terminal`)})),tr]),ar=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),methodId:q.string()}),or=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),sr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),blob:q.string(),mimeType:q.string().nullish(),uri:q.string()}),cr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),lr=q.object({amount:q.number(),currency:q.string()}),ur=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminalId:q.string()}),dr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),newText:q.string(),oldText:q.string().nullish(),path:q.string()}),fr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),value:q.string()}),pr=q.union([q.literal(-32700),q.literal(-32600),q.literal(-32601),q.literal(-32602),q.literal(-32603),q.literal(-32800),q.literal(-32e3),q.literal(-32002),q.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),mr=q.object({code:pr,data:q.unknown().optional(),message:q.string()}),hr=q.unknown(),gr=q.unknown(),_r=q.unknown(),vr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),readTextFile:q.boolean().optional().default(!1),writeTextFile:q.boolean().optional().default(!1)}),yr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),auth:$n.optional().default({terminal:!1}),fs:vr.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:q.boolean().optional().default(!1)}),br=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),value:q.string()}),xr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),name:q.string(),title:q.string().nullish(),version:q.string()}),Sr=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Cr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cursor:q.string().nullish(),cwd:q.string().nullish()}),wr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),http:q.boolean().optional().default(!1),sse:q.boolean().optional().default(!1)}),Tr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),headers:q.array(br),name:q.string(),url:q.string()}),Er=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),headers:q.array(br),name:q.string(),url:q.string()}),Dr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()),command:q.string(),env:q.array(fr),name:q.string()}),Or=q.union([Tr.and(q.object({type:q.literal(`http`)})),Er.and(q.object({type:q.literal(`sse`)})),Dr]),kr=q.string(),Ar=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),modelId:kr,name:q.string()}),jr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Or)}),Mr=q.string(),Nr=q.union([q.literal(`allow_once`),q.literal(`allow_always`),q.literal(`reject_once`),q.literal(`reject_always`)]),Pr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),kind:Nr,name:q.string(),optionId:Mr}),Fr=q.union([q.literal(`high`),q.literal(`medium`),q.literal(`low`)]),Ir=q.union([q.literal(`pending`),q.literal(`in_progress`),q.literal(`completed`)]),Lr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string(),priority:Fr,status:Ir}),Rr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),entries:q.array(Lr)}),zr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),audio:q.boolean().optional().default(!1),embeddedContext:q.boolean().optional().default(!1),image:q.boolean().optional().default(!1)}),Br=q.number().int().gte(0).lte(65535),Vr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),clientCapabilities:yr.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:xr.nullish(),protocolVersion:Br}),Hr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string()}),Ur=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Wr=q.union([q.number(),q.string()]).nullable();q.object({_meta:q.record(q.string(),q.unknown()).nullish(),requestId:Wr});const Gr=q.enum([`assistant`,`user`]),Kr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),audience:q.array(Gr).nullish(),lastModified:q.string().nullish(),priority:q.number().nullish()}),qr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Kr.nullish(),data:q.string(),mimeType:q.string()}),Jr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Kr.nullish(),data:q.string(),mimeType:q.string(),uri:q.string().nullish()}),Yr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Kr.nullish(),description:q.string().nullish(),mimeType:q.string().nullish(),name:q.string(),size:q.number().nullish(),title:q.string().nullish(),uri:q.string()}),Xr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),optionId:Mr}),Zr=q.union([q.object({outcome:q.literal(`cancelled`)}),Xr.and(q.object({outcome:q.literal(`selected`)}))]),Qr=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),outcome:Zr}),$r=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),ei=q.object({currentValue:q.boolean()}),ti=q.string(),ni=q.string(),ri=q.union([q.literal(`mode`),q.literal(`model`),q.literal(`thought_level`),q.string()]),ii=q.string(),ai=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),name:q.string(),value:ii}),oi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),group:ti,name:q.string(),options:q.array(ai)}),si=q.union([q.array(ai),q.array(oi)]),ci=q.object({currentValue:ii,options:si}),li=q.intersection(q.union([ci.and(q.object({type:q.literal(`select`)})),ei.and(q.object({type:q.literal(`boolean`)}))]),q.object({_meta:q.record(q.string(),q.unknown()).nullish(),category:ri.nullish(),description:q.string().nullish(),id:ni,name:q.string()})),ui=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li)}),di=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),fi=q.string(),pi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi});q.object({method:q.string(),params:q.union([pi,hr]).nullish()});const mi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi}),hi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),args:q.array(q.string()).optional(),command:q.string(),cwd:q.string().nullish(),env:q.array(fr).optional(),outputByteLimit:q.number().nullish(),sessionId:fi}),gi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Or).optional(),sessionId:fi}),_i=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi,terminalId:q.string()}),vi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Or),sessionId:fi}),yi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),limit:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:q.string(),sessionId:fi}),bi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi,terminalId:q.string()}),xi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),mcpServers:q.array(Or).optional(),sessionId:fi}),Si=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cwd:q.string(),sessionId:fi,title:q.string().nullish(),updatedAt:q.string().nullish()}),Ci=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),nextCursor:q.string().nullish(),sessions:q.array(Si)}),wi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),title:q.string().nullish(),updatedAt:q.string().nullish()}),Ti=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Ei=q.string(),Di=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),currentModeId:Ei}),Oi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string().nullish(),id:Ei,name:q.string()}),ki=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableModes:q.array(Oi),currentModeId:Ei}),Ai=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableModels:q.array(Ar),currentModelId:kr}),ji=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li).nullish(),models:Ai.nullish(),modes:ki.nullish(),sessionId:fi}),Mi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li).nullish(),models:Ai.nullish(),modes:ki.nullish()}),Ni=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li).nullish(),models:Ai.nullish(),modes:ki.nullish(),sessionId:fi}),Pi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li).nullish(),models:Ai.nullish(),modes:ki.nullish()}),Fi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Ii=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),close:$r.nullish(),fork:di.nullish(),list:Ti.nullish(),resume:Fi.nullish()}),Li=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),loadSession:q.boolean().optional().default(!1),mcpCapabilities:wr.optional().default({http:!1,sse:!1}),promptCapabilities:zr.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:Ii.optional().default({})}),Ri=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),agentCapabilities:Li.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:xr.nullish(),authMethods:q.array(ir).optional().default([]),protocolVersion:Br}),zi=q.intersection(q.union([q.object({type:q.literal(`boolean`),value:q.boolean()}),q.object({value:ii})]),q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configId:ni,sessionId:fi})),Bi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),configOptions:q.array(li)}),Vi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),modeId:Ei,sessionId:fi}),Hi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Ui=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),modelId:kr,sessionId:fi}),Wi=q.object({_meta:q.record(q.string(),q.unknown()).nullish()}),Gi=q.union([q.literal(`end_turn`),q.literal(`max_tokens`),q.literal(`max_turn_requests`),q.literal(`refusal`),q.literal(`cancelled`)]),Ki=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),terminalId:q.string()}),qi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitCode:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:q.string().nullish()}),Ji=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi,terminalId:q.string()}),Yi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitStatus:qi.nullish(),output:q.string(),truncated:q.boolean()}),Xi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Kr.nullish(),text:q.string()}),Zi=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),mimeType:q.string().nullish(),text:q.string(),uri:q.string()}),Qi=q.union([Zi,sr]),$i=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),annotations:Kr.nullish(),resource:Qi}),ea=q.union([Xi.and(q.object({type:q.literal(`text`)})),Jr.and(q.object({type:q.literal(`image`)})),qr.and(q.object({type:q.literal(`audio`)})),Yr.and(q.object({type:q.literal(`resource_link`)})),$i.and(q.object({type:q.literal(`resource`)}))]),ta=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:ea}),na=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:ea,messageId:q.string().nullish()}),ra=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),messageId:q.string().nullish(),prompt:q.array(ea),sessionId:fi});q.object({id:Wr,method:q.string(),params:q.union([Vr,ar,jr,vi,Cr,gi,xi,mi,Vi,zi,ra,Ui,gr]).nullish()});const ia=q.union([ta.and(q.object({type:q.literal(`content`)})),dr.and(q.object({type:q.literal(`diff`)})),Ki.and(q.object({type:q.literal(`terminal`)}))]),aa=q.string(),oa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),line:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:q.string()}),sa=q.union([q.literal(`pending`),q.literal(`in_progress`),q.literal(`completed`),q.literal(`failed`)]),ca=q.union([q.literal(`read`),q.literal(`edit`),q.literal(`delete`),q.literal(`move`),q.literal(`search`),q.literal(`execute`),q.literal(`think`),q.literal(`fetch`),q.literal(`switch_mode`),q.literal(`other`)]),la=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.array(ia).optional(),kind:ca.optional(),locations:q.array(oa).optional(),rawInput:q.unknown().optional(),rawOutput:q.unknown().optional(),status:sa.optional(),title:q.string(),toolCallId:aa}),ua=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.array(ia).nullish(),kind:ca.nullish(),locations:q.array(oa).nullish(),rawInput:q.unknown().optional(),rawOutput:q.unknown().optional(),status:sa.nullish(),title:q.string().nullish(),toolCallId:aa}),da=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),options:q.array(Pr),sessionId:fi,toolCall:ua}),fa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),hint:q.string()}),pa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),description:q.string(),input:fa.nullish(),name:q.string()}),ma=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),availableCommands:q.array(pa)}),ha=q.object({cachedReadTokens:q.number().nullish(),cachedWriteTokens:q.number().nullish(),inputTokens:q.number(),outputTokens:q.number(),thoughtTokens:q.number().nullish(),totalTokens:q.number()}),ga=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),stopReason:Gi,usage:ha.nullish(),userMessageId:q.string().nullish()});q.union([q.object({id:Wr,result:q.union([Ri,or,Ni,Mi,Ci,ji,Pi,cr,Hi,Bi,ga,Wi,_r])}),q.object({error:mr,id:Wr})]);const _a=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),cost:lr.nullish(),size:q.number(),used:q.number()}),va=q.union([na.and(q.object({sessionUpdate:q.literal(`user_message_chunk`)})),na.and(q.object({sessionUpdate:q.literal(`agent_message_chunk`)})),na.and(q.object({sessionUpdate:q.literal(`agent_thought_chunk`)})),la.and(q.object({sessionUpdate:q.literal(`tool_call`)})),ua.and(q.object({sessionUpdate:q.literal(`tool_call_update`)})),Rr.and(q.object({sessionUpdate:q.literal(`plan`)})),ma.and(q.object({sessionUpdate:q.literal(`available_commands_update`)})),Di.and(q.object({sessionUpdate:q.literal(`current_mode_update`)})),ui.and(q.object({sessionUpdate:q.literal(`config_option_update`)})),wi.and(q.object({sessionUpdate:q.literal(`session_info_update`)})),_a.and(q.object({sessionUpdate:q.literal(`usage_update`)}))]),ya=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi,update:va});q.object({method:q.string(),params:q.union([ya,hr]).nullish()});const ba=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),sessionId:fi,terminalId:q.string()}),xa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),exitCode:q.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:q.string().nullish()}),Sa=q.object({_meta:q.record(q.string(),q.unknown()).nullish(),content:q.string(),path:q.string(),sessionId:fi});q.object({id:Wr,method:q.string(),params:q.union([Sa,yi,da,hi,Ji,bi,ba,_i,gr]).nullish()});const Ca=q.object({_meta:q.record(q.string(),q.unknown()).nullish()});q.union([q.object({id:Wr,result:q.union([Ca,Hr,Qr,ur,Yi,Ur,xa,Sr,_r])}),q.object({error:mr,id:Wr})]);function wa(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 wa=class{#e;constructor(e,t){let n=e(this);this.#e=new Ta(async(e,t)=>{switch(e){case Zn.fs_write_text_file:{let e=xa.parse(t);return n.writeTextFile?.(e)}case Zn.fs_read_text_file:{let e=vi.parse(t);return n.readTextFile?.(e)}case Zn.session_request_permission:{let e=ua.parse(t);return n.requestPermission(e)}case Zn.terminal_create:{let e=mi.parse(t);return n.createTerminal?.(e)}case Zn.terminal_output:{let e=qi.parse(t);return n.terminalOutput?.(e)}case Zn.terminal_release:{let e=yi.parse(t);return await n.releaseTerminal?.(e)??{}}case Zn.terminal_wait_for_exit:{let e=ya.parse(t);return n.waitForTerminalExit?.(e)}case Zn.terminal_kill:{let e=gi.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw Ea.methodNotFound(e)}},async(e,t)=>{switch(e){case Zn.session_update:{let e=va.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw Ea.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(Xn.initialize,e)}async newSession(e){return await this.#e.sendRequest(Xn.session_new,e)}async loadSession(e){return await this.#e.sendRequest(Xn.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(Xn.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(Xn.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(Xn.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(Xn.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(Xn.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(Xn.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(Xn.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(Xn.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(Xn.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(Xn.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}},Ta=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 Ea)return e.toResult();if(e instanceof pe.ZodError)return Ea.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 Ea.internalError(t?JSON.parse(t):{}).toResult()}catch{return Ea.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof Ea)return e.toResult();if(e instanceof pe.ZodError)return Ea.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 Ea.internalError(t?JSON.parse(t):{}).toResult()}catch{return Ea.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}},Ea=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 Da=g.compose(g.isObject,g.compose(g.hasProperty(`message`),g.Struct({message:g.isString}))),Oa=b.String.pipe(b.brand(`SessionId`));var ka=class extends b.ErrorClass(`AcpStreamError`)({_tag:b.tag(`AcpStreamError`),cause:b.Unknown}){displayName=`An unexpected error occurred while streaming`;message=`Streaming failed: ${this.cause}`},Aa=class extends b.ErrorClass(`AcpProviderUnauthenticatedError`)({_tag:b.tag(`AcpProviderUnauthenticatedError`),provider:an}){displayName=`Your ${this.provider} agent is not authenticated`;message=m.value(this.provider).pipe(m.when(`claude`,()=>"Please log in using `claude login`, and then re-run expect."),m.when(`codex`,()=>"Please log in using `codex login`, and then re-run expect."),m.orElse(()=>`Please sign in to your coding agent, and then re-run expect.`))},ja=class extends b.ErrorClass(`AcpProviderUsageLimitError`)({_tag:b.tag(`AcpProviderUsageLimitError`),provider:an}){displayName=`Your ${this.provider} agent has exceeded its usage limits`;message=`Usage limits exceeded for ${this.provider}. Please check your plan and billing.`},Ma=class extends b.ErrorClass(`AcpSessionCreateError`)({_tag:b.tag(`AcpSessionCreateError`),cause:b.Unknown}){displayName=`Creating a chat session failed`;message=`Creating session failed: ${o.pretty(o.fail(this.cause))}`},Na=class extends b.ErrorClass(`AcpConnectionInitError`)({_tag:b.tag(`AcpConnectionInitError`),cause:b.Unknown}){message=`Init connection failed: ${this.cause}`},Pa=class extends b.ErrorClass(`AcpAdapterNotFoundError`)({_tag:b.tag(`AcpAdapterNotFoundError`),packageName:b.String,cause:b.Unknown}){message=`ACP adapter not found: ${this.packageName}. Error: ${o.pretty(o.fail(this.cause))}`},Fa=class e extends x.Service()(`@expect/AcpAdapter`){static layerCodex=f.effect(e)(c.try({try:()=>{let t=i(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 Pa({packageName:`@zed-industries/codex-acp`,cause:e})}));static layerClaude=f.effect(e)(c.gen(function*(){let t=yield*he.ChildProcessSpawner,n=b.Struct({loggedIn:b.Boolean});return yield*me.make(`claude`,[`auth`,`status`]).pipe(t.string,c.flatMap(b.decodeEffect(b.fromJsonString(n))),c.flatMap(({loggedIn:e})=>e?c.void:new Aa({provider:`claude`}).asEffect())),yield*c.try({try:()=>{let t=i(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 Pa({packageName:`@zed-industries/claude-agent-acp`,cause:e})})})).pipe(f.provide(J.layer))},Ia=class extends x.Service()(`@expect/AcpClient`,{make:c.gen(function*(){let e=yield*Fa;yield*c.annotateLogsScoped({adapter:e.args[0]}),yield*c.logInfo(`Initializing AcpClient`);let t=yield*he.ChildProcessSpawner,n=yield*u.make(),r=yield*v.unbounded(),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(Oa.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);let r=b.decodeUnknownSync(rn)(t);v.offerUnsafe(n,r)}},o=yield*me.make(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*c.annotateLogsScoped({pid:o.pid}),yield*c.logDebug(`ACP adapter subprocess spawned`),yield*S.fromQueue(r).pipe(S.run(o.stdin),c.forkScoped);let s=S.toReadableStream(o.stdout),l=new wa(e=>a,Ca(new WritableStream({write:e=>void v.offerUnsafe(r,e)}),s)),d=de(new URL(`./browser-mcp.js`,import.meta.url)),f=e=>[{command:process.execPath,args:[d],env:[...e],name:`browser`}],p=yield*c.tryPromise({try:()=>l.initialize({protocolVersion:1}),catch:e=>new Na({cause:e})});yield*c.logInfo(`ACP connection initialized`,{capabilities:p.agentCapabilities});let m=c.fn(`AcpClient.createSession`)(function*(t,n=[]){yield*c.annotateCurrentSpan({cwd:t});let r=f(n);return yield*c.tryPromise({try:()=>l.newSession({cwd:t,mcpServers:r}),catch:t=>{let n=Da(t)?t.message:String(t);return[`authentication`].some(e=>n.toLowerCase().includes(e))?new Aa({provider:e.provider}):[`out of usage`,`limits exceeded`,`usage exceeded`].some(e=>n.toLowerCase().includes(e))?new ja({provider:e.provider}):new Ma({cause:t})}}).pipe(c.map(({sessionId:e})=>Oa.makeUnsafe(e)),c.tap(e=>c.gen(function*(){let t=yield*v.unbounded();i.set(e,t),yield*c.logInfo(`ACP session created`,{sessionId:e})})))}),g=c.fn(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*c.die(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*v.unbounded();return i.set(e,t),t});return{createSession:m,stream:c.fn(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r,mcpEnv:i=[]}){let a=h.isSome(t)?t.value:yield*m(r,i);yield*c.logDebug(`ACP stream starting`,{sessionId:a});let o=yield*g(a);return yield*c.tryPromise({try:()=>l.prompt({sessionId:a,prompt:[{type:`text`,text:e}]}),catch:e=>new ka({cause:e})}).pipe(c.tap(()=>c.logDebug(`ACP prompt completed`)),c.tap(()=>v.end(o)),u.run(n,a,{startImmediately:!0})),S.fromQueue(o)},S.unwrap)}})}){static layer=f.effect(this)(this.make).pipe(f.provide(J.layer));static layerCodex=this.layer.pipe(f.provide(Fa.layerCodex));static layerClaude=this.layer.pipe(f.provide(Fa.layerClaude))},La=class e extends x.Service()(`@expect/Agent`){static layerAcp=f.effect(e)(c.gen(function*(){let t=yield*Ia;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:h.map(e.sessionId,e=>e),prompt:e.prompt,mcpEnv:e.mcpEnv})})})).pipe(f.provide(Ia.layer));static layerCodex=e.layerAcp.pipe(f.provide(Fa.layerCodex));static layerClaude=e.layerAcp.pipe(f.provide(Fa.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>f.effect(e,c.gen(function*(){let n=yield*d.FileSystem,r=b.decodeSync(rn);return e.of({stream:()=>n.stream(t).pipe(S.decodeText(),S.splitLines,S.map(e=>r(JSON.parse(e))),S.orDie),createSession:()=>c.die(`createSession not supported for test layer`)})})).pipe(f.provide(J.layer))};const Ra=[`claude`,`codex`,`cursor`],za=e=>{try{return z(`which ${e}`,{stdio:`pipe`}),!0}catch{return!1}},Ba=()=>Ra.filter(za),Va=12e3,Ha=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}`,``])]:[],Ua=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.`]}},Wa=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},Ga=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>Va?i.slice(0,Va)+`
|
|
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 Ta=class{#e;constructor(e,t){let n=e(this);this.#e=new Ea(async(e,t)=>{switch(e){case Qn.fs_write_text_file:{let e=Sa.parse(t);return n.writeTextFile?.(e)}case Qn.fs_read_text_file:{let e=yi.parse(t);return n.readTextFile?.(e)}case Qn.session_request_permission:{let e=da.parse(t);return n.requestPermission(e)}case Qn.terminal_create:{let e=hi.parse(t);return n.createTerminal?.(e)}case Qn.terminal_output:{let e=Ji.parse(t);return n.terminalOutput?.(e)}case Qn.terminal_release:{let e=bi.parse(t);return await n.releaseTerminal?.(e)??{}}case Qn.terminal_wait_for_exit:{let e=ba.parse(t);return n.waitForTerminalExit?.(e)}case Qn.terminal_kill:{let e=_i.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw Da.methodNotFound(e)}},async(e,t)=>{switch(e){case Qn.session_update:{let e=ya.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw Da.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(Zn.initialize,e)}async newSession(e){return await this.#e.sendRequest(Zn.session_new,e)}async loadSession(e){return await this.#e.sendRequest(Zn.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(Zn.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(Zn.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(Zn.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(Zn.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(Zn.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(Zn.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(Zn.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(Zn.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(Zn.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(Zn.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}},Ea=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 Da)return e.toResult();if(e instanceof me.ZodError)return Da.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 Da.internalError(t?JSON.parse(t):{}).toResult()}catch{return Da.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof Da)return e.toResult();if(e instanceof me.ZodError)return Da.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 Da.internalError(t?JSON.parse(t):{}).toResult()}catch{return Da.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}},Da=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 Oa=_.compose(_.isObject,_.compose(_.hasProperty(`message`),_.Struct({message:_.isString}))),ka=x.String.pipe(x.brand(`SessionId`));var Aa=class extends x.ErrorClass(`AcpStreamError`)({_tag:x.tag(`AcpStreamError`),cause:x.Unknown}){displayName=`An unexpected error occurred while streaming`;message=`Streaming failed: ${this.cause}`},ja=class extends x.ErrorClass(`AcpProviderUnauthenticatedError`)({_tag:x.tag(`AcpProviderUnauthenticatedError`),provider:on}){displayName=`Your ${this.provider} agent is not authenticated`;message=h.value(this.provider).pipe(h.when(`claude`,()=>"Please log in using `claude login`, and then re-run expect."),h.when(`codex`,()=>"Please log in using `codex login`, and then re-run expect."),h.orElse(()=>`Please sign in to your coding agent, and then re-run expect.`))},Ma=class extends x.ErrorClass(`AcpProviderUsageLimitError`)({_tag:x.tag(`AcpProviderUsageLimitError`),provider:on}){displayName=`Your ${this.provider} agent has exceeded its usage limits`;message=`Usage limits exceeded for ${this.provider}. Please check your plan and billing.`},Na=class extends x.ErrorClass(`AcpSessionCreateError`)({_tag:x.tag(`AcpSessionCreateError`),cause:x.Unknown}){displayName=`Creating a chat session failed`;message=`Creating session failed: ${o.pretty(o.fail(this.cause))}`},Pa=class extends x.ErrorClass(`AcpConnectionInitError`)({_tag:x.tag(`AcpConnectionInitError`),cause:x.Unknown}){message=`Init connection failed: ${this.cause}`},Fa=class extends x.ErrorClass(`AcpAdapterNotFoundError`)({_tag:x.tag(`AcpAdapterNotFoundError`),packageName:x.String,cause:x.Unknown}){message=`ACP adapter not found: ${this.packageName}. Error: ${o.pretty(o.fail(this.cause))}`},Ia=class e extends S.Service()(`@expect/AcpAdapter`){static layerCodex=p.effect(e)(l.try({try:()=>{let t=i(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 Fa({packageName:`@zed-industries/codex-acp`,cause:e})}));static layerClaude=p.effect(e)(l.gen(function*(){let t=yield*ge.ChildProcessSpawner,n=x.Struct({loggedIn:x.Boolean});return yield*he.make(`claude`,[`auth`,`status`]).pipe(t.string,l.flatMap(x.decodeEffect(x.fromJsonString(n))),l.flatMap(({loggedIn:e})=>e?l.void:new ja({provider:`claude`}).asEffect())),yield*l.try({try:()=>{let t=i(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 Fa({packageName:`@zed-industries/claude-agent-acp`,cause:e})})})).pipe(p.provide(ve.layer))},La=class extends S.Service()(`@expect/AcpClient`,{make:l.gen(function*(){let e=yield*Ia;yield*l.annotateLogsScoped({adapter:e.args[0]}),yield*l.logInfo(`Initializing AcpClient`);let t=yield*ge.ChildProcessSpawner,n=yield*d.make(),r=yield*y.unbounded(),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(ka.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);let r=x.decodeUnknownSync(an)(t);y.offerUnsafe(n,r)}},o=yield*he.make(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*l.annotateLogsScoped({pid:o.pid}),yield*l.logDebug(`ACP adapter subprocess spawned`),yield*C.fromQueue(r).pipe(C.run(o.stdin),l.forkScoped);let s=C.toReadableStream(o.stdout),c=new Ta(e=>a,wa(new WritableStream({write:e=>void y.offerUnsafe(r,e)}),s)),u=fe(new URL(`./browser-mcp.js`,import.meta.url)),f=e=>[{command:process.execPath,args:[u],env:[...e],name:`browser`}],p=yield*l.tryPromise({try:()=>c.initialize({protocolVersion:1}),catch:e=>new Pa({cause:e})});yield*l.logInfo(`ACP connection initialized`,{capabilities:p.agentCapabilities});let m=l.fn(`AcpClient.createSession`)(function*(t,n=[]){yield*l.annotateCurrentSpan({cwd:t});let r=f(n);return yield*l.tryPromise({try:()=>c.newSession({cwd:t,mcpServers:r}),catch:t=>{let n=Oa(t)?t.message:String(t);return[`authentication`].some(e=>n.toLowerCase().includes(e))?new ja({provider:e.provider}):[`out of usage`,`limits exceeded`,`usage exceeded`].some(e=>n.toLowerCase().includes(e))?new Ma({provider:e.provider}):new Na({cause:t})}}).pipe(l.map(({sessionId:e})=>ka.makeUnsafe(e)),l.tap(e=>l.gen(function*(){let t=yield*y.unbounded();i.set(e,t),yield*l.logInfo(`ACP session created`,{sessionId:e})})))}),h=l.fn(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*l.die(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*y.unbounded();return i.set(e,t),t});return{createSession:m,stream:l.fn(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r,mcpEnv:i=[]}){let a=g.isSome(t)?t.value:yield*m(r,i);yield*l.logDebug(`ACP stream starting`,{sessionId:a});let o=yield*h(a);return yield*l.tryPromise({try:()=>c.prompt({sessionId:a,prompt:[{type:`text`,text:e}]}),catch:e=>new Aa({cause:e})}).pipe(l.tap(()=>l.logDebug(`ACP prompt completed`)),l.tap(()=>y.end(o)),d.run(n,a,{startImmediately:!0})),C.fromQueue(o)},C.unwrap)}})}){static layer=p.effect(this)(this.make).pipe(p.provide(ve.layer));static layerCodex=this.layer.pipe(p.provide(Ia.layerCodex));static layerClaude=this.layer.pipe(p.provide(Ia.layerClaude))},Ra=class e extends S.Service()(`@expect/Agent`){static layerAcp=p.effect(e)(l.gen(function*(){let t=yield*La;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:g.map(e.sessionId,e=>e),prompt:e.prompt,mcpEnv:e.mcpEnv})})})).pipe(p.provide(La.layer));static layerCodex=e.layerAcp.pipe(p.provide(Ia.layerCodex));static layerClaude=e.layerAcp.pipe(p.provide(Ia.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>p.effect(e,l.gen(function*(){let n=yield*f.FileSystem,r=x.decodeSync(an);return e.of({stream:()=>n.stream(t).pipe(C.decodeText(),C.splitLines,C.map(e=>r(JSON.parse(e))),C.orDie),createSession:()=>l.die(`createSession not supported for test layer`)})})).pipe(p.provide(ve.layer))};const za=[`claude`,`codex`,`cursor`],Ba=e=>{try{return V(`which ${e}`,{stdio:`pipe`}),!0}catch{return!1}},Va=()=>za.filter(Ba),Ha=12e3,Ua=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}`,``])]:[],Wa=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.`]}},Ga=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},Ka=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>Ha?i.slice(0,Ha)+`
|
|
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,``,...Ua(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`,``,...Ga(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:`,...Wa(e.scope)].join(`
|
|
14
|
+
`)};var qa=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`:``)}})),Ja=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=qa(),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})),Ya=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=Ja()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Xa=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)}})),Za=n(((t,n)=>{let r=e(`os`),i=e(`tty`),a=Xa(),{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)))}})),Qa=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=Za();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 mc,hc=X({"src/lib/responses/ConfigList.ts"(){Q(),mc=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=ko(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 gc(e,t){return typeof e==`string`&&Object.hasOwn(xc,e)?e:t}function _c(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 vc(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 dc(t,e)}}}function yc(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return uc(e)}}}function bc(){return{addConfig(e,t,...n){return this._runTask(_c(e,t,n[0]===!0,gc(n[1],`local`)),bs(arguments))},getConfig(e,t){return this._runTask(vc(e,gc(t,void 0)),bs(arguments))},listConfig(...e){return this._runTask(yc(gc(e[0],void 0)),bs(arguments))}}}var xc,Sc=X({"src/lib/tasks/config.ts"(){hc(),Q(),xc=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(xc||{})}});function Cc(e){return Tc.has(e)}var wc,Tc,Ec=X({"src/lib/tasks/diff-name-status.ts"(){wc=(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))(wc||{}),Tc=new Set(Object.values(wc))}});function Dc(...e){return new Nc().param(...e)}function Oc(e){let t=new Set,n={};return Mo(e,e=>{let[r,i,a]=e.split(Ko);t.add(r),(n[r]=n[r]||[]).push({line:Bo(i),path:r,preview:a})}),{paths:t,results:n}}function kc(){return{grep(e){let t=bs(arguments),n=_s(arguments);for(let e of Ac)if(n.includes(e))return this._runTask(Us(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Dc().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return Oc(e)}},t)}}}var Ac,jc,Mc,Nc,Pc=X({"src/lib/tasks/grep.ts"(){Q(),Ys(),Ac=[`-h`],jc=Symbol(`grepQuery`),Nc=class{constructor(){this[Mc]=[]}*[(Mc=jc,Symbol.iterator)](){for(let e of this[jc])yield e}and(...e){return e.length&&this[jc].push(`--and`,`(`,...Vo(e,`-e`),`)`),this}param(...e){return this[jc].push(...Vo(e,`-e`)),this}}}}),Fc={};uo(Fc,{ResetMode:()=>zc,getResetMode:()=>Lc,resetTask:()=>Ic});function Ic(e,t){let n=[`reset`];return Rc(e)&&n.push(`--${e}`),n.push(...t),Ws(n)}function Lc(e){if(Rc(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function Rc(e){return typeof e==`string`&&Bc.includes(e)}var zc,Bc,Vc=X({"src/lib/tasks/reset.ts"(){Q(),Ys(),zc=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(zc||{}),Bc=zo(Object.values(zc))}});function Hc(){return(0,ro.default)(`simple-git`)}function Uc(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 Wc(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 Gc(e,t,n,r=Hc()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=Wc(Xo(t,ns),o,r);return l(n);function c(t,n){return Po(a,Gc(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&Uc(o,n)||qo,s=Uc(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var Kc=X({"src/lib/git-logger.ts"(){Q(),ro.default.formatters.L=e=>String(is(e)?e.length:`-`),ro.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):Jo(e)}}),qc,Jc=X({"src/lib/runners/tasks-pending-queue.ts"(){bo(),Kc(),qc=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:Gc(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 yo(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 Yc(e,t){return{method:Oo(e.commands)||``,commands:t}}function Xc(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function Zc(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var Qc,$c=X({"src/lib/runners/git-executor-chain.ts"(){bo(),Ys(),Q(),Jc(),Qc=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new qc}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(qs(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 yo?Object.assign(t,{task:e}):new yo(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`,``,Yc(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],Yc(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),Ks(e)?Ss(e.parser,a):Ss(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},{...Yc(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`,Jo(e)),c(new cs(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 cs(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},Yc(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,{...Yc(e,n),kill(e){u=e||u}});let d=we(t,n,o);d.stdout.on(`data`,Zc(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,Zc(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,Xc(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,{...Yc(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,{...Yc(e,t),kill(e){n=e||n}}),n}}}}),el={};uo(el,{GitExecutor:()=>tl});var tl,nl=X({"src/lib/runners/git-executor.ts"(){$c(),tl=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new Qc(this,this._scheduler,this._plugins)}chain(){return new Qc(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function rl(e,t,n=qo){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof xo?il(t):t,void 0)})}function il(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=qo};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 al=X({"src/lib/task-callback.ts"(){So(),Q()}});function ol(e,t){return Hs(n=>{if(!No(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var sl=X({"src/lib/tasks/change-working-directory.ts"(){Q(),Ys()}});function cl(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=Io(t,`-B`)),Ws(t)}function ll(){return{checkout(){return this._runTask(cl(_s(arguments,1)),bs(arguments))},checkoutBranch(e,t){return this._runTask(cl([`-b`,e,t,..._s(arguments)]),bs(arguments))},checkoutLocalBranch(e){return this._runTask(cl([`-b`,e,..._s(arguments)]),bs(arguments))}}}var ul=X({"src/lib/tasks/checkout.ts"(){Q(),Ys()}});function dl(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function fl(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return Cs(dl(),[pl],e)}})}}}var pl,ml=X({"src/lib/tasks/count-objects.ts"(){Q(),pl=new Z(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=Ro(t);Object.hasOwn(e,r)&&(e[r]=Bo(n))})}});function hl(e){return Cs({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},gl,e)}var gl,_l=X({"src/lib/parsers/parse-commit.ts"(){Q(),gl=[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 vl(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...Vo(e,`-m`),...t,...n],format:`utf-8`,parser:hl}}function yl(){return{commit(t,...n){let r=bs(arguments),i=e(t)||vl(Lo(t),Lo(Xo(n[0],rs,[])),[...zo(Xo(n[1],es,[])),..._s(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!rs(e)&&Us(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var bl=X({"src/lib/tasks/commit.ts"(){_l(),Q(),Ys()}});function xl(){return{firstCommit(){return this._runTask(Ws([`rev-list`,`--max-parents=0`,`HEAD`],!0),bs(arguments))}}}var Sl=X({"src/lib/tasks/first-commit.ts"(){Q(),Ys()}});function Cl(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),Ws(n,!0)}var wl=X({"src/lib/tasks/hash-object.ts"(){Ys()}});function Tl(e,t,n){let r=String(n).trim(),i;if(i=Dl.exec(r))return new El(e,t,!1,i[1]);if(i=Ol.exec(r))return new El(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new El(e,t,/^re/i.test(r),a)}var El,Dl,Ol,kl=X({"src/lib/responses/InitSummary.ts"(){El=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},Dl=/^Init.+ repository in (.+)$/,Ol=/^Rein.+ in (.+)$/}});function Al(e){return e.includes(Ml)}function jl(e=!1,t,n){let r=[`init`,...n];return e&&!Al(r)&&r.splice(1,0,Ml),{commands:r,format:`utf-8`,parser(e){return Tl(r.includes(`--bare`),t,e)}}}var Ml,Nl=X({"src/lib/tasks/init.ts"(){kl(),Ml=`--bare`}});function Pl(e){for(let t=0;t<e.length;t++){let n=Il.exec(e[t]);if(n)return`--${n[1]}`}return``}function Fl(e){return Il.test(e)}var Il,Ll=X({"src/lib/args/log-format.ts"(){Il=/^--(stat|numstat|name-only|name-status)(=|$)/}}),Rl,zl=X({"src/lib/responses/DiffSummary.ts"(){Rl=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function Bl(e=``){let t=Gl[e];return e=>Cs(new Rl,t,e,!1)}var Vl,Hl,Ul,Wl,Gl,Kl=X({"src/lib/parsers/parse-diff-summary.ts"(){Ll(),zl(),Ec(),Q(),Vl=[new Z(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:Bo(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:Bo(n),after:Bo(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=Bo(t),e.insertions=Bo(r?.[1]),e.deletions=Bo(i?.[1])})],Hl=[new Z(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=Bo(t),a=Bo(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})})],Ul=[new Z(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],Wl=[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:Go(Cc(t)&&t),from:Go(!!a&&r!==a&&r),similarity:Bo(n)})})],Gl={"":Vl,"--stat":Vl,"--numstat":Hl,"--name-status":Wl,"--name-only":Ul}}});function ql(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function Jl(e=Zl,t=Ql,n=``){let r=Bl(n);return function(n){let i=jo(n.trim(),!1,Yl).map(function(n){let i=n.split(Xl),a=ql(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 Yl,Xl,Zl,Ql,$l=X({"src/lib/parsers/parse-list-log-summary.ts"(){Q(),Kl(),Ll(),Yl=`òòòòòò `,Xl=` òò`,Zl=` ò `,Ql=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),eu={};uo(eu,{diffSummaryTask:()=>tu,validateLogFormatConfig:()=>nu});function tu(e){let t=Pl(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),nu(n)||{commands:n,format:`utf-8`,parser:Bl(t)}}function nu(e){let t=e.filter(Fl);if(t.length>1)return Us(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return Us(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var ru=X({"src/lib/tasks/diff.ts"(){Ll(),Kl(),Ys()}});function iu(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function au(e){return Object.keys(e).reduce((t,n)=>(n in lu||(t[n]=e[n]),t),{})}function ou(e={},t=[]){let n=Xo(e.splitter,ns,Zl),[r,i]=iu(Qo(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:${Yl}${i}${Xl}`,...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 ns(e.file)&&o.push(`--follow`,mo(e.file)),gs(au(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function su(e,t,n){let r=Jl(e,t,Pl(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function cu(){return{log(...n){let r=bs(arguments),i=ou(ys(arguments),zo(Xo(arguments[0],es,[]))),a=t(...n)||nu(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return su(e.splitter,e.fields,e.commands)}function t(e,t){return ns(e)&&ns(t)&&Us(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var lu,uu=X({"src/lib/tasks/log.ts"(){Ll(),vo(),$l(),Q(),Ys(),ru(),lu=(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))(lu||{})}}),du,fu,pu=X({"src/lib/responses/MergeSummary.ts"(){du=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},fu=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`}}}}),mu,hu,gu=X({"src/lib/responses/PullSummary.ts"(){mu=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},hu=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function _u(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 vu(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:Bo(t&&t[1]||`0`),delta:Bo(n&&n[1]||`0`)}}var yu,bu=X({"src/lib/parsers/parse-remote-objects.ts"(){Q(),yu=[new ds(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=_u(e.remoteMessages);Object.assign(i,{[r]:Bo(n)})}),new ds(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=_u(e.remoteMessages);Object.assign(i,{[r]:Bo(n)})}),new ds(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=_u(e.remoteMessages);i.total=vu(t),i.reused=vu(n),i.packReused=Bo(r)})]}});function xu(e,t){return Cs({remoteMessages:new Cu},Su,t)}var Su,Cu,wu=X({"src/lib/parsers/parse-remote-messages.ts"(){Q(),bu(),Su=[new ds(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...yu,new ds([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new ds([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:Bo(t),summary:n,url:r}})],Cu=class{constructor(){this.all=[]}}}});function Tu(e,t){let n=Cs(new hu,Au,[e,t]);return n.message&&n}var Eu,Du,Ou,ku,Au,ju,Mu,Nu=X({"src/lib/parsers/parse-pull.ts"(){gu(),Q(),wu(),Eu=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Du=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,Ou=/^(create|delete) mode \d+ (.+)/,ku=[new Z(Eu,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Z(Du,(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(Ou,(e,[t,n])=>{Po(e.files,n),Po(t===`create`?e.created:e.deleted,n)})],Au=[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})],ju=(e,t)=>Cs(new mu,ku,[e,t]),Mu=(e,t)=>Object.assign(new mu,ju(e,t),xu(e,t))}}),Pu,Fu,Iu,Lu=X({"src/lib/parsers/parse-merge.ts"(){pu(),Q(),Nu(),Pu=[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 du(t,n))}),new Z(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new du(t,n,{deleteRef:r}))}),new Z(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new du(t,null))}),new Z(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],Fu=(e,t)=>Object.assign(Iu(e,t),Mu(e,t)),Iu=e=>Cs(new fu,Pu,e)}});function Ru(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=Fu(e,t);if(n.failed)throw new xo(n);return n}}:Us(`Git.merge requires at least one option`)}var zu=X({"src/lib/tasks/merge.ts"(){So(),Lu(),Ys()}});function Bu(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 Vu,Hu,Uu,Wu=X({"src/lib/parsers/parse-push.ts"(){Q(),wu(),Vu=[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(Bu(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}}})],Hu=(e,t)=>{let n=Uu(e,t),r=xu(e,t);return{...n,...r}},Uu=(e,t)=>Cs({pushed:[]},Vu,[e,t])}}),Gu={};uo(Gu,{pushTagsTask:()=>Ku,pushTask:()=>qu});function Ku(e={},t){return Po(t,`--tags`),qu(e,t)}function qu(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),Io(n,`-v`),Po(n,`--verbose`),Po(n,`--porcelain`),{commands:n,format:`utf-8`,parser:Hu}}var Ju=X({"src/lib/tasks/push.ts"(){Wu(),Q()}});function Yu(){return{showBuffer(){let e=[`show`,..._s(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(Gs(e),bs(arguments))},show(){let e=[`show`,..._s(arguments,1)];return this._runTask(Ws(e),bs(arguments))}}}var Xu=X({"src/lib/tasks/show.ts"(){Q(),Ys()}}),Zu,Qu,$u=X({"src/lib/responses/FileStatusSummary.ts"(){Zu=/^(.+)\0(.+)$/,Qu=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=Zu.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function ed(e){let[t,n]=e.split(Ko);return{from:n||t,to:t}}function td(e,t,n){return[`${e}${t}`,n]}function nd(e,...t){return t.map(t=>td(e,t,(e,t)=>e.conflicted.push(t)))}function rd(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=ad.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new Qu(r,t,n))}}var id,ad,od,sd=X({"src/lib/responses/StatusSummary.ts"(){Q(),$u(),id=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}},ad=new Map([td(` `,`A`,(e,t)=>e.created.push(t)),td(` `,`D`,(e,t)=>e.deleted.push(t)),td(` `,`M`,(e,t)=>e.modified.push(t)),td(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),td(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),td(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),td(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),td(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),td(`R`,` `,(e,t)=>{e.renamed.push(ed(t))}),td(`R`,`M`,(e,t)=>{let n=ed(t);e.renamed.push(n),e.modified.push(n.to)}),td(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),td(`?`,`?`,(e,t)=>e.not_added.push(t)),...nd(`A`,`A`,`U`),...nd(`D`,`D`,`U`),...nd(`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=Xo(s?.[1],ns,null),s=a.exec(t),e.tracking=Xo(s?.[1],ns,null),s=o.exec(t),s&&(e.current=Xo(s?.[1],ns,e.current)),e.detached=/\(no branch\)/.test(t)}]]),od=function(e){let t=e.split(Ko),n=new id;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=Ko+(t[e++]||``)),rd(n,r))}return n}}});function cd(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!ld.includes(e))],parser(e){return od(e)}}}var ld,ud=X({"src/lib/tasks/status.ts"(){sd(),ld=[`--null`,`-z`]}});function dd(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 fd(){return dd(0,0,0,``,!1)}function pd(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:md,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(hd));r(t)}})}}}function md(e){return e===hd?fd():Cs(dd(0,0,0,e),gd,e)}var hd,gd,_d=X({"src/lib/tasks/version.ts"(){Q(),hd=`installed=false`,gd=[new Z(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,dd(Bo(t),Bo(n),Bo(r),i))}),new Z(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,dd(Bo(t),Bo(n),r,i))})]}});function vd(e,t,n,...r){return ns(n)?t(n,Xo(r[0],ns),_s(arguments)):Us(`git.${e}() requires a string 'repoPath'`)}function yd(){return{clone(e,...t){return this._runTask(vd(`clone`,bd,Xo(e,ns),...t),bs(arguments))},mirror(e,...t){return this._runTask(vd(`mirror`,xd,Xo(e,ns),...t),bs(arguments))}}}var bd,xd,Sd=X({"src/lib/tasks/clone.ts"(){Ys(),Q(),vo(),bd=(e,t,n)=>{let r=[`clone`,...n];return ns(e)&&r.push(mo(e)),ns(t)&&r.push(mo(t)),Ws(r)},xd=(e,t,n)=>(Po(n,`--mirror`),bd(e,t,n))}}),Cd={};uo(Cd,{SimpleGitApi:()=>wd});var wd,Td=X({"src/lib/simple-git-api.ts"(){al(),sl(),ul(),ml(),bl(),Sc(),Sl(),Pc(),wl(),Nl(),uu(),zu(),Ju(),Xu(),ud(),Ys(),_d(),Q(),Sd(),wd=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&rl(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(Ws([`add`,...Lo(e)]),bs(arguments))}cwd(e){let t=bs(arguments);return typeof e==`string`?this._runTask(ol(e,this._executor),t):typeof e?.path==`string`?this._runTask(ol(e.path,e.root&&this._executor||void 0),t):this._runTask(Us(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(Cl(e,t===!0),bs(arguments))}init(e){return this._runTask(jl(e===!0,this._executor.cwd,_s(arguments)),bs(arguments))}merge(){return this._runTask(Ru(_s(arguments)),bs(arguments))}mergeFromTo(e,t){return ns(e)&&ns(t)?this._runTask(Ru([e,t,..._s(arguments)]),bs(arguments,!1)):this._runTask(Us(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=qu({remote:Xo(arguments[0],ns),branch:Xo(arguments[1],ns)},_s(arguments));return this._runTask(e,bs(arguments))}stash(){return this._runTask(Ws([`stash`,..._s(arguments)]),bs(arguments))}status(){return this._runTask(cd(_s(arguments)),bs(arguments))}},Object.assign(wd.prototype,ll(),yd(),yl(),bc(),fl(),xl(),kc(),cu(),Yu(),pd())}}),Ed={};uo(Ed,{Scheduler:()=>Od});var Dd,Od,kd=X({"src/lib/runners/scheduler.ts"(){Q(),Kc(),Dd=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,io.createDeferred)();return{promise:t,done:n,id:e}}})(),Od=class{constructor(e=2){this.concurrency=e,this.logger=Gc(``,`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=Po(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),Io(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=Po(this.pending,Dd());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),Ad={};uo(Ad,{applyPatchTask:()=>jd});function jd(e,t){return Ws([`apply`,...t,...e])}var Md=X({"src/lib/tasks/apply-patch.ts"(){Ys()}});function Nd(e,t){return{branch:e,hash:t,success:!0}}function Pd(e){return{branch:e,hash:null,success:!1}}var Fd,Id=X({"src/lib/responses/BranchDeleteSummary.ts"(){Fd=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function Ld(e,t){return t===1&&zd.test(e)}var Rd,zd,Bd,Vd,Hd=X({"src/lib/parsers/parse-branch-delete.ts"(){Id(),Q(),Rd=/(\S+)\s+\(\S+\s([^)]+)\)/,zd=/^error[^']+'([^']+)'/m,Bd=[new Z(Rd,(e,[t,n])=>{let r=Nd(t,n);e.all.push(r),e.branches[t]=r}),new Z(zd,(e,[t])=>{let n=Pd(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],Vd=(e,t)=>Cs(new Fd,Bd,[e,t])}}),Ud,Wd=X({"src/lib/responses/BranchSummary.ts"(){Ud=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 Gd(e){return e?e.charAt(0):``}function Kd(e,t=!1){return Cs(new Ud,t?[Jd]:qd,e)}var qd,Jd,Yd=X({"src/lib/parsers/parse-branch.ts"(){Wd(),Q(),qd=[new Z(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(Gd(t),!0,n,r,i)}),new Z(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(Gd(t),!1,n,r,i)})],Jd=new Z(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),Xd={};uo(Xd,{branchLocalTask:()=>$d,branchTask:()=>Qd,containsDeleteBranchCommand:()=>Zd,deleteBranchTask:()=>tf,deleteBranchesTask:()=>ef});function Zd(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function Qd(e){let t=Zd(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?Vd(e,r).all[0]:Kd(e,n)}}}function $d(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return Kd(e)}}}function ef(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return Vd(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!Ld(String(n),e))return i(n);r(t)}}}function tf(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return Vd(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!Ld(String(i),e))return o(i);throw new xo(n.parser(Ho(r),Ho(t)),String(i))}};return n}var nf=X({"src/lib/tasks/branch.ts"(){So(),Hd(),Yd(),Q()}});function rf(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&le(t)}var af,of=X({"src/lib/responses/CheckIgnore.ts"(){af=e=>e.split(/\n/g).map(rf).filter(Boolean)}}),sf={};uo(sf,{checkIgnoreTask:()=>cf});function cf(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:af}}var lf=X({"src/lib/tasks/check-ignore.ts"(){of()}});function uf(e,t){return Cs({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},df,[e,t])}var df,ff=X({"src/lib/parsers/parse-fetch.ts"(){Q(),df=[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})})]}}),pf={};uo(pf,{fetchTask:()=>hf});function mf(e){return/^--upload-pack(=|$)/.test(e)}function hf(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(mf)?Us(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:uf}}var gf=X({"src/lib/tasks/fetch.ts"(){ff(),Ys()}});function _f(e){return Cs({moves:[]},vf,e)}var vf,yf=X({"src/lib/parsers/parse-move.ts"(){Q(),vf=[new Z(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),bf={};uo(bf,{moveTask:()=>xf});function xf(e,t){return{commands:[`mv`,`-v`,...Lo(e),t],format:`utf-8`,parser:_f}}var Sf=X({"src/lib/tasks/move.ts"(){yf(),Q()}}),Cf={};uo(Cf,{pullTask:()=>wf});function wf(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 Mu(e,t)},onError(e,t,n,r){let i=Tu(Ho(e.stdOut),Ho(e.stdErr));if(i)return r(new xo(i));r(t)}}}var Tf=X({"src/lib/tasks/pull.ts"(){So(),Nu(),Q()}});function Ef(e){let t={};return Of(e,([e])=>t[e]={name:e}),Object.values(t)}function Df(e){let t={};return Of(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 Of(e,t){Mo(e,e=>t(e.split(/\s+/)))}var kf=X({"src/lib/responses/GetRemoteSummary.ts"(){Q()}}),Af={};uo(Af,{addRemoteTask:()=>jf,getRemotesTask:()=>Mf,listRemotesTask:()=>Nf,remoteTask:()=>Pf,removeRemoteTask:()=>Ff});function jf(e,t,n){return Ws([`remote`,`add`,...n,e,t])}function Mf(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Df:Ef}}function Nf(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),Ws(t)}function Pf(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),Ws(t)}function Ff(e){return Ws([`remote`,`remove`,e])}var If=X({"src/lib/tasks/remote.ts"(){kf(),Ys()}}),Lf={};uo(Lf,{stashListTask:()=>Rf});function Rf(e={},t){let n=ou(e),r=[`stash`,`list`,...n.commands,...t],i=Jl(n.splitter,n.fields,Pl(r));return nu(r)||{commands:r,format:`utf-8`,parser:i}}var zf=X({"src/lib/tasks/stash-list.ts"(){Ll(),$l(),ru(),uu()}}),Bf={};uo(Bf,{addSubModuleTask:()=>Vf,initSubModuleTask:()=>Hf,subModuleTask:()=>Uf,updateSubModuleTask:()=>Wf});function Vf(e,t){return Uf([`add`,e,t])}function Hf(e){return Uf([`init`,...e])}function Uf(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),Ws(t)}function Wf(e){return Uf([`update`,...e])}var Gf=X({"src/lib/tasks/sub-module.ts"(){Ys()}});function Kf(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?qf(e,t):0:n?1:-1}function qf(e,t){return e===t?0:e>t?1:-1}function Jf(e){return e.trim()}function Yf(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var Xf,Zf,Qf=X({"src/lib/responses/TagList.ts"(){Xf=class{constructor(e,t){this.all=e,this.latest=t}},Zf=function(e,t=!1){let n=e.split(`
|
|
22
|
-
`).map(Jf).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return Kf(Yf(n[0]),Yf(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=qf(Yf(n[e]),Yf(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new Xf(n,r)}}}),$f={};uo($f,{addAnnotatedTagTask:()=>np,addTagTask:()=>tp,tagListTask:()=>ep});function ep(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return Zf(e,t)}}}function tp(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function np(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var rp=X({"src/lib/tasks/tag.ts"(){Qf()}}),ip=lo({"src/git.js"(e,t){var{GitExecutor:n}=(nl(),po(el)),{SimpleGitApi:r}=(Td(),po(Cd)),{Scheduler:i}=(kd(),po(Ed)),{adhocExecTask:a,configurationErrorTask:o}=(Ys(),po(Vs)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(Q(),po(Ts)),{applyPatchTask:g}=(Md(),po(Ad)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(nf(),po(Xd)),{checkIgnoreTask:x}=(lf(),po(sf)),{checkIsRepoTask:S}=(Ps(),po(Es)),{cleanWithOptionsTask:C,isCleanOptionsArray:w}=(lc(),po(Xs)),{diffSummaryTask:T}=(ru(),po(eu)),{fetchTask:E}=(gf(),po(pf)),{moveTask:D}=(Sf(),po(bf)),{pullTask:O}=(Tf(),po(Cf)),{pushTagsTask:ee}=(Ju(),po(Gu)),{addRemoteTask:k,getRemotesTask:A,listRemotesTask:j,remoteTask:te,removeRemoteTask:M}=(If(),po(Af)),{getResetMode:ne,resetTask:N}=(Vc(),po(Fc)),{stashListTask:P}=(zf(),po(Lf)),{addSubModuleTask:re,initSubModuleTask:ie,subModuleTask:F,updateSubModuleTask:I}=(Gf(),po(Bf)),{addAnnotatedTagTask:L,addTagTask:ae,tagListTask:R}=(rp(),po($f)),{straightThroughBufferTask:oe,straightThroughStringTask:z}=(Ys(),po(Vs));function B(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(B.prototype=Object.create(r.prototype)).constructor=B,B.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},B.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},B.prototype.stashList=function(e){return this._runTask(P(h(arguments)||{},c(e)&&e||[]),m(arguments))},B.prototype.mv=function(e,t){return this._runTask(D(e,t),m(arguments))},B.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},B.prototype.pull=function(e,t,n,r){return this._runTask(O(f(e,u),f(t,u),p(arguments)),m(arguments))},B.prototype.fetch=function(e,t){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},B.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.")))},B.prototype.tags=function(e,t){return this._runTask(R(p(arguments)),m(arguments))},B.prototype.rebase=function(){return this._runTask(z([`rebase`,...p(arguments)]),m(arguments))},B.prototype.reset=function(e){return this._runTask(N(ne(e),p(arguments)),m(arguments))},B.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(z([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},B.prototype.addTag=function(e){let t=typeof e==`string`?ae(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},B.prototype.addAnnotatedTag=function(e,t){return this._runTask(L(e,t),m(arguments))},B.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},B.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},B.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},B.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},B.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(z(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},B.prototype.submoduleAdd=function(e,t,n){return this._runTask(re(e,t),m(arguments))},B.prototype.submoduleUpdate=function(e,t){return this._runTask(I(p(arguments,!0)),m(arguments))},B.prototype.submoduleInit=function(e,t){return this._runTask(ie(p(arguments,!0)),m(arguments))},B.prototype.subModule=function(e,t){return this._runTask(F(p(arguments)),m(arguments))},B.prototype.listRemote=function(){return this._runTask(j(p(arguments)),m(arguments))},B.prototype.addRemote=function(e,t,n){return this._runTask(k(e,t,p(arguments)),m(arguments))},B.prototype.removeRemote=function(e,t){return this._runTask(M(e),m(arguments))},B.prototype.getRemotes=function(e,t){return this._runTask(A(e===!0),m(arguments))},B.prototype.remote=function(e,t){return this._runTask(te(p(arguments)),m(arguments))},B.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(z(n),m(arguments))},B.prototype.updateServerInfo=function(e){return this._runTask(z([`update-server-info`]),m(arguments))},B.prototype.pushTags=function(e,t){let n=ee({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},B.prototype.rm=function(e){return this._runTask(z([`rm`,`-f`,...s(e)]),m(arguments))},B.prototype.rmKeepLocal=function(e){return this._runTask(z([`rm`,`--cached`,...s(e)]),m(arguments))},B.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},B.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},B.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`?oe(r):z(r);return this._runTask(a,n)},B.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`):z([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},B.prototype.diffSummary=function(){return this._runTask(T(p(arguments,1)),m(arguments))},B.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))},B.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(z(e,!0),m(arguments))},B.prototype.clean=function(e,t,n){let r=w(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(C(i,a),m(arguments))},B.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},B.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.`)))},B.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},B.prototype.checkIsRepo=function(e,t){return this._runTask(S(f(e,u)),m(arguments))},t.exports=B}});vo(),bo();var ap=class extends yo{constructor(e,t){super(void 0,t),this.config=e}};bo(),bo();var op=class extends yo{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};So(),wo(),Ps(),lc(),Sc(),Ec(),Pc(),Vc();function sp(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new op(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new op(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function cp(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function lp(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 up(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&cp(i)&&r.test(a))throw new op(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var dp=[up(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),up(`core.sshCommand`,`allowUnsafeSshCommand`),up(`core.gitProxy`,`allowUnsafeGitProxy`),up(`core.hooksPath`,`allowUnsafeHooksPath`),up(`diff.external`,`allowUnsafeDiffExternal`)];function fp(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new op(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&lp(`u`,e))throw new op(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 op(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function pp({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||fp(i,r.method),dp.forEach(e=>e(t,i,o))}),n}}}Q();function mp(e){let t=Vo(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}Q();var hp=(0,io.deferred)().promise;function gp({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,io.deferred)(),closeTimeout:(0,io.deferred)(),exit:(0,io.deferred)(),exitTimeout:(0,io.deferred)()},a=Promise.race([e===!1?hp:i.closeTimeout.promise,t===!1?hp: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(()=>Wo(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 Wo(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}Q();var _p=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,vp=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function yp(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function bp(e,t){if(e.length<1||e.length>2)throw new op(void 0,`binary`,_p);if(e.some(yp))if(t)console.warn(vp);else throw new op(void 0,`binary`,vp);let[n,r]=e;return{binary:n,prefix:r}}function xp(e,t=[`git`],n=!1){let r=bp(Lo(t),n);e.on(`binary`,e=>{r=bp(Lo(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}bo();function Sp(e){return!!(e.exitCode&&e.stdErr.length)}function Cp(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function wp(e=!1,t=Sp,n=Cp){return(r,i)=>!e&&r||!t(i)?r:n(i)}function Tp(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 yo(void 0,r.toString(`utf-8`))}:{error:r}}}}Q();var Ep=class{constructor(){this.plugins=new Set,this.events=new Te}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=Po(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return Lo(e).forEach(e=>e&&this.plugins.add(Po(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 Dp(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?Fo(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:Op(n[1]),progress:Bo(n[2]),processed:Bo(n[3]),total:Bo(n[4])})})}}]}function Op(e){return String(e.toLowerCase().split(` `,1))||`unknown`}Q();function kp(e){let t=Uo(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function Ap({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 op(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()}}}vo();function jp(){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(ho(i)){r(go(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>ho(e)&&go(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}Q();var Mp=ip();function Np(e,t){let n=new Ep,r=ps(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!No(r.baseDir))throw new ap(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(mp(r.config)),n.add(pp(r.unsafe)),n.add(gp(r.completion)),r.abort&&n.add(sp(r.abort)),r.progress&&n.add(Dp(r.progress)),r.timeout&&n.add(Ap(r.timeout)),r.spawnOptions&&n.add(kp(r.spawnOptions)),n.add(jp()),n.add(Tp(wp(!0))),r.errors&&n.add(Tp(r.errors)),xp(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new Mp(r,n)}So();var Pp=Np;const Fp=`.expect`,Ip=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`,`.cts`,`.cjs`],Lp=new Set([`node_modules`,`dist`,`build`,`.git`,`.next`,`.turbo`,`coverage`,`.nyc_output`,`.cache`,`.repos`,`.specs`,`__snapshots__`,`__fixtures__`]);var Rp=class extends b.ErrorClass(`GitError`)({_tag:b.tag(`GitError`),operation:b.String,cause:b.Defect}){message=`Git error during "${this.operation}"`},zp=class extends b.ErrorClass(`FindRepoRootError`)({_tag:b.tag(`FindRepoRootError`),cause:b.Defect}){message=`Could not find git repository root`},Bp=class extends x.Service()(`@supervisor/GitRepoRoot`){},Vp=class e extends x.Service()(`@supervisor/Git`,{make:c.gen(function*(){let e=yield*d.FileSystem,t=e=>c.gen(function*(){let t=yield*Bp;return yield*c.tryPromise({try:()=>Pp(t).raw(e.args),catch:t=>new Rp({operation:e.operation,cause:t})}).pipe(c.map(e.trim?ve.trim:ye.identity))}),n=e=>c.tryPromise({try:()=>Pp(e).revparse([`--show-toplevel`]),catch:e=>new zp({cause:e})}).pipe(c.map(ve.trim)),r=e=>t=>c.gen(function*(){let r=yield*n(e);return yield*t.pipe(c.provideService(Bp,r))}),i=t({args:[`symbolic-ref`,`refs/remotes/origin/HEAD`],operation:`getting main branch`,trim:!0}).pipe(c.map(e=>e.replace(`refs/remotes/origin/`,``)),c.catchTag(`GitError`,()=>t({args:[`revparse`,`--verify`,`origin/main`],operation:`getting main branch (origin/main)`,trim:!0}).pipe(c.as(`main`))),c.catchTag(`GitError`,()=>t({args:[`rev-parse`,`--verify`,`main`],operation:`getting main branch (main)`,trim:!0}).pipe(c.as(`main`))),c.catchTag(`GitError`,()=>c.succeed(`main`))),a=t({args:[`rev-parse`,`--abbrev-ref`,`HEAD`],operation:`getting current branch`,trim:!0}).pipe(c.catchTag(`GitError`,()=>c.succeed(`HEAD`))),o=t({args:[`rev-parse`,`--is-inside-work-tree`],operation:`checking if inside work tree`,trim:!0}).pipe(c.map(e=>e===`true`),c.catchTag(`GitError`,()=>c.succeed(!1))),s=e=>{let[t,n,r]=e.split(` `);return new on({relativePath:r??``,added:Number.parseInt(t??`0`,10)||0,removed:Number.parseInt(n??`0`,10)||0})},l=c.fn(`Git.getFileStats`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`,`--numstat`],operation:`getting working tree file stats`}).pipe(c.map(ve.split(`
|
|
23
|
-
`)),
|
|
24
|
-
`)),
|
|
25
|
-
`)),
|
|
26
|
-
`)),
|
|
27
|
-
`)),
|
|
28
|
-
`).pipe(
|
|
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:
|
|
31
|
-
`).pipe(c.catchTag(`PlatformError`,()=>c.void))),n}),$p=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),em=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:$p(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:dn(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=h.getOrElse(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:h.getOrElse(e.baseUrl,()=>``),cookies:e.requiresCookies}});var tm=class extends x.Service()(`@supervisor/FlowStorage`,{make:c.gen(function*(){let e=yield*d.FileSystem,t=c.gen(function*(){let t=yield*Qp(e,yield*Bp);return G.join(t,`flows`)});return{save:c.fn(`FlowStorage.save`)(function*(n){let r=em(n),i=yield*t,a=G.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(c.catchTag(`PlatformError`,()=>c.void)),yield*e.writeFileString(a,Kp(r)),yield*c.logInfo(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:c.fn(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(c.catchTag(`PlatformError`,()=>c.succeed(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(c.catchTag(`PlatformError`,()=>c.succeed([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(G.join(n,t)).pipe(c.catchTag(`PlatformError`,()=>c.succeed(``)));if(!r)continue;let a=yield*c.try({try:()=>Zp(r),catch:()=>({_tag:`FlowParseError`})}).pipe(c.catchTag(`FlowParseError`,()=>c.succeed(void 0)));a&&i.push(a)}return yield*c.logDebug(`Flows listed`,{count:i.length}),i})}})}){static layer=f.effect(this)(this.make).pipe(f.provide(J.layer))};const nm=(e,t)=>{try{return z(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var rm=class extends b.ErrorClass(`GitHubCommandError`)({_tag:b.tag(`GitHubCommandError`),cause:b.String}){message=`GitHub CLI command failed: ${this.cause}`},im=class extends x.Service()(`@supervisor/GitHub`,{make:c.gen(function*(){let e=yield*Ae,t=yield*Ee,n=c.fn(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(me.make(`gh`,n,{cwd:t})).pipe(c.timeout(15e3),c.catchTags({PlatformError:e=>c.fail(new rm({cause:e.message})),TimeoutError:()=>c.fail(new rm({cause:`command timed out`}))}),c.map(e=>e.trim()))}),r=c.fn(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,m.value(t).pipe(m.when({_tag:`Branch`},e=>e.branchName),m.exhaustive),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*b.decodeEffect(b.fromJsonString(b.Array(Rn)))(r).pipe(c.map(a.head),c.catchTag(`SchemaError`,()=>c.succeed(h.none())))}),i=b.fromJsonString(b.Array(fn));return{findPullRequest:r,listPullRequests:c.fn(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(c.catchTag(`GitHubCommandError`,()=>c.succeed(`[]`)));return(yield*b.decodeEffect(i)(t).pipe(c.catchTag(`SchemaError`,c.die))).map(e=>new mn({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:c.fn(`GitHub.addComment`)(function*(e,r,i){yield*c.scoped(c.gen(function*(){let a=ce(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=f.effect(this)(this.make).pipe(f.provide(J.layer))};const am=e=>G.join(De.homedir(),Fp,`${e}.json`),om=new Map,sm={getItem:async e=>{try{let t=await Me.readFile(am(e),`utf-8`);return om.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(om.get(e)===t)return;om.set(e,t);let n=am(e);await Me.mkdir(G.dirname(n),{recursive:!0}),await Me.writeFile(n,t,`utf-8`)},removeItem:async e=>{om.delete(e);try{await Me.unlink(am(e))}catch{}}},cm=e=>G.join(process.cwd(),Fp,`${e}.json`),lm=new Map,um={getItem:async e=>{try{let t=await Me.readFile(cm(e),`utf-8`);return lm.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(lm.get(e)===t)return;lm.set(e,t);let n=cm(e);await Me.mkdir(G.dirname(n),{recursive:!0}),await Me.writeFile(n,t,`utf-8`)},removeItem:async e=>{lm.delete(e);try{await Me.unlink(cm(e))}catch{}}};var dm=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`]}})),fm=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)})),pm=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=dm().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=fm()}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 mm=[/from\s+["']([^"']+)["']/g,/import\s*\(\s*["']([^"']+)["']\s*\)/g,/require\s*\(\s*["']([^"']+)["']\s*\)/g],hm=/\.(?:test|spec|e2e)\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,gm=/(?:^|[/\\])(?:__tests?__|tests?)[/\\]/,_m=/\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,vm=e=>{let t=G.extname(e).toLowerCase();return Ip.includes(t)},ym=e=>e.split(/[/\\]/).some(e=>Lp.has(e)),bm=e=>!!(hm.test(e)||gm.test(e)&&_m.test(e)),xm=e=>{let t=[];for(let n of mm){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},Sm=(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},Cm=e=>c.tryPromise({try:()=>new Promise(t=>{oe(`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:()=>[]}),
|
|
33
|
-
`)}))
|
|
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,S=l(b)==`process`,C=function(){},w=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(C,C)};return(S||typeof PromiseRejectionEvent==`function`)&&e.then(C)instanceof t}catch{}}(),T=function(e,t){return e===t||e===x&&t===a},E=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},D=function(e){return T(x,e)?new O(e):new i(e)},O=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)},ee=function(e){try{e()}catch(e){return{error:e}}},k=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&&te(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=E(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&&A(e)})}},A=function(e){g.call(s,function(){var t,n,r,i=e._v;if(j(e)&&(t=ee(function(){S?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=S||j(e)?2:1),e._a=void 0,t)throw t.error})},j=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||!j(t.promise))return!1;return!0},te=function(e){g.call(s,function(){var t;S?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},M=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(),k(t,!0))},ne=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=E(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(ne,r,1),c(M,r,1))}catch(e){M.call(r,e)}}):(n._v=e,n._s=1,k(n,!1))}catch(e){M.call({_w:n,_d:!1},e)}}};w||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(ne,this,1),c(M,this,1))}catch(e){M.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=D(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=S?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&k(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),O=function(){var e=new r;this.promise=e,this.resolve=c(ne,e,1),this.reject=c(M,e,1)}),u(u.G+u.W+u.F*!w,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!w,v,{reject:function(e){var t=D(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!w),v,{resolve:function(e){if(e instanceof x&&T(e.constructor,this))return e;var t=D(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(w&&n(46)(function(e){x.all(e).catch(C)})),v,{all:function(e){var t=this,n=D(t),r=n.resolve,i=n.reject,a=ee(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=D(t),r=n.reject,i=ee(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 th(e){return typeof e==`string`?`'${e}'`:new nh().serialize(e)}const nh=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}(),rh=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,ih=`sha256`,ah=`base64url`;function oh(e){if(rh)return rh(ih,e,ah);let t=xe(ih).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(ah):t.digest(ah)}function sh(e){return oh(th(e))}function ch(){let e=lh();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function lh(e=process.argv[1]?Be(process.argv[1]):process.cwd(),t=He===`\\`){let n=t?uh(e):e;return e=>{if(!e)return;let r=t?uh(e):e,{dir:i,base:a,ext:o}=Ve.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 uh(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const dh=e=>{if(`flags`in e){let t=ph(e.flags),n=mh(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,gh(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,fh(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function fh(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 ph=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,hh(t)]).filter(([,e])=>e!==void 0)),mh=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?gh(n):void 0]}))},hh=e=>e===void 0?void 0:e.variant??e.enabled,gh=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},_h=`0123456789abcdef`;var vh=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+=_h.charAt(this.bytes[t]>>>4),e+=_h.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+=_h.charAt(this.bytes[t]>>>4),e+=_h.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}},yh=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??bh()}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 vh.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,vh.ofInner(e)}};const bh=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let xh;const Sh=()=>Ch().toString(),Ch=()=>(xh||=new yh).generate();var wh=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 Th=`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(`,`),Eh=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return Th.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},Dh=Array.isArray,Oh=Object.prototype;Oh.hasOwnProperty;const kh=Oh.toString,Ah=Dh||function(e){return kh.call(e)===`[object Array]`},jh=e=>e===Object(e)&&!Ah(e),Mh=e=>e===void 0,Nh=e=>kh.call(e)==`[object String]`,Ph=e=>Nh(e)&&e.trim().length===0,Fh=e=>kh.call(e)==`[object Number]`&&e===e,Ih=e=>e instanceof Error;function Lh(e){return typeof e!=`object`||!e}function Rh(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function zh(e){return!Mh(Event)&&Vh(e,Event)}function Bh(e){return Rh(e,`Object`)}function Vh(e,t){try{return e instanceof t}catch{return!1}}function Hh(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Fh(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),Hh(i||n,t,n,r))}var Uh=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Hh(e.bucketSize,0,100,e._logger),this._refillRate=Hh(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Hh(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={}}},Wh=class{add(e){let t=Sh();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 Gh(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const Kh=(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=>Kh(`${e} ${r}`,t,n)}},qh=e=>e();function Jh(e,t=qh){return Kh(e,t,Gh())}const Yh=`Android`;Yh+``;const Xh=`BlackBerry`,Zh=`Samsung`;Zh+``,Zh+``;const Qh=`Chrome`;Qh+``,Qh+``;const $h=`Opera`;$h+``;const eg=`Edge`;``+eg;const tg=`Firefox`;tg+``;const ng=`Nintendo`,rg=`PlayStation`,ig=`Xbox`;Yh+``;const ag=`Windows`;ag+``;const og=`Generic`;og+``,og+``;const sg=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+sg),new RegExp(ig,`i`),RegExp(rg+` \\w+`,`i`),RegExp(ng+` \\w+`,`i`),RegExp(Xh+`|PlayBook|BB10`,`i`),RegExp(`rv:`+sg),RegExp(eg+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+Qh+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+sg),RegExp(`(UCBrowser|UCWEB)\\/`+sg),RegExp(`(`+$h+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp(tg+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+sg),RegExp(`Konqueror[:/]?`+sg,`i`),RegExp(Xh+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+sg,`i`),RegExp(`(rv:|MSIE )`+sg),RegExp(`rv:`+sg),RegExp(ig+`; Xbox (.*?)[);]`,`i`),new RegExp(ng,`i`),new RegExp(rg,`i`),new RegExp(ag,`i`),RegExp(`(`+Yh+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function cg(e,t){if(!e||typeof e!=`string`||lg(e))throw Error(t)}function lg(e){return e.trim().length===0}function ug(e){return e?.replace(/\/+$/,``)}async function dg(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 fg(){return new Date().toISOString()}function pg(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const mg=e=>e instanceof Error;function hg(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var gg=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 _g(){return`CompressionStream`in globalThis}async function vg(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 yg=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()}},bg=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function xg(e){if(e instanceof yg){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 Sg(e){return typeof e==`object`&&(e instanceof yg||e instanceof bg)}function Cg(e){return typeof e==`object`&&e instanceof yg&&e.status===413}var wg=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new Wh,this._events=new gg,this._isInitialized=!1,cg(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=ug(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:Sg},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=Jh(`[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=!_g()||(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(wh.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(wh.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(wh.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:dh(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof yg)return{type:`api_error`,statusCode:e.status};if(e instanceof bg){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=hh(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(wh.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(wh.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(wh.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(wh.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(wh.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=pg(()=>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:fg()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await vg(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:fg(),uuid:n?.uuid?n.uuid:Sh()};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 xg(e)})}async flush(){let e=hg([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),hg([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(wh.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(wh.Queue)||[]).slice(n.length);this.setPersistedProperty(wh.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:fg()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await vg(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>Cg(e)?!1:Sg(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(Cg(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 bg||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 dg(async()=>{let n=new AbortController,i=pg(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new bg(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new yg(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(wh.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!Sg(e))throw e;await xg(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=pg(()=>{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 Tg,Eg,Dg;function Og(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Dg&&n.length===Eg?Dg:(Eg=n.length,Dg=n.reduce((n,r)=>{Tg||={};let i=Tg[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,Tg[r]=[a,o];break}}}return n},{}),Dg)}var kg=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&&Ah(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:Og(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 Ag=/^\s*[-]{4,}$/,jg=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,Mg=(e,t)=>{let n=e.match(jg);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:Pg(n[3]),colno:Pg(n[4]),in_app:Ng(s||``,c),platform:t}}if(e.match(Ag))return{filename:e,platform:t}};function Ng(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 Pg(e){return parseInt(e||``,10)||void 0}const Fg=/\(error: (.*)\)/;function Ig(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||Lg(t).filename,function:e.function||`?`}))}function Lg(e){return e[e.length-1]||{}}function Rg(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=Fg.test(r)?r.replace(Fg,`$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 Ig(i)}}var zg=class{match(e){return Ih(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 Bg=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Vg=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(Bg);return r&&(t=r[1],n=r[2]),[t,n]}};const Hg=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Ug(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 Wg=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 zh(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=Ug(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return Nh(e)&&!Ph(e)&&Hg.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(mg(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Gg=class{match(e){return zh(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Ug(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},Kg=class{match(e){return Lh(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},qg=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 Jg=new qg(25),Yg=new qg(20);async function Xg(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`||t_(i)||n_(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(Yg.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=i_(n);if(i.every(t=>r_(e,t)))continue;let a=c_(Jg,e,{});r.push(Zg(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&Qg(e,Jg),Jg.reduce(),e}function Zg(e,t,n){return new Promise(r=>{let i=Pe(e),a=Ue({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(){Yg.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]=l_(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 Qg(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;$g(n.lineno,n,e)}}function $g(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=o_(e);r<e;r++){let e=n[r];if(e===void 0)return void e_(t);t.pre_context.push(e)}if(n[e]===void 0)return void e_(t);t.context_line=n[e];let r=s_(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 e_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function t_(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function n_(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function r_(e,t){let n=Jg.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 i_(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=a_(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=a_(n)),t++}return i}function a_(e){return[o_(e),s_(e)]}function o_(e){return Math.max(1,e-7)}function s_(e){return e+7}function c_(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function l_(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 u_(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 d_(e,t){globalThis.process?.on(`uncaughtException`,u_(e,t))}function f_(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var p_=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Uh({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return jh(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||Sh(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(d_(this.onException.bind(this),this.onFatalError.bind(this)),f_(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 m_={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function h_(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 g_=[`is_not`];var __=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)}},v_=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},y_=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 v_||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 v_||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 v_)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`?C_(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):x_(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await b_(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await b_(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 __(`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 __(`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 __(`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 __&&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=pg(()=>{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 b_(e,t,n=``){let r=await h_(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function x_(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&&!g_.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 T_(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return T_(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=M_(String(i));if(e??=j_(i),e==null)throw new $(`Invalid date: ${i}`);let t=j_(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return D_(E_(String(o)),E_(String(i)))===0;case`semver_neq`:return D_(E_(String(o)),E_(String(i)))!==0;case`semver_gt`:return D_(E_(String(o)),E_(String(i)))>0;case`semver_gte`:return D_(E_(String(o)),E_(String(i)))>=0;case`semver_lt`:return D_(E_(String(o)),E_(String(i)))<0;case`semver_lte`:return D_(E_(String(o)),E_(String(i)))<=0;case`semver_tilde`:{let e=E_(String(o)),{lower:t,upper:n}=O_(String(i));return D_(e,t)>=0&&D_(e,n)<0}case`semver_caret`:{let e=E_(String(o)),{lower:t,upper:n}=k_(String(i));return D_(e,t)>=0&&D_(e,n)<0}case`semver_wildcard`:{let e=E_(String(o)),{lower:t,upper:n}=A_(String(i));return D_(e,t)>=0&&D_(e,n)<0}default:throw new $(`Unknown operator: ${a}`)}}function S_(e,t){if(!(e in t))throw new v_(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function C_(e,t,n,r=!1){let i=String(e.value);S_(i,n);let a=n[i];return w_(a,t,n,r)}function w_(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=w_(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof v_)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=C_(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=x_(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 v_)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 T_(e){try{return new RegExp(e),!0}catch{return!1}}function E_(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 D_(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 O_(e){let t=E_(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function k_(e){let[t,n,r]=E_(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 A_(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 j_(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 M_(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 N_=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const P_=3e4;var F_=class extends wg{constructor(e,t={}){if(super(e,t),this._memoryStorage=new N_,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):P_,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 y_({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 p_(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=pg(()=>{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=P_){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 v_||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=m_.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(m_.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(m_.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(m_.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=pg(()=>{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(Bh(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(!p_.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(p_.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!p_.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(p_.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=Sh(),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`&&Eh(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}},I_=class{constructor(){this.storage=new We}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 L_=`posthog-node`;function R_(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[z_.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 z_=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=L_,this.name=L_,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(R_(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};p_.errorPropertiesBuilder=new kg([new Gg,new zg,new Wg,new Vg,new Kg],Rg(`node:javascript`,Mg),[ch(),Xg]);const B_=new class extends F_{getLibraryId(){return`posthog-node`}initializeContext(){return new I_}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`}),V_=b.Struct({email:b.String});var H_=class extends x.Service()(`@expect/AnalyticsProvider`){static layerPostHog=f.succeed(this)({capture:e=>c.sync(()=>{B_.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>c.sync(()=>{B_.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:c.tryPromise({try:()=>B_.flush(),catch:e=>e}).pipe(c.ignore)});static layerDev=f.succeed(this)({capture:e=>c.logInfo(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(c.annotateLogs({module:`Analytics`})),identify:e=>c.logInfo(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(c.annotateLogs({module:`Analytics`})),flush:c.void})},U_=class extends x.Service()(`@expect/Analytics`,{make:c.gen(function*(){let e=yield*H_,t=yield*Ae,n=yield*c.tryPromise(()=>(0,eh.machineId)()).pipe(c.orDie),r=sh(process.cwd()),i=c.fn(`getClaudeCodeEmail`)(function*(){let e=yield*t.string(me.make(`claude`,[`auth`,`status`])).pipe(c.timeout(`5 seconds`));return(yield*b.decodeEffect(b.fromJsonString(V_))(e)).email}),a=c.fn(`getGitEmail`)(function*(){let e=yield*t.string(me.make(`git`,[`config`,`user.email`])).pipe(c.timeout(`5 seconds`),c.map(e=>e.trim()));return e.length===0?yield*c.fail(`empty`):e}),o=c.fn(`getGitName`)(function*(){let e=yield*t.string(me.make(`git`,[`config`,`user.name`])).pipe(c.timeout(`5 seconds`),c.map(e=>e.trim()));return e.length===0?yield*c.fail(`empty`):e});yield*c.all({email:i().pipe(c.catchTag(`PlatformError`,()=>a()),c.catchTag(`TimeoutError`,()=>a()),c.catchTag(`SchemaError`,()=>a())),name:o().pipe(c.catchCause(()=>c.succeed(void 0)))}).pipe(c.tap(({email:t,name:r})=>e.identify({distinctId:n,email:t,name:r})),c.catchCause(()=>c.void),c.forkScoped);let s=(t,...[i])=>c.gen(function*(){let a={timestamp:new Date().toISOString(),projectId:r};yield*e.capture({eventName:t,properties:{...a,...i??{}},distinctId:n})}).pipe(c.catchCause(e=>c.logWarning(`Analytics capture failed`,{eventName:t,cause:e}).pipe(c.annotateLogs({module:`Analytics`}))));return{capture:s,track:((e,t)=>n=>c.tap(n,n=>{let r=t?t(n):void 0;return s.call(void 0,e,...r===void 0?[]:[r])})),flush:e.flush}})}){static layerPostHog=f.effect(this)(this.make).pipe(f.provide(H_.layerPostHog),f.provide(J.layer));static layerDev=f.effect(this)(this.make).pipe(f.provide(H_.layerDev),f.provide(J.layer))};const W_=e=>{let t=o.squash(e);return{error_tag:g.hasProperty(t,`_tag`)?String(t._tag):`Unknown`,error_message:o.pretty(e)}};(class extends x.Service()(`@expect/ErrorHandler`,{make:c.gen(function*(){let e=yield*U_;return{orDie:t=>t.pipe(c.tapCause(t=>e.capture(`error:unexpected`,W_(t))),c.orDie),streamOrDie:t=>t.pipe(S.tapCause(t=>e.capture(`error:unexpected`,W_(t))),S.orDie),tapCause:(...t)=>n=>n.pipe(c.tapCause(n=>c.all([e.capture(`error:expected`,W_(n)),c.logError(...t,n)],{discard:!0})))}})}){static layer=f.effect(this)(this.make)}),Ke.layerWebSocket().pipe(f.provide(ke.layerWebSocketConstructor));const G_=f.unwrap(c.gen(function*(){let e=`expect-cli`;return qe.layerJson({baseUrl:`https://api.axiom.co`,resource:{serviceName:e},headers:{Authorization:`Bearer xaat-a6ce2fdb-d378-444e-9d72-bb458867187a`,"X-Axiom-Dataset":e}})})).pipe(f.provide(Ge.layerUndici),f.orDie),K_=Re()(Ye(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:Je(()=>sm),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),q_=U_.layerPostHog,J_=(e,...[t])=>c.runPromise(c.gen(function*(){let n=yield*U_;yield*n.capture.call(n,e,...t===void 0?[]:[t])}).pipe(c.catchCause(()=>c.void),c.provide(q_))),Y_=()=>J_(`session:started`,{mode:`interactive`,skip_planning:!1,browser_headed:K_.getState().browserHeaded}),X_=e=>c.runPromise(c.gen(function*(){let t=yield*U_;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush}).pipe(c.provide(q_))),Z_=()=>{let e=ne(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=Ot(),n,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=V(E,{color:`red`,children:U.cross}),r=V(E,{color:`green`,children:U.tick}),e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]===t.PRIMARY?i=e[4]:(i=V(E,{bold:!0,color:t.PRIMARY,children:` Expect`}),e[3]=t.PRIMARY,e[4]=i);let a;e[5]===t.DIM?a=e[6]:(a=V(E,{color:t.DIM,children:` v${dt}`}),e[5]=t.DIM,e[6]=a);let o;return e[7]!==t.BORDER||e[8]!==i||e[9]!==a?(o=V(w,{children:H(E,{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},Q_=[{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.`}],$_=e=>{let t=ne(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=Ot(),o=Gm(ev),[s,c]=L(0),l;t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==o?(l=e=>{let t=e.id===`enable-sync`;J_(`cookies:sync_choice`,{choice:t?`use_cookies`:`skip_cookies`}),o(Wm({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(tv),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&c(nv),e===`c`&&u(Q_[0]),e===`a`&&u(Q_[1]),t.return&&u(Q_[s])},t[6]=u,t[7]=s,t[8]=d):d=t[8],ee(d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=V(Z_,{}),t[9]=f):f=t[9];let p;t[10]===a.DIM?p=t[11]:(p=V(E,{color:a.DIM,children:U.pointerSmall}),t[10]=a.DIM,t[11]=p);let m;t[12]!==a.TEXT||t[13]!==r?(m=V(E,{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=H(w,{children:[f,H(E,{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=V(w,{marginTop:1,children:s===0?H(E,{color:a.GREEN,children:[U.tick,` Your signed-in session will be synced to the browser. Cookies stay on device.`]}):H(E,{color:a.YELLOW,children:[U.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?(_=Q_.map((e,t)=>{let n=t===s;return V(jt,{onClick:()=>{c(t),u(e)},children:H(w,{flexDirection:`column`,marginBottom:1,children:[H(E,{children:[V(E,{color:n?a.PRIMARY:a.DIM,children:n?`${U.pointer} `:` `}),V(E,{color:n?a.PRIMARY:a.TEXT,bold:n,children:e.label})]}),H(E,{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=V(w,{flexDirection:`column`,marginTop:1,children:_}),t[28]=_,t[29]=v);let y;return t[30]!==h||t[31]!==g||t[32]!==v?(y=H(w,{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 ev(e){return e.setScreen}function tv(e){return Math.min(Q_.length-1,e+1)}function nv(e){return Math.max(0,e-1)}const rv=Re()(Ye(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:Je(()=>um)})),iv=`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(`,`),av=[[/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`]],ov=e=>{let t=e.toLowerCase();return iv.some(e=>t.startsWith(e))},sv=e=>{if(!/^\d+$/.test(e))return``;try{let t=Ce(`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``}},cv=(e,t)=>{if(!/^\d+$/.test(e)||ov(t))return;let n=sv(e);try{let t=
|
|
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},uv=()=>{try{let e=lv(Ce(`lsof -iTCP -sTCP:LISTEN -nP`,{encoding:`utf-8`,timeout:3e3})),t=[];for(let n of e){let e=cv(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[]}},dv=()=>M({queryKey:[`listening-ports`],queryFn:()=>uv(),refetchInterval:5e3}),fv=e=>`http://localhost:${e}`,pv=(e,t)=>{let n=t.toLowerCase();return String(e.port).includes(n)||e.processName.toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n)},mv=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}},hv=e=>{let t=ne(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=Ot(),s=Gm(gv),c=rv(_v),l=rv(vv),{data:u}=dv(),d=u===void 0?[]:u,[f,p]=L(!1),[m,h]=L(``),[g,_]=L(!1),[v,y]=L(``),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,S]=L(b),C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=new Set,t[3]=C):C=t[3];let[T,D]=L(C),O=d.map(yv),k=m?O.filter(e=>pv(e,m)):O,A=k.length,j=k.length+1,te=k.length+2,M;t[4]===te?M=t[5]:(M={itemCount:te,visibleCount:10},t[4]=te,t[5]=M);let{highlightedIndex:N,setHighlightedIndex:P,scrollOffset:re,handleNavigation:ie}=Bm(M),F;t[6]!==n||t[7]!==T||t[8]!==r||t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==s?(F=e=>{let t=[...e,...T];l(t.length>0?t[0]:void 0),t.length===0?J_(`port:skipped`):J_(`port:selected`,{port_count:t.length,has_custom_url:T.size>0}),s(Um.Testing({changesFor:n,instruction:r,savedFlow:i,requiresCookies:a,baseUrls:t.length>0?t:void 0}))},t[6]=n,t[7]=T,t[8]=r,t[9]=a,t[10]=i,t[11]=l,t[12]=s,t[13]=F):F=t[13];let I=F,ae;t[14]===S?ae=t[15]:(ae=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[14]=S,t[15]=ae);let R=ae,oe;t[16]!==A||t[17]!==T||t[18]!==k||t[19]!==N||t[20]!==I||t[21]!==x||t[22]!==_||t[23]!==j?(oe=()=>{if(N===j){I([]);return}if(x.size>0||T.size>0){I([...x].sort(bv).map(fv));return}if(N===A){_(!0);return}let e=k[N];e&&I([fv(e.port)])},t[16]=A,t[17]=T,t[18]=k,t[19]=N,t[20]=I,t[21]=x,t[22]=_,t[23]=j,t[24]=oe):oe=t[24];let z=oe,B=xv,se;t[25]!==y||t[26]!==D||t[27]!==_?(se=e=>{let t=e.trim();if(!t){_(!1);return}let n=B(t);D(e=>new Set([...e,n])),y(``),_(!1)},t[25]=y,t[26]=D,t[27]=_,t[28]=se):se=t[28];let W=se,G;t[29]===D?G=t[30]:(G=e=>{D(t=>{let n=new Set(t);return n.delete(e),n})},t[29]=D,t[30]=G);let K=G,ce;t[31]!==P||t[32]!==h?(ce=e=>{h(e),P(0)},t[31]=P,t[32]=h,t[33]=ce):ce=t[33];let le=ce,ue;t[34]!==p||t[35]!==h||t[36]!==R?(ue=e=>{let t=mv(e);if(t){R(t),p(!1),h(``);return}p(!1)},t[34]=p,t[35]=h,t[36]=R,t[37]=ue):ue=t[37];let de=ue,fe;t[38]!==z||t[39]!==A||t[40]!==k||t[41]!==ie||t[42]!==N||t[43]!==g||t[44]!==f||t[45]!==y||t[46]!==_||t[47]!==p||t[48]!==R?(fe=(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(N===A){_(!0);return}let e=k[N];e&&R(e.port);return}t.return&&z()}},t[38]=z,t[39]=A,t[40]=k,t[41]=ie,t[42]=N,t[43]=g,t[44]=f,t[45]=y,t[46]=_,t[47]=p,t[48]=R,t[49]=fe):fe=t[49],ee(fe);let pe,q,me,he,ge,J,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee;if(t[50]!==o.DIM||t[51]!==o.GREEN||t[52]!==o.PRIMARY||t[53]!==o.TEXT||t[54]!==o.YELLOW||t[55]!==A||t[56]!==T||t[57]!==k||t[58]!==N||t[59]!==r||t[60]!==re||t[61]!==x||t[62]!==P||t[63]!==j||t[64]!==R){let e=k.slice(re,re+8);me=re+8>=k.length,J=me;let n=k[N];he=N===A,ge=N===j;let i;t[81]!==T||t[82]!==x?(i=[...[...x].sort(Sv).map(fv),...T],t[81]=T,t[82]=x,t[83]=i):i=t[83];let a=i;q=w,be=`column`,xe=`100%`,Se=1,Ce=1;let s;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(s=V(Z_,{}),t[84]=s):s=t[84];let c;t[85]===o.DIM?c=t[86]:(c=V(E,{color:o.DIM,children:U.pointerSmall}),t[85]=o.DIM,t[86]=c);let l;t[87]!==o.TEXT||t[88]!==r?(l=V(E,{color:o.TEXT,children:r}),t[87]=o.TEXT,t[88]=r,t[89]=l):l=t[89],t[90]!==c||t[91]!==l?(we=H(w,{children:[s,H(E,{wrap:`truncate`,children:[` `,c,` `,l]})]}),t[90]=c,t[91]=l,t[92]=we):we=t[92],t[93]===o.DIM?Te=t[94]:(Te=V(w,{marginTop:1,children:V(E,{color:o.DIM,children:`Pick the dev server the agent should open in the browser.`})}),t[93]=o.DIM,t[94]=Te);let u;t[95]!==o.GREEN||t[96]!==a?(u=a.length>0&&H(E,{color:o.GREEN,children:[U.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]!==he||t[102]!==ge?(d=a.length===0&&!ge&&!he&&n&&H(E,{color:o.DIM,children:[U.arrowRight,` `,fv(n.port)]}),t[98]=o.DIM,t[99]=a.length,t[100]=n,t[101]=he,t[102]=ge,t[103]=d):d=t[103];let f;t[104]!==o.YELLOW||t[105]!==a.length||t[106]!==ge?(f=a.length===0&&ge&&H(E,{color:o.YELLOW,children:[U.warning,` No base URL. The agent won`,`'`,`t know where your dev server is.`]}),t[104]=o.YELLOW,t[105]=a.length,t[106]=ge,t[107]=f):f=t[107],t[108]!==u||t[109]!==d||t[110]!==f?(Ee=H(w,{marginTop:1,children:[u,d,f]}),t[108]=u,t[109]=d,t[110]=f,t[111]=Ee):Ee=t[111],pe=w,_e=`column`,ve=1;let p;t[112]!==o.DIM||t[113]!==o.PRIMARY||t[114]!==o.TEXT||t[115]!==N||t[116]!==re||t[117]!==x||t[118]!==P||t[119]!==R?(p=(e,t)=>{let n=t+re,r=n===N,i=x.has(e.port);return V(jt,{onClick:()=>{P(n),R(e.port)},children:H(w,{children:[V(E,{color:r?o.PRIMARY:o.DIM,children:r?`${U.pointer} `:` `}),H(E,{color:i?o.PRIMARY:o.DIM,children:[i?U.checkboxOn:U.checkboxOff,` `]}),H(E,{color:r?o.PRIMARY:o.TEXT,bold:r,children:[`:`,e.port]}),e.processName&&H(E,{color:o.DIM,children:[` `,e.processName]}),e.cwd&&H(E,{color:o.DIM,children:[` `,e.cwd]})]})},e.port)},t[112]=o.DIM,t[113]=o.PRIMARY,t[114]=o.TEXT,t[115]=N,t[116]=re,t[117]=x,t[118]=P,t[119]=R,t[120]=p):p=t[120],ye=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]=A,t[56]=T,t[57]=k,t[58]=N,t[59]=r,t[60]=re,t[61]=x,t[62]=P,t[63]=j,t[64]=R,t[65]=pe,t[66]=q,t[67]=me,t[68]=he,t[69]=ge,t[70]=J,t[71]=_e,t[72]=ve,t[73]=ye,t[74]=be,t[75]=xe,t[76]=Se,t[77]=Ce,t[78]=we,t[79]=Te,t[80]=Ee}else pe=t[65],q=t[66],me=t[67],he=t[68],ge=t[69],J=t[70],_e=t[71],ve=t[72],ye=t[73],be=t[74],xe=t[75],Se=t[76],Ce=t[77],we=t[78],Te=t[79],Ee=t[80];let De;t[121]!==o.DIM||t[122]!==o.PRIMARY||t[123]!==o.TEXT||t[124]!==A||t[125]!==v||t[126]!==me||t[127]!==W||t[128]!==he||t[129]!==g||t[130]!==y||t[131]!==P||t[132]!==_?(De=me&&V(jt,{onClick:()=>{P(A),_(!0)},children:H(w,{children:[V(E,{color:he?o.PRIMARY:o.DIM,children:he?`${U.pointer} `:` `}),g&&H(w,{children:[V(E,{color:o.PRIMARY,children:`URL: `}),V(Lt,{focus:!0,value:v,placeholder:`http://localhost:4000 or staging.example.com`,onChange:y,onSubmit:W})]}),!g&&H(E,{color:he?o.PRIMARY:o.TEXT,bold:he,children:[`Enter a custom URL`,U.ellipsis]})]})}),t[121]=o.DIM,t[122]=o.PRIMARY,t[123]=o.TEXT,t[124]=A,t[125]=v,t[126]=me,t[127]=W,t[128]=he,t[129]=g,t[130]=y,t[131]=P,t[132]=_,t[133]=De):De=t[133];let Oe;t[134]!==o.DIM||t[135]!==o.PRIMARY||t[136]!==o.TEXT||t[137]!==me||t[138]!==T||t[139]!==K?(Oe=me&&[...T].map(e=>V(jt,{onClick:()=>K(e),children:H(w,{children:[V(E,{children:` `}),H(E,{color:o.PRIMARY,children:[U.checkboxOn,` `]}),V(E,{color:o.TEXT,children:e}),V(E,{color:o.DIM,children:` (click to remove)`})]})},e)),t[134]=o.DIM,t[135]=o.PRIMARY,t[136]=o.TEXT,t[137]=me,t[138]=T,t[139]=K,t[140]=Oe):Oe=t[140];let ke;t[141]!==o.DIM||t[142]!==o.PRIMARY||t[143]!==ge||t[144]!==I||t[145]!==P||t[146]!==j||t[147]!==J?(ke=J&&V(jt,{onClick:()=>{P(j),I([])},children:H(w,{children:[V(E,{color:ge?o.PRIMARY:o.DIM,children:ge?`${U.pointer} `:` `}),H(E,{color:ge?o.PRIMARY:o.DIM,bold:ge,children:[`Skip `,U.arrowRight,` no base URL`]})]})}),t[141]=o.DIM,t[142]=o.PRIMARY,t[143]=ge,t[144]=I,t[145]=P,t[146]=j,t[147]=J,t[148]=ke):ke=t[148];let Ae;t[149]!==o.DIM||t[150]!==k.length||t[151]!==J?(Ae=k.length===0&&!J&&V(E,{color:o.DIM,children:`No matching ports`}),t[149]=o.DIM,t[150]=k.length,t[151]=J,t[152]=Ae):Ae=t[152];let je;t[153]!==pe||t[154]!==_e||t[155]!==ve||t[156]!==ye||t[157]!==De||t[158]!==Oe||t[159]!==ke||t[160]!==Ae?(je=H(pe,{flexDirection:_e,marginTop:ve,children:[ye,De,Oe,ke,Ae]}),t[153]=pe,t[154]=_e,t[155]=ve,t[156]=ye,t[157]=De,t[158]=Oe,t[159]=ke,t[160]=Ae,t[161]=je):je=t[161];let Me;t[162]!==le||t[163]!==de||t[164]!==f||t[165]!==m?(Me=V(Rt,{isSearching:f,query:m,onChange:le,onSubmit:de}),t[162]=le,t[163]=de,t[164]=f,t[165]=m,t[166]=Me):Me=t[166];let Ne;return t[167]!==q||t[168]!==be||t[169]!==xe||t[170]!==Se||t[171]!==Ce||t[172]!==we||t[173]!==Te||t[174]!==Ee||t[175]!==je||t[176]!==Me?(Ne=H(q,{flexDirection:be,width:xe,paddingY:Se,paddingX:Ce,children:[we,Te,Ee,je,Me]}),t[167]=q,t[168]=be,t[169]=xe,t[170]=Se,t[171]=Ce,t[172]=we,t[173]=Te,t[174]=Ee,t[175]=je,t[176]=Me,t[177]=Ne):Ne=t[177],Ne};function gv(e){return e.setScreen}function _v(e){return e.lastBaseUrl}function vv(e){return e.setLastBaseUrl}function yv(e){return{port:e.port,processName:e.processName,cwd:e.cwd}}function bv(e,t){return e-t}function xv(e){let t=e.trim(),n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?fv(n):/^https?:\/\//i.test(t)?t:`http://${t}`}function Sv(e,t){return e-t}const Cv=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},wv=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,Tv=(e,t,n)=>e+(t-e)*n,Ev=(e,t,n)=>{let[r,i,a]=Cv(e),[o,s,c]=Cv(t);return wv(Tv(r,o,n),Tv(i,s,n),Tv(a,c,n))},Dv=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[i,a]=L(-16),o=I(r);o.current=r;let s=I(e.length);s.current=e.length;let c=I(!1);return c.current||(c.current=!0,setTimeout(()=>{setInterval(()=>{let e=s.current+16;a(t=>t>=e?-16:t+o.current)},50)},0)),V(E,{children:[...e].map((e,r)=>{let a=Math.abs(r-i),o=Math.max(0,1-a/16);return V(E,{color:o>0?Ev(t,n,o):t,children:e},r)})})},Ov=Re(e=>({executedPlan:void 0,expanded:!1,setExecutedPlan:t=>e({executedPlan:t}),setExpanded:t=>e({expanded:t}),toggleExpanded:()=>e(e=>({expanded:!e.expanded}))})),kv=e=>nt(Math.max(0,e),{secondsDecimalDigits:0}),Av=new Set([`warpterminal`]),jv=it.stdout,Mv=rt({preferOuter:!0}),Nv=process.stdout.isTTY&&!Av.has(Mv??``),Pv=Nv&&jv.kitty,Fv=Nv&&jv.iterm2,Iv=Pv||Fv,Lv=rt(),Rv=Lv===`tmux`||Lv===`screen`,zv=e=>Rv?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,Bv=(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}`),zv(`_G${r};${n}\\`)},Vv=(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`)}`,zv(n)},Hv=(e,t={})=>{if(!Ne.existsSync(e))return null;if(Pv)return Bv(e,t);if(Fv)try{return Vv(Ne.readFileSync(e),t)}catch{return null}return null},Uv=e=>e.startsWith(`file://`),Wv=e=>{let t=ne(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=Uv(n)?ue.fileURLToPath(n):G.resolve(n),a=Uv(n)?n:ue.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=V(E,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==o||t[7]!==c?(l=V(at,{url:o,children:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l},Gv=({src:e,alt:t,width:n,height:r})=>{let i=G.resolve(e),{write:a}=k(),o=I(!1);if(!o.current){let e=Hv(i,{width:n,height:r});e&&(a(e+`
|
|
38
|
-
`),o.current=!0)}return Iv?null:
|
|
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()},ey=
|
|
40
|
-
`).map(e=>e.trim()).filter(e=>e.length>0),r=n.find(e=>e.startsWith(ay))?.replace(ay,``),i=n.find(e=>e.startsWith(oy))?.replace(oy,``);return{localReplayUrl:r&&r.trim().length>0?
|
|
41
|
-
`)?o:void 0}},gy=e=>{let t=Object.values(e).filter(e=>typeof e==`string`&&e.length>0);return t.length===0?``:
|
|
42
|
-
`);i.push(H(E,{color:r.DIM,wrap:`truncate`,children:[t,U.lineVertical,` `,V(E,{color:r.TEXT,children:o.tool.name}),`(`,o.isRunning&&H(E,{children:[` `,V(Fe,{type:`line`})]}),o.resultTokens!==void 0&&` ${U.arrowDown} ${_y(o.resultTokens)} tokens`]},`${s}-h`));for(let n=0;n<e.length;n++)i.push(H(E,{color:r.DIM,children:[t,U.lineVertical,` `,` `,V(E,{color:r.TEXT,children:e[n]})]},`${s}-${n}`));i.push(H(E,{color:r.DIM,children:[t,U.lineVertical,` )`]},`${s}-c`))}else i.push(H(E,{color:r.DIM,wrap:`truncate`,children:[t,U.lineVertical,` `,V(E,{color:r.TEXT,children:o.tool.name}),`(`,o.tool.args,`)`,o.isRunning&&H(E,{children:[` `,V(Fe,{type:`line`})]}),o.resultTokens!==void 0&&` ${U.arrowDown} ${_y(o.resultTokens)} tokens`]},s))}return i},Dy=t=>{let n=ne(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=Gm(Oy),u=Ot(),[,d]=Et(),f=K_(ky),p=K_(Ay),m=K_(jy),g=K_(My),_;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(_={mode:`promiseExit`},n[1]=_):_=n[1];let[v,y]=$e(dy,_),b=tt(ly),[x,S]=L(void 0),C;n[2]===v?C=n[3]:(C=Xe.isWaiting(v),n[2]=v,n[3]=C);let D=C,O;n[4]===v?O=n[5]:(O=Xe.isSuccess(v),n[4]=v,n[5]=O);let k=O,A=k?v.value.report:void 0,[j,te]=L(void 0),[M,N]=L(void 0),[P,re]=L(0),[F,ae]=L(!1),R=Ov(Ny),oe=Ov(Py),z=Ov(Fy),B;n[6]===P?B=n[7]:(B=kv(P),n[6]=P,n[7]=B);let W=B,G=j?.steps?j.steps.length:0,K;if(n[8]!==u||n[9]!==W||n[10]!==j||n[11]!==R||n[12]!==D){if(K=[],R&&j){let e=j.steps??[];if(e.length===0&&D){let e=xy(j.events,!0);K.push(...Ey(e,` `,`planning`,u))}for(let t=0;t<e.length;t++){let n=e[t],r=h.isSome(n.summary)?n.summary.value:n.title,i=Ty(n),a=i===void 0?void 0:kv(i),o=`${t+1}.`;if(n.status===`active`){K.push(H(w,{children:[H(E,{color:u.DIM,children:[` `,o,` `]}),V(Rm,{}),V(E,{children:` `}),V(Dv,{text:`${n.title} ${W}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]},`step-${t}`));let e=by(j.events,!0);K.push(...Ey(e,` `,`s${t}`,u))}else if(n.status===`passed`){K.push(H(E,{children:[H(E,{color:u.DIM,children:[` `,o]}),H(E,{color:u.GREEN,children:[` `,U.tick,` `,Ie(r,100)]}),a&&H(E,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=Cy(j.events,t);K.push(...Ey(e,` `,`s${t}`,u))}else if(n.status===`failed`){K.push(H(E,{children:[H(E,{color:u.DIM,children:[` `,o]}),H(E,{color:u.RED,children:[` `,U.cross,` `,Ie(r,100)]}),a&&H(E,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=Cy(j.events,t);K.push(...Ey(e,` `,`s${t}`,u))}else K.push(H(E,{color:u.DIM,children:[` `,o,` `,U.circle,` `,n.title]},`step-${t}`))}}n[8]=u,n[9]=W,n[10]=j,n[11]=R,n[12]=D,n[13]=K}else K=n[13];let ce=Math.max(1,d-6),le;n[14]!==K.length||n[15]!==ce?(le={itemCount:K.length,visibleCount:ce},n[14]=K.length,n[15]=ce,n[16]=le):le=n[16];let ue=Bm(le),de=I(!1),fe,pe;n[17]!==R||n[18]!==K.length||n[19]!==ue?(fe=()=>{R&&!de.current&&K.length>0&&ue.setHighlightedIndex(K.length-1),de.current=R},pe=[R,K.length,ue],n[17]=R,n[18]=K.length,n[19]=ue,n[20]=fe,n[21]=pe):(fe=n[20],pe=n[21]),ie(fe,pe);let q,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]!==y?(me=()=>{N(Date.now());let e=s&&s.length>0?s.join(`, `):void 0,t=s?s.map(Iy).join(` `):void 0;return y({options:{changesFor:r,instruction:t?`${i} ${t}`:i,isHeadless:!p,requiresCookies:c,savedFlow:a,baseUrl:e},agentBackend:f,replayHost:m,onUpdate:te,onReplayUrl:S}),()=>{y(Ze.Interrupt)}},q=[y,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]=y,n[31]=q,n[32]=me):(q=n[31],me=n[32]),ie(me,q);let he=k?v.value.replayUrl:void 0,ge=k?v.value.localReplayUrl:void 0,J=k?v.value.videoUrl:void 0,_e,ve;n[33]!==j||n[34]!==k||n[35]!==ge||n[36]!==he||n[37]!==A||n[38]!==l||n[39]!==J?(_e=()=>{k&&j&&A&&(Ov.getState().setExecutedPlan(j),l(Um.Results({report:A,replayUrl:he,localReplayUrl:ge,videoUrl:J})))},ve=[k,j,A,he,ge,J,l],n[33]=j,n[34]=k,n[35]=ge,n[36]=he,n[37]=A,n[38]=l,n[39]=J,n[40]=_e,n[41]=ve):(_e=n[40],ve=n[41]),ie(_e,ve);let ye;n[42]===l?ye=n[43]:(ye=()=>{Ov.getState().setExecutedPlan(void 0),l(Um.Main())},n[42]=l,n[43]=ye);let be=ye,xe,Se;n[44]!==D||n[45]!==M?(xe=()=>{if(M===void 0||!D)return;let e=setInterval(()=>{re(Date.now()-M)},1e3);return()=>clearInterval(e)},Se=[M,D],n[44]=D,n[45]=M,n[46]=xe,n[47]=Se):(xe=n[46],Se=n[47]),ie(xe,Se);let Ce;n[48]!==j||n[49]!==v||n[50]!==R||n[51]!==ue||n[52]!==be||n[53]!==D||n[54]!==x||n[55]!==ge||n[56]!==he||n[57]!==A||n[58]!==oe||n[59]!==l||n[60]!==F||n[61]!==z||n[62]!==g||n[63]!==J?(Ce=(t,n)=>{let r=t.toLowerCase();if(F){if(n.return||r===`y`){ae(!1),J_(`run:cancelled`),be();return}(n.escape||r===`n`)&&ae(!1);return}if(r===`o`&&!n.ctrl&&!n.meta&&x){let{exec:t}=e(`node:child_process`);t(`open "${x.replace(/"/g,`\\"`)}"`),J_(`live_preview:opened`);return}if(n.ctrl&&t===`o`){z();return}if(n.ctrl&&t===`n`){g();return}if(R){if(ue.handleNavigation(t,n))return;if(n.escape){oe(!1);return}return}if(n.escape){if(Xe.isFailure(v)){be();return}if(D){ae(!0);return}if(j&&A){Ov.getState().setExecutedPlan(j),l(Um.Results({report:A,replayUrl:he,localReplayUrl:ge,videoUrl:J}));return}be()}},n[48]=j,n[49]=v,n[50]=R,n[51]=ue,n[52]=be,n[53]=D,n[54]=x,n[55]=ge,n[56]=he,n[57]=A,n[58]=oe,n[59]=l,n[60]=F,n[61]=z,n[62]=g,n[63]=J,n[64]=Ce):Ce=n[64],ee(Ce);let we;n[65]!==K||n[66]!==ue.scrollOffset||n[67]!==ce?(we=K.slice(ue.scrollOffset,ue.scrollOffset+ce),n[65]=K,n[66]=ue.scrollOffset,n[67]=ce,n[68]=we):we=n[68];let Te=we,Ee;n[69]===b?Ee=n[70]:(Ee=V(T,{items:[...b],children:Ly}),n[69]=b,n[70]=Ee);let De;n[71]===Symbol.for(`react.memo_cache_sentinel`)?(De=V(Z_,{}),n[71]=De):De=n[71];let Oe;n[72]===u.DIM?Oe=n[73]:(Oe=V(E,{color:u.DIM,children:U.pointerSmall}),n[72]=u.DIM,n[73]=Oe);let ke;n[74]!==u.TEXT||n[75]!==i?(ke=V(E,{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=H(w,{children:[De,H(E,{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]!==D||n[83]!==x?(je=x&&D&&V(w,{marginTop:0,children:H(E,{color:u.DIM,children:[` `,`Press `,V(E,{color:u.PRIMARY,children:`o`}),` to open live preview`]})}),n[80]=u.DIM,n[81]=u.PRIMARY,n[82]=D,n[83]=x,n[84]=je):je=n[84];let Me;n[85]!==u.DIM||n[86]!==u.GREEN||n[87]!==u.RED||n[88]!==W||n[89]!==j||n[90]!==R||n[91]!==D||n[92]!==G||n[93]!==Te?(Me=R?V(w,{flexDirection:`column`,marginTop:1,children:Te}):H(se,{children:[G===0&&D&&(()=>{let e=j?xy(j.events,!1):[];return H(w,{marginTop:1,flexDirection:`column`,children:[H(w,{children:[V(Rm,{}),V(E,{children:` `}),V(Dv,{text:`Starting${U.ellipsis} ${W}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),e.map(Ry)]})})(),V(w,{flexDirection:`column`,marginTop:1,children:(j?.steps??[]).map((e,t)=>{let n=h.isSome(e.summary)?e.summary.value:e.title,r=Ty(e),i=r===void 0?void 0:kv(r),a=`${t+1}.`;if(e.status===`active`){let t=j?by(j.events,!1):[];return H(w,{flexDirection:`column`,children:[H(w,{children:[H(E,{color:u.DIM,children:[` `,a,` `]}),V(Rm,{}),V(E,{children:` `}),V(Dv,{text:`${e.title} ${W}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),t.map(zy)]},e.id)}return e.status===`passed`?H(E,{children:[H(E,{color:u.DIM,children:[` `,a]}),H(E,{color:u.GREEN,children:[` `,U.tick,` `,Ie(n,100)]}),i&&H(E,{color:u.DIM,children:[` `,i]})]},e.id):e.status===`failed`?H(E,{children:[H(E,{color:u.DIM,children:[` `,a]}),H(E,{color:u.RED,children:[` `,U.cross,` `,Ie(n,100)]}),i&&H(E,{color:u.DIM,children:[` `,i]})]},e.id):H(E,{color:u.DIM,children:[` `,a,` `,U.circle,` `,e.title]},e.id)})})]}),n[85]=u.DIM,n[86]=u.GREEN,n[87]=u.RED,n[88]=W,n[89]=j,n[90]=R,n[91]=D,n[92]=G,n[93]=Te,n[94]=Me):Me=n[94];let Ne;n[95]!==u.PRIMARY||n[96]!==u.YELLOW||n[97]!==F?(Ne=F&&V(w,{marginTop:1,children:H(E,{color:u.YELLOW,children:[`Stop run? `,V(E,{color:u.PRIMARY,children:`enter`}),` to stop,`,` `,V(E,{color:u.PRIMARY,children:`esc`}),` to dismiss`]})}),n[95]=u.PRIMARY,n[96]=u.YELLOW,n[97]=F,n[98]=Ne):Ne=n[98];let Pe;n[99]!==Ae||n[100]!==je||n[101]!==Me||n[102]!==Ne?(Pe=H(w,{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]===v?Fe=n[105]:(Fe=Xe.builder(v).onError(By).onDefect(Vy).orNull(),n[104]=v,n[105]=Fe);let Le;n[106]!==Pe||n[107]!==Fe?(Le=H(w,{flexDirection:`column`,width:`100%`,children:[Pe,Fe]}),n[106]=Pe,n[107]=Fe,n[108]=Le):Le=n[108];let Re;return n[109]!==Ee||n[110]!==Le?(Re=H(se,{children:[Ee,Le]}),n[109]=Ee,n[110]=Le,n[111]=Re):Re=n[111],Re};function Oy(e){return e.setScreen}function ky(e){return e.agentBackend}function Ay(e){return e.browserHeaded}function jy(e){return e.replayHost}function My(e){return e.toggleNotifications}function Ny(e){return e.expanded}function Py(e){return e.setExpanded}function Fy(e){return e.toggleExpanded}function Iy(e){return`[url: ${e}]`}function Ly(e){return V(w,{paddingX:1,children:V(Gv,{src:e,alt:e})},e)}function Ry(e,t){return V(wy,{display:e,indent:` `},t)}function zy(e,t){return V(wy,{display:e,indent:` `},t)}function By(e){return V(Kv,{type:`error`,error:e})}function Vy(e){return V(Kv,{type:`defect`,error:{_tag:`Defect`,message:o.pretty(o.fail(e))}})}const Hy=e=>{try{return ae.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},Uy=(e,t)=>c.runPromise(im.use(n=>n.addComment(process.cwd(),e,t)).pipe(c.provide(im.layer))),Wy=()=>te({mutationFn:({pullRequest:e,body:t})=>Uy(e,t)}),Gy=Xv.fn(c.fnUntraced(function*(e,t){return yield*(yield*tm).save(e.plan)},c.annotateLogs({fn:`saveFlowFn`}),c.provide(J.layer))),Ky=e=>{if(!(h.isNone(e.startedAt)||h.isNone(e.endedAt)))return s.toEpochMillis(e.endedAt.value)-s.toEpochMillis(e.startedAt.value)},qy=e=>{let t=0;for(let n of e){let e=Ky(n);e!==void 0&&(t+=e)}return t},Jy=e=>{let t=ne(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=Ot(),s=Gm(Yy),[c,l]=L(void 0),u=Wy(),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d={mode:`promiseExit`},t[1]=d):d=t[1];let[f,p]=$e(Gy,d),m=f.waiting,g;t[2]===f?g=t[3]:(g=Xe.isSuccess(f),t[2]=f,t[3]=g);let _=g,v;t[4]!==u||t[5]!==n.pullRequest||t[6]!==n.toPlainText?(v=()=>{h.isSome(n.pullRequest)&&(J_(`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]=v):v=t[7];let y=v,b;t[8]!==o.GREEN||t[9]!==o.RED||t[10]!==n.toPlainText?(b=()=>{Hy(n.toPlainText)?(J_(`results:copied_to_clipboard`),l({text:`${U.tick} Copied to clipboard`,color:o.GREEN})):l({text:`${U.cross} Failed to copy to clipboard`,color:o.RED})},t[8]=o.GREEN,t[9]=o.RED,t[10]=n.toPlainText,t[11]=b):b=t[11];let x=b,S;t[12]!==n||t[13]!==m||t[14]!==_||t[15]!==p?(S=async()=>{m||_||(J_(`flow:saved`,{step_count:n.steps.length}),await p({plan:n}))},t[12]=n,t[13]=m,t[14]=_,t[15]=p,t[16]=S):S=t[16];let C=S,T;t[17]!==n.changesFor||t[18]!==n.instruction||t[19]!==s?(T=()=>{J_(`results:restarted`),Ov.getState().setExecutedPlan(void 0),s(Wm({changesFor:n.changesFor,instruction:n.instruction}))},t[17]=n.changesFor,t[18]=n.instruction,t[19]=s,t[20]=T):T=t[20];let D=T,O;t[21]!==x||t[22]!==y||t[23]!==D||t[24]!==C?(O=e=>{let t=e.toLowerCase();t===`y`&&x(),t===`p`&&y(),t===`s`&&C(),t===`r`&&D()},t[21]=x,t[22]=y,t[23]=D,t[24]=C,t[25]=O):O=t[25],ee(O);let k=n.status===`passed`,A=k?o.GREEN:o.RED,j=k?U.tick:U.cross,te=k?`Passed`:`Failed`,M,N,P,re,ie,F,I,ae,R,oe,z;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]!==A||t[36]!==j||t[37]!==te){let e=qy(n.steps);N=r??i,P=!!r&&!!i&&r!==i&&i!==void 0,M=w,oe=`column`,z=`100%`,re=1,ie=1;let a;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(a=V(Z_,{}),t[49]=a):a=t[49];let s;t[50]===o.DIM?s=t[51]:(s=V(E,{color:o.DIM,children:U.pointerSmall}),t[50]=o.DIM,t[51]=s);let c;t[52]!==o.TEXT||t[53]!==n.instruction?(c=V(E,{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?(F=H(w,{children:[a,H(E,{wrap:`truncate`,children:[` `,s,` `,c]})]}),t[55]=s,t[56]=c,t[57]=F):F=t[57];let l;t[58]!==A||t[59]!==j||t[60]!==te?(l=H(E,{color:A,bold:!0,children:[j,` `,te]}),t[58]=A,t[59]=j,t[60]=te,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=H(E,{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?(I=H(w,{marginTop:1,children:[l,d]}),t[66]=l,t[67]=d,t[68]=I):I=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=Ky(e),i=r===void 0?void 0:kv(r),a=n.stepStatuses.get(e.id),s=a?.status===`failed`,c=s?o.RED:o.GREEN,l=s?U.cross:U.tick,u=`${t+1}.`;return H(w,{flexDirection:`column`,children:[H(E,{children:[H(E,{color:o.DIM,children:[` `,u]}),H(E,{color:c,children:[` `,l,` `,e.title]}),i&&H(E,{color:o.DIM,children:[` `,i]})]}),s&&a.summary&&H(E,{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=V(w,{flexDirection:`column`,marginTop:1,children:f}),t[80]=f,t[81]=ae),R=e>0&&V(w,{marginTop:1,children:H(E,{color:o.DIM,children:[`Worked for `,kv(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]=A,t[36]=j,t[37]=te,t[38]=M,t[39]=N,t[40]=P,t[41]=re,t[42]=ie,t[43]=F,t[44]=I,t[45]=ae,t[46]=R,t[47]=oe,t[48]=z}else M=t[38],N=t[39],P=t[40],re=t[41],ie=t[42],F=t[43],I=t[44],ae=t[45],R=t[46],oe=t[47],z=t[48];let B;t[82]===c?B=t[83]:(B=c&&V(w,{marginTop:1,children:V(E,{color:c.color,children:c.text})}),t[82]=c,t[83]=B);let se;t[84]!==o.DIM||t[85]!==u.isPending?(se=u.isPending&&V(w,{marginTop:1,children:H(E,{color:o.DIM,children:[`Posting to PR`,U.ellipsis]})}),t[84]=o.DIM,t[85]=u.isPending,t[86]=se):se=t[86];let W;t[87]!==o.GREEN||t[88]!==u.isSuccess?(W=u.isSuccess&&V(w,{marginTop:1,children:H(E,{color:o.GREEN,children:[U.tick,` Posted to PR`]})}),t[87]=o.GREEN,t[88]=u.isSuccess,t[89]=W):W=t[89];let G;t[90]!==o.RED||t[91]!==u.isError?(G=u.isError&&V(w,{marginTop:1,children:H(E,{color:o.RED,children:[U.cross,` Failed to post to PR`]})}),t[90]=o.RED,t[91]=u.isError,t[92]=G):G=t[92];let K;t[93]!==o.DIM||t[94]!==m?(K=m&&V(w,{marginTop:1,children:H(E,{color:o.DIM,children:[`Saving flow`,U.ellipsis]})}),t[93]=o.DIM,t[94]=m,t[95]=K):K=t[95];let ce;t[96]!==o.GREEN||t[97]!==_?(ce=_&&V(w,{marginTop:1,children:H(E,{color:o.GREEN,children:[U.tick,` Flow saved`]})}),t[96]=o.GREEN,t[97]=_,t[98]=ce):ce=t[98];let le;t[99]!==o.RED||t[100]!==f?(le=Xe.isFailure(f)&&V(w,{marginTop:1,children:H(E,{color:o.RED,children:[U.cross,` Failed to save flow`]})}),t[99]=o.RED,t[100]=f,t[101]=le):le=t[101];let ue;t[102]!==o.DIM||t[103]!==o.PRIMARY||t[104]!==N?(ue=N&&V(w,{flexDirection:`column`,paddingX:1,marginTop:1,children:H(E,{color:o.DIM,children:[`Replay:`,` `,V(E,{color:o.PRIMARY,bold:!0,children:N})]})}),t[102]=o.DIM,t[103]=o.PRIMARY,t[104]=N,t[105]=ue):ue=t[105];let de;t[106]!==o.DIM||t[107]!==o.PRIMARY||t[108]!==i||t[109]!==P?(de=P&&V(w,{flexDirection:`column`,paddingX:1,children:H(E,{color:o.DIM,children:[`Local Replay:`,` `,V(E,{color:o.PRIMARY,bold:!0,children:i})]})}),t[106]=o.DIM,t[107]=o.PRIMARY,t[108]=i,t[109]=P,t[110]=de):de=t[110];let fe;t[111]!==o.DIM||t[112]!==o.PRIMARY||t[113]!==a?(fe=a&&V(w,{flexDirection:`column`,paddingX:1,children:H(E,{color:o.DIM,children:[`Video:`,` `,V(E,{color:o.PRIMARY,bold:!0,children:a})]})}),t[111]=o.DIM,t[112]=o.PRIMARY,t[113]=a,t[114]=fe):fe=t[114];let pe;t[115]===n.screenshotPaths?pe=t[116]:(pe=n.screenshotPaths.map(Xy),t[115]=n.screenshotPaths,t[116]=pe);let q;return t[117]!==M||t[118]!==re||t[119]!==ie||t[120]!==F||t[121]!==I||t[122]!==ae||t[123]!==R||t[124]!==B||t[125]!==se||t[126]!==W||t[127]!==G||t[128]!==K||t[129]!==ce||t[130]!==le||t[131]!==ue||t[132]!==de||t[133]!==fe||t[134]!==pe||t[135]!==oe||t[136]!==z?(q=H(M,{flexDirection:oe,width:z,paddingY:re,paddingX:ie,children:[F,I,ae,R,B,se,W,G,K,ce,le,ue,de,fe,pe]}),t[117]=M,t[118]=re,t[119]=ie,t[120]=F,t[121]=I,t[122]=ae,t[123]=R,t[124]=B,t[125]=se,t[126]=W,t[127]=G,t[128]=K,t[129]=ce,t[130]=le,t[131]=ue,t[132]=de,t[133]=fe,t[134]=pe,t[135]=oe,t[136]=z,t[137]=q):q=t[137],q};function Yy(e){return e.setScreen}function Xy(e){return V(w,{marginTop:1,children:V(Gv,{src:e,alt:`Screenshot: ${e}`})},e)}const Zy=f.mergeAll(tm.layer,Vp.withRepoRoot(process.cwd())),Qy=()=>M({queryKey:[`saved-flows`],queryFn:()=>c.gen(function*(){return yield*(yield*tm).list()}).pipe(c.provide(Zy),c.provide(J.layer),c.catchTag(`FindRepoRootError`,()=>c.succeed([])),c.runPromise)}),$y=new sn({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}),eb=()=>M({queryKey:[`git-state`],queryFn:async()=>{let e=await c.runPromiseExit(c.gen(function*(){return yield*(yield*Vp).getState()}).pipe(c.provide(Vp.withRepoRoot(process.cwd())),c.catchTag(`FindRepoRootError`,()=>c.succeed($y)),c.timeoutOrElse({duration:1e4,onTimeout:()=>c.succeed($y)}),c.provide(J.layer)));return l.isSuccess(e)?e.value:$y}}),tb=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],nb=(e,t)=>{let n=un.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=tb(e),i={title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r},a=e.environment.cookies;J_(`flow:reused`,{slug:e.slug,step_count:r.length}),Gm.getState().setScreen(Wm({changesFor:n,instruction:e.flow.userInstruction,savedFlow:i,requiresCookies:a}))},rb=()=>{let e=ne(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=Ot(),[n]=Et(),r=Gm(ib),{data:i}=eb(),{data:a,isLoading:o}=Qy(),s=a===void 0?[]:a,{highlightedIndex:c,setHighlightedIndex:l,scrollOffset:u,handleNavigation:d}=Bm({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);ee((e,t)=>{if(!d(e,t)){if(t.return){let e=s[c];e&&nb(e,i?.mainBranch??`main`)}t.escape&&r(Um.Main())}});let h=w,g=`${s.length} flow${s.length===1?``:`s`}`,_;e[1]===g?_=e[2]:(_=V(w,{paddingX:1,children:V(qm,{title:`Saved flows`,subtitle:g})}),e[1]=g,e[2]=_);let v;e[3]===o?v=e[4]:(v=o&&V(w,{marginTop:1,paddingX:1,children:V(Rm,{message:`Loading saved flows...`})}),e[3]=o,e[4]=v);let y=!o&&s.length===0&&V(w,{marginTop:1,paddingX:1,flexDirection:`column`,children:H(E,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,V(E,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),b=!o&&s.length>0&&V(w,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:m.map((e,n)=>{let r=n+u,a=r===c,o=tb(e).length;return H(jt,{onClick:()=>{l(r),nb(e,i?.mainBranch??`main`)},children:[V(E,{color:a?t.PRIMARY:t.DIM,children:a?`${U.pointer} `:` `}),V(E,{color:a?t.PRIMARY:t.TEXT,bold:a,children:zm(Ie(e.title,f-1),f)}),V(E,{color:t.DIM,children:zm(`${o} step${o===1?``:`s`}`,10)}),V(E,{color:t.DIM,children:Ie(e.description,p)})]},e.slug)})}),x;return e[5]!==h||e[6]!==_||e[7]!==v||e[8]!==y||e[9]!==b?(x=H(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 ib(e){return e.setScreen}const ab=e=>{let t=ne(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=Ot();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=H(E,{color:r.GREEN,children:[U.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=H(E,{color:r.PURPLE,children:[U.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=H(E,{color:r.DIM,children:[U.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},ob=e=>{let t=ne(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=Ot(),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=V(w,{flexDirection:`column`,children:V(E,{color:o.DIM,children:`No matching results`})}),t[11]=o.DIM,t[12]=e),f=e;break bb1}l=w,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=Nm(e,a),s=Pm(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 H(E,{wrap:`truncate`,children:[V(E,{color:n?o.PRIMARY:o.DIM,children:n?`${U.pointer} `:` `}),e._tag===`WorkingTree`?H(E,{color:o.GREEN,children:[U.bullet,` `]}):null,u?V(ab,{status:u}):null,V(E,{color:n?o.PRIMARY:o.TEXT,bold:n,children:i}),l?H(E,{children:[` `,H(E,{color:u===`open`?o.GREEN:u===`merged`?o.PURPLE:o.DIM,children:[`#`,l]}),u?H(E,{color:o.DIM,children:[` `,u]}):null]}):null,s&&!l?H(E,{color:o.DIM,children:[` `,s]}):null]},Bn(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?V(w,{children:H(E,{color:o.DIM,children:[` Loading PRs and branches`,U.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?V(w,{children:H(E,{color:o.DIM,children:[` `,n.length-8,` more `,U.arrowUp,`/`,U.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=H(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},sb=({gitState:e,onSelect:t})=>{let[n,r]=L(!1),[i,a]=L(``),[o,s]=L(0),{data:c=[]}=M({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>Am(e),enabled:!!e}),{data:l=[],isLoading:u}=M({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>Mm(e),enabled:n&&!!e}),d=F(()=>[...c,...l],[c,l]),f=F(()=>Im(d,i,e),[d,i,e]);ie(()=>{s(0)},[i]);let p=P(()=>{r(!0),a(``),s(0)},[]),m=P(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:f,localOptions:c,remoteLoading:u,openPicker:p,closePicker:m,handleContextSelect:P(e=>{t(e),m()},[t,m]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=Ct(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)}}},cb=e=>{let t=new Set;return e.filter(e=>t.has(e.path)?!1:(t.add(e.path),!0))},lb=e=>M({queryKey:[`test-coverage`,e?.fingerprint],queryFn:async()=>{if(!e?.isGitRepo||!e.hasChangesFromMain&&!e.hasUnstagedChanges)return;let t=e.mainBranch??`main`,n=await c.runPromiseExit(c.gen(function*(){let e=yield*Vp,n=yield*Om,r=yield*e.getChangedFiles(un.makeUnsafe({_tag:`WorkingTree`})),i=yield*e.getChangedFiles(un.makeUnsafe({_tag:`Changes`,mainBranch:t})),a=cb([...r,...i]);if(a.length!==0)return yield*n.analyze(a)}).pipe(c.provide(Vp.withRepoRoot(process.cwd())),c.provide(Om.layer),c.timeoutOrElse({duration:15e3,onTimeout:()=>c.succeed(void 0)}),c.provide(J.layer)));if(l.isSuccess(n))return n.value},enabled:!!(e?.isGitRepo&&(e.hasChangesFromMain||e.hasUnstagedChanges)),staleTime:3e4}),ub=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],db=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],fb=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],pb=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],mb=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],hb=(e,t)=>{if(!e)return ub;switch(e._tag){case`WorkingTree`:return db;case`Branch`:return fb;case`PullRequest`:return pb;case`Commit`:return mb;default:return ub}},gb=e=>e>=70?`green`:e>=40?`yellow`:`#e06c50`,_b=e=>e>=70?`#0a2b0a`:e>=40?`#332b00`:`#331510`,vb=e=>`Use Expect to test your changes.`,yb=e=>{let t=Math.round(e/100*10),n=10-t;return{filled:`█`.repeat(t),empty:`░`.repeat(n)}},bb=({gitState:e})=>{let t=Ot(),[n]=Et(),r=K_(e=>e.instructionHistory),i=Gm(e=>e.setScreen),[a,o]=L(void 0),[s,c]=L(``),[l,u]=L(0),[d,f]=L(0),[p,m]=L(!1),[h,g]=L(void 0),[_,v]=L(-1),[y,b]=L(``),x=rv(e=>e.cookiesEnabled),S=rv(e=>e.toggleCookies),{data:C}=lb(e),T=()=>{if(r.length===0)return;let e=_+1;e>=r.length||(_===-1&&b(s),v(e),c(r[e]),u(e=>e+1))},D=()=>{if(_<=-1)return;let e=_-1;v(e),c(e===-1?y:r[e]),u(e=>e+1)},O=sb({gitState:e??null,onSelect:e=>{o(e),J_(`context:selected`,{context_type:{WorkingTree:`working_tree`,Branch:`branch`,PullRequest:`pull_request`,Commit:`commit`}[e._tag]})}}),k=O.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,A=a??k??null,j=hb(A,e??null);ie(()=>{f(0)},[A,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;A?._tag===`Commit`?a=un.makeUnsafe({_tag:`Commit`,hash:A.hash}):A?._tag===`Branch`||A?._tag===`PullRequest`?(A.branch.name&&(nm(process.cwd(),A.branch.name),Km.invalidateQueries({queryKey:[`git-state`]})),a=un.makeUnsafe({_tag:`Branch`,mainBranch:r})):a=un.makeUnsafe({_tag:`Changes`,mainBranch:r}),K_.getState().rememberInstruction(n),x||Hm(n)?i(Wm({changesFor:a,instruction:n,requiresCookies:x})):i(Um.CookieSyncConfirm({changesFor:a,instruction:n}))},M=I(s);M.current=s;let ne=O.createInputChangeHandler(M,e=>{c(e),h&&g(void 0)}),N=!s.includes(`
|
|
43
|
-
`),P=s===``&&!O.pickerOpen&&j.length>0,re=P&&!p&&n>=80,F=j[d%j.length];return ee((e,t)=>{if(O.pickerOpen){if(t.escape){O.closePicker();return}if(t.downArrow||t.ctrl&&e===`n`){O.setPickerIndex(Math.min(O.filteredOptions.length-1,O.pickerIndex+1));return}if(t.upArrow||t.ctrl&&e===`p`){O.setPickerIndex(Math.max(0,O.pickerIndex-1));return}if(t.return||t.tab){let e=O.filteredOptions[O.pickerIndex];e&&O.handleContextSelect(e);return}if(t.backspace||t.delete){O.pickerQuery.length===0?O.closePicker():O.setPickerQuery(O.pickerQuery.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&O.setPickerQuery(O.pickerQuery+e);return}if(N&&t.upArrow){T();return}if(N&&t.downArrow){D();return}if(t.ctrl&&e===`k`){S(),J_(`cookies:toggled`,{enabled:!x});return}if(t.tab&&!t.shift&&P&&F){c(F),u(e=>e+1),J_(`suggestion:accepted`);return}if(!(t.tab&&t.shift)&&P){if(t.rightArrow){f(e=>(e+1)%j.length),m(!0);return}if(t.leftArrow){f(e=>(e-1+j.length)%j.length),m(!0);return}}},{isActive:!0}),H(w,{flexDirection:`column`,width:`100%`,paddingY:1,children:[V(w,{flexDirection:`column`,marginBottom:1,paddingX:1,children:V(Z_,{})}),(e?.hasUntestedChanges||C&&C.totalCount>0)&&!(C&&C.totalCount>0&&C.percent>=90)&&H(w,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:C&&C.totalCount>0?_b(C.percent):t.BANNER_BG,width:`100%`,flexDirection:`column`,gap:0,children:[(()=>{if(C&&C.totalCount>0)return H(w,{children:[H(E,{color:gb(C.percent),bold:!0,children:[U.warning,` Untested changes`]}),V(E,{children:` `}),V(E,{color:gb(C.percent),children:yb(C.percent).filled}),V(E,{color:t.DIM,children:yb(C.percent).empty}),H(E,{color:gb(C.percent),children:[` `,C.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 H(w,{children:[H(E,{color:t.YELLOW,bold:!0,children:[U.warning,` Untested changes detected`]}),n.length>0&&H(se,{children:[H(E,{color:t.DIM,children:[` `,n.length,` file`,n.length===1?``:`s`,` `]}),r>0&&H(E,{color:t.GREEN,children:[`+`,r]}),r>0&&i>0&&V(E,{color:t.DIM,children:` `}),i>0&&H(E,{color:t.RED,children:[`-`,i]})]})]})})(),V(E,{color:t.DIM,children:C&&C.totalCount>0?vb(C.percent):`Describe what to test and hit enter to verify your changes.`})]}),H(w,{flexDirection:`column`,width:`100%`,children:[H(w,{paddingX:1,children:[!e&&V(Rm,{message:`loading context`}),e&&e.isGitRepo&&A&&V(jt,{fullWidth:!1,onClick:()=>{O.pickerOpen?O.closePicker():O.openPicker()},children:H(E,{color:t.DIM,children:[U.bullet,` `,H(E,{color:t.PRIMARY,children:[`@`,Fm(A,e)]}),Pm(A,e)&&` (${Pm(A,e)})`]})})]}),V(jt,{children:V(w,{flexDirection:`column`,marginTop:1,backgroundColor:t.INPUT_BG,width:`100%`,paddingX:1,paddingY:1,children:H(w,{children:[V(E,{color:t.PRIMARY,children:`❯ `}),V(w,{flexGrow:1,children:V(Lt,{focus:!O.pickerOpen,multiline:!0,placeholder:F?`${F} [tab]`:``,value:s,onSubmit:te,onUpArrowAtTop:N?void 0:T,onDownArrowAtBottom:N?void 0:D,onChange:ne},l)}),re?V(E,{color:t.DIM,children:` ←→ cycle test suggestions`}):null]})})}),e?.isGitRepo&&O.pickerOpen&&H(kt,{color:t.BORDER,children:[H(w,{marginBottom:0,children:[V(E,{color:t.DIM,children:`@ `}),V(E,{color:t.PRIMARY,children:O.pickerQuery}),V(E,{color:t.DIM,children:O.pickerQuery?``:`type to filter`})]}),V(ob,{options:O.filteredOptions,selectedIndex:O.pickerIndex,isLoading:O.remoteLoading,gitState:e})]}),e?.isGitRepo&&!O.pickerOpen&&V(w,{marginTop:1,paddingX:1,children:H(E,{color:t.DIM,children:[V(E,{color:t.PRIMARY,children:`@`}),` add context`]})})]}),V(qv,{message:h})]})},xb=e=>{let t=ne(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=H(E,{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=H(E,{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=H(se,{children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Sb=e=>{let t=ne(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=V(E,{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)=>H(w,{children:[e.onClick?V(jt,{fullWidth:!1,onClick:e.onClick,children:V(xb,{segment:e,mutedColor:i})}):V(xb,{segment:e,mutedColor:i}),t<n.length-1&&V(E,{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=H(w,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s},Cb=b.Struct({version:b.String}),wb=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1},Tb=c.gen(function*(){let e=yield*c.tryPromise({try:()=>fetch(`https://registry.npmjs.org/${ht}/latest`).then(e=>e.json()),catch:e=>Error(`npm registry fetch failed: ${e}`)});return(yield*c.try({try:()=>b.decodeUnknownSync(Cb)(e),catch:e=>Error(`npm response decode failed: ${e}`)})).version}).pipe(c.timeoutOrElse({duration:5e3,onTimeout:()=>c.succeed(void 0)})),Eb=()=>{let{data:e}=M({queryKey:[`update-check`],queryFn:async()=>{let e=await c.runPromiseExit(Tb);if(l.isSuccess(e))return e.value},staleTime:36e5,retry:!1,refetchOnWindowFocus:!1});return{latestVersion:e,updateAvailable:e!==void 0&&wb(e,`0.0.8`)}},Db=(e,t)=>{let n=ne(87);if(n[0]!==`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`){for(let e=0;e<87;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`}let r=Ot(),i=Gm(Ab),a=rv(jb),o=rv(Mb),s=K_(Nb),c=K_(Pb),l=Ov(Fb);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(Um.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(Um.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(Um.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(Um.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(Um.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(Wm({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(Wm({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(Um.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],h.isSome(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:()=>{Ov.getState().setExecutedPlan(void 0),i(Wm({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:()=>{Ov.getState().setExecutedPlan(void 0),i(Um.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}}},Ob=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,kb=()=>{let e=ne(34);if(e[0]!==`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`){for(let t=0;t<34;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`}let[t]=Et(),{data:n}=eb(),r=Gm(Ib),{latestVersion:i,updateAvailable:a}=Eb(),o=Db(r,n),s,c,l,u,d,f,p,m;if(e[1]!==o||e[2]!==t||e[3]!==i||e[4]!==r._tag||e[5]!==a){let n=a?[...o,{key:`ctrl+u`,label:`v${i} available`,cta:!0,color:Y.warning}]:o;u=n.filter(Lb);let h=Le(Ob(u)),g=zb,_=n.filter(Bb),v=g(_)+h+2>t?_.filter(Vb):_,y=g(v);l=Math.max(0,t-y-h-2),c=w,p=`column`,e[14]!==t||e[15]!==r._tag?(m=r._tag===`Testing`?V(Dv,{text:`─`.repeat(t),baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight,speed:3}):V(E,{color:Y.border,children:`─`.repeat(t)}),e[14]=t,e[15]=r._tag,e[16]=m):m=e[16],s=w,d=1,f=v.map(Hb),e[1]=o,e[2]=t,e[3]=i,e[4]=r._tag,e[5]=a,e[6]=s,e[7]=c,e[8]=l,e[9]=u,e[10]=d,e[11]=f,e[12]=p,e[13]=m}else s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13];let h;e[17]===l?h=e[18]:(h=` `.repeat(l),e[17]=l,e[18]=h);let g;e[19]===h?g=e[20]:(g=V(E,{children:h}),e[19]=h,e[20]=g);let _;e[21]===u?_=e[22]:(_=u.length>0?V(Sb,{segments:u,color:Y.primary,mutedColor:Y.textMuted}):null,e[21]=u,e[22]=_);let v;e[23]!==s||e[24]!==d||e[25]!==f||e[26]!==g||e[27]!==_?(v=H(s,{paddingX:d,children:[f,g,_]}),e[23]=s,e[24]=d,e[25]=f,e[26]=g,e[27]=_,e[28]=v):v=e[28];let y;return e[29]!==c||e[30]!==p||e[31]!==m||e[32]!==v?(y=H(c,{flexDirection:p,children:[m,v]}),e[29]=c,e[30]=p,e[31]=m,e[32]=v,e[33]=y):y=e[33],y};function Ab(e){return e.setScreen}function jb(e){return e.cookiesEnabled}function Mb(e){return e.toggleCookies}function Nb(e){return e.notifications}function Pb(e){return e.toggleNotifications}function Fb(e){return e.expanded}function Ib(e){return e.screen}function Lb(e){return!e.cta}function Rb(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function zb(e){return Le(e.map(Rb).join(` `))}function Bb(e){return e.cta}function Vb(e){return e.key!==`ctrl+p`}function Hb(e,t){let n=H(E,{children:[t>0?` `:``,e.color?H(E,{backgroundColor:e.color,color:`black`,children:[` `,V(E,{bold:!0,children:e.label}),` `,H(E,{children:[`[`,e.key,`]`]}),` `]}):H(E,{children:[H(E,{color:Y.textMuted,children:[e.label,` `]}),H(E,{color:Y.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?V(jt,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let Ub=null;const Wb=e=>{Ub=e},Gb=()=>Ub?.clear(),Kb=e=>{let t=ne(34);if(t[0]!==`e6ac87aa0f631766a38fac7cfbcee5d6c83ce6fd1edd967a6457097df0e89416`){for(let e=0;e<34;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e6ac87aa0f631766a38fac7cfbcee5d6c83ce6fd1edd967a6457097df0e89416`}let{agent:n}=e,r=Gm(qb),i=Gm(Jb),a=Gm(Yb),{data:o}=eb(),s=et(Yv),c,l;t[1]!==n||t[2]!==s?(c=()=>{s(h.some(n))},l=[n,s],t[1]=n,t[2]=s,t[3]=c,t[4]=l):(c=t[3],l=t[4]),ie(c,l);let u;t[5]!==r._tag||t[6]!==i?(u=()=>{if(r._tag===`CookieSyncConfirm`){i(Um.Main());return}if(r._tag===`PortPicker`){i(Um.Main());return}if(r._tag===`Results`){Ov.getState().setExecutedPlan(void 0),i(Um.Main());return}r._tag!==`Testing`&&i(Um.Main())},t[5]=r._tag,t[6]=i,t[7]=u):u=t[7];let d=u,{updateAvailable:f}=Eb(),{exit:p}=O(),[,m]=L(0),[,g]=Et(),_;t[8]!==p||t[9]!==o?.isGitRepo||t[10]!==d||t[11]!==a||t[12]!==r._tag||t[13]!==m||t[14]!==f?(_=(e,t)=>{if(t.ctrl&&e===`l`){Gb(),m(Xb);return}if(t.ctrl&&e===`u`&&f){p(),process.stdout.write(ft),B(`npm`,[`install`,`-g`,`${ht}@latest`],{stdio:`inherit`});return}t.escape&&r._tag!==`Main`&&d(),t.ctrl&&e===`p`&&r._tag===`Main`&&o?.isGitRepo&&a(Um.SelectPr()),t.ctrl&&e===`r`&&r._tag===`Main`&&a(Um.SavedFlowPicker())},t[8]=p,t[9]=o?.isGitRepo,t[10]=d,t[11]=a,t[12]=r._tag,t[13]=m,t[14]=f,t[15]=_):_=t[15],ee(_);let v;t[16]!==o||t[17]!==r._tag||t[18]!==r.baseUrls||t[19]!==r.changesFor||t[20]!==r.instruction||t[21]!==r.localReplayUrl||t[22]!==r.replayUrl||t[23]!==r.report||t[24]!==r.requiresCookies||t[25]!==r.savedFlow||t[26]!==r.videoUrl?(v=()=>{if(!o)return V(bb,{gitState:void 0});switch(r._tag){case`PortPicker`:return V(hv,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies});case`Testing`:return V(Dy,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies,baseUrls:r.baseUrls});case`Results`:return V(Jy,{report:r.report,replayUrl:r.replayUrl,localReplayUrl:r.localReplayUrl,videoUrl:r.videoUrl});case`SelectPr`:return V(Jm,{});case`CookieSyncConfirm`:return V($_,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow});case`SavedFlowPicker`:return V(rb,{});default:return V(bb,{gitState:o})}},t[16]=o,t[17]=r._tag,t[18]=r.baseUrls,t[19]=r.changesFor,t[20]=r.instruction,t[21]=r.localReplayUrl,t[22]=r.replayUrl,t[23]=r.report,t[24]=r.requiresCookies,t[25]=r.savedFlow,t[26]=r.videoUrl,t[27]=v):v=t[27];let y=v,b;t[28]===y?b=t[29]:(b=V(w,{flexGrow:1,children:y()}),t[28]=y,t[29]=b);let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=V(kb,{}),t[30]=x):x=t[30];let S;return t[31]!==g||t[32]!==b?(S=V(bt,{children:H(w,{flexDirection:`column`,width:`100%`,height:g,children:[b,x]})}),t[31]=g,t[32]=b,t[33]=S):S=t[33],S};function qb(e){return e.screen}function Jb(e){return e.setScreen}function Yb(e){return e.navigateTo}function Xb(e){return e+1}const Zb=()=>{let e=Oe();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`},Qb=()=>new Promise(e=>{R(Zb(),()=>e())}),$b=e=>c.runPromise(Zv(c.gen(function*(){let t=yield*Up,n=yield*Wp,r=yield*U_,i=Date.now();yield*r.capture(`session:started`,{mode:`headless`,skip_planning:!1,browser_headed:e.headed}),console.log(`expect v${dt}`),console.log(`Testing ${dn(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(S.tap(e=>c.sync(()=>{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(`${U.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${U.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${U.cross} ${t.stepId} ${t.message}`);break}})),S.runLast,c.map(t=>t._tag===`Some`?t.value:new Gn({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!e.headed,requiresCookies:!1,testCoverage:h.none(),title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),l=yield*n.report(s),u=l.steps.filter(e=>l.stepStatuses.get(e.id)?.status===`passed`).length,d=l.steps.filter(e=>l.stepStatuses.get(e.id)?.status===`failed`).length;yield*r.capture(`run:completed`,{plan_id:s.id??`direct`,passed:u,failed:d,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${l.toPlainText}`),yield*c.promise(()=>Qb()),process.exit(l.status===`passed`?0:1)}).pipe(c.provide(Jv({verbose:e.verbose,agent:e.agent}))))),ex={error:W.red,warn:W.yellow,info:W.cyan,success:W.green,dim:W.dim},tx={error:(...e)=>{console.log(ex.error(e.join(` `)))},warn:(...e)=>{console.log(ex.warn(e.join(` `)))},info:(...e)=>{console.log(ex.info(e.join(` `)))},success:(...e)=>{console.log(ex.success(e.join(` `)))},dim:(...e)=>{console.log(ex.dim(e.join(` `)))},log:(...e)=>{console.log(e.join(` `))},break:()=>{console.log(``)}},nx=()=>{tx.break(),tx.log(`Cancelled.`),tx.break(),process.exit(0)},rx=e=>lt(e,{onCancel:nx}),ix=(e,t)=>ut({text:e,isSilent:t?.silent}),ax=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],ox=()=>ax.some(e=>!!process.env[e]),sx=()=>!process.stdin.isTTY,cx={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`},lx=`npx skills add https://github.com/millionco/expect --skill expect-cli`,ux=()=>{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`},dx=e=>e||ox()||sx(),fx=e=>new Promise(t=>{R(e,e=>{t(!e)})}),px=async(e={})=>{let t=dx(e.yes??!1),n=cx[ux()];tx.break(),tx.log(` ${W.red(U.cross)}${W.green(U.tick)} ${W.bold(`Expect`)} ${ex.dim(`v${dt}`)}`),tx.break(),Ba().length===0&&(tx.error(`No supported coding agent found. expect requires one of: Claude Code, Codex, or Cursor.`),tx.break(),tx.log(` Install one to get started:`),tx.log(` ${ex.info(`Claude Code`)} ${ex.dim(`https://docs.anthropic.com/en/docs/claude-code`)}`),tx.log(` ${ex.info(`Codex`)} ${ex.dim(`https://github.com/openai/codex`)}`),tx.log(` ${ex.info(`Cursor`)} ${ex.dim(`https://cursor.com`)}`),tx.break(),process.exit(1));let r=ix(`Installing expect-cli globally...`).start();await fx(n)?r.succeed(`Installed! You can now run ${ex.info(`expect-cli`)} from anywhere.`):(r.fail(`Failed to install globally.`),tx.dim(` Run manually: ${ex.info(n)}`)),tx.break();let i=t;if(t||(i=(await rx({type:`confirm`,name:`installSkill`,message:`Install the ${ex.info(`expect`)} skill for your coding agent?`,initial:!0})).installSkill),i){let e=ix(`Installing skill...`).start();await fx(lx)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),tx.dim(` Run manually: ${ex.info(lx)}`))}tx.break(),tx.success(`You're all set!`),tx.log(` Run ${ex.info(`expect-cli`)} in any project to start testing.`),tx.break()},mx=[`packages/*`,`apps/*`],hx=e=>mt.some(t=>e.includes(t)),gx=c.fn(`detectAgent`)(function*(e){let t=yield*d.FileSystem;for(let[n,r]of Object.entries(gt)){let i=G.join(e,n);if(yield*t.exists(i).pipe(c.catchTag(`PlatformError`,()=>c.succeed(!1))))return r}let n=G.join(e,`package.json`),r=yield*t.readFileString(n).pipe(c.catchTag(`PlatformError`,()=>c.succeed(``)));if(r){let e=yield*c.try({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})}).pipe(c.catchTag(`JsonParseError`,()=>c.succeed(void 0)));if(e?.packageManager){let t=e.packageManager.split(`@`)[0];if(t)return t}}return`npm`}),_x=c.fn(`readPackageJson`)(function*(e){let t=yield*d.FileSystem,n=G.join(e,`package.json`),r=yield*t.readFileString(n);return yield*c.try({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})})}),vx=c.fn(`listWorkspaceDirectories`)(function*(e){let t=yield*d.FileSystem,n=[];for(let r of mx){let i=G.join(e,G.dirname(r)),a=yield*t.readDirectory(i).pipe(c.catchTag(`PlatformError`,()=>c.succeed([])));for(let e of a){let r=G.join(i,e);(yield*t.stat(r).pipe(c.catchTag(`PlatformError`,()=>c.succeed(void 0))))?.type===`Directory`&&n.push(r)}}return n}),yx=(e,t,n)=>new Promise(r=>{oe(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})})}),bx=
|
|
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=Ja()(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)}})),$a=n(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=Ya():t.exports=Qa()})),eo=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($a()).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})),to=n((e=>{function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,`__esModule`,{value:!0}),t(eo())})),no=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})),ro=to(),io=t($a(),1),ao=no(),oo=Object.defineProperty,so=Object.getOwnPropertyDescriptor,co=Object.getOwnPropertyNames,lo=Object.prototype.hasOwnProperty,X=(e,t)=>function(){return e&&(t=(0,e[co(e)[0]])(e=0)),t},uo=(e,t)=>function(){return t||(0,e[co(e)[0]])((t={exports:{}}).exports,t),t.exports},fo=(e,t)=>{for(var n in t)oo(e,n,{get:t[n],enumerable:!0})},po=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of co(t))!lo.call(e,i)&&i!==n&&oo(e,i,{get:()=>t[i],enumerable:!(r=so(t,i))||r.enumerable});return e},mo=e=>po(oo({},`__esModule`,{value:!0}),e);function ho(...e){let t=new String(e);return vo.set(t,e),t}function go(e){return e instanceof String&&vo.has(e)}function _o(e){return vo.get(e)||[]}var vo,yo=X({"src/lib/args/pathspec.ts"(){vo=new WeakMap}}),bo,xo=X({"src/lib/errors/git-error.ts"(){bo=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),So,Co=X({"src/lib/errors/git-response-error.ts"(){xo(),So=class extends bo{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),wo,To=X({"src/lib/errors/task-configuration-error.ts"(){xo(),wo=class extends bo{constructor(e){super(void 0,e)}}}});function Eo(e){return typeof e==`function`?e:Jo}function Do(e){return typeof e==`function`&&e!==Jo}function Oo(e,t){let n=e.indexOf(t);return n<=0?[e,``]:[e.substr(0,n),e.substr(n+1)]}function ko(e,t=0){return jo(e)&&e.length>t?e[t]:void 0}function Ao(e,t=0){if(jo(e)&&e.length>t)return e[e.length-1-t]}function jo(e){return as(e)}function Mo(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 No(e,t){return Mo(e,!0).map(e=>t(e))}function Po(e){return(0,ro.exists)(e,ro.FOLDER)}function Fo(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function Io(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function Lo(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function Ro(e){return Array.isArray(e)?e:[e]}function zo(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function Bo(e){return Ro(e).map(e=>e instanceof String?e:String(e))}function Vo(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function Ho(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function Uo(e){return(Array.isArray(e)?Ce.concat(e):e).toString(`utf-8`)}function Wo(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function Go(e=0){return new Promise(t=>setTimeout(t,e))}function Ko(e){if(e!==!1)return e}var qo,Jo,Yo,Xo=X({"src/lib/utils/util.ts"(){os(),qo=`\0`,Jo=()=>{},Yo=Object.prototype.toString.call.bind(Object.prototype.toString)}});function Zo(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function Qo(e,t){let n=go(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function $o(e){return!!e&&Yo(e)===`[object Object]`}function es(e){return typeof e==`function`}var ts,ns,rs,is,as,os=X({"src/lib/utils/argument-filters.ts"(){yo(),Xo(),ts=e=>Array.isArray(e),ns=e=>typeof e==`number`,rs=e=>typeof e==`string`||go(e),is=e=>rs(e)||Array.isArray(e)&&e.every(rs),as=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),ss,cs=X({"src/lib/utils/exit-codes.ts"(){ss=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(ss||{})}}),ls,us=X({"src/lib/utils/git-output-streams.ts"(){ls=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function ds(){throw Error(`LineParser:useMatches not implemented`)}var Z,fs,ps=X({"src/lib/utils/line-parser.ts"(){Z=class{constructor(e,t){this.matches=[],this.useMatches=ds,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))}},fs=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 ms(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...hs},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var hs,gs=X({"src/lib/utils/simple-git-options.ts"(){hs={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function _s(e,t=[]){return $o(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(go(r))t.push(r);else if(Qo(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)Qo(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function vs(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 _s(bs(e),r),n||r.push(...ys(e)),r}function ys(e){return Bo(Zo(Ao(e,typeof Ao(e)==`function`?1:0),ts,[]))}function bs(e){return Zo(Ao(e,es(Ao(e))?1:0),$o)}function xs(e,t=!0){let n=Eo(Ao(e));return t||Do(n)?n:void 0}var Ss=X({"src/lib/utils/task-options.ts"(){os(),Xo(),yo()}});function Cs(e,t){return e(t.stdOut,t.stdErr)}function ws(e,t,n,r=!0){return Ro(n).forEach(n=>{for(let i=Mo(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 Ts=X({"src/lib/utils/task-parser.ts"(){Xo()}}),Es={};fo(Es,{ExitCodes:()=>ss,GitOutputStreams:()=>ls,LineParser:()=>Z,NOOP:()=>Jo,NULL:()=>qo,RemoteLineParser:()=>fs,append:()=>Fo,appendTaskOptions:()=>_s,asArray:()=>Ro,asCamelCase:()=>zo,asFunction:()=>Eo,asNumber:()=>Vo,asStringArray:()=>Bo,bufferToString:()=>Uo,callTaskParser:()=>Cs,createInstanceConfig:()=>ms,delay:()=>Go,filterArray:()=>ts,filterFunction:()=>es,filterHasLength:()=>as,filterNumber:()=>ns,filterPlainObject:()=>$o,filterPrimitives:()=>Qo,filterString:()=>rs,filterStringOrStringArray:()=>is,filterType:()=>Zo,first:()=>ko,folderExists:()=>Po,forEachLineWithContent:()=>No,getTrailingOptions:()=>vs,including:()=>Io,isUserFunction:()=>Do,last:()=>Ao,objectToString:()=>Yo,orVoid:()=>Ko,parseStringResponse:()=>ws,pick:()=>Wo,prefixedArray:()=>Ho,remove:()=>Lo,splitOn:()=>Oo,toLinesWithContent:()=>Mo,trailingFunctionArgument:()=>xs,trailingOptionsArgument:()=>bs});var Q=X({"src/lib/utils/index.ts"(){os(),cs(),us(),ps(),gs(),Ss(),Ts(),Xo()}}),Ds={};fo(Ds,{CheckRepoActions:()=>Ms,checkIsBareRepoTask:()=>As,checkIsRepoRootTask:()=>ks,checkIsRepoTask:()=>Os});function Os(e){switch(e){case`bare`:return As();case`root`:return ks()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:Ns,parser:Ps}}function ks(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:Ns,parser(e){return/^\.(git)?$/.test(e.trim())}}}function As(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:Ns,parser:Ps}}function js(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var Ms,Ns,Ps,Fs=X({"src/lib/tasks/check-is-repo.ts"(){Q(),Ms=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(Ms||{}),Ns=({exitCode:e},t,n,r)=>{if(e===128&&js(t))return n(Buffer.from(`false`));r(t)},Ps=e=>e.trim()===`true`}});function Is(e,t){let n=new Ls(e),r=e?zs:Rs;return Mo(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(Bs.test(t)?n.folders:n.files).push(t)}),n}var Ls,Rs,zs,Bs,Vs=X({"src/lib/responses/CleanSummary.ts"(){Q(),Ls=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},Rs=/^[a-z]+\s*/i,zs=/^[a-z]+\s+[a-z]+\s*/i,Bs=/\/$/}}),Hs={};fo(Hs,{EMPTY_COMMANDS:()=>Ys,adhocExecTask:()=>Us,configurationErrorTask:()=>Ws,isBufferTask:()=>qs,isEmptyTask:()=>Js,straightThroughBufferTask:()=>Ks,straightThroughStringTask:()=>Gs});function Us(e){return{commands:Ys,format:`empty`,parser:e}}function Ws(e){return{commands:Ys,format:`empty`,parser(){throw typeof e==`string`?new wo(e):e}}}function Gs(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function Ks(e){return{commands:e,format:`buffer`,parser(e){return e}}}function qs(e){return e.format===`buffer`}function Js(e){return e.format===`empty`||!e.commands.length}var Ys,Xs=X({"src/lib/tasks/task.ts"(){To(),Ys=[]}}),Zs={};fo(Zs,{CONFIG_ERROR_INTERACTIVE_MODE:()=>ac,CONFIG_ERROR_MODE_REQUIRED:()=>oc,CONFIG_ERROR_UNKNOWN_OPTION:()=>sc,CleanOptions:()=>cc,cleanTask:()=>$s,cleanWithOptionsTask:()=>Qs,isCleanOptionsArray:()=>ec});function Qs(e,t){let{cleanMode:n,options:r,valid:i}=tc(e);return n?i.options?(r.push(...t),r.some(ic)?Ws(ac):$s(n,r)):Ws(sc+JSON.stringify(e)):Ws(oc)}function $s(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return Is(e===`n`,t)}}}function ec(e){return Array.isArray(e)&&e.every(e=>lc.has(e))}function tc(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{nc(e)?(t=e,r.cleanMode=!0):r.options=r.options&&rc(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function nc(e){return e===`f`||e===`n`}function rc(e){return/^-[a-z]$/i.test(e)&&lc.has(e.charAt(1))}function ic(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var ac,oc,sc,cc,lc,uc=X({"src/lib/tasks/clean.ts"(){Vs(),Q(),Xs(),ac=`Git clean interactive mode is not supported`,oc=`Git clean mode parameter ("n" or "f") is required`,sc=`Git clean unknown option found in: `,cc=(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))(cc||{}),lc=new Set([`i`,...Bo(Object.values(cc))])}});function dc(e){let t=new hc;for(let n of mc(e))t.addValue(n.file,String(n.key),n.value);return t}function fc(e,t){let n=null,r=[],i=new Map;for(let a of mc(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 pc(e){return e.replace(/^(file):/,``)}function*mc(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=pc(n[e++]),i=n[e++],a=t;if(i.includes(`
|
|
20
|
+
`)){let e=Oo(i,`
|
|
21
|
+
`);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var hc,gc=X({"src/lib/responses/ConfigList.ts"(){Q(),hc=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=Ao(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 _c(e,t){return typeof e==`string`&&Object.hasOwn(Sc,e)?e:t}function vc(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 yc(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 fc(t,e)}}}function bc(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return dc(e)}}}function xc(){return{addConfig(e,t,...n){return this._runTask(vc(e,t,n[0]===!0,_c(n[1],`local`)),xs(arguments))},getConfig(e,t){return this._runTask(yc(e,_c(t,void 0)),xs(arguments))},listConfig(...e){return this._runTask(bc(_c(e[0],void 0)),xs(arguments))}}}var Sc,Cc=X({"src/lib/tasks/config.ts"(){gc(),Q(),Sc=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(Sc||{})}});function wc(e){return Ec.has(e)}var Tc,Ec,Dc=X({"src/lib/tasks/diff-name-status.ts"(){Tc=(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))(Tc||{}),Ec=new Set(Object.values(Tc))}});function Oc(...e){return new Pc().param(...e)}function kc(e){let t=new Set,n={};return No(e,e=>{let[r,i,a]=e.split(qo);t.add(r),(n[r]=n[r]||[]).push({line:Vo(i),path:r,preview:a})}),{paths:t,results:n}}function Ac(){return{grep(e){let t=xs(arguments),n=vs(arguments);for(let e of jc)if(n.includes(e))return this._runTask(Ws(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Oc().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return kc(e)}},t)}}}var jc,Mc,Nc,Pc,Fc=X({"src/lib/tasks/grep.ts"(){Q(),Xs(),jc=[`-h`],Mc=Symbol(`grepQuery`),Pc=class{constructor(){this[Nc]=[]}*[(Nc=Mc,Symbol.iterator)](){for(let e of this[Mc])yield e}and(...e){return e.length&&this[Mc].push(`--and`,`(`,...Ho(e,`-e`),`)`),this}param(...e){return this[Mc].push(...Ho(e,`-e`)),this}}}}),Ic={};fo(Ic,{ResetMode:()=>Bc,getResetMode:()=>Rc,resetTask:()=>Lc});function Lc(e,t){let n=[`reset`];return zc(e)&&n.push(`--${e}`),n.push(...t),Gs(n)}function Rc(e){if(zc(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function zc(e){return typeof e==`string`&&Vc.includes(e)}var Bc,Vc,Hc=X({"src/lib/tasks/reset.ts"(){Q(),Xs(),Bc=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(Bc||{}),Vc=Bo(Object.values(Bc))}});function Uc(){return(0,io.default)(`simple-git`)}function Wc(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 Gc(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 Kc(e,t,n,r=Uc()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=Gc(Zo(t,rs),o,r);return l(n);function c(t,n){return Fo(a,Kc(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&Wc(o,n)||Jo,s=Wc(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var qc=X({"src/lib/git-logger.ts"(){Q(),io.default.formatters.L=e=>String(as(e)?e.length:`-`),io.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):Yo(e)}}),Jc,Yc=X({"src/lib/runners/tasks-pending-queue.ts"(){xo(),qc(),Jc=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:Kc(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 bo(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 Xc(e,t){return{method:ko(e.commands)||``,commands:t}}function Zc(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function Qc(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var $c,el=X({"src/lib/runners/git-executor-chain.ts"(){xo(),Xs(),Q(),Yc(),$c=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new Jc}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(Js(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 bo?Object.assign(t,{task:e}):new bo(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`,``,Xc(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],Xc(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),qs(e)?Cs(e.parser,a):Cs(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},{...Xc(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`,Yo(e)),c(new ls(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 ls(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},Xc(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,{...Xc(e,n),kill(e){u=e||u}});let d=Te(t,n,o);d.stdout.on(`data`,Qc(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,Qc(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,Zc(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,{...Xc(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,{...Xc(e,t),kill(e){n=e||n}}),n}}}}),tl={};fo(tl,{GitExecutor:()=>nl});var nl,rl=X({"src/lib/runners/git-executor.ts"(){el(),nl=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new $c(this,this._scheduler,this._plugins)}chain(){return new $c(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function il(e,t,n=Jo){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof So?al(t):t,void 0)})}function al(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=Jo};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 ol=X({"src/lib/task-callback.ts"(){Co(),Q()}});function sl(e,t){return Us(n=>{if(!Po(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var cl=X({"src/lib/tasks/change-working-directory.ts"(){Q(),Xs()}});function ll(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=Lo(t,`-B`)),Gs(t)}function ul(){return{checkout(){return this._runTask(ll(vs(arguments,1)),xs(arguments))},checkoutBranch(e,t){return this._runTask(ll([`-b`,e,t,...vs(arguments)]),xs(arguments))},checkoutLocalBranch(e){return this._runTask(ll([`-b`,e,...vs(arguments)]),xs(arguments))}}}var dl=X({"src/lib/tasks/checkout.ts"(){Q(),Xs()}});function fl(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function pl(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return ws(fl(),[ml],e)}})}}}var ml,hl=X({"src/lib/tasks/count-objects.ts"(){Q(),ml=new Z(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=zo(t);Object.hasOwn(e,r)&&(e[r]=Vo(n))})}});function gl(e){return ws({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},_l,e)}var _l,vl=X({"src/lib/parsers/parse-commit.ts"(){Q(),_l=[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 yl(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...Ho(e,`-m`),...t,...n],format:`utf-8`,parser:gl}}function bl(){return{commit(t,...n){let r=xs(arguments),i=e(t)||yl(Ro(t),Ro(Zo(n[0],is,[])),[...Bo(Zo(n[1],ts,[])),...vs(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!is(e)&&Ws(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var xl=X({"src/lib/tasks/commit.ts"(){vl(),Q(),Xs()}});function Sl(){return{firstCommit(){return this._runTask(Gs([`rev-list`,`--max-parents=0`,`HEAD`],!0),xs(arguments))}}}var Cl=X({"src/lib/tasks/first-commit.ts"(){Q(),Xs()}});function wl(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),Gs(n,!0)}var Tl=X({"src/lib/tasks/hash-object.ts"(){Xs()}});function El(e,t,n){let r=String(n).trim(),i;if(i=Ol.exec(r))return new Dl(e,t,!1,i[1]);if(i=kl.exec(r))return new Dl(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new Dl(e,t,/^re/i.test(r),a)}var Dl,Ol,kl,Al=X({"src/lib/responses/InitSummary.ts"(){Dl=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},Ol=/^Init.+ repository in (.+)$/,kl=/^Rein.+ in (.+)$/}});function jl(e){return e.includes(Nl)}function Ml(e=!1,t,n){let r=[`init`,...n];return e&&!jl(r)&&r.splice(1,0,Nl),{commands:r,format:`utf-8`,parser(e){return El(r.includes(`--bare`),t,e)}}}var Nl,Pl=X({"src/lib/tasks/init.ts"(){Al(),Nl=`--bare`}});function Fl(e){for(let t=0;t<e.length;t++){let n=Ll.exec(e[t]);if(n)return`--${n[1]}`}return``}function Il(e){return Ll.test(e)}var Ll,Rl=X({"src/lib/args/log-format.ts"(){Ll=/^--(stat|numstat|name-only|name-status)(=|$)/}}),zl,Bl=X({"src/lib/responses/DiffSummary.ts"(){zl=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function Vl(e=``){let t=Kl[e];return e=>ws(new zl,t,e,!1)}var Hl,Ul,Wl,Gl,Kl,ql=X({"src/lib/parsers/parse-diff-summary.ts"(){Rl(),Bl(),Dc(),Q(),Hl=[new Z(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:Vo(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:Vo(n),after:Vo(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=Vo(t),e.insertions=Vo(r?.[1]),e.deletions=Vo(i?.[1])})],Ul=[new Z(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=Vo(t),a=Vo(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})})],Wl=[new Z(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],Gl=[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:Ko(wc(t)&&t),from:Ko(!!a&&r!==a&&r),similarity:Vo(n)})})],Kl={"":Hl,"--stat":Hl,"--numstat":Ul,"--name-status":Gl,"--name-only":Wl}}});function Jl(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function Yl(e=Ql,t=$l,n=``){let r=Vl(n);return function(n){let i=Mo(n.trim(),!1,Xl).map(function(n){let i=n.split(Zl),a=Jl(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 Xl,Zl,Ql,$l,eu=X({"src/lib/parsers/parse-list-log-summary.ts"(){Q(),ql(),Rl(),Xl=`òòòòòò `,Zl=` òò`,Ql=` ò `,$l=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),tu={};fo(tu,{diffSummaryTask:()=>nu,validateLogFormatConfig:()=>ru});function nu(e){let t=Fl(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),ru(n)||{commands:n,format:`utf-8`,parser:Vl(t)}}function ru(e){let t=e.filter(Il);if(t.length>1)return Ws(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return Ws(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var iu=X({"src/lib/tasks/diff.ts"(){Rl(),ql(),Xs()}});function au(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function ou(e){return Object.keys(e).reduce((t,n)=>(n in uu||(t[n]=e[n]),t),{})}function su(e={},t=[]){let n=Zo(e.splitter,rs,Ql),[r,i]=au($o(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:${Xl}${i}${Zl}`,...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 rs(e.file)&&o.push(`--follow`,ho(e.file)),_s(ou(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function cu(e,t,n){let r=Yl(e,t,Fl(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function lu(){return{log(...n){let r=xs(arguments),i=su(bs(arguments),Bo(Zo(arguments[0],ts,[]))),a=t(...n)||ru(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return cu(e.splitter,e.fields,e.commands)}function t(e,t){return rs(e)&&rs(t)&&Ws(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var uu,du=X({"src/lib/tasks/log.ts"(){Rl(),yo(),eu(),Q(),Xs(),iu(),uu=(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))(uu||{})}}),fu,pu,mu=X({"src/lib/responses/MergeSummary.ts"(){fu=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},pu=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`}}}}),hu,gu,_u=X({"src/lib/responses/PullSummary.ts"(){hu=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},gu=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function vu(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 yu(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:Vo(t&&t[1]||`0`),delta:Vo(n&&n[1]||`0`)}}var bu,xu=X({"src/lib/parsers/parse-remote-objects.ts"(){Q(),bu=[new fs(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=vu(e.remoteMessages);Object.assign(i,{[r]:Vo(n)})}),new fs(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=vu(e.remoteMessages);Object.assign(i,{[r]:Vo(n)})}),new fs(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=vu(e.remoteMessages);i.total=yu(t),i.reused=yu(n),i.packReused=Vo(r)})]}});function Su(e,t){return ws({remoteMessages:new wu},Cu,t)}var Cu,wu,Tu=X({"src/lib/parsers/parse-remote-messages.ts"(){Q(),xu(),Cu=[new fs(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...bu,new fs([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new fs([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:Vo(t),summary:n,url:r}})],wu=class{constructor(){this.all=[]}}}});function Eu(e,t){let n=ws(new gu,ju,[e,t]);return n.message&&n}var Du,Ou,ku,Au,ju,Mu,Nu,Pu=X({"src/lib/parsers/parse-pull.ts"(){_u(),Q(),Tu(),Du=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Ou=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,ku=/^(create|delete) mode \d+ (.+)/,Au=[new Z(Du,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Z(Ou,(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(ku,(e,[t,n])=>{Fo(e.files,n),Fo(t===`create`?e.created:e.deleted,n)})],ju=[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})],Mu=(e,t)=>ws(new hu,Au,[e,t]),Nu=(e,t)=>Object.assign(new hu,Mu(e,t),Su(e,t))}}),Fu,Iu,Lu,Ru=X({"src/lib/parsers/parse-merge.ts"(){mu(),Q(),Pu(),Fu=[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 fu(t,n))}),new Z(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new fu(t,n,{deleteRef:r}))}),new Z(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new fu(t,null))}),new Z(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],Iu=(e,t)=>Object.assign(Lu(e,t),Nu(e,t)),Lu=e=>ws(new pu,Fu,e)}});function zu(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=Iu(e,t);if(n.failed)throw new So(n);return n}}:Ws(`Git.merge requires at least one option`)}var Bu=X({"src/lib/tasks/merge.ts"(){Co(),Ru(),Xs()}});function Vu(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 Hu,Uu,Wu,Gu=X({"src/lib/parsers/parse-push.ts"(){Q(),Tu(),Hu=[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(Vu(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}}})],Uu=(e,t)=>{let n=Wu(e,t),r=Su(e,t);return{...n,...r}},Wu=(e,t)=>ws({pushed:[]},Hu,[e,t])}}),Ku={};fo(Ku,{pushTagsTask:()=>qu,pushTask:()=>Ju});function qu(e={},t){return Fo(t,`--tags`),Ju(e,t)}function Ju(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),Lo(n,`-v`),Fo(n,`--verbose`),Fo(n,`--porcelain`),{commands:n,format:`utf-8`,parser:Uu}}var Yu=X({"src/lib/tasks/push.ts"(){Gu(),Q()}});function Xu(){return{showBuffer(){let e=[`show`,...vs(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(Ks(e),xs(arguments))},show(){let e=[`show`,...vs(arguments,1)];return this._runTask(Gs(e),xs(arguments))}}}var Zu=X({"src/lib/tasks/show.ts"(){Q(),Xs()}}),Qu,$u,ed=X({"src/lib/responses/FileStatusSummary.ts"(){Qu=/^(.+)\0(.+)$/,$u=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=Qu.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function td(e){let[t,n]=e.split(qo);return{from:n||t,to:t}}function nd(e,t,n){return[`${e}${t}`,n]}function rd(e,...t){return t.map(t=>nd(e,t,(e,t)=>e.conflicted.push(t)))}function id(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=od.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new $u(r,t,n))}}var ad,od,sd,cd=X({"src/lib/responses/StatusSummary.ts"(){Q(),ed(),ad=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}},od=new Map([nd(` `,`A`,(e,t)=>e.created.push(t)),nd(` `,`D`,(e,t)=>e.deleted.push(t)),nd(` `,`M`,(e,t)=>e.modified.push(t)),nd(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),nd(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),nd(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),nd(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),nd(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),nd(`R`,` `,(e,t)=>{e.renamed.push(td(t))}),nd(`R`,`M`,(e,t)=>{let n=td(t);e.renamed.push(n),e.modified.push(n.to)}),nd(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),nd(`?`,`?`,(e,t)=>e.not_added.push(t)),...rd(`A`,`A`,`U`),...rd(`D`,`D`,`U`),...rd(`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=Zo(s?.[1],rs,null),s=a.exec(t),e.tracking=Zo(s?.[1],rs,null),s=o.exec(t),s&&(e.current=Zo(s?.[1],rs,e.current)),e.detached=/\(no branch\)/.test(t)}]]),sd=function(e){let t=e.split(qo),n=new ad;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=qo+(t[e++]||``)),id(n,r))}return n}}});function ld(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!ud.includes(e))],parser(e){return sd(e)}}}var ud,dd=X({"src/lib/tasks/status.ts"(){cd(),ud=[`--null`,`-z`]}});function fd(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 pd(){return fd(0,0,0,``,!1)}function md(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:hd,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(gd));r(t)}})}}}function hd(e){return e===gd?pd():ws(fd(0,0,0,e),_d,e)}var gd,_d,vd=X({"src/lib/tasks/version.ts"(){Q(),gd=`installed=false`,_d=[new Z(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,fd(Vo(t),Vo(n),Vo(r),i))}),new Z(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,fd(Vo(t),Vo(n),r,i))})]}});function yd(e,t,n,...r){return rs(n)?t(n,Zo(r[0],rs),vs(arguments)):Ws(`git.${e}() requires a string 'repoPath'`)}function bd(){return{clone(e,...t){return this._runTask(yd(`clone`,xd,Zo(e,rs),...t),xs(arguments))},mirror(e,...t){return this._runTask(yd(`mirror`,Sd,Zo(e,rs),...t),xs(arguments))}}}var xd,Sd,Cd=X({"src/lib/tasks/clone.ts"(){Xs(),Q(),yo(),xd=(e,t,n)=>{let r=[`clone`,...n];return rs(e)&&r.push(ho(e)),rs(t)&&r.push(ho(t)),Gs(r)},Sd=(e,t,n)=>(Fo(n,`--mirror`),xd(e,t,n))}}),wd={};fo(wd,{SimpleGitApi:()=>Td});var Td,Ed=X({"src/lib/simple-git-api.ts"(){ol(),cl(),dl(),hl(),xl(),Cc(),Cl(),Fc(),Tl(),Pl(),du(),Bu(),Yu(),Zu(),dd(),Xs(),vd(),Q(),Cd(),Td=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&il(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(Gs([`add`,...Ro(e)]),xs(arguments))}cwd(e){let t=xs(arguments);return typeof e==`string`?this._runTask(sl(e,this._executor),t):typeof e?.path==`string`?this._runTask(sl(e.path,e.root&&this._executor||void 0),t):this._runTask(Ws(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(wl(e,t===!0),xs(arguments))}init(e){return this._runTask(Ml(e===!0,this._executor.cwd,vs(arguments)),xs(arguments))}merge(){return this._runTask(zu(vs(arguments)),xs(arguments))}mergeFromTo(e,t){return rs(e)&&rs(t)?this._runTask(zu([e,t,...vs(arguments)]),xs(arguments,!1)):this._runTask(Ws(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=Ju({remote:Zo(arguments[0],rs),branch:Zo(arguments[1],rs)},vs(arguments));return this._runTask(e,xs(arguments))}stash(){return this._runTask(Gs([`stash`,...vs(arguments)]),xs(arguments))}status(){return this._runTask(ld(vs(arguments)),xs(arguments))}},Object.assign(Td.prototype,ul(),bd(),bl(),xc(),pl(),Sl(),Ac(),lu(),Xu(),md())}}),Dd={};fo(Dd,{Scheduler:()=>kd});var Od,kd,Ad=X({"src/lib/runners/scheduler.ts"(){Q(),qc(),Od=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,ao.createDeferred)();return{promise:t,done:n,id:e}}})(),kd=class{constructor(e=2){this.concurrency=e,this.logger=Kc(``,`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=Fo(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),Lo(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=Fo(this.pending,Od());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),jd={};fo(jd,{applyPatchTask:()=>Md});function Md(e,t){return Gs([`apply`,...t,...e])}var Nd=X({"src/lib/tasks/apply-patch.ts"(){Xs()}});function Pd(e,t){return{branch:e,hash:t,success:!0}}function Fd(e){return{branch:e,hash:null,success:!1}}var Id,Ld=X({"src/lib/responses/BranchDeleteSummary.ts"(){Id=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function Rd(e,t){return t===1&&Bd.test(e)}var zd,Bd,Vd,Hd,Ud=X({"src/lib/parsers/parse-branch-delete.ts"(){Ld(),Q(),zd=/(\S+)\s+\(\S+\s([^)]+)\)/,Bd=/^error[^']+'([^']+)'/m,Vd=[new Z(zd,(e,[t,n])=>{let r=Pd(t,n);e.all.push(r),e.branches[t]=r}),new Z(Bd,(e,[t])=>{let n=Fd(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],Hd=(e,t)=>ws(new Id,Vd,[e,t])}}),Wd,Gd=X({"src/lib/responses/BranchSummary.ts"(){Wd=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 Kd(e){return e?e.charAt(0):``}function qd(e,t=!1){return ws(new Wd,t?[Yd]:Jd,e)}var Jd,Yd,Xd=X({"src/lib/parsers/parse-branch.ts"(){Gd(),Q(),Jd=[new Z(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(Kd(t),!0,n,r,i)}),new Z(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(Kd(t),!1,n,r,i)})],Yd=new Z(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),Zd={};fo(Zd,{branchLocalTask:()=>ef,branchTask:()=>$d,containsDeleteBranchCommand:()=>Qd,deleteBranchTask:()=>nf,deleteBranchesTask:()=>tf});function Qd(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function $d(e){let t=Qd(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?Hd(e,r).all[0]:qd(e,n)}}}function ef(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return qd(e)}}}function tf(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return Hd(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!Rd(String(n),e))return i(n);r(t)}}}function nf(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return Hd(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!Rd(String(i),e))return o(i);throw new So(n.parser(Uo(r),Uo(t)),String(i))}};return n}var rf=X({"src/lib/tasks/branch.ts"(){Co(),Ud(),Xd(),Q()}});function af(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&ue(t)}var of,sf=X({"src/lib/responses/CheckIgnore.ts"(){of=e=>e.split(/\n/g).map(af).filter(Boolean)}}),cf={};fo(cf,{checkIgnoreTask:()=>lf});function lf(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:of}}var uf=X({"src/lib/tasks/check-ignore.ts"(){sf()}});function df(e,t){return ws({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},ff,[e,t])}var ff,pf=X({"src/lib/parsers/parse-fetch.ts"(){Q(),ff=[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})})]}}),mf={};fo(mf,{fetchTask:()=>gf});function hf(e){return/^--upload-pack(=|$)/.test(e)}function gf(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(hf)?Ws(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:df}}var _f=X({"src/lib/tasks/fetch.ts"(){pf(),Xs()}});function vf(e){return ws({moves:[]},yf,e)}var yf,bf=X({"src/lib/parsers/parse-move.ts"(){Q(),yf=[new Z(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),xf={};fo(xf,{moveTask:()=>Sf});function Sf(e,t){return{commands:[`mv`,`-v`,...Ro(e),t],format:`utf-8`,parser:vf}}var Cf=X({"src/lib/tasks/move.ts"(){bf(),Q()}}),wf={};fo(wf,{pullTask:()=>Tf});function Tf(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 Nu(e,t)},onError(e,t,n,r){let i=Eu(Uo(e.stdOut),Uo(e.stdErr));if(i)return r(new So(i));r(t)}}}var Ef=X({"src/lib/tasks/pull.ts"(){Co(),Pu(),Q()}});function Df(e){let t={};return kf(e,([e])=>t[e]={name:e}),Object.values(t)}function Of(e){let t={};return kf(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 kf(e,t){No(e,e=>t(e.split(/\s+/)))}var Af=X({"src/lib/responses/GetRemoteSummary.ts"(){Q()}}),jf={};fo(jf,{addRemoteTask:()=>Mf,getRemotesTask:()=>Nf,listRemotesTask:()=>Pf,remoteTask:()=>Ff,removeRemoteTask:()=>If});function Mf(e,t,n){return Gs([`remote`,`add`,...n,e,t])}function Nf(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Of:Df}}function Pf(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),Gs(t)}function Ff(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),Gs(t)}function If(e){return Gs([`remote`,`remove`,e])}var Lf=X({"src/lib/tasks/remote.ts"(){Af(),Xs()}}),Rf={};fo(Rf,{stashListTask:()=>zf});function zf(e={},t){let n=su(e),r=[`stash`,`list`,...n.commands,...t],i=Yl(n.splitter,n.fields,Fl(r));return ru(r)||{commands:r,format:`utf-8`,parser:i}}var Bf=X({"src/lib/tasks/stash-list.ts"(){Rl(),eu(),iu(),du()}}),Vf={};fo(Vf,{addSubModuleTask:()=>Hf,initSubModuleTask:()=>Uf,subModuleTask:()=>Wf,updateSubModuleTask:()=>Gf});function Hf(e,t){return Wf([`add`,e,t])}function Uf(e){return Wf([`init`,...e])}function Wf(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),Gs(t)}function Gf(e){return Wf([`update`,...e])}var Kf=X({"src/lib/tasks/sub-module.ts"(){Xs()}});function qf(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?Jf(e,t):0:n?1:-1}function Jf(e,t){return e===t?0:e>t?1:-1}function Yf(e){return e.trim()}function Xf(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var Zf,Qf,$f=X({"src/lib/responses/TagList.ts"(){Zf=class{constructor(e,t){this.all=e,this.latest=t}},Qf=function(e,t=!1){let n=e.split(`
|
|
22
|
+
`).map(Yf).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return qf(Xf(n[0]),Xf(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=Jf(Xf(n[e]),Xf(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new Zf(n,r)}}}),ep={};fo(ep,{addAnnotatedTagTask:()=>rp,addTagTask:()=>np,tagListTask:()=>tp});function tp(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return Qf(e,t)}}}function np(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function rp(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var ip=X({"src/lib/tasks/tag.ts"(){$f()}}),ap=uo({"src/git.js"(e,t){var{GitExecutor:n}=(rl(),mo(tl)),{SimpleGitApi:r}=(Ed(),mo(wd)),{Scheduler:i}=(Ad(),mo(Dd)),{adhocExecTask:a,configurationErrorTask:o}=(Xs(),mo(Hs)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(Q(),mo(Es)),{applyPatchTask:g}=(Nd(),mo(jd)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(rf(),mo(Zd)),{checkIgnoreTask:x}=(uf(),mo(cf)),{checkIsRepoTask:S}=(Fs(),mo(Ds)),{cleanWithOptionsTask:C,isCleanOptionsArray:w}=(uc(),mo(Zs)),{diffSummaryTask:T}=(iu(),mo(tu)),{fetchTask:ee}=(_f(),mo(mf)),{moveTask:E}=(Cf(),mo(xf)),{pullTask:D}=(Ef(),mo(wf)),{pushTagsTask:O}=(Yu(),mo(Ku)),{addRemoteTask:te,getRemotesTask:k,listRemotesTask:A,remoteTask:ne,removeRemoteTask:j}=(Lf(),mo(jf)),{getResetMode:M,resetTask:N}=(Hc(),mo(Ic)),{stashListTask:P}=(Bf(),mo(Rf)),{addSubModuleTask:re,initSubModuleTask:F,subModuleTask:ie,updateSubModuleTask:I}=(Kf(),mo(Vf)),{addAnnotatedTagTask:L,addTagTask:R,tagListTask:z}=(ip(),mo(ep)),{straightThroughBufferTask:ae,straightThroughStringTask:B}=(Xs(),mo(Hs));function V(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(V.prototype=Object.create(r.prototype)).constructor=V,V.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},V.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},V.prototype.stashList=function(e){return this._runTask(P(h(arguments)||{},c(e)&&e||[]),m(arguments))},V.prototype.mv=function(e,t){return this._runTask(E(e,t),m(arguments))},V.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},V.prototype.pull=function(e,t,n,r){return this._runTask(D(f(e,u),f(t,u),p(arguments)),m(arguments))},V.prototype.fetch=function(e,t){return this._runTask(ee(f(e,u),f(t,u),p(arguments)),m(arguments))},V.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.")))},V.prototype.tags=function(e,t){return this._runTask(z(p(arguments)),m(arguments))},V.prototype.rebase=function(){return this._runTask(B([`rebase`,...p(arguments)]),m(arguments))},V.prototype.reset=function(e){return this._runTask(N(M(e),p(arguments)),m(arguments))},V.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(B([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},V.prototype.addTag=function(e){let t=typeof e==`string`?R(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},V.prototype.addAnnotatedTag=function(e,t){return this._runTask(L(e,t),m(arguments))},V.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},V.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},V.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},V.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},V.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(B(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},V.prototype.submoduleAdd=function(e,t,n){return this._runTask(re(e,t),m(arguments))},V.prototype.submoduleUpdate=function(e,t){return this._runTask(I(p(arguments,!0)),m(arguments))},V.prototype.submoduleInit=function(e,t){return this._runTask(F(p(arguments,!0)),m(arguments))},V.prototype.subModule=function(e,t){return this._runTask(ie(p(arguments)),m(arguments))},V.prototype.listRemote=function(){return this._runTask(A(p(arguments)),m(arguments))},V.prototype.addRemote=function(e,t,n){return this._runTask(te(e,t,p(arguments)),m(arguments))},V.prototype.removeRemote=function(e,t){return this._runTask(j(e),m(arguments))},V.prototype.getRemotes=function(e,t){return this._runTask(k(e===!0),m(arguments))},V.prototype.remote=function(e,t){return this._runTask(ne(p(arguments)),m(arguments))},V.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(B(n),m(arguments))},V.prototype.updateServerInfo=function(e){return this._runTask(B([`update-server-info`]),m(arguments))},V.prototype.pushTags=function(e,t){let n=O({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},V.prototype.rm=function(e){return this._runTask(B([`rm`,`-f`,...s(e)]),m(arguments))},V.prototype.rmKeepLocal=function(e){return this._runTask(B([`rm`,`--cached`,...s(e)]),m(arguments))},V.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},V.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},V.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`?ae(r):B(r);return this._runTask(a,n)},V.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`):B([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},V.prototype.diffSummary=function(){return this._runTask(T(p(arguments,1)),m(arguments))},V.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))},V.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(B(e,!0),m(arguments))},V.prototype.clean=function(e,t,n){let r=w(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(C(i,a),m(arguments))},V.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},V.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.`)))},V.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},V.prototype.checkIsRepo=function(e,t){return this._runTask(S(f(e,u)),m(arguments))},t.exports=V}});yo(),xo();var op=class extends bo{constructor(e,t){super(void 0,t),this.config=e}};xo(),xo();var sp=class extends bo{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};Co(),To(),Fs(),uc(),Cc(),Dc(),Fc(),Hc();function cp(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new sp(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new sp(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function lp(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function up(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 dp(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&lp(i)&&r.test(a))throw new sp(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var fp=[dp(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),dp(`core.sshCommand`,`allowUnsafeSshCommand`),dp(`core.gitProxy`,`allowUnsafeGitProxy`),dp(`core.hooksPath`,`allowUnsafeHooksPath`),dp(`diff.external`,`allowUnsafeDiffExternal`)];function pp(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new sp(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&up(`u`,e))throw new sp(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 sp(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function mp({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||pp(i,r.method),fp.forEach(e=>e(t,i,o))}),n}}}Q();function hp(e){let t=Ho(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}Q();var gp=(0,ao.deferred)().promise;function _p({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,ao.deferred)(),closeTimeout:(0,ao.deferred)(),exit:(0,ao.deferred)(),exitTimeout:(0,ao.deferred)()},a=Promise.race([e===!1?gp:i.closeTimeout.promise,t===!1?gp: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(()=>Go(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 Go(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}Q();var vp=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,yp=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function bp(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function xp(e,t){if(e.length<1||e.length>2)throw new sp(void 0,`binary`,vp);if(e.some(bp))if(t)console.warn(yp);else throw new sp(void 0,`binary`,yp);let[n,r]=e;return{binary:n,prefix:r}}function Sp(e,t=[`git`],n=!1){let r=xp(Ro(t),n);e.on(`binary`,e=>{r=xp(Ro(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}xo();function Cp(e){return!!(e.exitCode&&e.stdErr.length)}function wp(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function Tp(e=!1,t=Cp,n=wp){return(r,i)=>!e&&r||!t(i)?r:n(i)}function Ep(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 bo(void 0,r.toString(`utf-8`))}:{error:r}}}}Q();var Dp=class{constructor(){this.plugins=new Set,this.events=new Ee}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=Fo(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return Ro(e).forEach(e=>e&&this.plugins.add(Fo(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 Op(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?Io(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:kp(n[1]),progress:Vo(n[2]),processed:Vo(n[3]),total:Vo(n[4])})})}}]}function kp(e){return String(e.toLowerCase().split(` `,1))||`unknown`}Q();function Ap(e){let t=Wo(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function jp({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 sp(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()}}}yo();function Mp(){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(go(i)){r(_o(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>go(e)&&_o(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}Q();var Np=ap();function Pp(e,t){let n=new Dp,r=ms(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!Po(r.baseDir))throw new op(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(hp(r.config)),n.add(mp(r.unsafe)),n.add(_p(r.completion)),r.abort&&n.add(cp(r.abort)),r.progress&&n.add(Op(r.progress)),r.timeout&&n.add(jp(r.timeout)),r.spawnOptions&&n.add(Ap(r.spawnOptions)),n.add(Mp()),n.add(Ep(Tp(!0))),r.errors&&n.add(Ep(r.errors)),Sp(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new Np(r,n)}Co();var Fp=Pp;const Ip=`.expect`,Lp=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`,`.cts`,`.cjs`],Rp=new Set([`node_modules`,`dist`,`build`,`.git`,`.next`,`.turbo`,`coverage`,`.nyc_output`,`.cache`,`.repos`,`.specs`,`__snapshots__`,`__fixtures__`]);var zp=class extends x.ErrorClass(`GitError`)({_tag:x.tag(`GitError`),operation:x.String,cause:x.Defect}){message=`Git error during "${this.operation}"`},Bp=class extends x.ErrorClass(`FindRepoRootError`)({_tag:x.tag(`FindRepoRootError`),cause:x.Defect}){message=`Could not find git repository root`},Vp=class extends S.Service()(`@supervisor/GitRepoRoot`){},Hp=class e extends S.Service()(`@supervisor/Git`,{make:l.gen(function*(){let e=yield*f.FileSystem,t=e=>l.gen(function*(){let t=yield*Vp;return yield*l.tryPromise({try:()=>Fp(t).raw(e.args),catch:t=>new zp({operation:e.operation,cause:t})}).pipe(l.map(e.trim?J.trim:be.identity))}),n=e=>l.tryPromise({try:()=>Fp(e).revparse([`--show-toplevel`]),catch:e=>new Bp({cause:e})}).pipe(l.map(J.trim)),r=e=>t=>l.gen(function*(){let r=yield*n(e);return yield*t.pipe(l.provideService(Vp,r))}),i=t({args:[`symbolic-ref`,`refs/remotes/origin/HEAD`],operation:`getting main branch`,trim:!0}).pipe(l.map(e=>e.replace(`refs/remotes/origin/`,``)),l.catchTag(`GitError`,()=>t({args:[`revparse`,`--verify`,`origin/main`],operation:`getting main branch (origin/main)`,trim:!0}).pipe(l.as(`main`))),l.catchTag(`GitError`,()=>t({args:[`rev-parse`,`--verify`,`main`],operation:`getting main branch (main)`,trim:!0}).pipe(l.as(`main`))),l.catchTag(`GitError`,()=>l.succeed(`main`))),a=t({args:[`rev-parse`,`--abbrev-ref`,`HEAD`],operation:`getting current branch`,trim:!0}).pipe(l.catchTag(`GitError`,()=>l.succeed(`HEAD`))),o=t({args:[`rev-parse`,`--is-inside-work-tree`],operation:`checking if inside work tree`,trim:!0}).pipe(l.map(e=>e===`true`),l.catchTag(`GitError`,()=>l.succeed(!1))),s=e=>{let[t,n,r]=e.split(` `);return new sn({relativePath:r??``,added:Number.parseInt(t??`0`,10)||0,removed:Number.parseInt(n??`0`,10)||0})},c=l.fn(`Git.getFileStats`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`,`--numstat`],operation:`getting working tree file stats`}).pipe(l.map(J.split(`
|
|
23
|
+
`)),l.map(ye.map(J.trim)),l.map(ye.filter(J.isNonEmpty)),l.map(ye.map(s)),l.catchTag(`GitError`,()=>l.succeed([]))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`,`--numstat`],operation:`getting file stats`}).pipe(l.map(J.split(`
|
|
24
|
+
`)),l.map(ye.map(J.trim)),l.map(ye.filter(J.isNonEmpty)),l.map(ye.map(s)),l.catchTag(`GitError`,()=>l.succeed([])))}),u=e=>e===`A`?`A`:e===`D`?`D`:e===`R`?`R`:e===`C`?`C`:e===`?`?`?`:`M`,d=l.fn(`Git.getChangedFiles`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`status`,`--porcelain`],operation:`getting working tree changes`}).pipe(l.map(J.split(`
|
|
25
|
+
`)),l.map(ye.filter(J.isNonEmpty)),l.map(ye.map(e=>{let t=e.at(0)??`M`;return{path:e.slice(3).trim(),status:u(t)}})),l.catchTag(`GitError`,()=>l.succeed([]))):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.map(J.split(`
|
|
26
|
+
`)),l.map(ye.map(J.trim)),l.map(ye.filter(J.isNonEmpty)),l.map(ye.map(e=>{let t=e.split(` `),n=(t[0]??`M`).at(0)??`M`;return{path:(n===`R`||n===`C`?t[2]:t[1])??``,status:u(n)}})),l.catchTag(`GitError`,()=>l.succeed([])))}),p=l.fn(`Git.getDiffPreview`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`],operation:`getting diff preview`,trim:!0}).pipe(l.catchTag(`GitError`,()=>l.succeed(``))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`],operation:`getting diff preview`,trim:!0}).pipe(l.catchTag(`GitError`,()=>l.succeed(``)))}),m=l.fn(`Git.getRecentCommits`)(function*(e){return yield*t({args:[`log`,`--format=%H %h %s`,e],operation:`getting recent commits`,trim:!0}).pipe(l.map(J.split(`
|
|
27
|
+
`)),l.map(ye.map(J.trim)),l.map(ye.filter(J.isNonEmpty)),l.map(ye.map(e=>{let[t,n,...r]=e.split(` `);return{hash:t??``,shortHash:n??``,subject:r.join(` `)}})),l.catchTag(`GitError`,()=>l.succeed([])))}),h=l.fn(`Git.getCommitSummary`)(function*(e){return yield*t({args:[`log`,`-1`,`--format=%H %h %s`,e],operation:`getting commit summary`,trim:!0}).pipe(l.map(e=>{let[t,n,...r]=e.split(` `);if(!(!t||!n))return{hash:t,shortHash:n,subject:r.join(` `)}}),l.catchTag(`GitError`,()=>l.succeed(void 0)))}),g=l.fn(`Git.computeFingerprint`)(function*(){let e=yield*t({args:[`rev-parse`,`HEAD`],operation:`getting HEAD for fingerprint`,trim:!0}).pipe(l.catchTag(`GitError`,()=>l.succeed(``)));if(!e)return;let n=yield*t({args:[`diff`],operation:`getting unstaged diff for fingerprint`}).pipe(l.catchTag(`GitError`,()=>l.succeed(``))),r=yield*t({args:[`diff`,`--cached`],operation:`getting staged diff for fingerprint`}).pipe(l.catchTag(`GitError`,()=>l.succeed(``)));return xe.createHash(`sha256`).update(e).update(`\0`).update(n).update(`\0`).update(r).digest(`hex`)}),_=l.fn(`ensureStateDir`)(function*(t){let n=K.join(t,Ip);yield*e.makeDirectory(n,{recursive:!0}).pipe(l.catchTag(`PlatformError`,()=>l.void));let r=K.join(n,`.gitignore`);return(yield*e.exists(r).pipe(l.catchTag(`PlatformError`,()=>l.succeed(!1))))||(yield*e.writeFileString(r,`*
|
|
28
|
+
`).pipe(l.catchTag(`PlatformError`,()=>l.void))),n}),v=l.gen(function*(){let e=yield*_(yield*Vp);return K.join(e,`last-tested`)}),y=l.fn(`Git.loadSavedFingerprint`)(function*(){let t=yield*v;return yield*e.readFileString(t).pipe(l.map(J.trim),l.catchTag(`PlatformError`,()=>l.succeed(void 0)))}),b=l.fn(`Git.saveTestedFingerprint`)(function*(){let t=yield*g();if(!t)return;let n=yield*v;yield*e.writeFileString(n,t)});return{withRepoRoot:r,getMainBranch:i,getCurrentBranch:a,isInsideWorkTree:o,getFileStats:c,getChangedFiles:d,getDiffPreview:p,getRecentCommits:m,getCommitSummary:h,getState:l.fn(`Git.getState`)(function*(){if(!(yield*o))return new cn({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*l.all([a,i,g(),y()],{concurrency:`unbounded`}),s=e===t,[u,d,f]=yield*l.all([c(dn.makeUnsafe({_tag:`Changes`,mainBranch:t})),c(dn.makeUnsafe({_tag:`WorkingTree`})),m(`${t}..HEAD`)],{concurrency:`unbounded`});return new cn({isGitRepo:!0,currentBranch:e,mainBranch:t,isOnMain:s,hasChangesFromMain:u.length>0,hasUnstagedChanges:d.length>0,hasBranchCommits:f.length>0,branchCommitCount:f.length,fileStats:u,workingTreeFileStats:d,fingerprint:n,savedFingerprint:r})}),computeFingerprint:g,saveTestedFingerprint:b}})}){static layer=p.effect(this)(this.make).pipe(p.provide(ve.layer));static withRepoRoot=t=>{let n=p.effect(Vp)(l.tryPromise({try:()=>Fp(t).revparse([`--show-toplevel`]),catch:e=>new Bp({cause:e})}).pipe(l.map(e=>e.trim())));return p.mergeAll(e.layer.pipe(p.provide(n)),n)}},Up=class extends x.ErrorClass(`@supervisor/ExecutionError`)({_tag:x.tag(`ExecutionError`),reason:x.Union([Aa,Na,ja,Ma])}){displayName=this.reason.displayName??`Browser testing failed`;message=this.reason.message},Wp=class extends S.Service()(`@supervisor/Executor`,{make:l.gen(function*(){let e=yield*Ra,t=yield*Hp,n=l.fn(`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:l.fn(`Executor.execute`)(function*(t){let i=yield*n(t.changesFor),a=Ka({userInstruction:t.instruction,scope:t.changesFor._tag,currentBranch:i.currentBranch,mainBranch:i.mainBranch,changedFiles:i.changedFiles,recentCommits:i.recentCommits,diffPreview:i.diffPreview,baseUrl:t.baseUrl,isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,savedFlow:t.savedFlow,learnings:t.learnings,testCoverage:t.testCoverage}),o=un.makeUnsafe(crypto.randomUUID()),s=K.join(process.cwd(),Ip,`replays`,`${o}.ndjson`),c=new Sn({id:o,changesFor:t.changesFor,currentBranch:i.currentBranch,diffPreview:i.diffPreview,fileStats:[],instruction:t.instruction,baseUrl:t.baseUrl?g.some(t.baseUrl):g.none(),isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,testCoverage:t.testCoverage?g.some(t.testCoverage):g.none(),title:t.instruction,rationale:`Direct execution`,steps:[]}),l=new Kn({...c,events:[new Cn({plan:c})]}),u=[{name:`EXPECT_REPLAY_OUTPUT_PATH`,value:s}];t.liveViewUrl&&u.push({name:r,value:t.liveViewUrl});let d=new Xn({cwd:process.cwd(),sessionId:g.none(),prompt:a,systemPrompt:g.none(),mcpEnv:u});return e.stream(d).pipe(C.mapAccum(()=>l,(e,t)=>{let n=e.addEvent(t);return[n,[n]]}),C.mapError(e=>new Up({reason:e})))},C.unwrap)}})}){static layer=p.effect(this)(this.make).pipe(p.provide(ve.layer))},Gp=class extends S.Service()(`@supervisor/Reporter`,{make:l.gen(function*(){return{report:l.fn(`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 qn({...e,summary:i,screenshotPaths:a,pullRequest:g.none(),testCoverageReport:e.testCoverage})})}})}){static layer=p.effect(this)(this.make)};const Kp=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
|
+
`)},qp=e=>`---\n${Kp(e)}\n---\n`,Jp=e=>e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e,Yp=e=>_.isObject(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.instruction==`string`&&typeof e.expectedOutcome==`string`,Xp=e=>_.isObject(e)?{title:typeof e.title==`string`?e.title:``,userInstruction:typeof e.userInstruction==`string`?e.userInstruction:``,steps:Array.isArray(e.steps)?e.steps.filter(Yp):[]}:{title:``,userInstruction:``,steps:[]},Zp=e=>_.isObject(e)?{baseUrl:typeof e.baseUrl==`string`?e.baseUrl:``,cookies:typeof e.cookies==`boolean`?e.cookies:!1}:{baseUrl:``,cookies:!1},Qp=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:Jp(r.get(`title`)??``),description:Jp(r.get(`description`)??``),slug:Jp(r.get(`slug`)??``),savedTargetScope:Jp(r.get(`saved_target_scope`)??``),savedTargetDisplayName:Jp(r.get(`saved_target_display_name`)??``),flow:Xp(JSON.parse(r.get(`flow`)??`{}`)),environment:Zp(JSON.parse(r.get(`environment`)??`{}`))},a=r.get(`selected_commit`);return a!==void 0&&(i.selectedCommit=Jp(a)),i},$p=l.fn(`ensureStateDir`)(function*(e,t){let n=K.join(t,Ip);yield*e.makeDirectory(n,{recursive:!0}).pipe(l.catchTag(`PlatformError`,()=>l.void));let r=K.join(n,`.gitignore`);return(yield*e.exists(r).pipe(l.catchTag(`PlatformError`,()=>l.succeed(!1))))||(yield*e.writeFileString(r,`*
|
|
31
|
+
`).pipe(l.catchTag(`PlatformError`,()=>l.void))),n}),em=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),tm=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:em(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:fn(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=g.getOrElse(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:g.getOrElse(e.baseUrl,()=>``),cookies:e.requiresCookies}});var nm=class extends S.Service()(`@supervisor/FlowStorage`,{make:l.gen(function*(){let e=yield*f.FileSystem,t=l.gen(function*(){let t=yield*$p(e,yield*Vp);return K.join(t,`flows`)});return{save:l.fn(`FlowStorage.save`)(function*(n){let r=tm(n),i=yield*t,a=K.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(l.catchTag(`PlatformError`,()=>l.void)),yield*e.writeFileString(a,qp(r)),yield*l.logInfo(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:l.fn(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(l.catchTag(`PlatformError`,()=>l.succeed(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(l.catchTag(`PlatformError`,()=>l.succeed([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(K.join(n,t)).pipe(l.catchTag(`PlatformError`,()=>l.succeed(``)));if(!r)continue;let a=yield*l.try({try:()=>Qp(r),catch:()=>({_tag:`FlowParseError`})}).pipe(l.catchTag(`FlowParseError`,()=>l.succeed(void 0)));a&&i.push(a)}return yield*l.logDebug(`Flows listed`,{count:i.length}),i})}})}){static layer=p.effect(this)(this.make).pipe(p.provide(ve.layer))};const rm=(e,t)=>{try{return V(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var im=class extends x.ErrorClass(`GitHubCommandError`)({_tag:x.tag(`GitHubCommandError`),cause:x.String}){message=`GitHub CLI command failed: ${this.cause}`},am=class extends S.Service()(`@supervisor/GitHub`,{make:l.gen(function*(){let e=yield*je,t=yield*De,n=l.fn(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(he.make(`gh`,n,{cwd:t})).pipe(l.timeout(15e3),l.catchTags({PlatformError:e=>l.fail(new im({cause:e.message})),TimeoutError:()=>l.fail(new im({cause:`command timed out`}))}),l.map(e=>e.trim()))}),r=l.fn(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,h.value(t).pipe(h.when({_tag:`Branch`},e=>e.branchName),h.exhaustive),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*x.decodeEffect(x.fromJsonString(x.Array(zn)))(r).pipe(l.map(a.head),l.catchTag(`SchemaError`,()=>l.succeed(g.none())))}),i=x.fromJsonString(x.Array(pn));return{findPullRequest:r,listPullRequests:l.fn(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(l.catchTag(`GitHubCommandError`,()=>l.succeed(`[]`)));return(yield*x.decodeEffect(i)(t).pipe(l.catchTag(`SchemaError`,l.die))).map(e=>new hn({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.fn(`GitHub.addComment`)(function*(e,r,i){yield*l.scoped(l.gen(function*(){let a=le(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=p.effect(this)(this.make).pipe(p.provide(ve.layer))};const om=e=>K.join(Oe.homedir(),Ip,`${e}.json`),sm=new Map,cm={getItem:async e=>{try{let t=await Ne.readFile(om(e),`utf-8`);return sm.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(sm.get(e)===t)return;sm.set(e,t);let n=om(e);await Ne.mkdir(K.dirname(n),{recursive:!0}),await Ne.writeFile(n,t,`utf-8`)},removeItem:async e=>{sm.delete(e);try{await Ne.unlink(om(e))}catch{}}},lm=e=>K.join(process.cwd(),Ip,`${e}.json`),um=new Map,dm={getItem:async e=>{try{let t=await Ne.readFile(lm(e),`utf-8`);return um.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(um.get(e)===t)return;um.set(e,t);let n=lm(e);await Ne.mkdir(K.dirname(n),{recursive:!0}),await Ne.writeFile(n,t,`utf-8`)},removeItem:async e=>{um.delete(e);try{await Ne.unlink(lm(e))}catch{}}};var fm=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`]}})),pm=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)})),mm=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=fm().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=pm()}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 hm=[/from\s+["']([^"']+)["']/g,/import\s*\(\s*["']([^"']+)["']\s*\)/g,/require\s*\(\s*["']([^"']+)["']\s*\)/g],gm=/\.(?:test|spec|e2e)\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,_m=/(?:^|[/\\])(?:__tests?__|tests?)[/\\]/,vm=/\.(?:ts|tsx|js|jsx|mts|mjs|cts|cjs)$/,ym=e=>{let t=K.extname(e).toLowerCase();return Lp.includes(t)},bm=e=>e.split(/[/\\]/).some(e=>Rp.has(e)),xm=e=>!!(gm.test(e)||_m.test(e)&&vm.test(e)),Sm=e=>{let t=[];for(let n of hm){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},Cm=(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},wm=e=>l.tryPromise({try:()=>new Promise(t=>{B(`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:()=>[]}),Tm=e=>{try{return new mm.ResolverFactory({tsconfig:{configFile:K.join(e,`tsconfig.json`),references:`auto`},extensions:[...Lp],mainFields:[`module`,`main`],conditionNames:[`import`,`require`,`default`]})}catch{return}},Em=(e,t,n)=>{try{return e.sync(t,n).path??void 0}catch{return}},Dm=(e,t,n)=>l.gen(function*(){let r=t.filter(e=>ym(e)&&!bm(e)),i=Tm(e);if(!i)return new Map;let a=new Map;return yield*l.forEach(r,t=>l.gen(function*(){let r=K.join(e,t),o=yield*n.readFileString(r).pipe(l.catchTag(`PlatformError`,()=>l.succeed(``)));if(!o)return;let s=Sm(o),c=new Set;for(let t of s)if(t.startsWith(`.`)||t.startsWith(`@`)||t.startsWith(`~`)){let n=Em(i,K.dirname(r),t);if(n){let t=K.relative(e,n);bm(t)||c.add(t)}}c.size>0&&a.set(t,c)}),{concurrency:50}),a}),Om=e=>e.filter(e=>!bm(e)&&xm(e)).slice(0,200);var km=class extends S.Service()(`@supervisor/TestCoverage`,{make:l.gen(function*(){let e=yield*f.FileSystem;return{analyze:l.fn(`TestCoverage.analyze`)(function*(t){yield*l.annotateCurrentSpan({changedFileCount:t.length});let n=yield*Vp,r=yield*wm(n),i=Om(r),a=yield*Dm(n,r,e),o=new Map;for(let e of i){let t=Cm(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=>vm.test(e.path)&&!xm(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}}),u=c.filter(e=>e.covered).length,d=s.length,f=d>0?Math.round(u/d*100):100;return yield*l.logInfo(`Test coverage analyzed`,{coveredCount:u,totalCount:d,percent:f,testFileCount:i.length,graphEdgeCount:a.size}),{entries:c,coveredCount:u,totalCount:d,percent:f}})}})}){static layer=p.effect(this)(this.make).pipe(p.provide(ve.layer))};const Am=e=>e.pipe(l.provide(am.layer)),jm=async e=>{let t=[];if(e.hasUntestedChanges&&t.push(Bn.makeUnsafe({_tag:`WorkingTree`})),e.mainBranch){let n=process.cwd(),r=await l.runPromise(l.gen(function*(){return yield*(yield*Hp).getRecentCommits(`${e.mainBranch}..HEAD`)}).pipe(l.provide(Hp.withRepoRoot(n))));for(let e of r)t.push(Bn.makeUnsafe({_tag:`Commit`,hash:e.hash,shortHash:e.shortHash,subject:e.subject}))}return t},Mm=e=>l.runPromise(Am(am.use(t=>t.listPullRequests(e)))),Nm=async e=>{let t=await Mm(process.cwd()),n=t.filter(e=>e.prNumber!==null&&e.prStatus===`open`).map(e=>Bn.makeUnsafe({_tag:`PullRequest`,branch:e})),r=t.filter(e=>e.prNumber!==null&&e.prStatus===`merged`).slice(0,5).map(e=>Bn.makeUnsafe({_tag:`PullRequest`,branch:e})),i=t.filter(t=>t.name!==e.currentBranch&&t.prNumber===null).map(e=>Bn.makeUnsafe({_tag:`Branch`,branch:e}));return[...n,...r,...i]},Pm=(e,t)=>e._tag===`WorkingTree`&&t&&!t.isOnMain?t.currentBranch:Un(e),Fm=(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 Wn(e)},Im=(e,t)=>e._tag===`WorkingTree`?Pm(e,t):Gn(e),Lm=(e,t,n)=>{if(!t)return[...e];let r=t.toLowerCase();return e.filter(e=>(e._tag===`WorkingTree`?`local changes ${n?.currentBranch??``}`:Hn(e)).toLowerCase().includes(r))},Rm=()=>M({queryKey:[`remote-branches`],queryFn:()=>Mm(process.cwd())}),zm=e=>{let t=N(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=kt(),i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=H(Ie,{type:`dots`}),t[1]=i):i=t[1];let a;t[2]===r.SELECTION?a=t[3]:(a=H(E,{color:r.SELECTION,children:i}),t[2]=r.SELECTION,t[3]=a);let o;t[4]===n?o=t[5]:(o=n?U(E,{children:[` `,n]}):null,t[4]=n,t[5]=o);let s;return t[6]!==r.DIM||t[7]!==a||t[8]!==o?(s=U(E,{color:r.DIM,children:[a,o]}),t[6]=r.DIM,t[7]=a,t[8]=o,t[9]=s):s=t[9],s},Bm=(e,t)=>{let n=Math.max(0,t-Re(e));return e+` `.repeat(n)},Vm=({itemCount:e,visibleCount:t,initialIndex:n})=>{let[r,i]=R(n??0),a=L(e);return a.current!==e&&(a.current=e,i(t=>Math.min(t,Math.max(0,e-1)))),{highlightedIndex:r,setHighlightedIndex:i,scrollOffset:I(()=>{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:re((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])}},Hm=/(?:https?:\/\/|localhost[:/]|[\w-]+\.[\w-]+\.[\w]+|[\w-]+\.(com|org|net|io|dev|app|co|me|ai))\S*/i,Um=e=>Hm.test(e),Wm=Be.taggedEnum(),Gm=e=>Um(e.instruction)?Wm.Testing(e):Wm.PortPicker(e),Km=ze(e=>({screen:Wm.Main(),previousScreen:Wm.Main(),navigateTo:t=>e(e=>({screen:t,previousScreen:e.screen})),setScreen:t=>e({screen:t})})),qm=new A({defaultOptions:{queries:{staleTime:1/0,retry:!1}}}),Jm=e=>{let t=N(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]=Dt(),s,c,l;t[1]!==r||t[2]!==n?(l=n.toUpperCase(),s=r?` │ ${r}`:``,c=Re(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+Re(s),d=a?Math.max(0,o-u-3):0,f;t[6]===l?f=t[7]:(f=H(E,{bold:!0,color:Y.text,children:l}),t[6]=l,t[7]=f);let p;t[8]!==r||t[9]!==s?(p=r?H(E,{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?U(E,{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=U(E,{children:[f,p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h},Ym=()=>{let e=N(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]=Dt(),n=Km(Xm),r=kt(),[i,a]=R(null),[o,s]=R(``),[c,l]=R(`recent`),[u,d]=R(!1),[f,p]=R(void 0),{data:m,isLoading:h}=Rm(),g=m===void 0?[]:m,_=hn.filterBranches(g,c,o),{highlightedIndex:v,setHighlightedIndex:y,scrollOffset:b,handleNavigation:x}=Vm({itemCount:_.length,visibleCount:15}),S=t-2-32-16-2,C=_.slice(b,b+15),w;e[1]===y?w=e[2]:(w=e=>{s(wt(e)),y(0)},e[1]=y,e[2]=w);let ee=w,D;e[3]===n?D=e[4]:(D=e=>{rm(process.cwd(),e)?(p(void 0),qm.invalidateQueries({queryKey:[`git-state`]}),n(Wm.Main())):p(`Could not checkout "${e}". You may have uncommitted changes or the branch may not exist locally.`)},e[3]=n,e[4]=D);let O=D,k;e[5]!==c||e[6]!==y?(k=e=>{l(mn[(mn.indexOf(c)+e+mn.length)%mn.length]),y(0)},e[5]=c,e[6]=y,e[7]=k):k=e[7];let A=k;te((e,t)=>{if(u){t.escape&&d(!1);return}if(!x(e,t)){if(t.rightArrow&&A(1),t.leftArrow&&A(-1),t.return){let e=_[v];e&&(p(void 0),O(e.name))}e===`/`&&d(!0)}});let ne;e[8]!==i||e[9]!==O?(ne=(e,t)=>{i&&(e.toLowerCase()===`y`&&(p(void 0),O(i.name),a(null)),(e.toLowerCase()===`n`||t.escape)&&a(null))},e[8]=i,e[9]=O,e[10]=ne):ne=e[10];let j=i!==null,M;e[11]===j?M=e[12]:(M={isActive:j},e[11]=j,e[12]=M),te(ne,M);let P=T,re=`${_.length} branches`,F;e[13]===re?F=e[14]:(F=H(T,{paddingX:1,children:H(Jm,{title:`Select a PR or branch to test`,subtitle:re})}),e[13]=re,e[14]=F);let ie;e[15]!==r||e[16]!==c||e[17]!==y?(ie=mn.map((e,t)=>{let n=e===c,i=t<mn.length-1?` · `:``,a={recent:r.CYAN,all:r.TEXT,open:r.GREEN,draft:r.DIM,merged:r.PURPLE,"no-pr":r.YELLOW};return U(T,{children:[H(Mt,{fullWidth:!1,onClick:()=>{l(e),y(0)},children:H(E,{color:n?a[e]:r.DIM,children:n?`[${e}]`:e})}),H(E,{color:r.DIM,children:i})]},e)}),e[15]=r,e[16]=c,e[17]=y,e[18]=ie):ie=e[18];let I;e[19]===ie?I=e[20]:(I=H(T,{marginTop:1,paddingX:1,children:ie}),e[19]=ie,e[20]=I);let L=h?H(T,{marginTop:1,paddingX:1,children:H(zm,{message:`Fetching PRs...`})}):U(T,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:[C.map((e,t)=>{let n=t+b,i=n===v;return U(Mt,{onClick:()=>{y(n),O(e.name)},children:[H(E,{color:i?r.PRIMARY:r.DIM,children:i?`${W.pointer} `:` `}),H(E,{color:i?r.PRIMARY:r.DIM,bold:i,children:Bm(Le(e.name,31),32)}),H(E,{color:r.CYAN,children:Bm(Le(e.author||`—`,15),16)}),e.prNumber&&e.prStatus?H(E,{color:e.prStatus===`open`?r.GREEN:e.prStatus===`merged`?r.PURPLE:r.DIM,children:Le(`#${e.prNumber} ${e.prStatus}`,S)}):H(E,{color:r.DIM,children:`—`})]},e.name)}),_.length===0&&H(E,{color:r.DIM,children:`No matching branches`})]}),z;e[21]!==r||e[22]!==f?(z=f?H(T,{marginTop:1,paddingX:1,children:H(E,{color:r.RED,children:f})}):null,e[21]=r,e[22]=f,e[23]=z):z=e[23];let ae;e[24]!==r||e[25]!==i?(ae=i?U(At,{color:r.YELLOW,marginTop:1,children:[U(E,{color:r.YELLOW,bold:!0,children:[`Switch to `,i.name,`?`]}),U(E,{color:r.DIM,children:[`Press `,H(E,{color:r.PRIMARY,children:`y`}),` to continue or`,` `,H(E,{color:r.PRIMARY,children:`n`}),` to cancel.`]})]}):null,e[24]=r,e[25]=i,e[26]=ae):ae=e[26];let B;e[27]!==ee||e[28]!==u||e[29]!==o?(B=H(T,{paddingX:1,children:H(zt,{isSearching:u,query:o,onChange:ee})}),e[27]=ee,e[28]=u,e[29]=o,e[30]=B):B=e[30];let V;return e[31]!==P||e[32]!==F||e[33]!==I||e[34]!==L||e[35]!==z||e[36]!==ae||e[37]!==B?(V=U(P,{flexDirection:`column`,width:`100%`,paddingY:1,children:[F,I,L,z,ae,B]}),e[31]=P,e[32]=F,e[33]=I,e[34]=L,e[35]=z,e[36]=ae,e[37]=B,e[38]=V):V=e[38],V};function Xm(e){return e.setScreen}const Zm=ce.join(process.cwd(),`.expect`,`logs.md`),Qm=m.formatLogFmt.pipe(m.toFile(Zm)),$m=p.effectDiscard(l.gen(function*(){let e=yield*f.FileSystem;yield*e.makeDirectory(ce.dirname(Zm),{recursive:!0}),yield*e.writeFileString(ce.join(ce.dirname(Zm),`.gitignore`),`*
|
|
33
|
+
`)})),eh=p.mergeAll($m,m.layer([Qm])).pipe(p.provide(_e.layer));var th=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 S,C,w,T=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)}},ee=t+` Iterator`,E=y==g,D=!1,O=e.prototype,te=O[f]||O[m]||y&&O[y],k=te||T(y),A=y?E?T(`entries`):k:void 0,ne=t==`Array`&&O.entries||te;if(ne&&(w=d(ne.call(new e)),w!==Object.prototype&&(u(w,ee,!0),r||s(w,f)||o(w,f,_))),E&&te&&te.name!==g&&(D=!0,k=function(){return te.call(this)}),r&&!x||!p&&!D&&O[f]||o(O,f,k),c[t]=k,c[ee]=_,y)if(S={values:E?k:T(g),keys:b?k:T(h),entries:A},x)for(C in S)C in O||a(O,C,S[C]);else i(i.P+i.F*(p||D),t,S);return S}},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,S=l(b)==`process`,C=function(){},w=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(C,C)};return(S||typeof PromiseRejectionEvent==`function`)&&e.then(C)instanceof t}catch{}}(),T=function(e,t){return e===t||e===x&&t===a},ee=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},E=function(e){return T(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&&ne(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=ee(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&&k(e)})}},k=function(e){g.call(s,function(){var t,n,r,i=e._v;if(A(e)&&(t=O(function(){S?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=S||A(e)?2:1),e._a=void 0,t)throw t.error})},A=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||!A(t.promise))return!1;return!0},ne=function(e){g.call(s,function(){var t;S?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))},M=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=ee(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(M,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)}}};w||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(M,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=S?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(M,e,1),this.reject=c(j,e,1)}),u(u.G+u.W+u.F*!w,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!w,v,{reject:function(e){var t=E(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!w),v,{resolve:function(e){if(e instanceof x&&T(e.constructor,this))return e;var t=E(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(w&&n(46)(function(e){x.all(e).catch(C)})),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 nh(e){return typeof e==`string`?`'${e}'`:new rh().serialize(e)}const rh=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}(),ih=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,ah=`sha256`,oh=`base64url`;function sh(e){if(ih)return ih(ah,e,oh);let t=Se(ah).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(oh):t.digest(oh)}function ch(e){return sh(nh(e))}function lh(){let e=uh();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function uh(e=process.argv[1]?Ve(process.argv[1]):process.cwd(),t=Ue===`\\`){let n=t?dh(e):e;return e=>{if(!e)return;let r=t?dh(e):e,{dir:i,base:a,ext:o}=He.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 dh(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const fh=e=>{if(`flags`in e){let t=mh(e.flags),n=hh(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,_h(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,ph(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function ph(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 mh=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,gh(t)]).filter(([,e])=>e!==void 0)),hh=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?_h(n):void 0]}))},gh=e=>e===void 0?void 0:e.variant??e.enabled,_h=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},vh=`0123456789abcdef`;var yh=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+=vh.charAt(this.bytes[t]>>>4),e+=vh.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+=vh.charAt(this.bytes[t]>>>4),e+=vh.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}},bh=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??xh()}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 yh.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,yh.ofInner(e)}};const xh=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let Sh;const Ch=()=>wh().toString(),wh=()=>(Sh||=new bh).generate();var Th=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 Eh=`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(`,`),Dh=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return Eh.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},Oh=Array.isArray,kh=Object.prototype;kh.hasOwnProperty;const Ah=kh.toString,jh=Oh||function(e){return Ah.call(e)===`[object Array]`},Mh=e=>e===Object(e)&&!jh(e),Nh=e=>e===void 0,Ph=e=>Ah.call(e)==`[object String]`,Fh=e=>Ph(e)&&e.trim().length===0,Ih=e=>Ah.call(e)==`[object Number]`&&e===e,Lh=e=>e instanceof Error;function Rh(e){return typeof e!=`object`||!e}function zh(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function Bh(e){return!Nh(Event)&&Hh(e,Event)}function Vh(e){return zh(e,`Object`)}function Hh(e,t){try{return e instanceof t}catch{return!1}}function Uh(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Ih(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),Uh(i||n,t,n,r))}var Wh=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Uh(e.bucketSize,0,100,e._logger),this._refillRate=Uh(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Uh(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={}}},Gh=class{add(e){let t=Ch();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 Kh(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const qh=(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=>qh(`${e} ${r}`,t,n)}},Jh=e=>e();function Yh(e,t=Jh){return qh(e,t,Kh())}const Xh=`Android`;Xh+``;const Zh=`BlackBerry`,Qh=`Samsung`;Qh+``,Qh+``;const $h=`Chrome`;$h+``,$h+``;const eg=`Opera`;eg+``;const tg=`Edge`;``+tg;const ng=`Firefox`;ng+``;const rg=`Nintendo`,ig=`PlayStation`,ag=`Xbox`;Xh+``;const og=`Windows`;og+``;const sg=`Generic`;sg+``,sg+``;const cg=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+cg),new RegExp(ag,`i`),RegExp(ig+` \\w+`,`i`),RegExp(rg+` \\w+`,`i`),RegExp(Zh+`|PlayBook|BB10`,`i`),RegExp(`rv:`+cg),RegExp(tg+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+$h+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+cg),RegExp(`(UCBrowser|UCWEB)\\/`+cg),RegExp(`(`+eg+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp(ng+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+cg),RegExp(`Konqueror[:/]?`+cg,`i`),RegExp(Zh+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+cg,`i`),RegExp(`(rv:|MSIE )`+cg),RegExp(`rv:`+cg),RegExp(ag+`; Xbox (.*?)[);]`,`i`),new RegExp(rg,`i`),new RegExp(ig,`i`),new RegExp(og,`i`),RegExp(`(`+Xh+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function lg(e,t){if(!e||typeof e!=`string`||ug(e))throw Error(t)}function ug(e){return e.trim().length===0}function dg(e){return e?.replace(/\/+$/,``)}async function fg(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 pg(){return new Date().toISOString()}function mg(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const hg=e=>e instanceof Error;function gg(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var _g=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 vg(){return`CompressionStream`in globalThis}async function yg(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 bg=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()}},xg=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function Sg(e){if(e instanceof bg){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 Cg(e){return typeof e==`object`&&(e instanceof bg||e instanceof xg)}function wg(e){return typeof e==`object`&&e instanceof bg&&e.status===413}var Tg=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new Gh,this._events=new _g,this._isInitialized=!1,lg(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=dg(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:Cg},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=Yh(`[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=!vg()||(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(Th.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(Th.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(Th.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:fh(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof bg)return{type:`api_error`,statusCode:e.status};if(e instanceof xg){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=gh(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(Th.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(Th.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(Th.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(Th.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(Th.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=mg(()=>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:pg()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await yg(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:pg(),uuid:n?.uuid?n.uuid:Ch()};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 Sg(e)})}async flush(){let e=gg([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),gg([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(Th.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(Th.Queue)||[]).slice(n.length);this.setPersistedProperty(Th.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:pg()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await yg(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>wg(e)?!1:Cg(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(wg(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 xg||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 fg(async()=>{let n=new AbortController,i=mg(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new xg(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new bg(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(Th.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!Cg(e))throw e;await Sg(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=mg(()=>{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 Eg,Dg,Og;function kg(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Og&&n.length===Dg?Og:(Dg=n.length,Og=n.reduce((n,r)=>{Eg||={};let i=Eg[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,Eg[r]=[a,o];break}}}return n},{}),Og)}var Ag=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&&jh(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:kg(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 jg=/^\s*[-]{4,}$/,Mg=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,Ng=(e,t)=>{let n=e.match(Mg);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:Fg(n[3]),colno:Fg(n[4]),in_app:Pg(s||``,c),platform:t}}if(e.match(jg))return{filename:e,platform:t}};function Pg(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 Fg(e){return parseInt(e||``,10)||void 0}const Ig=/\(error: (.*)\)/;function Lg(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||Rg(t).filename,function:e.function||`?`}))}function Rg(e){return e[e.length-1]||{}}function zg(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=Ig.test(r)?r.replace(Ig,`$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 Lg(i)}}var Bg=class{match(e){return Lh(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 Vg=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Hg=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(Vg);return r&&(t=r[1],n=r[2]),[t,n]}};const Ug=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Wg(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 Gg=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 Bh(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=Wg(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return Ph(e)&&!Fh(e)&&Ug.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(hg(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Kg=class{match(e){return Bh(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Wg(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},qg=class{match(e){return Rh(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},Jg=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 Yg=new Jg(25),Xg=new Jg(20);async function Zg(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`||n_(i)||r_(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(Xg.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=a_(n);if(i.every(t=>i_(e,t)))continue;let a=l_(Yg,e,{});r.push(Qg(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&$g(e,Yg),Yg.reduce(),e}function Qg(e,t,n){return new Promise(r=>{let i=Fe(e),a=We({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(){Xg.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]=u_(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 $g(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;e_(n.lineno,n,e)}}function e_(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=s_(e);r<e;r++){let e=n[r];if(e===void 0)return void t_(t);t.pre_context.push(e)}if(n[e]===void 0)return void t_(t);t.context_line=n[e];let r=c_(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 t_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function n_(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function r_(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function i_(e,t){let n=Yg.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 a_(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=o_(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=o_(n)),t++}return i}function o_(e){return[s_(e),c_(e)]}function s_(e){return Math.max(1,e-7)}function c_(e){return e+7}function l_(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function u_(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 d_(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 f_(e,t){globalThis.process?.on(`uncaughtException`,d_(e,t))}function p_(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var m_=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Wh({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return Mh(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||Ch(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(f_(this.onException.bind(this),this.onFatalError.bind(this)),p_(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 h_={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function g_(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 __=[`is_not`];var v_=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)}},y_=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},b_=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 y_||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 y_||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 y_)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`?w_(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):S_(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await x_(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await x_(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 v_(`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 v_(`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 v_(`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 v_&&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=mg(()=>{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 x_(e,t,n=``){let r=await g_(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function S_(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&&!__.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 E_(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return E_(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=N_(String(i));if(e??=M_(i),e==null)throw new $(`Invalid date: ${i}`);let t=M_(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return O_(D_(String(o)),D_(String(i)))===0;case`semver_neq`:return O_(D_(String(o)),D_(String(i)))!==0;case`semver_gt`:return O_(D_(String(o)),D_(String(i)))>0;case`semver_gte`:return O_(D_(String(o)),D_(String(i)))>=0;case`semver_lt`:return O_(D_(String(o)),D_(String(i)))<0;case`semver_lte`:return O_(D_(String(o)),D_(String(i)))<=0;case`semver_tilde`:{let e=D_(String(o)),{lower:t,upper:n}=k_(String(i));return O_(e,t)>=0&&O_(e,n)<0}case`semver_caret`:{let e=D_(String(o)),{lower:t,upper:n}=A_(String(i));return O_(e,t)>=0&&O_(e,n)<0}case`semver_wildcard`:{let e=D_(String(o)),{lower:t,upper:n}=j_(String(i));return O_(e,t)>=0&&O_(e,n)<0}default:throw new $(`Unknown operator: ${a}`)}}function C_(e,t){if(!(e in t))throw new y_(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function w_(e,t,n,r=!1){let i=String(e.value);C_(i,n);let a=n[i];return T_(a,t,n,r)}function T_(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=T_(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof y_)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=w_(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=S_(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 y_)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 E_(e){try{return new RegExp(e),!0}catch{return!1}}function D_(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 O_(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 k_(e){let t=D_(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function A_(e){let[t,n,r]=D_(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 j_(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 M_(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 N_(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 P_=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const F_=3e4;var I_=class extends Tg{constructor(e,t={}){if(super(e,t),this._memoryStorage=new P_,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):F_,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 b_({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 m_(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=mg(()=>{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=F_){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 y_||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=h_.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(h_.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(h_.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(h_.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=mg(()=>{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(Vh(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(!m_.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(m_.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!m_.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(m_.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=Ch(),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`&&Dh(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}},L_=class{constructor(){this.storage=new Ge}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 R_=`posthog-node`;function z_(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[B_.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 B_=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=R_,this.name=R_,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(z_(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};m_.errorPropertiesBuilder=new Ag([new Kg,new Bg,new Gg,new Hg,new qg],zg(`node:javascript`,Ng),[lh(),Zg]);const V_=new class extends I_{getLibraryId(){return`posthog-node`}initializeContext(){return new L_}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`});var H_=class extends S.Service()(`@expect/AnalyticsProvider`){static layerPostHog=p.succeed(this)({capture:e=>l.sync(()=>{V_.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>l.sync(()=>{V_.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:l.tryPromise({try:()=>V_.flush(),catch:e=>e}).pipe(l.ignore)});static layerDev=p.succeed(this)({capture:e=>l.logInfo(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(l.annotateLogs({module:`Analytics`})),identify:e=>l.logInfo(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(l.annotateLogs({module:`Analytics`})),flush:l.void})},U_=class extends S.Service()(`@expect/Analytics`,{make:l.gen(function*(){let e=yield*H_,t=yield*s.option(s.string(`NO_TELEMTRY`)),n=g.match(t,{onNone:()=>!1,onSome:e=>e===`1`}),r=yield*l.tryPromise(()=>(0,th.machineId)()).pipe(l.orDie),i=ch(process.cwd()),a=(t,...[a])=>n?l.void:l.gen(function*(){let n={timestamp:new Date().toISOString(),projectId:i};yield*e.capture({eventName:t,properties:{...n,...a??{}},distinctId:r})}).pipe(l.catchCause(e=>l.logWarning(`Analytics capture failed`,{eventName:t,cause:e}).pipe(l.annotateLogs({module:`Analytics`}))));return{capture:a,track:((e,t)=>n=>l.tap(n,n=>{let r=t?t(n):void 0;return a.call(void 0,e,...r===void 0?[]:[r])})),flush:n?l.void:e.flush}})}){static layerPostHog=p.effect(this)(this.make).pipe(p.provide(H_.layerPostHog),p.provide(ve.layer));static layerDev=p.effect(this)(this.make).pipe(p.provide(H_.layerDev),p.provide(ve.layer))};const W_=e=>{let t=o.squash(e);return{error_tag:_.hasProperty(t,`_tag`)?String(t._tag):`Unknown`,error_message:o.pretty(e)}};(class extends S.Service()(`@expect/ErrorHandler`,{make:l.gen(function*(){let e=yield*U_;return{orDie:t=>t.pipe(l.tapCause(t=>e.capture(`error:unexpected`,W_(t))),l.orDie),streamOrDie:t=>t.pipe(C.tapCause(t=>e.capture(`error:unexpected`,W_(t))),C.orDie),tapCause:(...t)=>n=>n.pipe(l.tapCause(n=>l.all([e.capture(`error:expected`,W_(n)),l.logError(...t,n)],{discard:!0})))}})}){static layer=p.effect(this)(this.make)}),qe.layerWebSocket().pipe(p.provide(Ae.layerWebSocketConstructor));const G_=p.unwrap(l.gen(function*(){let e=`expect-cli`;return Je.layerJson({baseUrl:`https://api.axiom.co`,resource:{serviceName:e},headers:{Authorization:`Bearer xaat-a6ce2fdb-d378-444e-9d72-bb458867187a`,"X-Axiom-Dataset":e}})})).pipe(p.provide(Ke.layerUndici),p.orDie),K_=ze()(Xe(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:Ye(()=>cm),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),q_=U_.layerPostHog,J_=(e,...[t])=>l.runPromise(l.gen(function*(){let n=yield*U_;yield*n.capture.call(n,e,...t===void 0?[]:[t])}).pipe(l.catchCause(()=>l.void),l.provide(q_))),Y_=()=>J_(`session:started`,{mode:`interactive`,skip_planning:!1,browser_headed:K_.getState().browserHeaded}),X_=e=>l.runPromise(l.gen(function*(){let t=yield*U_;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush}).pipe(l.provide(q_))),Z_=()=>{let e=N(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=kt(),n,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=H(E,{color:`red`,children:W.cross}),r=H(E,{color:`green`,children:W.tick}),e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]===t.PRIMARY?i=e[4]:(i=H(E,{bold:!0,color:t.PRIMARY,children:` Expect`}),e[3]=t.PRIMARY,e[4]=i);let a;e[5]===t.DIM?a=e[6]:(a=H(E,{color:t.DIM,children:` v${ft}`}),e[5]=t.DIM,e[6]=a);let o;return e[7]!==t.BORDER||e[8]!==i||e[9]!==a?(o=H(T,{children:U(E,{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},Q_=[{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.`}],$_=e=>{let t=N(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=kt(),o=Km(ev),[s,c]=R(0),l;t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==o?(l=e=>{let t=e.id===`enable-sync`;J_(`cookies:sync_choice`,{choice:t?`use_cookies`:`skip_cookies`}),o(Gm({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(tv),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&c(nv),e===`c`&&u(Q_[0]),e===`a`&&u(Q_[1]),t.return&&u(Q_[s])},t[6]=u,t[7]=s,t[8]=d):d=t[8],te(d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=H(Z_,{}),t[9]=f):f=t[9];let p;t[10]===a.DIM?p=t[11]:(p=H(E,{color:a.DIM,children:W.pointerSmall}),t[10]=a.DIM,t[11]=p);let m;t[12]!==a.TEXT||t[13]!==r?(m=H(E,{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=U(T,{children:[f,U(E,{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=H(T,{marginTop:1,children:s===0?U(E,{color:a.GREEN,children:[W.tick,` Your signed-in session will be synced to the browser. Cookies stay on device.`]}):U(E,{color:a.YELLOW,children:[W.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?(_=Q_.map((e,t)=>{let n=t===s;return H(Mt,{onClick:()=>{c(t),u(e)},children:U(T,{flexDirection:`column`,marginBottom:1,children:[U(E,{children:[H(E,{color:n?a.PRIMARY:a.DIM,children:n?`${W.pointer} `:` `}),H(E,{color:n?a.PRIMARY:a.TEXT,bold:n,children:e.label})]}),U(E,{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=H(T,{flexDirection:`column`,marginTop:1,children:_}),t[28]=_,t[29]=v);let y;return t[30]!==h||t[31]!==g||t[32]!==v?(y=U(T,{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 ev(e){return e.setScreen}function tv(e){return Math.min(Q_.length-1,e+1)}function nv(e){return Math.max(0,e-1)}const rv=ze()(Xe(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:Ye(()=>dm)})),iv=`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(`,`),av=[[/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`]],ov=e=>{let t=e.toLowerCase();return iv.some(e=>t.startsWith(e))},sv=e=>{if(!/^\d+$/.test(e))return``;try{let t=we(`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``}},cv=(e,t)=>{if(!/^\d+$/.test(e)||ov(t))return;let n=sv(e);try{let t=we(`ps -p ${e} -o command=`,{encoding:`utf-8`,timeout:1e3}).trim();for(let[e,r]of av)if(e.test(t))return{name:r,isFramework:!0,cwd:n}}catch{}return{name:t,isFramework:!1,cwd:n}},lv=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},uv=()=>{try{let e=lv(we(`lsof -iTCP -sTCP:LISTEN -nP`,{encoding:`utf-8`,timeout:3e3})),t=[];for(let n of e){let e=cv(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[]}},dv=()=>M({queryKey:[`listening-ports`],queryFn:()=>uv(),refetchInterval:5e3}),fv=e=>`http://localhost:${e}`,pv=(e,t)=>{let n=t.toLowerCase();return String(e.port).includes(n)||e.processName.toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n)},mv=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}},hv=e=>{let t=N(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=kt(),s=Km(gv),c=rv(_v),l=rv(vv),{data:u}=dv(),d=u===void 0?[]:u,[f,p]=R(!1),[m,h]=R(``),[g,_]=R(!1),[v,y]=R(``),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,S]=R(b),C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=new Set,t[3]=C):C=t[3];let[w,ee]=R(C),D=d.map(yv),O=m?D.filter(e=>pv(e,m)):D,k=O.length,A=O.length+1,ne=O.length+2,j;t[4]===ne?j=t[5]:(j={itemCount:ne,visibleCount:10},t[4]=ne,t[5]=j);let{highlightedIndex:M,setHighlightedIndex:P,scrollOffset:re,handleNavigation:F}=Vm(j),ie;t[6]!==n||t[7]!==w||t[8]!==r||t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==s?(ie=e=>{let t=[...e,...w];l(t.length>0?t[0]:void 0),t.length===0?J_(`port:skipped`):J_(`port:selected`,{port_count:t.length,has_custom_url:w.size>0}),s(Wm.Testing({changesFor:n,instruction:r,savedFlow:i,requiresCookies:a,baseUrls:t.length>0?t:void 0}))},t[6]=n,t[7]=w,t[8]=r,t[9]=a,t[10]=i,t[11]=l,t[12]=s,t[13]=ie):ie=t[13];let I=ie,L;t[14]===S?L=t[15]:(L=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[14]=S,t[15]=L);let z=L,ae;t[16]!==k||t[17]!==w||t[18]!==O||t[19]!==M||t[20]!==I||t[21]!==x||t[22]!==_||t[23]!==A?(ae=()=>{if(M===A){I([]);return}if(x.size>0||w.size>0){I([...x].sort(bv).map(fv));return}if(M===k){_(!0);return}let e=O[M];e&&I([fv(e.port)])},t[16]=k,t[17]=w,t[18]=O,t[19]=M,t[20]=I,t[21]=x,t[22]=_,t[23]=A,t[24]=ae):ae=t[24];let B=ae,V=xv,oe;t[25]!==y||t[26]!==ee||t[27]!==_?(oe=e=>{let t=e.trim();if(!t){_(!1);return}let n=V(t);ee(e=>new Set([...e,n])),y(``),_(!1)},t[25]=y,t[26]=ee,t[27]=_,t[28]=oe):oe=t[28];let se=oe,G;t[29]===ee?G=t[30]:(G=e=>{ee(t=>{let n=new Set(t);return n.delete(e),n})},t[29]=ee,t[30]=G);let K=G,ce;t[31]!==P||t[32]!==h?(ce=e=>{h(e),P(0)},t[31]=P,t[32]=h,t[33]=ce):ce=t[33];let le=ce,ue;t[34]!==p||t[35]!==h||t[36]!==z?(ue=e=>{let t=mv(e);if(t){z(t),p(!1),h(``);return}p(!1)},t[34]=p,t[35]=h,t[36]=z,t[37]=ue):ue=t[37];let de=ue,fe;t[38]!==B||t[39]!==k||t[40]!==O||t[41]!==F||t[42]!==M||t[43]!==g||t[44]!==f||t[45]!==y||t[46]!==_||t[47]!==p||t[48]!==z?(fe=(e,t)=>{if(g){if(t.escape){_(!1),y(``);return}return}if(f){if(t.escape){p(!1);return}return}if(!F(e,t)){if(e===`/`){p(!0);return}if(e===` `){if(M===k){_(!0);return}let e=O[M];e&&z(e.port);return}t.return&&B()}},t[38]=B,t[39]=k,t[40]=O,t[41]=F,t[42]=M,t[43]=g,t[44]=f,t[45]=y,t[46]=_,t[47]=p,t[48]=z,t[49]=fe):fe=t[49],te(fe);let pe,me,q,he,ge,_e,ve,ye,J,be,xe,Se,Ce,we,Te,Ee;if(t[50]!==o.DIM||t[51]!==o.GREEN||t[52]!==o.PRIMARY||t[53]!==o.TEXT||t[54]!==o.YELLOW||t[55]!==k||t[56]!==w||t[57]!==O||t[58]!==M||t[59]!==r||t[60]!==re||t[61]!==x||t[62]!==P||t[63]!==A||t[64]!==z){let e=O.slice(re,re+8);q=re+8>=O.length,_e=q;let n=O[M];he=M===k,ge=M===A;let i;t[81]!==w||t[82]!==x?(i=[...[...x].sort(Sv).map(fv),...w],t[81]=w,t[82]=x,t[83]=i):i=t[83];let a=i;me=T,be=`column`,xe=`100%`,Se=1,Ce=1;let s;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(s=H(Z_,{}),t[84]=s):s=t[84];let c;t[85]===o.DIM?c=t[86]:(c=H(E,{color:o.DIM,children:W.pointerSmall}),t[85]=o.DIM,t[86]=c);let l;t[87]!==o.TEXT||t[88]!==r?(l=H(E,{color:o.TEXT,children:r}),t[87]=o.TEXT,t[88]=r,t[89]=l):l=t[89],t[90]!==c||t[91]!==l?(we=U(T,{children:[s,U(E,{wrap:`truncate`,children:[` `,c,` `,l]})]}),t[90]=c,t[91]=l,t[92]=we):we=t[92],t[93]===o.DIM?Te=t[94]:(Te=H(T,{marginTop:1,children:H(E,{color:o.DIM,children:`Pick the dev server the agent should open in the browser.`})}),t[93]=o.DIM,t[94]=Te);let u;t[95]!==o.GREEN||t[96]!==a?(u=a.length>0&&U(E,{color:o.GREEN,children:[W.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]!==he||t[102]!==ge?(d=a.length===0&&!ge&&!he&&n&&U(E,{color:o.DIM,children:[W.arrowRight,` `,fv(n.port)]}),t[98]=o.DIM,t[99]=a.length,t[100]=n,t[101]=he,t[102]=ge,t[103]=d):d=t[103];let f;t[104]!==o.YELLOW||t[105]!==a.length||t[106]!==ge?(f=a.length===0&&ge&&U(E,{color:o.YELLOW,children:[W.warning,` No base URL. The agent won`,`'`,`t know where your dev server is.`]}),t[104]=o.YELLOW,t[105]=a.length,t[106]=ge,t[107]=f):f=t[107],t[108]!==u||t[109]!==d||t[110]!==f?(Ee=U(T,{marginTop:1,children:[u,d,f]}),t[108]=u,t[109]=d,t[110]=f,t[111]=Ee):Ee=t[111],pe=T,ve=`column`,ye=1;let p;t[112]!==o.DIM||t[113]!==o.PRIMARY||t[114]!==o.TEXT||t[115]!==M||t[116]!==re||t[117]!==x||t[118]!==P||t[119]!==z?(p=(e,t)=>{let n=t+re,r=n===M,i=x.has(e.port);return H(Mt,{onClick:()=>{P(n),z(e.port)},children:U(T,{children:[H(E,{color:r?o.PRIMARY:o.DIM,children:r?`${W.pointer} `:` `}),U(E,{color:i?o.PRIMARY:o.DIM,children:[i?W.checkboxOn:W.checkboxOff,` `]}),U(E,{color:r?o.PRIMARY:o.TEXT,bold:r,children:[`:`,e.port]}),e.processName&&U(E,{color:o.DIM,children:[` `,e.processName]}),e.cwd&&U(E,{color:o.DIM,children:[` `,e.cwd]})]})},e.port)},t[112]=o.DIM,t[113]=o.PRIMARY,t[114]=o.TEXT,t[115]=M,t[116]=re,t[117]=x,t[118]=P,t[119]=z,t[120]=p):p=t[120],J=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]=k,t[56]=w,t[57]=O,t[58]=M,t[59]=r,t[60]=re,t[61]=x,t[62]=P,t[63]=A,t[64]=z,t[65]=pe,t[66]=me,t[67]=q,t[68]=he,t[69]=ge,t[70]=_e,t[71]=ve,t[72]=ye,t[73]=J,t[74]=be,t[75]=xe,t[76]=Se,t[77]=Ce,t[78]=we,t[79]=Te,t[80]=Ee}else pe=t[65],me=t[66],q=t[67],he=t[68],ge=t[69],_e=t[70],ve=t[71],ye=t[72],J=t[73],be=t[74],xe=t[75],Se=t[76],Ce=t[77],we=t[78],Te=t[79],Ee=t[80];let De;t[121]!==o.DIM||t[122]!==o.PRIMARY||t[123]!==o.TEXT||t[124]!==k||t[125]!==v||t[126]!==q||t[127]!==se||t[128]!==he||t[129]!==g||t[130]!==y||t[131]!==P||t[132]!==_?(De=q&&H(Mt,{onClick:()=>{P(k),_(!0)},children:U(T,{children:[H(E,{color:he?o.PRIMARY:o.DIM,children:he?`${W.pointer} `:` `}),g&&U(T,{children:[H(E,{color:o.PRIMARY,children:`URL: `}),H(Rt,{focus:!0,value:v,placeholder:`http://localhost:4000 or staging.example.com`,onChange:y,onSubmit:se})]}),!g&&U(E,{color:he?o.PRIMARY:o.TEXT,bold:he,children:[`Enter a custom URL`,W.ellipsis]})]})}),t[121]=o.DIM,t[122]=o.PRIMARY,t[123]=o.TEXT,t[124]=k,t[125]=v,t[126]=q,t[127]=se,t[128]=he,t[129]=g,t[130]=y,t[131]=P,t[132]=_,t[133]=De):De=t[133];let Oe;t[134]!==o.DIM||t[135]!==o.PRIMARY||t[136]!==o.TEXT||t[137]!==q||t[138]!==w||t[139]!==K?(Oe=q&&[...w].map(e=>H(Mt,{onClick:()=>K(e),children:U(T,{children:[H(E,{children:` `}),U(E,{color:o.PRIMARY,children:[W.checkboxOn,` `]}),H(E,{color:o.TEXT,children:e}),H(E,{color:o.DIM,children:` (click to remove)`})]})},e)),t[134]=o.DIM,t[135]=o.PRIMARY,t[136]=o.TEXT,t[137]=q,t[138]=w,t[139]=K,t[140]=Oe):Oe=t[140];let ke;t[141]!==o.DIM||t[142]!==o.PRIMARY||t[143]!==ge||t[144]!==I||t[145]!==P||t[146]!==A||t[147]!==_e?(ke=_e&&H(Mt,{onClick:()=>{P(A),I([])},children:U(T,{children:[H(E,{color:ge?o.PRIMARY:o.DIM,children:ge?`${W.pointer} `:` `}),U(E,{color:ge?o.PRIMARY:o.DIM,bold:ge,children:[`Skip `,W.arrowRight,` no base URL`]})]})}),t[141]=o.DIM,t[142]=o.PRIMARY,t[143]=ge,t[144]=I,t[145]=P,t[146]=A,t[147]=_e,t[148]=ke):ke=t[148];let Ae;t[149]!==o.DIM||t[150]!==O.length||t[151]!==_e?(Ae=O.length===0&&!_e&&H(E,{color:o.DIM,children:`No matching ports`}),t[149]=o.DIM,t[150]=O.length,t[151]=_e,t[152]=Ae):Ae=t[152];let je;t[153]!==pe||t[154]!==ve||t[155]!==ye||t[156]!==J||t[157]!==De||t[158]!==Oe||t[159]!==ke||t[160]!==Ae?(je=U(pe,{flexDirection:ve,marginTop:ye,children:[J,De,Oe,ke,Ae]}),t[153]=pe,t[154]=ve,t[155]=ye,t[156]=J,t[157]=De,t[158]=Oe,t[159]=ke,t[160]=Ae,t[161]=je):je=t[161];let Me;t[162]!==le||t[163]!==de||t[164]!==f||t[165]!==m?(Me=H(zt,{isSearching:f,query:m,onChange:le,onSubmit:de}),t[162]=le,t[163]=de,t[164]=f,t[165]=m,t[166]=Me):Me=t[166];let Ne;return t[167]!==me||t[168]!==be||t[169]!==xe||t[170]!==Se||t[171]!==Ce||t[172]!==we||t[173]!==Te||t[174]!==Ee||t[175]!==je||t[176]!==Me?(Ne=U(me,{flexDirection:be,width:xe,paddingY:Se,paddingX:Ce,children:[we,Te,Ee,je,Me]}),t[167]=me,t[168]=be,t[169]=xe,t[170]=Se,t[171]=Ce,t[172]=we,t[173]=Te,t[174]=Ee,t[175]=je,t[176]=Me,t[177]=Ne):Ne=t[177],Ne};function gv(e){return e.setScreen}function _v(e){return e.lastBaseUrl}function vv(e){return e.setLastBaseUrl}function yv(e){return{port:e.port,processName:e.processName,cwd:e.cwd}}function bv(e,t){return e-t}function xv(e){let t=e.trim(),n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?fv(n):/^https?:\/\//i.test(t)?t:`http://${t}`}function Sv(e,t){return e-t}const Cv=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},wv=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,Tv=(e,t,n)=>e+(t-e)*n,Ev=(e,t,n)=>{let[r,i,a]=Cv(e),[o,s,c]=Cv(t);return wv(Tv(r,o,n),Tv(i,s,n),Tv(a,c,n))},Dv=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[i,a]=R(-16),o=L(r);o.current=r;let s=L(e.length);s.current=e.length;let c=L(!1);return c.current||(c.current=!0,setTimeout(()=>{setInterval(()=>{let e=s.current+16;a(t=>t>=e?-16:t+o.current)},50)},0)),H(E,{children:[...e].map((e,r)=>{let a=Math.abs(r-i),o=Math.max(0,1-a/16);return H(E,{color:o>0?Ev(t,n,o):t,children:e},r)})})},Ov=ze(e=>({executedPlan:void 0,expanded:!1,setExecutedPlan:t=>e({executedPlan:t}),setExpanded:t=>e({expanded:t}),toggleExpanded:()=>e(e=>({expanded:!e.expanded}))})),kv=e=>rt(Math.max(0,e),{secondsDecimalDigits:0}),Av=new Set([`warpterminal`]),jv=at.stdout,Mv=it({preferOuter:!0}),Nv=process.stdout.isTTY&&!Av.has(Mv??``),Pv=Nv&&jv.kitty,Fv=Nv&&jv.iterm2,Iv=Pv||Fv,Lv=it(),Rv=Lv===`tmux`||Lv===`screen`,zv=e=>Rv?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,Bv=(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}`),zv(`_G${r};${n}\\`)},Vv=(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`)}`,zv(n)},Hv=(e,t={})=>{if(!Pe.existsSync(e))return null;if(Pv)return Bv(e,t);if(Fv)try{return Vv(Pe.readFileSync(e),t)}catch{return null}return null},Uv=e=>e.startsWith(`file://`),Wv=e=>{let t=N(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=Uv(n)?de.fileURLToPath(n):K.resolve(n),a=Uv(n)?n:de.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=H(E,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==o||t[7]!==c?(l=H(ot,{url:o,children:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l},Gv=({src:e,alt:t,width:n,height:r})=>{let i=K.resolve(e),{write:a}=k(),o=L(!1);if(!o.current){let e=Hv(i,{width:n,height:r});e&&(a(e+`
|
|
38
|
+
`),o.current=!0)}return Iv?null:H(Wv,{path:i,label:t})},Kv=({error:e,type:t})=>{if(!e.message)return null;let n=kt(),r=t===`defect`;return U(T,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:n.ERROR_BG,width:`100%`,flexDirection:`column`,gap:0,children:[H(T,{paddingBottom:1,children:U(E,{color:n.RED,bold:!0,children:[W.warning,` `,e.displayName??e._tag]})}),H(T,{paddingBottom:1,children:H(E,{color:n.DIM,children:e.message})}),r&&U(E,{color:n.DIM,children:[`This is a bug. Report it at`,` `,H(E,{color:n.YELLOW,children:`https://github.com/millionco/expect/issues`})]}),U(E,{color:n.DIM,children:[`Press `,H(E,{color:n.RED,children:`esc`}),` to return`]})]})},qv=e=>{let t=N(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=kt();if(!n)return null;let i;return t[1]!==r.RED||t[2]!==n?(i=H(T,{marginTop:1,children:H(E,{color:r.RED,children:n})}),t[1]=r.RED,t[2]=n,t[3]=i):i=t[3],i},Jv=({verbose:e,agent:t})=>{let n=Hp.withRepoRoot(process.cwd());return p.mergeAll(Wp.layer.pipe(p.provide(n)),Gp.layer,Jn.layer,nm.layer,qe.layer(),n,U_.layerPostHog).pipe(p.provide(Ra.layerFor(t??`claude`)),p.provide(eh),p.provide(G_),p.provideMerge(p.succeed(b.MinimumLogLevel,e?`All`:`Error`)))},Yv=Qe.make(g.none()),Xv=Qe.runtime(l.fnUntraced(function*(e){return Jv({verbose:!0,agent:yield*e.some(Yv)})},p.unwrap)).pipe(Qe.keepAlive),Zv=e=>e;var Qv=class extends x.ErrorClass(`ReplayProxyStartError`)({_tag:x.tag(`ReplayProxyStartError`),cause:x.String}){message=`Failed to start replay proxy: ${this.cause}`};const $v=(e,t,n,r)=>{let i=new URL(e.url??`/`,r),a=Me({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
|
|
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()},ey=l.fn(`startReplayProxy`)(function*(e){let t=new st,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 ct(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*l.try({try:()=>lt({fetch:t.fetch,port:0}),catch:e=>new Qv({cause:String(e)})});c.on(`upgrade`,(e,t,n)=>{$v(e,t,n,o)});let u=c.address(),d=`http://localhost:${typeof u==`object`&&u?u.port:0}`;return yield*l.logInfo(`Replay proxy started`,{proxyUrl:d,liveViewUrl:e.liveViewUrl}),{url:d,close:l.callback(e=>{c.close(()=>e(l.void))})}}),ty=e=>g.isSome(e)?Number(c.toEpochMillis(e.value)):void 0,ny=e=>e.length===0||!e.every(e=>e.status===`passed`||e.status===`failed`)?`running`:e.some(e=>e.status===`failed`)?`failed`:`passed`,ry=e=>{let t=e.events.find(e=>e._tag===`RunFinished`),n=t&&t._tag===`RunFinished`?t.status:ny(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:g.isSome(e.summary)?e.summary.value:void 0,startedAtMs:ty(e.startedAt),endedAtMs:ty(e.endedAt)}));return{title:e.title,status:n,summary:r,steps:i}},iy=l.fn(`pushStepState`)(function*(e,t){yield*l.tryPromise(()=>fetch(`${e}/steps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).pipe(l.catchCause(()=>l.void))}),ay=`rrweb report:`,oy=`Playwright video:`,sy=()=>5e4+Math.floor(Math.random()*1e4),cy=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(`
|
|
40
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),r=n.find(e=>e.startsWith(ay))?.replace(ay,``),i=n.find(e=>e.startsWith(oy))?.replace(oy,``);return{localReplayUrl:r&&r.trim().length>0?pe(r.trim()).href:void 0,videoUrl:i&&i.trim().length>0?pe(i.trim()).href:void 0}},ly=Qe.make([]),uy=l.fnUntraced(function*(e,t){let n=yield*Gp,r=yield*Wp,i=yield*U_,a=yield*Hp,o=Date.now(),s=`http://localhost:${sy()}`,c;e.replayHost&&(c=`${(yield*ey({replayHost:e.replayHost,liveViewUrl:s})).url}/replay?live=true`,yield*l.logInfo(`Replay viewer available`,{replayUrl:c}),yield*l.sync(()=>e.onReplayUrl?.(c)));let u={...e.options,liveViewUrl:s};yield*i.capture(`run:started`,{plan_id:`direct`});let d=yield*r.execute(u).pipe(C.tap(t=>l.gen(function*(){e.onUpdate(t),yield*iy(s,ry(t))})),C.runLast,l.map(t=>t._tag===`Some`?t.value:new Kn({...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:g.none(),title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),f=cy(d.events);if(c){let e=c.split(`/replay`)[0];yield*l.tryPromise(()=>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(l.catchCause(()=>l.void)),yield*iy(e,ry(d))}let p=yield*n.report(d),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:d.id??`direct`,passed:m,failed:h,step_count:d.steps.length,file_count:0,duration_ms:Date.now()-o}),p.status===`passed`&&(yield*a.saveTestedFingerprint()),{executedPlan:d,report:p,replayUrl:c??f.localReplayUrl,localReplayUrl:f.localReplayUrl,videoUrl:f.videoUrl}},l.annotateLogs({fn:`executeFn`})),dy=Xv.fn()((e,t)=>Zv(uy(e,t)).pipe(l.tapError(e=>l.gen(function*(){let t=yield*U_,n=e instanceof Error?e.constructor.name:`UnknownError`;yield*t.capture(`run:failed`,{plan_id:`direct`,error_tag:n})}).pipe(l.catchCause(()=>l.void))),l.provide(ve.layer)));Xv.fn(l.fnUntraced(function*(e,t){let n=yield*Gp,r=yield*Wp,i=yield*U_,a=yield*Hp,o=Date.now(),s=`http://localhost:${sy()}`,c;e.replayHost&&(c=`${(yield*ey({replayHost:e.replayHost,liveViewUrl:s})).url}/replay?live=true`,yield*l.logInfo(`Replay viewer available`,{replayUrl:c}),yield*l.sync(()=>e.onReplayUrl?.(c)));let u={...e.options,liveViewUrl:s};yield*i.capture(`run:started`,{plan_id:`direct`});let d=yield*r.execute(u).pipe(C.tap(t=>l.gen(function*(){e.onUpdate(t),yield*iy(s,ry(t))})),C.runLast,l.map(t=>t._tag===`Some`?t.value:new Kn({...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:g.none(),title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),f=cy(d.events);if(c){let e=c.split(`/replay`)[0];yield*l.tryPromise(()=>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(l.catchCause(()=>l.void)),yield*iy(e,ry(d))}let p=yield*n.report(d),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:d.id??`direct`,passed:m,failed:h,step_count:d.steps.length,file_count:0,duration_ms:Date.now()-o}),p.status===`passed`&&(yield*a.saveTestedFingerprint()),{executedPlan:d,report:p,replayUrl:c??f.localReplayUrl,localReplayUrl:f.localReplayUrl,videoUrl:f.videoUrl}},l.annotateLogs({fn:`executeAtomFn`})));const fy=e=>{if(typeof e==`string`)try{let t=JSON.parse(e);if(_.isObject(t))return t}catch{return{}}return _.isObject(e)?e:{}},py=e=>e.replace(/\s+/g,` `).trim(),my=e=>{let t=e.match(/^mcp__.+__(.+)$/);return t?t[1]:e},hy=(e,t)=>{let n=my(e),r=typeof t==`string`?t:JSON.stringify(t??{}),i=fy(t),a=h.value(n).pipe(h.when(`open`,()=>i.url?`"${i.url}"`:``),h.when(`screenshot`,()=>{let e=i.mode??`screenshot`;return e===`screenshot`?``:e}),h.when(`playwright`,()=>Le(py(i.code??r),100)),h.when(`console_logs`,()=>i.type?`type: "${i.type}"`:``),h.when(`network_requests`,()=>{let e=[];return i.method&&e.push(i.method),i.url&&e.push(`"${i.url}"`),e.join(`, `)}),h.when(`performance_metrics`,()=>``),h.when(`close`,()=>``),h.orElse(()=>gy(i))),o=(i.code??r).trim();return{name:n,args:a,multilineArgs:n===`playwright`&&o.includes(`
|
|
41
|
+
`)?o:void 0}},gy=e=>{let t=Object.values(e).filter(e=>typeof e==`string`&&e.length>0);return t.length===0?``:Le(py(t.join(`, `)),100)},_y=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`,vy=(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:hy(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},yy=(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},by=(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=yy(vy(e,n+1),e);return t?r:r.slice(-5)},xy=(e,t=!1)=>{let n=yy(vy(e,0),e);return t?n:n.slice(-5)},Sy=(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]},Cy=(e,t)=>{let[n,r]=Sy(e,t);return vy(e,n,r)},wy=e=>{let t=N(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=kt(),a;t[1]!==i.TEXT||t[2]!==n.tool.name?(a=H(E,{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&&U(E,{children:[` `,H(Ie,{type:`line`})]}),t[4]=n.isRunning,t[5]=o);let s;t[6]===n.resultTokens?s=t[7]:(s=n.resultTokens!==void 0&&` ${W.arrowDown} ${_y(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=U(E,{color:i.DIM,wrap:`truncate`,children:[r,W.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},Ty=e=>{if(!g.isNone(e.startedAt))return(g.isSome(e.endedAt)?c.toEpochMillis(e.endedAt.value):Date.now())-c.toEpochMillis(e.startedAt.value)},Ey=(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(`
|
|
42
|
+
`);i.push(U(E,{color:r.DIM,wrap:`truncate`,children:[t,W.lineVertical,` `,H(E,{color:r.TEXT,children:o.tool.name}),`(`,o.isRunning&&U(E,{children:[` `,H(Ie,{type:`line`})]}),o.resultTokens!==void 0&&` ${W.arrowDown} ${_y(o.resultTokens)} tokens`]},`${s}-h`));for(let n=0;n<e.length;n++)i.push(U(E,{color:r.DIM,children:[t,W.lineVertical,` `,` `,H(E,{color:r.TEXT,children:e[n]})]},`${s}-${n}`));i.push(U(E,{color:r.DIM,children:[t,W.lineVertical,` )`]},`${s}-c`))}else i.push(U(E,{color:r.DIM,wrap:`truncate`,children:[t,W.lineVertical,` `,H(E,{color:r.TEXT,children:o.tool.name}),`(`,o.tool.args,`)`,o.isRunning&&U(E,{children:[` `,H(Ie,{type:`line`})]}),o.resultTokens!==void 0&&` ${W.arrowDown} ${_y(o.resultTokens)} tokens`]},s))}return i},Dy=t=>{let n=N(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=Km(Oy),u=kt(),[,d]=Dt(),f=K_(ky),p=K_(Ay),m=K_(jy),h=K_(My),_;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(_={mode:`promiseExit`},n[1]=_):_=n[1];let[v,y]=et(dy,_),b=nt(ly),[x,S]=R(void 0),C;n[2]===v?C=n[3]:(C=Ze.isWaiting(v),n[2]=v,n[3]=C);let w=C,D;n[4]===v?D=n[5]:(D=Ze.isSuccess(v),n[4]=v,n[5]=D);let O=D,k=O?v.value.report:void 0,[A,ne]=R(void 0),[j,M]=R(void 0),[P,re]=R(0),[F,I]=R(!1),z=Ov(Ny),ae=Ov(Py),B=Ov(Fy),V;n[6]===P?V=n[7]:(V=kv(P),n[6]=P,n[7]=V);let oe=V,G=A?.steps?A.steps.length:0,K;if(n[8]!==u||n[9]!==oe||n[10]!==A||n[11]!==z||n[12]!==w){if(K=[],z&&A){let e=A.steps??[];if(e.length===0&&w){let e=xy(A.events,!0);K.push(...Ey(e,` `,`planning`,u))}for(let t=0;t<e.length;t++){let n=e[t],r=g.isSome(n.summary)?n.summary.value:n.title,i=Ty(n),a=i===void 0?void 0:kv(i),o=`${t+1}.`;if(n.status===`active`){K.push(U(T,{children:[U(E,{color:u.DIM,children:[` `,o,` `]}),H(zm,{}),H(E,{children:` `}),H(Dv,{text:`${n.title} ${oe}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]},`step-${t}`));let e=by(A.events,!0);K.push(...Ey(e,` `,`s${t}`,u))}else if(n.status===`passed`){K.push(U(E,{children:[U(E,{color:u.DIM,children:[` `,o]}),U(E,{color:u.GREEN,children:[` `,W.tick,` `,Le(r,100)]}),a&&U(E,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=Cy(A.events,t);K.push(...Ey(e,` `,`s${t}`,u))}else if(n.status===`failed`){K.push(U(E,{children:[U(E,{color:u.DIM,children:[` `,o]}),U(E,{color:u.RED,children:[` `,W.cross,` `,Le(r,100)]}),a&&U(E,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=Cy(A.events,t);K.push(...Ey(e,` `,`s${t}`,u))}else K.push(U(E,{color:u.DIM,children:[` `,o,` `,W.circle,` `,n.title]},`step-${t}`))}}n[8]=u,n[9]=oe,n[10]=A,n[11]=z,n[12]=w,n[13]=K}else K=n[13];let ce=Math.max(1,d-6),le;n[14]!==K.length||n[15]!==ce?(le={itemCount:K.length,visibleCount:ce},n[14]=K.length,n[15]=ce,n[16]=le):le=n[16];let ue=Vm(le),de=L(!1),fe,pe;n[17]!==z||n[18]!==K.length||n[19]!==ue?(fe=()=>{z&&!de.current&&K.length>0&&ue.setHighlightedIndex(K.length-1),de.current=z},pe=[z,K.length,ue],n[17]=z,n[18]=K.length,n[19]=ue,n[20]=fe,n[21]=pe):(fe=n[20],pe=n[21]),ie(fe,pe);let me,q;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]!==y?(q=()=>{M(Date.now());let e=s&&s.length>0?s.join(`, `):void 0,t=s?s.map(Iy).join(` `):void 0;return y({options:{changesFor:r,instruction:t?`${i} ${t}`:i,isHeadless:!p,requiresCookies:c,savedFlow:a,baseUrl:e},agentBackend:f,replayHost:m,onUpdate:ne,onReplayUrl:S}),()=>{y(Qe.Interrupt)}},me=[y,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]=y,n[31]=me,n[32]=q):(me=n[31],q=n[32]),ie(q,me);let he=O?v.value.replayUrl:void 0,ge=O?v.value.localReplayUrl:void 0,_e=O?v.value.videoUrl:void 0,ve,ye;n[33]!==A||n[34]!==O||n[35]!==ge||n[36]!==he||n[37]!==k||n[38]!==l||n[39]!==_e?(ve=()=>{O&&A&&k&&(Ov.getState().setExecutedPlan(A),l(Wm.Results({report:k,replayUrl:he,localReplayUrl:ge,videoUrl:_e})))},ye=[O,A,k,he,ge,_e,l],n[33]=A,n[34]=O,n[35]=ge,n[36]=he,n[37]=k,n[38]=l,n[39]=_e,n[40]=ve,n[41]=ye):(ve=n[40],ye=n[41]),ie(ve,ye);let J;n[42]===l?J=n[43]:(J=()=>{Ov.getState().setExecutedPlan(void 0),l(Wm.Main())},n[42]=l,n[43]=J);let be=J,xe,Se;n[44]!==w||n[45]!==j?(xe=()=>{if(j===void 0||!w)return;let e=setInterval(()=>{re(Date.now()-j)},1e3);return()=>clearInterval(e)},Se=[j,w],n[44]=w,n[45]=j,n[46]=xe,n[47]=Se):(xe=n[46],Se=n[47]),ie(xe,Se);let Ce;n[48]!==A||n[49]!==v||n[50]!==z||n[51]!==ue||n[52]!==be||n[53]!==w||n[54]!==x||n[55]!==ge||n[56]!==he||n[57]!==k||n[58]!==ae||n[59]!==l||n[60]!==F||n[61]!==B||n[62]!==h||n[63]!==_e?(Ce=(t,n)=>{let r=t.toLowerCase();if(F){if(n.return||r===`y`){I(!1),J_(`run:cancelled`),be();return}(n.escape||r===`n`)&&I(!1);return}if(r===`o`&&!n.ctrl&&!n.meta&&x){let{exec:t}=e(`node:child_process`);t(`open "${x.replace(/"/g,`\\"`)}"`),J_(`live_preview:opened`);return}if(n.ctrl&&t===`o`){B();return}if(n.ctrl&&t===`n`){h();return}if(z){if(ue.handleNavigation(t,n))return;if(n.escape){ae(!1);return}return}if(n.escape){if(Ze.isFailure(v)){be();return}if(w){I(!0);return}if(A&&k){Ov.getState().setExecutedPlan(A),l(Wm.Results({report:k,replayUrl:he,localReplayUrl:ge,videoUrl:_e}));return}be()}},n[48]=A,n[49]=v,n[50]=z,n[51]=ue,n[52]=be,n[53]=w,n[54]=x,n[55]=ge,n[56]=he,n[57]=k,n[58]=ae,n[59]=l,n[60]=F,n[61]=B,n[62]=h,n[63]=_e,n[64]=Ce):Ce=n[64],te(Ce);let we;n[65]!==K||n[66]!==ue.scrollOffset||n[67]!==ce?(we=K.slice(ue.scrollOffset,ue.scrollOffset+ce),n[65]=K,n[66]=ue.scrollOffset,n[67]=ce,n[68]=we):we=n[68];let Te=we,Ee;n[69]===b?Ee=n[70]:(Ee=H(ee,{items:[...b],children:Ly}),n[69]=b,n[70]=Ee);let De;n[71]===Symbol.for(`react.memo_cache_sentinel`)?(De=H(Z_,{}),n[71]=De):De=n[71];let Oe;n[72]===u.DIM?Oe=n[73]:(Oe=H(E,{color:u.DIM,children:W.pointerSmall}),n[72]=u.DIM,n[73]=Oe);let ke;n[74]!==u.TEXT||n[75]!==i?(ke=H(E,{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=U(T,{children:[De,U(E,{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]!==w||n[83]!==x?(je=x&&w&&H(T,{marginTop:0,children:U(E,{color:u.DIM,children:[` `,`Press `,H(E,{color:u.PRIMARY,children:`o`}),` to open live preview`]})}),n[80]=u.DIM,n[81]=u.PRIMARY,n[82]=w,n[83]=x,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]!==A||n[90]!==z||n[91]!==w||n[92]!==G||n[93]!==Te?(Me=z?H(T,{flexDirection:`column`,marginTop:1,children:Te}):U(se,{children:[G===0&&w&&(()=>{let e=A?xy(A.events,!1):[];return U(T,{marginTop:1,flexDirection:`column`,children:[U(T,{children:[H(zm,{}),H(E,{children:` `}),H(Dv,{text:`Starting${W.ellipsis} ${oe}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),e.map(Ry)]})})(),H(T,{flexDirection:`column`,marginTop:1,children:(A?.steps??[]).map((e,t)=>{let n=g.isSome(e.summary)?e.summary.value:e.title,r=Ty(e),i=r===void 0?void 0:kv(r),a=`${t+1}.`;if(e.status===`active`){let t=A?by(A.events,!1):[];return U(T,{flexDirection:`column`,children:[U(T,{children:[U(E,{color:u.DIM,children:[` `,a,` `]}),H(zm,{}),H(E,{children:` `}),H(Dv,{text:`${e.title} ${oe}`,baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight})]}),t.map(zy)]},e.id)}return e.status===`passed`?U(E,{children:[U(E,{color:u.DIM,children:[` `,a]}),U(E,{color:u.GREEN,children:[` `,W.tick,` `,Le(n,100)]}),i&&U(E,{color:u.DIM,children:[` `,i]})]},e.id):e.status===`failed`?U(E,{children:[U(E,{color:u.DIM,children:[` `,a]}),U(E,{color:u.RED,children:[` `,W.cross,` `,Le(n,100)]}),i&&U(E,{color:u.DIM,children:[` `,i]})]},e.id):U(E,{color:u.DIM,children:[` `,a,` `,W.circle,` `,e.title]},e.id)})})]}),n[85]=u.DIM,n[86]=u.GREEN,n[87]=u.RED,n[88]=oe,n[89]=A,n[90]=z,n[91]=w,n[92]=G,n[93]=Te,n[94]=Me):Me=n[94];let Ne;n[95]!==u.PRIMARY||n[96]!==u.YELLOW||n[97]!==F?(Ne=F&&H(T,{marginTop:1,children:U(E,{color:u.YELLOW,children:[`Stop run? `,H(E,{color:u.PRIMARY,children:`enter`}),` to stop,`,` `,H(E,{color:u.PRIMARY,children:`esc`}),` to dismiss`]})}),n[95]=u.PRIMARY,n[96]=u.YELLOW,n[97]=F,n[98]=Ne):Ne=n[98];let Pe;n[99]!==Ae||n[100]!==je||n[101]!==Me||n[102]!==Ne?(Pe=U(T,{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]===v?Fe=n[105]:(Fe=Ze.builder(v).onError(By).onDefect(Vy).orNull(),n[104]=v,n[105]=Fe);let Ie;n[106]!==Pe||n[107]!==Fe?(Ie=U(T,{flexDirection:`column`,width:`100%`,children:[Pe,Fe]}),n[106]=Pe,n[107]=Fe,n[108]=Ie):Ie=n[108];let Re;return n[109]!==Ee||n[110]!==Ie?(Re=U(se,{children:[Ee,Ie]}),n[109]=Ee,n[110]=Ie,n[111]=Re):Re=n[111],Re};function Oy(e){return e.setScreen}function ky(e){return e.agentBackend}function Ay(e){return e.browserHeaded}function jy(e){return e.replayHost}function My(e){return e.toggleNotifications}function Ny(e){return e.expanded}function Py(e){return e.setExpanded}function Fy(e){return e.toggleExpanded}function Iy(e){return`[url: ${e}]`}function Ly(e){return H(T,{paddingX:1,children:H(Gv,{src:e,alt:e})},e)}function Ry(e,t){return H(wy,{display:e,indent:` `},t)}function zy(e,t){return H(wy,{display:e,indent:` `},t)}function By(e){return H(Kv,{type:`error`,error:e})}function Vy(e){return H(Kv,{type:`defect`,error:{_tag:`Defect`,message:o.pretty(o.fail(e))}})}const Hy=e=>{try{return z.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},Uy=(e,t)=>l.runPromise(am.use(n=>n.addComment(process.cwd(),e,t)).pipe(l.provide(am.layer))),Wy=()=>j({mutationFn:({pullRequest:e,body:t})=>Uy(e,t)}),Gy=Xv.fn(l.fnUntraced(function*(e,t){return yield*(yield*nm).save(e.plan)},l.annotateLogs({fn:`saveFlowFn`}),l.provide(ve.layer))),Ky=e=>{if(!(g.isNone(e.startedAt)||g.isNone(e.endedAt)))return c.toEpochMillis(e.endedAt.value)-c.toEpochMillis(e.startedAt.value)},qy=e=>{let t=0;for(let n of e){let e=Ky(n);e!==void 0&&(t+=e)}return t},Jy=e=>{let t=N(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=kt(),s=Km(Yy),[c,l]=R(void 0),u=Wy(),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d={mode:`promiseExit`},t[1]=d):d=t[1];let[f,p]=et(Gy,d),m=f.waiting,h;t[2]===f?h=t[3]:(h=Ze.isSuccess(f),t[2]=f,t[3]=h);let _=h,v;t[4]!==u||t[5]!==n.pullRequest||t[6]!==n.toPlainText?(v=()=>{g.isSome(n.pullRequest)&&(J_(`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]=v):v=t[7];let y=v,b;t[8]!==o.GREEN||t[9]!==o.RED||t[10]!==n.toPlainText?(b=()=>{Hy(n.toPlainText)?(J_(`results:copied_to_clipboard`),l({text:`${W.tick} Copied to clipboard`,color:o.GREEN})):l({text:`${W.cross} Failed to copy to clipboard`,color:o.RED})},t[8]=o.GREEN,t[9]=o.RED,t[10]=n.toPlainText,t[11]=b):b=t[11];let x=b,S;t[12]!==n||t[13]!==m||t[14]!==_||t[15]!==p?(S=async()=>{m||_||(J_(`flow:saved`,{step_count:n.steps.length}),await p({plan:n}))},t[12]=n,t[13]=m,t[14]=_,t[15]=p,t[16]=S):S=t[16];let C=S,w;t[17]!==n.changesFor||t[18]!==n.instruction||t[19]!==s?(w=()=>{J_(`results:restarted`),Ov.getState().setExecutedPlan(void 0),s(Gm({changesFor:n.changesFor,instruction:n.instruction}))},t[17]=n.changesFor,t[18]=n.instruction,t[19]=s,t[20]=w):w=t[20];let ee=w,D;t[21]!==x||t[22]!==y||t[23]!==ee||t[24]!==C?(D=e=>{let t=e.toLowerCase();t===`y`&&x(),t===`p`&&y(),t===`s`&&C(),t===`r`&&ee()},t[21]=x,t[22]=y,t[23]=ee,t[24]=C,t[25]=D):D=t[25],te(D);let O=n.status===`passed`,k=O?o.GREEN:o.RED,A=O?W.tick:W.cross,ne=O?`Passed`:`Failed`,j,M,P,re,F,ie,I,L,z,ae,B;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]!==k||t[36]!==A||t[37]!==ne){let e=qy(n.steps);M=r??i,P=!!r&&!!i&&r!==i&&i!==void 0,j=T,ae=`column`,B=`100%`,re=1,F=1;let a;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(a=H(Z_,{}),t[49]=a):a=t[49];let s;t[50]===o.DIM?s=t[51]:(s=H(E,{color:o.DIM,children:W.pointerSmall}),t[50]=o.DIM,t[51]=s);let c;t[52]!==o.TEXT||t[53]!==n.instruction?(c=H(E,{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?(ie=U(T,{children:[a,U(E,{wrap:`truncate`,children:[` `,s,` `,c]})]}),t[55]=s,t[56]=c,t[57]=ie):ie=t[57];let l;t[58]!==k||t[59]!==A||t[60]!==ne?(l=U(E,{color:k,bold:!0,children:[A,` `,ne]}),t[58]=k,t[59]=A,t[60]=ne,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=U(E,{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?(I=U(T,{marginTop:1,children:[l,d]}),t[66]=l,t[67]=d,t[68]=I):I=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=Ky(e),i=r===void 0?void 0:kv(r),a=n.stepStatuses.get(e.id),s=a?.status===`failed`,c=s?o.RED:o.GREEN,l=s?W.cross:W.tick,u=`${t+1}.`;return U(T,{flexDirection:`column`,children:[U(E,{children:[U(E,{color:o.DIM,children:[` `,u]}),U(E,{color:c,children:[` `,l,` `,e.title]}),i&&U(E,{color:o.DIM,children:[` `,i]})]}),s&&a.summary&&U(E,{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?L=t[81]:(L=H(T,{flexDirection:`column`,marginTop:1,children:f}),t[80]=f,t[81]=L),z=e>0&&H(T,{marginTop:1,children:U(E,{color:o.DIM,children:[`Worked for `,kv(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]=k,t[36]=A,t[37]=ne,t[38]=j,t[39]=M,t[40]=P,t[41]=re,t[42]=F,t[43]=ie,t[44]=I,t[45]=L,t[46]=z,t[47]=ae,t[48]=B}else j=t[38],M=t[39],P=t[40],re=t[41],F=t[42],ie=t[43],I=t[44],L=t[45],z=t[46],ae=t[47],B=t[48];let V;t[82]===c?V=t[83]:(V=c&&H(T,{marginTop:1,children:H(E,{color:c.color,children:c.text})}),t[82]=c,t[83]=V);let oe;t[84]!==o.DIM||t[85]!==u.isPending?(oe=u.isPending&&H(T,{marginTop:1,children:U(E,{color:o.DIM,children:[`Posting to PR`,W.ellipsis]})}),t[84]=o.DIM,t[85]=u.isPending,t[86]=oe):oe=t[86];let se;t[87]!==o.GREEN||t[88]!==u.isSuccess?(se=u.isSuccess&&H(T,{marginTop:1,children:U(E,{color:o.GREEN,children:[W.tick,` Posted to PR`]})}),t[87]=o.GREEN,t[88]=u.isSuccess,t[89]=se):se=t[89];let G;t[90]!==o.RED||t[91]!==u.isError?(G=u.isError&&H(T,{marginTop:1,children:U(E,{color:o.RED,children:[W.cross,` Failed to post to PR`]})}),t[90]=o.RED,t[91]=u.isError,t[92]=G):G=t[92];let K;t[93]!==o.DIM||t[94]!==m?(K=m&&H(T,{marginTop:1,children:U(E,{color:o.DIM,children:[`Saving flow`,W.ellipsis]})}),t[93]=o.DIM,t[94]=m,t[95]=K):K=t[95];let ce;t[96]!==o.GREEN||t[97]!==_?(ce=_&&H(T,{marginTop:1,children:U(E,{color:o.GREEN,children:[W.tick,` Flow saved`]})}),t[96]=o.GREEN,t[97]=_,t[98]=ce):ce=t[98];let le;t[99]!==o.RED||t[100]!==f?(le=Ze.isFailure(f)&&H(T,{marginTop:1,children:U(E,{color:o.RED,children:[W.cross,` Failed to save flow`]})}),t[99]=o.RED,t[100]=f,t[101]=le):le=t[101];let ue;t[102]!==o.DIM||t[103]!==o.PRIMARY||t[104]!==M?(ue=M&&H(T,{flexDirection:`column`,paddingX:1,marginTop:1,children:U(E,{color:o.DIM,children:[`Replay:`,` `,H(E,{color:o.PRIMARY,bold:!0,children:M})]})}),t[102]=o.DIM,t[103]=o.PRIMARY,t[104]=M,t[105]=ue):ue=t[105];let de;t[106]!==o.DIM||t[107]!==o.PRIMARY||t[108]!==i||t[109]!==P?(de=P&&H(T,{flexDirection:`column`,paddingX:1,children:U(E,{color:o.DIM,children:[`Local Replay:`,` `,H(E,{color:o.PRIMARY,bold:!0,children:i})]})}),t[106]=o.DIM,t[107]=o.PRIMARY,t[108]=i,t[109]=P,t[110]=de):de=t[110];let fe;t[111]!==o.DIM||t[112]!==o.PRIMARY||t[113]!==a?(fe=a&&H(T,{flexDirection:`column`,paddingX:1,children:U(E,{color:o.DIM,children:[`Video:`,` `,H(E,{color:o.PRIMARY,bold:!0,children:a})]})}),t[111]=o.DIM,t[112]=o.PRIMARY,t[113]=a,t[114]=fe):fe=t[114];let pe;t[115]===n.screenshotPaths?pe=t[116]:(pe=n.screenshotPaths.map(Xy),t[115]=n.screenshotPaths,t[116]=pe);let me;return t[117]!==j||t[118]!==re||t[119]!==F||t[120]!==ie||t[121]!==I||t[122]!==L||t[123]!==z||t[124]!==V||t[125]!==oe||t[126]!==se||t[127]!==G||t[128]!==K||t[129]!==ce||t[130]!==le||t[131]!==ue||t[132]!==de||t[133]!==fe||t[134]!==pe||t[135]!==ae||t[136]!==B?(me=U(j,{flexDirection:ae,width:B,paddingY:re,paddingX:F,children:[ie,I,L,z,V,oe,se,G,K,ce,le,ue,de,fe,pe]}),t[117]=j,t[118]=re,t[119]=F,t[120]=ie,t[121]=I,t[122]=L,t[123]=z,t[124]=V,t[125]=oe,t[126]=se,t[127]=G,t[128]=K,t[129]=ce,t[130]=le,t[131]=ue,t[132]=de,t[133]=fe,t[134]=pe,t[135]=ae,t[136]=B,t[137]=me):me=t[137],me};function Yy(e){return e.setScreen}function Xy(e){return H(T,{marginTop:1,children:H(Gv,{src:e,alt:`Screenshot: ${e}`})},e)}const Zy=p.mergeAll(nm.layer,Hp.withRepoRoot(process.cwd())),Qy=()=>M({queryKey:[`saved-flows`],queryFn:()=>l.gen(function*(){return yield*(yield*nm).list()}).pipe(l.provide(Zy),l.provide(ve.layer),l.catchTag(`FindRepoRootError`,()=>l.succeed([])),l.runPromise)}),$y=new cn({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}),eb=()=>M({queryKey:[`git-state`],queryFn:async()=>{let e=await l.runPromiseExit(l.gen(function*(){return yield*(yield*Hp).getState()}).pipe(l.provide(Hp.withRepoRoot(process.cwd())),l.catchTag(`FindRepoRootError`,()=>l.succeed($y)),l.timeoutOrElse({duration:1e4,onTimeout:()=>l.succeed($y)}),l.provide(ve.layer)));return u.isSuccess(e)?e.value:$y}}),tb=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],nb=(e,t)=>{let n=dn.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=tb(e),i={title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r},a=e.environment.cookies;J_(`flow:reused`,{slug:e.slug,step_count:r.length}),Km.getState().setScreen(Gm({changesFor:n,instruction:e.flow.userInstruction,savedFlow:i,requiresCookies:a}))},rb=()=>{let e=N(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=kt(),[n]=Dt(),r=Km(ib),{data:i}=eb(),{data:a,isLoading:o}=Qy(),s=a===void 0?[]:a,{highlightedIndex:c,setHighlightedIndex:l,scrollOffset:u,handleNavigation:d}=Vm({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);te((e,t)=>{if(!d(e,t)){if(t.return){let e=s[c];e&&nb(e,i?.mainBranch??`main`)}t.escape&&r(Wm.Main())}});let h=T,g=`${s.length} flow${s.length===1?``:`s`}`,_;e[1]===g?_=e[2]:(_=H(T,{paddingX:1,children:H(Jm,{title:`Saved flows`,subtitle:g})}),e[1]=g,e[2]=_);let v;e[3]===o?v=e[4]:(v=o&&H(T,{marginTop:1,paddingX:1,children:H(zm,{message:`Loading saved flows...`})}),e[3]=o,e[4]=v);let y=!o&&s.length===0&&H(T,{marginTop:1,paddingX:1,flexDirection:`column`,children:U(E,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,H(E,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),b=!o&&s.length>0&&H(T,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:m.map((e,n)=>{let r=n+u,a=r===c,o=tb(e).length;return U(Mt,{onClick:()=>{l(r),nb(e,i?.mainBranch??`main`)},children:[H(E,{color:a?t.PRIMARY:t.DIM,children:a?`${W.pointer} `:` `}),H(E,{color:a?t.PRIMARY:t.TEXT,bold:a,children:Bm(Le(e.title,f-1),f)}),H(E,{color:t.DIM,children:Bm(`${o} step${o===1?``:`s`}`,10)}),H(E,{color:t.DIM,children:Le(e.description,p)})]},e.slug)})}),x;return e[5]!==h||e[6]!==_||e[7]!==v||e[8]!==y||e[9]!==b?(x=U(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 ib(e){return e.setScreen}const ab=e=>{let t=N(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=kt();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=U(E,{color:r.GREEN,children:[W.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=U(E,{color:r.PURPLE,children:[W.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=U(E,{color:r.DIM,children:[W.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},ob=e=>{let t=N(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=kt(),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=H(T,{flexDirection:`column`,children:H(E,{color:o.DIM,children:`No matching results`})}),t[11]=o.DIM,t[12]=e),f=e;break bb1}l=T,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=Pm(e,a),s=Fm(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 U(E,{wrap:`truncate`,children:[H(E,{color:n?o.PRIMARY:o.DIM,children:n?`${W.pointer} `:` `}),e._tag===`WorkingTree`?U(E,{color:o.GREEN,children:[W.bullet,` `]}):null,u?H(ab,{status:u}):null,H(E,{color:n?o.PRIMARY:o.TEXT,bold:n,children:i}),l?U(E,{children:[` `,U(E,{color:u===`open`?o.GREEN:u===`merged`?o.PURPLE:o.DIM,children:[`#`,l]}),u?U(E,{color:o.DIM,children:[` `,u]}):null]}):null,s&&!l?U(E,{color:o.DIM,children:[` `,s]}):null]},Vn(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?H(T,{children:U(E,{color:o.DIM,children:[` Loading PRs and branches`,W.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?H(T,{children:U(E,{color:o.DIM,children:[` `,n.length-8,` more `,W.arrowUp,`/`,W.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=U(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},sb=({gitState:e,onSelect:t})=>{let[n,r]=R(!1),[i,a]=R(``),[o,s]=R(0),{data:c=[]}=M({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>jm(e),enabled:!!e}),{data:l=[],isLoading:u}=M({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>Nm(e),enabled:n&&!!e}),d=I(()=>[...c,...l],[c,l]),f=I(()=>Lm(d,i,e),[d,i,e]);ie(()=>{s(0)},[i]);let p=re(()=>{r(!0),a(``),s(0)},[]),m=re(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:f,localOptions:c,remoteLoading:u,openPicker:p,closePicker:m,handleContextSelect:re(e=>{t(e),m()},[t,m]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=wt(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)}}},cb=e=>{let t=new Set;return e.filter(e=>t.has(e.path)?!1:(t.add(e.path),!0))},lb=e=>M({queryKey:[`test-coverage`,e?.fingerprint],queryFn:async()=>{if(!e?.isGitRepo||!e.hasChangesFromMain&&!e.hasUnstagedChanges)return;let t=e.mainBranch??`main`,n=await l.runPromiseExit(l.gen(function*(){let e=yield*Hp,n=yield*km,r=yield*e.getChangedFiles(dn.makeUnsafe({_tag:`WorkingTree`})),i=yield*e.getChangedFiles(dn.makeUnsafe({_tag:`Changes`,mainBranch:t})),a=cb([...r,...i]);if(a.length!==0)return yield*n.analyze(a)}).pipe(l.provide(Hp.withRepoRoot(process.cwd())),l.provide(km.layer),l.timeoutOrElse({duration:15e3,onTimeout:()=>l.succeed(void 0)}),l.provide(ve.layer)));if(u.isSuccess(n))return n.value},enabled:!!(e?.isGitRepo&&(e.hasChangesFromMain||e.hasUnstagedChanges)),staleTime:3e4}),ub=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],db=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],fb=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],pb=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],mb=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],hb=(e,t)=>{if(!e)return ub;switch(e._tag){case`WorkingTree`:return db;case`Branch`:return fb;case`PullRequest`:return pb;case`Commit`:return mb;default:return ub}},gb=e=>e>=70?`green`:e>=40?`yellow`:`#e06c50`,_b=e=>e>=70?`#0a2b0a`:e>=40?`#332b00`:`#331510`,vb=e=>`Use Expect to test your changes.`,yb=e=>{let t=Math.round(e/100*10),n=10-t;return{filled:`█`.repeat(t),empty:`░`.repeat(n)}},bb=({gitState:e})=>{let t=kt(),[n]=Dt(),r=K_(e=>e.instructionHistory),i=Km(e=>e.setScreen),[a,o]=R(void 0),[s,c]=R(``),[l,u]=R(0),[d,f]=R(0),[p,m]=R(!1),[h,g]=R(void 0),[_,v]=R(-1),[y,b]=R(``),x=rv(e=>e.cookiesEnabled),S=rv(e=>e.toggleCookies),{data:C}=lb(e),w=()=>{if(r.length===0)return;let e=_+1;e>=r.length||(_===-1&&b(s),v(e),c(r[e]),u(e=>e+1))},ee=()=>{if(_<=-1)return;let e=_-1;v(e),c(e===-1?y:r[e]),u(e=>e+1)},D=sb({gitState:e??null,onSelect:e=>{o(e),J_(`context:selected`,{context_type:{WorkingTree:`working_tree`,Branch:`branch`,PullRequest:`pull_request`,Commit:`commit`}[e._tag]})}}),O=D.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,k=a??O??null,A=hb(k,e??null);ie(()=>{f(0)},[k,e]);let ne=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;k?._tag===`Commit`?a=dn.makeUnsafe({_tag:`Commit`,hash:k.hash}):k?._tag===`Branch`||k?._tag===`PullRequest`?(k.branch.name&&(rm(process.cwd(),k.branch.name),qm.invalidateQueries({queryKey:[`git-state`]})),a=dn.makeUnsafe({_tag:`Branch`,mainBranch:r})):a=dn.makeUnsafe({_tag:`Changes`,mainBranch:r}),K_.getState().rememberInstruction(n),x||Um(n)?i(Gm({changesFor:a,instruction:n,requiresCookies:x})):i(Wm.CookieSyncConfirm({changesFor:a,instruction:n}))},j=L(s);j.current=s;let M=D.createInputChangeHandler(j,e=>{c(e),h&&g(void 0)}),N=!s.includes(`
|
|
43
|
+
`),P=s===``&&!D.pickerOpen&&A.length>0,re=P&&!p&&n>=80,F=A[d%A.length];return te((e,t)=>{if(D.pickerOpen){if(t.escape){D.closePicker();return}if(t.downArrow||t.ctrl&&e===`n`){D.setPickerIndex(Math.min(D.filteredOptions.length-1,D.pickerIndex+1));return}if(t.upArrow||t.ctrl&&e===`p`){D.setPickerIndex(Math.max(0,D.pickerIndex-1));return}if(t.return||t.tab){let e=D.filteredOptions[D.pickerIndex];e&&D.handleContextSelect(e);return}if(t.backspace||t.delete){D.pickerQuery.length===0?D.closePicker():D.setPickerQuery(D.pickerQuery.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&D.setPickerQuery(D.pickerQuery+e);return}if(N&&t.upArrow){w();return}if(N&&t.downArrow){ee();return}if(t.ctrl&&e===`k`){S(),J_(`cookies:toggled`,{enabled:!x});return}if(t.tab&&!t.shift&&P&&F){c(F),u(e=>e+1),J_(`suggestion:accepted`);return}if(!(t.tab&&t.shift)&&P){if(t.rightArrow){f(e=>(e+1)%A.length),m(!0);return}if(t.leftArrow){f(e=>(e-1+A.length)%A.length),m(!0);return}}},{isActive:!0}),U(T,{flexDirection:`column`,width:`100%`,paddingY:1,children:[H(T,{flexDirection:`column`,marginBottom:1,paddingX:1,children:H(Z_,{})}),(e?.hasUntestedChanges||C&&C.totalCount>0)&&!(C&&C.totalCount>0&&C.percent>=90)&&U(T,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:C&&C.totalCount>0?_b(C.percent):t.BANNER_BG,width:`100%`,flexDirection:`column`,gap:0,children:[(()=>{if(C&&C.totalCount>0)return U(T,{children:[U(E,{color:gb(C.percent),bold:!0,children:[W.warning,` Untested changes`]}),H(E,{children:` `}),H(E,{color:gb(C.percent),children:yb(C.percent).filled}),H(E,{color:t.DIM,children:yb(C.percent).empty}),U(E,{color:gb(C.percent),children:[` `,C.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 U(T,{children:[U(E,{color:t.YELLOW,bold:!0,children:[W.warning,` Untested changes detected`]}),n.length>0&&U(se,{children:[U(E,{color:t.DIM,children:[` `,n.length,` file`,n.length===1?``:`s`,` `]}),r>0&&U(E,{color:t.GREEN,children:[`+`,r]}),r>0&&i>0&&H(E,{color:t.DIM,children:` `}),i>0&&U(E,{color:t.RED,children:[`-`,i]})]})]})})(),H(E,{color:t.DIM,children:C&&C.totalCount>0?vb(C.percent):`Describe what to test and hit enter to verify your changes.`})]}),U(T,{flexDirection:`column`,width:`100%`,children:[U(T,{paddingX:1,children:[!e&&H(zm,{message:`loading context`}),e&&e.isGitRepo&&k&&H(Mt,{fullWidth:!1,onClick:()=>{D.pickerOpen?D.closePicker():D.openPicker()},children:U(E,{color:t.DIM,children:[W.bullet,` `,U(E,{color:t.PRIMARY,children:[`@`,Im(k,e)]}),Fm(k,e)&&` (${Fm(k,e)})`]})})]}),H(Mt,{children:H(T,{flexDirection:`column`,marginTop:1,backgroundColor:t.INPUT_BG,width:`100%`,paddingX:1,paddingY:1,children:U(T,{children:[H(E,{color:t.PRIMARY,children:`❯ `}),H(T,{flexGrow:1,children:H(Rt,{focus:!D.pickerOpen,multiline:!0,placeholder:F?`${F} [tab]`:``,value:s,onSubmit:ne,onUpArrowAtTop:N?void 0:w,onDownArrowAtBottom:N?void 0:ee,onChange:M},l)}),re?H(E,{color:t.DIM,children:` ←→ cycle test suggestions`}):null]})})}),e?.isGitRepo&&D.pickerOpen&&U(At,{color:t.BORDER,children:[U(T,{marginBottom:0,children:[H(E,{color:t.DIM,children:`@ `}),H(E,{color:t.PRIMARY,children:D.pickerQuery}),H(E,{color:t.DIM,children:D.pickerQuery?``:`type to filter`})]}),H(ob,{options:D.filteredOptions,selectedIndex:D.pickerIndex,isLoading:D.remoteLoading,gitState:e})]}),e?.isGitRepo&&!D.pickerOpen&&H(T,{marginTop:1,paddingX:1,children:U(E,{color:t.DIM,children:[H(E,{color:t.PRIMARY,children:`@`}),` add context`]})})]}),H(qv,{message:h})]})},xb=e=>{let t=N(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=U(E,{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=U(E,{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=U(se,{children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Sb=e=>{let t=N(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=H(E,{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)=>U(T,{children:[e.onClick?H(Mt,{fullWidth:!1,onClick:e.onClick,children:H(xb,{segment:e,mutedColor:i})}):H(xb,{segment:e,mutedColor:i}),t<n.length-1&&H(E,{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=U(T,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s},Cb=x.Struct({version:x.String}),wb=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1},Tb=l.gen(function*(){let e=yield*l.tryPromise({try:()=>fetch(`https://registry.npmjs.org/${gt}/latest`).then(e=>e.json()),catch:e=>Error(`npm registry fetch failed: ${e}`)});return(yield*l.try({try:()=>x.decodeUnknownSync(Cb)(e),catch:e=>Error(`npm response decode failed: ${e}`)})).version}).pipe(l.timeoutOrElse({duration:5e3,onTimeout:()=>l.succeed(void 0)})),Eb=()=>{let{data:e}=M({queryKey:[`update-check`],queryFn:async()=>{let e=await l.runPromiseExit(Tb);if(u.isSuccess(e))return e.value},staleTime:36e5,retry:!1,refetchOnWindowFocus:!1});return{latestVersion:e,updateAvailable:e!==void 0&&wb(e,`0.0.9`)}},Db=(e,t)=>{let n=N(87);if(n[0]!==`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`){for(let e=0;e<87;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`}let r=kt(),i=Km(Ab),a=rv(jb),o=rv(Mb),s=K_(Nb),c=K_(Pb),l=Ov(Fb);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(Wm.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(Wm.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(Wm.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(Wm.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(Wm.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(Gm({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(Gm({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(Wm.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],g.isSome(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:()=>{Ov.getState().setExecutedPlan(void 0),i(Gm({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:()=>{Ov.getState().setExecutedPlan(void 0),i(Wm.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}}},Ob=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,kb=()=>{let e=N(34);if(e[0]!==`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`){for(let t=0;t<34;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`0545e7691866a2045c1228f27b801065cf39232a2a018c782c9ae2928aa6e0a5`}let[t]=Dt(),{data:n}=eb(),r=Km(Ib),{latestVersion:i,updateAvailable:a}=Eb(),o=Db(r,n),s,c,l,u,d,f,p,m;if(e[1]!==o||e[2]!==t||e[3]!==i||e[4]!==r._tag||e[5]!==a){let n=a?[...o,{key:`ctrl+u`,label:`v${i} available`,cta:!0,color:Y.warning}]:o;u=n.filter(Lb);let h=Re(Ob(u)),g=zb,_=n.filter(Bb),v=g(_)+h+2>t?_.filter(Vb):_,y=g(v);l=Math.max(0,t-y-h-2),c=T,p=`column`,e[14]!==t||e[15]!==r._tag?(m=r._tag===`Testing`?H(Dv,{text:`─`.repeat(t),baseColor:Y.shimmerBase,highlightColor:Y.shimmerHighlight,speed:3}):H(E,{color:Y.border,children:`─`.repeat(t)}),e[14]=t,e[15]=r._tag,e[16]=m):m=e[16],s=T,d=1,f=v.map(Hb),e[1]=o,e[2]=t,e[3]=i,e[4]=r._tag,e[5]=a,e[6]=s,e[7]=c,e[8]=l,e[9]=u,e[10]=d,e[11]=f,e[12]=p,e[13]=m}else s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13];let h;e[17]===l?h=e[18]:(h=` `.repeat(l),e[17]=l,e[18]=h);let g;e[19]===h?g=e[20]:(g=H(E,{children:h}),e[19]=h,e[20]=g);let _;e[21]===u?_=e[22]:(_=u.length>0?H(Sb,{segments:u,color:Y.primary,mutedColor:Y.textMuted}):null,e[21]=u,e[22]=_);let v;e[23]!==s||e[24]!==d||e[25]!==f||e[26]!==g||e[27]!==_?(v=U(s,{paddingX:d,children:[f,g,_]}),e[23]=s,e[24]=d,e[25]=f,e[26]=g,e[27]=_,e[28]=v):v=e[28];let y;return e[29]!==c||e[30]!==p||e[31]!==m||e[32]!==v?(y=U(c,{flexDirection:p,children:[m,v]}),e[29]=c,e[30]=p,e[31]=m,e[32]=v,e[33]=y):y=e[33],y};function Ab(e){return e.setScreen}function jb(e){return e.cookiesEnabled}function Mb(e){return e.toggleCookies}function Nb(e){return e.notifications}function Pb(e){return e.toggleNotifications}function Fb(e){return e.expanded}function Ib(e){return e.screen}function Lb(e){return!e.cta}function Rb(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function zb(e){return Re(e.map(Rb).join(` `))}function Bb(e){return e.cta}function Vb(e){return e.key!==`ctrl+p`}function Hb(e,t){let n=U(E,{children:[t>0?` `:``,e.color?U(E,{backgroundColor:e.color,color:`black`,children:[` `,H(E,{bold:!0,children:e.label}),` `,U(E,{children:[`[`,e.key,`]`]}),` `]}):U(E,{children:[U(E,{color:Y.textMuted,children:[e.label,` `]}),U(E,{color:Y.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?H(Mt,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let Ub=null;const Wb=e=>{Ub=e},Gb=()=>Ub?.clear(),Kb=e=>{let t=N(34);if(t[0]!==`e6ac87aa0f631766a38fac7cfbcee5d6c83ce6fd1edd967a6457097df0e89416`){for(let e=0;e<34;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e6ac87aa0f631766a38fac7cfbcee5d6c83ce6fd1edd967a6457097df0e89416`}let{agent:n}=e,r=Km(qb),i=Km(Jb),a=Km(Yb),{data:o}=eb(),s=tt(Yv),c,l;t[1]!==n||t[2]!==s?(c=()=>{s(g.some(n))},l=[n,s],t[1]=n,t[2]=s,t[3]=c,t[4]=l):(c=t[3],l=t[4]),ie(c,l);let u;t[5]!==r._tag||t[6]!==i?(u=()=>{if(r._tag===`CookieSyncConfirm`){i(Wm.Main());return}if(r._tag===`PortPicker`){i(Wm.Main());return}if(r._tag===`Results`){Ov.getState().setExecutedPlan(void 0),i(Wm.Main());return}r._tag!==`Testing`&&i(Wm.Main())},t[5]=r._tag,t[6]=i,t[7]=u):u=t[7];let d=u,{updateAvailable:f}=Eb(),{exit:p}=O(),[,m]=R(0),[,h]=Dt(),_;t[8]!==p||t[9]!==o?.isGitRepo||t[10]!==d||t[11]!==a||t[12]!==r._tag||t[13]!==m||t[14]!==f?(_=(e,t)=>{if(t.ctrl&&e===`l`){Gb(),m(Xb);return}if(t.ctrl&&e===`u`&&f){p(),process.stdout.write(pt),oe(`npm`,[`install`,`-g`,`${gt}@latest`],{stdio:`inherit`});return}t.escape&&r._tag!==`Main`&&d(),t.ctrl&&e===`p`&&r._tag===`Main`&&o?.isGitRepo&&a(Wm.SelectPr()),t.ctrl&&e===`r`&&r._tag===`Main`&&a(Wm.SavedFlowPicker())},t[8]=p,t[9]=o?.isGitRepo,t[10]=d,t[11]=a,t[12]=r._tag,t[13]=m,t[14]=f,t[15]=_):_=t[15],te(_);let v;t[16]!==o||t[17]!==r._tag||t[18]!==r.baseUrls||t[19]!==r.changesFor||t[20]!==r.instruction||t[21]!==r.localReplayUrl||t[22]!==r.replayUrl||t[23]!==r.report||t[24]!==r.requiresCookies||t[25]!==r.savedFlow||t[26]!==r.videoUrl?(v=()=>{if(!o)return H(bb,{gitState:void 0});switch(r._tag){case`PortPicker`:return H(hv,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies});case`Testing`:return H(Dy,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies,baseUrls:r.baseUrls});case`Results`:return H(Jy,{report:r.report,replayUrl:r.replayUrl,localReplayUrl:r.localReplayUrl,videoUrl:r.videoUrl});case`SelectPr`:return H(Ym,{});case`CookieSyncConfirm`:return H($_,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow});case`SavedFlowPicker`:return H(rb,{});default:return H(bb,{gitState:o})}},t[16]=o,t[17]=r._tag,t[18]=r.baseUrls,t[19]=r.changesFor,t[20]=r.instruction,t[21]=r.localReplayUrl,t[22]=r.replayUrl,t[23]=r.report,t[24]=r.requiresCookies,t[25]=r.savedFlow,t[26]=r.videoUrl,t[27]=v):v=t[27];let y=v,b;t[28]===y?b=t[29]:(b=H(T,{flexGrow:1,children:y()}),t[28]=y,t[29]=b);let x;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(x=H(kb,{}),t[30]=x):x=t[30];let S;return t[31]!==h||t[32]!==b?(S=H(xt,{children:U(T,{flexDirection:`column`,width:`100%`,height:h,children:[b,x]})}),t[31]=h,t[32]=b,t[33]=S):S=t[33],S};function qb(e){return e.screen}function Jb(e){return e.setScreen}function Yb(e){return e.navigateTo}function Xb(e){return e+1}const Zb=()=>{let e=ke();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`},Qb=()=>new Promise(e=>{ae(Zb(),()=>e())}),$b=e=>l.runPromise(Zv(l.gen(function*(){let t=yield*Wp,n=yield*Gp,r=yield*U_,i=Date.now();yield*r.capture(`session:started`,{mode:`headless`,skip_planning:!1,browser_headed:e.headed}),console.log(`expect v${ft}`),console.log(`Testing ${fn(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(C.tap(e=>l.sync(()=>{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(`${W.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${W.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${W.cross} ${t.stepId} ${t.message}`);break}})),C.runLast,l.map(t=>t._tag===`Some`?t.value:new Kn({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!e.headed,requiresCookies:!1,testCoverage:g.none(),title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),c=yield*n.report(s),u=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`passed`).length,d=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`failed`).length;yield*r.capture(`run:completed`,{plan_id:s.id??`direct`,passed:u,failed:d,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*l.promise(()=>Qb()),process.exit(c.status===`passed`?0:1)}).pipe(l.provide(Jv({verbose:e.verbose,agent:e.agent}))))),ex={error:G.red,warn:G.yellow,info:G.cyan,success:G.green,dim:G.dim},tx={error:(...e)=>{console.log(ex.error(e.join(` `)))},warn:(...e)=>{console.log(ex.warn(e.join(` `)))},info:(...e)=>{console.log(ex.info(e.join(` `)))},success:(...e)=>{console.log(ex.success(e.join(` `)))},dim:(...e)=>{console.log(ex.dim(e.join(` `)))},log:(...e)=>{console.log(e.join(` `))},break:()=>{console.log(``)}},nx=()=>{tx.break(),tx.log(`Cancelled.`),tx.break(),process.exit(0)},rx=e=>ut(e,{onCancel:nx}),ix=(e,t)=>dt({text:e,isSilent:t?.silent}),ax=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],ox=()=>ax.some(e=>!!process.env[e]),sx=()=>!process.stdin.isTTY,cx={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`},lx=`npx skills add https://github.com/millionco/expect --skill expect`,ux=()=>{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`},dx=e=>e||ox()||sx(),fx=e=>new Promise(t=>{ae(e,e=>{t(!e)})}),px=async(e={})=>{let t=dx(e.yes??!1),n=cx[ux()];tx.break(),tx.log(` ${G.red(W.cross)}${G.green(W.tick)} ${G.bold(`Expect`)} ${ex.dim(`v${ft}`)}`),tx.break(),Va().length===0&&(tx.error(`No supported coding agent found. expect requires one of: Claude Code, Codex, or Cursor.`),tx.break(),tx.log(` Install one to get started:`),tx.log(` ${ex.info(`Claude Code`)} ${ex.dim(`https://docs.anthropic.com/en/docs/claude-code`)}`),tx.log(` ${ex.info(`Codex`)} ${ex.dim(`https://github.com/openai/codex`)}`),tx.log(` ${ex.info(`Cursor`)} ${ex.dim(`https://cursor.com`)}`),tx.break(),process.exit(1));let r=ix(`Installing expect-cli globally...`).start();await fx(n)?r.succeed(`Installed! You can now run ${ex.info(`expect-cli`)} from anywhere.`):(r.fail(`Failed to install globally.`),tx.dim(` Run manually: ${ex.info(n)}`)),tx.break();let i=t;if(t||(i=(await rx({type:`confirm`,name:`installSkill`,message:`Install the ${ex.info(`expect`)} skill for your coding agent?`,initial:!0})).installSkill),i){let e=ix(`Installing skill...`).start();await fx(lx)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),tx.dim(` Run manually: ${ex.info(lx)}`))}tx.break(),tx.success(`You're all set!`),tx.log(` Run ${ex.info(`expect-cli`)} in any project to start testing.`),tx.break()},mx=[`packages/*`,`apps/*`],hx=e=>ht.some(t=>e.includes(t)),gx=l.fn(`detectAgent`)(function*(e){let t=yield*f.FileSystem;for(let[n,r]of Object.entries(_t)){let i=K.join(e,n);if(yield*t.exists(i).pipe(l.catchTag(`PlatformError`,()=>l.succeed(!1))))return r}let n=K.join(e,`package.json`),r=yield*t.readFileString(n).pipe(l.catchTag(`PlatformError`,()=>l.succeed(``)));if(r){let e=yield*l.try({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})}).pipe(l.catchTag(`JsonParseError`,()=>l.succeed(void 0)));if(e?.packageManager){let t=e.packageManager.split(`@`)[0];if(t)return t}}return`npm`}),_x=l.fn(`readPackageJson`)(function*(e){let t=yield*f.FileSystem,n=K.join(e,`package.json`),r=yield*t.readFileString(n);return yield*l.try({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})})}),vx=l.fn(`listWorkspaceDirectories`)(function*(e){let t=yield*f.FileSystem,n=[];for(let r of mx){let i=K.join(e,K.dirname(r)),a=yield*t.readDirectory(i).pipe(l.catchTag(`PlatformError`,()=>l.succeed([])));for(let e of a){let r=K.join(i,e);(yield*t.stat(r).pipe(l.catchTag(`PlatformError`,()=>l.succeed(void 0))))?.type===`Directory`&&n.push(r)}}return n}),yx=(e,t,n)=>new Promise(r=>{B(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})})}),bx=l.fn(`discoverPackages`)(function*(e){let t=yield*vx(e),n=[];for(let e of t){let t=yield*_x(e).pipe(l.catchTag(`PlatformError`,()=>l.succeed(void 0)),l.catchTag(`JsonParseError`,()=>l.succeed(void 0)));if(!t?.scripts)continue;let r=Object.keys(t.scripts).filter(hx);r.length!==0&&n.push({packageName:t.name??K.basename(e),directory:e,scripts:r})}return n}),xx=async(e,t)=>{let n=l.gen(function*(){let n=yield*gx(e),r=yield*bx(e);return yield*l.forEach(r,e=>l.gen(function*(){t.onPackageStart(e.packageName,e.scripts);let r=[];for(let i of e.scripts){let a=yield*l.promise(()=>yx(n,e.directory,i));t.onScriptDone(e.packageName,a),r.push(a)}return{packageName:e.packageName,directory:e.directory,results:r}}),{concurrency:4})});return l.runPromise(n.pipe(l.provide(ve.layer)))},Sx=e=>{let t=N(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=H(E,{bold:!0,children:`expect audit`}),a=H(E,{children:` `}),t[3]=i,t[4]=a):(i=t[3],a=t[4]),r=U(T,{flexDirection:`column`,paddingY:1,children:[i,a,e.map(Ax)]}),t[1]=n,t[2]=r}else r=t[2];return r},Cx=e=>{let t=N(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=H(E,{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&&U(E,{color:`yellow`,children:[`Run `,H(E,{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&&U(E,{color:`green`,children:[`Looking good! Run `,H(E,{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=U(T,{flexDirection:`column`,gap:1,children:[s,c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u},wx=async()=>{let e=process.cwd(),t={current:new Map},n,r,i=D(H(()=>{let[e,t]=R(new Map),[i,a]=R();return n=e=>t(new Map(e)),r=a,U(T,{flexDirection:`column`,children:[H(Sx,{statusMap:e}),i&&H(Cx,{results:i})]})},{})),a=await xx(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)},Tx=async()=>{let e=process.cwd();console.log(``),console.log(G.bold(`expect audit`)),console.log(``);let t=await xx(e,{onPackageStart:(e,t)=>{console.log(`${W.arrowRight} ${G.bold(e)} (${t.join(`, `)})`)},onScriptDone:(e,t)=>{let n=t.passed?G.green(W.tick):G.red(W.cross);if(console.log(` ${n} ${t.script}`),!t.passed){let e=t.output.split(`
|
|
45
45
|
`).slice(-3).join(`
|
|
46
|
-
`);console.log(
|
|
46
|
+
`);console.log(G.dim(` ${e.split(`
|
|
47
47
|
`).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?
|
|
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?G.red:G.green;console.log(a(G.bold(i))),r>0?(console.log(``),console.log(G.yellow(`Run ${G.bold(`expect`)} to test your changes in a real browser and catch issues before they ship.`))):(console.log(``),console.log(G.green(`Looking good! Run ${G.bold(`expect`)} to verify your changes work end-to-end in the browser.`))),console.log(``),r>0&&process.exit(1)},Ex=async()=>{ox()||sx()?await Tx():await wx()};function Dx(e){return e.passed}function Ox(e){return U(T,{flexDirection:`column`,children:[U(E,{children:[` `,e.passed?H(E,{color:`green`,children:W.tick}):H(E,{color:`red`,children:W.cross}),` `,e.script]}),!e.passed&&U(E,{color:`gray`,children:[` `,e.output.split(`
|
|
49
49
|
`).slice(-3).join(`
|
|
50
|
-
`)]})]},e.script)}function kx(e){return
|
|
50
|
+
`)]})]},e.script)}function kx(e){return U(E,{color:`gray`,children:[` `,H(Ie,{type:`dots`}),` `,e]},e)}function Ax(e){let[t,n]=e;return U(T,{flexDirection:`column`,children:[U(T,{children:[n.done&&H(E,{children:n.completed.every(Dx)?H(E,{color:`green`,children:W.tick}):H(E,{color:`red`,children:W.cross})}),!n.done&&H(E,{color:`white`,children:H(Ie,{type:`dots`})}),U(E,{bold:!0,children:[` `,t]})]}),n.completed.map(Ox),!n.done&&n.scripts.filter(e=>!n.completed.some(t=>t.script===e)).slice(0,1).map(kx)]},t)}const jx=[`unstaged`,`branch`,`changes`],Mx=new w().name(`expect`).description(`AI-powered browser testing for your changes`).version(ft,`-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
51
|
Examples:
|
|
52
52
|
$ expect open interactive TUI
|
|
53
53
|
$ expect -m "test the login flow" -y run immediately
|
|
54
54
|
$ expect --headed -m "smoke test" -y run with a visible browser
|
|
55
55
|
$ expect --target branch test all branch changes
|
|
56
|
-
$ expect --target unstaged test unstaged changes`),Nx=`\x1B[?1000l\x1B[?1006l`,Px=async e=>{let t=Date.now();await Y_(),process.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`),process.on(`exit`,()=>process.stdout.write(Nx+
|
|
56
|
+
$ expect --target unstaged test unstaged changes`),Nx=`\x1B[?1000l\x1B[?1006l`,Px=async e=>{let t=Date.now();await Y_(),process.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`),process.on(`exit`,()=>process.stdout.write(Nx+pt));let n=D(H($e,{initialValues:[[Yv,g.some(e)]],children:H(ne,{client:qm,children:H(Kb,{agent:e})})}));Wb(n),await n.waitUntilExit(),await X_(t),process.stdout.write(Nx+pt),process.exit(0)},Fx=async e=>{let t=process.cwd();return l.runPromise(l.gen(function*(){let t=yield*Hp,n=yield*t.getMainBranch,r=yield*t.getCurrentBranch;return e===`branch`?{changesFor:dn.makeUnsafe({_tag:`Branch`,mainBranch:n}),currentBranch:r}:e===`changes`?{changesFor:dn.makeUnsafe({_tag:`Changes`,mainBranch:n}),currentBranch:r}:{changesFor:dn.makeUnsafe({_tag:`WorkingTree`}),currentBranch:r}}).pipe(l.provide(Hp.withRepoRoot(t))))},Ix=(e,t)=>{K_.setState({...e.agent?{agentBackend:e.agent}:{},browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),e.message?Km.setState({screen:Wm.Testing({changesFor:t,instruction:e.message})}):Km.setState({screen:Wm.Main()})},Lx=async(e,t)=>{let{changesFor:n}=await Fx(e);return $b({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})},Rx=async(e,t)=>{let{changesFor:n}=await Fx(e);Ix(t,n),Px(t.agent??`claude`)};Mx.command(`init`).description(`set up expect for your coding agent`).option(`-y, --yes`,`skip confirmation prompts`).action(async e=>{await px(e)}),Mx.command(`audit`).description(`audit your workspace for lint, type, and formatting issues`).action(async()=>{await Ex()}),Mx.action(async()=>{let e=Mx.opts(),t=e.target??`changes`;if(jx.includes(t)||Mx.error(`Unknown target: ${t}. Use ${jx.join(`, `)}.`),ox()||sx())return Lx(t,e);e.message||e.flow||e.yes?await Rx(t,e):(K_.setState({browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),Px(e.agent??`claude`))}),Mx.parse();export{};
|
|
57
57
|
//# sourceMappingURL=index.js.map
|