expect-cli 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,65 +1,57 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import{Command as t}from"commander";import{Box as n,Static as r,Text as i,render as a,useInput as o,useStdout as s}from"ink";import{QueryClient as c,QueryClientProvider as l,useMutation as u,useQuery as d}from"@tanstack/react-query";import{c as f}from"react/compiler-runtime";import{createContext as p,useCallback as m,useContext as h,useEffect as g,useMemo as _,useRef as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";import C from"figures";import w from"picocolors";import*as T from"node:url";import{fileURLToPath as E}from"node:url";import{z as D}from"zod";import{z as O}from"zod/v4";import*as k from"node:child_process";import{exec as ee,execSync as te}from"node:child_process";import*as ne from"node:crypto";import{createHash as A}from"node:crypto";import*as j from"node:fs";import{createReadStream as re}from"node:fs";import*as ie from"node:os";import{platform as ae}from"node:os";import*as oe from"node:path";import se,{join as ce,normalize as le}from"node:path";import*as ue from"node:readline";import{createInterface as de}from"node:readline";import{NodeFileSystem as fe,NodeServices as pe}from"@effect/platform-node";import{Buffer as me}from"node:buffer";import{spawn as M}from"child_process";import{EventEmitter as he}from"node:events";import*as ge from"node:fs/promises";import _e from"ink-spinner";import ve from"cli-truncate";import ye from"string-width";import{create as be}from"zustand";import{RegistryProvider as xe,useAtom as Se,useAtomSet as Ce,useAtomValue as we}from"@effect/atom-react";import{createJSONStorage as Te,persist as Ee}from"zustand/middleware";import De from"pretty-ms";import{detectTerminal as Oe}from"detect-terminal";import ke from"supports-terminal-graphics";import Ae from"ink-link";import{dirname as je,posix as Me,sep as Ne}from"path";import{AsyncLocalStorage as Pe}from"node:async_hooks";import"node-notifier";import Fe from"prompts";import Ie from"ora";var Le=Object.create,Re=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyNames,Ve=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),We=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Be(t),a=0,o=i.length,s;a<o;a++)s=i[a],!He.call(e,s)&&s!==n&&Re(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ze(t,s))||r.enumerable});return e},Ge=(e,t,n)=>(n=e==null?{}:Le(Ve(e)),We(t||!e||!e.__esModule?Re(n,`default`,{value:e,enumerable:!0}):n,e)),Ke=e(import.meta.url);const N=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},qe={pipe(){return N(this,arguments)}},Je=function(){function e(){}return e.prototype=qe,e}(),P=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},F=e=>e,Ye=e=>()=>e,Xe=Ye(!0),Ze=Ye(!1),Qe=Ye(null),$e=Ye(void 0),et=$e;function tt(e,...t){return N(e,t)}function nt(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function rt(e){let t=new WeakMap;return n=>{if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r}}const it=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},at=new WeakSet;function ot(e){return typeof e==`string`}function st(e){return typeof e==`number`}function ct(e){return typeof e==`boolean`}function lt(e){return typeof e==`bigint`}function ut(e){return typeof e==`symbol`}function dt(e){return ot(e)||st(e)||ut(e)}function ft(e){return typeof e==`function`}function pt(e){return e===void 0}function mt(e){return e!==void 0}function ht(e){return e!==null}function gt(e){return e==null}function _t(e){return e!=null}function vt(e){return!0}function yt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bt(e){return typeof e==`object`&&!!e||ft(e)}const I=P(2,(e,t)=>bt(e)&&t in e),xt=P(2,(e,t)=>I(e,`_tag`)&&e._tag===t);function St(e){return I(e,Symbol.iterator)||ot(e)}const Ct=`~effect/interfaces/Hash`,wt=e=>{switch(typeof e){case`number`:return kt(e);case`bigint`:return At(e.toString(10));case`boolean`:return At(String(e));case`symbol`:return At(String(e));case`string`:return At(e);case`undefined`:return At(`undefined`);case`function`:case`object`:if(e===null)return At(`null`);if(e instanceof Date)return At(e.toISOString());if(e instanceof RegExp)return At(e.toString());{if(at.has(e))return Tt(e);if(Rt.has(e))return Rt.get(e);let t=Bt(e,()=>Ot(e)?e[Ct]():typeof e==`function`?Tt(e):Array.isArray(e)?Pt(e):e instanceof Map?Ft(e):e instanceof Set?It(e):Mt(e));return Rt.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Tt=e=>(Lt.has(e)||Lt.set(e,kt(Math.floor(Math.random()*(2**53-1)))),Lt.get(e)),Et=P(2,(e,t)=>e*53^t),Dt=e=>e&3221225471|e>>>1&1073741824,Ot=e=>I(e,Ct),kt=e=>{if(e!==e)return At(`NaN`);if(e===1/0)return At(`Infinity`);if(e===-1/0)return At(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Dt(t)},At=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Dt(t)},jt=(e,t)=>{let n=12289;for(let r of t)n^=Et(wt(r),wt(e[r]));return Dt(n)},Mt=e=>jt(e,it(e)),Nt=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Dt(r)},Pt=Nt(6151,wt),Ft=Nt(At(`Map`),([e,t])=>Et(wt(e),wt(t))),It=Nt(At(`Set`),wt),Lt=new WeakMap,Rt=new WeakMap,zt=new WeakSet;function Bt(e,t){if(zt.has(e))return At(`[Circular]`);zt.add(e);let n=t();return zt.delete(e),n}const Vt=`~effect/interfaces/Equal`;function Ht(){return arguments.length===1?e=>Ut(e,arguments[0]):Ut(arguments[0],arguments[1])}function Ut(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||at.has(e)||at.has(t)?!1:Jt(e,t,qt):!1}function Wt(e,t,n){let r=Gt.has(e),i=Kt.has(t);if(r&&i)return!0;if(r||i)return!1;Gt.add(e),Kt.add(t);let a=n();return Gt.delete(e),Kt.delete(t),a}const Gt=new WeakSet,Kt=new WeakSet;function qt(e,t){if(wt(e)!==wt(t))return!1;if(e instanceof Date)return t instanceof Date?e.toISOString()===t.toISOString():!1;if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=nn(e),r=nn(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:Wt(e,t,()=>i?e[Vt](t):Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:Xt(e,t):e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:$t(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:tn(e,t):Zt(e,t))}function Jt(e,t,n){let r=Yt.get(e);if(!r)r=new WeakMap,Yt.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=Yt.get(t);return a||(a=new WeakMap,Yt.set(t,a)),a.set(e,i),i}const Yt=new WeakMap;function Xt(e,t){for(let n=0;n<e.length;n++)if(!Ut(e[n],t[n]))return!1;return!0}function Zt(e,t){let n=it(e),r=it(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Ut(e[i],t[i]))return!1;return!0}function Qt(e,t){return function(n,r){for(let[i,a]of n){let n=!1;for(let[o,s]of r)if(e(i,o)&&t(a,s)){n=!0;break}if(!n)return!1}return!0}}const $t=Qt(Ut,Ut);function en(e){return function(t,n){for(let r of t){let t=!1;for(let i of n)if(e(r,i)){t=!0;break}if(!t)return!1}return!0}}const tn=en(Ut),nn=e=>I(e,Vt),rn=()=>Ht,an=e=>(t,n)=>t===n||e(t,n),on=e=>e.length>0,sn=Symbol.for(`~effect/Inspectable/redactable`),cn=e=>I(e,sn);function ln(e){return cn(e)?un(e):e}function un(e){return e[sn](globalThis[`~effect/Fiber/currentFiber`]?.services??fn)}const dn=`~effect/Fiber/currentFiber`,fn={"~effect/ServiceMap":{},mapUnsafe:new Map,pipe(){return N(this,arguments)}};function pn(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(Array.isArray(e)){if(r.has(e))return mn;if(r.add(e),!i||e.length<=1)return`[${e.map(e=>c(e,n)).join(`,`)}]`;let t=e.map(e=>c(e,n+1)).join(`,
3
- `+a(n+1));return`[\n${a(n+1)}${t}\n${a(n)}]`}if(e instanceof Date)return _n(e);if(!t?.ignoreToString&&I(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=vn(e);return e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return mn;if(r.add(e),sn in e)return pn(un(e));if(Symbol.iterator in e)return`${e.constructor.name}(${c(Array.from(e),n)})`;let t=s(e);return!i||t.length<=1?o(e,`{${t.map(t=>`${hn(t)}:${c(e[t],n)}`).join(`,`)}}`):o(e,`{\n${t.map(t=>`${a(n+1)}${hn(t)}: ${c(e[t],n+1)}`).join(`,
4
- `)}\n${a(n)}}`)}return String(e)}return c(e,0)}const mn=`[Circular]`;function hn(e){return typeof e==`string`?JSON.stringify(e):String(e)}function gn(e){return e.map(e=>`[${hn(e)}]`).join(``)}function _n(e){try{return e.toISOString()}catch{return`Invalid Date`}}function vn(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function yn(e,t){let n=[],r=JSON.stringify(e,(e,t)=>typeof t==`object`&&t?n.includes(t)?void 0:n.push(t)&&ln(t):t,t?.space);return n=void 0,r}const bn=Symbol.for(`nodejs.util.inspect.custom`),xn=e=>{try{if(I(e,`toJSON`)&&ft(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(xn)}catch{return`[toJSON threw]`}return ln(e)},Sn=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?Cn(e,t):String(e)}catch{return String(e)}},Cn=(e,t)=>{let n=[],r=JSON.stringify(e,(e,t)=>typeof t==`object`&&t?n.includes(t)?void 0:n.push(t)&&ln(t):t,t);return n=void 0,r},wn={toJSON(){return xn(this)},[bn](){return this.toJSON()},toString(){return pn(this.toJSON())}};var Tn=class e{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}};const En=`~effect/Utils/internal`,Dn={[En]:e=>e()},On={[En]:e=>{try{return e()}finally{}}},kn=Dn[En](()=>Error().stack)?.includes(En)===!0?Dn[En]:On[En],An=`~effect/Effect`,jn=`~effect/Exit`,Mn={_A:F,_E:F,_R:F},Nn=`${An}/identifier`,L=`${An}/args`,Pn=`${An}/evaluate`,Fn=`${An}/successCont`,In=`${An}/failureCont`,Ln=`${An}/ensureCont`,Rn=Symbol.for(`effect/Effect/Yield`),zn={pipe(){return N(this,arguments)},toJSON(){return{...this}},toString(){return pn(this.toJSON(),{ignoreToString:!0,space:2})},[bn](){return this.toJSON()}},Bn={[Ct](){return jt(this,Object.keys(this))},[Vt](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]&&!Ht(this[t[r]],e[t[r]]))return!1;return!0}},Vn={[Symbol.iterator](){return new Tn(this)}},Hn={...Vn,pipe(){return N(this,arguments)}},Un={[An]:Mn,...zn,[Symbol.iterator](){return new Tn(this)},asEffect(){return this},toJSON(){return{_id:`Effect`,op:this[Nn],...L in this?{args:this[L]}:void 0}}},Wn=e=>I(e,An),Gn=e=>I(e,jn),Kn=`~effect/Cause`,qn=`~effect/Cause/Reason`,Jn=e=>I(e,Kn);var Yn=class{[Kn];reasons;constructor(e){this[Kn]=Kn,this.reasons=e}pipe(){return N(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${pn(this.reasons)})`}[bn](){return this.toJSON()}[Vt](e){return Jn(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Ht(t,e.reasons[n]))}[Ct](){return Pt(this.reasons)}};const Xn=new WeakMap;var Zn=class{[qn];annotations;_tag;constructor(e,t,n){if(this[qn]=qn,this._tag=e,t!==Qn&&typeof n==`object`&&n&&t.size>0){let e=Xn.get(n);e&&(t=new Map([...e,...t])),Xn.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return N(this,arguments)}toString(){return pn(this)}[bn](){return this.toString()}};const Qn=new Map;var $n=class extends Zn{error;constructor(e,t=Qn){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${pn(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[Vt](e){return or(e)&&Ht(this.error,e.error)&&Ht(this.annotations,e.annotations)}[Ct](){return Et(At(this._tag))(Et(wt(this.error))(wt(this.annotations)))}};const er=e=>new Yn(e),tr=new Yn([]),nr=e=>new Yn([new $n(e)]);var rr=class extends Zn{defect;constructor(e,t=Qn){super(`Die`,t,e),this.defect=e}toString(){return`Die(${pn(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[Vt](e){return sr(e)&&Ht(this.defect,e.defect)&&Ht(this.annotations,e.annotations)}[Ct](){return Et(At(this._tag))(Et(wt(this.defect))(wt(this.annotations)))}};const ir=e=>new Yn([new rr(e)]),ar=P(e=>Jn(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Yn(e.reasons.map(e=>e.annotate(t,n)))),or=e=>e._tag===`Fail`,sr=e=>e._tag===`Die`,cr=e=>e._tag===`Interrupt`;function lr(e){return vr(`Effect.evaluate: Not implemented`)}const ur=e=>({...Un,[Nn]:e.op,[Pn]:e[Pn]??lr,[Fn]:e[Fn],[In]:e[In],[Ln]:e[Ln]}),dr=e=>{let t=ur(e);return function(){let n=Object.create(t);return n[L]=e.single===!1?arguments:arguments[0],n}},fr=e=>{let t={...ur(e),[jn]:jn,_tag:e.op,get[e.prop](){return this[L]},toString(){return`${e.op}(${pn(this[L])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[L]}},[Vt](e){return Gn(e)&&e._tag===this._tag&&Ht(this[L],e[L])},[Ct](){return Et(At(e.op),wt(this[L]))}};return function(e){let n=Object.create(t);return n[L]=e,n}},pr=fr({op:`Success`,prop:`value`,[Pn](e){let t=e.getCont(Fn);return t?t[Fn](this[L],e,this):e.yieldWith(this)}}),mr={key:`effect/Cause/StackTrace`},hr={key:`effect/Cause/InterruptorStackTrace`},gr=fr({op:`Failure`,prop:`cause`,[Pn](e){let t=this[L],n=!1;e.currentStackFrame&&(t=ar(t,{mapUnsafe:new Map([[mr.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(In);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(In);return r?r[In](t,e,n?void 0:this):e.yieldWith(n?this:gr(t))}}),_r=e=>gr(nr(e)),vr=e=>gr(ir(e)),R=dr({op:`WithFiber`,[Pn](e){return this[L](e)}}),yr=function(){class e extends globalThis.Error{asEffect(){return _r(this)}}return Object.assign(e.prototype,Hn),e}(),br=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends yr{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Object.assign(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),xr=e=>{class t extends br{_tag=e}return t.prototype.name=e,t},Sr=`~effect/Cause/NoSuchElementError`;var Cr=class extends xr(`NoSuchElementError`){[Sr]=Sr;constructor(e){super({message:e})}};const wr=`~effect/Cause/Done`,Tr=e=>I(e,wr),Er={[wr]:wr,_tag:`Done`,value:void 0},Dr=e=>e===void 0?Er:{[wr]:wr,_tag:`Done`,value:e},Or=_r(Er),kr=e=>e===void 0?Or:_r(Dr(e)),Ar=`~effect/data/Option`,jr={[Ar]:{_A:e=>e},...zn,...Vn},Mr=Object.assign(Object.create(jr),{_tag:`Some`,_op:`Some`,[Vt](e){return Fr(e)&&Lr(e)&&Ht(this.value,e.value)},[Ct](){return Et(wt(this._tag))(wt(this.value))},toString(){return`some(${pn(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:xn(this.value)}},asEffect(){return pr(this.value)}});Object.defineProperty(Mr,`valueOrUndefined`,{get(){return this.value}});const Nr=wt(`None`),Pr=Object.assign(Object.create(jr),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[Vt](e){return Fr(e)&&Ir(e)},[Ct](){return Nr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}},asEffect(){return _r(new Cr)}}),Fr=e=>I(e,Ar),Ir=e=>e._tag===`None`,Lr=e=>e._tag===`Some`,Rr=Object.create(Pr),zr=e=>{let t=Object.create(Mr);return t.value=e,t},Br=`~effect/data/Result`,Vr={[Br]:{_A:e=>e,_E:e=>e},...zn,...Vn},Hr=Object.assign(Object.create(Vr),{_tag:`Success`,_op:`Success`,[Vt](e){return Wr(e)&&Kr(e)&&Ht(this.success,e.success)},[Ct](){return Et(wt(this._tag))(wt(this.success))},toString(){return`success(${pn(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:xn(this.success)}},asEffect(){return pr(this.success)}}),Ur=Object.assign(Object.create(Vr),{_tag:`Failure`,_op:`Failure`,[Vt](e){return Wr(e)&&Gr(e)&&Ht(this.failure,e.failure)},[Ct](){return Et(wt(this._tag))(wt(this.failure))},toString(){return`failure(${pn(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:xn(this.failure)}},asEffect(){return _r(this.failure)}}),Wr=e=>I(e,Br),Gr=e=>e._tag===`Failure`,Kr=e=>e._tag===`Success`,qr=e=>{let t=Object.create(Ur);return t.failure=e,t},Jr=e=>{let t=Object.create(Hr);return t.success=e,t};function Yr(e){return(t,n)=>t===n?0:e(t,n)}const Xr=Yr((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),Zr=P(2,(e,t)=>Yr((n,r)=>e(t(n),t(r)))),Qr=e=>P(2,(t,n)=>e(t,n)===1),z=()=>Rr,B=zr,$r=Fr,ei=Ir,ti=Lr,ni=P(2,(e,{onNone:t,onSome:n})=>ei(e)?t():n(e.value)),ri=P(2,(e,t)=>ei(e)?t():e.value),ii=e=>e==null?z():B(e),ai=e=>e===void 0?z():B(e),oi=e=>e===null?z():B(e),si=ri(Qe),ci=ri($e),li=e=>(...t)=>{try{return B(e(...t))}catch{return z()}},ui=P(2,(e,t)=>{if(ti(e))return e.value;throw t()}),di=P(2,(e,t)=>ei(e)?z():B(t(e.value))),fi=P(2,(e,t)=>ei(e)?z():t(e.value)),pi=P(2,(e,t)=>ei(e)?z():t(e.value)?B(e.value):z()),mi=e=>an((t,n)=>ei(t)?ei(n):ei(n)?!1:e(t.value,n.value)),hi=Jr,gi=qr,_i=Wr,vi=Gr,yi=Kr,bi={[Symbol.iterator](){return xi}},xi={next(){return{done:!0,value:void 0}}},Si=()=>bi,Ci=globalThis.Array,wi=e=>Ci.isArray(e)?e:Ci.from(e),Ti=e=>Ci.isArray(e)?e:[e],Ei=P(2,(e,t)=>[...e,t]),Di=P(2,(e,t)=>wi(e).concat(wi(t))),Oi=Ci.isArray,ki=on,Ai=on;function ji(e,t){return e<0||e>=t.length}const Mi=P(2,(e,t)=>{let n=Math.floor(t);return ji(n,e)?z():B(e[n])}),Ni=P(2,(e,t)=>{let n=Math.floor(t);if(ji(n,e))throw Error(`Index out of bounds: ${n}`);return e[n]}),Pi=Mi(0),Fi=Ni(0),Ii=e=>e[e.length-1],Li=e=>e.slice(1),Ri=P(3,(e,t,n)=>{let r=wi(e),i=wi(t);return Ai(r)?Ai(i)?Wi(n)(Di(r,i)):r:i}),zi=P(2,(e,t)=>Ri(e,t,rn())),Bi=()=>[],Vi=e=>[e],Hi=P(2,(e,t)=>e.map(t)),Ui=P(2,(e,t)=>{let n=wi(e),r=[];for(let e=0;e<n.length;e++)t(n[e],e)&&r.push(n[e]);return r}),Wi=P(2,(e,t)=>{let n=wi(e);if(Ai(n)){let e=[Fi(n)],r=Li(n);for(let n of r)e.every(e=>!t(n,e))&&e.push(n);return e}return[]}),Gi=`~effect/BigDecimal`,Ki={[Gi]:Gi,[Ct](){let e=$i(this);return Et(wt(e.value),kt(e.scale))},[Vt](e){return qi(e)&&ra(this,e)},toString(){return`BigDecimal(${ia(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[bn](){return this.toJSON()},pipe(){return N(this,arguments)}},qi=e=>I(e,Gi),Ji=(e,t)=>{let n=Object.create(Ki);return n.value=e,n.scale=t,n},Yi=(e,t)=>{if(e!==Xi&&e%Zi===Xi)throw RangeError(`Value must be normalized`);let n=Ji(e,t);return n.normalized=n,n},Xi=BigInt(0),Zi=BigInt(10),Qi=Yi(Xi,0),$i=e=>{if(e.normalized===void 0)if(e.value===Xi)e.normalized=Qi;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e),e.normalized=Yi(BigInt(t.substring(0,t.length-n)),e.scale-n)}return e.normalized},ea=P(2,(e,t)=>t>e.scale?Ji(e.value*Zi**BigInt(t-e.scale),t):t<e.scale?Ji(e.value/Zi**BigInt(e.scale-t),t):e),ta=e=>e.value<Xi?Ji(-e.value,e.scale):e,na=an((e,t)=>e.scale>t.scale?ea(t,e.scale).value===e.value:e.scale<t.scale?ea(e,t.scale).value===t.value:e.value===t.value),ra=P(2,(e,t)=>na(e,t)),ia=e=>{let t=$i(e);if(Math.abs(t.scale)>=16)return aa(t);let n=t.value<Xi,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},aa=e=>{if(oa(e))return`0e+0`;let t=$i(e),n=`${ta(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${sa(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},oa=e=>e.value===Xi,sa=e=>e.value<Xi,ca=`~effect/time/Duration`,la=BigInt(0),ua=BigInt(1e3),da=BigInt(1e6),fa=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,pa=e=>{switch(typeof e){case`number`:return Da(e);case`bigint`:return Ta(e);case`string`:{let t=fa.exec(e);if(!t)break;let[n,r,i]=t,a=Number(r);switch(i){case`nano`:case`nanos`:return Ta(BigInt(r));case`micro`:case`micros`:return Ea(BigInt(r));case`milli`:case`millis`:return Da(a);case`second`:case`seconds`:return Oa(a);case`minute`:case`minutes`:return ka(a);case`hour`:case`hours`:return Aa(a);case`day`:case`days`:return ja(a);case`week`:case`weeks`:return Ma(a)}break}case`object`:{if(e===null)break;if(ca in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(st)?ma(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Sa:e[0]===-1/0||e[1]===-1/0?wa:e[0]===1/0||e[1]===1/0?Ca:ya(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));let t=e,n=0;if(t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds)return ya(n);let r=BigInt(n)*da;return t.microseconds&&(r+=BigInt(t.microseconds)*ua),t.nanoseconds&&(r+=BigInt(t.nanoseconds)),ya(r)}}return ma(e)},ma=e=>{throw Error(`Invalid Input: ${e}`)},ha={_tag:`Millis`,millis:0},ga={_tag:`Infinity`},_a={_tag:`NegativeInfinity`},va={[ca]:ca,[Ct](){return Mt(this.value)},[Vt](e){return ba(e)&&Ra(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[bn](){return this.toJSON()},pipe(){return N(this,arguments)}},ya=e=>{let t=Object.create(va);return typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?t.value=ha:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:`Millis`,millis:e}:t.value={_tag:`Nanos`,nanos:BigInt(Math.round(e*1e6))}:t.value=e>0?ga:_a:e===la?t.value=ha:t.value={_tag:`Nanos`,nanos:e},t},ba=e=>I(e,ca),xa=e=>e.value._tag!==`Infinity`&&e.value._tag!==`NegativeInfinity`,Sa=ya(0),Ca=ya(1/0),wa=ya(-1/0),Ta=e=>ya(e),Ea=e=>ya(e*ua),Da=e=>ya(e),Oa=e=>ya(e*1e3),ka=e=>ya(e*6e4),Aa=e=>ya(e*36e5),ja=e=>ya(e*864e5),Ma=e=>ya(e*6048e5),Na=e=>Fa(e,{onMillis:F,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Pa=e=>{switch(e.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return e.value.nanos;case`Millis`:return BigInt(Math.round(e.value.millis*1e6))}},Fa=P(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),Ia=P(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Pa(e),t.value.nanos):n.onNanos(e.value.nanos,Pa(t))),La=(e,t)=>Ia(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Ra=P(2,(e,t)=>La(e,t)),za=e=>t=>e(t)?hi(t):gi(t),Ba=e=>t=>!vi(e(t)),Va=e=>t=>t.has(e)?hi(t):gi(t),Ha=P(2,(e,t)=>n=>{let r=e(n);return vi(r)?r:t(r.success)}),Ua=P(2,(e,t)=>n=>{let r=e(n);if(vi(r))return gi(n);let i=t(r.success);return vi(i)?gi(n):i}),Wa=e=>t=>{let n=e(t);return vi(n)?z():B(n.success)},Ga=function(){let e=Error.stackTraceLimit;Error.stackTraceLimit=2;let t=Error();Error.stackTraceLimit=e;function n(){}let r=n;return Object.setPrototypeOf(r,Ka),Object.defineProperty(r,`stack`,{get(){return t.stack}}),arguments.length>0?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[qa]=qa,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},Ka={"~effect/ServiceMap/Service":{_Service:e=>e,_Identifier:e=>e},...zn,...Vn,toJSON(){return{_id:`Service`,key:this.key,stack:this.stack}},asEffect(){return(this.asEffect=Ye(R(e=>pr(ao(e.services,this)))))()},of(e){return e},serviceMap(e){return to(this,e)},use(e){return R(t=>e(ao(t.services,this)))},useSync(e){return R(t=>pr(e(ao(t.services,this))))}},qa=`~effect/ServiceMap/Reference`,Ja=`~effect/ServiceMap`,Ya=e=>{let t=Object.create(Xa);return t.mapUnsafe=e,t.mutable=!1,t},Xa={...zn,[Ja]:{_Services:e=>e},toJSON(){return{_id:`ServiceMap`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Vt](e){if(!Za(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!Ht(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[Ct](){return kt(this.mapUnsafe.size)}},Za=e=>I(e,Ja),Qa=e=>I(e,qa),$a=()=>eo,eo=Ya(new Map),to=(e,t)=>Ya(new Map([[e.key,t]])),no=P(3,(e,t,n)=>mo(e,e=>{e.set(t.key,n)})),ro=P(3,(e,t,n)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):Qa(t)?co(t):n()),io=P(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(qa in t)return co(t);throw lo(t)}return e.mapUnsafe.get(t.key)}),ao=io,oo=(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):co(t),so=`~effect/ServiceMap/defaultValue`,co=e=>so in e?e[so]:e[so]=e.defaultValue(),lo=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(e.stack){let n=e.stack.split(`
5
- `);if(n.length>2){let e=n[2].match(/at (.*)/);e&&(t.message+=` (defined at ${e[1]})`)}}if(t.stack){let e=t.stack.split(`
6
- `);e.splice(1,3),t.stack=e.join(`
7
- `)}return t},uo=P(2,(e,t)=>e.mapUnsafe.has(t.key)?B(e.mapUnsafe.get(t.key)):Qa(t)?B(co(t)):z()),fo=P(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:mo(e,e=>{t.mapUnsafe.forEach((t,n)=>e.set(n,t))})),po=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Ya(t)},mo=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let n=new Map(e.mapUnsafe);return t(n),Ya(n)},ho=Ga,go=ho(`effect/Scheduler`,{defaultValue:()=>new yo}),_o=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};var vo=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},yo=class{executionMode;setImmediate;constructor(e=`async`,t=_o){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new bo(this.setImmediate)}},bo=class{tasks=new vo;running=void 0;setImmediate;constructor(e=_o){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}};const xo=ho(`effect/Scheduler/MaxOpsBeforeYield`,{defaultValue:()=>2048}),So=ho(`effect/Scheduler/PreventSchedulerYield`,{defaultValue:()=>!1}),Co=`effect/Tracer/ParentSpan`;var wo=class extends Ga()(Co){};const To=e=>e,Eo=ho(`effect/Tracer/DisablePropagation`,{defaultValue:Ze}),Do=ho(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),Oo=ho(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),ko=`effect/Tracer`,Ao=ho(ko,{defaultValue:()=>To({span:e=>new jo(e)})});var jo=class{_tag=`Span`;spanId;traceId=`native`;sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime},this.attributes=new Map,this.traceId=ci(e.parent)?.traceId??Mo(32),this.spanId=Mo(16)}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}};const Mo=function(){return function(e){let t=``;for(let n=0;n<e;n++)t+=`abcdef0123456789`.charAt(Math.floor(Math.random()*16));return t}}(),No=ho(`effect/References/CurrentConcurrency`,{defaultValue:()=>`unbounded`}),Po=ho(`effect/References/CurrentStackFrame`,{defaultValue:$e}),Fo=ho(`effect/References/TracerEnabled`,{defaultValue:Xe}),Io=ho(`effect/References/TracerTimingEnabled`,{defaultValue:Xe}),Lo=ho(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),Ro=ho(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),zo=ho(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),Bo=ho(`effect/References/CurrentLogLevel`,{defaultValue:()=>`Info`}),Vo=ho(`effect/References/MinimumLogLevel`,{defaultValue:()=>`Info`}),Ho=ho(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),Uo=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
8
- `);if(i[e]!==void 0)return n=i[e].trim(),n}};var Wo=class extends Zn{fiberId;constructor(e,t=Qn){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[Vt](e){return cr(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Ct](){return Et(At(`${this._tag}:${this.fiberId}`))(Tt(this.annotations))}};const Go=e=>new Yn([new Wo(e)]),Ko=e=>{let t=e.reasons.find(or);return t?hi(t):gi(e)},qo=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return hi(n.error)}return gi(e)},Jo=Wa(qo),Yo=e=>{let t=e.reasons.find(sr);return t?hi(t.defect):gi(e)},Xo=e=>e.reasons.some(cr),Zo=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?hi(t):gi(e)},Qo=e=>e.reasons.length>0&&e.reasons.every(cr),$o=P(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Yn(zi(e.reasons,t.reasons));return Ht(e,n)?e:n}),es=e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},ts=e=>{let t=es(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`)},ns=e=>{let t=[],n=[];if(e.reasons.length===0)return t;let r=Error.stackTraceLimit;Error.stackTraceLimit=1;for(let r of e.reasons){if(r._tag===`Interrupt`){n.push(r);continue}t.push(rs(r._tag===`Die`?r.defect:r.error,r.annotations))}if(t.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=cs(e,n);let r=new globalThis.Error(`All fibers interrupted without error`,{cause:e});r.name=`InterruptError`,r.stack=`${r.name}: ${r.message}`,t.push(rs(r,n[0].annotations))}return Error.stackTraceLimit=r,t},rs=(e,t)=>{let n=typeof e,r;if(e&&n===`object`){if(r=new globalThis.Error(is(e),{cause:e.cause?rs(e.cause):void 0}),typeof e.name==`string`&&(r.name=e.name),typeof e.stack==`string`)r.stack=os(e.stack,r,t);else{let e=`${r.name}: ${r.message}`;r.stack=t?ss(e,t):e}for(let t of Object.keys(e))t in r||(r[t]=e[t])}else r=new globalThis.Error(e?n===`string`?e:yn(e):`Unknown error: ${e}`);return r},is=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return yn(e)},as=/\((.*)\)/g,os=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
9
- `),a=[r];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return n?ss(a.join(`
10
- `),n):a.join(`
11
- `)},ss=(e,t)=>{let n=t?.get(mr.key);return n&&(e=`${e}\n${ls(n)}`),e},cs=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(hr.key);n.push(` at fiber (${t})`),r&&n.push(ls(r))}return n.join(`
12
- `)},ls=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(as),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
13
- `)},us=e=>ns(e).map(e=>e.cause?`${e.stack} {\n${ds(e.cause,` `)}\n}`:e.stack).join(`
14
- `),ds=(e,t)=>{let n=e.stack.split(`
15
- `),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${ds(e.cause,`${t} `)}\n${t}}`),r},fs=`~effect/Fiber/dev`,ps={_A:F,_E:F},ms={id:0},hs=()=>globalThis[dn];var gs=class{constructor(e,t=!0){this[fs]=ps,this.setServices(e),this.id=++ms.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0}[fs];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;services;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return oo(this.services,e)}addObserver(e){return this._exit?(e(this._exit),et):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=Go(e);this.currentStackFrame&&(n=ar(n,to(mr,this.currentStackFrame))),t&&(n=ar(n,t)),this._interruptedCause=this._interruptedCause?$o(this._interruptedCause,n):n,this.interruptible&&this.evaluate(Es(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this.runtimeMetrics?.recordFiberStart(this.services),this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Rn)return;let n=_s.interruptChildren&&_s.interruptChildren(this);if(n!==void 0)return this.evaluate(H(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.services,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=globalThis[dn];globalThis[dn]=this;let n=!1,r=e;this.currentOpCount=0;let i=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!n&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){n=!0;let e=r;r=H(As,()=>e)}if(r=this.currentTracerContext?this.currentTracerContext(r,this):r[Pn](this),i!==this.currentLoopCount)return Rn;if(r===Rn){let e=this._yielded;return jn in e?(this._yielded=void 0,e):Rn}}}catch(e){return I(r,Pn)?this.runLoop(vr(e)):vr(`Fiber.runLoop: Not a valid effect: ${String(r)}`)}finally{globalThis[dn]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let n=t[Ln]&&t[Ln](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,Rn}children(){return this._children??=new Set}pipe(){return N(this,arguments)}setServices(e){this.services=e;let t=this.getRef(go);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(Co),this.currentLogLevel=this.getRef(Bo),this.minimumLogLevel=this.getRef(Vo),this.currentStackFrame=e.mapUnsafe.get(Po.key),this.maxOpsBeforeYield=this.getRef(xo),this.currentPreventYield=this.getRef(So),this.runtimeMetrics=e.mapUnsafe.get(`effect/observability/Metric/FiberRuntimeMetricsKey`);let n=e.mapUnsafe.get(ko);this.currentTracerContext=n?n.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag===`Span`?this.currentSpan:void 0}};const _s={interruptChildren:void 0},vs=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(mr.key,e.currentStackFrame),Ya(t)},ys=e=>{let t=e;return t._exit?V(t._exit):Us(n=>t._exit?n(V(t._exit)):Os(e.addObserver(e=>n(V(e)))))},bs=e=>Us(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(V(r))}return a(),Os(()=>i?.())}),xs=e=>{let t=e;return t._exit?t._exit:Us(n=>t._exit?n(t._exit):Os(e.addObserver(n)))},Ss=e=>Us(t=>{let n=Array.from(e);if(n.length===0)return t(V(Bi()));let r=Array(n.length),i=Bi(),a=0,o=!1;for(let e=0;e<n.length&&!o;e++)i.push(n[e].addObserver(s=>{if(a++,s._tag===`Failure`)return o=!0,i.forEach(e=>e()),t(s);r[e]=s.value,a===n.length&&t(V(r))}))}),Cs=e=>R(t=>ws(e,t.id)),ws=P(e=>I(e[0],fs),(e,t,n)=>R(r=>{let i=vs(r);return i=i&&n?fo(i,n):i??n,e.interruptUnsafe(t,i),rc(ys(e))})),Ts=e=>R(t=>{let n=vs(t);for(let r of e)r.interruptUnsafe(t.id,n);return rc(bs(e))}),V=pr,Es=gr,Ds=_r,Os=dr({op:`Sync`,[Pn](e){let t=this[L](),n=e.getCont(Fn);return n?n[Fn](t,e):e.yieldWith(pr(t))}}),ks=dr({op:`Suspend`,[Pn](e){return this[L]()}}),As=dr({op:`Yield`,[Pn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(yc)},this[L]??0),e.yieldWith(()=>{t=!0})}})(0),js=e=>V(B(e)),Ms=V(z()),Ns=e=>vr(e),Ps=e=>ks(()=>Ds(kn(e))),Fs=V(void 0),Is=e=>ks(()=>{try{return V(kn(e.try))}catch(t){return Ds(kn(()=>e.catch(t)))}}),Ls=e=>Vs(function(t,n){kn(()=>e(n)).then(e=>t(V(e)),e=>t(Ns(e)))},e.length!==0),Rs=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Lu(e,`An error occurred in Effect.tryPromise`):e.catch;return Vs(function(e,r){try{kn(()=>t(r)).then(t=>e(V(t)),t=>e(Ds(kn(()=>n(t)))))}catch(t){e(Ds(kn(()=>n(t))))}},eval.length!==0)},zs=e=>R(t=>e(t.id)),Bs=zs(V),Vs=dr({op:`Async`,single:!1,[Pn](e){let t=kn(()=>this[L][0].bind(e.currentScheduler)),n=!1,r=!1,i=this[L][1]?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Hs(()=>(n=!0,i?.abort(),a??yc))),Rn):r}}),Hs=dr({op:`AsyncFinalizer`,[Ln](e){e.interruptible&&(e.interruptible=!1,e._stack.push(zl))},[In](e,t){return Xo(e)?H(this[L](),()=>Es(e)):Es(e)}}),Us=e=>Vs(e,e.length>=2),Ws=(...e)=>ks(()=>Qs(e.length===1?e[0]():e[1].call(e[0].self))),Gs=(e,...t)=>{let n=t.length===0?function(){return ks(()=>Qs(e.apply(this,arguments)))}:function(){let n=ks(()=>Qs(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return Ks(e.length,n)},Ks=(e,t)=>Object.defineProperty(t,`length`,{value:e,configurable:!0}),qs=Uo(2),Js=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=globalThis.Error.stackTraceLimit;globalThis.Error.stackTraceLimit=2;let i=new globalThis.Error;return globalThis.Error.stackTraceLimit=r,e?(r,...a)=>Ys(t,r,i,a,e,n):Ys(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},Ys=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.pop().bind(t.self);return Ks(o.length,function(...t){let s=ks(()=>{let e=o.apply(this,arguments);return Wn(e)?e:Qs(e)});for(let e=0;e<r.length;e++)s=r[e](s,...t);if(!Wn(s))return s;let c=globalThis.Error.stackTraceLimit;globalThis.Error.stackTraceLimit=2;let l=new globalThis.Error;return globalThis.Error.stackTraceLimit=c,Oc(i?Su(e,a,e=>Cu(s,e)):s,Po,t=>({name:e,stack:qs(()=>l.stack),parent:{name:`${e} (definition)`,stack:qs(()=>n.stack),parent:t}}))})},Xs=(e,...t)=>Ks(e.length,t.length===0?function(){return Zs(()=>e.apply(this,arguments))}:function(){let n=Zs(()=>e.apply(this,arguments));for(let e of t)n=e(n);return n}),Zs=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return V(r.value);let i=r.value.asEffect(),a=i;if(a&&a._tag===`Success`){n=a.value;continue}else if(a&&a._tag===`Failure`)return i;else{let n=!0;return ks(()=>n?(n=!1,H(i,e=>Qs(t,e))):ks(()=>Qs(e())))}}}catch(e){return Ns(e)}},Qs=dr({op:`Iterator`,single:!1,[Fn](e,t){let n=this[L][0];for(;;){let r=n.next(e);if(r.done)return V(r.value);let i=r.value.asEffect();if(!sc(i))return t._stack.push(this),i;if(i._tag===`Failure`)return i;e=i.value}},[Pn](e){return this[Fn](this[L][1],e)}}),$s=P(2,(e,t)=>{let n=V(t);return H(e,e=>n)}),ec=e=>uc(e,B),tc=P(2,(e,t)=>H(e,e=>Wn(t)?t:kn(()=>t(e)))),nc=P(2,(e,t)=>H(e,e=>$s(Wn(t)?t:kn(()=>t(e)),e))),rc=e=>H(e,e=>yc),ic=(e,t)=>R(n=>Us(r=>{let i=!1,a=new Set,o=e=>{i=!0,r(a.size===0?e:H(Ll(Ts(a)),()=>e))},s=0;for(let r of e){if(i)break;let e=s++,c=Yl(n,r,!0,!0,!1);a.add(c),c.addObserver(r=>{a.delete(c);let s=!i;o(r),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}return Ts(a)})),ac=P(e=>Wn(e[1]),(e,t,n)=>ic([e,t],n)),H=P(2,(e,t)=>{let n=Object.create(oc);return n[L]=e,n[Fn]=t.length===1?t:e=>t(e),n}),oc=ur({op:`OnSuccess`,[Pn](e){return e._stack.push(this),this[L]}}),sc=e=>jn in e,cc=P(2,(e,t)=>sc(e)?e._tag===`Success`?t(e.value):e:H(e,t)),lc=e=>H(e,F),uc=P(2,(e,t)=>H(e,e=>V(kn(()=>t(e))))),dc=P(2,(e,t)=>sc(e)?bc(e,t):uc(e,t)),fc=P(2,(e,t)=>sc(e)?xc(e,t):Kc(e,t)),pc=P(2,(e,t)=>sc(e)?Sc(e,t):qc(e,t)),mc=P(2,(e,t)=>{if(sc(e)){if(e._tag===`Success`)return e;let n=qo(e.cause);return vi(n)?e:t(n.success)}return Bc(e,t)}),hc=e=>gr(Go(e)),gc=e=>e._tag===`Success`,_c=e=>e._tag===`Failure`,vc=e=>e._tag===`Failure`?hi(e.cause):gi(e),yc=pr(void 0),bc=P(2,(e,t)=>e._tag===`Success`?pr(t(e.value)):e),xc=P(2,(e,t)=>{if(e._tag===`Success`)return e;let n=qo(e.cause);return vi(n)?e:_r(t(n.success))}),Sc=P(2,(e,t)=>{if(e._tag===`Success`)return pr(t.onSuccess(e.value));let n=qo(e.cause);return vi(n)?e:_r(t.onFailure(n.success))}),Cc=P(2,(e,t)=>gc(e)?t:e),wc=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?yc:gr(er(t))},Tc=e=>gc(e)?B(e.value):z(),Ec=e=>R(t=>V(uo(t.services,e))),Dc=P(2,(e,t)=>R(n=>{let r=n.services,i=t(r);return r===i?e:(n.setServices(i),kl(e,()=>{n.setServices(r)}))})),Oc=P(3,(e,t,n)=>Dc(e,e=>{let r=io(e,t),i=n(r);return r===i?e:no(e,t,i)})),kc=()=>Ac,Ac=R(e=>V(e.services)),jc=e=>R(t=>e(t.services)),Mc=P(2,(e,t)=>sc(e)?e:Dc(e,fo(t))),Nc=function(){return arguments.length===1?P(2,(e,t)=>Pc(e,arguments[0],t)):P(3,(e,t,n)=>Pc(e,t,n)).apply(this,arguments)},Pc=(e,t,n)=>Dc(e,e=>e.mapUnsafe.get(t.key)===n?e:no(e,t,n)),Fc=P(2,(e,t)=>H(t,t=>t?ec(e):Ms)),Ic=P(e=>Wn(e[0]),(e,t)=>Kl({while:Xe,body:Ye(t?.disableYield?e:H(e,e=>As)),step:et})),Lc=P(2,(e,t)=>{let n=Object.create(Rc);return n[L]=e,n[In]=t.length===1?t:e=>t(e),n}),Rc=ur({op:`OnFailure`,[Pn](e){return e._stack.push(this),this[L]}}),zc=P(3,(e,t,n)=>Lc(e,e=>{let r=t(e);return vi(r)?Es(r.failure):kn(()=>n(r.success,e))})),Bc=P(2,(e,t)=>zc(e,qo,e=>t(e))),Vc=P(2,(e,t)=>Lc(e,e=>tc(kn(()=>t(e)),Es(e)))),Hc=P(e=>Wn(e[0]),(e,t,n,r)=>Lc(e,e=>{let i=qo(e);return vi(i)?Es(i.failure):t(i.success)?kn(()=>n(i.success)):r?kn(()=>r(i.success)):Es(e)})),Uc=P(e=>Wn(e[0]),(e,t,n,r)=>Lc(e,e=>{let i=qo(e);if(vi(i))return Es(i.failure);let a=t(i.success);return vi(a)?r?kn(()=>r(a.failure)):Es(e):kn(()=>n(a.success))})),Wc=P(e=>Wn(e[0]),(e,t,n,r)=>Hc(e,Array.isArray(t)?e=>I(e,`_tag`)&&t.includes(e._tag):xt(t),n,r)),Gc=P(e=>Wn(e[0]),(e,t,n)=>{let r;return Uc(e,e=>(r??=Object.keys(t),I(e,`_tag`)&&ot(e._tag)&&r.includes(e._tag)?hi(e):gi(e)),e=>kn(()=>t[e._tag](e)),n)}),Kc=P(2,(e,t)=>Bc(e,e=>Ps(()=>t(e)))),qc=P(2,(e,t)=>el(e,{onFailure:e=>Ps(()=>t.onFailure(e)),onSuccess:e=>Os(()=>t.onSuccess(e))})),Jc=e=>Bc(e,Ns),Yc=e=>Bc(e,t=>H(As,()=>Yc(e))),Xc=P(e=>Wn(e[0]),(e,t)=>{if(!t?.log)return el(e,{onFailure:e=>Fs,onSuccess:e=>Fs});let n=qu(t.log===!0?void 0:t.log);return Qc(e,{onFailure(e){let r=Ko(e);return vi(r)?Es(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>Fs})}),Zc=e=>nl(e,{onFailure:gi,onSuccess:hi}),Qc=P(2,(e,t)=>{let n=Object.create($c);return n[L]=e,n[Fn]=t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),n[In]=t.onFailure.length===1?t.onFailure:e=>t.onFailure(e),n}),$c=ur({op:`OnSuccessAndFailure`,[Pn](e){return e._stack.push(this),this[L]}}),el=P(2,(e,t)=>Qc(e,{onFailure:e=>{let n=e.reasons.find(or);return n?kn(()=>t.onFailure(n.error)):Es(e)},onSuccess:t.onSuccess})),tl=P(2,(e,t)=>el(e,{onFailure:e=>Os(()=>t.onFailure(e)),onSuccess:e=>Os(()=>t.onSuccess(e))})),nl=P(2,(e,t)=>{if(sc(e)){if(e._tag===`Success`)return pr(t.onSuccess(e.value));let n=qo(e.cause);return vi(n)?e:pr(t.onFailure(n.success))}return tl(e,t)}),rl=e=>sc(e)?pr(e):il(e),il=dr({op:`Exit`,[Pn](e){return e._stack.push(this),this[L]},[Fn](e,t,n){return V(n??pr(e))},[In](e,t,n){return V(n??gr(e))}}),al=P(2,(e,t)=>tc(ju(t),e)),ol=P(2,(e,t)=>ac(e,H(ju(t.duration),t.onTimeout))),sl=P(2,(e,t)=>ol(e,{duration:t,onTimeout:()=>Ds(new Nu)})),cl=P(2,(e,t)=>ac(ec(e),$s(ju(t),z()))),ll=`~effect/Scope`,ul=`~effect/Scope/Closeable`,dl=Ga(`effect/Scope`),fl=(e,t)=>ks(()=>pl(e,t)??Fs),pl=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let{finalizers:r}=e.state;if(e.state=n,r.size!==0)return r.size===1?r.values().next().value(t):ml(e,r,t)},ml=Gs(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=hs();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*rl(s(n))):i.push(Yl(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*bs(i)),yield*wc(r)}),hl=(e,t)=>Os(()=>gl(e,t)),gl=(e,t)=>{let n=xl(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return yl(e,r,e=>fl(n,e)),yl(n,r,t=>Os(()=>bl(e,r))),n},_l=(e,t)=>ks(()=>e.state._tag===`Closed`?t(e.state.exit):(yl(e,{},t),Fs)),vl=(e,t)=>_l(e,Ye(t)),yl=(e,t,n)=>{e.state._tag===`Empty`?e.state={_tag:`Open`,finalizers:new Map([[t,n]])}:e.state._tag===`Open`&&e.state.finalizers.set(t,n)},bl=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.delete(t)},xl=(e=`sequential`)=>({[ul]:ul,[ll]:ll,strategy:e,state:Sl}),Sl={_tag:`Empty`},Cl=dl.asEffect(),wl=Nc(dl),Tl=e=>R(t=>{let n=t.services,r=xl();return t.setServices(no(t.services,dl,r)),kl(e,e=>(t.setServices(n),pl(r,e)))}),El=e=>ks(()=>{let t=xl();return Al(e(t),e=>ks(()=>pl(t,e)??Fs))}),Dl=(e,t,n)=>jc(r=>Hl(i=>H(Cl,a=>nc(n?.interruptible?i(e):e,e=>_l(a,n=>Mc(t(e,n),r)))))),Ol=e=>H(Cl,t=>jc(n=>_l(t,t=>Mc(e(t),n)))),kl=dr({op:`OnExit`,single:!1,[Pn](e){return e._stack.push(this),this[L][0]},[Ln](e){e.interruptible&&this[L][2]!==!0&&(e._stack.push(zl),e.interruptible=!1)},[Fn](e,t,n){n??=pr(e);let r=this[L][1](n);return r?H(r,e=>n):n},[In](e,t,n){n??=gr(e);let r=this[L][1](n);return r?H(r,e=>n):n}}),Al=P(2,kl),jl=P(2,(e,t)=>Al(e,e=>t)),Ml=P(3,(e,t,n)=>Al(e,e=>{let r=t(e);return vi(r)?Fs:n(r.success,e)})),Nl=P(2,(e,t)=>Ml(e,vc,t)),Pl=P(3,(e,t,n)=>Al(e,e=>{if(e._tag!==`Failure`)return Fs;let r=t(e.cause);return vi(r)?Fs:n(r.success,e.cause)})),Fl=P(2,(e,t)=>Pl(Zo,t)(e)),Il=R(e=>Es(Go(e.id))),Ll=e=>R(t=>t.interruptible?(t.interruptible=!1,t._stack.push(zl),e):e),Rl=dr({op:`SetInterruptible`,[Ln](e){if(e.interruptible=this[L],e._interruptedCause&&e.interruptible)return()=>Es(e._interruptedCause)}}),zl=Rl(!0),Bl=Rl(!1),Vl=e=>R(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(Bl),t._interruptedCause?Es(t._interruptedCause):e)),Hl=e=>R(t=>t.interruptible?(t.interruptible=!1,t._stack.push(zl),e(Vl)):e(F)),Ul=(e,t)=>St(e)?t?.mode===`result`?ql(e,Zc,t):ql(e,F,t):t?.discard?t.mode===`result`?ql(Object.values(e),Zc,t):ql(Object.values(e),F,t):ks(()=>{let n={};return $s(ql(Object.entries(e),([e,r])=>uc(t?.mode===`result`?Zc(r):r,t=>{n[e]=t}),{discard:!0,concurrency:t?.concurrency}),n)}),Wl=(e,t,n,r)=>H(n(r,t),i=>{if(i)return V(B(r));let a=e.next();return a.done?V(z()):Wl(e,t+1,n,a.value)}),Gl=(e,t,n,r)=>H(n(r,t),r=>{if(yi(r))return V(B(r.success));let i=e.next();return i.done?V(z()):Gl(e,t+1,n,i.value)}),Kl=dr({op:`While`,[Fn](e,t){return this[L].step(e),this[L].while()?(t._stack.push(this),this[L].body()):yc},[Pn](e){return this[L].while()?(e._stack.push(this),this[L].body()):yc}}),ql=P(e=>typeof e[1]==`function`,(e,t,n)=>R(r=>{let i=n?.concurrency===`inherit`?r.getRef(No):n?.concurrency??1,a=i===`unbounded`?1/0:Math.max(1,i);if(a===1)return Jl(e,t,n);let o=wi(e),s=o.length;if(s===0)return n?.discard?Fs:V([]);let c=n?.discard?void 0:Array(s),l=0,u=vs(r);return Us(e=>{let n=new Set,i=[],d=!1,f=0,p=0,m=!1,h=!1;function g(){for(m=!0;f<a&&l<s;){let _=l,v=o[_];l++,f++;try{let o=Yl(r,t(v,_),!0,!0,`inherit`);n.add(o),o.addObserver(t=>{if(!h){if(n.delete(o),t._tag===`Failure`)if(!d)d=!0,s=l,i.push(...t.cause.reasons),n.forEach(e=>e.interruptUnsafe(r.id,u));else for(let e of t.cause.reasons)e._tag!==`Interrupt`&&i.push(e);else c!==void 0&&(c[_]=t.value);p++,f--,p===s?e(i.length>0?gr(er(i)):V(c)):!m&&!d&&f<a&&g()}})}catch(e){d=!0,s=l,i.push(new rr(e)),n.forEach(e=>e.interruptUnsafe(r.id,u))}}m=!1}return g(),ks(()=>(h=!0,l=s,Ts(n)))})})),Jl=(e,t,n)=>ks(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return $s(Kl({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Yl=(e,t,n=!1,r=!1,i=!1)=>{let a=i===`inherit`?e.interruptible:!i,o=new gs(e.services,a);return n?o.evaluate(t):e.currentDispatcher.scheduleTask(()=>o.evaluate(t),0),!r&&!o._exit&&(e.children().add(o),o.addObserver(()=>e._children.delete(o))),o},Xl=P(e=>Wn(e[0]),(e,t)=>R(n=>V(Yl(n,e,t?.startImmediately,!0,t?.uninterruptible)))),Zl=P(e=>Wn(e[0]),(e,t,n)=>R(r=>{let i=Yl(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!i._exit)if(t.state._tag!==`Closed`){let e={};yl(t,e,()=>zs(e=>e===i.id?Fs:Cs(i))),i.addObserver(()=>bl(t,e))}else i.interruptUnsafe(r.id,vs(r));return V(i)})),Ql=P(e=>Wn(e[0]),(e,t)=>H(Cl,n=>Zl(e,n,t))),$l=e=>(t,n)=>{let r=new gs(n?.scheduler?no(e,go,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}return r},eu=P(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return yl(t,n,()=>Cs(e)),e.addObserver(()=>bl(t,n)),e}),tu=$l($a()),nu=e=>{let t=$l(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},ru=nu($a()),iu=e=>{let t=$l(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},au=iu($a()),ou=e=>{let t=iu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw ts(e.cause);return e.value})},su=ou($a()),cu=e=>{let t=$l(e);return e=>{if(sc(e))return e;let n=t(e,{scheduler:new yo(`sync`)});return n.currentDispatcher?.flush(),n._exit??vr(n)}},lu=cu($a()),uu=e=>{let t=cu(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw ts(n.cause);return n.value}},du=uu($a()),fu=V(!0),pu=V(!1);var mu=class{waiters=[];scheduled=!1;isOpen;constructor(e){this.isOpen=e}scheduleUnsafe(e){return this.scheduled||this.waiters.length===0?fu:(this.scheduled=!0,e.currentDispatcher.scheduleTask(this.flushWaiters,0),fu)}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](yc)};open=R(e=>this.isOpen?pu:(this.isOpen=!0,this.scheduleUnsafe(e)));release=R(e=>this.open?pu:this.scheduleUnsafe(e));openUnsafe(){return this.isOpen?!1:(this.isOpen=!0,this.flushWaiters(),!0)}await=Us(e=>this.isOpen?e(Fs):(this.waiters.push(e),Os(()=>{let t=this.waiters.indexOf(e);t!==-1&&this.waiters.splice(t,1)})));closeUnsafe(){return this.isOpen?(this.isOpen=!1,!0):!1}close=Os(()=>this.closeUnsafe());whenOpen=e=>H(this.await,()=>e)};const hu=e=>new mu(e??!1),gu=R(e=>V(e.getRef(Ao))),_u=BigInt(0),vu={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:_u,endTime:_u,exit:yc},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},yu=e=>Object.assign(Object.create(vu),e),bu=e=>e?ao(e.annotations,Eo)?e._tag===`Span`?bu(ci(e.parent)):z():B(e):z(),xu=(e,t,n)=>{let r=!e.getRef(Fo)||n?.annotations&&ao(n.annotations,Eo),i=n?.parent===void 0?n?.root?z():bu(e.currentSpan):B(n.parent),a;if(r)a=yu({name:t,parent:i,annotations:no(n?.annotations??$a(),Eo,!0)});else{let r=e.getRef(Ao),o=e.getRef(Tu),s=e.getRef(Io),c=e.getRef(Lo),l=e.getRef(Ro),u=n?.level??e.getRef(Do),d=n?.links===void 0?l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??$a(),links:d,startTime:s?o.currentTimeNanosUnsafe():0n,kind:n?.kind??`internal`,root:n?.root??ei(i),sampled:n?.sampled??(ti(i)&&i.value.sampled===!1?!1:!zu(e.getRef(Oo),u))});for(let[e,t]of Object.entries(c))a.attribute(e,t);if(n?.attributes!==void 0)for(let[e,t]of Object.entries(n.attributes))a.attribute(e,t)}return a},Su=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return R(t=>{let i=xu(t,e,n),a=t.getRef(Tu);return Al(kn(()=>r(i)),e=>Os(()=>{i.status._tag!==`Ended`&&i.end(a.currentTimeNanosUnsafe(),e)}))})},Cu=Nc(wo),wu=(...e)=>R(t=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[t,r]of Object.entries(e[0]))n.attribute(t,r);else n.attribute(e[0],e[1]);return Fs}),Tu=ho(`effect/Clock`,{defaultValue:()=>new Du}),Eu=2**31-1;var Du=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Os(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return ku()}currentTimeNanos=Os(()=>this.currentTimeNanosUnsafe());sleep(e){let t=Na(e);return t<=0?As:Us(e=>{if(t>Eu)return;let n=setTimeout(()=>e(Fs),t);return Os(()=>clearTimeout(n))})}};const Ou=function(){let e=BigInt(1e6);if(typeof performance>`u`||performance.now===void 0)return()=>BigInt(Date.now())*e;if(typeof performance.timeOrigin==`number`&&performance.timeOrigin===0)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6));return()=>t+BigInt(Math.round(performance.now()*1e6))}(),ku=function(){let e=typeof process==`object`&&`hrtime`in process&&typeof process.hrtime.bigint==`function`?process.hrtime:void 0;if(!e)return Ou;let t=Ou()-e.bigint();return()=>t+e.bigint()}(),Au=e=>R(t=>e(t.getRef(Tu))),ju=e=>Au(t=>t.sleep(pa(e))),Mu=`~effect/Cause/TimeoutError`;var Nu=class extends xr(`TimeoutError`){[Mu]=Mu;constructor(e){super({message:e})}};const Pu=`~effect/Cause/IllegalArgumentError`;var Fu=class extends xr(`IllegalArgumentError`){[Pu]=Pu;constructor(e){super({message:e})}};xr(`ExceededCapacityError`);const Iu=`~effect/Cause/UnknownError`;var Lu=class extends xr(`UnknownError`){[Iu]=Iu;constructor(e,t){super({message:t,cause:e})}};const Ru=ho(`effect/Console/CurrentConsole`,{defaultValue:()=>globalThis.console}),zu=Qr(Zr(Xr,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),Bu=ho(`effect/Loggers/CurrentLoggers`,{defaultValue:()=>new Set([Zu,Qu])}),Vu=ho(`effect/Logger/LogToStderr`,{defaultValue:Ze}),Hu=function(){let e=typeof arguments[0]==`string`?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return Ll(R(t=>{let n=t.getRef(zo),r={...n};for(let t=0;t<e.length;t++){let[n,i]=e[t];r[n]=i}return t.setServices(no(t.services,zo,r)),_l(io(t.services,dl),r=>{let i=t.getRef(zo),a={...i};for(let t=0;t<e.length;t++){let[r,o]=e[t];i[r]===o&&(r in n?a[r]=n[r]:delete a[r])}return t.setServices(no(t.services,zo,a)),Fs})}))},Uu={"~effect/Logger":{_Message:F,_Output:F},pipe(){return N(this,arguments)}},Wu=e=>{let t=Object.create(Uu);return t.log=e,t},Gu=e=>e.replace(/[\s="]/g,`_`),Ku=(e,t)=>`${Gu(e[0])}=${t-e[1]}ms`,qu=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];Jn(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?er(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=tr),R(r=>{let i=e??r.currentLogLevel;if(zu(r.minimumLogLevel,i))return Fs;let a=r.getRef(Tu),o=r.getRef(Bu);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return Fs})},Ju={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Ju.gray,Ju.blue,Ju.green,Ju.yellow,Ju.red,Ju.bgBrightRed,Ju.black;const Yu=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Xu=typeof process==`object`&&process!==null&&typeof process.stdout==`object`&&process.stdout!==null;Xu&&process.stdout.isTTY,Xu||`Deno`in globalThis;const Zu=Wu(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(us(e));let o=t.getTime(),s=n.getRef(Ho),c=``;for(let e of s)c+=` ${Ku(e,o)}`;let l=n.getRef(zo);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Ru);(n.getRef(Vu)?u.error:u.log)(`[${Yu(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Qu=Wu(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(Tu),a=t.getRef(zo),o=t.currentSpan;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))s[e]=t;s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=us(e)),o.event(Sn(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),$u=nr,ed=ir,td=Go,nd=Qo,rd=ts,id=qo,ad=Jo,od=Yo,sd=Zo,cd=us,ld=Cr,ud=Tr,dd=Dr,fd=kr,pd=Fu,md=Lu,hd=Gn,gd=pr,_d=gr,vd=_r,yd=yc,bd=gc,xd=_c,Sd=Tc,Cd={"~effect/Deferred":{_A:F,_E:F},pipe(){return N(this,arguments)}},wd=()=>{let e=Object.create(Cd);return e.resumes=void 0,e.effect=void 0,e},Td=()=>Os(()=>wd()),Ed=e=>Us(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Os(()=>{let n=e.resumes.indexOf(t);e.resumes.splice(n,1)}))),Dd=P(2,(e,t)=>Os(()=>Nd(e,t))),Od=Dd,kd=P(2,(e,t)=>Od(e,gr(t))),Ad=P(2,(e,t)=>kd(e,Go(t))),jd=e=>Os(()=>Md(e)),Md=e=>e.effect!==void 0,Nd=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let n=0;n<e.resumes.length;n++)e.resumes[n](t);e.resumes=void 0}return!0},Pd=P(2,(e,t)=>Hl(n=>H(rl(n(e)),e=>Od(t,e)))),Fd=dl,Id=xl,Ld=wl,Rd=_l,zd=vl,Bd=hl,Vd=gl,Hd=fl,Ud=`~effect/Layer`,Wd=`~effect/Layer/MemoMap`,Gd=e=>I(e,Ud),Kd={[Ud]:{_ROut:F,_E:F,_RIn:F},pipe(){return N(this,arguments)}},qd=e=>{let t=Object.create(Kd);return t.build=e,t},Jd=e=>qd((t,n)=>{let r=Vd(n);return Al(e(t,r),e=>e._tag===`Failure`?Hd(r,e):Fs)}),Yd=e=>{let t=Jd((n,r)=>n.getOrElseMemoize(t,r,e));return t};var Xd=class{get[Wd](){return Wd}map=new Map;getOrElseMemoize(e,t,n){if(this.map.has(e)){let n=this.map.get(e);return n.observers++,tc(_l(t,e=>n.finalizer(e)),n.effect)}let r=Id(),i=wd(),a={observers:1,effect:Ed(i),finalizer:t=>ks(()=>(a.observers--,a.observers===0?(this.map.delete(e),Hd(r,t)):Fs))};return this.map.set(e,a),_l(t,a.finalizer).pipe(H(()=>n(this,r)),Al(e=>(a.effect=e,Od(i,e))))}};const Zd=()=>new Xd;var Qd=class extends Ga()(`effect/Layer/CurrentMemoMap`){static getOrCreate=ro(this,Zd)};const $d=P(3,(e,t,n)=>Nc(uc(e.build(t,n),no(Qd,t)),Qd,t)),ef=P(2,(e,t)=>R(n=>$d(e,Qd.getOrCreate(n.services),t))),tf=function(){return arguments.length===1?e=>nf(to(arguments[0],e)):nf(to(arguments[0],arguments[1]))},nf=e=>qd(Ye(V(e))),rf=function(){return arguments.length===1?e=>af(arguments[0],e):af(arguments[0],arguments[1])},af=(e,t)=>of(uc(t,t=>to(e,t))),of=e=>Yd((t,n)=>Ld(e,n)),sf=e=>of($s(e,$a())),cf=e=>{let t=Ga(`effect/Layer/unwrap`);return mf(rf(t)(e),ao(t))},lf=(e,t,n)=>{let r=Vd(n,`parallel`);return ql(e,e=>e.build(t,Vd(r,`sequential`)),{concurrency:e.length}).pipe(uc(e=>po(...e)))},uf=(...e)=>Jd((t,n)=>lf(e,t,n)),df=(e,t,n)=>Jd((r,i)=>H(Array.isArray(t)?lf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Mc(t),uc(e=>n(e,t))))),ff=P(2,(e,t)=>df(e,t,F)),pf=P(2,(e,t)=>df(e,t,(e,t)=>fo(t,e))),mf=P(2,(e,t)=>Jd((n,r)=>H(e.build(n,r),e=>t(e).build(n,r)))),hf=`~effect/ExecutionPlan`,gf={[hf]:hf,get withRequirements(){let e=this;return jc(t=>V(_f(e.steps.map(e=>({...e,provide:Gd(e.provide)?ff(e.provide,nf(t)):e.provide})))))},pipe(){return N(this,arguments)}},_f=e=>{let t=Object.create(gf);return t.steps=e,t},vf=class extends Je{constructor(e){super(),e&&Object.assign(this,e)}},yf=()=>new Proxy({},{get(e,t,n){return t===`$is`?xt:t===`$match`?bf:e=>({_tag:t,...e})}});function bf(){if(arguments.length===1){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0];return arguments[1][e._tag](e)}const xf=br,Sf=xr,Cf=`~effect/time/DateTime`,wf=`~effect/time/DateTime/TimeZone`,Tf={[Cf]:Cf,pipe(){return N(this,arguments)},[bn](){return this.toString()},toJSON(){return Rf(this).toJSON()}},Ef={...Tf,_tag:`Utc`,[Ct](){return kt(this.epochMilliseconds)},[Vt](e){return Of(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Rf(this).toJSON()})`}};({...Tf});const Df={[wf]:wf,[bn](){return this.toString()}};({...Df}),{...Df};const Of=e=>I(e,Cf),kf=e=>e._tag===`Utc`,Af=an((e,t)=>e.epochMilliseconds===t.epochMilliseconds),jf=e=>{let t=Object.create(Ef);return t.epochMilliseconds=e,Object.defineProperty(t,`partsUtc`,{value:void 0,enumerable:!1,writable:!0}),t},Mf=e=>{let t=e.getTime();if(Number.isNaN(t))throw new pd(`Invalid date`);return jf(t)},Nf=e=>{if(Of(e))return e;if(e instanceof Date)return Mf(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return jf(e.epochMilliseconds);let t=new Date(0);return Uf(t,e),Mf(t)}else if(typeof e==`string`&&!Pf(e))return Mf(new Date(e+`Z`));return Mf(new Date(e))},Pf=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Ff=li(Nf),If=()=>jf(Date.now()),Lf=e=>jf(e.epochMilliseconds),Rf=e=>new Date(e.epochMilliseconds),zf=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},Bf=e=>zf(e).getTime()-Hf(e),Vf=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},Hf=e=>e.epochMilliseconds,Uf=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},Wf=e=>Rf(e).toISOString();globalThis.String;const Gf=e=>e.trim(),Kf=e=>e.length>0,qf=P(2,(e,t)=>{let n=e.split(t);return on(n)?n:[e]}),Jf=P(2,(e,t)=>zc(e,$f,e=>t(e))),Yf=e=>e.reasons.some(Xf),Xf=e=>e._tag===`Fail`&&ud(e.error),Zf=Ua(id,e=>ud(e)?hi(e):gi(e)),Qf=za(e=>e.reasons.every(e=>!Xf(e))),$f=Ua(id,e=>ud(e)?hi(e.value):gi(e)),ep=e=>{let t=Zf(e);return vi(t)?_d(t.failure):gd(t.success.value)},tp=(e,t,n)=>El(r=>H(n?.local?$d(t,Zd(),r):ef(t,r),t=>Mc(e,t))),np=P(e=>Wn(e[0]),(e,t,n)=>Za(t)?Mc(e,t):tp(e,Array.isArray(t)?uf(...t):t,n));({...Bn});const rp=ho(`~effect/observability/Metric/MetricRegistryKey`,{defaultValue:()=>new Map}),ip=e=>{let t=ao(e,rp);return Array.from(t.values()).map(({hooks:t,...n})=>({...n,state:t.get(e)}))},ap=Wn,op=Ul,sp=ql,cp=Kl,lp=Ls,up=Rs,U=V,dp=Ms,fp=js,pp=ks,W=Os,mp=Fs,hp=Us,gp=Ws,G=Ds,_p=Es,vp=Ns,yp=Is,bp=R,K=H,xp=lc,Sp=tc,Cp=nc,wp=rl,q=uc,Tp=$s,Ep=rc,Dp=Bc,J=Wc,Op=Gc,kp=Lc,Ap=Uc,jp=zc,Mp=Jc,Np=Vc,Pp=Xc,Fp=sl,Ip=cl,Lp=ol,Rp=al,zp=ju,Bp=ac,Vp=Fc,Hp=Qc,Up=el,Wp=kc,Gp=jc,Kp=np,qp=Mc,Jp=Ec,Yp=Dc,Xp=Nc,Zp=Cl,Qp=Tl,$p=El,em=Dl,tm=Ol,nm=jl,rm=Nl,im=Al,am=Il,om=Fl,sm=Ll,cm=Hl,lm=Ic,um=gu,dm=wu,fm=Zl,pm=Ql,mm=Xl,hm=Bs,gm=tu,_m=$l,vm=nu,ym=ru,bm=su,xm=ou,Sm=au,Cm=iu,wm=du,Tm=uu,Em=lu,Dm=cu,Om=Gs,km=Js,Am=qu(`Warn`),jm=qu(`Error`),Mm=qu(`Info`),Nm=qu(`Debug`),Pm=P(e=>ap(e[0]),(e,...t)=>Oc(e,zo,e=>{let n={...e};return t.length===1?Object.assign(n,t[0]):n[t[0]]=t[1],n})),Fm=Hu,Im=(e,t,n)=>(...r)=>hp(i=>{try{e(...r,(e,n)=>{i(e?G(t?t(e,r):e):U(n))})}catch(e){i(n?G(n(e,r)):vp(e))}}),Lm=dc,Rm=fc,zm=pc,Bm=cc,Vm=mc,Hm=Xs;function Um(e,t,n){return t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n,e}function Wm(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Gm(e){return t=>Wm(t)?.[e]}const Km=Gm(`identifier`),qm=Gm(`brands`),Jm=rt(e=>{let t=Km(e);return typeof t==`string`?t:e.getExpected(Jm)});globalThis.RegExp;const Ym=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`),Xm=Of,Zm=kf,Qm=Af,$m=Mf,eh=Ff,th=If,nh=Lf,rh=Hf;Ga()(`effect/DateTime/CurrentTimeZone`);const ih=Wf;Sf(`EncodingError`);const ah=`~effect/SchemaIssue/Issue`;function oh(e){return I(e,ah)}var sh=class{[ah]=ah;toString(){return Th(this)}},ch=class extends sh{_tag=`Filter`;actual;filter;issue;constructor(e,t,n){super(),this.actual=e,this.filter=t,this.issue=n}},lh=class extends sh{_tag=`Encoding`;ast;actual;issue;constructor(e,t,n){super(),this.ast=e,this.actual=t,this.issue=n}},uh=class extends sh{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},dh=class extends sh{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},fh=class extends sh{_tag=`UnexpectedKey`;ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}},ph=class extends sh{_tag=`Composite`;ast;actual;issues;constructor(e,t,n){super(),this.ast=e,this.actual=t,this.issues=n}},mh=class extends sh{_tag=`InvalidType`;ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}},hh=class extends sh{_tag=`InvalidValue`;actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}},gh=class extends sh{_tag=`AnyOf`;ast;actual;issues;constructor(e,t,n){super(),this.ast=e,this.actual=t,this.issues=n}},_h=class extends sh{_tag=`OneOf`;ast;actual;successes;constructor(e,t,n){super(),this.ast=e,this.actual=t,this.successes=n}};function vh(e,t){if(oh(t))return t;if(t!==void 0)return typeof t==`boolean`?t?void 0:new hh(B(e)):typeof t==`string`?new hh(B(e),{message:t}):new uh(t.path,new hh(B(e),{message:t.message}))}const yh=e=>{let t=Dh(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return xh(Jm(e.ast),kh(e.actual));case`InvalidValue`:return`Invalid data ${kh(e.actual)}`;case`MissingKey`:return`Missing key`;case`UnexpectedKey`:return`Unexpected key with value ${pn(e.actual)}`;case`Forbidden`:return`Forbidden operation`;case`OneOf`:return`Expected exactly one member to match the input ${pn(e.actual)}`}},bh=e=>Dh(e.issue)??Dh(e);function xh(e,t){return`Expected ${e}, got ${t}`}function Sh(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];switch(e.issue._tag){case`InvalidValue`:return[{path:t,message:xh(Ch(e.filter),pn(e.actual))}];default:return Sh(e.issue,t,n,r)}}case`Encoding`:return Sh(e.issue,t,n,r);case`Pointer`:return Sh(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>Sh(e,t,n,r));case`AnyOf`:{let i=Dh(e);return e.issues.length===0?i===void 0?[{path:t,message:xh(Jm(e.ast),pn(e.actual))}]:[{path:t,message:i}]:e.issues.flatMap(e=>Sh(e,t,n,r))}default:return[{path:t,message:n(e)}]}}function Ch(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Ch(e)).join(` & `)}}function wh(){return e=>Sh(e,[],yh,bh).map(Eh).join(`
16
- `)}const Th=wh();function Eh(e){let t=e.message;if(e.path&&e.path.length>0){let n=gn(e.path);t+=`\n at ${n}`}return t}function Dh(e){switch(e._tag){case`InvalidType`:case`OneOf`:case`Composite`:case`AnyOf`:return Oh(e.ast.annotations);case`InvalidValue`:case`Forbidden`:return Oh(e.annotations);case`MissingKey`:return Oh(e.annotations,`messageMissingKey`);case`UnexpectedKey`:return Oh(e.ast.annotations,`messageUnexpectedKey`);case`Filter`:return Oh(e.filter.annotations);case`Encoding`:return Dh(e.issue)}}function Oh(e,t=`message`){let n=e?.[t];if(typeof n==`string`)return n}function kh(e){return ei(e)?`no value provided`:pn(e.value)}var Ah=class e extends Je{run;constructor(e){super(),this.run=e}map(t){return new e((e,n)=>this.run(e,n).pipe(Lm(di(t))))}compose(t){return Mh(this)?t:Mh(t)?this:new e((e,n)=>this.run(e,n).pipe(Bm(e=>t.run(e,n))))}};const jh=new Ah(U);function Mh(e){return e.run===jh.run}function Nh(){return jh}function Ph(e){return new Ah((t,n)=>ei(t)?dp:e(t.value,n))}function Fh(e){return Lh(di(e))}function Ih(e){return Ph((t,n)=>e(t,n).pipe(Lm(B)))}function Lh(e){return new Ah(t=>U(e(t)))}function Rh(){return Fh(globalThis.String)}function zh(){return Fh(globalThis.Number)}function Bh(){return Fh(globalThis.BigInt)}function Vh(e){return Ph(t=>yp({try:()=>B(JSON.parse(t,e?.reviver)),catch:e=>new hh(B(t),{message:globalThis.String(e)})}))}function Hh(e){return Ph(t=>yp({try:()=>B(JSON.stringify(t,e?.replacer,e?.space)),catch:e=>new hh(B(t),{message:globalThis.String(e)})}))}const Uh=`~effect/SchemaTransformation/Transformation`;var Wh=class e{[Uh]=Uh;_tag=`Transformation`;decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function Gh(e){return I(e,Uh)}const Kh=e=>Gh(e)?e:new Wh(e.decode,e.encode);function qh(e){return new Wh(Ih(e.decode),Ih(e.encode))}function Jh(e){return new Wh(Fh(e.decode),Fh(e.encode))}const Yh=new Wh(Nh(),Nh());function Xh(){return Yh}const Zh=new Wh(zh(),Rh()),Qh=new Wh(Bh(),Rh()),$h=e=>Jh({decode:e=>{let t=Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},encode:t=>{let n={name:t.name,message:t.message};return e?.includeStack&&typeof t.stack==`string`&&(n.stack=t.stack),n}});function eg(){return Jh({decode:oi,encode:si})}const tg=new Wh(Vh(),Hh()),ng=qh({decode:e=>ni(eh(e),{onNone:()=>G(new hh(B(e),{message:`Invalid DateTime input`})),onSome:e=>U(nh(e))}),encode:e=>U(ih(e))});function rg(e){return t=>t._tag===e}const ig=rg(`Declaration`),ag=rg(`Never`),og=rg(`Literal`),sg=rg(`UniqueSymbol`),cg=rg(`Arrays`),lg=rg(`Objects`),ug=rg(`Union`);var dg=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}};const fg={};var pg=class{isOptional;isMutable;defaultValue;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.defaultValue=n,this.annotations=r}};const mg=`~effect/Schema`;var hg=class{[mg]=mg;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},gg=class e extends hg{_tag=`Declaration`;typeParameters;run;constructor(e,t,n,r,i,a){super(n,r,i,a),this.typeParameters=e,this.run=t}getParser(){let e=this.run(this.typeParameters);return(t,n)=>ei(t)?dp:Lm(e(t.value,this,n),B)}recur(t){let n=g_(this.typeParameters,t);return n===this.typeParameters?this:new e(n,this.run,this.annotations,this.checks,void 0,this.context)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}};const _g=new class extends hg{_tag=`Null`;getParser(){return P_(this,null)}getExpected(){return`null`}};var vg=class extends hg{_tag=`Undefined`;getParser(){return P_(this,void 0)}toCodecJson(){return s_(this,[yg])}getExpected(){return`undefined`}};const yg=new dg(_g,new Wh(Fh(()=>void 0),Fh(()=>null))),bg=new vg,xg=new class extends hg{_tag=`Any`;getParser(){return F_(this,vt)}getExpected(){return`any`}},Sg=new class extends hg{_tag=`Unknown`;getParser(){return F_(this,vt)}getExpected(){return`unknown`}};var Cg=class extends hg{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${pn(e)}`);this.literal=e}getParser(){return P_(this,this.literal)}toCodecJson(){return typeof this.literal==`bigint`?wg(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:wg(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function wg(e){let t=globalThis.String(e.literal);return s_(e,[new dg(new Cg(t),new Wh(Fh(()=>e.literal),Fh(()=>t)))])}const Tg=new class extends hg{_tag=`String`;getParser(){return F_(this,ot)}getExpected(){return`string`}};var Eg=class extends hg{_tag=`Number`;getParser(){return F_(this,st)}toCodecJson(){return this.checks&&(Dg(this.checks,`isFinite`)||Dg(this.checks,`isInt`))?this:s_(this,[Zg])}toCodecStringTree(){return this.checks&&(Dg(this.checks,`isFinite`)||Dg(this.checks,`isInt`))?s_(this,[H_]):s_(this,[U_])}getExpected(){return`number`}};function Dg(e,t){return e.some(e=>{switch(e._tag){case`Filter`:return e.annotations?.meta?._tag===t;case`FilterGroup`:return Dg(e.checks,t)}})}const Og=new Eg,kg=new class extends hg{_tag=`Boolean`;getParser(){return F_(this,ct)}getExpected(){return`boolean`}},Ag=new class extends hg{_tag=`BigInt`;getParser(){return F_(this,lt)}toCodecStringTree(){return s_(this,[q_])}getExpected(){return`bigint`}};var jg=class e extends hg{_tag=`Arrays`;isMutable;elements;rest;constructor(e,t,n,r,i,a,o){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n;let s=t.findIndex(w_);if(s!==-1&&(t.slice(s+1).some(e=>!w_(e))||n.length>1))throw Error(`A required element cannot follow an optional element. ts(1257)`);if(n.length>1&&n.slice(1).some(w_))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e){let t=this,n=t.elements.map(t=>({ast:t,parser:e(t)})),r=t.rest.map(t=>({ast:t,parser:e(t)})),i=n.length;return Hm(function*(e,a){if(e._tag===`None`)return e;let o=e.value;if(!Array.isArray(o))return yield*G(new mh(t,e));let s=[],c,l=a.errors===`all`,u=0;for(;u<i;u++){let r=n[u],i=u<o.length?B(o[u]):z(),d=r.parser(i,a),f=sc(d)?d:yield*wp(d);if(f._tag===`Failure`){let n=id(f.cause);if(vi(n))return yield*f;let r=new uh([u],n.success);if(l)c?c.push(r):c=[r];else return yield*G(new ph(t,e,[r]))}else if(f.value._tag===`Some`)s[u]=f.value.value;else if(!w_(r.ast)){let n=new uh([u],new dh(r.ast.context?.annotations));if(l)c?c.push(n):c=[n];else return yield*G(new ph(t,e,[n]))}}let d=o.length;if(t.rest.length>0){let[n,...i]=r,f=n.ast.context?.annotations;for(;u<d-i.length;u++){let r=n.parser(B(o[u]),a),i=sc(r)?r:yield*wp(r);if(i._tag===`Failure`){let n=id(i.cause);if(vi(n))return yield*i;let r=new uh([u],n.success);if(l)c?c.push(r):c=[r];else return yield*G(new ph(t,e,[r]))}else if(i.value._tag===`Some`)s[u]=i.value.value;else{let n=new uh([u],new dh(f));if(l)c?c.push(n):c=[n];else return yield*G(new ph(t,e,[n]))}}for(let n=0;n<i.length;n++){let r=u+n;if(!(d<r)){let u=i[n],d=u.ast.context?.annotations,f=u.parser(B(o[r]),a),p=sc(f)?f:yield*wp(f);if(p._tag===`Failure`){let n=id(p.cause);if(vi(n))return yield*p;let i=new uh([r],n.success);if(l)c?c.push(i):c=[i];else return yield*G(new ph(t,e,[i]))}else if(p.value._tag===`Some`)s[r]=p.value.value;else{let n=new uh([r],new dh(d));if(l)c?c.push(n):c=[n];else return yield*G(new ph(t,e,[n]))}}}}else for(let n=i;n<=d-1;n++){let r=new uh([n],new fh(t,o[n]));if(l)c?c.push(r):c=[r];else return yield*G(new ph(t,e,[r]))}return c?yield*G(new ph(t,e,c)):B(s)})}recur(t){let n=g_(this.elements,t),r=g_(this.rest,t);return n===this.elements&&r===this.rest?this:new e(this.isMutable,n,r,this.annotations,this.checks,void 0,this.context)}getExpected(){return`array`}};const Mg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`,Ng=new globalThis.RegExp(`(?:${Mg}|Infinity|-Infinity|NaN)`);function Pg(e,t){let n=E_(t);switch(n._tag){case`String`:return Object.keys(e);case`TemplateLiteral`:{let t=j_(n);return Object.keys(e).filter(e=>t.test(e))}case`Symbol`:return Object.getOwnPropertySymbols(e);case`Number`:return Object.keys(e).filter(e=>Ng.test(e));case`Union`:return[...new Set(n.types.flatMap(t=>Pg(e,t)))];default:return[]}}var Fg=class{name;type;constructor(e,t){this.name=e,this.type=t}},Ig=class e{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new e(this.encode,this.decode)}},Lg=class{parameter;type;merge;constructor(e,t,n){if(this.parameter=e,this.type=t,this.merge=n,w_(t)&&!k_(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Rg=class e extends hg{_tag=`Objects`;propertySignatures;indexSignatures;constructor(e,t,n,r,i,a){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t;let o=e.map(e=>e.name).filter((e,t,n)=>n.indexOf(e)!==t);if(o.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(o)}. ts(2300)`)}getParser(e){let t=this,n=[],r=new Set,i=[],a=t.propertySignatures.length;for(let a of t.propertySignatures)n.push(a.name),r.add(a.name),i.push({ps:a,parser:e(a.type),name:a.name,type:a.type});let o=t.indexSignatures.length;return t.propertySignatures.length===0&&t.indexSignatures.length===0?F_(t,_t):Hm(function*(s,c){if(s._tag===`None`)return s;let l=s.value;if(!(typeof l==`object`&&l&&!Array.isArray(l)))return yield*G(new mh(t,s));let u={},d,f=c.errors===`all`,p=c.onExcessProperty===`error`,m=c.onExcessProperty===`preserve`,h;if(t.indexSignatures.length===0&&(p||m)){h=Reflect.ownKeys(l);for(let e=0;e<h.length;e++){let n=h[e];if(!r.has(n))if(p){let e=new uh([n],new fh(t,l[n]));if(f){d?d.push(e):d=[e];continue}else return yield*G(new ph(t,s,[e]))}else Um(u,n,l[n])}}for(let e=0;e<a;e++){let n=i[e],r=Object.hasOwn(l,n.name)?B(l[n.name]):z(),a=n.parser(r,c),o=sc(a)?a:yield*wp(a);if(o._tag===`Failure`){let e=id(o.cause);if(vi(e))return yield*o;let r=new uh([n.name],e.success);if(f){d?d.push(r):d=[r];continue}else return yield*G(new ph(t,s,[r]))}else if(o.value._tag===`Some`)Um(u,n.name,o.value.value);else if(!w_(n.type)){let e=new uh([n.name],new dh(n.type.context?.annotations));if(f){d?d.push(e):d=[e];continue}else return yield*G(new ph(t,s,[e]))}}if(o>0)for(let n=0;n<o;n++){let r=t.indexSignatures[n],i=Pg(l,r.parameter);for(let n=0;n<i.length;n++){let a=i[n],o=e(L_(r.parameter))(B(a),c),p=sc(o)?o:yield*wp(o);if(p._tag===`Failure`){let e=id(p.cause);if(vi(e))return yield*p;let n=new uh([a],e.success);if(f){d?d.push(n):d=[n];continue}return yield*G(new ph(t,s,[n]))}let m=B(l[a]),h=e(r.type)(m,c),g=sc(h)?h:yield*wp(h);if(g._tag===`Failure`){let e=id(g.cause);if(vi(e))return yield*g;let n=new uh([a],e.success);if(f){d?d.push(n):d=[n];continue}else return yield*G(new ph(t,s,[n]))}else if(p.value._tag===`Some`&&g.value._tag===`Some`){let e=p.value.value,t=g.value.value;if(r.merge&&r.merge.decode&&Object.hasOwn(u,e)){let[n,i]=r.merge.decode.combine([e,u[e]],[e,t]);Um(u,n,i)}else Um(u,e,t)}}}if(d)return yield*G(new ph(t,s,d));if(c.propertyOrder===`original`){let e=(h??Reflect.ownKeys(l)).concat(n),t={};for(let n of e)Object.hasOwn(u,n)&&Um(t,n,u[n]);return B(t)}return B(u)})}rebuild(t,n){let r=g_(this.propertySignatures,e=>{let n=t(e.type);return n===e.type?e:new Fg(e.name,n)}),i=g_(this.indexSignatures,e=>{let r=t(e.parameter),i=t(e.type),a=n?e.merge?.flip():e.merge;return r===e.parameter&&i===e.type&&a===e.merge?e:new Lg(r,i,a)});return r===this.propertySignatures&&i===this.indexSignatures?this:new e(r,i,this.annotations,this.checks,void 0,this.context)}flip(e){return this.rebuild(e,!0)}recur(e){return this.rebuild(e,!1)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function zg(e,t,n){return new Rg(Reflect.ownKeys(e).map(t=>new Fg(t,e[t].ast)),[],n,t)}function Bg(e){return e.ast}function Vg(e,t=void 0){return new jg(!1,e.map(e=>e.ast),[],void 0,t)}function Hg(e,t,n){return new Yg(e.map(Bg),t,void 0,n)}function Ug(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:case`Void`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`object`,`array`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Ug)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function Wg(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[`~sentinels`];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!w_(t)){if(og(t))return[{key:e.name,literal:t.literal}];if(sg(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>og(e)&&!w_(e)?[{key:t,literal:e.literal}]:[]);case`Suspend`:return Wg(e.thunk())}}const Gg=new WeakMap;function Kg(e){let t=Gg.get(e);if(t)return t;t={};for(let n of e){let e=E_(n);if(ag(e))continue;let r=Ug(e),i=Wg(e);t.byType??={};for(let e of r)(t.byType[e]??=[]).push(n);if(i.length>0){t.bySentinel??=new Map;for(let{key:e,literal:r}of i){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let a=i.get(r);a||i.set(r,a=[]),a.push(n)}}else{t.otherwise??={};for(let e of r)(t.otherwise[e]??=[]).push(n)}}return Gg.set(e,t),t}function qg(e){return t=>{let n=E_(t);return n._tag===`Literal`?n.literal===e:n._tag===`UniqueSymbol`?n.symbol===e:!0}}function Jg(e,t){let n=Kg(t),r=e===null?`null`:Array.isArray(e)?`array`:typeof e;if(n.bySentinel){let t=n.otherwise?.[r]??[];if(r===`object`||r===`array`){for(let[r,i]of n.bySentinel)if(Object.hasOwn(e,r)){let n=i.get(e[r]);if(n)return[...n,...t].filter(qg(e))}}return t}return(n.byType?.[r]??[]).filter(qg(e))}var Yg=class e extends hg{_tag=`Union`;types;mode;constructor(e,t,n,r,i,a){super(n,r,i,a),this.types=e,this.mode=t}getParser(e){let t=this;return Hm(function*(n,r){if(n._tag===`None`)return n;let i=n.value,a=t.mode===`oneOf`,o=Jg(i,t.types),s,c={out:void 0,successes:[]};for(let l=0;l<o.length;l++){let u=o[l],d=e(u)(n,r),f=sc(d)?d:yield*wp(d);if(f._tag===`Failure`){let e=id(f.cause);if(vi(e))return yield*f;s?s.push(e.success):s=[e.success];continue}else{if(c.out&&a)return c.successes.push(u),yield*G(new _h(t,i,c.successes));if(c.out=f.value,c.successes.push(u),!a)break}}return c.out?c.out:yield*G(new gh(t,i,s??[]))})}recur(t){let n=g_(this.types,t);return n===this.types?this:new e(n,this.mode,this.annotations,this.checks,void 0,this.context)}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=E_(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(og);if(t.length>0)return`${Qg(n.isMutable)}[ ${t.map(t=>e(t)+$g(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>og(e.type));if(t.length>0)return`{ ${t.map(t=>`${Qg(t.type.context?.isMutable)}${hn(t.name)}${$g(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};const Xg=new Yg([new Cg(`Infinity`),new Cg(`-Infinity`),new Cg(`NaN`)],`anyOf`),Zg=new dg(new Yg([Og,Xg],`anyOf`),new Wh(zh(),Fh(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Qg(e){return e?``:`readonly `}function $g(e){return e?`?`:``}function e_(e){let t=!1,n;return()=>t?n:(n=e(),t=!0,n)}var t_=class e extends hg{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){super(t,n,r,i),this.thunk=e_(e)}getParser(e){return e(this.thunk())}recur(t){return new e(()=>t(this.thunk()),this.annotations,this.checks,void 0,this.context)}getExpected(e){return e(this.thunk())}},n_=class e extends Je{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(e,t){return new r_([this,e],t)}},r_=class e extends Je{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function i_(e,t,n=!1){return new n_((t,n,r)=>vh(t,e(t,n,r)),t,n)}function a_(e,t){let n=e.source;return i_(t=>e.test(t),{expected:`a string matching the RegExp ${n}`,meta:{_tag:`isPattern`,regExp:e},toArbitraryConstraint:{string:{patterns:[e.source]}},...t})}function o_(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}function s_(e,t){return e.encoding===t?e:o_(e,e=>{e.encoding.value=t})}function c_(e,t){return e.context===t?e:o_(e,e=>{e.context.value=t})}function l_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return u_(e,Ei(e.checks.slice(0,-1),n.annotate(t)))}return o_(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function u_(e,t){return e.checks===t?e:o_(e,e=>{e.checks.value=t})}function d_(e,t){return u_(e,e.checks?[...e.checks,...t]:t)}function f_(e,t){let n=e,r=n[n.length-1],i=t(r.to);return i===r.to?e:Ei(e.slice(0,e.length-1),new dg(i,r.transformation))}function p_(e){return t=>t.encoding?s_(t,f_(t.encoding,e)):t}function m_(e,t,n){let r=new dg(e,t);return s_(n,n.encoding?[...n.encoding,r]:[r])}function h_(e,t){let n=qm(e);return l_(e,{brands:n?[...n,t]:[t]})}function g_(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function __(e,t){return c_(e,e.context?new pg(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new pg(!1,!1,void 0,t))}const v_=p_(y_);function y_(e){return v_(c_(e,e.context?e.context.isOptional===!1?new pg(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new pg(!0,!1)))}function b_(e,t){let n=[new dg(Sg,new Wh(new Ah(e=>{if(ei(pi(e,mt))){let n=t(e);return ap(n)?n:U(n)}else return U(e)}),Nh()))];return c_(e,e.context?new pg(e.context.isOptional,e.context.isMutable,n,e.context.annotations):new pg(!1,!1,n))}function x_(e,t,n){return m_(e,n,t)}function S_(e){switch(e._tag){case`Literal`:return{literals:dt(e.literal)?[e.literal]:[],parameters:[]};case`UniqueSymbol`:return{literals:[e.symbol],parameters:[]};case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return{literals:[],parameters:[e]};case`Union`:{let t={literals:[],parameters:[]};for(let n=0;n<e.types.length;n++){let r=S_(e.types[n]);t.literals=t.literals.concat(r.literals),t.parameters=t.parameters.concat(r.parameters)}return t}}return{literals:[],parameters:[]}}function C_(e,t,n){let{literals:r,parameters:i}=S_(e);return new Rg(r.map(e=>new Fg(e,t)),i.map(e=>new Lg(e,t,n)))}function w_(e){return e.context?.isOptional??!1}const T_=rt(e=>{if(e.encoding)return T_(s_(e,void 0));let t=e;return t.recur?.(T_)??t}),E_=rt(e=>T_(O_(e)));function D_(e,t){let n=t,r=n.length,i=n[r-1],a=[new dg(O_(s_(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new dg(O_(n[e-1].to),n[e].transformation.flip()));let o=O_(i.to);return o.encoding?s_(o,[...o.encoding,...a]):s_(o,a)}const O_=rt(e=>{if(e.encoding)return D_(e,e.encoding);let t=e;return t.flip?.(O_)??t.recur?.(O_)??t});function k_(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(k_);default:return!1}}function A_(e,t){return e.encodedParts.map(e=>N_(e,M_(e),t)).join(``)}const j_=rt(e=>new globalThis.RegExp(`^${A_(e,!0)}$`));function M_(e){switch(e._tag){case`Literal`:return Ym(globalThis.String(e.literal));case`String`:return R_;case`Number`:return Mg;case`BigInt`:return W_;case`TemplateLiteral`:return A_(e,!1);case`Union`:return e.types.map(M_).join(`|`)}}function N_(e,t,n){if(ug(e)){if(!n)return`(?:${t})`}else if(!n)return t;return`(${t})`}function P_(e,t){let n=fp(t);return r=>r._tag===`None`?dp:r.value===t?n:G(new mh(e,r))}function F_(e,t){return n=>n._tag===`None`?dp:t(n.value)?U(n):G(new mh(e,n))}function I_(e){function t(n){return n.encoding?s_(n,f_(n.encoding,t)):e(n)}return rt(t)}const L_=I_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(L_)}}),R_=`[\\s\\S]*?`,z_=new globalThis.RegExp(`^${Mg}$`);function B_(e){return a_(z_,{expected:`a string representing a finite number`,meta:{_tag:`isStringFinite`,regExp:z_},...e})}const V_=d_(Tg,[B_()]),H_=new dg(V_,Zh),U_=new dg(new Yg([V_,Xg],`anyOf`),Zh),W_=`-?\\d+`,G_=new globalThis.RegExp(`^${W_}$`);function K_(e){return a_(G_,{expected:`a string representing a bigint`,meta:{_tag:`isStringBigInt`,regExp:G_},...e})}const q_=new dg(d_(Tg,[K_()]),Qh);function J_(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`)J_(o.checks,t,n,r,i);else{let e=o.run(t,r,i);if(e&&(n.push(new ch(t,o,e)),o.aborted||i?.errors!==`all`))return}}}const Y_=`~effect/Schema/Class`;function X_(e){let t=new Set;return n(e);function n(e){return e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?globalThis.Number.isFinite(e):typeof e!=`object`||e===void 0||t.has(e)?!1:(t.add(e),Array.isArray(e)?e.every(n):Object.keys(e).every(t=>n(e[t])))}}const Z_=new gg([],()=>(e,t)=>X_(e)?U(e):G(new mh(t,B(e))),{typeConstructor:{_tag:`effect/Json`},generation:{runtime:`Schema.Json`,Type:`Schema.Json`},expected:`JSON value`,toCodecJson:()=>new dg(Sg,Xh())}),Q_=new dg(_g,new Wh(Nh(),Fh(()=>null))),$_=new dg(Z_,Xh());function ev(){return Object.assign(e=>e,{option:e=>B(e),result:e=>hi(e),is:e=>!0})}const tv=`~effect/collections/MutableHashMap`,nv={[tv]:tv,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${pn(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:xn(Array.from(this))}},[bn](){return this.toJSON()},pipe(){return N(this,arguments)}},rv=()=>{let e=Object.create(nv);return e.backing=new Map,e.buckets=new Map,e},iv=P(2,(e,t)=>{if(e.backing.has(t))return B(e.backing.get(t));if(ov(t))return z();let n=av.get(e);if(n!==void 0)return e.backing.has(n)?B(e.backing.get(n)):z();let r=wt(t),i=e.buckets.get(r);return i===void 0?z():cv(e,i,t)}),av=new WeakMap,ov=e=>typeof e!=`object`&&typeof e!=`function`,sv=e=>e.backing.values(),cv=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(Ht(n,t[r])){let i=t[r];return av.set(n,i),B(e.backing.get(i))}return z()},lv=P(2,(e,t)=>ti(iv(e,t))),uv=P(3,(e,t,n)=>{if(e.backing.has(t)||ov(t))return e.backing.set(t,n),e;let r=av.get(e);if(r!==void 0&&e.backing.has(r))return e.backing.set(r,n),e;let i=wt(t),a=e.buckets.get(i);return a===void 0?(e.buckets.set(i,[t]),e.backing.set(t,n),e):(r=dv(a,t),r===void 0&&(a.push(t),r=t),e.backing.set(r,n),e)}),dv=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(Ht(t,e[n]))return av.set(t,e[n]),e[n]},fv=P(2,(e,t)=>{if(ov(t))return e.backing.delete(t),e;let n=av.get(e)??t,r=wt(n),i=e.buckets.get(r);if(i===void 0)return e;for(let t=0,r=i.length;t<r;t++){let r=i[t];if(r===n||Ht(n,r)){e.backing.delete(r),i.splice(t,1);break}}return i.length===0&&e.buckets.delete(r),e}),pv=ys,mv=xs,hv=Ss,gv=Cs,_v=Ts,vv=hs,yv=eu,bv=hu,xv=Symbol.for(`effect/MutableList/Empty`),Sv=()=>({head:void 0,tail:void 0,length:0}),Cv=()=>({array:[],mutable:!0,offset:0,next:void 0}),wv=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Cv(),e.tail=e.tail.next):e.head=e.tail=Cv(),e.tail.array.push(t),e.length++},Tv=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.length++},Ev=e=>{e.head=e.tail=void 0,e.length=0},Dv=(e,t)=>{if(t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Ev(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i,e.length-=t,e.length===0&&Ev(e),n;i=i.next}return Ev(e),n},Ov=e=>Dv(e,e.length),kv=e=>{if(!e.head)return xv;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:Ev(e)),t},Av=(e,t)=>{let n=[],r=e.head;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],e)&&n.push(r.array[e]);r=r.next}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0}},jv=(e,t)=>Av(e,e=>e!==t),Mv=`~effect/MutableRef`,Nv={[Mv]:Mv,...zn,toJSON(){return{_id:`MutableRef`,current:xn(this.current)}}},Pv=e=>{let t=Object.create(Nv);return t.current=e,t},Fv=P(2,(e,t)=>(e.current=t,e)),Iv=e=>W(()=>$v(e.atomicPubSub(),new Map,Id(),bv(!1),Pv(!1),e.strategy())),Lv=e=>Iv({atomicPubSub:()=>Rv(e),strategy:()=>new ey}),Rv=e=>new Yv(e?.replay?new ry(e.replay):void 0),zv=P(2,(e,t)=>pp(()=>e.shutdownFlag.current?am:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),U(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),Bv=P(2,(e,t)=>e.shutdownFlag.current?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),Vv=e=>em(W(()=>Jv(e.pubsub,e.subscribers,e.strategy)),Hv),Hv=e=>sm(bp(t=>(Fv(e.shutdownFlag,!0),sp(Ov(e.pollers),e=>Ad(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Cp(()=>W(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Vp(e.shutdownHook.open),Ep)))),Uv=e=>pp(function t(n){if(e.shutdownFlag.current)return am;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?U(e.replayWindow.takeAll().concat(r)):ki(r)?U(r):K(Wv(e),e=>t([e]))}),Wv=e=>{let t=wd(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),wv(e.pollers,t),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),om(Ed(t),()=>(jv(e.pollers,t),mp))},Gv=Symbol.for(`effect/PubSub/AbsentValue`),Kv=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},qv=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},Jv=(e,t,n)=>new Zv(e,t,e.subscribe(),Sv(),bv(!1),Pv(!1),n,e.replayWindow());var Yv=class{publisherHead={value:Gv,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=2**53-1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new iy(this.replayBuffer):ay}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.publisherTail.subscribers;return t!==0&&(this.publisherTail.next={value:e,subscribers:t,next:null},this.publisherTail=this.publisherTail.next,this.publisherIndex+=1),this.replayBuffer&&this.replayBuffer.offer(e),!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else this.replayBuffer&&this.replayBuffer.offerAll(e);return[]}slide(){this.publisherHead!==this.publisherTail&&(this.publisherHead=this.publisherHead.next,this.publisherHead.value=Gv,this.subscribersIndex+=1),this.replayBuffer&&this.replayBuffer.slide()}subscribe(){return this.publisherTail.subscribers+=1,new Xv(this,this.publisherTail,this.publisherIndex,!1)}},Xv=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;for(;t;)this.subscriberHead===this.self.publisherTail?t=!1:this.subscriberHead.next.value===Gv?(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1):(e=!1,t=!1);return e}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return xv;let e=!0,t=xv;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==Gv&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gv,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){let t=[],n=0;for(;n!==e;){let r=this.poll();r===xv?n=e:(t.push(r),n+=1)}return t}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,--this.self.publisherTail.subscribers;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==Gv&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=Gv,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},Zv=class{"~effect/PubSub/Subscription"={_A:F};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;constructor(e,t,n,r,i,a,o,s){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s}pipe(){return N(this,arguments)}},Qv=class{"~effect/PubSub"={_A:F};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;constructor(e,t,n,r,i,a){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=i,this.strategy=a}pipe(){return N(this,arguments)}};const $v=(e,t,n,r,i,a)=>new Qv(e,t,n,r,i,a);var ey=class{get shutdown(){return mp}handleSurplus(e,t,n,r){return U(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return ty(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return ny(this,e,t)}};const ty=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=kv(i);if(o===xv)qv(n,r,i),i.length===0?a=!1:Kv(n,r,i);else{let a=r.poll();a===xv?Tv(i,o):(Nd(o,gd(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},ny=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)};var ry=class{capacity;head={value:Gv,next:null};tail=this.head;size=0;index=0;constructor(e){this.capacity=e}slide(){this.index++}offer(e){this.tail.value=e,this.tail.next={value:Gv,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1}offerAll(e){for(let t of e)this.offer(t)}},iy=class{head;index;remaining;buffer;constructor(e){this.buffer=e,this.index=e.index,this.remaining=e.size,this.head=e.head}fastForward(){for(;this.index<this.buffer.index;)this.head=this.head.next,this.index++}take(){if(this.remaining===0)return;this.index<this.buffer.index&&this.fastForward(),this.remaining--;let e=this.head.value;return this.head=this.head.next,e}takeN(e){if(this.remaining===0)return[];this.index<this.buffer.index&&this.fastForward();let t=Math.min(e,this.remaining),n=Array(t);for(let e=0;e<t;e++){let t=this.head.value;this.head=this.head.next,n[e]=t}return this.remaining-=t,n}takeAll(){return this.takeN(this.remaining)}};const ay={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[]},oy={_A:F,_E:F},sy={"~effect/Queue":oy,"~effect/Queue/Enqueue":oy,"~effect/Queue/Dequeue":oy,...zn,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Sy(this)}}},cy=e=>R(t=>{let n=Object.create(sy);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Sv(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},V(n)}),ly=e=>cy({capacity:e}),uy=()=>cy(),dy=(e,t)=>ks(()=>{if(e.state._tag!==`Open`)return wy;if(e.messages.length>=e.capacity)switch(e.strategy){case`dropping`:return wy;case`suspend`:return e.capacity<=0&&e.state.takers.size>0?(wv(e.messages,t),Oy(e),Ty):jy(e,t);case`sliding`:return kv(e.messages),wv(e.messages,t),Ty}return wv(e.messages,t),ky(e),Ty}),fy=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(kv(e.messages),wv(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(wv(e.messages,t),Oy(e),!0):!1:(wv(e.messages,t),ky(e),!0):!1,py=P(2,(e,t)=>Os(()=>my(e,t))),my=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=Cc(gr(t),Ey);return e.state.offers.size===0&&e.messages.length===0?(Py(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},!0)},hy=e=>py(e,nr(Dr())),gy=e=>my(e,nr(Dr())),_y=e=>Os(()=>{if(e.state._tag===`Done`)return!0;Ev(e.messages);let t=e.state.offers;if(Py(e,e.state._tag===`Open`?Dy:e.state.exit),t.size>0){for(let e of t)e._tag===`Single`?e.resume(wy):e.resume(pr(e.remaining.slice(e.offset)));t.clear()}return!0}),vy=e=>yy(e,1,1/0),yy=(e,t,n)=>ks(()=>Ay(e,t,n)??tc(Ny(e),yy(e,1,n))),by=e=>ks(()=>xy(e)??tc(Ny(e),by(e))),xy=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=kv(e.messages);return My(e),pr(t)}else if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,My(e),e.capacity=0;let t=kv(e.messages);return My(e),pr(t)}},Sy=e=>e.state._tag===`Done`?0:e.messages.length,Cy=P(2,(e,t)=>Hl(n=>Qc(n(e),{onFailure:e=>py(t,e),onSuccess:e=>hy(t)}))),wy=pr(!1),Ty=pr(!0),Ey=_r(Dr()),Dy=hc(),Oy=e=>{if(e.scheduleRunning=!1,!(e.state._tag===`Done`||e.state.takers.size===0)){for(let t of e.state.takers)if(e.state.takers.delete(t),t(yc),e.messages.length===0)break}},ky=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>Oy(e),0))},Ay=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return pr([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,My(e),e.capacity=0;let t=[kv(e.messages)];return My(e),pr(t)}if(t=Math.min(t,e.capacity||1),t<=e.messages.length){let t=Dv(e.messages,n);return My(e),pr(t)}},jy=(e,t)=>Us(n=>{if(e.state._tag!==`Open`)return n(wy);let r={_tag:`Single`,message:t,resume:n};return e.state.offers.add(r),Os(()=>{e.state._tag===`Open`&&e.state.offers.delete(r)})}),My=e=>{if(e.state._tag===`Done`)return Yf(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0?(Py(e,e.state.exit),Yf(e.state.exit.cause)):!1;let t=e.capacity-e.messages.length;for(let n of e.state.offers)if(t===0)break;else if(n._tag===`Single`)wv(e.messages,n.message),t--,n.resume(Ty),e.state.offers.delete(n);else{for(;n.offset<n.remaining.length;n.offset++){if(t===0)return!1;wv(e.messages,n.remaining[n.offset]),t--}n.resume(pr([])),e.state.offers.delete(n)}return!1},Ny=e=>Us(t=>e.state._tag===`Done`?t(e.state.exit):(e.state.takers.add(t),Os(()=>{e.state._tag!==`Done`&&e.state.takers.delete(t)}))),Py=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},Fy=e=>new Iy(e);var Iy=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ks(()=>this.free<e?Us(n=>{if(this.free>=e)return n(t);let r=()=>{this.free<e||(this.waiters.delete(r),n(t))};return this.waiters.add(r),Os(()=>{this.waiters.delete(r)})}):(this.taken+=e,V(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;t.done===!1&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return R(t=>V(this.updateTakenUnsafe(t,e)))}resize(e){return R(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),Fs))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>Hl(n=>H(n(this.take(e)),e=>kl(n(t),()=>{this.updateTakenUnsafe(hs(),t=>t-e)},!0)))}get withPermit(){return this.withPermits(1)}withPermitsIfAvailable(e){return t=>Hl(n=>this.free<e?Ms:(this.taken+=e,kl(n(ec(t)),()=>{this.updateTakenUnsafe(hs(),t=>t-e)},!0)))}};const Ly=`~effect/Channel`,Ry=e=>I(e,Ly),zy={[Ly]:{_Env:F,_InErr:F,_InElem:F,_OutErr:F,_OutElem:F},pipe(){return N(this,arguments)}},By=e=>{let t=Object.create(zy);return t.transform=(t,n)=>kp(e(t,n),e=>U(_p(e))),t},Vy=(e,t)=>By((n,r)=>K(Wy(e)(n,r),e=>t(e,r))),Hy=e=>By((t,n)=>e),Uy=e=>By(Om(function*(t,n){let r=Vd(n),i=e=>Hd(r,ep(e));return rm(yield*rm(e(t,n,r),i),i)})),Wy=e=>e.transform,Gy=(e,t,n)=>cy({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Cp(t=>zd(e,_y(t))),Cp(n=>fm(Ld(t(n),e),e))),Ky=(e,t)=>By((n,r)=>q(Gy(r,e,t),vy)),qy=e=>By((t,n)=>pp(()=>Wy(e())(t,n))),Jy=Hy(U(fd())),Yy=e=>Hy(U(G(e))),Xy=e=>Hy(_p(e)),Zy=e=>Xy(ed(e)),Qy=e=>Hy(K(e,()=>fd())),$y=e=>Hy(U(vy(e))),eb=e=>Hy(U(om(Uv(e),()=>fd()))),tb=e=>xb(q(Vv(e),eb)),nb=P(2,(e,t)=>Vy(e,e=>W(()=>{let n=0;return q(e,e=>t(e,n++))}))),rb=P(2,(e,t)=>ib(e,e=>U(t(e)))),ib=P(2,(e,t)=>Vy(e,e=>U(Jf(e,e=>K(t(e),fd))))),ab=e=>e===void 0||e!==`unbounded`&&e<=1,ob=P(e=>Ry(e[0]),(e,t,n)=>ab(n?.concurrency)?sb(e,t):cb(e,t,n)),sb=(e,t)=>By((n,r)=>{let i=0;return q(Wy(e)(n,r),K(e=>t(e,i++)))}),cb=(e,t,n)=>Uy(Om(function*(r,i,a){let o=0,s=yield*Wy(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*ly(0);yield*zd(a,_y(l));let u=_m(yield*Wp()),d=yv(a);if(n.unordered){let e=Fy(c),n=Ye(e.release(1)),r=Hp({onFailure:e=>K(py(l,e),n),onSuccess:e=>K(dy(l,e),n)});yield*e.take(1).pipe(K(()=>s),K(e=>(d(u(r(t(e,o++)))),mp)),lm({disableYield:!0}),kp(t=>e.withPermits(c-1)(py(l,t))),fm(a))}else{let e=yield*ly(c-2);yield*zd(a,_y(l)),yield*by(e).pipe(xp,K(e=>dy(l,e)),lm({disableYield:!0}),kp(e=>py(l,e)),fm(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,my(l,e.cause))};yield*s.pipe(K(i=>{if(n)return _p(n);let a=u(t(i,o++));return d(a),a.addObserver(r),dy(e,mv(a))}),lm({disableYield:!0}),kp(t=>dy(e,_d(t)).pipe(Sp(py(e,t)))),fm(a))}return by(l)})),lb=e=>Vy(e,e=>{let t,n=0;return U(pp(function r(){if(t===void 0)return K(e,e=>{switch(e.length){case 0:return r();case 1:return U(e[0]);default:return t=e,U(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),U(i)}))}),ub=P(2,(e,t)=>Vy(e,e=>U(K(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return Ai(i)?U(i):K(e,n)})))),db=P(e=>Ry(e[0]),(e,t,n,r)=>By((i,a)=>q(Wy(e)(i,a),e=>{let i=t(),a,o=0,s,c=Hp(e,{onFailure(e){s=e;let t=r?.onHalt&&r.onHalt(i);return t&&t.length>0?U([i,t]):_p(e)},onSuccess(e){let t=n(i,e);return Oi(t)?U(t):t}});return pp(function e(){if(a===void 0)return s?_p(s):K(c,([t,n])=>(i=t,n.length===0?e():n.length===1?U(n[0]):(a=n,e())));let t=a[o++];return o>=a.length&&(a=void 0,o=0),U(t)})}))),fb=P(2,(e,t)=>By((n,r)=>{let i=Vd(r);return q(Wy(e)(n,i),e=>{let a=e.pipe(kp(e=>{if(Yf(e))return _p(e);let o=i;return i=Vd(r),Hd(o,_d(e)).pipe(Sp(Wy(t(e))(n,i)),K(e=>(a=e,e)))}));return pp(()=>a)})})),pb=P(2,(e,t)=>fb(e,e=>Qy(K(t(e),t=>_p(e))))),mb=P(3,(e,t,n)=>fb(e,e=>{let r=t(e);return vi(r)?Xy(r.failure):n(r.success,e)})),hb=P(2,(e,t)=>mb(e,id,e=>t(e))),gb=P(2,(e,t)=>hb(e,e=>Yy(t(e)))),_b=e=>hb(e,Zy),vb=P(e=>Ry(e[0])&&Ry(e[1]),(e,t,n)=>Uy(Om(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*ly(0);yield*zd(a,_y(s));let c=0;function l(e,t){if(c++,!Yf(t))return py(s,t);switch(o){case`both`:return c===2?py(s,t):mp;case`left`:case`right`:return e===o?py(s,t):mp;case`either`:return py(s,t)}}let u=(e,t,n)=>Wy(t)(r,n).pipe(K(e=>e.pipe(K(e=>dy(s,e)),lm)),rm(t=>Sp(Hd(n,ep(t)),l(e,t))),fm(a));return yield*u(`left`,e,Vd(a)),yield*u(`right`,t,Vd(a)),by(s)}))),yb=()=>By((e,t)=>W(()=>{let t=``,n=!1,r=e=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a.length!==0){let e=0,i=a.indexOf(`\r`),o=a.indexOf(`
17
- `);for(n&&=(o===0?(r.push(t),t=``,e=1,o=a.indexOf(`
18
- `,e)):t+=`\r`,!1);i!==-1||o!==-1;)i===-1||o!==-1&&o<i?(t.length===0?r.push(a.substring(e,o)):(r.push(t+a.substring(e,o)),t=``),e=o+1,o=a.indexOf(`
19
- `,e)):a.length===i+1?(n=!0,i=-1):o===i+1?(t.length===0?r.push(a.substring(e,i)):(t+=a.substring(e,i),r.push(t),t=``),e=i+2,i=a.indexOf(`\r`,e),o=a.indexOf(`
20
- `,e)):i=a.indexOf(`\r`,i+1);n?t+=a.substring(e,a.length-1):t+=a.substring(e,a.length)}}return Ai(r)?r:null};return K(e,function t(n){let i=r(n);return i===null?K(e,t):U(i)})})),bb=P(2,(e,t)=>By((n,r)=>K(Wy(e)(n,r),e=>Wy(t)(e,r)))),xb=e=>By((t,n)=>{let r;return U(pp(()=>r||e.pipe(Ld(n),K(e=>Wy(e)(t,n)),K(e=>r=e))))}),Sb=P(2,(e,t)=>Uy((n,r,i)=>Rd(i,t).pipe(Sp(Wy(e)(n,r))))),Cb=P(2,(e,t)=>Vy(e,e=>W(()=>{let n=!0,r=Cp(e,e=>(n=!1,t(e)));return pp(()=>n?r:e)}))),wb=P(2,(e,t)=>Sb(e,e=>t)),Tb=(e,t,n)=>pp(()=>{let r=Id();return Jf(K(Wy(e)(fd(),r),t),n||U).pipe(im(e=>Hd(r,e)))}),Eb=P(2,(e,t)=>Tb(e,e=>lm(K(e,t),{disableYield:!0}))),Db=e=>pp(()=>{let t=Symbol(),n=t;return Tb(e,e=>lm(K(e,e=>(n=e,mp)),{disableYield:!0}),()=>n===t?dp:fp(n))}),Ob=P(3,(e,t,n)=>pp(()=>{let r=t();return Tb(e,e=>cp({while:Xe,body:()=>e,step:e=>{r=n(r,e)}}),()=>U(r))})),kb=Om(function*(e){let t=Fy(1),n=yield*Wp(),r=ao(n,Fd);return(yield*Wy(e)(fd(),r)).pipe(qp(n),t.withPermits(1))},kp(e=>U(_p(e)))),Ab=(e,t)=>Wy(e)(fd(),t),jb=e=>e,Mb=rt(e=>{switch(e._tag){case`Declaration`:{let t=e.annotations?.[Y_];if(ft(t)){let n=t(e.typeParameters),r=Mb(n.to);return s_(e,r===n.to?[n]:[new dg(r,n.transformation)])}return e}case`Objects`:case`Arrays`:return e.recur(e=>{let t=e.context?.defaultValue;return t?s_(Mb(e),t):Mb(e)});case`Suspend`:return e.recur(Mb);default:return e}});function Nb(e){let t=Hb(Mb(T_(e.ast)));return(e,n)=>t(e,n?.parseOptions)}function Pb(e){let t=Nb(e);return(e,n)=>Sd(Em(t(e,n)))}function Fb(e){let t=Nb(e);return(e,n)=>wm(Rm(t(e,n),e=>Error(e.toString(),{cause:e})))}function Ib(e){return Lb(e.ast)}function Lb(e){let t=Ub(Hb(T_(e)));return e=>bd(t(e,fg))}function Rb(e){return Hb(e.ast)}function zb(e){return Wb(Rb(e))}const Bb=zb;function Vb(e){return Hb(O_(e.ast))}function Hb(e){let t=Gb(e);return(e,n)=>Bm(t(B(e),n??fg),e=>e._tag===`None`?G(new hh(e)):U(e.value))}function Ub(e){return(t,n)=>Em(e(t,n))}function Wb(e){return(t,n)=>wm(Rm(e(t,n),e=>Error(e.toString(),{cause:e})))}const Gb=rt(e=>{let t;if(!e.context&&!e.encoding&&!e.checks)return(n,r)=>(t??=e.getParser(Gb),t(n,Wm(e)?.parseOptions??r));let n=cg(e)||lg(e)||ig(e)&&e.typeParameters.length>0;return(r,i)=>{i=Wm(e)?.parseOptions??i;let a=e.encoding,o;if(a){let t=a,n=t.length;for(let e=n-1;e>=0;e--){let n=t[e],a=n.to,s=Gb(a);if(o=o?Bm(o,e=>s(e,i)):s(r,i),n.transformation._tag===`Transformation`){let e=n.transformation.decode;o=Bm(o,t=>e.run(t,i))}else o=n.transformation.decode(o,i)}o=Rm(o,t=>new lh(e,r,t))}t??=e.getParser(Gb);let s=o?Bm(o,e=>t(e,i)):t(r,i);if(e.checks){let t=e.checks;i?.errors===`all`&&n&&ti(r)&&(s=Vm(s,n=>{let a=[];return J_(t.filter(e=>e.annotations?.[`~structural`]),r.value,a,e,i),G(ki(a)?n._tag===`Composite`&&n.ast===e?new ph(e,n.actual,[...n.issues,...a]):new ph(e,r,[n,...a]):n)})),s=Bm(s,n=>{if(ti(n)){let r=n.value,a=[];if(J_(t,r,a,e,i),ki(a))return G(new ph(e,n,a))}return U(n)})}return s}}),Kb=`~effect/Schema/Schema`,qb={[Kb]:Kb,pipe(){return N(this,arguments)},annotate(e){return this.rebuild(l_(this.ast,e))},annotateKey(e){return this.rebuild(__(this.ast,e))},check(...e){return this.rebuild(d_(this.ast,e))}};function Jb(e,t){let n=Object.create(qb);return t&&Object.assign(n,t),n.ast=e,n.rebuild=e=>Jb(e,t),n.makeUnsafe=Fb(n),n.makeOption=Pb(n),n}const Yb=I_(e=>{let t=Xb(e);return t!==e&&w_(e)?v_(t):t});function Xb(e){switch(e._tag){case`Declaration`:{let t=e.annotations?.toCodecJson??e.annotations?.toCodec;if(ft(t)){let n=t(ig(e)?e.typeParameters.map(e=>Jb(E_(e))):[]),r=Yb(n.to);return s_(e,r===n.to?[n]:[new dg(r,n.transformation)])}return s_(e,[Q_])}case`Unknown`:case`ObjectKeyword`:return s_(e,[$_]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e});return e.recur(Yb);case`Union`:{let t=Zb(e.types);return t===e.types?e.recur(Yb):new Yg(t,e.mode,e.annotations,e.checks,e.encoding,e.context).recur(Yb)}case`Arrays`:case`Suspend`:return e.recur(Yb)}return e}const Zb=$b(Qb);function Qb(e){switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}}function $b(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(E_(t[e]),e);let r=[...t].sort((t,r)=>{t=E_(t),r=E_(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}const ex=Kb;function tx(){return(e,t,n)=>fx(new gg(e.map(Bg),e=>t(e.map(e=>fx(e))),n))}function nx(e,t){return tx()([],()=>(t,n)=>e(t)?U(t):G(new mh(n,B(t))),t)}const rx=`~effect/Schema/SchemaError`;var ix=class{[rx]=rx;_tag=`SchemaError`;name=`SchemaError`;issue;constructor(e){this.issue=e}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}};const ax=Ib;function ox(e){let t=Rb(e);return(e,n)=>Rm(t(e,n),e=>new ix(e))}const sx=ox,cx=zb,lx=Bb;function ux(e){let t=Vb(e);return(e,n)=>Rm(t(e,n),e=>new ix(e))}const dx=ux,fx=Jb;function px(e){return I(e,ex)&&e[ex]===ex}const mx=jb(e=>fx(y_(e.ast),{schema:e})),hx=jb(e=>mx(Fx(e))),gx=jb(e=>fx(T_(e.ast),{schema:e}));function _x(e){let t=fx(new Cg(e),{literal:e,transform(n){return t.pipe(Rx(_x(n),{decode:Fh(()=>n),encode:Fh(()=>e)}))}});return t}const vx=fx(xg),yx=fx(Sg),bx=fx(_g),xx=fx(bg),Y=fx(Tg),Sx=fx(Og),Cx=fx(kg),wx=fx(Ag);function Tx(e,t){return fx(e,{fields:t,mapFields(e,t){let n=e(this.fields);return Tx(zg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function X(e){return Tx(zg(e,void 0),e)}function Ex(e,t,n){let r=n?.keyValueCombiner?.decode||n?.keyValueCombiner?.encode?new Ig(n.keyValueCombiner.decode,n.keyValueCombiner.encode):void 0;return fx(C_(e.ast,t.ast,r),{key:e,value:t})}function Dx(e,t){return fx(e,{elements:t,mapElements(e,t){let n=e(this.elements);return Dx(Vg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Ox(e){return Dx(Vg(e),e)}const kx=jb(e=>fx(new jg(!1,[],[e.ast]),{schema:e})),Ax=jb(e=>fx(new jg(!1,[e.ast],[e.ast]),{schema:e}));function jx(e,t){return fx(e,{members:t,mapMembers(e,t){let n=e(this.members);return jx(Hg(n,this.ast.mode,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Mx(e,t){return jx(Hg(e,t?.mode??`anyOf`,void 0),e)}function Nx(e){let t=e.map(_x);return fx(Hg(t,`anyOf`,void 0),{literals:e,members:t,mapMembers(e){return Mx(e(this.members))},pick(e){return Nx(e)},transform(e){return Mx(t.map((t,n)=>t.transform(e[n])))}})}const Px=jb(e=>Mx([e,bx])),Fx=jb(e=>Mx([e,xx]));function Ix(e){return fx(new t_(()=>e().ast))}function Lx(e){return t=>fx(h_(t.ast,e),{schema:t,identifier:e})}function Rx(e,t){return n=>fx(x_(n.ast,e.ast,t?Kh(t):Xh()),{from:n,to:e})}function zx(e){return t=>fx(b_(t.ast,e),{schema:t})}function Bx(e){return _x(e).pipe(zx(()=>B(e)))}function Vx(e,t){return X({_tag:Bx(e),...t})}function Hx(e){return t=>{let n={},r={};return i(t),Object.assign(t,{cases:n,isAnyOf:t=>n=>t.includes(n[e]),guards:r,match:a});function i(t){let a=t.ast;if(ug(a)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every(px))return t.members.forEach(i);let o=Wg(a);if(o.length>0){let i=o.find(t=>t.key===e)?.literal;if(dt(i)){n[i]=t,r[i]=ax(gx(t));return}}throw new globalThis.Error(`No literal or unique symbol found`)}function a(){if(arguments.length===1){let t=arguments[0];return function(n){return t[n[e]](n)}}let t=arguments[0];return arguments[1][t[e]](t)}}}function Ux(e){let t={},n=[];for(let r of Object.keys(e))n.push(t[r]=Vx(r,e[r]));let r=Mx(n),{guards:i,isAnyOf:a,match:o}=Hx(`_tag`)(r);return fx(r.ast,{cases:t,isAnyOf:a,guards:i,match:o})}function Wx(e,t){return nx(t=>t instanceof e,t)}function Gx(){return(e,t)=>new dg(e.ast,Kh(t))}function Kx(e){return fx(tx()([e],([e])=>(t,n,r)=>$r(t)?ei(t)?dp:zm(Rb(e)(t.value,r),{onSuccess:B,onFailure:e=>new ph(n,B(t),[new uh([`value`],e)])}):G(new mh(n,B(t))),{typeConstructor:{_tag:`effect/Option`},generation:{runtime:`Schema.Option(?)`,Type:`Option.Option<?>`,importDeclaration:`import * as Option from "effect/Option"`},expected:`Option`,toCodec:([e])=>Gx()(Mx([X({_tag:_x(`Some`),value:e}),X({_tag:_x(`None`)})]),Jh({decode:e=>e._tag===`None`?z():B(e.value),encode:e=>ti(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}})),toArbitrary:([e])=>(t,n)=>t.oneof(n?.isSuspend?{maxDepth:2,depthIdentifier:`Option`}:{},t.constant(z()),e.map(B)),toEquivalence:([e])=>mi(e),toFormatter:([e])=>ni({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`})}).ast,{value:e})}function qx(e){return Px(e).pipe(Rx(Kx(gx(e)),eg()))}const Jx=X({message:Y,name:mx(Y),stack:mx(Y)}),Yx=Wx(globalThis.Error,{typeConstructor:{_tag:`Error`},generation:{runtime:`Schema.Error`,Type:`globalThis.Error`},expected:`Error`,toCodecJson:()=>Gx()(Jx,$h()),toArbitrary:()=>e=>e.string().map(e=>new globalThis.Error(e))});globalThis.Error;const Xx=new Wh(Nh(),Fh(e=>{try{return JSON.parse(JSON.stringify(e))}catch{return pn(e)}})),Zx=Mx([Jx.pipe(Rx(Yx,$h())),vx.pipe(Rx(yx.annotate({toCodecJson:()=>Gx()(vx,Xx),toArbitrary:()=>e=>e.json()}),Xx))]);function Qx(e,t){return fx(tx()([e,t],([e,t])=>{let n=kx(Ox([e,t]));return(e,t,r)=>e instanceof globalThis.Map?zm(Rb(n)([...e],r),{onSuccess:e=>new globalThis.Map(e),onFailure:n=>new ph(t,B(e),[new uh([`entries`],n)])}):G(new mh(t,B(e)))},{typeConstructor:{_tag:`ReadonlyMap`},generation:{runtime:`Schema.ReadonlyMap(?, ?)`,Type:`globalThis.ReadonlyMap<?, ?>`},expected:`ReadonlyMap`,toCodec:([e,t])=>Gx()(kx(Ox([e,t])),Jh({decode:e=>new globalThis.Map(e),encode:e=>[...e.entries()]})),toArbitrary:([e,t])=>(n,r)=>n.oneof(r?.isSuspend?{maxDepth:2,depthIdentifier:`ReadonlyMap`}:{},n.constant([]),n.array(n.tuple(e,t),r?.constraints?.array)).map(e=>new globalThis.Map(e)),toEquivalence:([e,t])=>Qt(e,t),toFormatter:([e,t])=>n=>{let r=n.size;return r===0?`ReadonlyMap(0) {}`:`ReadonlyMap(${r}) { ${globalThis.Array.from(n.entries()).sort().map(([n,r])=>`${e(n)} => ${t(r)}`).join(`, `)} }`}}).ast,{key:e,value:t})}globalThis.RegExp,globalThis.URL;function $x(e){return Y.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`,contentSchema:E_(e.ast)}).pipe(Rx(e,tg))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;const eS=nx(e=>Xm(e)&&Zm(e),{typeConstructor:{_tag:`effect/DateTime.Utc`},generation:{runtime:`Schema.DateTimeUtc`,Type:`DateTime.Utc`,importDeclaration:`import * as DateTime from "effect/DateTime"`},expected:`DateTime.Utc`,toCodecJson:()=>Gx()(Y,ng),toArbitrary:()=>(e,t)=>e.date({noInvalidDate:!0,...t?.constraints?.date}).map(e=>$m(e)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>Qm}),tS=globalThis.Symbol.for(`immer-draftable`);function nS(e,t,n,r){let i=aS(n,t,r),a=iS(t);return class extends e{constructor(...[e,t]){let r=e??{};if(t?.disableValidation)super(r,t);else{let e=n.makeUnsafe(r,t);super({...r,...e},{...t,disableValidation:!0})}}toString(){return`${t}(${pn({...this})})`}static[ex]=ex;get[a](){return a}static[tS]=!0;static identifier=t;static fields=n.fields;static get ast(){return i(this).ast}static pipe(){return N(this,arguments)}static rebuild(e){return i(this).rebuild(e)}static makeUnsafe(e,t){return new this(e,t)}static makeOption(e,t){return Pb(i(this))(e,t)}static annotate(e){return this.rebuild(l_(this.ast,e))}static annotateKey(e){return this.rebuild(__(this.ast,e))}static check(...e){return this.rebuild(d_(this.ast,e))}static extend(e){return(t,r)=>{let i={...n.fields,...t};return nS(this,e,Tx(zg(i,n.ast.checks,{identifier:e}),i),r)}}static mapFields(e,t){return n.mapFields(e,t)}}}function rS(e){return new Wh(Fh(t=>new e(t)),Nh())}function iS(e){return`~effect/Schema/Class/${e}`}function aS(e,t,n){let r;return i=>{if(r===void 0){let a=rS(i),o=fx(new gg([e.ast],()=>(e,n)=>e instanceof i||I(e,iS(t))?U(e):G(new mh(n,B(e))),{identifier:t,[Y_]:([e])=>new dg(e,a),toCodec:([e])=>new dg(e.ast,a),toArbitrary:([e])=>()=>e.map(e=>new i(e)),toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,"~sentinels":Wg(e.ast),...n}));r=e.pipe(Rx(o,a))}return r}}function oS(e){return px(e)}const sS=e=>(t,n)=>nS(vf,e,oS(t)?t:X(t),n),cS=e=>(t,n,r)=>sS(e??t)(oS(n)?n.mapFields(e=>({_tag:Bx(t),...e}),{unsafePreserveChecks:!0}):Vx(t,n),r),lS=e=>(t,n)=>{let r=nS(br,e,oS(t)?t:X(t),n);return r.prototype.name=e,r},uS=e=>(t,n,r)=>lS(e??t)(oS(n)?n.mapFields(e=>({_tag:Bx(t),...e}),{unsafePreserveChecks:!0}):Vx(t,n),r);function dS(e){return fx(Yb(e.ast))}const fS=e=>()=>{let t=dx(Ax(e));return By((e,n)=>U(K(e,e=>t(e))))},pS=e=>()=>{let t=sx(Ax(e));return By((e,n)=>U(K(e,e=>t(e))))},mS=P(2,(e,t)=>fS(t.inputSchema)().pipe(bb(e),bb(pS(t.outputSchema)()))),hS=`~effect/platform/PlatformError`;var gS=class extends Sf(`BadArgument`){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}},_S=class extends xf{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}},vS=class extends Sf(`PlatformError`){constructor(e){`cause`in e?super({reason:e,cause:e.cause}):super({reason:e})}[hS]=hS;get message(){return this.reason.message}};const yS=e=>new vS(new _S(e)),bS=e=>new vS(new gS(e)),xS={_R:F,_E:F,_A:F},SS={"~effect/Stream":xS,pipe(){return N(this,arguments)}},CS=e=>{let t=Object.create(SS);return t.channel=e,t},wS=`~effect/Sink`,TS=U([void 0]),ES={_A:F,_In:F,_L:F,_E:F,_R:F},DS={[wS]:ES,pipe(){return N(this,arguments)}},OS=e=>I(e,wS),kS=e=>AS((t,n)=>Wy(e)(t,n).pipe(K(lm({disableYield:!0})),Jf(U))),AS=e=>{let t=Object.create(DS);return t.transform=e,t},jS=e=>By((t,n)=>U(K(e.transform(t,n),fd))),MS=AS(e=>Jf(lm(e,{disableYield:!0}),()=>TS)),NS=e=>PS(sp(t=>e(t),{discard:!0})),PS=e=>AS(t=>t.pipe(K(e),lm({disableYield:!0}),Jf(()=>TS))),FS=e=>kS(xb(q(e,jS))),IS={_tag:`Empty`},LS={_tag:`Closed`},RS={_A:F,_E:F};var zS=class{"~effect/RcRef"=RS;pipe(){return N(this,arguments)}state=IS;semaphore=Fy(1);acquire;services;scope;idleTimeToLive;constructor(e,t,n,r){this.acquire=e,this.services=t,this.scope=n,this.idleTimeToLive=r}};const BS=e=>bp(t=>{let n=t.services,r=ao(n,Fd),i=new zS(e.acquire,n,r,e.idleTimeToLive?pa(e.idleTimeToLive):void 0);return Tp(Rd(r,()=>{let e=i.state._tag===`Acquired`?Hd(i.state.scope,yd):mp;return i.state=LS,e}),i)}),VS=e=>cm(t=>{switch(e.state._tag){case`Closed`:return am;case`Acquired`:return e.state.refCount++,e.state.fiber?Tp(gv(e.state.fiber),e.state):U(e.state);case`Empty`:{let n=Id();return e.semaphore.withPermits(1)(t(qp(e.acquire,no(e.services,Fd,n))).pipe(q(t=>{let r={_tag:`Acquired`,value:t,scope:n,fiber:void 0,refCount:1,invalidated:!1};return e.state=r,r})))}}}),HS=Om(function*(e){let t=e,n=yield*VS(t),r=yield*Zp,i=t.idleTimeToLive!==void 0&&xa(t.idleTimeToLive);return yield*Rd(r,()=>(n.refCount--,n.refCount>0?mp:t.idleTimeToLive===void 0?(t.state=IS,Hd(n.scope,yd)):n.invalidated?Hd(n.scope,yd):(i&&(n.fiber=zp(t.idleTimeToLive).pipe(K(()=>t.state._tag===`Acquired`&&t.state.refCount===0?(t.state=IS,Hd(n.scope,yd)):mp),nm(W(()=>{n.fiber=void 0})),_m(t.services),yv(t.scope))),mp))),n.value}),US=BS,WS=HS,GS=e=>I(e,`~effect/Stream`),KS=CS,qS=e=>KS(Hy(e)),JS=(e,t)=>KS(By((n,r)=>K(Ab(e.channel,r),e=>t(e,r)))),YS=e=>e.channel,XS=(e,t)=>KS(Ky(e,t)),ZS=KS(Jy),QS=e=>KS(qy(()=>e().channel)),$S=e=>KS($y(e)),eC=e=>KS(tb(e)),tC=e=>KS(xb(q(e,YS))),nC=P(2,(e,t)=>QS(()=>{let n=0;return KS(nb(e.channel,Hi(e=>t(e,n++))))})),rC=P(e=>GS(e[0]),(e,t,n)=>e.channel.pipe(lb,ob(t,n),nb(Vi),KS)),iC=P(e=>GS(e[0]),(e,t,n)=>rC(e,e=>Tp(t(e),e),n)),aC=P(e=>GS(e[0])&&GS(e[1]),(e,t,n)=>KS(vb(YS(e),YS(t),n))),oC=P(2,(e,t)=>e.channel.pipe(pb(t),KS)),sC=P(2,(e,t)=>KS(gb(e.channel,t))),cC=e=>KS(_b(e.channel)),lC=P(e=>GS(e[0]),(e,t,n,r)=>KS(db(e.channel,t,(e,t)=>{let r=Bi();for(let i=0;i<t.length;i++){let[a,o]=n(e,t[i]);e=a,r.push(...o)}return[e,ki(r)?Vi(r):uC]},r?.onHalt?{onHalt(e){let t=r.onHalt(e);return Ai(t)?Vi(t):uC}}:void 0))),uC=Bi(),dC=P(2,(e,t)=>JS(e,(e,n)=>W(()=>{let r,i,a=pp(()=>{if(i!==void 0){let e=i;return i=void 0,U(e)}return e}).pipe(Dp(e=>(r=vd(e),fd()))),o=q(pp(()=>t.transform(a,n)),([e,t])=>(i=t,Vi(e)));return pp(()=>r||o)}))),fC=P(2,(e,t)=>KS(bb(e.channel,t))),pC=P(e=>GS(e[0]),(e,t)=>QS(()=>{let n=new TextDecoder(t?.encoding);return nC(e,e=>n.decode(e,{stream:!0}))})),mC=e=>e.channel.pipe(bb(yb()),KS),hC=P(2,(e,t)=>KS(Cb(e.channel,e=>t(e[0])))),gC=P(2,(e,t)=>KS(wb(e.channel,t))),_C=P(2,(e,t)=>$p(n=>Ab(e.channel,n).pipe(K(e=>t.transform(e,n)),q(([e])=>e)))),vC=e=>Ob(e.channel,()=>[],(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n]);return e}),yC=e=>q(Db(e.channel),di(Ii)),bC=P(2,(e,t)=>Eb(e.channel,e=>{let n=0;return cp({while:()=>n<e.length,body:()=>t(e[n++]),step:et})})),xC=P(2,(e,t)=>Eb(e.channel,t)),SC=e=>kb(e.channel),CC=e=>Ob(e.channel,()=>``,(e,t)=>e+t.join(``)),wC=P(e=>GS(e[0]),(e,t,n)=>{let r,i,a=bv(!1);return new ReadableStream({start(n){i=gm(qp(xC(e,e=>a.whenOpen(W(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(rd(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return bm(Ep(gv(i)))}},n?.strategy)}),TC=P(e=>GS(e[0]),(e,t)=>wC(e,$a(),t)),EC=`~effect/platform/FileSystem`,DC=e=>typeof e==`bigint`?e:BigInt(e),OC=BigInt(1024);OC*OC*OC*OC*OC;const kC=Ga(`effect/platform/FileSystem`),AC=e=>kC.of({...e,[EC]:EC,exists:t=>tt(e.access(t),Tp(!0),J(`PlatformError`,e=>e.reason._tag===`NotFound`?U(!1):G(e))),readFileString:(t,n)=>K(e.readFile(t),e=>yp({try:()=>new TextDecoder(n).decode(e),catch:e=>bS({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})})),stream:Om(function*(t,n){let r=yield*e.open(t,{flag:`r`});n?.offset&&(yield*r.seek(n.offset,`start`));let i=n?.bytesToRead===void 0?void 0:DC(n.bytesToRead),a=BigInt(0),o=DC(n?.chunkSize??64*1024),s=r.readAlloc(o);return qS(U(K(pp(()=>i!==void 0&&i<=a?fd():i!==void 0&&i-a<o?r.readAlloc(i-a):s),ni({onNone:()=>fd(),onSome:e=>(a+=BigInt(e.length),U(Vi(e)))}))))},tC),sink:(t,n)=>tt(e.open(t,{flag:`w`,...n}),q(e=>NS(t=>e.writeAll(t))),FS),writeFileString:(t,n,r)=>K(yp({try:()=>new TextEncoder().encode(n),catch:e=>bS({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),jC=`~effect/platform/FileSystem/File`,MC=ev();var NC=class extends Ga()(`effect/platform/FileSystem/WatchBackend`){};const PC=`~effect/platform/Path`,FC=Ga(`effect/Path`);function IC(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function LC(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function RC(e){if(e.protocol!==`file:`)return G(new gS({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return G(new gS({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return G(new gS({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return U(decodeURIComponent(t))}const zC=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=IC(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function BC(e){let t=new URL(`file://`),n=zC(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=KC(n),U(t)}const VC=/%/g,HC=/\\/g,UC=/\n/g,WC=/\r/g,GC=/\t/g;function KC(e){return e.includes(`%`)&&(e=e.replace(VC,`%25`)),e.includes(`\\`)&&(e=e.replace(HC,`%5C`)),e.includes(`
21
- `)&&(e=e.replace(UC,`%0A`)),e.includes(`\r`)&&(e=e.replace(WC,`%0D`)),e.includes(` `)&&(e=e.replace(GC,`%09`)),e}const qC=FC.of({[PC]:PC,resolve:zC,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=IC(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:qC.normalize(e)},relative(e,t){if(e===t||(e=qC.resolve(e),t=qC.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return LC(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:RC,toFileUrl:BC,toNamespacedPath:F}),JC=`~effect/FiberMap`,YC=e=>I(e,JC),XC={[JC]:JC,[Symbol.iterator](){return this.state._tag===`Closed`?Si():this.state.backing[Symbol.iterator]()},...zn,toJSON(){return{_id:`FiberMap`,state:this.state}}},ZC=(e,t)=>{let n=Object.create(XC);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},QC=()=>em(W(()=>ZC(rv(),wd())),e=>pp(()=>{let t=e.state;return t._tag===`Closed`?mp:(e.state={_tag:`Closed`},_v(sv(t.backing)).pipe(Pd(e.deferred)))})),$C=Ba(Ha(sd,Va(-1))),ew=P(e=>YC(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(-1);return}let i=iv(e.state.backing,t);if(i._tag===`Some`){if(r?.onlyIfMissing===!0){n.interruptUnsafe(-1);return}else if(i.value===n)return;i.value.interruptUnsafe(-1)}uv(e.state.backing,t,n),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=iv(e.state.backing,t);ti(a)&&n===a.value&&fv(e.state.backing,t),xd(i)&&(r?.propagateInterruption===!0?!$C(i.cause):!nd(i.cause))&&Nd(e.deferred,i)})}),tw=P(2,(e,t)=>e.state._tag===`Closed`?!1:lv(e.state.backing,t)),nw=function(){let e;return()=>(e===void 0&&(e=gm(am)),e)}(),rw=function(){let e=arguments[0];if(ap(arguments[2]))return iw(e,arguments[1],arguments[2],arguments[3]);let t=arguments[1],n=arguments[2];return r=>iw(e,t,r,n)},iw=(e,t,n,r)=>bp(i=>{if(e.state._tag===`Closed`)return am;if(r?.onlyIfMissing===!0&&tw(e,t))return W(nw);let a=_m(i.services)(n);return ew(e,t,a,r),U(a)}),aw=`~effect/FiberSet`,ow=e=>I(e,aw),sw={[aw]:aw,[Symbol.iterator](){return this.state._tag===`Closed`?Si():this.state.backing[Symbol.iterator]()},...zn,toJSON(){return{_id:`FiberMap`,state:this.state}}},cw=(e,t)=>{let n=Object.create(sw);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},lw=()=>em(W(()=>cw(new Set,wd())),e=>pp(()=>{let t=e.state;if(t._tag===`Closed`)return mp;e.state={_tag:`Closed`};let n=t.backing;return _v(n).pipe(Pd(e.deferred))})),uw=Ba(Ha(sd,Va(-1))),dw=P(e=>ow(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(-1);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),xd(r)&&(n?.propagateInterruption===!0?!uw(r.cause):!nd(r.cause))&&Nd(e.deferred,r))})}),fw=function(){let e;return()=>(e===void 0&&(e=gm(am)),e)}(),pw=e=>()=>q(Wp(),t=>{let n=_m(t);return(t,r)=>{if(e.state._tag===`Closed`)return fw();let i=n(t,r);return dw(e,i),i}}),mw=e=>Ed(e.deferred),hw=e=>I(e,`~effect/Logger`),gw=Bu,_w=/^[^\s"=]*$/,vw=e=>`#${e}`,yw=Wu(((e,t)=>({cause:n,date:r,fiber:i,logLevel:a,message:o})=>{let s=t=>t.match(_w)?t:e(t),c=(e,t)=>`${Gu(e)}=${s(t)}`,l=(e,t)=>` `+c(e,t),u=c(`timestamp`,r.toISOString());u+=l(`level`,a),u+=l(`fiber`,vw(i.id));let d=Ti(o);for(let e=0;e<d.length;e++)u+=l(`message`,pn(d[e],{space:t}));n.reasons.length>0&&(u+=l(`cause`,us(n)));let f=r.getTime(),p=i.getRef(Ho);for(let e of p)u+=` `+Ku(e,f);let m=i.getRef(zo);for(let[e,n]of Object.entries(m))u+=l(e,pn(n,{space:t}));return u})(JSON.stringify,0)),bw=P(2,(e,t)=>H(Cl,n=>{let r=[],i=ks(()=>{if(r.length===0)return Fs;let e=r;return r=[],t.flush(e)});return Hl(a=>a(ju(t.window).pipe(tc(i),Ic)).pipe(Xl,H(e=>_l(n,()=>Cs(e))),tc(Ol(()=>i)),$s(Wu(t=>{r.push(e.log(t))}))))})),xw=(e,t)=>rf(gw,R(Gs(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(Bu):[]);for(let t of e)r.add(Wn(t)?yield*t:t);return r}))),Sw=P(e=>hw(e[0]),(e,t,n)=>Ws(function*(){let r=yield*(yield*kC).open(t,{flag:`a+`,...n}),i=new TextEncoder;return yield*bw(e,{window:n?.batchWindow??1e3,flush:e=>Xc(r.write(i.encode(e.join(`
22
- `)+`
23
- `)))})})),Cw=`~effect/ManagedRuntime`,ww=(e,t)=>{let n=t?.memoMap??Zd(),r=Id(),i,a=bp(t=>(i||=yv(gm(Cp($d(e,n,r),e=>W(()=>{o.cachedServices=e})),{scheduler:t.currentScheduler}),r),xp(pv(i)))),o={[Cw]:Cw,memoMap:n,scope:r,servicesEffect:a,cachedServices:void 0,services(){return o.cachedServices===void 0?bm(o.servicesEffect):Promise.resolve(o.cachedServices)},dispose(){return bm(o.disposeEffect)},disposeEffect:pp(()=>(o.servicesEffect=vp(`ManagedRuntime disposed`),o.cachedServices=void 0,Hd(o.scope,yd))),runFork(e,t){return o.cachedServices===void 0?gm(Tw(o,e),t):_m(o.cachedServices)(e,t)},runCallback(e,t){return o.cachedServices===void 0?ym(Tw(o,e),t):vm(o.cachedServices)(e,t)},runSyncExit(e){return o.cachedServices===void 0?Em(Tw(o,e)):Dm(o.cachedServices)(e)},runSync(e){return o.cachedServices===void 0?wm(Tw(o,e)):Tm(o.cachedServices)(e)},runPromiseExit(e,t){return o.cachedServices===void 0?Sm(Tw(o,e),t):Cm(o.cachedServices)(e,t)},runPromise(e,t){return o.cachedServices===void 0?bm(Tw(o,e),t):xm(o.cachedServices)(e,t)}};return o};function Tw(e,t){return K(e.servicesEffect,e=>qp(t,e))}const Ew=`~effect/match/Match/Matcher`,Dw={[Ew]:{_input:F,_filters:F,_remaining:F,_result:F,_return:F},_tag:`TypeMatcher`,add(e){return Ow([...this.cases,e])},pipe(){return N(this,arguments)}};function Ow(e){let t=Object.create(Dw);return t.cases=e,t}const kw={[Ew]:{_input:F,_filters:F,_result:F,_return:F},_tag:`ValueMatcher`,add(e){return yi(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?Aw(this.provided,hi(e.evaluate(this.provided))):this},pipe(){return N(this,arguments)}};function Aw(e,t){let n=Object.create(kw);return n.provided=e,n.value=t,n}const jw=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),Mw=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(Mw),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,Mw(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},Nw=e=>Aw(e,gi(e)),Pw=(e,t)=>n=>n.add(jw(Mw(e),t)),Fw=e=>t=>{let n=jw(n=>n!=null&&n[e]in t,n=>t[n[e]](n));return e=>e.add(n)},Iw=(e=>t=>{let n=Fw(e)(t);return e=>zw(n(e))})(`_tag`),Lw=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return e=>t._tag===`When`&&t.guard(e)===!0||t._tag===`Not`&&t.guard(e)===!1?hi(t.evaluate(e)):gi(e)}return n=>{for(let r=0;r<t;r++){let t=e.cases[r];if(t._tag===`When`&&t.guard(n)===!0||t._tag===`Not`&&t.guard(n)===!1)return hi(t.evaluate(n))}return gi(n)}},Rw=`effect/match/Match/exhaustive: absurd`,zw=e=>{let t=Lw(e);if(_i(t)){if(yi(t))return t.success;throw Error(Rw)}return e=>{let n=t(e);if(yi(n))return n.success;throw Error(Rw)}},Bw=Nw,Vw=Pw,Hw=Iw,Uw=zw;var Ww=class extends Ga()(`effect/reactivity/Reactivity`){};const Gw=W(()=>{let e=new Map,t=t=>{Zw(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>Gp(n=>{let r=n.mapUnsafe.get(Kw.key);return r?Zw(e,e=>{r.add(e)}):t(e),mp}),r=(e,t)=>Cp(t,n(e)),i=(t,n)=>{let r=[];return Zw(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},a=(e,t)=>gp(function*(){let n=yield*Wp(),r=ao(n,Fd),a=yield*cy(),o=nt(_m(n),yv(r)),s=!1,c=!1,l=e=>{e._tag===`Failure`?my(a,e.cause):fy(a,e.value),c?(c=!1,o(t).addObserver(l)):s=!1};function u(){if(s){c=!0;return}s=!0,o(t).addObserver(l)}return yield*zd(r,W(i(e,u))),u(),a});return Ww.of({mutation:r,query:a,stream:(e,t)=>a(e,t).pipe(q($S),tC),invalidateUnsafe:t,invalidate:n,registerUnsafe:i,withBatch:t=>pp(()=>{let n=new Set;return t.pipe(Xp(Kw,n),im(t=>W(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})});var Kw=class extends Ga()(`effect/reactivity/Reactivity/PendingInvalidation`){};const qw=P(2,(e,t)=>Ww.use(n=>n.mutation(t,e))),Jw=e=>Ww.use(t=>t.invalidate(e)),Yw=rf(Ww)(Gw);function Xw(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return wt(e)}}const Zw=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Xw(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Xw(r[e])}`)}},Qw=`~effect/Stdio`,$w=Ga(Qw),eT=e=>({[Qw]:Qw,...e}),tT=e=>I(e,`~effect/SubscriptionRef`);({...zn});const nT=e=>eC(e.pubsub),rT=e=>W(()=>e.value),iT=(e,t)=>{e.value=t,Bv(e.pubsub,t)},aT=P(2,(e,t)=>e.semaphore.withPermit(W(()=>iT(e,t)))),oT=`~effect/platform/Terminal`;lS(`QuitError`)({_tag:Bx(`QuitError`)});const sT=Ga(`effect/platform/Terminal`),cT=e=>sT.of({...e,[oT]:oT}),lT=`0.0.3`,uT=process.env.SUPPORT_CLICK===`true`||process.env.SUPPORT_CLICK===`1`,dT=()=>{},fT=p({subscribeClick:()=>dT}),pT=/\x1b\[<(\d+);(\d+);(\d+)([Mm])|\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\d+;\d+R|\[\?[\d;]+[a-z]/g,mT=({children:e})=>{if(!uT)return x(b,{children:e});let t=v(new Set),n=v(!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(pT,(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=m(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]);return x(fT.Provider,{value:{subscribeClick:r},children:e})},hT=()=>{let e=f(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 h(fT)},gT=/\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\?[\d;]+[a-z]|\[\d+;\d+R/g,_T=e=>uT?e.replace(gT,``):e,vT=e=>e&&e>0?e:80,yT=e=>e&&e>0?e:24,bT=()=>{let{stdout:e}=s(),[t,n]=y([vT(e.columns),yT(e.rows)]),r=v(!1);return r.current||(r.current=!0,e.on(`resize`,()=>n([vT(e.columns),yT(e.rows)]))),t},xT={primary:`white`,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`},ST={TEXT:xT.text,DIM:xT.textMuted,GREEN:xT.success,PRIMARY:xT.primary,SELECTION:xT.accent,RED:xT.error,BORDER:xT.border,DIVIDER:xT.borderSubtle,YELLOW:xT.warning,PURPLE:xT.secondary,CYAN:xT.info},CT=()=>ST,wT=e=>{let t=f(21);if(t[0]!==`a8af523f6a47fe2809894f0ccc449956b3bd8892fa926c9ce35b235545503e82`){for(let e=0;e<21;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`a8af523f6a47fe2809894f0ccc449956b3bd8892fa926c9ce35b235545503e82`}let{color:r,children:a,marginTop:o,marginBottom:s,paddingX:c,ref:l}=e,u=c===void 0?1:c,[d]=bT(),p;t[1]===d?p=t[2]:(p=`─`.repeat(d),t[1]=d,t[2]=p);let m;t[3]!==r||t[4]!==p?(m=x(i,{color:r,children:p}),t[3]=r,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==a||t[7]!==u?(h=x(n,{flexDirection:`column`,paddingX:u,children:a}),t[6]=a,t[7]=u,t[8]=h):h=t[8];let g;t[9]===d?g=t[10]:(g=`─`.repeat(d),t[9]=d,t[10]=g);let _;t[11]!==r||t[12]!==g?(_=x(i,{color:r,children:g}),t[11]=r,t[12]=g,t[13]=_):_=t[13];let v;return t[14]!==s||t[15]!==o||t[16]!==l||t[17]!==m||t[18]!==h||t[19]!==_?(v=S(n,{flexDirection:`column`,width:`100%`,marginTop:o,marginBottom:s,ref:l,children:[m,h,_]}),t[14]=s,t[15]=o,t[16]=l,t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v},TT=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}},ET=({onClick:e,children:t,fullWidth:r=!0})=>{let{subscribeClick:i}=hT(),a=v(e);return a.current=e,x(n,{ref:m(e=>{if(e)return i((t,n)=>{if(n!==`press`||!e.yogaNode)return;let r=TT(e),i=e.yogaNode.getComputedLayout(),o=t.x<r.left||t.x>=r.left+i.width,s=t.y<r.top||t.y>=r.top+i.height;!o&&!s&&a.current?.()})},[i]),width:r?`100%`:void 0,children:t})},DT=e=>/\w/.test(e),OT=(e,t)=>{let n=t-1;for(;n>0&&!DT(e[n]);)n--;for(;n>0&&DT(e[n-1]);)n--;return n},kT=(e,t)=>{let n=t;for(;n<e.length&&DT(e[n]);)n++;for(;n<e.length&&!DT(e[n]);)n++;return n},AT=(e,t)=>{let n=e.split(`
24
- `),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}},jT=(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)},MT=({value:e,placeholder:t=``,focus:n=!0,mask:r,highlightPastedText:a=!1,showCursor:s=!0,multiline:c=!1,onChange:l,onSubmit:u,onUpArrowAtTop:d,onDownArrowAtBottom:f})=>{let[p,m]=y({cursorOffset:(e||``).length,cursorWidth:0}),{cursorOffset:h,cursorWidth:g}=p,_=v({originalValue:e,focus:n,showCursor:s});(_.current.originalValue!==e||_.current.focus!==n||_.current.showCursor!==s)&&(_.current={originalValue:e,focus:n,showCursor:s},m(t=>{if(!n||!s)return t;let r=e||``;return t.cursorOffset>r.length-1?{cursorOffset:r.length,cursorWidth:0}:t}));let b=a?g:0,S=r?r.repeat(e.length):e,C=S,T=t?w.gray(t):void 0;if(s&&n){T=t.length>0?w.inverse(t[0])+w.gray(t.slice(1)):w.inverse(` `),C=S.length>0?``:w.inverse(` `);let e=0;for(let t of S){let n=e>=h-b&&e<=h;n&&t===`
25
- `?C+=w.inverse(` `)+`
26
- `:C+=n?w.inverse(t):t,e++}S.length>0&&h===S.length&&(C+=w.inverse(` `))}return o((t,n)=>{if(!c&&(n.upArrow||n.downArrow)||n.ctrl&&t===`c`||n.tab||n.shift&&n.tab)return;let r=h,i=e,a=0,o=!1;if(c&&n.upArrow&&s){let{lineIndex:t,column:n,lines:i}=AT(e,h);t>0?r=jT(i,t-1,n):d?.(),o=!0}else if(c&&n.downArrow&&s){let{lineIndex:t,column:n,lines:i}=AT(e,h);t<i.length-1?r=jT(i,t+1,n):f?.(),o=!0}else if(n.ctrl&&t===`a`&&s)r=0,o=!0;else if(n.ctrl&&t===`e`&&s)r=e.length,o=!0;else if(n.ctrl&&t===`f`&&s)r=h+1,o=!0;else if(n.ctrl&&t===`b`&&s)r=h-1,o=!0;else if(n.ctrl&&t===`k`)i=e.slice(0,h),o=!0;else if(n.ctrl&&t===`u`)h>0&&(i=e.slice(h),r=0),o=!0;else if(n.ctrl&&t===`w`){if(h>0){let t=OT(e,h);i=e.slice(0,t)+e.slice(h),r=t}o=!0}else if(n.ctrl&&t===`d`)h<e.length&&(i=e.slice(0,h)+e.slice(h+1)),o=!0;else if(n.ctrl&&t===`t`)h>0&&h<e.length&&(i=e.slice(0,h-1)+e[h]+e[h-1]+e.slice(h+1),r=h+1),o=!0;else if(n.meta&&t===`b`&&s)r=OT(e,h),o=!0;else if(n.meta&&t===`f`&&s)r=kT(e,h),o=!0;else if(n.meta&&(n.backspace||n.delete)){if(h>0){let t=OT(e,h);i=e.slice(0,t)+e.slice(h),r=t}o=!0}else if(n.meta)return;if(!o)if(n.return)if(c&&n.shift)i=e.slice(0,h)+`
27
- `+e.slice(h),r++;else{u&&u(e);return}else n.leftArrow?s&&r--:n.rightArrow?s&&r++:n.backspace||n.delete?h>0&&(i=e.slice(0,h-1)+e.slice(h,e.length),r--):(i=e.slice(0,h)+t+e.slice(h,e.length),r+=t.length,t.length>1&&(a=t.length));r<0&&(r=0),r>i.length&&(r=i.length),m({cursorOffset:r,cursorWidth:a}),i!==e&&l(i)},{isActive:n}),x(i,{children:t?S.length>0?C:T:C})},NT=e=>{let t=f(12);if(t[0]!==`c6c3ef187baf87ef1618d6c08f65ced3e6d8e16cb26b5f85a56cd10f01788927`){for(let e=0;e<12;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`c6c3ef187baf87ef1618d6c08f65ced3e6d8e16cb26b5f85a56cd10f01788927`}let{isSearching:r,query:a,onChange:o}=e,s=CT();if(r){let e;t[1]===s.DIM?e=t[2]:(e=x(i,{color:s.DIM,children:`/`}),t[1]=s.DIM,t[2]=e);let r;t[3]!==o||t[4]!==a?(r=x(MT,{focus:!0,value:a,onChange:o}),t[3]=o,t[4]=a,t[5]=r):r=t[5];let c;return t[6]!==e||t[7]!==r?(c=S(n,{marginTop:1,children:[e,r]}),t[6]=e,t[7]=r,t[8]=c):c=t[8],c}if(a){let e;return t[9]!==s.DIM||t[10]!==a?(e=x(n,{marginTop:1,children:S(i,{color:s.DIM,children:[`/`,a]})}),t[9]=s.DIM,t[10]=a,t[11]=e):e=t[11],e}return null},PT=Nx([`pending`,`in_progress`,`completed`,`failed`]),FT=Nx([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);Nx([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const IT=Mx([X({type:_x(`text`),text:Y}),X({type:_x(`image`),data:Y,mimeType:Y}),X({type:_x(`resource_link`),uri:Y}),X({type:_x(`resource`),uri:Y})]),LT=Mx([X({type:_x(`content`),content:IT}),X({type:_x(`diff`),path:Y,oldText:hx(Px(Y)),newText:hx(Px(Y))}),X({type:_x(`terminal`),terminalId:Y})]),RT=X({path:Y,lineNumber:hx(Px(Sx))});var zT=class extends sS(`AcpAgentMessageChunk`)({sessionUpdate:_x(`agent_message_chunk`),content:IT,messageId:hx(Px(Y))}){},BT=class extends sS(`AcpAgentThoughtChunk`)({sessionUpdate:_x(`agent_thought_chunk`),content:IT,messageId:hx(Px(Y))}){},VT=class extends sS(`AcpUserMessageChunk`)({sessionUpdate:_x(`user_message_chunk`),content:IT,messageId:hx(Px(Y))}){},HT=class extends sS(`AcpToolCall`)({sessionUpdate:_x(`tool_call`),toolCallId:Y,title:Y,kind:hx(FT),status:hx(PT),content:hx(kx(LT)),locations:hx(kx(RT)),rawInput:hx(yx),rawOutput:hx(yx)}){},UT=class extends sS(`AcpToolCallUpdate`)({sessionUpdate:_x(`tool_call_update`),toolCallId:Y,title:hx(Px(Y)),kind:hx(Px(FT)),status:hx(Px(PT)),content:hx(Px(kx(LT))),locations:hx(Px(kx(RT))),rawInput:hx(yx),rawOutput:hx(yx)}){};const WT=Nx([`pending`,`in_progress`,`completed`]),GT=Nx([`high`,`medium`,`low`]),KT=Mx([zT,BT,VT,HT,UT,class extends sS(`AcpPlanUpdate`)({sessionUpdate:_x(`plan`),entries:kx(X({content:Y,priority:GT,status:WT}))}){},class extends sS(`AcpAvailableCommandsUpdate`)({sessionUpdate:_x(`available_commands_update`)}){},class extends sS(`AcpCurrentModeUpdate`)({sessionUpdate:_x(`current_mode_update`)}){},class extends sS(`AcpConfigOptionUpdate`)({sessionUpdate:_x(`config_option_update`)}){},class extends sS(`AcpSessionInfoUpdate`)({sessionUpdate:_x(`session_info_update`)}){},class extends sS(`AcpUsageUpdate`)({sessionUpdate:_x(`usage_update`)}){}]);X({inputTokens:Sx,outputTokens:Sx,cachedReadTokens:hx(Px(Sx)),cachedWriteTokens:hx(Px(Sx)),thoughtTokens:hx(Px(Sx))}),Nx([`claude`,`codex`,`cursor`]);var qT=class extends sS(`@ami/FileStat`)({relativePath:Y,added:Sx,removed:Sx}){},JT=class extends sS(`@supervisor/GitState`)({isGitRepo:Cx,currentBranch:Y,mainBranch:Fx(Y),isOnMain:Cx,hasChangesFromMain:Cx,hasUnstagedChanges:Cx,hasBranchCommits:Cx,branchCommitCount:Sx,fileStats:kx(qT),fingerprint:Fx(Y),savedFingerprint:Fx(Y)}){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 YT=Y.pipe(Lx(`StepId`)),XT=Y.pipe(Lx(`PlanId`)),ZT=Ux({WorkingTree:{},Branch:{mainBranch:Y},Changes:{mainBranch:Y},Commit:{hash:Y}}),QT=e=>Bw(e).pipe(Hw({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),$T=X({number:Sx,headRefName:Y,author:X({login:Y}),state:Y,updatedAt:Y}),eE=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var tE=class extends sS(`@supervisor/RemoteBranch`)({name:Y,author:Y,prNumber:Px(Sx),prStatus:Px(Nx([`open`,`draft`,`merged`])),updatedAt:Px(Y)}){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 nE=Nx([`pending`,`active`,`passed`,`failed`]);var rE=class e extends sS(`@supervisor/TestPlanStep`)({id:YT,title:Y,instruction:Y,expectedOutcome:Y,routeHint:qx(Y),status:nE,summary:qx(Y),startedAt:qx(eS),endedAt:qx(eS)}){update(t){return new e({...this,...t})}};const iE=Y.pipe(Lx(`DraftId`));var aE=class e extends sS(`@supervisor/TestPlanDraft`)({id:iE,changesFor:ZT,currentBranch:Y,diffPreview:Y,fileStats:kx(qT),instruction:Y,baseUrl:Kx(Y),isHeadless:Cx,requiresCookies:Cx}){update(t){return new e({...this,...t})}},oE=class e extends aE.extend(`@supervisor/TestPlan`)({id:XT,title:Y,rationale:Y,steps:kx(rE)}){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 resetForRerun(){return new e({...this,steps:this.steps.map(e=>new rE({...e,status:`pending`,summary:z(),startedAt:z(),endedAt:z()}))})}},sE=class extends cS()(`RunStarted`,{plan:oE}){get id(){return`run-started-${this.plan.id}`}},cE=class extends cS()(`StepStarted`,{stepId:YT,title:Y}){get id(){return`step-started-${this.stepId}`}},lE=class extends cS()(`StepCompleted`,{stepId:YT,summary:Y}){get id(){return`step-completed-${this.stepId}`}},uE=class extends cS()(`StepFailed`,{stepId:YT,message:Y}){get id(){return`step-failed-${this.stepId}`}},dE=class extends cS()(`ToolCall`,{toolName:Y,input:yx}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return yt(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},fE=class extends cS()(`ToolResult`,{toolName:Y,result:Y,isError:Cx}){get id(){return`tool-result-${this.toolName}-${this.result}`}},pE=class extends cS()(`AgentThinking`,{text:Y}){get id(){return`agent-thinking-${this.text}`}},mE=class extends cS()(`AgentText`,{text:Y}){get id(){return`agent-text-${this.text}`}},hE=class extends cS()(`RunFinished`,{status:Nx([`passed`,`failed`]),summary:Y}){get id(){return`run-finished-${this.status}`}};const gE=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)}},_E=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 cE({stepId:YT.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new lE({stepId:YT.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new uE({stepId:YT.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new hE({status:a===`failed`?`failed`:`passed`,summary:o})},vE=Mx([sE,cE,lE,uE,dE,fE,pE,mE,hE]),yE=Mx([sE,cE,lE,uE,dE,fE,pE,hE,class extends cS()(`RunCompleted`,{report:Ix(()=>kE)}){}]);var bE=class extends sS(`@supervisor/Update`)({content:yE,receivedAt:eS}){},xE=class extends sS(`@supervisor/PullRequest`)({number:Sx,url:Y,title:Y,headRefName:Y}){};const SE=Ux({WorkingTree:{},Branch:{branch:tE},PullRequest:{branch:tE},Commit:{hash:Y,shortHash:Y,subject:Y}}),CE=e=>Bw(e).pipe(Hw({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),wE=e=>Bw(e).pipe(Hw({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),TE=e=>Bw(e).pipe(Hw({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),EE=e=>Bw(e).pipe(Hw({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),DE=e=>Bw(e).pipe(Hw({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));Ux({Branch:{branchName:Y}});var OE=class e extends oE.extend(`@supervisor/ExecutedTestPlan`)({events:kx(vE)}){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 pE({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new pE({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 mE({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new mE({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new dE({toolName:t.title,input:JSON.stringify(t.rawInput??{})})]})}return t.sessionUpdate===`tool_call_update`&&(t.status===`completed`||t.status===`failed`)?new e({...this,events:[...this.events,new fE({toolName:t.title??``,result:gE(t.rawOutput),isError:t.status===`failed`})]}):this}finalizeTextBlock(){let t=this.events.at(-1);if(t?._tag!==`AgentText`)return this;let n=t.text.split(`
28
- `).map(_E).filter(mt);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:B(th())}):e)}):new e({...this,steps:[...this.steps,new rE({id:t.stepId,title:t.title,instruction:t.title,expectedOutcome:``,routeHint:z(),status:`active`,summary:z(),startedAt:B(th()),endedAt:z()})]}):t._tag===`StepCompleted`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`passed`,summary:B(t.summary),expectedOutcome:t.summary,endedAt:B(th())}):e)}):t._tag===`StepFailed`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`failed`,summary:B(t.message),expectedOutcome:t.message,endedAt:B(th())}):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}},kE=class extends OE.extend(`@supervisor/TestReport`)({summary:Y,screenshotPaths:kx(Y),pullRequest:Kx(Ix(()=>xE))}){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}`)}return r.join(`
29
- `)}};const AE={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`},jE={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`},ME=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),terminal:O.boolean().optional().default(!1)}),NE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),label:O.string().nullish(),name:O.string(),optional:O.boolean().optional().default(!1),secret:O.boolean().optional().default(!0)}),PE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string().nullish(),id:O.string(),name:O.string()}),FE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string().nullish(),id:O.string(),link:O.string().nullish(),name:O.string(),vars:O.array(NE)}),IE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),args:O.array(O.string()).optional(),description:O.string().nullish(),env:O.record(O.string(),O.string()).optional(),id:O.string(),name:O.string()}),LE=O.union([FE.and(O.object({type:O.literal(`env_var`)})),IE.and(O.object({type:O.literal(`terminal`)})),PE]),RE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),methodId:O.string()}),zE=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),BE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),blob:O.string(),mimeType:O.string().nullish(),uri:O.string()}),VE=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),HE=O.object({amount:O.number(),currency:O.string()}),UE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),terminalId:O.string()}),WE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),newText:O.string(),oldText:O.string().nullish(),path:O.string()}),GE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),name:O.string(),value:O.string()}),KE=O.union([O.literal(-32700),O.literal(-32600),O.literal(-32601),O.literal(-32602),O.literal(-32603),O.literal(-32800),O.literal(-32e3),O.literal(-32002),O.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),qE=O.object({code:KE,data:O.unknown().optional(),message:O.string()}),JE=O.unknown(),YE=O.unknown(),XE=O.unknown(),ZE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),readTextFile:O.boolean().optional().default(!1),writeTextFile:O.boolean().optional().default(!1)}),QE=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),auth:ME.optional().default({terminal:!1}),fs:ZE.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:O.boolean().optional().default(!1)}),$E=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),name:O.string(),value:O.string()}),eD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),name:O.string(),title:O.string().nullish(),version:O.string()}),tD=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),nD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cursor:O.string().nullish(),cwd:O.string().nullish()}),rD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),http:O.boolean().optional().default(!1),sse:O.boolean().optional().default(!1)}),iD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),headers:O.array($E),name:O.string(),url:O.string()}),aD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),headers:O.array($E),name:O.string(),url:O.string()}),oD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),args:O.array(O.string()),command:O.string(),env:O.array(GE),name:O.string()}),sD=O.union([iD.and(O.object({type:O.literal(`http`)})),aD.and(O.object({type:O.literal(`sse`)})),oD]),cD=O.string(),lD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string().nullish(),modelId:cD,name:O.string()}),uD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cwd:O.string(),mcpServers:O.array(sD)}),dD=O.string(),fD=O.union([O.literal(`allow_once`),O.literal(`allow_always`),O.literal(`reject_once`),O.literal(`reject_always`)]),pD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),kind:fD,name:O.string(),optionId:dD}),mD=O.union([O.literal(`high`),O.literal(`medium`),O.literal(`low`)]),hD=O.union([O.literal(`pending`),O.literal(`in_progress`),O.literal(`completed`)]),gD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:O.string(),priority:mD,status:hD}),_D=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),entries:O.array(gD)}),vD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),audio:O.boolean().optional().default(!1),embeddedContext:O.boolean().optional().default(!1),image:O.boolean().optional().default(!1)}),yD=O.number().int().gte(0).lte(65535),bD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),clientCapabilities:QE.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:eD.nullish(),protocolVersion:yD}),xD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:O.string()}),SD=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),CD=O.union([O.number(),O.string()]).nullable();O.object({_meta:O.record(O.string(),O.unknown()).nullish(),requestId:CD});const wD=O.enum([`assistant`,`user`]),TD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),audience:O.array(wD).nullish(),lastModified:O.string().nullish(),priority:O.number().nullish()}),ED=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),annotations:TD.nullish(),data:O.string(),mimeType:O.string()}),DD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),annotations:TD.nullish(),data:O.string(),mimeType:O.string(),uri:O.string().nullish()}),OD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),annotations:TD.nullish(),description:O.string().nullish(),mimeType:O.string().nullish(),name:O.string(),size:O.number().nullish(),title:O.string().nullish(),uri:O.string()}),kD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),optionId:dD}),AD=O.union([O.object({outcome:O.literal(`cancelled`)}),kD.and(O.object({outcome:O.literal(`selected`)}))]),jD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),outcome:AD}),MD=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),ND=O.object({currentValue:O.boolean()}),PD=O.string(),FD=O.string(),ID=O.union([O.literal(`mode`),O.literal(`model`),O.literal(`thought_level`),O.string()]),LD=O.string(),RD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string().nullish(),name:O.string(),value:LD}),zD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),group:PD,name:O.string(),options:O.array(RD)}),BD=O.union([O.array(RD),O.array(zD)]),VD=O.object({currentValue:LD,options:BD}),HD=O.intersection(O.union([VD.and(O.object({type:O.literal(`select`)})),ND.and(O.object({type:O.literal(`boolean`)}))]),O.object({_meta:O.record(O.string(),O.unknown()).nullish(),category:ID.nullish(),description:O.string().nullish(),id:FD,name:O.string()})),UD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD)}),WD=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),GD=O.string(),KD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD});O.object({method:O.string(),params:O.union([KD,JE]).nullish()});const qD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD}),JD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),args:O.array(O.string()).optional(),command:O.string(),cwd:O.string().nullish(),env:O.array(GE).optional(),outputByteLimit:O.number().nullish(),sessionId:GD}),YD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cwd:O.string(),mcpServers:O.array(sD).optional(),sessionId:GD}),XD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD,terminalId:O.string()}),ZD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cwd:O.string(),mcpServers:O.array(sD),sessionId:GD}),QD=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),limit:O.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:O.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:O.string(),sessionId:GD}),$D=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD,terminalId:O.string()}),eO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cwd:O.string(),mcpServers:O.array(sD).optional(),sessionId:GD}),tO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cwd:O.string(),sessionId:GD,title:O.string().nullish(),updatedAt:O.string().nullish()}),nO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),nextCursor:O.string().nullish(),sessions:O.array(tO)}),rO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),title:O.string().nullish(),updatedAt:O.string().nullish()}),iO=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),aO=O.string(),oO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),currentModeId:aO}),sO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string().nullish(),id:aO,name:O.string()}),cO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),availableModes:O.array(sO),currentModeId:aO}),lO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),availableModels:O.array(lD),currentModelId:cD}),uO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD).nullish(),models:lO.nullish(),modes:cO.nullish(),sessionId:GD}),dO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD).nullish(),models:lO.nullish(),modes:cO.nullish()}),fO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD).nullish(),models:lO.nullish(),modes:cO.nullish(),sessionId:GD}),pO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD).nullish(),models:lO.nullish(),modes:cO.nullish()}),mO=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),hO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),close:MD.nullish(),fork:WD.nullish(),list:iO.nullish(),resume:mO.nullish()}),gO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),loadSession:O.boolean().optional().default(!1),mcpCapabilities:rD.optional().default({http:!1,sse:!1}),promptCapabilities:vD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:hO.optional().default({})}),_O=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),agentCapabilities:gO.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:eD.nullish(),authMethods:O.array(LE).optional().default([]),protocolVersion:yD}),vO=O.intersection(O.union([O.object({type:O.literal(`boolean`),value:O.boolean()}),O.object({value:LD})]),O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configId:FD,sessionId:GD})),yO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),configOptions:O.array(HD)}),bO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),modeId:aO,sessionId:GD}),xO=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),SO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),modelId:cD,sessionId:GD}),CO=O.object({_meta:O.record(O.string(),O.unknown()).nullish()}),wO=O.union([O.literal(`end_turn`),O.literal(`max_tokens`),O.literal(`max_turn_requests`),O.literal(`refusal`),O.literal(`cancelled`)]),TO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),terminalId:O.string()}),EO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),exitCode:O.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:O.string().nullish()}),DO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD,terminalId:O.string()}),OO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),exitStatus:EO.nullish(),output:O.string(),truncated:O.boolean()}),kO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),annotations:TD.nullish(),text:O.string()}),AO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),mimeType:O.string().nullish(),text:O.string(),uri:O.string()}),jO=O.union([AO,BE]),MO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),annotations:TD.nullish(),resource:jO}),NO=O.union([kO.and(O.object({type:O.literal(`text`)})),DD.and(O.object({type:O.literal(`image`)})),ED.and(O.object({type:O.literal(`audio`)})),OD.and(O.object({type:O.literal(`resource_link`)})),MO.and(O.object({type:O.literal(`resource`)}))]),PO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:NO}),FO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:NO,messageId:O.string().nullish()}),IO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),messageId:O.string().nullish(),prompt:O.array(NO),sessionId:GD});O.object({id:CD,method:O.string(),params:O.union([bD,RE,uD,ZD,nD,YD,eO,qD,bO,vO,IO,SO,YE]).nullish()});const LO=O.union([PO.and(O.object({type:O.literal(`content`)})),WE.and(O.object({type:O.literal(`diff`)})),TO.and(O.object({type:O.literal(`terminal`)}))]),RO=O.string(),zO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),line:O.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:O.string()}),BO=O.union([O.literal(`pending`),O.literal(`in_progress`),O.literal(`completed`),O.literal(`failed`)]),VO=O.union([O.literal(`read`),O.literal(`edit`),O.literal(`delete`),O.literal(`move`),O.literal(`search`),O.literal(`execute`),O.literal(`think`),O.literal(`fetch`),O.literal(`switch_mode`),O.literal(`other`)]),HO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:O.array(LO).optional(),kind:VO.optional(),locations:O.array(zO).optional(),rawInput:O.unknown().optional(),rawOutput:O.unknown().optional(),status:BO.optional(),title:O.string(),toolCallId:RO}),UO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:O.array(LO).nullish(),kind:VO.nullish(),locations:O.array(zO).nullish(),rawInput:O.unknown().optional(),rawOutput:O.unknown().optional(),status:BO.nullish(),title:O.string().nullish(),toolCallId:RO}),WO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),options:O.array(pD),sessionId:GD,toolCall:UO}),GO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),hint:O.string()}),KO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),description:O.string(),input:GO.nullish(),name:O.string()}),qO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),availableCommands:O.array(KO)}),JO=O.object({cachedReadTokens:O.number().nullish(),cachedWriteTokens:O.number().nullish(),inputTokens:O.number(),outputTokens:O.number(),thoughtTokens:O.number().nullish(),totalTokens:O.number()}),YO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),stopReason:wO,usage:JO.nullish(),userMessageId:O.string().nullish()});O.union([O.object({id:CD,result:O.union([_O,zE,fO,dO,nO,uO,pO,VE,xO,yO,YO,CO,XE])}),O.object({error:qE,id:CD})]);const XO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),cost:HE.nullish(),size:O.number(),used:O.number()}),ZO=O.union([FO.and(O.object({sessionUpdate:O.literal(`user_message_chunk`)})),FO.and(O.object({sessionUpdate:O.literal(`agent_message_chunk`)})),FO.and(O.object({sessionUpdate:O.literal(`agent_thought_chunk`)})),HO.and(O.object({sessionUpdate:O.literal(`tool_call`)})),UO.and(O.object({sessionUpdate:O.literal(`tool_call_update`)})),_D.and(O.object({sessionUpdate:O.literal(`plan`)})),qO.and(O.object({sessionUpdate:O.literal(`available_commands_update`)})),oO.and(O.object({sessionUpdate:O.literal(`current_mode_update`)})),UD.and(O.object({sessionUpdate:O.literal(`config_option_update`)})),rO.and(O.object({sessionUpdate:O.literal(`session_info_update`)})),XO.and(O.object({sessionUpdate:O.literal(`usage_update`)}))]),QO=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD,update:ZO});O.object({method:O.string(),params:O.union([QO,JE]).nullish()});const $O=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),sessionId:GD,terminalId:O.string()}),ek=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),exitCode:O.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:O.string().nullish()}),tk=O.object({_meta:O.record(O.string(),O.unknown()).nullish(),content:O.string(),path:O.string(),sessionId:GD});O.object({id:CD,method:O.string(),params:O.union([tk,QD,WO,JD,DO,$D,$O,XD,YE]).nullish()});const nk=O.object({_meta:O.record(O.string(),O.unknown()).nullish()});O.union([O.object({id:CD,result:O.union([nk,xD,jD,UE,OO,SD,ek,tD,XE])}),O.object({error:qE,id:CD})]);function rk(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a)break;if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
2
+ import{n as e,r as t,t as n}from"./chunk-wdO_pP5q.js";import{$ as r,$i as i,$n as a,$r as o,$t as s,A as c,Aa as l,Ai as u,An as d,Ar as f,At as p,B as m,Ba as h,Bi as g,Bn as _,Br as v,Bt as y,C as b,Ca as x,Ci as ee,Cn as S,Cr as C,Ct as w,D as te,Da as T,Di as E,Dn as D,Dr as ne,Dt as O,E as k,Ea as A,Ei as re,En as j,Er as ie,Et as M,F as ae,Fa as N,Fi as oe,Fn as P,Fr as F,Ft as se,G as ce,Ga as le,Gn as I,Gr as L,Gt as ue,H as de,Ha as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ia as ve,Ii as ye,In as be,Ir as xe,It as Se,J as Ce,Ji as we,Jn as Te,Jr as Ee,Jt as De,K as Oe,Ka as ke,Ki as Ae,Kn as je,Kr as R,Kt as z,La as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Ma as Re,Mi as ze,Mn as Be,Mr as Ve,Mt as B,N as He,Na as Ue,Ni as We,Nn as Ge,Nr as V,Nt as Ke,O as qe,Oa as Je,Oi as Ye,On as Xe,Or as Ze,Ot as Qe,P as $e,Pa as et,Pi as tt,Pn as nt,Pr as rt,Pt as it,Q as at,Qi as ot,Qn as st,Qr as ct,Qt as lt,R as ut,Ra as dt,Ri as ft,Rn as pt,Rr as mt,Rt as ht,S as gt,Sa as _t,Si as vt,Sn as yt,Sr as bt,St as xt,T as St,Ta as Ct,Ti as wt,Tn as Tt,Tr as Et,Tt as Dt,U as Ot,Ua as kt,Ui as At,Un as jt,Ur as Mt,Ut as Nt,V as Pt,Va as Ft,Vi as It,Vn as Lt,Vr as Rt,Vt as zt,Wa as Bt,Wi as Vt,Wn as Ht,Wr as Ut,Wt,X as Gt,Xi as Kt,Xn as qt,Xr as Jt,Xt as Yt,Y as Xt,Yi as Zt,Yn as Qt,Yr as $t,Yt as en,Z as tn,Zi as nn,Zn as rn,Zr as an,Zt as on,_ as sn,_a as cn,_i as ln,_n as un,_r as dn,_t as fn,a as pn,aa as mn,ai as hn,an as gn,ar as _n,at as vn,b as yn,ba as bn,bi as xn,bn as Sn,br as Cn,bt as wn,c as Tn,ca as En,ci as Dn,cn as On,cr as kn,ct as An,d as jn,da as Mn,di as Nn,dn as Pn,dr as Fn,dt as In,ea as Ln,ei as Rn,en as zn,er as Bn,et as Vn,f as Hn,fa as Un,fi as Wn,fn as Gn,fr as Kn,ft as qn,g as Jn,ga as Yn,gi as Xn,gn as Zn,gr as Qn,gt as $n,h as er,ha as tr,hi as nr,hn as rr,hr as ir,ht as ar,ia as or,ii as sr,in as cr,ir as lr,it as ur,j as dr,ja as fr,ji as pr,jn as mr,jr as hr,jt as gr,k as _r,ka as vr,ki as yr,kn as br,kr as xr,kt as Sr,l as Cr,la as wr,li as Tr,ln as Er,lr as Dr,lt as Or,m as kr,ma as Ar,mi as jr,mn as Mr,mr as Nr,mt as Pr,na as Fr,ni as Ir,nn as Lr,nr as H,nt as Rr,o as zr,oa as Br,oi as Vr,on as Hr,or as Ur,ot as Wr,p as Gr,pa as Kr,pi as qr,pn as Jr,pt as Yr,q as Xr,qi as Zr,qn as Qr,qr as $r,qt as ei,ra as ti,ri as ni,rn as ri,rr as ii,rt as ai,s as oi,sa as si,si as ci,sn as li,sr as ui,st as di,t as fi,ta as pi,ti as mi,tn as hi,tr as gi,tt as _i,u as vi,ua as yi,ui as bi,un as xi,ur as U,ut as Si,v as Ci,va as wi,vi as Ti,vn as Ei,vr as Di,vt as Oi,w as ki,wa as Ai,wn as ji,wr as Mi,wt as Ni,x as Pi,xa as Fi,xi as Ii,xn as Li,xr as Ri,xt as zi,y as Bi,ya as Vi,yi as Hi,yn as Ui,yr as Wi,yt as Gi,z as Ki,za as qi,zi as Ji,zn as Yi,zr as Xi,zt as Zi}from"./server-C9rjDe4G-tK1eEVqu.js";import{createRequire as Qi}from"node:module";import{Command as $i}from"commander";import{Box as W,Static as ea,Text as G,render as ta,useInput as na,useStdout as ra}from"ink";import{QueryClient as ia,QueryClientProvider as aa,useMutation as oa,useQuery as sa}from"@tanstack/react-query";import{c as ca}from"react/compiler-runtime";import{createContext as la,useCallback as ua,useContext as da,useEffect as fa,useMemo as pa,useRef as ma,useState as K}from"react";import{Fragment as ha,jsx as q,jsxs as J}from"react/jsx-runtime";import Y from"figures";import ga from"picocolors";import*as _a from"node:path";import va,{join as ya,normalize as ba}from"node:path";import*as xa from"node:url";import{fileURLToPath as Sa,pathToFileURL as Ca}from"node:url";import{z as wa}from"zod";import{z as X}from"zod/v4";import*as Ta from"node:child_process";import{exec as Ea,execFile as Da,execSync as Oa}from"node:child_process";import*as ka from"node:crypto";import{createHash as Aa}from"node:crypto";import*as ja from"node:fs";import{createReadStream as Ma}from"node:fs";import*as Na from"node:os";import{platform as Pa}from"node:os";import*as Fa from"node:readline";import{createInterface as Ia}from"node:readline";import{NodeFileSystem as La,NodeServices as Ra}from"@effect/platform-node";import{Buffer as za}from"node:buffer";import{execSync as Ba,spawn as Va}from"child_process";import{EventEmitter as Ha}from"node:events";import{request as Ua}from"node:http";import*as Wa from"node:fs/promises";import Ga from"ink-spinner";import Ka from"cli-truncate";import qa from"string-width";import{create as Ja}from"zustand";import{dirname as Ya,posix as Xa,sep as Za}from"path";import{AsyncLocalStorage as Qa}from"node:async_hooks";import{createJSONStorage as $a,persist as eo}from"zustand/middleware";import{RegistryProvider as to,useAtom as no,useAtomSet as ro,useAtomValue as io}from"@effect/atom-react";import ao from"pretty-ms";import{detectTerminal as oo}from"detect-terminal";import so from"supports-terminal-graphics";import co from"ink-link";import{Hono as lo}from"hono";import{proxy as uo}from"hono/proxy";import{serve as fo}from"@hono/node-server";import"node-notifier";import po from"prompts";import mo from"ora";const ho=e=>()=>{let t=Wt(Dt(e));return on((e,n)=>V(Qt(e,e=>t(e))))},go=e=>()=>{let t=zt(Dt(e));return on((e,n)=>V(Qt(e,e=>t(e))))},_o=fe(2,(e,t)=>ho(t.inputSchema)().pipe(hi(e),hi(go(t.outputSchema)()))),vo=`~effect/FiberMap`,yo=e=>et(e,vo),bo={[vo]:vo,[Symbol.iterator](){return this.state._tag===`Closed`?Un():this.state.backing[Symbol.iterator]()},...T,toJSON(){return{_id:`FiberMap`,state:this.state}}},xo=(e,t)=>{let n=Object.create(bo);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},So=()=>br(F(()=>xo(Li(),vt())),e=>rt(()=>{let t=e.state;return t._tag===`Closed`?R:(e.state={_tag:`Closed`},Ei(j(t.backing)).pipe(Hi(e.deferred)))})),Co=Ln(ot(oe,i(-1))),wo=fe(e=>yo(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(-1);return}let i=yt(e.state.backing,t);if(i._tag===`Some`){if(r?.onlyIfMissing===!0){n.interruptUnsafe(-1);return}else if(i.value===n)return;i.value.interruptUnsafe(-1)}Tt(e.state.backing,t,n),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=yt(e.state.backing,t);_t(a)&&n===a.value&&ji(e.state.backing,t),re(i)&&(r?.propagateInterruption===!0?!Co(i.cause):!ft(i.cause))&&Ti(e.deferred,i)})}),To=fe(2,(e,t)=>e.state._tag===`Closed`?!1:S(e.state.backing,t)),Eo=function(){let e;return()=>(e===void 0&&(e=Ri(lr)),e)}(),Do=function(){let e=arguments[0];if(_n(arguments[2]))return Oo(e,arguments[1],arguments[2],arguments[3]);let t=arguments[1],n=arguments[2];return r=>Oo(e,t,r,n)},Oo=(e,t,n,r)=>Ee(i=>{if(e.state._tag===`Closed`)return lr;if(r?.onlyIfMissing===!0&&To(e,t))return F(Eo);let a=bt(i.services)(n);return wo(e,t,a,r),V(a)});var ko=class extends Zr()(`effect/reactivity/Reactivity`){};const Ao=F(()=>{let e=new Map,t=t=>{Io(t,t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})},n=e=>Ve(n=>{let r=n.mapUnsafe.get(jo.key);return r?Io(e,e=>{r.add(e)}):t(e),R}),r=(e,t)=>xe(t,n(e)),i=(t,n)=>{let r=[];return Io(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i.delete(n),i.size===0&&e.delete(r[t])}}},a=(e,t)=>H(function*(){let n=yield*hr(),r=Kt(n,Wn),a=yield*On(),o=kt(bt(n),Sn(r)),s=!1,c=!1,l=e=>{e._tag===`Failure`?li(a,e.cause):xi(a,e.value),c?(c=!1,o(t).addObserver(l)):s=!1};function u(){if(s){c=!0;return}s=!0,o(t).addObserver(l)}return yield*qr(r,F(i(e,u))),u(),a});return ko.of({mutation:r,query:a,stream:(e,t)=>a(e,t).pipe(U(m),Wr),invalidateUnsafe:t,invalidate:n,registerUnsafe:i,withBatch:t=>rt(()=>{let n=new Set;return t.pipe(Di(jo,n),Nr(t=>F(()=>{n.forEach(t=>{let n=e.get(t);n!==void 0&&n.forEach(e=>e())})})))})})});var jo=class extends Zr()(`effect/reactivity/Reactivity/PendingInvalidation`){};const Mo=fe(2,(e,t)=>ko.use(n=>n.mutation(t,e))),No=e=>ko.use(t=>t.invalidate(e)),Po=sr(ko)(Ao);function Fo(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return fr(e)}}const Io=(e,t)=>{if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(Fo(e[n]));return}for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Fo(r[e])}`)}},Lo=`~effect/Stdio`,Ro=Zr(Lo),zo=e=>({[Lo]:Lo,...e}),Bo=e=>et(e,`~effect/SubscriptionRef`);({...T});const Vo=e=>Ki(e.pubsub),Ho=e=>F(()=>e.value),Uo=(e,t)=>{e.value=t,Jr(e.pubsub,t)},Wo=fe(2,(e,t)=>e.semaphore.withPermit(F(()=>Uo(e,t)))),Go=`~effect/platform/Terminal`;xt(`QuitError`)({_tag:De(`QuitError`)});const Ko=Zr(`effect/platform/Terminal`),qo=e=>Ko.of({...e,[Go]:Go}),Jo=`0.0.5`,Yo=`\x1B[?1049l`,Xo=process.env.SUPPORT_CLICK===`true`||process.env.SUPPORT_CLICK===`1`,Zo=[`lint`,`check`,`format`,`typecheck`,`type-check`],Qo={"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`},$o=()=>{},es=la({subscribeClick:()=>$o}),ts=/\x1b\[<(\d+);(\d+);(\d+)([Mm])|\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\d+;\d+R|\[\?[\d;]+[a-z]/g,ns=({children:e})=>{if(!Xo)return q(ha,{children:e});let t=ma(new Set),n=ma(!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(ts,(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=ua(e=>(t.current.add(e),()=>{t.current.delete(e)}),[]);return q(es.Provider,{value:{subscribeClick:r},children:e})},rs=()=>{let e=ca(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 da(es)},is=/\x1b\[[\d;?<>=]*[A-Za-z~]|\[<[\d;]+[Mm]|\[\?[\d;]+[a-z]|\[\d+;\d+R/g,as=e=>Xo?e.replace(is,``):e,os=e=>e&&e>0?e:80,ss=e=>e&&e>0?e:24,cs=()=>{let{stdout:e}=ra(),[t,n]=K([os(e.columns),ss(e.rows)]),r=ma(!1);return r.current||(r.current=!0,e.on(`resize`,()=>n([os(e.columns),ss(e.rows)]))),t},ls={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`},us={TEXT:ls.text,DIM:ls.textMuted,GREEN:ls.success,PRIMARY:ls.primary,SELECTION:ls.accent,RED:ls.error,BORDER:ls.border,DIVIDER:ls.borderSubtle,YELLOW:ls.warning,PURPLE:ls.secondary,CYAN:ls.info,INPUT_BG:ls.inputBg,BANNER_BG:ls.bannerBg},ds=()=>us,fs=e=>{let t=ca(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]=cs(),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=q(G,{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=q(W,{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=q(G,{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=J(W,{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},ps=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}},ms=({onClick:e,children:t,fullWidth:n=!0})=>{let{subscribeClick:r}=rs(),i=ma(e);return i.current=e,q(W,{ref:ua(e=>{if(e)return r((t,n)=>{if(n!==`press`||!e.yogaNode)return;let r=ps(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})},hs=e=>/\w/.test(e),gs=(e,t)=>{let n=t-1;for(;n>0&&!hs(e[n]);)n--;for(;n>0&&hs(e[n-1]);)n--;return n},_s=(e,t)=>{let n=t;for(;n<e.length&&hs(e[n]);)n++;for(;n<e.length&&!hs(e[n]);)n++;return n},vs=(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}},ys=(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)},bs=({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]=K({cursorOffset:(e||``).length,cursorWidth:0}),{cursorOffset:p,cursorWidth:m}=d,h=ma({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?ga.gray(t):void 0;if(a&&n){y=t.length>0?ga.inverse(t[0])+ga.gray(t.slice(1)):ga.inverse(` `),v=_.length>0?``:ga.inverse(` `);let e=0;for(let t of _){let n=e>=p-g&&e<=p;n&&t===`
4
+ `?v+=ga.inverse(` `)+`
5
+ `:v+=n?ga.inverse(t):t,e++}_.length>0&&p===_.length&&(v+=ga.inverse(` `))}return na((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}=vs(e,p);t>0?r=ys(i,t-1,n):l?.(),m=!0}else if(o&&n.downArrow&&a){let{lineIndex:t,column:n,lines:i}=vs(e,p);t<i.length-1?r=ys(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=gs(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=gs(e,p),m=!0;else if(n.meta&&t===`f`&&a)r=_s(e,p),m=!0;else if(n.meta&&(n.backspace||n.delete)){if(p>0){let t=gs(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}),q(G,{children:t?_.length>0?v:y:v})},xs=e=>{let t=ca(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=ds();if(n){let e;t[1]===o.DIM?e=t[2]:(e=q(G,{color:o.DIM,children:`/`}),t[1]=o.DIM,t[2]=e);let n;t[3]!==i||t[4]!==a||t[5]!==r?(n=q(bs,{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=J(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=q(W,{marginTop:1,children:J(G,{color:o.DIM,children:[`/`,r]})}),t[10]=o.DIM,t[11]=r,t[12]=e):e=t[12],e}return null},Ss=Ni([`pending`,`in_progress`,`completed`,`failed`]),Cs=Ni([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`switch_mode`,`other`]);Ni([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`]);const ws=ht([Ke({type:w(`text`),text:B}),Ke({type:w(`image`),data:B,mimeType:B}),Ke({type:w(`resource_link`),uri:B}),Ke({type:w(`resource`),uri:B})]),Ts=ht([Ke({type:w(`content`),content:ws}),Ke({type:w(`diff`),path:B,oldText:z(M(B)),newText:z(M(B))}),Ke({type:w(`terminal`),terminalId:B})]),Es=Ke({path:B,lineNumber:z(M(O))});var Ds=class extends Gi(`AcpAgentMessageChunk`)({sessionUpdate:w(`agent_message_chunk`),content:ws,messageId:z(M(B))}){},Os=class extends Gi(`AcpAgentThoughtChunk`)({sessionUpdate:w(`agent_thought_chunk`),content:ws,messageId:z(M(B))}){},ks=class extends Gi(`AcpUserMessageChunk`)({sessionUpdate:w(`user_message_chunk`),content:ws,messageId:z(M(B))}){},As=class extends Gi(`AcpToolCall`)({sessionUpdate:w(`tool_call`),toolCallId:B,title:B,kind:z(Cs),status:z(Ss),content:z($n(Ts)),locations:z($n(Es)),rawInput:z(Zi),rawOutput:z(Zi)}){},js=class extends Gi(`AcpToolCallUpdate`)({sessionUpdate:w(`tool_call_update`),toolCallId:B,title:z(M(B)),kind:z(M(Cs)),status:z(M(Ss)),content:z(M($n(Ts))),locations:z(M($n(Es))),rawInput:z(Zi),rawOutput:z(Zi)}){};const Ms=Ni([`pending`,`in_progress`,`completed`]),Ns=Ni([`high`,`medium`,`low`]),Ps=ht([Ds,Os,ks,As,js,class extends Gi(`AcpPlanUpdate`)({sessionUpdate:w(`plan`),entries:$n(Ke({content:B,priority:Ns,status:Ms}))}){},class extends Gi(`AcpAvailableCommandsUpdate`)({sessionUpdate:w(`available_commands_update`)}){},class extends Gi(`AcpCurrentModeUpdate`)({sessionUpdate:w(`current_mode_update`)}){},class extends Gi(`AcpConfigOptionUpdate`)({sessionUpdate:w(`config_option_update`)}){},class extends Gi(`AcpSessionInfoUpdate`)({sessionUpdate:w(`session_info_update`)}){},class extends Gi(`AcpUsageUpdate`)({sessionUpdate:w(`usage_update`)}){}]);Ke({inputTokens:O,outputTokens:O,cachedReadTokens:z(M(O)),cachedWriteTokens:z(M(O)),thoughtTokens:z(M(O))}),Ni([`claude`,`codex`,`cursor`]);var Fs=class extends Gi(`@ami/FileStat`)({relativePath:B,added:O,removed:O}){},Is=class extends Gi(`@supervisor/GitState`)({isGitRepo:Oi,currentBranch:B,mainBranch:Ie(B),isOnMain:Oi,hasChangesFromMain:Oi,hasUnstagedChanges:Oi,hasBranchCommits:Oi,branchCommitCount:O,fileStats:$n(Fs),workingTreeFileStats:$n(Fs),fingerprint:Ie(B),savedFingerprint:Ie(B)}){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 Ls=B.pipe(y(`StepId`)),Rs=B.pipe(y(`PlanId`)),zs=se({WorkingTree:{},Branch:{mainBranch:B},Changes:{mainBranch:B},Commit:{hash:B}}),Bs=e=>yn(e).pipe(Bi({WorkingTree:()=>`working tree`,Branch:()=>`branch`,Changes:()=>`changes`,Commit:({hash:e})=>e.slice(0,7)})),Vs=Ke({number:O,headRefName:B,author:Ke({login:B}),state:B,updatedAt:B}),Hs=[`recent`,`all`,`open`,`draft`,`merged`,`no-pr`];var Us=class extends Gi(`@supervisor/RemoteBranch`)({name:B,author:B,prNumber:M(O),prStatus:M(Ni([`open`,`draft`,`merged`])),updatedAt:M(B)}){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 Ws=Ni([`pending`,`active`,`passed`,`failed`]);var Gs=class e extends Gi(`@supervisor/TestPlanStep`)({id:Ls,title:B,instruction:B,expectedOutcome:B,routeHint:Sr(B),status:Ws,summary:Sr(B),startedAt:Sr(wn),endedAt:Sr(wn)}){update(t){return new e({...this,...t})}};const Ks=B.pipe(y(`DraftId`));var qs=class e extends Gi(`@supervisor/TestPlanDraft`)({id:Ks,changesFor:zs,currentBranch:B,diffPreview:B,fileStats:$n(Fs),instruction:B,baseUrl:Qe(B),isHeadless:Oi,requiresCookies:Oi}){update(t){return new e({...this,...t})}},Js=class e extends qs.extend(`@supervisor/TestPlan`)({id:Rs,title:B,rationale:B,steps:$n(Gs)}){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 resetForRerun(){return new e({...this,steps:this.steps.map(e=>new Gs({...e,status:`pending`,summary:Ct(),startedAt:Ct(),endedAt:Ct()}))})}},Ys=class extends it()(`RunStarted`,{plan:Js}){get id(){return`run-started-${this.plan.id}`}},Xs=class extends it()(`StepStarted`,{stepId:Ls,title:B}){get id(){return`step-started-${this.stepId}`}},Zs=class extends it()(`StepCompleted`,{stepId:Ls,summary:B}){get id(){return`step-completed-${this.stepId}`}},Qs=class extends it()(`StepFailed`,{stepId:Ls,message:B}){get id(){return`step-failed-${this.stepId}`}},$s=class extends it()(`ToolCall`,{toolName:B,input:Zi}){get id(){return`tool-call-${this.toolName}-${JSON.stringify(this.input)}`}get displayText(){return dt(this.input)&&`command`in this.input?String(this.input.command).slice(0,80):this.toolName}},ec=class extends it()(`ToolProgress`,{toolName:B,outputSize:O}){get id(){return`tool-progress-${this.toolName}-${this.outputSize}`}},tc=class extends it()(`ToolResult`,{toolName:B,result:B,isError:Oi}){get id(){return`tool-result-${this.toolName}-${this.result}`}},nc=class extends it()(`AgentThinking`,{text:B}){get id(){return`agent-thinking-${this.text}`}},rc=class extends it()(`AgentText`,{text:B}){get id(){return`agent-text-${this.text}`}},ic=class extends it()(`RunFinished`,{status:Ni([`passed`,`failed`]),summary:B}){get id(){return`run-finished-${this.status}`}};const ac=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)}},oc=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 Xs({stepId:Ls.makeUnsafe(a),title:o});if(n===`STEP_DONE`)return new Zs({stepId:Ls.makeUnsafe(a),summary:o});if(n===`ASSERTION_FAILED`)return new Qs({stepId:Ls.makeUnsafe(a),message:o});if(n===`RUN_COMPLETED`)return new ic({status:a===`failed`?`failed`:`passed`,summary:o})},sc=ht([Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic]),cc=ht([Ys,Xs,Zs,Qs,$s,tc,nc,ic,class extends it()(`RunCompleted`,{report:ei(()=>vc)}){}]);var lc=class extends Gi(`@supervisor/Update`)({content:cc,receivedAt:wn}){},uc=class extends Gi(`@supervisor/PullRequest`)({number:O,url:B,title:B,headRefName:B}){};const dc=se({WorkingTree:{},Branch:{branch:Us},PullRequest:{branch:Us},Commit:{hash:B,shortHash:B,subject:B}}),fc=e=>yn(e).pipe(Bi({WorkingTree:()=>`working-tree`,Branch:({branch:e})=>`branch-${e.name}`,PullRequest:({branch:e})=>`pr-${e.prNumber}`,Commit:({hash:e})=>`commit-${e}`})),pc=e=>yn(e).pipe(Bi({WorkingTree:()=>`local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber} ${e.name} ${e.author}`,Commit:({shortHash:e,subject:t})=>`${e} ${t}`})),mc=e=>yn(e).pipe(Bi({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>e.name,Commit:({shortHash:e})=>e})),hc=e=>yn(e).pipe(Bi({WorkingTree:()=>`working tree`,Branch:({branch:e})=>e.author?`by ${e.author}`:``,PullRequest:({branch:e})=>`#${e.prNumber} ${e.prStatus??``}`.trim(),Commit:({subject:e})=>e})),gc=e=>yn(e).pipe(Bi({WorkingTree:()=>`Local changes`,Branch:({branch:e})=>e.name,PullRequest:({branch:e})=>`#${e.prNumber}`,Commit:({shortHash:e})=>e}));se({Branch:{branchName:B}});var _c=class e extends Js.extend(`@supervisor/ExecutedTestPlan`)({events:$n(sc)}){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 nc({text:r.text+t.content.text})]}):new e({...n,events:[...n.events,new nc({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 rc({text:n.text+t.content.text})]}):new e({...this,events:[...this.events,new rc({text:t.content.text})]})}if(t.sessionUpdate===`tool_call`){let n=this.finalizeTextBlock();return new e({...n,events:[...n.events,new $s({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 $s({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 tc({toolName:t.title??``,result:ac(t.rawOutput),isError:t.status===`failed`})]});if(t.rawOutput!==void 0){let r=ac(t.rawOutput).length;return new e({...n,events:[...n.events.filter(e=>!(e._tag===`ToolProgress`&&e.toolName===(t.title??``))),new ec({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(oc).filter(ve);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:A(D())}):e)}):new e({...this,steps:[...this.steps,new Gs({id:t.stepId,title:t.title,instruction:t.title,expectedOutcome:``,routeHint:Ct(),status:`active`,summary:Ct(),startedAt:A(D()),endedAt:Ct()})]}):t._tag===`StepCompleted`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`passed`,summary:A(t.summary),expectedOutcome:t.summary,endedAt:A(D())}):e)}):t._tag===`StepFailed`?new e({...this,steps:this.steps.map(e=>e.id===t.stepId?e.update({status:`failed`,summary:A(t.message),expectedOutcome:t.message,endedAt:A(D())}):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}},vc=class extends _c.extend(`@supervisor/TestReport`)({summary:B,screenshotPaths:$n(B),pullRequest:Qe(ei(()=>uc))}){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}`)}return r.join(`
8
+ `)}};const yc={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`},bc={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`},xc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),terminal:X.boolean().optional().default(!1)}),Sc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),label:X.string().nullish(),name:X.string(),optional:X.boolean().optional().default(!1),secret:X.boolean().optional().default(!0)}),Cc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string().nullish(),id:X.string(),name:X.string()}),wc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string().nullish(),id:X.string(),link:X.string().nullish(),name:X.string(),vars:X.array(Sc)}),Tc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),args:X.array(X.string()).optional(),description:X.string().nullish(),env:X.record(X.string(),X.string()).optional(),id:X.string(),name:X.string()}),Ec=X.union([wc.and(X.object({type:X.literal(`env_var`)})),Tc.and(X.object({type:X.literal(`terminal`)})),Cc]),Dc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),methodId:X.string()}),Oc=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),kc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),blob:X.string(),mimeType:X.string().nullish(),uri:X.string()}),Ac=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),jc=X.object({amount:X.number(),currency:X.string()}),Mc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),terminalId:X.string()}),Nc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),newText:X.string(),oldText:X.string().nullish(),path:X.string()}),Pc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),name:X.string(),value:X.string()}),Fc=X.union([X.literal(-32700),X.literal(-32600),X.literal(-32601),X.literal(-32602),X.literal(-32603),X.literal(-32800),X.literal(-32e3),X.literal(-32002),X.number().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),Ic=X.object({code:Fc,data:X.unknown().optional(),message:X.string()}),Lc=X.unknown(),Rc=X.unknown(),zc=X.unknown(),Bc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),readTextFile:X.boolean().optional().default(!1),writeTextFile:X.boolean().optional().default(!1)}),Vc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),auth:xc.optional().default({terminal:!1}),fs:Bc.optional().default({readTextFile:!1,writeTextFile:!1}),terminal:X.boolean().optional().default(!1)}),Hc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),name:X.string(),value:X.string()}),Uc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),name:X.string(),title:X.string().nullish(),version:X.string()}),Wc=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),Gc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cursor:X.string().nullish(),cwd:X.string().nullish()}),Kc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),http:X.boolean().optional().default(!1),sse:X.boolean().optional().default(!1)}),qc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),headers:X.array(Hc),name:X.string(),url:X.string()}),Jc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),headers:X.array(Hc),name:X.string(),url:X.string()}),Yc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),args:X.array(X.string()),command:X.string(),env:X.array(Pc),name:X.string()}),Xc=X.union([qc.and(X.object({type:X.literal(`http`)})),Jc.and(X.object({type:X.literal(`sse`)})),Yc]),Zc=X.string(),Qc=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string().nullish(),modelId:Zc,name:X.string()}),$c=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cwd:X.string(),mcpServers:X.array(Xc)}),el=X.string(),tl=X.union([X.literal(`allow_once`),X.literal(`allow_always`),X.literal(`reject_once`),X.literal(`reject_always`)]),nl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),kind:tl,name:X.string(),optionId:el}),rl=X.union([X.literal(`high`),X.literal(`medium`),X.literal(`low`)]),il=X.union([X.literal(`pending`),X.literal(`in_progress`),X.literal(`completed`)]),al=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:X.string(),priority:rl,status:il}),ol=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),entries:X.array(al)}),sl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),audio:X.boolean().optional().default(!1),embeddedContext:X.boolean().optional().default(!1),image:X.boolean().optional().default(!1)}),cl=X.number().int().gte(0).lte(65535),ll=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),clientCapabilities:Vc.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Uc.nullish(),protocolVersion:cl}),ul=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:X.string()}),dl=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),fl=X.union([X.number(),X.string()]).nullable();X.object({_meta:X.record(X.string(),X.unknown()).nullish(),requestId:fl});const pl=X.enum([`assistant`,`user`]),ml=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),audience:X.array(pl).nullish(),lastModified:X.string().nullish(),priority:X.number().nullish()}),hl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),annotations:ml.nullish(),data:X.string(),mimeType:X.string()}),gl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),annotations:ml.nullish(),data:X.string(),mimeType:X.string(),uri:X.string().nullish()}),_l=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),annotations:ml.nullish(),description:X.string().nullish(),mimeType:X.string().nullish(),name:X.string(),size:X.number().nullish(),title:X.string().nullish(),uri:X.string()}),vl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),optionId:el}),yl=X.union([X.object({outcome:X.literal(`cancelled`)}),vl.and(X.object({outcome:X.literal(`selected`)}))]),bl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),outcome:yl}),xl=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),Sl=X.object({currentValue:X.boolean()}),Cl=X.string(),wl=X.string(),Tl=X.union([X.literal(`mode`),X.literal(`model`),X.literal(`thought_level`),X.string()]),El=X.string(),Dl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string().nullish(),name:X.string(),value:El}),Ol=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),group:Cl,name:X.string(),options:X.array(Dl)}),kl=X.union([X.array(Dl),X.array(Ol)]),Al=X.object({currentValue:El,options:kl}),jl=X.intersection(X.union([Al.and(X.object({type:X.literal(`select`)})),Sl.and(X.object({type:X.literal(`boolean`)}))]),X.object({_meta:X.record(X.string(),X.unknown()).nullish(),category:Tl.nullish(),description:X.string().nullish(),id:wl,name:X.string()})),Ml=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl)}),Nl=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),Pl=X.string(),Fl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl});X.object({method:X.string(),params:X.union([Fl,Lc]).nullish()});const Il=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl}),Ll=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),args:X.array(X.string()).optional(),command:X.string(),cwd:X.string().nullish(),env:X.array(Pc).optional(),outputByteLimit:X.number().nullish(),sessionId:Pl}),Rl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cwd:X.string(),mcpServers:X.array(Xc).optional(),sessionId:Pl}),zl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl,terminalId:X.string()}),Bl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cwd:X.string(),mcpServers:X.array(Xc),sessionId:Pl}),Vl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),limit:X.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:X.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:X.string(),sessionId:Pl}),Hl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl,terminalId:X.string()}),Ul=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cwd:X.string(),mcpServers:X.array(Xc).optional(),sessionId:Pl}),Wl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cwd:X.string(),sessionId:Pl,title:X.string().nullish(),updatedAt:X.string().nullish()}),Gl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),nextCursor:X.string().nullish(),sessions:X.array(Wl)}),Kl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),title:X.string().nullish(),updatedAt:X.string().nullish()}),ql=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),Jl=X.string(),Yl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),currentModeId:Jl}),Xl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string().nullish(),id:Jl,name:X.string()}),Zl=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),availableModes:X.array(Xl),currentModeId:Jl}),Ql=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),availableModels:X.array(Qc),currentModelId:Zc}),$l=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl).nullish(),models:Ql.nullish(),modes:Zl.nullish(),sessionId:Pl}),eu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl).nullish(),models:Ql.nullish(),modes:Zl.nullish()}),tu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl).nullish(),models:Ql.nullish(),modes:Zl.nullish(),sessionId:Pl}),nu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl).nullish(),models:Ql.nullish(),modes:Zl.nullish()}),ru=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),iu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),close:xl.nullish(),fork:Nl.nullish(),list:ql.nullish(),resume:ru.nullish()}),au=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),loadSession:X.boolean().optional().default(!1),mcpCapabilities:Kc.optional().default({http:!1,sse:!1}),promptCapabilities:sl.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:iu.optional().default({})}),ou=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),agentCapabilities:au.optional().default({loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Uc.nullish(),authMethods:X.array(Ec).optional().default([]),protocolVersion:cl}),su=X.intersection(X.union([X.object({type:X.literal(`boolean`),value:X.boolean()}),X.object({value:El})]),X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configId:wl,sessionId:Pl})),cu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),configOptions:X.array(jl)}),lu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),modeId:Jl,sessionId:Pl}),uu=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),du=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),modelId:Zc,sessionId:Pl}),fu=X.object({_meta:X.record(X.string(),X.unknown()).nullish()}),pu=X.union([X.literal(`end_turn`),X.literal(`max_tokens`),X.literal(`max_turn_requests`),X.literal(`refusal`),X.literal(`cancelled`)]),mu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),terminalId:X.string()}),hu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),exitCode:X.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:X.string().nullish()}),gu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl,terminalId:X.string()}),_u=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),exitStatus:hu.nullish(),output:X.string(),truncated:X.boolean()}),vu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),annotations:ml.nullish(),text:X.string()}),yu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),mimeType:X.string().nullish(),text:X.string(),uri:X.string()}),bu=X.union([yu,kc]),xu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),annotations:ml.nullish(),resource:bu}),Su=X.union([vu.and(X.object({type:X.literal(`text`)})),gl.and(X.object({type:X.literal(`image`)})),hl.and(X.object({type:X.literal(`audio`)})),_l.and(X.object({type:X.literal(`resource_link`)})),xu.and(X.object({type:X.literal(`resource`)}))]),Cu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:Su}),wu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:Su,messageId:X.string().nullish()}),Tu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),messageId:X.string().nullish(),prompt:X.array(Su),sessionId:Pl});X.object({id:fl,method:X.string(),params:X.union([ll,Dc,$c,Bl,Gc,Rl,Ul,Il,lu,su,Tu,du,Rc]).nullish()});const Eu=X.union([Cu.and(X.object({type:X.literal(`content`)})),Nc.and(X.object({type:X.literal(`diff`)})),mu.and(X.object({type:X.literal(`terminal`)}))]),Du=X.string(),Ou=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),line:X.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:X.string()}),ku=X.union([X.literal(`pending`),X.literal(`in_progress`),X.literal(`completed`),X.literal(`failed`)]),Au=X.union([X.literal(`read`),X.literal(`edit`),X.literal(`delete`),X.literal(`move`),X.literal(`search`),X.literal(`execute`),X.literal(`think`),X.literal(`fetch`),X.literal(`switch_mode`),X.literal(`other`)]),ju=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:X.array(Eu).optional(),kind:Au.optional(),locations:X.array(Ou).optional(),rawInput:X.unknown().optional(),rawOutput:X.unknown().optional(),status:ku.optional(),title:X.string(),toolCallId:Du}),Mu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:X.array(Eu).nullish(),kind:Au.nullish(),locations:X.array(Ou).nullish(),rawInput:X.unknown().optional(),rawOutput:X.unknown().optional(),status:ku.nullish(),title:X.string().nullish(),toolCallId:Du}),Nu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),options:X.array(nl),sessionId:Pl,toolCall:Mu}),Pu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),hint:X.string()}),Fu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),description:X.string(),input:Pu.nullish(),name:X.string()}),Iu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),availableCommands:X.array(Fu)}),Lu=X.object({cachedReadTokens:X.number().nullish(),cachedWriteTokens:X.number().nullish(),inputTokens:X.number(),outputTokens:X.number(),thoughtTokens:X.number().nullish(),totalTokens:X.number()}),Ru=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),stopReason:pu,usage:Lu.nullish(),userMessageId:X.string().nullish()});X.union([X.object({id:fl,result:X.union([ou,Oc,tu,eu,Gl,$l,nu,Ac,uu,cu,Ru,fu,zc])}),X.object({error:Ic,id:fl})]);const zu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),cost:jc.nullish(),size:X.number(),used:X.number()}),Bu=X.union([wu.and(X.object({sessionUpdate:X.literal(`user_message_chunk`)})),wu.and(X.object({sessionUpdate:X.literal(`agent_message_chunk`)})),wu.and(X.object({sessionUpdate:X.literal(`agent_thought_chunk`)})),ju.and(X.object({sessionUpdate:X.literal(`tool_call`)})),Mu.and(X.object({sessionUpdate:X.literal(`tool_call_update`)})),ol.and(X.object({sessionUpdate:X.literal(`plan`)})),Iu.and(X.object({sessionUpdate:X.literal(`available_commands_update`)})),Yl.and(X.object({sessionUpdate:X.literal(`current_mode_update`)})),Ml.and(X.object({sessionUpdate:X.literal(`config_option_update`)})),Kl.and(X.object({sessionUpdate:X.literal(`session_info_update`)})),zu.and(X.object({sessionUpdate:X.literal(`usage_update`)}))]),Vu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl,update:Bu});X.object({method:X.string(),params:X.union([Vu,Lc]).nullish()});const Hu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),sessionId:Pl,terminalId:X.string()}),Uu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),exitCode:X.number().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:X.string().nullish()}),Wu=X.object({_meta:X.record(X.string(),X.unknown()).nullish(),content:X.string(),path:X.string(),sessionId:Pl});X.object({id:fl,method:X.string(),params:X.union([Wu,Vl,Nu,Ll,gu,Hl,Hu,zl,Rc]).nullish()});const Gu=X.object({_meta:X.record(X.string(),X.unknown()).nullish()});X.union([X.object({id:fl,result:X.union([Gu,ul,bl,Mc,_u,dl,Uu,Wc,zc])}),X.object({error:Ic,id:fl})]);function Ku(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(`
30
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)+`
31
- `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}Symbol.asyncDispose;var ik=class{#e;constructor(e,t){let n=e(this);this.#e=new ak(async(e,t)=>{switch(e){case jE.fs_write_text_file:{let e=tk.parse(t);return n.writeTextFile?.(e)}case jE.fs_read_text_file:{let e=QD.parse(t);return n.readTextFile?.(e)}case jE.session_request_permission:{let e=WO.parse(t);return n.requestPermission(e)}case jE.terminal_create:{let e=JD.parse(t);return n.createTerminal?.(e)}case jE.terminal_output:{let e=DO.parse(t);return n.terminalOutput?.(e)}case jE.terminal_release:{let e=$D.parse(t);return await n.releaseTerminal?.(e)??{}}case jE.terminal_wait_for_exit:{let e=$O.parse(t);return n.waitForTerminalExit?.(e)}case jE.terminal_kill:{let e=XD.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw ok.methodNotFound(e)}},async(e,t)=>{switch(e){case jE.session_update:{let e=QO.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw ok.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(AE.initialize,e)}async newSession(e){return await this.#e.sendRequest(AE.session_new,e)}async loadSession(e){return await this.#e.sendRequest(AE.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(AE.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(AE.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(AE.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(AE.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(AE.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(AE.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(AE.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(AE.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(AE.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(AE.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}},ak=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 ok)return e.toResult();if(e instanceof D.ZodError)return ok.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 ok.internalError(t?JSON.parse(t):{}).toResult()}catch{return ok.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof ok)return e.toResult();if(e instanceof D.ZodError)return ok.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 ok.internalError(t?JSON.parse(t):{}).toResult()}catch{return ok.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}},ok=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 sk=ev(),ck=ev(),lk=`~effect/ChildProcessSpawner/ChildProcessHandle`,uk={[lk]:lk,...wn,toJSON(){return{_id:`ChildProcessHandle`,pid:this.pid}}},dk=e=>Object.assign(Object.create(uk),e),fk=e=>{let t=(t,n)=>e(t).pipe(q(e=>pC(n?.includeStderr===!0?e.all:e.stdout)),tC),n=(e,n)=>mC(t(e,n));return pk.of({spawn:e,exitCode:t=>Qp(K(e(t),e=>e.exitCode)),streamString:t,streamLines:n,lines:(e,t)=>vC(n(e,t)),string:(e,n)=>CC(t(e,n))})};var pk=class extends Ga()(`effect/process/ChildProcessSpawner`){};const mk=`~effect/unstable/process/ChildProcess`,hk={...zn,...Vn,[mk]:mk,asEffect(){return pk.use(e=>e.spawn(this))}},gk=(e,t,n)=>Object.assign(Object.create(hk),{_tag:`StandardCommand`,command:e,args:t,options:n}),_k=function(...e){if(vk(e[0])){let[t,...n]=e,r=xk(t,n);return gk(r[0]??``,r.slice(1),{})}if(typeof e[0]==`object`&&!Array.isArray(e[0])&&!vk(e[0])){let t=e[0];return function(e,...n){let r=xk(e,n);return gk(r[0]??``,r.slice(1),t)}}if(typeof e[0]==`string`&&!Array.isArray(e[1])){let[t,n={}]=e;return gk(t,[],n)}let[t,n=[],r={}]=e;return gk(t,n,r)},vk=e=>Array.isArray(e)&&`raw`in e&&Array.isArray(e.raw),yk=e=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let n=parseInt(t[1],10);return n>=3?n:void 0},bk=e=>`fd${e}`,xk=(e,t)=>{let n=[];for(let[r,i]of e.entries())n=Sk(e,t,n,i,r);return n},Sk=(e,t,n,r,i)=>{let a=e.raw[i];if(a===void 0)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:o,hasTrailingWhitespace:s,tokens:c}=Ek(r,a),l=Dk(n,c,o);if(i===t.length)return l;let u=t[i];return Dk(l,Array.isArray(u)?u.map(e=>Ck(e)):[Ck(u)],s)},Ck=e=>typeof e==`string`?e:String(e),wk=new Set([` `,` `,`\r`,`
32
- `]),Tk={x:3,u:5},Ek=(e,t)=>{if(t.length===0)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let n=wk.has(t[0]),r=[],i=0;for(let n=0,a=0;n<e.length;n+=1,a+=1){let o=t[a];if(wk.has(o))i!==n&&r.push(e.slice(i,n)),i=n+1;else if(o===`\\`){let e=t[a+1];e===`
33
- `?(--n,a+=1):e===`u`&&t[a+2]===`{`?a=t.indexOf(`}`,a+3):a+=Tk[e]??1}}let a=i===e.length;return a||r.push(e.slice(i)),{tokens:r,hasLeadingWhitespace:n,hasTrailingWhitespace:a}},Dk=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)];var Ok=class extends sS(`AgentStreamOptions`)({cwd:Y,sessionId:Kx(Y),prompt:Y,systemPrompt:Kx(Y)}){};const kk=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return yS({_tag:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})},Ak=e=>kS(rb(jk(e),e=>[e])),jk=e=>By(t=>{let n=e.evaluate();return U(Mk({...e,writable:n,pull:t}))}),Mk=e=>e.pull.pipe(K(t=>{let n=0;return hp(function r(i){for(;n<t.length;)if(!e.writable.write(t[n++],e.encoding)){e.writable.once(`drain`,()=>r(i));return}i(mp)})}),lm({disableYield:!0}),Bp(hp(t=>{let n=n=>t(G(e.onError(n)));return e.writable.once(`error`,n),W(()=>{e.writable.off(`error`,n)})})),e.endOnDone===!1?F:Jf(t=>`closed`in e.writable&&e.writable.closed?fd(t):hp(n=>{e.writable.once(`finish`,()=>n(fd(t))),e.writable.end()}))),Nk=e=>KS(Pk(e)),Pk=e=>By((t,n)=>Fk({scope:n,readable:e.evaluate(),onError:e.onError??Ik,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),Fk=e=>{let t=e.readable;if(t.readableEnded)return U(fd());let n=e.closeOnDone??!0,r=e.exit??Pv(void 0),i=bv(!1);function a(){i.openUnsafe()}function o(t){r.current=vd(e.onError(t)),i.openUnsafe()}function s(){r.current=vd(dd()),i.openUnsafe()}t.on(`readable`,a),t.once(`error`,o),t.once(`end`,s);let c=pp(function t(){let n=e.readable.read(e.chunkSize);if(n===null)return r.current?r.current:(i.closeUnsafe(),K(i.await,t));let a=Vi(n);for(;n=e.readable.read(e.chunkSize),n!==null;)a.push(n);return U(a)});return Tp(zd(e.scope,W(()=>{t.off(`readable`,a),t.off(`error`,o),t.off(`end`,s),n&&`closed`in e.readable&&!e.readable.closed&&e.readable.destroy()})),c)},Ik=e=>new md(e),Lk=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),Rk=(e,t,n)=>{let{commands:r}=Bk(n),i=r.reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return kk(`ChildProcess`,e)(t,[i])},zk=rf(pk,gp(function*(){let e=yield*kC,t=yield*FC,n=Om(function*(n){if(!pt(n.cwd))return yield*e.access(n.cwd),t.resolve(n.cwd)}),r=e=>e.extendEnv?{...globalThis.process.env,...e.env}:e.env,i=e=>GS(e)?`pipe`:e,a=e=>OS(e)?`pipe`:e,o=e=>{let t={stream:`pipe`,encoding:`utf-8`,endOnDone:!0};return pt(e.stdin)?t:typeof e.stdin==`string`||GS(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},s=(e,t)=>{let n=e[t];return pt(n)?{stream:`pipe`}:typeof n==`string`||OS(n)?{stream:n}:{stream:n.stream}},c=e=>{if(pt(e.additionalFds))return[];let t=[];for(let[n,r]of Object.entries(e.additionalFds)){let e=yk(n);mt(e)&&t.push({fd:e,config:r})}return t.sort((e,t)=>e.fd-t.fd)},l=(e,t,n,r)=>{let o=[i(e.stream),a(t.stream),a(n.stream)];if(r.length===0)return o;let s=r.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=s;e++)o[e]=`ignore`;for(let{fd:e}of r)o[e]=`pipe`;return o},u=Om(function*(e,t,n){if(n.length===0)return{getInputFd:()=>MS,getOutputFd:()=>ZS};let r=new Map,i=new Map;for(let{config:a,fd:o}of n){let n=t.stdio[o];switch(a.type){case`input`:{let t=MS;n&&`write`in n&&(t=Ak({evaluate:()=>n,onError:t=>Rk(`fromWritable(fd${o})`,Lk(t),e)})),a.stream&&(yield*pm(_C(a.stream,t))),r.set(o,t);break}case`output`:{let t=ZS;n&&`read`in n&&(t=Nk({evaluate:()=>n,onError:t=>Rk(`fromReadable(fd${o})`,Lk(t),e)})),a.sink&&(t=dC(t,a.sink)),i.set(o,t);break}}}return{getInputFd:e=>r.get(e)??MS,getOutputFd:e=>i.get(e)??ZS}}),d=(e,t,n)=>pp(()=>{let r=MS;return ht(t.stdin)&&(r=Ak({evaluate:()=>t.stdin,onError:t=>Rk(`fromWritable(stdin)`,Lk(t),e),endOnDone:n.endOnDone,encoding:n.encoding})),GS(n.stream)?Tp(pm(_C(n.stream,r)),r):U(r)}),f=(e,t,n,r)=>{let i=t.stdout?Nk({evaluate:()=>t.stdout,onError:t=>Rk(`fromReadable(stdout)`,Lk(t),e)}):ZS,a=t.stderr?Nk({evaluate:()=>t.stderr,onError:t=>Rk(`fromReadable(stderr)`,Lk(t),e)}):ZS;OS(n.stream)&&(i=dC(i,n.stream)),OS(r.stream)&&(a=dC(a,r.stream));let o=aC(i,a);return{stdout:i,stderr:a,all:o}},p=(e,t)=>hp(n=>{let r=wd(),i=k.spawn(e.command,e.args,t);return i.on(`error`,t=>{n(G(Rk(`spawn`,t,e)))}),i.on(`exit`,(...e)=>{Nd(r,gd(e))}),i.on(`spawn`,()=>{n(U([i,r]))}),W(()=>{i.kill(`SIGTERM`)})}),m=(e,t,n)=>globalThis.process.platform===`win32`?hp(n=>{k.exec(`taskkill /pid ${t.pid} /T /F`,t=>{n(t?G(Rk(`kill`,Lk(t),e)):mp)})}):yp({try:()=>{globalThis.process.kill(-t.pid,n)},catch:t=>Rk(`kill`,Lk(t),e)}),h=(e,t,n)=>pp(()=>t.kill(n)?mp:G(Rk(`kill`,new globalThis.Error(`Failed to kill child process`),e))),g=(e,t,n)=>r=>{let i=n?.killSignal??`SIGTERM`;return pt(n?.forceKillAfter)?r(t,e,i):Lp(r(t,e,i),{duration:n.forceKillAfter,onTimeout:()=>r(t,e,`SIGKILL`)})},_=(e,t)=>{let n=t??`stdout`;switch(n){case`stdout`:return e.stdout;case`stderr`:return e.stderr;case`all`:return e.all;default:{let t=yk(n);return mt(t)?e.getOutputFd(t):e.stdout}}},v=Om(function*(e){switch(e._tag){case`StandardCommand`:{let t=o(e.options),i=s(e.options,`stdout`),a=s(e.options,`stderr`),_=c(e.options),[v,y]=yield*em(p(e,{cwd:yield*n(e.options),env:r(e.options),stdio:l(t,i,a,_),detached:e.options.detached??process.platform!==`win32`,shell:e.options.shell}),Om(function*([t,n]){let r=yield*jd(n),i=g(t,e,e.options);if(r){let[e]=yield*Ed(n);return e!==0&&ht(e)?yield*Pp(i(m)):yield*mp}return yield*i((e,t,n)=>Dp(m(e,t,n),()=>h(e,t,n))).pipe(Sp(Ed(n)),Pp)})),b=ck(v.pid),x=yield*d(e,v,t),{all:S,stderr:C,stdout:w}=f(e,v,i,a),{getInputFd:T,getOutputFd:E}=yield*u(e,v,_),D=q(jd(y),e=>!e);return dk({pid:b,exitCode:K(Ed(y),([t,n])=>ht(t)?U(sk(t)):G(Rk(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: '${n}'`),e))),isRunning:D,kill:t=>g(v,e,t)((e,t,n)=>Dp(m(e,t,n),()=>h(e,t,n))).pipe(Sp(Ed(y)),Ep),stdin:x,stdout:w,stderr:C,all:S,getInputFd:T,getOutputFd:E})}case`PipedCommand`:{let{commands:t,pipeOptions:n}=Bk(e),[r,...i]=t,a=v(r);for(let e=0;e<i.length;e++){let t=i[e],r=n[e]??{},s=o(t.options),c=tC(q(a,e=>_(e,r.from))),l=r.to??`stdin`;if(l===`stdin`)a=v(_k(t.command,t.args,{...t.options,stdin:{...s,stream:c}}));else{let e=yk(l);if(mt(e)){let n=bk(e),r=t.options.additionalFds??{};a=v(_k(t.command,t.args,{...t.options,additionalFds:{...r,[n]:{type:`input`,stream:c}}}))}else a=v(_k(t.command,t.args,{...t.options,stdin:{...s,stream:c}}))}}return yield*a}}});return fk(v)})),Bk=e=>{let t=[],n=[],r=e=>{switch(e._tag){case`StandardCommand`:t.push(e);break;case`PipedCommand`:r(e.left),n.push(e.options),r(e.right);break}};if(r(e),t.length===0)throw Error(`flattenCommand produced empty commands array`);let[i,...a]=t;return{commands:[i,...a],pipeOptions:n}},Vk=e=>t=>bS({module:`FileSystem`,method:e,description:t.message??String(t)}),Hk=(()=>{let e=Im(j.access,kk(`FileSystem`,`access`),Vk(`access`));return(t,n)=>{let r=j.constants.F_OK;return n?.readable&&(r|=j.constants.R_OK),n?.writable&&(r|=j.constants.W_OK),e(t,r)}})(),Uk=(()=>{let e=Im(j.cp,kk(`FileSystem`,`copy`),Vk(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Wk=(()=>{let e=Im(j.copyFile,kk(`FileSystem`,`copyFile`),Vk(`copyFile`));return(t,n)=>e(t,n)})(),Gk=(()=>{let e=Im(j.chmod,kk(`FileSystem`,`chmod`),Vk(`chmod`));return(t,n)=>e(t,n)})(),Kk=(()=>{let e=Im(j.chown,kk(`FileSystem`,`chown`),Vk(`chown`));return(t,n,r)=>e(t,n,r)})(),qk=(()=>{let e=Im(j.link,kk(`FileSystem`,`link`),Vk(`link`));return(t,n)=>e(t,n)})(),Jk=(()=>{let e=Im(j.mkdir,kk(`FileSystem`,`makeDirectory`),Vk(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),Yk=e=>{let t=Im(j.mkdtemp,kk(`FileSystem`,e),Vk(e));return e=>pp(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?oe.join(e.directory,`.`):ie.tmpdir();return t(n?oe.join(r,n):r+`/`)})},Xk=Yk(`makeTempDirectory`),Zk=e=>{let t=Im(j.rm,kk(`FileSystem`,e),Vk(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Qk=Zk(`remove`),$k=(()=>{let e=Yk(`makeTempDirectoryScoped`),t=Zk(`makeTempDirectoryScoped`);return n=>em(e(n),e=>Mp(t(e,{recursive:!0})))})(),eA=(e=>{let t=Im(j.open,kk(`FileSystem`,e),Vk(e)),n=Im(j.close,kk(`FileSystem`,e),Vk(e));return(e,r)=>tt(em(t(e,r?.flag??`r`,r?.mode),e=>Mp(n(e))),q(e=>tA(MC(e),r?.flag?.startsWith(`a`)??!1)))})(`open`),tA=(()=>{let e=e=>Im(j.read,kk(`FileSystem`,e),Vk(e)),t=e(`read`),n=e(`readAlloc`),r=Im(j.fstat,kk(`FileSystem`,`stat`),Vk(`stat`)),i=Im(j.ftruncate,kk(`FileSystem`,`truncate`),Vk(`truncate`)),a=Im(j.fsync,kk(`FileSystem`,`sync`),Vk(`sync`)),o=e=>Im(j.write,kk(`FileSystem`,e),Vk(e)),s=o(`write`),c=o(`writeAll`);class l{[jC];fd;append;position=0n;constructor(e,t){this[jC]=jC,this.fd=e,this.append=t}get stat(){return q(r(this.fd),uA)}get sync(){return a(this.fd)}seek(e,t){let n=DC(e);return W(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position))}read(e){return pp(()=>{let n=this.position;return q(t(this.fd,{buffer:e,position:n}),e=>{let t=DC(e);return this.position=n+t,t})})}readAlloc(e){let t=Number(e);return pp(()=>{let e=Buffer.allocUnsafeSlow(t),r=this.position;return q(n(this.fd,{buffer:e,position:r}),n=>{if(n===0)return z();if(this.position=r+BigInt(n),n===t)return B(e);let i=Buffer.allocUnsafeSlow(n);return e.copy(i,0,0,n),B(i)})})}truncate(e){return q(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return pp(()=>{let t=this.position;return q(s(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let n=DC(e);return this.append||(this.position=t+n),n})})}writeAllChunk(e){return pp(()=>{let t=this.position;return K(c(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),n=>n===0?G(yS({module:`FileSystem`,method:`writeAll`,_tag:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position=t+BigInt(n)),n<e.length?this.writeAllChunk(e.subarray(n)):mp))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new l(e,t)})(),nA=e=>{let t=Yk(e);return Om(function*(e){let n=yield*t(e),r=ne.randomBytes(6).toString(`hex`),i=oe.join(n,e?.suffix?`${r}${e.suffix}`:r);return yield*_A(i,new Uint8Array),i})},rA=nA(`makeTempFile`),iA=(()=>{let e=nA(`makeTempFileScoped`),t=Zk(`makeTempFileScoped`);return n=>em(e(n),e=>Mp(t(oe.dirname(e),{recursive:!0})))})(),aA=(e,t)=>up({try:()=>j.promises.readdir(e,t),catch:t=>kk(`FileSystem`,`readDirectory`)(t,[e])}),oA=e=>hp((t,n)=>{try{j.readFile(e,{signal:n},(n,r)=>{t(n?G(kk(`FileSystem`,`readFile`)(n,[e])):U(r))})}catch(e){t(G(Vk(`readFile`)(e)))}}),sA=(()=>{let e=Im(j.readlink,kk(`FileSystem`,`readLink`),Vk(`readLink`));return t=>e(t)})(),cA=(()=>{let e=Im(j.realpath,kk(`FileSystem`,`realPath`),Vk(`realPath`));return t=>e(t)})(),lA=(()=>{let e=Im(j.rename,kk(`FileSystem`,`rename`),Vk(`rename`));return(t,n)=>e(t,n)})(),uA=e=>({type:e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,mtime:ii(e.mtime),atime:ii(e.atime),birthtime:ii(e.birthtime),dev:e.dev,rdev:ii(e.rdev),ino:ii(e.ino),mode:e.mode,nlink:ii(e.nlink),uid:ii(e.uid),gid:ii(e.gid),size:DC(e.size),blksize:e.blksize===void 0?z():B(DC(e.blksize)),blocks:ii(e.blocks)}),dA=(()=>{let e=Im(j.stat,kk(`FileSystem`,`stat`),Vk(`stat`));return t=>q(e(t),uA)})(),fA=(()=>{let e=Im(j.symlink,kk(`FileSystem`,`symlink`),Vk(`symlink`));return(t,n)=>e(t,n)})(),pA=(()=>{let e=Im(j.truncate,kk(`FileSystem`,`truncate`),Vk(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),mA=(()=>{let e=Im(j.utimes,kk(`FileSystem`,`utime`),Vk(`utime`));return(t,n,r)=>e(t,n,r)})(),hA=e=>XS(t=>em(W(()=>{let n=j.watch(e,{recursive:!0},(e,n)=>{if(n)switch(e){case`rename`:gm(Up(dA(n),{onSuccess:e=>dy(t,{_tag:`Create`,path:n}),onFailure:e=>dy(t,{_tag:`Remove`,path:n})}));return;case`change`:fy(t,{_tag:`Update`,path:n});return}});return n.on(`error`,n=>{my(t,$u(yS({module:`FileSystem`,_tag:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:n})))}),n.on(`close`,()=>{gy(t)}),n}),e=>W(()=>e.close()))),gA=(e,t)=>dA(t).pipe(q(n=>e.pipe(fi(e=>e.register(t,n)),ri(()=>hA(t)))),tC),_A=(e,t,n)=>hp((r,i)=>{try{j.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?G(kk(`FileSystem`,`writeFile`)(t,[e])):mp)})}catch(e){r(G(Vk(`writeFile`)(e)))}}),vA=q(Jp(NC),e=>AC({access:Hk,chmod:Gk,chown:Kk,copy:Uk,copyFile:Wk,link:qk,makeDirectory:Jk,makeTempDirectory:Xk,makeTempDirectoryScoped:$k,makeTempFile:rA,makeTempFileScoped:iA,open:eA,readDirectory:aA,readFile:oA,readLink:sA,realPath:cA,remove:Qk,rename:lA,stat:dA,symlink:fA,truncate:pA,utimes:mA,watch(t){return gA(e,t)},writeFile:_A})),yA=rf(kC)(vA),bA=e=>yp({try:()=>T.fileURLToPath(e),catch:e=>new gS({module:`Path`,method:`fromFileUrl`,cause:e})}),xA=e=>yp({try:()=>T.pathToFileURL(e),catch:e=>new gS({module:`Path`,method:`toFileUrl`,cause:e})});({...oe.posix}),{...oe.win32};const SA=tf(FC)({[PC]:PC,...oe,fromFileUrl:bA,toFileUrl:xA}),CA=tf($w,eT({args:W(()=>process.argv.slice(2)),stdout:e=>Ak({evaluate:()=>process.stdout,onError:e=>yS({module:`Stdio`,method:`stdout`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>Ak({evaluate:()=>process.stderr,onError:e=>yS({module:`Stdio`,method:`stderr`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stdin:Nk({evaluate:()=>process.stdin,onError:e=>yS({module:`Stdio`,method:`stdin`,_tag:`Unknown`,cause:e}),closeOnDone:!1})})),wA=rf(sT,Om(function*(e=TA){let t=process.stdin,n=process.stdout,r=yield*US({acquire:em(W(()=>{let e=ue.createInterface({input:t,escapeCodeTimeout:50});return ue.emitKeypressEvents(t,e),t.isTTY&&t.setRawMode(!0),e}),e=>W(()=>{t.isTTY&&t.setRawMode(!1),e.close()}))});return cT({columns:W(()=>n.columns??0),readInput:gp(function*(){yield*WS(r);let n=yield*cy(),i=(t,r)=>{let i={input:ai(t),key:{name:r.name??``,ctrl:!!r.ctrl,meta:!!r.meta,shift:!!r.shift}};fy(n,i),e(i)&&gy(n)};return yield*tm(()=>W(()=>t.off(`keypress`,i))),t.on(`keypress`,i),n}),readLine:Qp(K(WS(r),e=>hp(t=>{let n=e=>t(U(e));return e.once(`line`,n),W(()=>e.off(`line`,n))}))),display:e=>sm(hp(t=>{n.write(e,e=>gt(e)?t(mp):t(G(bS({module:`Terminal`,method:`display`,description:`Failed to write prompt to stdout`,cause:e}))))}))})})(TA));function TA(e){return e.key.ctrl&&(e.key.name===`c`||e.key.name===`d`)}const EA=pf(zk,uf(yA,SA,CA,wA)),DA=Y.pipe(Lx(`SessionId`));var OA=class extends lS(`AcpStreamError`)({_tag:Bx(`AcpStreamError`),cause:yx}){message=`Streaming failed: ${this.cause}`},kA=class extends lS(`AcpSessionCreateError`)({_tag:Bx(`AcpSessionCreateError`),cause:yx}){message=`Creating session failed: ${this.cause}`},AA=class extends lS(`AcpConnectionInitError`)({_tag:Bx(`AcpConnectionInitError`),cause:yx}){message=`Init connection failed: ${this.cause}`},jA=class extends lS(`AcpAdapterNotFoundError`)({_tag:Bx(`AcpAdapterNotFoundError`),packageName:Y}){message=`ACP adapter not found: ${this.packageName}`},MA=class t extends Ga()(`@expect/AcpAdapter`){static layerCodex=rf(t)(yp({try:()=>{let n=e(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/codex-acp/bin/codex-acp.js`);return t.of({bin:process.execPath,args:[n],env:{}})},catch:()=>new jA({packageName:`@zed-industries/codex-acp`})}));static layerClaude=rf(t)(yp({try:()=>{let n=e(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/claude-agent-acp/dist/index.js`);return t.of({bin:process.execPath,args:[n],env:{}})},catch:()=>new jA({packageName:`@zed-industries/claude-agent-acp`})}))},NA=class extends Ga()(`@expect/AcpClient`,{make:gp(function*(){let e=yield*MA;yield*Fm({adapter:e.args[0]}),yield*Mm(`Initializing AcpClient`);let t=yield*pk,n=yield*QC(),r=yield*uy(),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(DA.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);fy(n,cx(KT)(t))}},o=yield*_k(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*Fm({pid:o.pid}),yield*Nm(`ACP adapter subprocess spawned`),yield*$S(r).pipe(_C(o.stdin),pm);let s=TC(o.stdout),c=new ik(e=>a,rk(new WritableStream({write:e=>void fy(r,e)}),s)),l=E(import.meta.resolve(`@expect/browser/cli`)),u=[{command:process.execPath,args:[l],env:[],name:`browser`}];yield*Mm(`ACP connection initialized`,{capabilities:(yield*up({try:()=>c.initialize({protocolVersion:1}),catch:e=>new AA({cause:e})})).agentCapabilities,mcpServers:u.map(e=>e.name)});let d=km(`AcpClient.createSession`)(function*(e){return yield*dm({cwd:e}),yield*up({try:()=>c.newSession({cwd:e,mcpServers:u}),catch:e=>new kA({cause:e})}).pipe(q(({sessionId:e})=>DA.makeUnsafe(e)),Cp(e=>gp(function*(){let t=yield*uy();i.set(e,t),yield*Mm(`ACP session created`,{sessionId:e})})))}),f=km(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*vp(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*uy();return i.set(e,t),t});return{createSession:d,stream:km(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r}){let i=ti(t)?t.value:yield*d(r);yield*Nm(`ACP stream starting`,{sessionId:i});let a=yield*f(i);return yield*up({try:()=>c.prompt({sessionId:i,prompt:[{type:`text`,text:e}]}),catch:e=>new OA({cause:e})}).pipe(Cp(()=>Nm(`ACP prompt completed`)),Cp(()=>hy(a)),rw(n,i,{startImmediately:!0})),$S(a)},tC)}})}){static layer=rf(this)(this.make).pipe(ff(EA));static layerCodex=this.layer.pipe(ff(MA.layerCodex));static layerClaude=this.layer.pipe(ff(MA.layerClaude))},PA=class e extends Ga()(`@expect/Agent`){static layerAcp=rf(e)(gp(function*(){let t=yield*NA;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:di(e.sessionId,e=>e),prompt:e.prompt})})})).pipe(ff(NA.layer));static layerCodex=e.layerAcp.pipe(ff(MA.layerCodex));static layerClaude=e.layerAcp.pipe(ff(MA.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>rf(e,gp(function*(){let n=yield*kC,r=lx(KT);return e.of({stream:()=>n.stream(t).pipe(pC(),mC,nC(e=>r(JSON.parse(e))),cC),createSession:()=>vp(`createSession not supported for test layer`)})})).pipe(ff(EA))};const FA=12e3,IA=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}`,``])]:[],LA=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.`]}},RA=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>FA?i.slice(0,FA)+`
34
- ... (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,``,...IA(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(`
10
+ `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}Symbol.asyncDispose;var qu=class{#e;constructor(e,t){let n=e(this);this.#e=new Ju(async(e,t)=>{switch(e){case bc.fs_write_text_file:{let e=Wu.parse(t);return n.writeTextFile?.(e)}case bc.fs_read_text_file:{let e=Vl.parse(t);return n.readTextFile?.(e)}case bc.session_request_permission:{let e=Nu.parse(t);return n.requestPermission(e)}case bc.terminal_create:{let e=Ll.parse(t);return n.createTerminal?.(e)}case bc.terminal_output:{let e=gu.parse(t);return n.terminalOutput?.(e)}case bc.terminal_release:{let e=Hl.parse(t);return await n.releaseTerminal?.(e)??{}}case bc.terminal_wait_for_exit:{let e=Hu.parse(t);return n.waitForTerminalExit?.(e)}case bc.terminal_kill:{let e=zl.parse(t);return await n.killTerminal?.(e)??{}}default:if(n.extMethod)return n.extMethod(e,t);throw Yu.methodNotFound(e)}},async(e,t)=>{switch(e){case bc.session_update:{let e=Vu.parse(t);return n.sessionUpdate(e)}default:if(n.extNotification)return n.extNotification(e,t);throw Yu.methodNotFound(e)}},t)}async initialize(e){return await this.#e.sendRequest(yc.initialize,e)}async newSession(e){return await this.#e.sendRequest(yc.session_new,e)}async loadSession(e){return await this.#e.sendRequest(yc.session_load,e)??{}}async unstable_forkSession(e){return await this.#e.sendRequest(yc.session_fork,e)}async listSessions(e){return await this.#e.sendRequest(yc.session_list,e)}async unstable_resumeSession(e){return await this.#e.sendRequest(yc.session_resume,e)}async unstable_closeSession(e){return await this.#e.sendRequest(yc.session_close,e)}async setSessionMode(e){return await this.#e.sendRequest(yc.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await this.#e.sendRequest(yc.session_set_model,e)??{}}async setSessionConfigOption(e){return await this.#e.sendRequest(yc.session_set_config_option,e)}async authenticate(e){return await this.#e.sendRequest(yc.authenticate,e)??{}}async prompt(e){return await this.#e.sendRequest(yc.session_prompt,e)}async cancel(e){return await this.#e.sendNotification(yc.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}},Ju=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 Yu)return e.toResult();if(e instanceof wa.ZodError)return Yu.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 Yu.internalError(t?JSON.parse(t):{}).toResult()}catch{return Yu.internalError({details:t}).toResult()}}}async#d(e,t){try{return await this.#r(e,t),{result:null}}catch(e){if(e instanceof Yu)return e.toResult();if(e instanceof wa.ZodError)return Yu.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 Yu.internalError(t?JSON.parse(t):{}).toResult()}catch{return Yu.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}},Yu=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 Xu=Ke({name:B,value:B});var Zu=class extends Gi(`AgentStreamOptions`)({cwd:B,sessionId:Qe(B),prompt:B,systemPrompt:Qe(B),mcpEnv:z($n(Xu))}){};const Qu=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return Pr({_tag:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})},$u=e=>Si(s(ed(e),e=>[e])),ed=e=>on(t=>{let n=e.evaluate();return V(td({...e,writable:n,pull:t}))}),td=e=>e.pull.pipe(Qt(t=>{let n=0;return pt(function r(i){for(;n<t.length;)if(!e.writable.write(t[n++],e.encoding)){e.writable.once(`drain`,()=>r(i));return}i(R)})}),a({disableYield:!0}),Wi(pt(t=>{let n=n=>t(je(e.onError(n)));return e.writable.once(`error`,n),F(()=>{e.writable.off(`error`,n)})})),e.endOnDone===!1?Bt:Jt(t=>`closed`in e.writable&&e.writable.closed?We(t):pt(n=>{e.writable.once(`finish`,()=>n(We(t))),e.writable.end()}))),nd=e=>ut(rd(e)),rd=e=>on((t,n)=>id({scope:n,readable:e.evaluate(),onError:e.onError??ad,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),id=e=>{let t=e.readable;if(t.readableEnded)return V(We());let n=e.closeOnDone??!0,r=e.exit??rr(void 0),i=Zn(!1);function a(){i.openUnsafe()}function o(t){r.current=ee(e.onError(t)),i.openUnsafe()}function s(){r.current=ee(u()),i.openUnsafe()}t.on(`readable`,a),t.once(`error`,o),t.once(`end`,s);let c=rt(function t(){let n=e.readable.read(e.chunkSize);if(n===null)return r.current?r.current:(i.closeUnsafe(),Qt(i.await,t));let a=Mn(n);for(;n=e.readable.read(e.chunkSize),n!==null;)a.push(n);return V(a)});return be(qr(e.scope,F(()=>{t.off(`readable`,a),t.off(`error`,o),t.off(`end`,s),n&&`closed`in e.readable&&!e.readable.closed&&e.readable.destroy()})),c)},ad=e=>new ze(e),od=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),sd=(e,t,n)=>{let{commands:r}=ld(n),i=r.reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return Qu(`ChildProcess`,e)(t,[i])},cd=sr(Hn,H(function*(){let e=yield*qe,t=yield*St,n=rn(function*(n){if(!qi(n.cwd))return yield*e.access(n.cwd),t.resolve(n.cwd)}),r=e=>e.extendEnv?{...globalThis.process.env,...e.env}:e.env,i=e=>Pt(e)?`pipe`:e,a=e=>In(e)?`pipe`:e,o=e=>{let t={stream:`pipe`,encoding:`utf-8`,endOnDone:!0};return qi(e.stdin)?t:typeof e.stdin==`string`||Pt(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},s=(e,t)=>{let n=e[t];return qi(n)?{stream:`pipe`}:typeof n==`string`||In(n)?{stream:n}:{stream:n.stream}},c=e=>{if(qi(e.additionalFds))return[];let t=[];for(let[n,r]of Object.entries(e.additionalFds)){let e=jn(n);ve(e)&&t.push({fd:e,config:r})}return t.sort((e,t)=>e.fd-t.fd)},l=(e,t,n,r)=>{let o=[i(e.stream),a(t.stream),a(n.stream)];if(r.length===0)return o;let s=r.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=s;e++)o[e]=`ignore`;for(let{fd:e}of r)o[e]=`pipe`;return o},u=rn(function*(e,t,n){if(n.length===0)return{getInputFd:()=>Or,getOutputFd:()=>ae};let r=new Map,i=new Map;for(let{config:a,fd:o}of n){let n=t.stdio[o];switch(a.type){case`input`:{let t=Or;n&&`write`in n&&(t=$u({evaluate:()=>n,onError:t=>sd(`fromWritable(fd${o})`,od(t),e)})),a.stream&&(yield*gi(Gt(a.stream,t))),r.set(o,t);break}case`output`:{let t=ae;n&&`read`in n&&(t=nd({evaluate:()=>n,onError:t=>sd(`fromReadable(fd${o})`,od(t),e)})),a.sink&&(t=vn(t,a.sink)),i.set(o,t);break}}}return{getInputFd:e=>r.get(e)??Or,getOutputFd:e=>i.get(e)??ae}}),d=(e,t,n)=>rt(()=>{let r=Or;return N(t.stdin)&&(r=$u({evaluate:()=>t.stdin,onError:t=>sd(`fromWritable(stdin)`,od(t),e),endOnDone:n.endOnDone,encoding:n.encoding})),Pt(n.stream)?be(gi(Gt(n.stream,r)),r):V(r)}),f=(e,t,n,r)=>{let i=t.stdout?nd({evaluate:()=>t.stdout,onError:t=>sd(`fromReadable(stdout)`,od(t),e)}):ae,a=t.stderr?nd({evaluate:()=>t.stderr,onError:t=>sd(`fromReadable(stderr)`,od(t),e)}):ae;In(n.stream)&&(i=vn(i,n.stream)),In(r.stream)&&(a=vn(a,r.stream));let o=Oe(i,a);return{stdout:i,stderr:a,all:o}},p=(e,t)=>pt(n=>{let r=vt(),i=Ta.spawn(e.command,e.args,t);return i.on(`error`,t=>{n(je(sd(`spawn`,t,e)))}),i.on(`exit`,(...e)=>{Ti(r,Ye(e))}),i.on(`spawn`,()=>{n(V([i,r]))}),F(()=>{i.kill(`SIGTERM`)})}),m=(e,t,n)=>globalThis.process.platform===`win32`?pt(n=>{Ta.exec(`taskkill /pid ${t.pid} /T /F`,t=>{n(t?je(sd(`kill`,od(t),e)):R)})}):Ut({try:()=>{globalThis.process.kill(-t.pid,n)},catch:t=>sd(`kill`,od(t),e)}),h=(e,t,n)=>rt(()=>t.kill(n)?R:je(sd(`kill`,new globalThis.Error(`Failed to kill child process`),e))),g=(e,t,n)=>r=>{let i=n?.killSignal??`SIGTERM`;return qi(n?.forceKillAfter)?r(t,e,i):Rt(r(t,e,i),{duration:n.forceKillAfter,onTimeout:()=>r(t,e,`SIGKILL`)})},_=(e,t)=>{let n=t??`stdout`;switch(n){case`stdout`:return e.stdout;case`stderr`:return e.stderr;case`all`:return e.all;default:{let t=jn(n);return ve(t)?e.getOutputFd(t):e.stdout}}},v=rn(function*(e){switch(e._tag){case`StandardCommand`:{let t=o(e.options),i=s(e.options,`stdout`),a=s(e.options,`stderr`),_=c(e.options),[v,y]=yield*br(p(e,{cwd:yield*n(e.options),env:r(e.options),stdio:l(t,i,a,_),detached:e.options.detached??process.platform!==`win32`,shell:e.options.shell}),rn(function*([t,n]){let r=yield*xn(n),i=g(t,e,e.options);if(r){let[e]=yield*Xn(n);return e!==0&&N(e)?yield*ii(i(m)):yield*R}return yield*i((e,t,n)=>me(m(e,t,n),()=>h(e,t,n))).pipe(Be(Xn(n)),ii)})),b=kr(v.pid),x=yield*d(e,v,t),{all:ee,stderr:S,stdout:C}=f(e,v,i,a),{getInputFd:w,getOutputFd:te}=yield*u(e,v,_),T=U(xn(y),e=>!e);return Jn({pid:b,exitCode:Qt(Xn(y),([t,n])=>N(t)?V(Gr(t)):je(sd(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: '${n}'`),e))),isRunning:T,kill:t=>g(v,e,t)((e,t,n)=>me(m(e,t,n),()=>h(e,t,n))).pipe(Be(Xn(y)),Pe),stdin:x,stdout:C,stderr:S,all:ee,getInputFd:w,getOutputFd:te})}case`PipedCommand`:{let{commands:t,pipeOptions:n}=ld(e),[r,...i]=t,a=v(r);for(let e=0;e<i.length;e++){let t=i[e],r=n[e]??{},s=o(t.options),c=Wr(U(a,e=>_(e,r.from))),l=r.to??`stdin`;if(l===`stdin`)a=v(vi(t.command,t.args,{...t.options,stdin:{...s,stream:c}}));else{let e=jn(l);if(ve(e)){let n=Cr(e),r=t.options.additionalFds??{};a=v(vi(t.command,t.args,{...t.options,additionalFds:{...r,[n]:{type:`input`,stream:c}}}))}else a=v(vi(t.command,t.args,{...t.options,stdin:{...s,stream:c}}))}}return yield*a}}});return er(v)})),ld=e=>{let t=[],n=[],r=e=>{switch(e._tag){case`StandardCommand`:t.push(e);break;case`PipedCommand`:r(e.left),n.push(e.options),r(e.right);break}};if(r(e),t.length===0)throw Error(`flattenCommand produced empty commands array`);let[i,...a]=t;return{commands:[i,...a],pipeOptions:n}},ud=e=>t=>Yr({module:`FileSystem`,method:e,description:t.message??String(t)}),dd=(()=>{let e=I(ja.access,Qu(`FileSystem`,`access`),ud(`access`));return(t,n)=>{let r=ja.constants.F_OK;return n?.readable&&(r|=ja.constants.R_OK),n?.writable&&(r|=ja.constants.W_OK),e(t,r)}})(),fd=(()=>{let e=I(ja.cp,Qu(`FileSystem`,`copy`),ud(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),pd=(()=>{let e=I(ja.copyFile,Qu(`FileSystem`,`copyFile`),ud(`copyFile`));return(t,n)=>e(t,n)})(),md=(()=>{let e=I(ja.chmod,Qu(`FileSystem`,`chmod`),ud(`chmod`));return(t,n)=>e(t,n)})(),hd=(()=>{let e=I(ja.chown,Qu(`FileSystem`,`chown`),ud(`chown`));return(t,n,r)=>e(t,n,r)})(),gd=(()=>{let e=I(ja.link,Qu(`FileSystem`,`link`),ud(`link`));return(t,n)=>e(t,n)})(),_d=(()=>{let e=I(ja.mkdir,Qu(`FileSystem`,`makeDirectory`),ud(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),vd=e=>{let t=I(ja.mkdtemp,Qu(`FileSystem`,e),ud(e));return e=>rt(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?_a.join(e.directory,`.`):Na.tmpdir();return t(n?_a.join(r,n):r+`/`)})},yd=vd(`makeTempDirectory`),bd=e=>{let t=I(ja.rm,Qu(`FileSystem`,e),ud(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},xd=bd(`remove`),Sd=(()=>{let e=vd(`makeTempDirectoryScoped`),t=bd(`makeTempDirectoryScoped`);return n=>br(e(n),e=>ir(t(e,{recursive:!0})))})(),Cd=(e=>{let t=I(ja.open,Qu(`FileSystem`,e),ud(e)),n=I(ja.close,Qu(`FileSystem`,e),ud(e));return(e,r)=>le(br(t(e,r?.flag??`r`,r?.mode),e=>ir(n(e))),U(e=>wd(te(e),r?.flag?.startsWith(`a`)??!1)))})(`open`),wd=(()=>{let e=e=>I(ja.read,Qu(`FileSystem`,e),ud(e)),t=e(`read`),n=e(`readAlloc`),r=I(ja.fstat,Qu(`FileSystem`,`stat`),ud(`stat`)),i=I(ja.ftruncate,Qu(`FileSystem`,`truncate`),ud(`truncate`)),a=I(ja.fsync,Qu(`FileSystem`,`sync`),ud(`sync`)),o=e=>I(ja.write,Qu(`FileSystem`,e),ud(e)),s=o(`write`),l=o(`writeAll`);class u{[_r];fd;append;position=0n;constructor(e,t){this[_r]=_r,this.fd=e,this.append=t}get stat(){return U(r(this.fd),Nd)}get sync(){return a(this.fd)}seek(e,t){let n=c(e);return F(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position))}read(e){return rt(()=>{let n=this.position;return U(t(this.fd,{buffer:e,position:n}),e=>{let t=c(e);return this.position=n+t,t})})}readAlloc(e){let t=Number(e);return rt(()=>{let e=Buffer.allocUnsafeSlow(t),r=this.position;return U(n(this.fd,{buffer:e,position:r}),n=>{if(n===0)return Ct();if(this.position=r+BigInt(n),n===t)return A(e);let i=Buffer.allocUnsafeSlow(n);return e.copy(i,0,0,n),A(i)})})}truncate(e){return U(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return rt(()=>{let t=this.position;return U(s(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let n=c(e);return this.append||(this.position=t+n),n})})}writeAllChunk(e){return rt(()=>{let t=this.position;return Qt(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),n=>n===0?je(Pr({module:`FileSystem`,method:`writeAll`,_tag:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position=t+BigInt(n)),n<e.length?this.writeAllChunk(e.subarray(n)):R))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new u(e,t)})(),Td=e=>{let t=vd(e);return rn(function*(e){let n=yield*t(e),r=ka.randomBytes(6).toString(`hex`),i=_a.join(n,e?.suffix?`${r}${e.suffix}`:r);return yield*Bd(i,new Uint8Array),i})},Ed=Td(`makeTempFile`),Dd=(()=>{let e=Td(`makeTempFileScoped`),t=bd(`makeTempFileScoped`);return n=>br(e(n),e=>ir(t(_a.dirname(e),{recursive:!0})))})(),Od=(e,t)=>Mt({try:()=>ja.promises.readdir(e,t),catch:t=>Qu(`FileSystem`,`readDirectory`)(t,[e])}),kd=e=>pt((t,n)=>{try{ja.readFile(e,{signal:n},(n,r)=>{t(n?je(Qu(`FileSystem`,`readFile`)(n,[e])):V(r))})}catch(e){t(je(ud(`readFile`)(e)))}}),Ad=(()=>{let e=I(ja.readlink,Qu(`FileSystem`,`readLink`),ud(`readLink`));return t=>e(t)})(),jd=(()=>{let e=I(ja.realpath,Qu(`FileSystem`,`realPath`),ud(`realPath`));return t=>e(t)})(),Md=(()=>{let e=I(ja.rename,Qu(`FileSystem`,`rename`),ud(`rename`));return(t,n)=>e(t,n)})(),Nd=e=>({type:e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,mtime:Yn(e.mtime),atime:Yn(e.atime),birthtime:Yn(e.birthtime),dev:e.dev,rdev:Yn(e.rdev),ino:Yn(e.ino),mode:e.mode,nlink:Yn(e.nlink),uid:Yn(e.uid),gid:Yn(e.gid),size:c(e.size),blksize:e.blksize===void 0?Ct():A(c(e.blksize)),blocks:Yn(e.blocks)}),Pd=(()=>{let e=I(ja.stat,Qu(`FileSystem`,`stat`),ud(`stat`));return t=>U(e(t),Nd)})(),Fd=(()=>{let e=I(ja.symlink,Qu(`FileSystem`,`symlink`),ud(`symlink`));return(t,n)=>e(t,n)})(),Id=(()=>{let e=I(ja.truncate,Qu(`FileSystem`,`truncate`),ud(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),Ld=(()=>{let e=I(ja.utimes,Qu(`FileSystem`,`utime`),ud(`utime`));return(t,n,r)=>e(t,n,r)})(),Rd=e=>He(t=>br(F(()=>{let n=ja.watch(e,{recursive:!0},(e,n)=>{if(n)switch(e){case`rename`:Ri(Kn(Pd(n),{onSuccess:e=>Er(t,{_tag:`Create`,path:n}),onFailure:e=>Er(t,{_tag:`Remove`,path:n})}));return;case`change`:xi(t,{_tag:`Update`,path:n});return}});return n.on(`error`,n=>{li(t,tt(Pr({module:`FileSystem`,_tag:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:n})))}),n.on(`close`,()=>{gn(t)}),n}),e=>F(()=>e.close()))),zd=(e,t)=>Pd(t).pipe(U(n=>e.pipe(tr(e=>e.register(t,n)),wi(()=>Rd(t)))),Wr),Bd=(e,t,n)=>pt((r,i)=>{try{ja.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?je(Qu(`FileSystem`,`writeFile`)(t,[e])):R)})}catch(e){r(je(ud(`writeFile`)(e)))}}),Vd=U(f(dr),e=>Le({access:dd,chmod:md,chown:hd,copy:fd,copyFile:pd,link:gd,makeDirectory:_d,makeTempDirectory:yd,makeTempDirectoryScoped:Sd,makeTempFile:Ed,makeTempFileScoped:Dd,open:Cd,readDirectory:Od,readFile:kd,readLink:Ad,realPath:jd,remove:xd,rename:Md,stat:Pd,symlink:Fd,truncate:Id,utimes:Ld,watch(t){return zd(e,t)},writeFile:Bd})),Hd=sr(qe)(Vd),Ud=e=>Ut({try:()=>xa.fileURLToPath(e),catch:e=>new qn({module:`Path`,method:`fromFileUrl`,cause:e})}),Wd=e=>Ut({try:()=>xa.pathToFileURL(e),catch:e=>new qn({module:`Path`,method:`toFileUrl`,cause:e})});({..._a.posix}),{..._a.win32};const Gd=bi(St)({[k]:k,..._a,fromFileUrl:Ud,toFileUrl:Wd}),Kd=bi(Ro,zo({args:F(()=>process.argv.slice(2)),stdout:e=>$u({evaluate:()=>process.stdout,onError:e=>Pr({module:`Stdio`,method:`stdout`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>$u({evaluate:()=>process.stderr,onError:e=>Pr({module:`Stdio`,method:`stderr`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stdin:nd({evaluate:()=>process.stdin,onError:e=>Pr({module:`Stdio`,method:`stdin`,_tag:`Unknown`,cause:e}),closeOnDone:!1})})),qd=sr(Ko,rn(function*(e=Jd){let t=process.stdin,n=process.stdout,r=yield*An({acquire:br(F(()=>{let e=Fa.createInterface({input:t,escapeCodeTimeout:50});return Fa.emitKeypressEvents(t,e),t.isTTY&&t.setRawMode(!0),e}),e=>F(()=>{t.isTTY&&t.setRawMode(!1),e.close()}))});return qo({columns:F(()=>n.columns??0),readInput:H(function*(){yield*di(r);let n=yield*On(),i=(t,r)=>{let i={input:cn(t),key:{name:r.name??``,ctrl:!!r.ctrl,meta:!!r.meta,shift:!!r.shift}};xi(n,i),e(i)&&gn(n)};return yield*d(()=>F(()=>t.off(`keypress`,i))),t.on(`keypress`,i),n}),readLine:Ze(Qt(di(r),e=>pt(t=>{let n=e=>t(V(e));return e.once(`line`,n),F(()=>e.off(`line`,n))}))),display:e=>L(pt(t=>{n.write(e,e=>Me(e)?t(R):t(je(Yr({module:`Terminal`,method:`display`,description:`Failed to write prompt to stdout`,cause:e}))))}))})})(Jd));function Jd(e){return e.key.ctrl&&(e.key.name===`c`||e.key.name===`d`)}const Yd=Tr(cd,ci(Hd,Gd,Kd,qd)),Xd=B.pipe(y(`SessionId`));var Zd=class extends xt(`AcpStreamError`)({_tag:De(`AcpStreamError`),cause:Zi}){message=`Streaming failed: ${this.cause}`},Qd=class extends xt(`AcpSessionCreateError`)({_tag:De(`AcpSessionCreateError`),cause:Zi}){message=`Creating session failed: ${this.cause}`},$d=class extends xt(`AcpConnectionInitError`)({_tag:De(`AcpConnectionInitError`),cause:Zi}){message=`Init connection failed: ${this.cause}`},ef=class extends xt(`AcpAdapterNotFoundError`)({_tag:De(`AcpAdapterNotFoundError`),packageName:B}){message=`ACP adapter not found: ${this.packageName}`},tf=class e extends Zr()(`@expect/AcpAdapter`){static layerCodex=sr(e)(Ut({try:()=>{let t=Qi(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/codex-acp/bin/codex-acp.js`);return e.of({bin:process.execPath,args:[t],env:{}})},catch:()=>new ef({packageName:`@zed-industries/codex-acp`})}));static layerClaude=sr(e)(Ut({try:()=>{let t=Qi(typeof __filename<`u`?__filename:import.meta.url).resolve(`@zed-industries/claude-agent-acp/dist/index.js`);return e.of({bin:process.execPath,args:[t],env:{}})},catch:()=>new ef({packageName:`@zed-industries/claude-agent-acp`})}))},nf=class extends Zr()(`@expect/AcpClient`,{make:H(function*(){let e=yield*tf;yield*P({adapter:e.args[0]}),yield*kn(`Initializing AcpClient`);let t=yield*Hn,n=yield*So(),r=yield*Pn(),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(Xd.makeUnsafe(e));if(n===void 0)return console.warn(`updates queue not found for session ${e}`);xi(n,Nt(Ps)(t))}},o=yield*vi(e.bin,e.args,{env:e.env}).pipe(t.spawn);yield*P({pid:o.pid}),yield*Ur(`ACP adapter subprocess spawned`),yield*m(r).pipe(Gt(o.stdin),gi);let s=ur(o.stdout),c=new qu(e=>a,Ku(new WritableStream({write:e=>void xi(r,e)}),s)),l=Sa(new URL(`./browser-mcp.js`,import.meta.url)),u=e=>[{command:process.execPath,args:[l],env:[...e],name:`browser`}];yield*kn(`ACP connection initialized`,{capabilities:(yield*Mt({try:()=>c.initialize({protocolVersion:1}),catch:e=>new $d({cause:e})})).agentCapabilities});let d=qt(`AcpClient.createSession`)(function*(e,t=[]){yield*Ge({cwd:e});let n=u(t);return yield*Mt({try:()=>c.newSession({cwd:e,mcpServers:n}),catch:e=>new Qd({cause:e})}).pipe(U(({sessionId:e})=>Xd.makeUnsafe(e)),xe(e=>H(function*(){let t=yield*Pn();i.set(e,t),yield*kn(`ACP session created`,{sessionId:e})})))}),f=qt(`AcpClient.getQueueBySessionId`)(function*(e){if(!i.has(e))return yield*Ht(`Session ${e} not initialized, did you forget to call createSession?`);let t=yield*Pn();return i.set(e,t),t});return{createSession:d,stream:qt(`AcpClient.stream`)(function*({prompt:e,sessionId:t,cwd:r,mcpEnv:i=[]}){let a=_t(t)?t.value:yield*d(r,i);yield*Ur(`ACP stream starting`,{sessionId:a});let o=yield*f(a);return yield*Mt({try:()=>c.prompt({sessionId:a,prompt:[{type:`text`,text:e}]}),catch:e=>new Zd({cause:e})}).pipe(xe(()=>Ur(`ACP prompt completed`)),xe(()=>cr(o)),Do(n,a,{startImmediately:!0})),m(o)},Wr)}})}){static layer=sr(this)(this.make).pipe(Dn(Yd));static layerCodex=this.layer.pipe(Dn(tf.layerCodex));static layerClaude=this.layer.pipe(Dn(tf.layerClaude))},rf=class e extends Zr()(`@expect/Agent`){static layerAcp=sr(e)(H(function*(){let t=yield*nf;return e.of({createSession:e=>t.createSession(e),stream:e=>t.stream({cwd:e.cwd,sessionId:x(e.sessionId,e=>e),prompt:e.prompt,mcpEnv:e.mcpEnv})})})).pipe(Dn(nf.layer));static layerCodex=e.layerAcp.pipe(Dn(tf.layerCodex));static layerClaude=e.layerAcp.pipe(Dn(tf.layerClaude));static layerFor=t=>t===`claude`?e.layerClaude:e.layerCodex;static layerTest=t=>sr(e,H(function*(){let n=yield*qe,r=ge(Ps);return e.of({stream:()=>n.stream(t).pipe($e(),Vn,de(e=>r(JSON.parse(e))),Ce),createSession:()=>Ht(`createSession not supported for test layer`)})})).pipe(Dn(Yd))};const af=[`claude`,`codex`,`cursor`],of=e=>{try{return Oa(`which ${e}`,{stdio:`pipe`}),!0}catch{return!1}},sf=()=>af.filter(of),cf=12e3,lf=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}`,``])]:[],uf=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.`]}},df=e=>{let t=e.browserMcpServerName??`browser`,n=e.changedFiles.slice(0,12),r=e.recentCommits.slice(0,5),i=e.diffPreview||``,a=i.length>cf?i.slice(0,cf)+`
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,``,...lf(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(`
35
12
  `):`- No changed files detected`,``,`Recent commits:`,r.length>0?r.map(e=>`- ${e.shortHash} ${e.subject}`).join(`
36
- `):`- No recent commits available`,``,`Diff preview:`,a||`No diff preview available`,``,`Scope strategy:`,...LA(e.scope)].join(`
37
- `)};var zA=Ue(((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`:``)}})),BA=Ue(((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=zA(),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})),VA=Ue(((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=BA()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),HA=Ue(((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)}})),UA=Ue(((e,t)=>{let n=Ke(`os`),r=Ke(`tty`),i=HA(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){return s(c(e,e&&e.isTTY))}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})),WA=Ue(((e,t)=>{let n=Ke(`tty`),r=Ke(`util`);e.init=u,e.log=s,e.formatArgs=a,e.save=c,e.load=l,e.useColors=i,e.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=UA();t&&(t.stderr||t).level>=2&&(e.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{}e.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 i(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:n.isatty(process.stderr.fd)}function a(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \u001B[0m`;e[0]=a+e[0].split(`
13
+ `):`- No recent commits available`,``,`Diff preview:`,a||`No diff preview available`,``,`Scope strategy:`,...uf(e.scope)].join(`
14
+ `)};var ff=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`:``)}})),pf=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=ff(),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})),mf=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=pf()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),hf=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)}})),gf=n(((t,n)=>{let r=e(`os`),i=e(`tty`),a=hf(),{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)))}})),_f=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=gf();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(`
38
15
  `).join(`
39
- `+a),e.push(i+`m+`+t.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=o()+n+` `+e[0]}function o(){return e.inspectOpts.hideDate?``:new Date().toISOString()+` `}function s(...t){return process.stderr.write(r.formatWithOptions(e.inspectOpts,...t)+`
40
- `)}function c(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function l(){return process.env.DEBUG}function u(t){t.inspectOpts={};let n=Object.keys(e.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=e.inspectOpts[n[r]]}t.exports=BA()(e);let{formatters:d}=t.exports;d.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split(`
41
- `).map(e=>e.trim()).join(` `)},d.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}})),GA=Ue(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=VA():t.exports=WA()})),KA=Ue((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0});let n=Ke(`fs`),r=t(GA()).default(`@kwsites/file-exists`);function i(e,t,i){r(`checking %s`,e);try{let a=n.statSync(e);return a.isFile()&&t?(r(`[OK] path represents a file`),!0):a.isDirectory()&&i?(r(`[OK] path represents a directory`),!0):(r(`[FAIL] path represents something other than a file or directory`),!1)}catch(e){if(e.code===`ENOENT`)return r(`[FAIL] path is not accessible: %o`,e),!1;throw r(`[FATAL] %o`,e),e}}function a(t,n=e.READABLE){return i(t,(n&e.FILE)>0,(n&e.FOLDER)>0)}e.exists=a,e.FILE=1,e.FOLDER=2,e.READABLE=e.FILE+e.FOLDER})),qA=Ue((e=>{function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,`__esModule`,{value:!0}),t(KA())})),JA=Ue((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})),YA=qA(),XA=Ge(GA(),1),ZA=JA(),QA=Object.defineProperty,$A=Object.getOwnPropertyDescriptor,ej=Object.getOwnPropertyNames,tj=Object.prototype.hasOwnProperty,Z=(e,t)=>function(){return e&&(t=(0,e[ej(e)[0]])(e=0)),t},nj=(e,t)=>function(){return t||(0,e[ej(e)[0]])((t={exports:{}}).exports,t),t.exports},rj=(e,t)=>{for(var n in t)QA(e,n,{get:t[n],enumerable:!0})},ij=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of ej(t))!tj.call(e,i)&&i!==n&&QA(e,i,{get:()=>t[i],enumerable:!(r=$A(t,i))||r.enumerable});return e},aj=e=>ij(QA({},`__esModule`,{value:!0}),e);function oj(...e){let t=new String(e);return lj.set(t,e),t}function sj(e){return e instanceof String&&lj.has(e)}function cj(e){return lj.get(e)||[]}var lj,uj=Z({"src/lib/args/pathspec.ts"(){lj=new WeakMap}}),dj,fj=Z({"src/lib/errors/git-error.ts"(){dj=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),pj,mj=Z({"src/lib/errors/git-response-error.ts"(){fj(),pj=class extends dj{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),hj,gj=Z({"src/lib/errors/task-configuration-error.ts"(){fj(),hj=class extends dj{constructor(e){super(void 0,e)}}}});function _j(e){return typeof e==`function`?e:zj}function vj(e){return typeof e==`function`&&e!==zj}function yj(e,t){let n=e.indexOf(t);return n<=0?[e,``]:[e.substr(0,n),e.substr(n+1)]}function bj(e,t=0){return Sj(e)&&e.length>t?e[t]:void 0}function xj(e,t=0){if(Sj(e)&&e.length>t)return e[e.length-1-t]}function Sj(e){return Xj(e)}function Cj(e=``,t=!0,n=`
42
- `){return e.split(n).reduce((e,n)=>{let r=t?n.trim():n;return r&&e.push(r),e},[])}function wj(e,t){return Cj(e,!0).map(e=>t(e))}function Tj(e){return(0,YA.exists)(e,YA.FOLDER)}function Ej(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function Dj(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function Oj(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function kj(e){return Array.isArray(e)?e:[e]}function Aj(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function jj(e){return kj(e).map(e=>e instanceof String?e:String(e))}function Mj(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function Nj(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function Pj(e){return(Array.isArray(e)?me.concat(e):e).toString(`utf-8`)}function Fj(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function Ij(e=0){return new Promise(t=>setTimeout(t,e))}function Lj(e){if(e!==!1)return e}var Rj,zj,Bj,Vj=Z({"src/lib/utils/util.ts"(){Zj(),Rj=`\0`,zj=()=>{},Bj=Object.prototype.toString.call.bind(Object.prototype.toString)}});function Hj(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function Uj(e,t){let n=sj(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function Wj(e){return!!e&&Bj(e)===`[object Object]`}function Gj(e){return typeof e==`function`}var Kj,qj,Jj,Yj,Xj,Zj=Z({"src/lib/utils/argument-filters.ts"(){uj(),Vj(),Kj=e=>Array.isArray(e),qj=e=>typeof e==`number`,Jj=e=>typeof e==`string`||sj(e),Yj=e=>Jj(e)||Array.isArray(e)&&e.every(Jj),Xj=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),Qj,$j=Z({"src/lib/utils/exit-codes.ts"(){Qj=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(Qj||{})}}),eM,tM=Z({"src/lib/utils/git-output-streams.ts"(){eM=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function nM(){throw Error(`LineParser:useMatches not implemented`)}var Q,rM,iM=Z({"src/lib/utils/line-parser.ts"(){Q=class{constructor(e,t){this.matches=[],this.useMatches=nM,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))}},rM=class extends Q{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 aM(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...oM},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var oM,sM=Z({"src/lib/utils/simple-git-options.ts"(){oM={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function cM(e,t=[]){return Wj(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(sj(r))t.push(r);else if(Uj(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)Uj(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function lM(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 cM(dM(e),r),n||r.push(...uM(e)),r}function uM(e){return jj(Hj(xj(e,typeof xj(e)==`function`?1:0),Kj,[]))}function dM(e){return Hj(xj(e,Gj(xj(e))?1:0),Wj)}function fM(e,t=!0){let n=_j(xj(e));return t||vj(n)?n:void 0}var pM=Z({"src/lib/utils/task-options.ts"(){Zj(),Vj(),uj()}});function mM(e,t){return e(t.stdOut,t.stdErr)}function hM(e,t,n,r=!0){return kj(n).forEach(n=>{for(let i=Cj(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 gM=Z({"src/lib/utils/task-parser.ts"(){Vj()}}),_M={};rj(_M,{ExitCodes:()=>Qj,GitOutputStreams:()=>eM,LineParser:()=>Q,NOOP:()=>zj,NULL:()=>Rj,RemoteLineParser:()=>rM,append:()=>Ej,appendTaskOptions:()=>cM,asArray:()=>kj,asCamelCase:()=>Aj,asFunction:()=>_j,asNumber:()=>Mj,asStringArray:()=>jj,bufferToString:()=>Pj,callTaskParser:()=>mM,createInstanceConfig:()=>aM,delay:()=>Ij,filterArray:()=>Kj,filterFunction:()=>Gj,filterHasLength:()=>Xj,filterNumber:()=>qj,filterPlainObject:()=>Wj,filterPrimitives:()=>Uj,filterString:()=>Jj,filterStringOrStringArray:()=>Yj,filterType:()=>Hj,first:()=>bj,folderExists:()=>Tj,forEachLineWithContent:()=>wj,getTrailingOptions:()=>lM,including:()=>Dj,isUserFunction:()=>vj,last:()=>xj,objectToString:()=>Bj,orVoid:()=>Lj,parseStringResponse:()=>hM,pick:()=>Fj,prefixedArray:()=>Nj,remove:()=>Oj,splitOn:()=>yj,toLinesWithContent:()=>Cj,trailingFunctionArgument:()=>fM,trailingOptionsArgument:()=>dM});var $=Z({"src/lib/utils/index.ts"(){Zj(),$j(),tM(),iM(),sM(),pM(),gM(),Vj()}}),vM={};rj(vM,{CheckRepoActions:()=>CM,checkIsBareRepoTask:()=>xM,checkIsRepoRootTask:()=>bM,checkIsRepoTask:()=>yM});function yM(e){switch(e){case`bare`:return xM();case`root`:return bM()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:wM,parser:TM}}function bM(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:wM,parser(e){return/^\.(git)?$/.test(e.trim())}}}function xM(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:wM,parser:TM}}function SM(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var CM,wM,TM,EM=Z({"src/lib/tasks/check-is-repo.ts"(){$(),CM=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(CM||{}),wM=({exitCode:e},t,n,r)=>{if(e===128&&SM(t))return n(Buffer.from(`false`));r(t)},TM=e=>e.trim()===`true`}});function DM(e,t){let n=new OM(e),r=e?AM:kM;return Cj(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(jM.test(t)?n.folders:n.files).push(t)}),n}var OM,kM,AM,jM,MM=Z({"src/lib/responses/CleanSummary.ts"(){$(),OM=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},kM=/^[a-z]+\s*/i,AM=/^[a-z]+\s+[a-z]+\s*/i,jM=/\/$/}}),NM={};rj(NM,{EMPTY_COMMANDS:()=>BM,adhocExecTask:()=>PM,configurationErrorTask:()=>FM,isBufferTask:()=>RM,isEmptyTask:()=>zM,straightThroughBufferTask:()=>LM,straightThroughStringTask:()=>IM});function PM(e){return{commands:BM,format:`empty`,parser:e}}function FM(e){return{commands:BM,format:`empty`,parser(){throw typeof e==`string`?new hj(e):e}}}function IM(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function LM(e){return{commands:e,format:`buffer`,parser(e){return e}}}function RM(e){return e.format===`buffer`}function zM(e){return e.format===`empty`||!e.commands.length}var BM,VM=Z({"src/lib/tasks/task.ts"(){gj(),BM=[]}}),HM={};rj(HM,{CONFIG_ERROR_INTERACTIVE_MODE:()=>XM,CONFIG_ERROR_MODE_REQUIRED:()=>ZM,CONFIG_ERROR_UNKNOWN_OPTION:()=>QM,CleanOptions:()=>$M,cleanTask:()=>WM,cleanWithOptionsTask:()=>UM,isCleanOptionsArray:()=>GM});function UM(e,t){let{cleanMode:n,options:r,valid:i}=KM(e);return n?i.options?(r.push(...t),r.some(YM)?FM(XM):WM(n,r)):FM(QM+JSON.stringify(e)):FM(ZM)}function WM(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return DM(e===`n`,t)}}}function GM(e){return Array.isArray(e)&&e.every(e=>eN.has(e))}function KM(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{qM(e)?(t=e,r.cleanMode=!0):r.options=r.options&&JM(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function qM(e){return e===`f`||e===`n`}function JM(e){return/^-[a-z]$/i.test(e)&&eN.has(e.charAt(1))}function YM(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var XM,ZM,QM,$M,eN,tN=Z({"src/lib/tasks/clean.ts"(){MM(),$(),VM(),XM=`Git clean interactive mode is not supported`,ZM=`Git clean mode parameter ("n" or "f") is required`,QM=`Git clean unknown option found in: `,$M=(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))($M||{}),eN=new Set([`i`,...jj(Object.values($M))])}});function nN(e){let t=new oN;for(let n of aN(e))t.addValue(n.file,String(n.key),n.value);return t}function rN(e,t){let n=null,r=[],i=new Map;for(let a of aN(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 iN(e){return e.replace(/^(file):/,``)}function*aN(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=iN(n[e++]),i=n[e++],a=t;if(i.includes(`
43
- `)){let e=yj(i,`
44
- `);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var oN,sN=Z({"src/lib/responses/ConfigList.ts"(){$(),oN=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=xj(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 cN(e,t){return typeof e==`string`&&Object.hasOwn(pN,e)?e:t}function lN(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 uN(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 rN(t,e)}}}function dN(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return nN(e)}}}function fN(){return{addConfig(e,t,...n){return this._runTask(lN(e,t,n[0]===!0,cN(n[1],`local`)),fM(arguments))},getConfig(e,t){return this._runTask(uN(e,cN(t,void 0)),fM(arguments))},listConfig(...e){return this._runTask(dN(cN(e[0],void 0)),fM(arguments))}}}var pN,mN=Z({"src/lib/tasks/config.ts"(){sN(),$(),pN=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(pN||{})}});function hN(e){return _N.has(e)}var gN,_N,vN=Z({"src/lib/tasks/diff-name-status.ts"(){gN=(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))(gN||{}),_N=new Set(Object.values(gN))}});function yN(...e){return new TN().param(...e)}function bN(e){let t=new Set,n={};return wj(e,e=>{let[r,i,a]=e.split(Rj);t.add(r),(n[r]=n[r]||[]).push({line:Mj(i),path:r,preview:a})}),{paths:t,results:n}}function xN(){return{grep(e){let t=fM(arguments),n=lM(arguments);for(let e of SN)if(n.includes(e))return this._runTask(FM(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=yN().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return bN(e)}},t)}}}var SN,CN,wN,TN,EN=Z({"src/lib/tasks/grep.ts"(){$(),VM(),SN=[`-h`],CN=Symbol(`grepQuery`),TN=class{constructor(){this[wN]=[]}*[(wN=CN,Symbol.iterator)](){for(let e of this[CN])yield e}and(...e){return e.length&&this[CN].push(`--and`,`(`,...Nj(e,`-e`),`)`),this}param(...e){return this[CN].push(...Nj(e,`-e`)),this}}}}),DN={};rj(DN,{ResetMode:()=>jN,getResetMode:()=>kN,resetTask:()=>ON});function ON(e,t){let n=[`reset`];return AN(e)&&n.push(`--${e}`),n.push(...t),IM(n)}function kN(e){if(AN(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function AN(e){return typeof e==`string`&&MN.includes(e)}var jN,MN,NN=Z({"src/lib/tasks/reset.ts"(){$(),VM(),jN=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(jN||{}),MN=jj(Object.values(jN))}});function PN(){return(0,XA.default)(`simple-git`)}function FN(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 IN(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 LN(e,t,n,r=PN()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=IN(Hj(t,Jj),o,r);return l(n);function c(t,n){return Ej(a,LN(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&FN(o,n)||zj,s=FN(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var RN=Z({"src/lib/git-logger.ts"(){$(),XA.default.formatters.L=e=>String(Xj(e)?e.length:`-`),XA.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):Bj(e)}}),zN,BN=Z({"src/lib/runners/tasks-pending-queue.ts"(){fj(),RN(),zN=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:LN(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 dj(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 VN(e,t){return{method:bj(e.commands)||``,commands:t}}function HN(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function UN(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var WN,GN=Z({"src/lib/runners/git-executor-chain.ts"(){fj(),VM(),$(),BN(),WN=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new zN}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(zM(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 dj?Object.assign(t,{task:e}):new dj(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`,``,VN(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],VN(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),RM(e)?mM(e.parser,a):mM(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},{...VN(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`,Bj(e)),c(new eM(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 eM(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},VN(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,{...VN(e,n),kill(e){u=e||u}});let d=M(t,n,o);d.stdout.on(`data`,UN(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,UN(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,HN(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,{...VN(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,{...VN(e,t),kill(e){n=e||n}}),n}}}}),KN={};rj(KN,{GitExecutor:()=>qN});var qN,JN=Z({"src/lib/runners/git-executor.ts"(){GN(),qN=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new WN(this,this._scheduler,this._plugins)}chain(){return new WN(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function YN(e,t,n=zj){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof pj?XN(t):t,void 0)})}function XN(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=zj};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 ZN=Z({"src/lib/task-callback.ts"(){mj(),$()}});function QN(e,t){return PM(n=>{if(!Tj(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var $N=Z({"src/lib/tasks/change-working-directory.ts"(){$(),VM()}});function eP(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=Oj(t,`-B`)),IM(t)}function tP(){return{checkout(){return this._runTask(eP(lM(arguments,1)),fM(arguments))},checkoutBranch(e,t){return this._runTask(eP([`-b`,e,t,...lM(arguments)]),fM(arguments))},checkoutLocalBranch(e){return this._runTask(eP([`-b`,e,...lM(arguments)]),fM(arguments))}}}var nP=Z({"src/lib/tasks/checkout.ts"(){$(),VM()}});function rP(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function iP(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return hM(rP(),[aP],e)}})}}}var aP,oP=Z({"src/lib/tasks/count-objects.ts"(){$(),aP=new Q(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=Aj(t);Object.hasOwn(e,r)&&(e[r]=Mj(n))})}});function sP(e){return hM({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},cP,e)}var cP,lP=Z({"src/lib/parsers/parse-commit.ts"(){$(),cP=[new Q(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new Q(/\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 Q(/(\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 Q(/^(\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 uP(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...Nj(e,`-m`),...t,...n],format:`utf-8`,parser:sP}}function dP(){return{commit(t,...n){let r=fM(arguments),i=e(t)||uP(kj(t),kj(Hj(n[0],Yj,[])),[...jj(Hj(n[1],Kj,[])),...lM(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!Yj(e)&&FM(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var fP=Z({"src/lib/tasks/commit.ts"(){lP(),$(),VM()}});function pP(){return{firstCommit(){return this._runTask(IM([`rev-list`,`--max-parents=0`,`HEAD`],!0),fM(arguments))}}}var mP=Z({"src/lib/tasks/first-commit.ts"(){$(),VM()}});function hP(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),IM(n,!0)}var gP=Z({"src/lib/tasks/hash-object.ts"(){VM()}});function _P(e,t,n){let r=String(n).trim(),i;if(i=yP.exec(r))return new vP(e,t,!1,i[1]);if(i=bP.exec(r))return new vP(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new vP(e,t,/^re/i.test(r),a)}var vP,yP,bP,xP=Z({"src/lib/responses/InitSummary.ts"(){vP=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},yP=/^Init.+ repository in (.+)$/,bP=/^Rein.+ in (.+)$/}});function SP(e){return e.includes(wP)}function CP(e=!1,t,n){let r=[`init`,...n];return e&&!SP(r)&&r.splice(1,0,wP),{commands:r,format:`utf-8`,parser(e){return _P(r.includes(`--bare`),t,e)}}}var wP,TP=Z({"src/lib/tasks/init.ts"(){xP(),wP=`--bare`}});function EP(e){for(let t=0;t<e.length;t++){let n=OP.exec(e[t]);if(n)return`--${n[1]}`}return``}function DP(e){return OP.test(e)}var OP,kP=Z({"src/lib/args/log-format.ts"(){OP=/^--(stat|numstat|name-only|name-status)(=|$)/}}),AP,jP=Z({"src/lib/responses/DiffSummary.ts"(){AP=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function MP(e=``){let t=LP[e];return e=>hM(new AP,t,e,!1)}var NP,PP,FP,IP,LP,RP=Z({"src/lib/parsers/parse-diff-summary.ts"(){kP(),jP(),vN(),$(),NP=[new Q(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:Mj(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new Q(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:Mj(n),after:Mj(r),binary:!0})}),new Q(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=Mj(t),e.insertions=Mj(r?.[1]),e.deletions=Mj(i?.[1])})],PP=[new Q(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=Mj(t),a=Mj(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new Q(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],FP=[new Q(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],IP=[new Q(/([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:Lj(hN(t)&&t),from:Lj(!!a&&r!==a&&r),similarity:Mj(n)})})],LP={"":NP,"--stat":NP,"--numstat":PP,"--name-status":IP,"--name-only":FP}}});function zP(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function BP(e=UP,t=WP,n=``){let r=MP(n);return function(n){let i=Cj(n.trim(),!1,VP).map(function(n){let i=n.split(HP),a=zP(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 VP,HP,UP,WP,GP=Z({"src/lib/parsers/parse-list-log-summary.ts"(){$(),RP(),kP(),VP=`òòòòòò `,HP=` òò`,UP=` ò `,WP=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),KP={};rj(KP,{diffSummaryTask:()=>qP,validateLogFormatConfig:()=>JP});function qP(e){let t=EP(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),JP(n)||{commands:n,format:`utf-8`,parser:MP(t)}}function JP(e){let t=e.filter(DP);if(t.length>1)return FM(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return FM(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var YP=Z({"src/lib/tasks/diff.ts"(){kP(),RP(),VM()}});function XP(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function ZP(e){return Object.keys(e).reduce((t,n)=>(n in tF||(t[n]=e[n]),t),{})}function QP(e={},t=[]){let n=Hj(e.splitter,Jj,UP),[r,i]=XP(Wj(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:${VP}${i}${HP}`,...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 Jj(e.file)&&o.push(`--follow`,oj(e.file)),cM(ZP(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function $P(e,t,n){let r=BP(e,t,EP(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function eF(){return{log(...n){let r=fM(arguments),i=QP(dM(arguments),jj(Hj(arguments[0],Kj,[]))),a=t(...n)||JP(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return $P(e.splitter,e.fields,e.commands)}function t(e,t){return Jj(e)&&Jj(t)&&FM(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var tF,nF=Z({"src/lib/tasks/log.ts"(){kP(),uj(),GP(),$(),VM(),YP(),tF=(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))(tF||{})}}),rF,iF,aF=Z({"src/lib/responses/MergeSummary.ts"(){rF=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},iF=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`}}}}),oF,sF,cF=Z({"src/lib/responses/PullSummary.ts"(){oF=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},sF=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function lF(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 uF(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:Mj(t&&t[1]||`0`),delta:Mj(n&&n[1]||`0`)}}var dF,fF=Z({"src/lib/parsers/parse-remote-objects.ts"(){$(),dF=[new rM(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=lF(e.remoteMessages);Object.assign(i,{[r]:Mj(n)})}),new rM(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=lF(e.remoteMessages);Object.assign(i,{[r]:Mj(n)})}),new rM(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=lF(e.remoteMessages);i.total=uF(t),i.reused=uF(n),i.packReused=Mj(r)})]}});function pF(e,t){return hM({remoteMessages:new hF},mF,t)}var mF,hF,gF=Z({"src/lib/parsers/parse-remote-messages.ts"(){$(),fF(),mF=[new rM(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...dF,new rM([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new rM([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:Mj(t),summary:n,url:r}})],hF=class{constructor(){this.all=[]}}}});function _F(e,t){let n=hM(new sF,SF,[e,t]);return n.message&&n}var vF,yF,bF,xF,SF,CF,wF,TF=Z({"src/lib/parsers/parse-pull.ts"(){cF(),$(),gF(),vF=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,yF=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,bF=/^(create|delete) mode \d+ (.+)/,xF=[new Q(vF,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Q(yF,(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 Q(bF,(e,[t,n])=>{Ej(e.files,n),Ej(t===`create`?e.created:e.deleted,n)})],SF=[new Q(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new Q(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new Q(/([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})],CF=(e,t)=>hM(new oF,xF,[e,t]),wF=(e,t)=>Object.assign(new oF,CF(e,t),pF(e,t))}}),EF,DF,OF,kF=Z({"src/lib/parsers/parse-merge.ts"(){aF(),$(),TF(),EF=[new Q(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new Q(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new rF(t,n))}),new Q(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new rF(t,n,{deleteRef:r}))}),new Q(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new rF(t,null))}),new Q(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],DF=(e,t)=>Object.assign(OF(e,t),wF(e,t)),OF=e=>hM(new iF,EF,e)}});function AF(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=DF(e,t);if(n.failed)throw new pj(n);return n}}:FM(`Git.merge requires at least one option`)}var jF=Z({"src/lib/tasks/merge.ts"(){mj(),kF(),VM()}});function MF(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 NF,PF,FF,IF=Z({"src/lib/parsers/parse-push.ts"(){$(),gF(),NF=[new Q(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new Q(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new Q(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(MF(t,n,r))}),new Q(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new Q(/^([^:]+):(\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}}})],PF=(e,t)=>{let n=FF(e,t),r=pF(e,t);return{...n,...r}},FF=(e,t)=>hM({pushed:[]},NF,[e,t])}}),LF={};rj(LF,{pushTagsTask:()=>RF,pushTask:()=>zF});function RF(e={},t){return Ej(t,`--tags`),zF(e,t)}function zF(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),Oj(n,`-v`),Ej(n,`--verbose`),Ej(n,`--porcelain`),{commands:n,format:`utf-8`,parser:PF}}var BF=Z({"src/lib/tasks/push.ts"(){IF(),$()}});function VF(){return{showBuffer(){let e=[`show`,...lM(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(LM(e),fM(arguments))},show(){let e=[`show`,...lM(arguments,1)];return this._runTask(IM(e),fM(arguments))}}}var HF=Z({"src/lib/tasks/show.ts"(){$(),VM()}}),UF,WF,GF=Z({"src/lib/responses/FileStatusSummary.ts"(){UF=/^(.+)\0(.+)$/,WF=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=UF.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function KF(e){let[t,n]=e.split(Rj);return{from:n||t,to:t}}function qF(e,t,n){return[`${e}${t}`,n]}function JF(e,...t){return t.map(t=>qF(e,t,(e,t)=>e.conflicted.push(t)))}function YF(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=ZF.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new WF(r,t,n))}}var XF,ZF,QF,$F=Z({"src/lib/responses/StatusSummary.ts"(){$(),GF(),XF=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}},ZF=new Map([qF(` `,`A`,(e,t)=>e.created.push(t)),qF(` `,`D`,(e,t)=>e.deleted.push(t)),qF(` `,`M`,(e,t)=>e.modified.push(t)),qF(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),qF(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),qF(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),qF(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),qF(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),qF(`R`,` `,(e,t)=>{e.renamed.push(KF(t))}),qF(`R`,`M`,(e,t)=>{let n=KF(t);e.renamed.push(n),e.modified.push(n.to)}),qF(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),qF(`?`,`?`,(e,t)=>e.not_added.push(t)),...JF(`A`,`A`,`U`),...JF(`D`,`D`,`U`),...JF(`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=Hj(s?.[1],Jj,null),s=a.exec(t),e.tracking=Hj(s?.[1],Jj,null),s=o.exec(t),s&&(e.current=Hj(s?.[1],Jj,e.current)),e.detached=/\(no branch\)/.test(t)}]]),QF=function(e){let t=e.split(Rj),n=new XF;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=Rj+(t[e++]||``)),YF(n,r))}return n}}});function eI(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!tI.includes(e))],parser(e){return QF(e)}}}var tI,nI=Z({"src/lib/tasks/status.ts"(){$F(),tI=[`--null`,`-z`]}});function rI(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 iI(){return rI(0,0,0,``,!1)}function aI(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:oI,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(sI));r(t)}})}}}function oI(e){return e===sI?iI():hM(rI(0,0,0,e),cI,e)}var sI,cI,lI=Z({"src/lib/tasks/version.ts"(){$(),sI=`installed=false`,cI=[new Q(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,rI(Mj(t),Mj(n),Mj(r),i))}),new Q(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,rI(Mj(t),Mj(n),r,i))})]}});function uI(e,t,n,...r){return Jj(n)?t(n,Hj(r[0],Jj),lM(arguments)):FM(`git.${e}() requires a string 'repoPath'`)}function dI(){return{clone(e,...t){return this._runTask(uI(`clone`,fI,Hj(e,Jj),...t),fM(arguments))},mirror(e,...t){return this._runTask(uI(`mirror`,pI,Hj(e,Jj),...t),fM(arguments))}}}var fI,pI,mI=Z({"src/lib/tasks/clone.ts"(){VM(),$(),uj(),fI=(e,t,n)=>{let r=[`clone`,...n];return Jj(e)&&r.push(oj(e)),Jj(t)&&r.push(oj(t)),IM(r)},pI=(e,t,n)=>(Ej(n,`--mirror`),fI(e,t,n))}}),hI={};rj(hI,{SimpleGitApi:()=>gI});var gI,_I=Z({"src/lib/simple-git-api.ts"(){ZN(),$N(),nP(),oP(),fP(),mN(),mP(),EN(),gP(),TP(),nF(),jF(),BF(),HF(),nI(),VM(),lI(),$(),mI(),gI=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&YN(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(IM([`add`,...kj(e)]),fM(arguments))}cwd(e){let t=fM(arguments);return typeof e==`string`?this._runTask(QN(e,this._executor),t):typeof e?.path==`string`?this._runTask(QN(e.path,e.root&&this._executor||void 0),t):this._runTask(FM(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(hP(e,t===!0),fM(arguments))}init(e){return this._runTask(CP(e===!0,this._executor.cwd,lM(arguments)),fM(arguments))}merge(){return this._runTask(AF(lM(arguments)),fM(arguments))}mergeFromTo(e,t){return Jj(e)&&Jj(t)?this._runTask(AF([e,t,...lM(arguments)]),fM(arguments,!1)):this._runTask(FM(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=zF({remote:Hj(arguments[0],Jj),branch:Hj(arguments[1],Jj)},lM(arguments));return this._runTask(e,fM(arguments))}stash(){return this._runTask(IM([`stash`,...lM(arguments)]),fM(arguments))}status(){return this._runTask(eI(lM(arguments)),fM(arguments))}},Object.assign(gI.prototype,tP(),dI(),dP(),fN(),iP(),pP(),xN(),eF(),VF(),aI())}}),vI={};rj(vI,{Scheduler:()=>bI});var yI,bI,xI=Z({"src/lib/runners/scheduler.ts"(){$(),RN(),yI=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,ZA.createDeferred)();return{promise:t,done:n,id:e}}})(),bI=class{constructor(e=2){this.concurrency=e,this.logger=LN(``,`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=Ej(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),Oj(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=Ej(this.pending,yI());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),SI={};rj(SI,{applyPatchTask:()=>CI});function CI(e,t){return IM([`apply`,...t,...e])}var wI=Z({"src/lib/tasks/apply-patch.ts"(){VM()}});function TI(e,t){return{branch:e,hash:t,success:!0}}function EI(e){return{branch:e,hash:null,success:!1}}var DI,OI=Z({"src/lib/responses/BranchDeleteSummary.ts"(){DI=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function kI(e,t){return t===1&&jI.test(e)}var AI,jI,MI,NI,PI=Z({"src/lib/parsers/parse-branch-delete.ts"(){OI(),$(),AI=/(\S+)\s+\(\S+\s([^)]+)\)/,jI=/^error[^']+'([^']+)'/m,MI=[new Q(AI,(e,[t,n])=>{let r=TI(t,n);e.all.push(r),e.branches[t]=r}),new Q(jI,(e,[t])=>{let n=EI(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],NI=(e,t)=>hM(new DI,MI,[e,t])}}),FI,II=Z({"src/lib/responses/BranchSummary.ts"(){FI=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 LI(e){return e?e.charAt(0):``}function RI(e,t=!1){return hM(new FI,t?[BI]:zI,e)}var zI,BI,VI=Z({"src/lib/parsers/parse-branch.ts"(){II(),$(),zI=[new Q(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(LI(t),!0,n,r,i)}),new Q(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(LI(t),!1,n,r,i)})],BI=new Q(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),HI={};rj(HI,{branchLocalTask:()=>GI,branchTask:()=>WI,containsDeleteBranchCommand:()=>UI,deleteBranchTask:()=>qI,deleteBranchesTask:()=>KI});function UI(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function WI(e){let t=UI(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?NI(e,r).all[0]:RI(e,n)}}}function GI(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return RI(e)}}}function KI(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return NI(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!kI(String(n),e))return i(n);r(t)}}}function qI(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return NI(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!kI(String(i),e))return o(i);throw new pj(n.parser(Pj(r),Pj(t)),String(i))}};return n}var JI=Z({"src/lib/tasks/branch.ts"(){mj(),PI(),VI(),$()}});function YI(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&le(t)}var XI,ZI=Z({"src/lib/responses/CheckIgnore.ts"(){XI=e=>e.split(/\n/g).map(YI).filter(Boolean)}}),QI={};rj(QI,{checkIgnoreTask:()=>$I});function $I(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:XI}}var eL=Z({"src/lib/tasks/check-ignore.ts"(){ZI()}});function tL(e,t){return hM({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},nL,[e,t])}var nL,rL=Z({"src/lib/parsers/parse-fetch.ts"(){$(),nL=[new Q(/From (.+)$/,(e,[t])=>{e.remote=t}),new Q(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new Q(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new Q(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new Q(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),iL={};rj(iL,{fetchTask:()=>oL});function aL(e){return/^--upload-pack(=|$)/.test(e)}function oL(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(aL)?FM(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:tL}}var sL=Z({"src/lib/tasks/fetch.ts"(){rL(),VM()}});function cL(e){return hM({moves:[]},lL,e)}var lL,uL=Z({"src/lib/parsers/parse-move.ts"(){$(),lL=[new Q(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),dL={};rj(dL,{moveTask:()=>fL});function fL(e,t){return{commands:[`mv`,`-v`,...kj(e),t],format:`utf-8`,parser:cL}}var pL=Z({"src/lib/tasks/move.ts"(){uL(),$()}}),mL={};rj(mL,{pullTask:()=>hL});function hL(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 wF(e,t)},onError(e,t,n,r){let i=_F(Pj(e.stdOut),Pj(e.stdErr));if(i)return r(new pj(i));r(t)}}}var gL=Z({"src/lib/tasks/pull.ts"(){mj(),TF(),$()}});function _L(e){let t={};return yL(e,([e])=>t[e]={name:e}),Object.values(t)}function vL(e){let t={};return yL(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 yL(e,t){wj(e,e=>t(e.split(/\s+/)))}var bL=Z({"src/lib/responses/GetRemoteSummary.ts"(){$()}}),xL={};rj(xL,{addRemoteTask:()=>SL,getRemotesTask:()=>CL,listRemotesTask:()=>wL,remoteTask:()=>TL,removeRemoteTask:()=>EL});function SL(e,t,n){return IM([`remote`,`add`,...n,e,t])}function CL(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?vL:_L}}function wL(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),IM(t)}function TL(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),IM(t)}function EL(e){return IM([`remote`,`remove`,e])}var DL=Z({"src/lib/tasks/remote.ts"(){bL(),VM()}}),OL={};rj(OL,{stashListTask:()=>kL});function kL(e={},t){let n=QP(e),r=[`stash`,`list`,...n.commands,...t],i=BP(n.splitter,n.fields,EP(r));return JP(r)||{commands:r,format:`utf-8`,parser:i}}var AL=Z({"src/lib/tasks/stash-list.ts"(){kP(),GP(),YP(),nF()}}),jL={};rj(jL,{addSubModuleTask:()=>ML,initSubModuleTask:()=>NL,subModuleTask:()=>PL,updateSubModuleTask:()=>FL});function ML(e,t){return PL([`add`,e,t])}function NL(e){return PL([`init`,...e])}function PL(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),IM(t)}function FL(e){return PL([`update`,...e])}var IL=Z({"src/lib/tasks/sub-module.ts"(){VM()}});function LL(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?RL(e,t):0:n?1:-1}function RL(e,t){return e===t?0:e>t?1:-1}function zL(e){return e.trim()}function BL(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var VL,HL,UL=Z({"src/lib/responses/TagList.ts"(){VL=class{constructor(e,t){this.all=e,this.latest=t}},HL=function(e,t=!1){let n=e.split(`
45
- `).map(zL).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return LL(BL(n[0]),BL(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=RL(BL(n[e]),BL(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new VL(n,r)}}}),WL={};rj(WL,{addAnnotatedTagTask:()=>qL,addTagTask:()=>KL,tagListTask:()=>GL});function GL(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return HL(e,t)}}}function KL(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function qL(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var JL=Z({"src/lib/tasks/tag.ts"(){UL()}}),YL=nj({"src/git.js"(e,t){var{GitExecutor:n}=(JN(),aj(KN)),{SimpleGitApi:r}=(_I(),aj(hI)),{Scheduler:i}=(xI(),aj(vI)),{adhocExecTask:a,configurationErrorTask:o}=(VM(),aj(NM)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=($(),aj(_M)),{applyPatchTask:g}=(wI(),aj(SI)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(JI(),aj(HI)),{checkIgnoreTask:x}=(eL(),aj(QI)),{checkIsRepoTask:S}=(EM(),aj(vM)),{cleanWithOptionsTask:C,isCleanOptionsArray:w}=(tN(),aj(HM)),{diffSummaryTask:T}=(YP(),aj(KP)),{fetchTask:E}=(sL(),aj(iL)),{moveTask:D}=(pL(),aj(dL)),{pullTask:O}=(gL(),aj(mL)),{pushTagsTask:k}=(BF(),aj(LF)),{addRemoteTask:ee,getRemotesTask:te,listRemotesTask:ne,remoteTask:A,removeRemoteTask:j}=(DL(),aj(xL)),{getResetMode:re,resetTask:ie}=(NN(),aj(DN)),{stashListTask:ae}=(AL(),aj(OL)),{addSubModuleTask:oe,initSubModuleTask:se,subModuleTask:ce,updateSubModuleTask:le}=(IL(),aj(jL)),{addAnnotatedTagTask:ue,addTagTask:de,tagListTask:fe}=(JL(),aj(WL)),{straightThroughBufferTask:pe,straightThroughStringTask:me}=(VM(),aj(NM));function M(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(M.prototype=Object.create(r.prototype)).constructor=M,M.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},M.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},M.prototype.stashList=function(e){return this._runTask(ae(h(arguments)||{},c(e)&&e||[]),m(arguments))},M.prototype.mv=function(e,t){return this._runTask(D(e,t),m(arguments))},M.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},M.prototype.pull=function(e,t,n,r){return this._runTask(O(f(e,u),f(t,u),p(arguments)),m(arguments))},M.prototype.fetch=function(e,t){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},M.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.")))},M.prototype.tags=function(e,t){return this._runTask(fe(p(arguments)),m(arguments))},M.prototype.rebase=function(){return this._runTask(me([`rebase`,...p(arguments)]),m(arguments))},M.prototype.reset=function(e){return this._runTask(ie(re(e),p(arguments)),m(arguments))},M.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(me([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},M.prototype.addTag=function(e){let t=typeof e==`string`?de(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},M.prototype.addAnnotatedTag=function(e,t){return this._runTask(ue(e,t),m(arguments))},M.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},M.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},M.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(me(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},M.prototype.submoduleAdd=function(e,t,n){return this._runTask(oe(e,t),m(arguments))},M.prototype.submoduleUpdate=function(e,t){return this._runTask(le(p(arguments,!0)),m(arguments))},M.prototype.submoduleInit=function(e,t){return this._runTask(se(p(arguments,!0)),m(arguments))},M.prototype.subModule=function(e,t){return this._runTask(ce(p(arguments)),m(arguments))},M.prototype.listRemote=function(){return this._runTask(ne(p(arguments)),m(arguments))},M.prototype.addRemote=function(e,t,n){return this._runTask(ee(e,t,p(arguments)),m(arguments))},M.prototype.removeRemote=function(e,t){return this._runTask(j(e),m(arguments))},M.prototype.getRemotes=function(e,t){return this._runTask(te(e===!0),m(arguments))},M.prototype.remote=function(e,t){return this._runTask(A(p(arguments)),m(arguments))},M.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(me(n),m(arguments))},M.prototype.updateServerInfo=function(e){return this._runTask(me([`update-server-info`]),m(arguments))},M.prototype.pushTags=function(e,t){let n=k({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},M.prototype.rm=function(e){return this._runTask(me([`rm`,`-f`,...s(e)]),m(arguments))},M.prototype.rmKeepLocal=function(e){return this._runTask(me([`rm`,`--cached`,...s(e)]),m(arguments))},M.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},M.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},M.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`?pe(r):me(r);return this._runTask(a,n)},M.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`):me([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},M.prototype.diffSummary=function(){return this._runTask(T(p(arguments,1)),m(arguments))},M.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))},M.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(me(e,!0),m(arguments))},M.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))},M.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},M.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.`)))},M.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},M.prototype.checkIsRepo=function(e,t){return this._runTask(S(f(e,u)),m(arguments))},t.exports=M}});uj(),fj();var XL=class extends dj{constructor(e,t){super(void 0,t),this.config=e}};fj(),fj();var ZL=class extends dj{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};mj(),gj(),EM(),tN(),mN(),vN(),EN(),NN();function QL(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new ZL(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new ZL(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function $L(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function eR(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 tR(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&$L(i)&&r.test(a))throw new ZL(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var nR=[tR(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),tR(`core.sshCommand`,`allowUnsafeSshCommand`),tR(`core.gitProxy`,`allowUnsafeGitProxy`),tR(`core.hooksPath`,`allowUnsafeHooksPath`),tR(`diff.external`,`allowUnsafeDiffExternal`)];function rR(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new ZL(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&eR(`u`,e))throw new ZL(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 ZL(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function iR({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||rR(i,r.method),nR.forEach(e=>e(t,i,o))}),n}}}$();function aR(e){let t=Nj(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}$();var oR=(0,ZA.deferred)().promise;function sR({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,ZA.deferred)(),closeTimeout:(0,ZA.deferred)(),exit:(0,ZA.deferred)(),exitTimeout:(0,ZA.deferred)()},a=Promise.race([e===!1?oR:i.closeTimeout.promise,t===!1?oR: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(()=>Ij(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 Ij(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}$();var cR=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,lR=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function uR(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function dR(e,t){if(e.length<1||e.length>2)throw new ZL(void 0,`binary`,cR);if(e.some(uR))if(t)console.warn(lR);else throw new ZL(void 0,`binary`,lR);let[n,r]=e;return{binary:n,prefix:r}}function fR(e,t=[`git`],n=!1){let r=dR(kj(t),n);e.on(`binary`,e=>{r=dR(kj(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}fj();function pR(e){return!!(e.exitCode&&e.stdErr.length)}function mR(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function hR(e=!1,t=pR,n=mR){return(r,i)=>!e&&r||!t(i)?r:n(i)}function gR(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 dj(void 0,r.toString(`utf-8`))}:{error:r}}}}$();var _R=class{constructor(){this.plugins=new Set,this.events=new he}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=Ej(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return kj(e).forEach(e=>e&&this.plugins.add(Ej(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}};$();function vR(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?Dj(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:yR(n[1]),progress:Mj(n[2]),processed:Mj(n[3]),total:Mj(n[4])})})}}]}function yR(e){return String(e.toLowerCase().split(` `,1))||`unknown`}$();function bR(e){let t=Fj(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function xR({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 ZL(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()}}}uj();function SR(){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(sj(i)){r(cj(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>sj(e)&&cj(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}$();var CR=YL();function wR(e,t){let n=new _R,r=aM(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!Tj(r.baseDir))throw new XL(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(aR(r.config)),n.add(iR(r.unsafe)),n.add(sR(r.completion)),r.abort&&n.add(QL(r.abort)),r.progress&&n.add(vR(r.progress)),r.timeout&&n.add(xR(r.timeout)),r.spawnOptions&&n.add(bR(r.spawnOptions)),n.add(SR()),n.add(gR(hR(!0))),r.errors&&n.add(gR(r.errors)),fR(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new CR(r,n)}mj();var TR=wR,ER=class extends Ga()(`@supervisor/Updates`,{make:gp(function*(){let e=yield*Lv();return{publish:km(`Updates.publish`)(function*(t){yield*zv(e,new bE({content:t,receivedAt:th()}))}),stream:km(`Updates.stream`)(function*(){return eC(e)})}})}){static layer=rf(this)(this.make)};const DR=`.expect`,OR=km(`ensureStateDir`)(function*(e){let t=yield*kC,n=oe.join(e,DR);yield*t.makeDirectory(n,{recursive:!0}).pipe(J(`PlatformError`,()=>mp));let r=oe.join(n,`.gitignore`);return(yield*t.exists(r).pipe(J(`PlatformError`,()=>U(!1))))||(yield*t.writeFileString(r,`*
46
- `).pipe(J(`PlatformError`,()=>mp))),n});var kR=class extends lS(`GitError`)({_tag:Bx(`GitError`),operation:Y,cause:Zx}){message=`Git error during "${this.operation}"`},AR=class extends lS(`FindRepoRootError`)({_tag:Bx(`FindRepoRootError`),cause:Zx}){message=`Could not find git repository root`},jR=class extends Ga()(`@supervisor/GitRepoRoot`){},MR=class e extends Ga()(`@supervisor/Git`,{make:gp(function*(){let e=yield*kC,t=e=>gp(function*(){let t=yield*jR;return yield*up({try:()=>TR(t).raw(e.args),catch:t=>new kR({operation:e.operation,cause:t})}).pipe(q(e.trim?Gf:F))}),n=e=>up({try:()=>TR(e).revparse([`--show-toplevel`]),catch:e=>new AR({cause:e})}).pipe(q(Gf)),r=e=>t=>gp(function*(){let r=yield*n(e);return yield*t.pipe(Xp(jR,r))}),i=t({args:[`symbolic-ref`,`refs/remotes/origin/HEAD`],operation:`getting main branch`,trim:!0}).pipe(q(e=>e.replace(`refs/remotes/origin/`,``)),J(`GitError`,()=>t({args:[`revparse`,`--verify`,`origin/main`],operation:`getting main branch (origin/main)`,trim:!0}).pipe(Tp(`main`))),J(`GitError`,()=>t({args:[`rev-parse`,`--verify`,`main`],operation:`getting main branch (main)`,trim:!0}).pipe(Tp(`main`))),J(`GitError`,()=>U(`main`))),a=t({args:[`rev-parse`,`--abbrev-ref`,`HEAD`],operation:`getting current branch`,trim:!0}).pipe(J(`GitError`,()=>U(`HEAD`))),o=t({args:[`rev-parse`,`--is-inside-work-tree`],operation:`checking if inside work tree`,trim:!0}).pipe(q(e=>e===`true`),J(`GitError`,()=>U(!1))),s=e=>{let[t,n,r]=e.split(` `);return new qT({relativePath:r??``,added:Number.parseInt(t??`0`,10)||0,removed:Number.parseInt(n??`0`,10)||0})},c=km(`Git.getFileStats`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`,`--numstat`],operation:`getting working tree file stats`}).pipe(q(qf(`
47
- `)),q(Hi(Gf)),q(Ui(Kf)),q(Hi(s)),J(`GitError`,()=>U([]))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`,`--numstat`],operation:`getting file stats`}).pipe(q(qf(`
48
- `)),q(Hi(Gf)),q(Ui(Kf)),q(Hi(s)),J(`GitError`,()=>U([])))}),l=e=>e===`A`?`A`:e===`D`?`D`:e===`R`?`R`:e===`C`?`C`:e===`?`?`?`:`M`,u=km(`Git.getChangedFiles`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`status`,`--porcelain`],operation:`getting working tree changes`}).pipe(q(qf(`
49
- `)),q(Ui(Kf)),q(Hi(e=>{let t=e.at(0)??`M`;return{path:e.slice(3).trim(),status:l(t)}})),J(`GitError`,()=>U([]))):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(q(qf(`
50
- `)),q(Hi(Gf)),q(Ui(Kf)),q(Hi(e=>{let t=e.split(` `),n=(t[0]??`M`).at(0)??`M`;return{path:(n===`R`||n===`C`?t[2]:t[1])??``,status:l(n)}})),J(`GitError`,()=>U([])))}),d=km(`Git.getDiffPreview`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`],operation:`getting diff preview`,trim:!0}).pipe(J(`GitError`,()=>U(``))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`],operation:`getting diff preview`,trim:!0}).pipe(J(`GitError`,()=>U(``)))}),f=km(`Git.getRecentCommits`)(function*(e){return yield*t({args:[`log`,`--format=%H %h %s`,e],operation:`getting recent commits`,trim:!0}).pipe(q(qf(`
51
- `)),q(Hi(Gf)),q(Ui(Kf)),q(Hi(e=>{let[t,n,...r]=e.split(` `);return{hash:t??``,shortHash:n??``,subject:r.join(` `)}})),J(`GitError`,()=>U([])))}),p=km(`Git.getCommitSummary`)(function*(e){return yield*t({args:[`log`,`-1`,`--format=%H %h %s`,e],operation:`getting commit summary`,trim:!0}).pipe(q(e=>{let[t,n,...r]=e.split(` `);if(!(!t||!n))return{hash:t,shortHash:n,subject:r.join(` `)}}),J(`GitError`,()=>U(void 0)))}),m=km(`Git.computeFingerprint`)(function*(){let e=yield*t({args:[`rev-parse`,`HEAD`],operation:`getting HEAD for fingerprint`,trim:!0}).pipe(J(`GitError`,()=>U(``)));if(!e)return;let n=yield*t({args:[`diff`],operation:`getting unstaged diff for fingerprint`}).pipe(J(`GitError`,()=>U(``))),r=yield*t({args:[`diff`,`--cached`],operation:`getting staged diff for fingerprint`}).pipe(J(`GitError`,()=>U(``)));return ne.createHash(`sha256`).update(e).update(`\0`).update(n).update(`\0`).update(r).digest(`hex`)}),h=gp(function*(){let e=yield*OR(yield*jR);return oe.join(e,`last-tested`)}),g=km(`Git.loadSavedFingerprint`)(function*(){let t=yield*h;return yield*e.readFileString(t).pipe(q(Gf),J(`PlatformError`,()=>U(void 0)))}),_=km(`Git.saveTestedFingerprint`)(function*(){let t=yield*m();if(!t)return;let n=yield*h;yield*e.writeFileString(n,t)});return{withRepoRoot:r,getMainBranch:i,getCurrentBranch:a,isInsideWorkTree:o,getFileStats:c,getChangedFiles:u,getDiffPreview:d,getRecentCommits:f,getCommitSummary:p,getState:km(`Git.getState`)(function*(){if(!(yield*o))return new JT({isGitRepo:!1,currentBranch:`HEAD`,mainBranch:void 0,isOnMain:!1,hasChangesFromMain:!1,hasUnstagedChanges:!1,hasBranchCommits:!1,branchCommitCount:0,fileStats:[],fingerprint:void 0,savedFingerprint:void 0});let[e,t,n,r]=yield*op([a,i,m(),g()],{concurrency:`unbounded`}),s=e===t,[l,u,d]=yield*op([c(ZT.makeUnsafe({_tag:`Changes`,mainBranch:t})),c(ZT.makeUnsafe({_tag:`WorkingTree`})),f(`${t}..HEAD`)],{concurrency:`unbounded`});return new JT({isGitRepo:!0,currentBranch:e,mainBranch:t,isOnMain:s,hasChangesFromMain:l.length>0,hasUnstagedChanges:u.length>0,hasBranchCommits:d.length>0,branchCommitCount:d.length,fileStats:l,fingerprint:n,savedFingerprint:r})}),computeFingerprint:m,saveTestedFingerprint:_}})}){static layer=rf(this)(this.make).pipe(ff(pe.layer));static withRepoRoot=t=>{let n=rf(jR)(up({try:()=>TR(t).revparse([`--show-toplevel`]),catch:e=>new AR({cause:e})}).pipe(q(e=>e.trim())));return uf(e.layer.pipe(ff(n)),n)}},NR=class extends lS(`@supervisor/ExecutionError`)({_tag:Bx(`@supervisor/ExecutionError`),reason:Mx([OA,kA])}){message=`Execution failed: ${this.reason.message}`},PR=class extends Ga()(`@supervisor/Executor`,{make:gp(function*(){let e=yield*PA,t=yield*MR,n=km(`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:km(`Executor.execute`)(function*(t){let r=yield*n(t.changesFor),i=RA({userInstruction:t.instruction,scope:t.changesFor._tag,currentBranch:r.currentBranch,mainBranch:r.mainBranch,changedFiles:r.changedFiles,recentCommits:r.recentCommits,diffPreview:r.diffPreview,baseUrl:t.baseUrl,isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,savedFlow:t.savedFlow,learnings:t.learnings}),a=new oE({id:XT.makeUnsafe(crypto.randomUUID()),changesFor:t.changesFor,currentBranch:r.currentBranch,diffPreview:r.diffPreview,fileStats:[],instruction:t.instruction,baseUrl:t.baseUrl?B(t.baseUrl):z(),isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,title:t.instruction,rationale:`Direct execution`,steps:[]}),o=new OE({...a,events:[new sE({plan:a})]}),s=new Ok({cwd:process.cwd(),sessionId:z(),prompt:i,systemPrompt:z()});return e.stream(s).pipe(lC(()=>o,(e,t)=>{let n=e.addEvent(t);return[n,[n]]}),sC(e=>new NR({reason:e})))},tC)}})}){static layer=rf(this)(this.make).pipe(ff(pe.layer))},FR=class extends Ga()(`@supervisor/Reporter`,{make:gp(function*(){return{report:km(`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 kE({...e,summary:i,screenshotPaths:a,pullRequest:z()})})}})}){static layer=rf(this)(this.make)};const IR=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(`
52
- `)},LR=e=>`---\n${IR(e)}\n---\n`,RR=e=>e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e,zR=e=>yt(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.instruction==`string`&&typeof e.expectedOutcome==`string`,BR=e=>yt(e)?{title:typeof e.title==`string`?e.title:``,userInstruction:typeof e.userInstruction==`string`?e.userInstruction:``,steps:Array.isArray(e.steps)?e.steps.filter(zR):[]}:{title:``,userInstruction:``,steps:[]},VR=e=>yt(e)?{baseUrl:typeof e.baseUrl==`string`?e.baseUrl:``,cookies:typeof e.cookies==`boolean`?e.cookies:!1}:{baseUrl:``,cookies:!1},HR=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(`
53
- `)){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:RR(r.get(`title`)??``),description:RR(r.get(`description`)??``),slug:RR(r.get(`slug`)??``),savedTargetScope:RR(r.get(`saved_target_scope`)??``),savedTargetDisplayName:RR(r.get(`saved_target_display_name`)??``),flow:BR(JSON.parse(r.get(`flow`)??`{}`)),environment:VR(JSON.parse(r.get(`environment`)??`{}`))},a=r.get(`selected_commit`);return a!==void 0&&(i.selectedCommit=RR(a)),i},UR=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),WR=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:UR(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:QT(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=ri(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:ri(e.baseUrl,()=>``),cookies:e.requiresCookies}});var GR=class extends Ga()(`@supervisor/FlowStorage`,{make:gp(function*(){let e=yield*kC,t=gp(function*(){let e=yield*OR(yield*jR);return oe.join(e,`flows`)});return{save:km(`FlowStorage.save`)(function*(n){let r=WR(n),i=yield*t,a=oe.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(J(`PlatformError`,()=>mp)),yield*e.writeFileString(a,LR(r)),yield*Mm(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:km(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(J(`PlatformError`,()=>U(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(J(`PlatformError`,()=>U([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(oe.join(n,t)).pipe(J(`PlatformError`,()=>U(``)));if(!r)continue;let a=yield*yp({try:()=>HR(r),catch:()=>({_tag:`FlowParseError`})}).pipe(J(`FlowParseError`,()=>U(void 0)));a&&i.push(a)}return yield*Nm(`Flows listed`,{count:i.length}),i})}})}){static layer=rf(this)(this.make).pipe(ff(pe.layer))};const KR=(e,t)=>{try{return te(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var qR=class extends lS(`GitHubCommandError`)({_tag:Bx(`GitHubCommandError`),cause:Y}){message=`GitHub CLI command failed: ${this.cause}`},JR=class extends Ga()(`@supervisor/GitHub`,{make:gp(function*(){let e=yield*pk,t=yield*kC,n=km(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(_k(`gh`,n,{cwd:t})).pipe(Fp(15e3),Op({PlatformError:e=>G(new qR({cause:e.message})),TimeoutError:()=>G(new qR({cause:`command timed out`}))}),q(e=>e.trim()))}),r=km(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,Bw(t).pipe(Vw({_tag:`Branch`},e=>e.branchName),Uw),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*sx($x(kx(xE)))(r).pipe(q(Pi),J(`SchemaError`,()=>U(z())))}),i=$x(kx($T));return{findPullRequest:r,listPullRequests:km(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(J(`GitHubCommandError`,()=>U(`[]`)));return(yield*sx(i)(t).pipe(J(`SchemaError`,vp))).map(e=>new tE({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:km(`GitHub.addComment`)(function*(e,r,i){yield*Qp(gp(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=rf(this)(this.make).pipe(ff(pe.layer))};const YR=e=>oe.join(ie.homedir(),DR,`${e}.json`),XR=new Map,ZR={getItem:async e=>{try{let t=await ge.readFile(YR(e),`utf-8`);return XR.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(XR.get(e)===t)return;XR.set(e,t);let n=YR(e);await ge.mkdir(oe.dirname(n),{recursive:!0}),await ge.writeFile(n,t,`utf-8`)},removeItem:async e=>{XR.delete(e);try{await ge.unlink(YR(e))}catch{}}},QR=e=>e.pipe(Kp(JR.layer)),$R=async e=>{let t=[];if(e.hasUntestedChanges&&t.push(SE.makeUnsafe({_tag:`WorkingTree`})),e.mainBranch){let n=process.cwd(),r=await bm(gp(function*(){return yield*(yield*MR).getRecentCommits(`${e.mainBranch}..HEAD`)}).pipe(Kp(MR.withRepoRoot(n))));for(let e of r)t.push(SE.makeUnsafe({_tag:`Commit`,hash:e.hash,shortHash:e.shortHash,subject:e.subject}))}return t},ez=e=>bm(QR(JR.use(t=>t.listPullRequests(e)))),tz=async e=>{let t=await ez(process.cwd()),n=t.filter(e=>e.prNumber!==null&&e.prStatus===`open`).map(e=>SE.makeUnsafe({_tag:`PullRequest`,branch:e})),r=t.filter(e=>e.prNumber!==null&&e.prStatus===`merged`).slice(0,5).map(e=>SE.makeUnsafe({_tag:`PullRequest`,branch:e})),i=t.filter(t=>t.name!==e.currentBranch&&t.prNumber===null).map(e=>SE.makeUnsafe({_tag:`Branch`,branch:e}));return[...n,...r,...i]},nz=(e,t)=>e._tag===`WorkingTree`&&t&&!t.isOnMain?t.currentBranch:TE(e),rz=(e,t)=>{if(e._tag===`WorkingTree`&&t){let e=[];if(t.branchCommitCount>0&&e.push(`${t.branchCommitCount} commit${t.branchCommitCount===1?``:`s`}`),t.fileStats.length>0&&e.push(`${t.fileStats.length} file${t.fileStats.length===1?``:`s`}`),t.hasUnstagedChanges&&e.push(`uncommitted changes`),e.length>0)return e.join(`, `)}return EE(e)},iz=(e,t)=>e._tag===`WorkingTree`?nz(e,t):DE(e),az=(e,t,n)=>{if(!t)return[...e];let r=t.toLowerCase();return e.filter(e=>(e._tag===`WorkingTree`?`local changes ${n?.currentBranch??``}`:wE(e)).toLowerCase().includes(r))},oz=()=>d({queryKey:[`remote-branches`],queryFn:()=>ez(process.cwd())}),sz=e=>{let t=f(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=CT(),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=x(_e,{type:`dots`}),t[1]=a):a=t[1];let o;t[2]===r.SELECTION?o=t[3]:(o=x(i,{color:r.SELECTION,children:a}),t[2]=r.SELECTION,t[3]=o);let s;t[4]===n?s=t[5]:(s=n?S(i,{children:[` `,n]}):null,t[4]=n,t[5]=s);let c;return t[6]!==r.DIM||t[7]!==o||t[8]!==s?(c=S(i,{color:r.DIM,children:[o,s]}),t[6]=r.DIM,t[7]=o,t[8]=s,t[9]=c):c=t[9],c},cz=(e,t)=>{let n=Math.max(0,t-ye(e));return e+` `.repeat(n)},lz=({itemCount:e,visibleCount:t,initialIndex:n})=>{let[r,i]=y(n??0),a=v(e);return a.current!==e&&(a.current=e,i(t=>Math.min(t,Math.max(0,e-1)))),{highlightedIndex:r,setHighlightedIndex:i,scrollOffset:_(()=>{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:m((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])}},uz=yf(),dz=be(e=>({screen:uz.Main(),previousScreen:uz.Main(),navigateTo:t=>e(e=>({screen:t,previousScreen:e.screen})),setScreen:t=>e({screen:t})})),fz=new c({defaultOptions:{queries:{staleTime:1/0,retry:!1}}}),pz=e=>{let t=f(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:a}=e,o=a===void 0?!0:a,[s]=bT(),c,l,u;t[1]!==r||t[2]!==n?(u=n.toUpperCase(),c=r?` │ ${r}`:``,l=ye(u),t[1]=r,t[2]=n,t[3]=c,t[4]=l,t[5]=u):(c=t[3],l=t[4],u=t[5]);let d=l+ye(c),p=o?Math.max(0,s-d-3):0,m;t[6]===u?m=t[7]:(m=x(i,{bold:!0,color:xT.text,children:u}),t[6]=u,t[7]=m);let h;t[8]!==r||t[9]!==c?(h=r?x(i,{color:xT.textMuted,children:c}):null,t[8]=r,t[9]=c,t[10]=h):h=t[10];let g;t[11]!==p||t[12]!==o?(g=o?S(i,{color:xT.border,children:[` `,`─`.repeat(p)]}):null,t[11]=p,t[12]=o,t[13]=g):g=t[13];let _;return t[14]!==m||t[15]!==h||t[16]!==g?(_=S(i,{children:[m,h,g]}),t[14]=m,t[15]=h,t[16]=g,t[17]=_):_=t[17],_},mz=()=>{let e=f(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]=bT(),r=dz(hz),a=CT(),[s,c]=y(null),[l,u]=y(``),[d,p]=y(`recent`),[m,h]=y(!1),[g,_]=y(void 0),{data:v,isLoading:b}=oz(),w=v===void 0?[]:v,T=tE.filterBranches(w,d,l),{highlightedIndex:E,setHighlightedIndex:D,scrollOffset:O,handleNavigation:k}=lz({itemCount:T.length,visibleCount:15}),ee=t-2-32-16-2,te=T.slice(O,O+15),ne;e[1]===D?ne=e[2]:(ne=e=>{u(_T(e)),D(0)},e[1]=D,e[2]=ne);let A=ne,j;e[3]===r?j=e[4]:(j=e=>{KR(process.cwd(),e)?(_(void 0),fz.invalidateQueries({queryKey:[`git-state`]}),r(uz.Main())):_(`Could not checkout "${e}". You may have uncommitted changes or the branch may not exist locally.`)},e[3]=r,e[4]=j);let re=j,ie;e[5]!==d||e[6]!==D?(ie=e=>{p(eE[(eE.indexOf(d)+e+eE.length)%eE.length]),D(0)},e[5]=d,e[6]=D,e[7]=ie):ie=e[7];let ae=ie;o((e,t)=>{if(m){t.escape&&h(!1);return}if(!k(e,t)){if(t.rightArrow&&ae(1),t.leftArrow&&ae(-1),t.return){let e=T[E];e&&(_(void 0),re(e.name))}e===`/`&&h(!0)}});let oe;e[8]!==s||e[9]!==re?(oe=(e,t)=>{s&&(e.toLowerCase()===`y`&&(_(void 0),re(s.name),c(null)),(e.toLowerCase()===`n`||t.escape)&&c(null))},e[8]=s,e[9]=re,e[10]=oe):oe=e[10];let se=s!==null,ce;e[11]===se?ce=e[12]:(ce={isActive:se},e[11]=se,e[12]=ce),o(oe,ce);let le=n,ue=`${T.length} branches`,de;e[13]===ue?de=e[14]:(de=x(n,{paddingX:1,children:x(pz,{title:`Select a PR or branch to test`,subtitle:ue})}),e[13]=ue,e[14]=de);let fe;e[15]!==a||e[16]!==d||e[17]!==D?(fe=eE.map((e,t)=>{let r=e===d,o=t<eE.length-1?` · `:``,s={recent:a.CYAN,all:a.TEXT,open:a.GREEN,draft:a.DIM,merged:a.PURPLE,"no-pr":a.YELLOW};return S(n,{children:[x(ET,{fullWidth:!1,onClick:()=>{p(e),D(0)},children:x(i,{color:r?s[e]:a.DIM,children:r?`[${e}]`:e})}),x(i,{color:a.DIM,children:o})]},e)}),e[15]=a,e[16]=d,e[17]=D,e[18]=fe):fe=e[18];let pe;e[19]===fe?pe=e[20]:(pe=x(n,{marginTop:1,paddingX:1,children:fe}),e[19]=fe,e[20]=pe);let me=b?x(n,{marginTop:1,paddingX:1,children:x(sz,{message:`Fetching PRs...`})}):S(n,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:[te.map((e,t)=>{let n=t+O,r=n===E;return S(ET,{onClick:()=>{D(n),re(e.name)},children:[x(i,{color:r?a.PRIMARY:a.DIM,children:r?`${C.pointer} `:` `}),x(i,{color:r?a.PRIMARY:a.DIM,bold:r,children:cz(ve(e.name,31),32)}),x(i,{color:a.CYAN,children:cz(ve(e.author||`—`,15),16)}),e.prNumber&&e.prStatus?x(i,{color:e.prStatus===`open`?a.GREEN:e.prStatus===`merged`?a.PURPLE:a.DIM,children:ve(`#${e.prNumber} ${e.prStatus}`,ee)}):x(i,{color:a.DIM,children:`—`})]},e.name)}),T.length===0&&x(i,{color:a.DIM,children:`No matching branches`})]}),M;e[21]!==a||e[22]!==g?(M=g?x(n,{marginTop:1,paddingX:1,children:x(i,{color:a.RED,children:g})}):null,e[21]=a,e[22]=g,e[23]=M):M=e[23];let he;e[24]!==a||e[25]!==s?(he=s?S(wT,{color:a.YELLOW,marginTop:1,children:[S(i,{color:a.YELLOW,bold:!0,children:[`Switch to `,s.name,`?`]}),S(i,{color:a.DIM,children:[`Press `,x(i,{color:a.PRIMARY,children:`y`}),` to continue or`,` `,x(i,{color:a.PRIMARY,children:`n`}),` to cancel.`]})]}):null,e[24]=a,e[25]=s,e[26]=he):he=e[26];let ge;e[27]!==A||e[28]!==m||e[29]!==l?(ge=x(n,{paddingX:1,children:x(NT,{isSearching:m,query:l,onChange:A})}),e[27]=A,e[28]=m,e[29]=l,e[30]=ge):ge=e[30];let _e;return e[31]!==le||e[32]!==de||e[33]!==pe||e[34]!==me||e[35]!==M||e[36]!==he||e[37]!==ge?(_e=S(le,{flexDirection:`column`,width:`100%`,paddingY:1,children:[de,pe,me,M,he,ge]}),e[31]=le,e[32]=de,e[33]=pe,e[34]=me,e[35]=M,e[36]=he,e[37]=ge,e[38]=_e):_e=e[38],_e};function hz(e){return e.setScreen}const gz=[{id:`enable-sync`,label:`Enable cookie sync and start testing`,detail:`Recommended for authenticated flows and much more reliable results.`},{id:`run-without-sync`,label:`Run anyway without cookie sync`,detail:`More likely to fail because the browser will not inherit your signed-in session.`}],_z=e=>{let t=f(45);if(t[0]!==`3b5222aa33ef93ca800bf65774e3901b0e8b7613ce6abfe52462af10f9d17f00`){for(let e=0;e<45;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`3b5222aa33ef93ca800bf65774e3901b0e8b7613ce6abfe52462af10f9d17f00`}let{changesFor:r,instruction:a,savedFlow:s}=e,c=CT(),l=dz(vz),[u,d]=y(0),p;t[1]!==r||t[2]!==a||t[3]!==s||t[4]!==l?(p=e=>{l(uz.Testing({changesFor:r,instruction:a,savedFlow:s}))},t[1]=r,t[2]=a,t[3]=s,t[4]=l,t[5]=p):p=t[5];let m=p,h;t[6]!==m||t[7]!==u?(h=(e,t)=>{(t.downArrow||e===`j`||t.ctrl&&e===`n`)&&d(yz),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&d(bz),e===`c`&&m(gz[0]),e===`a`&&m(gz[1]),t.return&&m(gz[u])},t[6]=m,t[7]=u,t[8]=h):h=t[8],o(h);let g;t[9]===a?g=t[10]:(g=x(n,{paddingX:1,children:x(pz,{title:`Cookie sync is off`,subtitle:a})}),t[9]=a,t[10]=g);let _;t[11]===c.RED?_=t[12]:(_=x(i,{color:c.RED,bold:!0,children:`This test may need cookie sync.`}),t[11]=c.RED,t[12]=_);let v,b;t[13]===c.DIM?(v=t[14],b=t[15]):(v=x(i,{color:c.DIM,children:`Running without synced cookies will make browser testing less reliable and more likely to fail.`}),b=x(i,{color:c.DIM,children:`If this flow needs an authenticated session, the browser may start in the wrong state.`}),t[13]=c.DIM,t[14]=v,t[15]=b);let w;t[16]!==c.RED||t[17]!==_||t[18]!==v||t[19]!==b?(w=S(wT,{color:c.RED,marginTop:1,children:[_,v,b]}),t[16]=c.RED,t[17]=_,t[18]=v,t[19]=b,t[20]=w):w=t[20];let T;t[21]!==c.DIM||t[22]!==c.PRIMARY||t[23]!==c.TEXT||t[24]!==m||t[25]!==u?(T=gz.map((e,t)=>{let r=t===u;return x(ET,{onClick:()=>{d(t),m(e)},children:S(n,{flexDirection:`column`,marginBottom:1,children:[S(i,{children:[x(i,{color:r?c.PRIMARY:c.DIM,children:r?`${C.pointer} `:` `}),x(i,{color:r?c.PRIMARY:c.TEXT,bold:r,children:e.label})]}),S(i,{color:c.DIM,children:[` `,e.detail]})]})},e.id)}),t[21]=c.DIM,t[22]=c.PRIMARY,t[23]=c.TEXT,t[24]=m,t[25]=u,t[26]=T):T=t[26];let E;t[27]===T?E=t[28]:(E=x(n,{flexDirection:`column`,marginTop:1,paddingX:1,children:T}),t[27]=T,t[28]=E);let D;t[29]===c.PRIMARY?D=t[30]:(D=x(i,{color:c.PRIMARY,children:`c`}),t[29]=c.PRIMARY,t[30]=D);let O;t[31]===c.PRIMARY?O=t[32]:(O=x(i,{color:c.PRIMARY,children:`a`}),t[31]=c.PRIMARY,t[32]=O);let k;t[33]===c.PRIMARY?k=t[34]:(k=x(i,{color:c.PRIMARY,children:`Esc`}),t[33]=c.PRIMARY,t[34]=k);let ee;t[35]!==c.DIM||t[36]!==D||t[37]!==O||t[38]!==k?(ee=x(n,{marginTop:1,paddingX:1,children:S(i,{color:c.DIM,children:[`Press `,D,` to enable cookie sync,`,` `,O,` to approve anyway, or`,` `,k,` to go back.`]})}),t[35]=c.DIM,t[36]=D,t[37]=O,t[38]=k,t[39]=ee):ee=t[39];let te;return t[40]!==ee||t[41]!==g||t[42]!==w||t[43]!==E?(te=S(n,{flexDirection:`column`,width:`100%`,paddingY:1,children:[g,w,E,ee]}),t[40]=ee,t[41]=g,t[42]=w,t[43]=E,t[44]=te):te=t[44],te};function vz(e){return e.setScreen}function yz(e){return Math.min(gz.length-1,e+1)}function bz(e){return Math.max(0,e-1)}const xz={"~effect/reactivity/AsyncResult":{E:F,A:F},pipe(){return N(this,arguments)},[Vt](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return Ht(this.value,e.value);case`Failure`:return Ht(this.cause,e.cause)}},[Ct](){let e=At(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:Et(e)(this._tag===`Success`?wt(this.value):wt(this.cause))}},Sz=e=>e.waiting,Cz=(e,t)=>e._tag===`Success`?Oz(e.value):jz(e.cause,{previous:t}),wz=e=>e._tag===`None`?Ez(!0):Nz(e.value),Tz=e=>e._tag===`Initial`,Ez=(e=!1)=>{let t=Object.create(xz);return t._tag=`Initial`,t.waiting=e,t},Dz=e=>e._tag===`Success`,Oz=(e,t)=>{let n=Object.create(xz);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},kz=e=>e._tag===`Failure`,Az=(e,t)=>{let n=Object.create(xz);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??z(),n.waiting=t?.waiting??!1,n},jz=(e,t)=>Az(e,{previousSuccess:fi(t.previous,e=>Dz(e)?B(e):kz(e)?e.previousSuccess:z()),waiting:t.waiting}),Mz=(e,t)=>jz($u(e),t),Nz=(e,t)=>{if(e.waiting)return t?.touch?Pz(e):e;let n=Object.assign(Object.create(xz),e);return n.waiting=!0,t?.touch&&Dz(n)&&(n.timestamp=Date.now()),n},Pz=e=>Dz(e)?Oz(e.value,{waiting:e.waiting}):e,Fz=(e,t)=>e._tag===`Failure`?jz(e.cause,{previous:t,waiting:e.waiting}):e,Iz=e=>e._tag===`Success`?B(e.value):e._tag===`Failure`?di(e.previousSuccess,e=>e.value):z(),Lz=e=>ui(Iz(e),()=>new ld(`AsyncResult.getOrThrow: no value found`)),Rz=e=>new zz(e);var zz=class{constructor(e){this.result=e}result;output=z();when(e,t){if(ei(this.output)&&e(this.result)){let e=t(this.result);ti(e)&&(this.output=e)}return this}pipe(){return N(this,arguments)}onWaiting(e){return this.when(e=>e.waiting,t=>B(e(t)))}onInitialOrWaiting(e){return this.when(e=>Tz(e)||e.waiting,t=>B(e(t)))}onInitial(e){return this.when(Tz,t=>B(e(t)))}onSuccess(e){return this.when(Dz,t=>B(e(t.value,t)))}onFailure(e){return this.when(kz,t=>B(e(t.cause,t)))}onError(e){return this.onErrorIf(Xe,e)}onErrorIf(e,t){return this.when(kz,n=>ad(n.cause).pipe(pi(e),di(e=>t(e,n))))}onErrorTag(e,t){return this.onErrorIf(t=>I(t,`_tag`)&&(Array.isArray(e)?e.includes(t._tag):t._tag===e),t)}onDefect(e){return this.when(kz,t=>{let n=od(t.cause);return vi(n)?z():B(e(n.success,t))})}orElse(e){return ri(this.output,e)}orNull(){return si(this.output)}render(){if(ti(this.output))return this.output.value;if(kz(this.result))throw rd(this.result.cause);return null}};const Bz=Ga(`~effect/reactivity/AtomRegistry`),Vz={alive:1,initialized:2,waitingForValue:4},Hz={uninitialized:Vz.alive|Vz.waitingForValue,stale:Vz.alive|Vz.initialized|Vz.waitingForValue,valid:Vz.alive|Vz.initialized,removed:0},Uz={disabled:0,collect:1,commit:2},Wz={phase:Uz.disabled,depth:0,stale:[],notify:new Set};function Gz(e){Wz.phase=Uz.collect,Wz.depth++;try{if(e(),Wz.depth===1){for(let e=0;e<Wz.stale.length;e++)Kz(Wz.stale[e]);Wz.phase=Uz.commit;for(let e of Wz.notify)e.notify();Wz.notify.clear()}}finally{Wz.depth--,Wz.depth===0&&(Wz.phase=Uz.disabled,Wz.stale=[])}}function Kz(e){if(e.state!==Hz.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==Hz.valid&&Kz(n)}e.state!==Hz.valid&&e.value()}}const qz=`~effect/reactivity/Atom`,Jz=e=>I(e,qz),Yz=`~effect/reactivity/Atom/Writable`,Xz=P(2,(e,t)=>{let n=pa(t),r=xa(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?Na(n):void 0})})(0),Zz={[qz]:qz,...zn,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},Qz={...Zz,atom(e,t){let n=oB(e,t);return nB(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):Fz(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>$z(this,e,t):$z(this,e,t)},pull(e,t){let n=Xz(lB(0));return SB(n,nB(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?dB(r,xB(r,n,e,t),Ez(!0),a.value):Fz(a,i)}))},subscriptionRef(e){return _B(Xz(nB(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return Fz(r,n);let i=typeof e==`function`?e(t):e;return tT(i)?i:dB(t,i,Ez(!0),r.value)})),(e,t)=>gB(e,t,Lz(e(this))))}},$z=(e,t,n)=>{let[r,i,a]=bB(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return ap(i)?qw(i,n.reactivityKeys):gC(i,Jw(n.reactivityKeys))}:t,n);return rB(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):Fz(i,n)},i)},eB={...Zz,[Yz]:Yz},tB=e=>Yz in e,nB=(e,t)=>{let n=Object.create(Zz);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},rB=(e,t,n)=>{let r=Object.create(eB);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function iB(e,t){e.setSelf(t)}const aB=(e,t)=>{let n=oB(e,t);return`~effect/reactivity/Atom`in n?n:nB(n)},oB=(e,t)=>{if(typeof e==`function`&&!ap(e)&&!GS(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:sB in i?uB(e,i,t,r):cB in i?mB(e,i,t,r):i;default:return i}}}else if(ap(e))return function(n,r){return uB(n,e,t,r)};else if(GS(e))return function(n,r){return mB(n,e,t,r)};return lB(e)},sB=`~effect/Effect`,cB=`~effect/Stream`,lB=e=>rB(function(t){return e},iB),uB=(e,t,n,r)=>dB(e,t,n?.initialValue===void 0?Ez():Oz(n.initialValue),r,n?.uninterruptible);function dB(e,t,n,r=$a(),i=!1){let a=e.self(),o=Id();e.addFinalizer(()=>{_m(r)(Hd(o,yd))});let s=new Map(r.mapUnsafe);s.set(Fd.key,o),s.set(Bz.key,e.registry),s.set(go.key,e.registry.scheduler);let c,l=!1,u=fB(Ya(s),t,function(t){c=Cz(t,a),l&&e.setSelf(c)},i);return l=!0,u!==void 0&&e.addFinalizer(u),c===void 0?a._tag===`Some`?wz(a):Nz(n):c}function fB(e,t,n,r=!1){if(hd(t)){n(t);return}let i=_m(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}const pB=(e=>{let t=Yw;function n(r){let i=Object.create(Qz);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=CB(nB(typeof r==`function`?e=>pf(r(e),t):()=>pf(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return uB(t,K(Zp,t=>$d(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=pf(t,ff(e,Yw))};let r=Xz(aB(Gp(t=>$d(Yw,e.memoMap,ao(t,Fd))).pipe(q(ao(Ww)))));return n.withReactivity=e=>t=>wB(t,n=>{let i=Lz(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:Zd()});pB.withReactivity;const mB=(e,t,n,r)=>hB(e,t,n?.initialValue===void 0?Ez():Oz(n.initialValue),r);function hB(e,t,n,r=$a()){let i=e.self();r=no(r,Bz,e.registry);let a=$p(n=>K(Ab(t.channel,n),t=>cp({while:Xe,body:()=>t,step(t){e.setSelf(Oz(Ii(t),{waiting:!0}))}}))).pipe(kp(t=>(Yf(t)?tt(e.self(),fi(Iz),ni({onNone:()=>e.setSelf(Mz(new ld,{previous:e.self()})),onSome:t=>e.setSelf(Oz(t))})):e.setSelf(jz(t,{previous:e.self()})),mp))),o=new Map(r.mapUnsafe);o.set(Bz.key,e.registry),o.set(go.key,e.registry.scheduler);let s=fB(Ya(o),a,et,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?wz(i):Nz(n)}const gB=(e,t,n=$a())=>tT(t)?(e.addFinalizer(nT(t).pipe(xC(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return mp}),vm(n))),Tm(n)(rT(t))):t._tag===`Success`?hB(e,nT(t.value),Ez(!0),n):t,_B=(e,t)=>{function n(t,n){let r=t.get(e);tT(r)?wm(aT(r,n)):Dz(r)&&wm(aT(r.value,n))}return rB(n=>{let r=n(e);return tT(r)||Dz(r)?t(n,r):r},n)},vB=Symbol.for(`effect/reactivity/atom/Atom/Reset`),yB=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`);function bB(e,t){let n=Xz(lB([0,void 0])),r=t?.initialValue===void 0?Ez():Oz(t.initialValue),i=t?.concurrent?Xz(nB(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===yB)return jz(td(),{previous:t.self()});let l=e(c,t);return sB in l?(o&&(l=K(mm(l,{startImmediately:!0}),e=>(o.add(e),e.addObserver(()=>o.delete(e)),q(hv(o),e=>e[0])))),dB(t,l,r,a,!1)):hB(t,l,r,a)}function o(e,t){EB(()=>{t===vB?e.set(n,[0,void 0]):t===yB?e.set(n,[e.get(n)[0]+1,yB]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}const xB=(e,t,n,r)=>K(SC(typeof n==`function`?n(e):n),n=>{let i=vv().services,a=Bi(),o=Hp(n,{onFailure(e){return Yf(e)?Ai(a)?U({done:!0,items:a}):G(new ld(`Atom.pull: no items`)):_p(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=Di(a,e),a=t),U({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(wz(e.self()));let t;t=fB(i,o,n=>{t&&s.delete(t);let r=Cz(n,e.self()),i=s.size>0;e.setSelf(i?Nz(r):r)}),t&&s.add(t)}),o}),SB=(e,t)=>rB(t.read,function(t,n){t.set(e,t.get(e)+1)}),CB=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),wB=P(e=>Jz(e[0]),(e,t,n)=>{let r=Xz(tB(e)?rB(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):nB(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=TB(n.initialValueTarget)),r}),TB=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},EB=Gz,DB=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},OB=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,kB=(e,t,n)=>e+(t-e)*n,AB=(e,t,n)=>{let[r,i,a]=DB(e),[o,s,c]=DB(t);return OB(kB(r,o,n),kB(i,s,n),kB(a,c,n))},jB=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[a,o]=y(-16),s=v(r);s.current=r;let c=v(e.length);c.current=e.length;let l=v(!1);return l.current||(l.current=!0,setTimeout(()=>{setInterval(()=>{let e=c.current+16;o(t=>t>=e?-16:t+s.current)},50)},0)),x(i,{children:[...e].map((e,r)=>{let o=Math.abs(r-a),s=Math.max(0,1-o/16);return x(i,{color:s>0?AB(t,n,s):t,children:e},r)})})},MB=be(e=>({executedPlan:void 0,setExecutedPlan:t=>e({executedPlan:t})})),NB=be()(Ee(e=>({agentBackend:`claude`,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:Te(()=>ZR),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),PB=e=>De(Math.max(0,e),{secondsDecimalDigits:0}),FB=new Set([`warpterminal`]),IB=ke.stdout,LB=Oe({preferOuter:!0}),RB=process.stdout.isTTY&&!FB.has(LB??``),zB=RB&&IB.kitty,BB=RB&&IB.iterm2,VB=zB||BB,HB=Oe(),UB=HB===`tmux`||HB===`screen`,WB=e=>UB?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,GB=(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}`),WB(`_G${r};${n}\\`)},KB=(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`)}`,WB(n)},qB=(e,t={})=>{if(!j.existsSync(e))return null;if(zB)return GB(e,t);if(BB)try{return KB(j.readFileSync(e),t)}catch{return null}return null},JB=e=>e.startsWith(`file://`),YB=e=>{let t=f(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,a,o;t[1]===n?(a=t[2],o=t[3]):(a=JB(n)?T.fileURLToPath(n):oe.resolve(n),o=JB(n)?n:T.pathToFileURL(a).href,t[1]=n,t[2]=a,t[3]=o);let s=o,c=r??a,l;t[4]===c?l=t[5]:(l=x(i,{children:c}),t[4]=c,t[5]=l);let u;return t[6]!==s||t[7]!==l?(u=x(Ae,{url:s,children:l}),t[6]=s,t[7]=l,t[8]=u):u=t[8],u},XB=({src:e,alt:t,width:n,height:r})=>{let i=oe.resolve(e),{write:a}=s(),o=v(!1);if(!o.current){let e=qB(i,{width:n,height:r});e&&(a(e+`
54
- `),o.current=!0)}return VB?null:x(YB,{path:i,label:t})},ZB=({message:e})=>e?x(n,{marginTop:1,children:x(i,{color:CT().RED,children:e})}):null,QB=se.join(process.cwd(),`.expect`,`logs.md`),$B=yw.pipe(Sw(QB)),eV=uf(sf(gp(function*(){let e=yield*kC;yield*e.makeDirectory(se.dirname(QB),{recursive:!0}),yield*e.writeFileString(se.join(se.dirname(QB),`.gitignore`),`*
55
- `)})),xw([$B])).pipe(ff(fe.layer));var tV=Ue(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(Ke(`child_process`),Ke(`crypto`)):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],r):typeof e==`object`?e[`electron-machine-id`]=r(Ke(`child_process`),Ke(`crypto`)):n[`electron-machine-id`]=r(n.child_process,n.crypto)})(e,function(e,t){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 k)return k[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)}},E=t+` Iterator`,D=y==g,O=!1,k=e.prototype,ee=k[f]||k[m]||y&&k[y],te=ee||T(y),ne=y?D?T(`entries`):te:void 0,A=t==`Array`&&k.entries||ee;if(A&&(w=d(A.call(new e)),w!==Object.prototype&&(u(w,E,!0),r||s(w,f)||o(w,f,_))),D&&ee&&ee.name!==g&&(O=!0,te=function(){return ee.call(this)}),r&&!x||!p&&!O&&k[f]||o(k,f,te),c[t]=te,c[E]=_,y)if(S={values:D?te:T(g),keys:b?te:T(h),entries:ne},x)for(C in S)C in k||a(k,C,S[C]);else i(i.P+i.F*(p||O),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(`
56
- `)[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)},k=function(e){try{e()}catch(e){return{error:e}}},ee=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&A(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=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&&te(e)})}},te=function(e){g.call(s,function(){var t,n,r,i=e._v;if(ne(e)&&(t=k(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||ne(e)?2:1),e._a=void 0,t)throw t.error})},ne=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||!ne(t.promise))return!1;return!0},A=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(),ee(t,!0))},re=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=E(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(re,r,1),c(j,r,1))}catch(e){j.call(r,e)}}):(n._v=e,n._s=1,ee(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(re,this,1),c(j,this,1))}catch(e){j.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=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&&ee(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(re,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=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=k(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=k(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(e,t){e.exports=Ke(`child_process`)},function(e,t){e.exports=Ke(`crypto`)}])})}))();function nV(e){return typeof e==`string`?`'${e}'`:new rV().serialize(e)}const rV=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}(),iV=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,aV=`sha256`,oV=`base64url`;function sV(e){if(iV)return iV(aV,e,oV);let t=A(aV).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(oV):t.digest(oV)}function cV(e){return sV(nV(e))}function lV(){let e=uV();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function uV(e=process.argv[1]?je(process.argv[1]):process.cwd(),t=Ne===`\\`){let n=t?dV(e):e;return e=>{if(!e)return;let r=t?dV(e):e,{dir:i,base:a,ext:o}=Me.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 dV(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const fV=e=>{if(`flags`in e){let t=mV(e.flags),n=hV(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,_V(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,pV(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function pV(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 mV=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,gV(t)]).filter(([,e])=>e!==void 0)),hV=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?_V(n):void 0]}))},gV=e=>e===void 0?void 0:e.variant??e.enabled,_V=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},vV=`0123456789abcdef`;var yV=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+=vV.charAt(this.bytes[t]>>>4),e+=vV.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+=vV.charAt(this.bytes[t]>>>4),e+=vV.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}},bV=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??xV()}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 yV.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,yV.ofInner(e)}};const xV=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let SV;const CV=()=>wV().toString(),wV=()=>(SV||=new bV).generate();var TV=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 EV=`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(`,`),DV=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return EV.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},OV=Array.isArray,kV=Object.prototype;kV.hasOwnProperty;const AV=kV.toString,jV=OV||function(e){return AV.call(e)===`[object Array]`},MV=e=>e===Object(e)&&!jV(e),NV=e=>e===void 0,PV=e=>AV.call(e)==`[object String]`,FV=e=>PV(e)&&e.trim().length===0,IV=e=>AV.call(e)==`[object Number]`&&e===e,LV=e=>e instanceof Error;function RV(e){return typeof e!=`object`||!e}function zV(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function BV(e){return!NV(Event)&&HV(e,Event)}function VV(e){return zV(e,`Object`)}function HV(e,t){try{return e instanceof t}catch{return!1}}function UV(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),IV(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),UV(i||n,t,n,r))}var WV=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=UV(e.bucketSize,0,100,e._logger),this._refillRate=UV(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=UV(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={}}},GV=class{add(e){let t=CV();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 KV(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const qV=(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=>qV(`${e} ${r}`,t,n)}},JV=e=>e();function YV(e,t=JV){return qV(e,t,KV())}const XV=`Android`;XV+``;const ZV=`BlackBerry`,QV=`Samsung`;QV+``,QV+``;const $V=`Chrome`;$V+``,$V+``;const eH=`Opera`;eH+``;const tH=`Edge`;``+tH;const nH=`Firefox`;nH+``;const rH=`Nintendo`,iH=`PlayStation`,aH=`Xbox`;XV+``;const oH=`Windows`;oH+``;const sH=`Generic`;sH+``,sH+``;const cH=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+cH),new RegExp(aH,`i`),RegExp(iH+` \\w+`,`i`),RegExp(rH+` \\w+`,`i`),RegExp(ZV+`|PlayBook|BB10`,`i`),RegExp(`rv:`+cH),RegExp(tH+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+$V+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+cH),RegExp(`(UCBrowser|UCWEB)\\/`+cH),RegExp(`(`+eH+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp(nH+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+cH),RegExp(`Konqueror[:/]?`+cH,`i`),RegExp(ZV+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+cH,`i`),RegExp(`(rv:|MSIE )`+cH),RegExp(`rv:`+cH),RegExp(aH+`; Xbox (.*?)[);]`,`i`),new RegExp(rH,`i`),new RegExp(iH,`i`),new RegExp(oH,`i`),RegExp(`(`+XV+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function lH(e,t){if(!e||typeof e!=`string`||uH(e))throw Error(t)}function uH(e){return e.trim().length===0}function dH(e){return e?.replace(/\/+$/,``)}async function fH(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 pH(){return new Date().toISOString()}function mH(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const hH=e=>e instanceof Error;function gH(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var _H=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 vH(){return`CompressionStream`in globalThis}async function yH(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 bH=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()}},xH=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function SH(e){if(e instanceof bH){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 CH(e){return typeof e==`object`&&(e instanceof bH||e instanceof xH)}function wH(e){return typeof e==`object`&&e instanceof bH&&e.status===413}var TH=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new GV,this._events=new _H,this._isInitialized=!1,lH(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=dH(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:CH},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=YV(`[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=!vH()||(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(TV.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(TV.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(TV.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:fV(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof bH)return{type:`api_error`,statusCode:e.status};if(e instanceof xH){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=gV(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(TV.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(TV.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(TV.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(TV.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(TV.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=mH(()=>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:pH()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await yH(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:pH(),uuid:n?.uuid?n.uuid:CV()};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 SH(e)})}async flush(){let e=gH([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),gH([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(TV.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(TV.Queue)||[]).slice(n.length);this.setPersistedProperty(TV.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:pH()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await yH(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>wH(e)?!1:CH(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(wH(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 xH||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 fH(async()=>{let n=new AbortController,i=mH(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new xH(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new bH(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(TV.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!CH(e))throw e;await SH(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=mH(()=>{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 EH,DH,OH;function kH(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return OH&&n.length===DH?OH:(DH=n.length,OH=n.reduce((n,r)=>{EH||={};let i=EH[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,EH[r]=[a,o];break}}}return n},{}),OH)}var AH=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&&jV(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:kH(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 jH=/^\s*[-]{4,}$/,MH=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,NH=(e,t)=>{let n=e.match(MH);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:FH(n[3]),colno:FH(n[4]),in_app:PH(s||``,c),platform:t}}if(e.match(jH))return{filename:e,platform:t}};function PH(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 FH(e){return parseInt(e||``,10)||void 0}const IH=/\(error: (.*)\)/;function LH(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||RH(t).filename,function:e.function||`?`}))}function RH(e){return e[e.length-1]||{}}function zH(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
57
- `);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=IH.test(r)?r.replace(IH,`$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 LH(i)}}var BH=class{match(e){return LV(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 VH=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var HH=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(VH);return r&&(t=r[1],n=r[2]),[t,n]}};const UH=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function WH(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 GH=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 BV(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=WH(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return PV(e)&&!FV(e)&&UH.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(hH(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},KH=class{match(e){return BV(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${WH(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},qH=class{match(e){return RV(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},JH=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 YH=new JH(25),XH=new JH(20);async function ZH(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`||nU(i)||rU(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(XH.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=aU(n);if(i.every(t=>iU(e,t)))continue;let a=lU(YH,e,{});r.push(QH(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&$H(e,YH),YH.reduce(),e}function QH(e,t,n){return new Promise(r=>{let i=re(e),a=de({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(){XH.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]=uU(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 $H(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;eU(n.lineno,n,e)}}function eU(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=sU(e);r<e;r++){let e=n[r];if(e===void 0)return void tU(t);t.pre_context.push(e)}if(n[e]===void 0)return void tU(t);t.context_line=n[e];let r=cU(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 tU(e){delete e.pre_context,delete e.context_line,delete e.post_context}function nU(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function rU(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function iU(e,t){let n=YH.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 aU(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=oU(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=oU(n)),t++}return i}function oU(e){return[sU(e),cU(e)]}function sU(e){return Math.max(1,e-7)}function cU(e){return e+7}function lU(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function uU(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 dU(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 fU(e,t){globalThis.process?.on(`uncaughtException`,dU(e,t))}function pU(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var mU=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new WV({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return MV(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||CV(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(fU(this.onException.bind(this),this.onFatalError.bind(this)),pU(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 hU={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function gU(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 _U=[`is_not`];var vU=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},yU=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},bU=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},xU=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 bU||t instanceof yU?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 bU||t instanceof yU?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 yU(`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 yU(`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 yU(`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 yU(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new yU(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new yU(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new yU(`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 yU(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1;else throw new yU(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new yU(`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 bU)throw e;if(e instanceof yU)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new yU(`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`?TU(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):CU(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await SU(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await SU(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 vU(`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 vU(`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 vU(`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 vU&&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=mH(()=>{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 SU(e,t,n=``){let r=await gU(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function CU(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 yU(`Operator is_not_set is not supported`)}else throw new yU(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!_U.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 DU(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return DU(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 yU(`Date operations cannot be performed on boolean values`);let e=PU(String(i));if(e??=NU(i),e==null)throw new yU(`Invalid date: ${i}`);let t=NU(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return kU(OU(String(o)),OU(String(i)))===0;case`semver_neq`:return kU(OU(String(o)),OU(String(i)))!==0;case`semver_gt`:return kU(OU(String(o)),OU(String(i)))>0;case`semver_gte`:return kU(OU(String(o)),OU(String(i)))>=0;case`semver_lt`:return kU(OU(String(o)),OU(String(i)))<0;case`semver_lte`:return kU(OU(String(o)),OU(String(i)))<=0;case`semver_tilde`:{let e=OU(String(o)),{lower:t,upper:n}=AU(String(i));return kU(e,t)>=0&&kU(e,n)<0}case`semver_caret`:{let e=OU(String(o)),{lower:t,upper:n}=jU(String(i));return kU(e,t)>=0&&kU(e,n)<0}case`semver_wildcard`:{let e=OU(String(o)),{lower:t,upper:n}=MU(String(i));return kU(e,t)>=0&&kU(e,n)<0}default:throw new yU(`Unknown operator: ${a}`)}}function wU(e,t){if(!(e in t))throw new bU(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function TU(e,t,n,r=!1){let i=String(e.value);wU(i,n);let a=n[i];return EU(a,t,n,r)}function EU(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=EU(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof bU)throw t;if(t instanceof yU)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new yU(`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=TU(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=CU(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 bU)throw t;if(t instanceof yU)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new yU(`can't match cohort without a given cohort property value`);return i===`AND`}function DU(e){try{return new RegExp(e),!0}catch{return!1}}function OU(e){let t=String(e).trim().replace(/^[vV]/,``).split(`-`)[0].split(`+`)[0];if(!t||t.startsWith(`.`))throw new yU(`Invalid semver: ${e}`);let n=t.split(`.`),r=t=>{if(t===void 0||t===``)return 0;if(!/^\d+$/.test(t))throw new yU(`Invalid semver: ${e}`);return parseInt(t,10)};return[r(n[0]),r(n[1]),r(n[2])]}function kU(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 AU(e){let t=OU(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function jU(e){let[t,n,r]=OU(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 MU(e){let t=String(e).trim().replace(/^[vV]/,``).replace(/\.\*$/,``).replace(/\*$/,``);if(!t)throw new yU(`Invalid wildcard semver: ${e}`);let n=t.split(`.`),r=parseInt(n[0],10);if(isNaN(r))throw new yU(`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 yU(`Invalid wildcard semver: ${e}`);i=[r,t,0],a=[r,t+1,0]}return{lower:i,upper:a}}function NU(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 yU(`${e} is in an invalid date format`)}throw new yU(`The date provided ${e} must be a string, number, or date object`)}function PU(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 FU=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const IU=3e4;var LU=class extends TH{constructor(e,t={}){if(super(e,t),this._memoryStorage=new FU,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):IU,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 xU({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 mU(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=mH(()=>{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=IU){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 bU||t instanceof yU)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=hU.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(hU.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(hU.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(hU.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=mH(()=>{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(VV(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(!mU.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(mU.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!mU.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(mU.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=CV(),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`&&DV(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}},RU=class{constructor(){this.storage=new Pe}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 zU=`posthog-node`;function BU(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[VU.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 VU=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=zU,this.name=zU,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(BU(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};mU.errorPropertiesBuilder=new AH([new KH,new BH,new GH,new HH,new qH],zH(`node:javascript`,NH),[lV(),ZH]);const HU=new class extends LU{getLibraryId(){return`posthog-node`}initializeContext(){return new RU}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`}),UU=X({email:Y}),WU=km(`getClaudeCodeEmail`)(function*(){let e=yield*(yield*pk).string(_k(`claude`,[`auth`,`status`])).pipe(Fp(`5 seconds`));return(yield*sx($x(UU))(e)).email}),GU=km(`getGitEmail`)(function*(){let e=yield*(yield*pk).string(_k(`git`,[`config`,`user.email`])).pipe(Fp(`5 seconds`),q(e=>e.trim()));return e.length===0?yield*G(`empty`):e}),KU=km(`getGitName`)(function*(){let e=yield*(yield*pk).string(_k(`git`,[`config`,`user.name`])).pipe(Fp(`5 seconds`),q(e=>e.trim()));return e.length===0?yield*G(`empty`):e});var qU=class extends Ga()(`@expect/AnalyticsProvider`){static layerPostHog=tf(this)({capture:e=>W(()=>{HU.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>W(()=>{HU.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:up({try:()=>HU.flush(),catch:e=>e}).pipe(Pp)});static layerDev=tf(this)({capture:e=>Mm(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(Pm({module:`Analytics`})),identify:e=>Mm(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(Pm({module:`Analytics`})),flush:mp})},JU=class extends Ga()(`@expect/Analytics`,{make:gp(function*(){let e=yield*qU,t=yield*up({try:()=>(0,tV.machineId)(),catch:()=>`unknown`}),n=cV(process.cwd());yield*op({email:WU().pipe(J(`PlatformError`,()=>GU()),J(`TimeoutError`,()=>GU()),J(`SchemaError`,()=>GU())),name:KU().pipe(kp(()=>U(void 0)))}).pipe(Cp(({email:n,name:r})=>e.identify({distinctId:t,email:n,name:r})),kp(()=>mp),mm);let r=(r,...[i])=>gp(function*(){let a={timestamp:new Date().toISOString(),projectId:n};yield*e.capture({eventName:r,properties:{...a,...i??{}},distinctId:t})}).pipe(kp(e=>Am(`Analytics capture failed`,{eventName:r,cause:e}).pipe(Pm({module:`Analytics`}))));return{capture:r,track:((e,t)=>n=>Cp(n,n=>{let i=t?t(n):void 0;return r.call(void 0,e,...i===void 0?[]:[i])})),flush:e.flush}})}){static layerPostHog=rf(this)(this.make).pipe(ff(qU.layerPostHog),ff(pe.layer));static layerDev=rf(this)(this.make).pipe(ff(qU.layerDev),ff(pe.layer))};const YU=e=>{let t=rd(e);return{error_tag:I(t,`_tag`)?String(t._tag):`Unknown`,error_message:cd(e)}};(class extends Ga()(`@expect/ErrorHandler`,{make:gp(function*(){let e=yield*JU;return{orDie:t=>t.pipe(Np(t=>e.capture(`error:unexpected`,YU(t))),Mp),streamOrDie:t=>t.pipe(oC(t=>e.capture(`error:unexpected`,YU(t))),cC),tapCause:(...t)=>n=>n.pipe(Np(n=>op([e.capture(`error:expected`,YU(n)),jm(...t,n)],{discard:!0})))}})}){static layer=rf(this)(this.make)});const XU=`~effect/socket/Socket`,ZU=e=>I(e,XU),QU=Ga(`effect/socket/Socket`),$U=e=>I(e,`~effect/socket/Socket/CloseEvent`),eW=`~effect/socket/Socket/SocketError`,tW=e=>I(e,eW);var nW=class extends lS(`effect/socket/Socket/SocketReadError`)({_tag:Bx(`SocketReadError`),cause:Zx}){message=`An error occurred during Read`},rW=class extends lS(`effect/socket/Socket/SocketWriteError`)({_tag:Bx(`SocketWriteError`),cause:Zx}){message=`An error occurred during Write`},iW=class extends lS(`effect/socket/Socket/SocketOpenError`)({_tag:Bx(`SocketOpenError`),kind:Nx([`Unknown`,`Timeout`]),cause:Zx}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},aW=class extends lS(`effect/socket/Socket/SocketCloseError`)({_tag:Bx(`SocketCloseError`),code:Sx,closeReason:hx(Y)}){static filterClean(e){return function(t){return sW.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?hi(t.reason):gi(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}};const oW=Mx([nW,rW,iW,aW]);var sW=class extends uS(eW)(`SocketError`,{_tag:Bx(`SocketError`),reason:oW}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[eW]=eW;static is(e){return tW(e)}message=this.reason.message};const cW=(e,t)=>By(Om(function*(n,r){let i=yield*cy(),a=yield*Bd(r),o=yield*Ld(e.writer,a),s,c=0,l=cp({while:()=>c<s.length,body:()=>o(s[c++]),step:et});return yield*n.pipe(K(e=>e.length===1?o(e[0]):(s=e,c=0,l)),lm({disableYield:!0}),jp(Qf,e=>py(i,e)),nm(Hd(a,yd)),fm(r)),yield*e.runRaw(e=>{fy(i,t(e))}).pipe(Cy(i),fm(r)),vy(i)})),lW=P(e=>ZU(e[0]),(e,t)=>{let n=new TextDecoder(t);return cW(e,e=>typeof e==`string`?e:n.decode(e))}),uW=e=>e!==1e3&&e!==1006;var dW=class extends Ga()(`~effect/socket/Socket/WebSocket`){},fW=class extends Ga()(`@effect/platform/Socket/WebSocketConstructor`){};const pW=tf(fW)((e,t)=>new globalThis.WebSocket(e,t)),mW=(e,t)=>fW.use(n=>hW(em((typeof e==`string`?U(e):e).pipe(q(e=>n(e,t?.protocols))),e=>W(()=>e.close(1e3))),t)),hW=(e,t)=>bp(n=>{let r,i=bv(!1),a=n.services,o=t?.closeCodeIsError??uW,s=(n,s)=>$p(Om(function*(a){let c=yield*lw().pipe(Ld(a)),l=yield*Ld(e,a),u=yield*Xp(pw(c)(),dW,l),d=!1;function f(e){if(e.data instanceof Blob)return u(K(lp(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return ap(t)?t:mp}));let t=n(e.data);ap(t)&&u(t)}function p(e){l.removeEventListener(`message`,f),l.removeEventListener(`close`,m),Nd(c.deferred,G(new sW({reason:d?new nW({cause:e}):new iW({kind:`Unknown`,cause:e})})))}function m(e){let t=typeof e.code==`number`?e.code:1001;l.removeEventListener(`message`,f),l.removeEventListener(`error`,p),Nd(c.deferred,G(new sW({reason:new aW({code:t,closeReason:e.reason})})))}if(l.addEventListener(`close`,m,{once:!0}),l.addEventListener(`error`,p,{once:!0}),l.addEventListener(`message`,f),l.readyState!==1){let e=wd();l.addEventListener(`open`,()=>{d=!0,Nd(e,mp)},{once:!0}),yield*Ed(e).pipe(Lp({duration:t?.openTimeout??1e4,onTimeout:()=>G(new sW({reason:new iW({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),Bp(mw(c)))}return d=!0,r=l,i.openUnsafe(),s?.onOpen&&(yield*s.onOpen),yield*Ap(mw(c),aW.filterClean(e=>!o(e)),()=>mp)})).pipe(Yp(e=>fo(a,e)),nm(W(()=>{i.closeUnsafe(),r=void 0}))),c=new TextEncoder,l=(e,t)=>s(t=>typeof t==`string`?e(c.encode(t)):t instanceof Uint8Array?e(t):e(new Uint8Array(t)),t),u=U(e=>i.whenOpen(W(()=>{let t=r;$U(e)?t.close(e.code,e.reason):t.send(e)})));return U(QU.of({[XU]:XU,run:l,runRaw:s,writer:u}))}),gW=nt(mW,rf(QU)),_W=`~effect/encoding/Ndjson/NdjsonError`;var vW=class extends Sf(`NdjsonError`){[_W]=_W;get message(){return this.kind}};const yW=()=>By((e,t)=>U(K(e,e=>{try{return U(Vi(e.map(e=>JSON.stringify(e)).join(`
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=pf()(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)}})),vf=n(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=mf():t.exports=_f()})),yf=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(vf()).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})),bf=n((e=>{function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,`__esModule`,{value:!0}),t(yf())})),xf=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})),Sf=bf(),Cf=t(vf(),1),wf=xf(),Tf=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,Df=Object.getOwnPropertyNames,Of=Object.prototype.hasOwnProperty,Z=(e,t)=>function(){return e&&(t=(0,e[Df(e)[0]])(e=0)),t},kf=(e,t)=>function(){return t||(0,e[Df(e)[0]])((t={exports:{}}).exports,t),t.exports},Af=(e,t)=>{for(var n in t)Tf(e,n,{get:t[n],enumerable:!0})},jf=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Df(t))!Of.call(e,i)&&i!==n&&Tf(e,i,{get:()=>t[i],enumerable:!(r=Ef(t,i))||r.enumerable});return e},Mf=e=>jf(Tf({},`__esModule`,{value:!0}),e);function Nf(...e){let t=new String(e);return If.set(t,e),t}function Pf(e){return e instanceof String&&If.has(e)}function Ff(e){return If.get(e)||[]}var If,Lf=Z({"src/lib/args/pathspec.ts"(){If=new WeakMap}}),Rf,zf=Z({"src/lib/errors/git-error.ts"(){Rf=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),Bf,Vf=Z({"src/lib/errors/git-response-error.ts"(){zf(),Bf=class extends Rf{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),Hf,Uf=Z({"src/lib/errors/task-configuration-error.ts"(){zf(),Hf=class extends Rf{constructor(e){super(void 0,e)}}}});function Wf(e){return typeof e==`function`?e:fp}function Gf(e){return typeof e==`function`&&e!==fp}function Kf(e,t){let n=e.indexOf(t);return n<=0?[e,``]:[e.substr(0,n),e.substr(n+1)]}function qf(e,t=0){return Yf(e)&&e.length>t?e[t]:void 0}function Jf(e,t=0){if(Yf(e)&&e.length>t)return e[e.length-1-t]}function Yf(e){return Cp(e)}function Xf(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 Zf(e,t){return Xf(e,!0).map(e=>t(e))}function Qf(e){return(0,Sf.exists)(e,Sf.FOLDER)}function $f(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function ep(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function tp(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function np(e){return Array.isArray(e)?e:[e]}function rp(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function ip(e){return np(e).map(e=>e instanceof String?e:String(e))}function ap(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function op(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function sp(e){return(Array.isArray(e)?za.concat(e):e).toString(`utf-8`)}function cp(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function lp(e=0){return new Promise(t=>setTimeout(t,e))}function up(e){if(e!==!1)return e}var dp,fp,pp,mp=Z({"src/lib/utils/util.ts"(){wp(),dp=`\0`,fp=()=>{},pp=Object.prototype.toString.call.bind(Object.prototype.toString)}});function hp(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function gp(e,t){let n=Pf(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function _p(e){return!!e&&pp(e)===`[object Object]`}function vp(e){return typeof e==`function`}var yp,bp,xp,Sp,Cp,wp=Z({"src/lib/utils/argument-filters.ts"(){Lf(),mp(),yp=e=>Array.isArray(e),bp=e=>typeof e==`number`,xp=e=>typeof e==`string`||Pf(e),Sp=e=>xp(e)||Array.isArray(e)&&e.every(xp),Cp=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),Tp,Ep=Z({"src/lib/utils/exit-codes.ts"(){Tp=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(Tp||{})}}),Dp,Op=Z({"src/lib/utils/git-output-streams.ts"(){Dp=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function kp(){throw Error(`LineParser:useMatches not implemented`)}var Q,Ap,jp=Z({"src/lib/utils/line-parser.ts"(){Q=class{constructor(e,t){this.matches=[],this.useMatches=kp,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))}},Ap=class extends Q{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 Mp(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...Np},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var Np,Pp=Z({"src/lib/utils/simple-git-options.ts"(){Np={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Fp(e,t=[]){return _p(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(Pf(r))t.push(r);else if(gp(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)gp(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function Ip(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 Fp(Rp(e),r),n||r.push(...Lp(e)),r}function Lp(e){return ip(hp(Jf(e,typeof Jf(e)==`function`?1:0),yp,[]))}function Rp(e){return hp(Jf(e,vp(Jf(e))?1:0),_p)}function zp(e,t=!0){let n=Wf(Jf(e));return t||Gf(n)?n:void 0}var Bp=Z({"src/lib/utils/task-options.ts"(){wp(),mp(),Lf()}});function Vp(e,t){return e(t.stdOut,t.stdErr)}function Hp(e,t,n,r=!0){return np(n).forEach(n=>{for(let i=Xf(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 Up=Z({"src/lib/utils/task-parser.ts"(){mp()}}),Wp={};Af(Wp,{ExitCodes:()=>Tp,GitOutputStreams:()=>Dp,LineParser:()=>Q,NOOP:()=>fp,NULL:()=>dp,RemoteLineParser:()=>Ap,append:()=>$f,appendTaskOptions:()=>Fp,asArray:()=>np,asCamelCase:()=>rp,asFunction:()=>Wf,asNumber:()=>ap,asStringArray:()=>ip,bufferToString:()=>sp,callTaskParser:()=>Vp,createInstanceConfig:()=>Mp,delay:()=>lp,filterArray:()=>yp,filterFunction:()=>vp,filterHasLength:()=>Cp,filterNumber:()=>bp,filterPlainObject:()=>_p,filterPrimitives:()=>gp,filterString:()=>xp,filterStringOrStringArray:()=>Sp,filterType:()=>hp,first:()=>qf,folderExists:()=>Qf,forEachLineWithContent:()=>Zf,getTrailingOptions:()=>Ip,including:()=>ep,isUserFunction:()=>Gf,last:()=>Jf,objectToString:()=>pp,orVoid:()=>up,parseStringResponse:()=>Hp,pick:()=>cp,prefixedArray:()=>op,remove:()=>tp,splitOn:()=>Kf,toLinesWithContent:()=>Xf,trailingFunctionArgument:()=>zp,trailingOptionsArgument:()=>Rp});var $=Z({"src/lib/utils/index.ts"(){wp(),Ep(),Op(),jp(),Pp(),Bp(),Up(),mp()}}),Gp={};Af(Gp,{CheckRepoActions:()=>Xp,checkIsBareRepoTask:()=>Jp,checkIsRepoRootTask:()=>qp,checkIsRepoTask:()=>Kp});function Kp(e){switch(e){case`bare`:return Jp();case`root`:return qp()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:Zp,parser:Qp}}function qp(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:Zp,parser(e){return/^\.(git)?$/.test(e.trim())}}}function Jp(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:Zp,parser:Qp}}function Yp(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var Xp,Zp,Qp,$p=Z({"src/lib/tasks/check-is-repo.ts"(){$(),Xp=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(Xp||{}),Zp=({exitCode:e},t,n,r)=>{if(e===128&&Yp(t))return n(Buffer.from(`false`));r(t)},Qp=e=>e.trim()===`true`}});function em(e,t){let n=new tm(e),r=e?rm:nm;return Xf(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(im.test(t)?n.folders:n.files).push(t)}),n}var tm,nm,rm,im,am=Z({"src/lib/responses/CleanSummary.ts"(){$(),tm=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},nm=/^[a-z]+\s*/i,rm=/^[a-z]+\s+[a-z]+\s*/i,im=/\/$/}}),om={};Af(om,{EMPTY_COMMANDS:()=>pm,adhocExecTask:()=>sm,configurationErrorTask:()=>cm,isBufferTask:()=>dm,isEmptyTask:()=>fm,straightThroughBufferTask:()=>um,straightThroughStringTask:()=>lm});function sm(e){return{commands:pm,format:`empty`,parser:e}}function cm(e){return{commands:pm,format:`empty`,parser(){throw typeof e==`string`?new Hf(e):e}}}function lm(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function um(e){return{commands:e,format:`buffer`,parser(e){return e}}}function dm(e){return e.format===`buffer`}function fm(e){return e.format===`empty`||!e.commands.length}var pm,mm=Z({"src/lib/tasks/task.ts"(){Uf(),pm=[]}}),hm={};Af(hm,{CONFIG_ERROR_INTERACTIVE_MODE:()=>Cm,CONFIG_ERROR_MODE_REQUIRED:()=>wm,CONFIG_ERROR_UNKNOWN_OPTION:()=>Tm,CleanOptions:()=>Em,cleanTask:()=>_m,cleanWithOptionsTask:()=>gm,isCleanOptionsArray:()=>vm});function gm(e,t){let{cleanMode:n,options:r,valid:i}=ym(e);return n?i.options?(r.push(...t),r.some(Sm)?cm(Cm):_m(n,r)):cm(Tm+JSON.stringify(e)):cm(wm)}function _m(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return em(e===`n`,t)}}}function vm(e){return Array.isArray(e)&&e.every(e=>Dm.has(e))}function ym(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{bm(e)?(t=e,r.cleanMode=!0):r.options=r.options&&xm(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function bm(e){return e===`f`||e===`n`}function xm(e){return/^-[a-z]$/i.test(e)&&Dm.has(e.charAt(1))}function Sm(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var Cm,wm,Tm,Em,Dm,Om=Z({"src/lib/tasks/clean.ts"(){am(),$(),mm(),Cm=`Git clean interactive mode is not supported`,wm=`Git clean mode parameter ("n" or "f") is required`,Tm=`Git clean unknown option found in: `,Em=(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))(Em||{}),Dm=new Set([`i`,...ip(Object.values(Em))])}});function km(e){let t=new Nm;for(let n of Mm(e))t.addValue(n.file,String(n.key),n.value);return t}function Am(e,t){let n=null,r=[],i=new Map;for(let a of Mm(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 jm(e){return e.replace(/^(file):/,``)}function*Mm(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=jm(n[e++]),i=n[e++],a=t;if(i.includes(`
20
+ `)){let e=Kf(i,`
21
+ `);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var Nm,Pm=Z({"src/lib/responses/ConfigList.ts"(){$(),Nm=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=Jf(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 Fm(e,t){return typeof e==`string`&&Object.hasOwn(Bm,e)?e:t}function Im(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 Lm(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 Am(t,e)}}}function Rm(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return km(e)}}}function zm(){return{addConfig(e,t,...n){return this._runTask(Im(e,t,n[0]===!0,Fm(n[1],`local`)),zp(arguments))},getConfig(e,t){return this._runTask(Lm(e,Fm(t,void 0)),zp(arguments))},listConfig(...e){return this._runTask(Rm(Fm(e[0],void 0)),zp(arguments))}}}var Bm,Vm=Z({"src/lib/tasks/config.ts"(){Pm(),$(),Bm=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(Bm||{})}});function Hm(e){return Wm.has(e)}var Um,Wm,Gm=Z({"src/lib/tasks/diff-name-status.ts"(){Um=(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))(Um||{}),Wm=new Set(Object.values(Um))}});function Km(...e){return new Qm().param(...e)}function qm(e){let t=new Set,n={};return Zf(e,e=>{let[r,i,a]=e.split(dp);t.add(r),(n[r]=n[r]||[]).push({line:ap(i),path:r,preview:a})}),{paths:t,results:n}}function Jm(){return{grep(e){let t=zp(arguments),n=Ip(arguments);for(let e of Ym)if(n.includes(e))return this._runTask(cm(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Km().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return qm(e)}},t)}}}var Ym,Xm,Zm,Qm,$m=Z({"src/lib/tasks/grep.ts"(){$(),mm(),Ym=[`-h`],Xm=Symbol(`grepQuery`),Qm=class{constructor(){this[Zm]=[]}*[(Zm=Xm,Symbol.iterator)](){for(let e of this[Xm])yield e}and(...e){return e.length&&this[Xm].push(`--and`,`(`,...op(e,`-e`),`)`),this}param(...e){return this[Xm].push(...op(e,`-e`)),this}}}}),eh={};Af(eh,{ResetMode:()=>ih,getResetMode:()=>nh,resetTask:()=>th});function th(e,t){let n=[`reset`];return rh(e)&&n.push(`--${e}`),n.push(...t),lm(n)}function nh(e){if(rh(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function rh(e){return typeof e==`string`&&ah.includes(e)}var ih,ah,oh=Z({"src/lib/tasks/reset.ts"(){$(),mm(),ih=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(ih||{}),ah=ip(Object.values(ih))}});function sh(){return(0,Cf.default)(`simple-git`)}function ch(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 lh(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 uh(e,t,n,r=sh()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=lh(hp(t,xp),o,r);return l(n);function c(t,n){return $f(a,uh(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&ch(o,n)||fp,s=ch(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var dh=Z({"src/lib/git-logger.ts"(){$(),Cf.default.formatters.L=e=>String(Cp(e)?e.length:`-`),Cf.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):pp(e)}}),fh,ph=Z({"src/lib/runners/tasks-pending-queue.ts"(){zf(),dh(),fh=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:uh(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 Rf(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 mh(e,t){return{method:qf(e.commands)||``,commands:t}}function hh(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function gh(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var _h,vh=Z({"src/lib/runners/git-executor-chain.ts"(){zf(),mm(),$(),ph(),_h=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new fh}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(fm(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 Rf?Object.assign(t,{task:e}):new Rf(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`,``,mh(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],mh(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),dm(e)?Vp(e.parser,a):Vp(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},{...mh(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`,pp(e)),c(new Dp(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 Dp(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},mh(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,{...mh(e,n),kill(e){u=e||u}});let d=Va(t,n,o);d.stdout.on(`data`,gh(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,gh(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,hh(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,{...mh(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,{...mh(e,t),kill(e){n=e||n}}),n}}}}),yh={};Af(yh,{GitExecutor:()=>bh});var bh,xh=Z({"src/lib/runners/git-executor.ts"(){vh(),bh=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new _h(this,this._scheduler,this._plugins)}chain(){return new _h(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function Sh(e,t,n=fp){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof Bf?Ch(t):t,void 0)})}function Ch(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=fp};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 wh=Z({"src/lib/task-callback.ts"(){Vf(),$()}});function Th(e,t){return sm(n=>{if(!Qf(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var Eh=Z({"src/lib/tasks/change-working-directory.ts"(){$(),mm()}});function Dh(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=tp(t,`-B`)),lm(t)}function Oh(){return{checkout(){return this._runTask(Dh(Ip(arguments,1)),zp(arguments))},checkoutBranch(e,t){return this._runTask(Dh([`-b`,e,t,...Ip(arguments)]),zp(arguments))},checkoutLocalBranch(e){return this._runTask(Dh([`-b`,e,...Ip(arguments)]),zp(arguments))}}}var kh=Z({"src/lib/tasks/checkout.ts"(){$(),mm()}});function Ah(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function jh(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return Hp(Ah(),[Mh],e)}})}}}var Mh,Nh=Z({"src/lib/tasks/count-objects.ts"(){$(),Mh=new Q(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=rp(t);Object.hasOwn(e,r)&&(e[r]=ap(n))})}});function Ph(e){return Hp({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},Fh,e)}var Fh,Ih=Z({"src/lib/parsers/parse-commit.ts"(){$(),Fh=[new Q(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new Q(/\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 Q(/(\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 Q(/^(\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 Lh(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...op(e,`-m`),...t,...n],format:`utf-8`,parser:Ph}}function Rh(){return{commit(t,...n){let r=zp(arguments),i=e(t)||Lh(np(t),np(hp(n[0],Sp,[])),[...ip(hp(n[1],yp,[])),...Ip(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!Sp(e)&&cm(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var zh=Z({"src/lib/tasks/commit.ts"(){Ih(),$(),mm()}});function Bh(){return{firstCommit(){return this._runTask(lm([`rev-list`,`--max-parents=0`,`HEAD`],!0),zp(arguments))}}}var Vh=Z({"src/lib/tasks/first-commit.ts"(){$(),mm()}});function Hh(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),lm(n,!0)}var Uh=Z({"src/lib/tasks/hash-object.ts"(){mm()}});function Wh(e,t,n){let r=String(n).trim(),i;if(i=Kh.exec(r))return new Gh(e,t,!1,i[1]);if(i=qh.exec(r))return new Gh(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new Gh(e,t,/^re/i.test(r),a)}var Gh,Kh,qh,Jh=Z({"src/lib/responses/InitSummary.ts"(){Gh=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},Kh=/^Init.+ repository in (.+)$/,qh=/^Rein.+ in (.+)$/}});function Yh(e){return e.includes(Zh)}function Xh(e=!1,t,n){let r=[`init`,...n];return e&&!Yh(r)&&r.splice(1,0,Zh),{commands:r,format:`utf-8`,parser(e){return Wh(r.includes(`--bare`),t,e)}}}var Zh,Qh=Z({"src/lib/tasks/init.ts"(){Jh(),Zh=`--bare`}});function $h(e){for(let t=0;t<e.length;t++){let n=tg.exec(e[t]);if(n)return`--${n[1]}`}return``}function eg(e){return tg.test(e)}var tg,ng=Z({"src/lib/args/log-format.ts"(){tg=/^--(stat|numstat|name-only|name-status)(=|$)/}}),rg,ig=Z({"src/lib/responses/DiffSummary.ts"(){rg=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function ag(e=``){let t=ug[e];return e=>Hp(new rg,t,e,!1)}var og,sg,cg,lg,ug,dg=Z({"src/lib/parsers/parse-diff-summary.ts"(){ng(),ig(),Gm(),$(),og=[new Q(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:ap(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new Q(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:ap(n),after:ap(r),binary:!0})}),new Q(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=ap(t),e.insertions=ap(r?.[1]),e.deletions=ap(i?.[1])})],sg=[new Q(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=ap(t),a=ap(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new Q(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],cg=[new Q(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],lg=[new Q(/([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:up(Hm(t)&&t),from:up(!!a&&r!==a&&r),similarity:ap(n)})})],ug={"":og,"--stat":og,"--numstat":sg,"--name-status":lg,"--name-only":cg}}});function fg(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function pg(e=gg,t=_g,n=``){let r=ag(n);return function(n){let i=Xf(n.trim(),!1,mg).map(function(n){let i=n.split(hg),a=fg(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 mg,hg,gg,_g,vg=Z({"src/lib/parsers/parse-list-log-summary.ts"(){$(),dg(),ng(),mg=`òòòòòò `,hg=` òò`,gg=` ò `,_g=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),yg={};Af(yg,{diffSummaryTask:()=>bg,validateLogFormatConfig:()=>xg});function bg(e){let t=$h(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),xg(n)||{commands:n,format:`utf-8`,parser:ag(t)}}function xg(e){let t=e.filter(eg);if(t.length>1)return cm(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return cm(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var Sg=Z({"src/lib/tasks/diff.ts"(){ng(),dg(),mm()}});function Cg(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function wg(e){return Object.keys(e).reduce((t,n)=>(n in Og||(t[n]=e[n]),t),{})}function Tg(e={},t=[]){let n=hp(e.splitter,xp,gg),[r,i]=Cg(_p(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:${mg}${i}${hg}`,...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 xp(e.file)&&o.push(`--follow`,Nf(e.file)),Fp(wg(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function Eg(e,t,n){let r=pg(e,t,$h(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function Dg(){return{log(...n){let r=zp(arguments),i=Tg(Rp(arguments),ip(hp(arguments[0],yp,[]))),a=t(...n)||xg(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return Eg(e.splitter,e.fields,e.commands)}function t(e,t){return xp(e)&&xp(t)&&cm(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var Og,kg=Z({"src/lib/tasks/log.ts"(){ng(),Lf(),vg(),$(),mm(),Sg(),Og=(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))(Og||{})}}),Ag,jg,Mg=Z({"src/lib/responses/MergeSummary.ts"(){Ag=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},jg=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`}}}}),Ng,Pg,Fg=Z({"src/lib/responses/PullSummary.ts"(){Ng=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},Pg=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function Ig(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 Lg(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:ap(t&&t[1]||`0`),delta:ap(n&&n[1]||`0`)}}var Rg,zg=Z({"src/lib/parsers/parse-remote-objects.ts"(){$(),Rg=[new Ap(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ig(e.remoteMessages);Object.assign(i,{[r]:ap(n)})}),new Ap(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ig(e.remoteMessages);Object.assign(i,{[r]:ap(n)})}),new Ap(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=Ig(e.remoteMessages);i.total=Lg(t),i.reused=Lg(n),i.packReused=ap(r)})]}});function Bg(e,t){return Hp({remoteMessages:new Hg},Vg,t)}var Vg,Hg,Ug=Z({"src/lib/parsers/parse-remote-messages.ts"(){$(),zg(),Vg=[new Ap(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...Rg,new Ap([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new Ap([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:ap(t),summary:n,url:r}})],Hg=class{constructor(){this.all=[]}}}});function Wg(e,t){let n=Hp(new Pg,Yg,[e,t]);return n.message&&n}var Gg,Kg,qg,Jg,Yg,Xg,Zg,Qg=Z({"src/lib/parsers/parse-pull.ts"(){Fg(),$(),Ug(),Gg=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Kg=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,qg=/^(create|delete) mode \d+ (.+)/,Jg=[new Q(Gg,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new Q(Kg,(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 Q(qg,(e,[t,n])=>{$f(e.files,n),$f(t===`create`?e.created:e.deleted,n)})],Yg=[new Q(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new Q(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new Q(/([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})],Xg=(e,t)=>Hp(new Ng,Jg,[e,t]),Zg=(e,t)=>Object.assign(new Ng,Xg(e,t),Bg(e,t))}}),$g,e_,t_,n_=Z({"src/lib/parsers/parse-merge.ts"(){Mg(),$(),Qg(),$g=[new Q(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new Q(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new Ag(t,n))}),new Q(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new Ag(t,n,{deleteRef:r}))}),new Q(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new Ag(t,null))}),new Q(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],e_=(e,t)=>Object.assign(t_(e,t),Zg(e,t)),t_=e=>Hp(new jg,$g,e)}});function r_(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=e_(e,t);if(n.failed)throw new Bf(n);return n}}:cm(`Git.merge requires at least one option`)}var i_=Z({"src/lib/tasks/merge.ts"(){Vf(),n_(),mm()}});function a_(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 o_,s_,c_,l_=Z({"src/lib/parsers/parse-push.ts"(){$(),Ug(),o_=[new Q(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new Q(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new Q(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(a_(t,n,r))}),new Q(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new Q(/^([^:]+):(\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}}})],s_=(e,t)=>{let n=c_(e,t),r=Bg(e,t);return{...n,...r}},c_=(e,t)=>Hp({pushed:[]},o_,[e,t])}}),u_={};Af(u_,{pushTagsTask:()=>d_,pushTask:()=>f_});function d_(e={},t){return $f(t,`--tags`),f_(e,t)}function f_(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),tp(n,`-v`),$f(n,`--verbose`),$f(n,`--porcelain`),{commands:n,format:`utf-8`,parser:s_}}var p_=Z({"src/lib/tasks/push.ts"(){l_(),$()}});function m_(){return{showBuffer(){let e=[`show`,...Ip(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(um(e),zp(arguments))},show(){let e=[`show`,...Ip(arguments,1)];return this._runTask(lm(e),zp(arguments))}}}var h_=Z({"src/lib/tasks/show.ts"(){$(),mm()}}),g_,__,v_=Z({"src/lib/responses/FileStatusSummary.ts"(){g_=/^(.+)\0(.+)$/,__=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=g_.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function y_(e){let[t,n]=e.split(dp);return{from:n||t,to:t}}function b_(e,t,n){return[`${e}${t}`,n]}function x_(e,...t){return t.map(t=>b_(e,t,(e,t)=>e.conflicted.push(t)))}function S_(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=w_.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new __(r,t,n))}}var C_,w_,T_,E_=Z({"src/lib/responses/StatusSummary.ts"(){$(),v_(),C_=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}},w_=new Map([b_(` `,`A`,(e,t)=>e.created.push(t)),b_(` `,`D`,(e,t)=>e.deleted.push(t)),b_(` `,`M`,(e,t)=>e.modified.push(t)),b_(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),b_(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),b_(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),b_(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),b_(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),b_(`R`,` `,(e,t)=>{e.renamed.push(y_(t))}),b_(`R`,`M`,(e,t)=>{let n=y_(t);e.renamed.push(n),e.modified.push(n.to)}),b_(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),b_(`?`,`?`,(e,t)=>e.not_added.push(t)),...x_(`A`,`A`,`U`),...x_(`D`,`D`,`U`),...x_(`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=hp(s?.[1],xp,null),s=a.exec(t),e.tracking=hp(s?.[1],xp,null),s=o.exec(t),s&&(e.current=hp(s?.[1],xp,e.current)),e.detached=/\(no branch\)/.test(t)}]]),T_=function(e){let t=e.split(dp),n=new C_;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=dp+(t[e++]||``)),S_(n,r))}return n}}});function D_(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!O_.includes(e))],parser(e){return T_(e)}}}var O_,k_=Z({"src/lib/tasks/status.ts"(){E_(),O_=[`--null`,`-z`]}});function A_(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 j_(){return A_(0,0,0,``,!1)}function M_(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:N_,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(P_));r(t)}})}}}function N_(e){return e===P_?j_():Hp(A_(0,0,0,e),F_,e)}var P_,F_,I_=Z({"src/lib/tasks/version.ts"(){$(),P_=`installed=false`,F_=[new Q(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,A_(ap(t),ap(n),ap(r),i))}),new Q(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,A_(ap(t),ap(n),r,i))})]}});function L_(e,t,n,...r){return xp(n)?t(n,hp(r[0],xp),Ip(arguments)):cm(`git.${e}() requires a string 'repoPath'`)}function R_(){return{clone(e,...t){return this._runTask(L_(`clone`,z_,hp(e,xp),...t),zp(arguments))},mirror(e,...t){return this._runTask(L_(`mirror`,B_,hp(e,xp),...t),zp(arguments))}}}var z_,B_,V_=Z({"src/lib/tasks/clone.ts"(){mm(),$(),Lf(),z_=(e,t,n)=>{let r=[`clone`,...n];return xp(e)&&r.push(Nf(e)),xp(t)&&r.push(Nf(t)),lm(r)},B_=(e,t,n)=>($f(n,`--mirror`),z_(e,t,n))}}),H_={};Af(H_,{SimpleGitApi:()=>U_});var U_,W_=Z({"src/lib/simple-git-api.ts"(){wh(),Eh(),kh(),Nh(),zh(),Vm(),Vh(),$m(),Uh(),Qh(),kg(),i_(),p_(),h_(),k_(),mm(),I_(),$(),V_(),U_=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&Sh(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(lm([`add`,...np(e)]),zp(arguments))}cwd(e){let t=zp(arguments);return typeof e==`string`?this._runTask(Th(e,this._executor),t):typeof e?.path==`string`?this._runTask(Th(e.path,e.root&&this._executor||void 0),t):this._runTask(cm(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(Hh(e,t===!0),zp(arguments))}init(e){return this._runTask(Xh(e===!0,this._executor.cwd,Ip(arguments)),zp(arguments))}merge(){return this._runTask(r_(Ip(arguments)),zp(arguments))}mergeFromTo(e,t){return xp(e)&&xp(t)?this._runTask(r_([e,t,...Ip(arguments)]),zp(arguments,!1)):this._runTask(cm(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=f_({remote:hp(arguments[0],xp),branch:hp(arguments[1],xp)},Ip(arguments));return this._runTask(e,zp(arguments))}stash(){return this._runTask(lm([`stash`,...Ip(arguments)]),zp(arguments))}status(){return this._runTask(D_(Ip(arguments)),zp(arguments))}},Object.assign(U_.prototype,Oh(),R_(),Rh(),zm(),jh(),Bh(),Jm(),Dg(),m_(),M_())}}),G_={};Af(G_,{Scheduler:()=>q_});var K_,q_,J_=Z({"src/lib/runners/scheduler.ts"(){$(),dh(),K_=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,wf.createDeferred)();return{promise:t,done:n,id:e}}})(),q_=class{constructor(e=2){this.concurrency=e,this.logger=uh(``,`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=$f(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),tp(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=$f(this.pending,K_());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),Y_={};Af(Y_,{applyPatchTask:()=>X_});function X_(e,t){return lm([`apply`,...t,...e])}var Z_=Z({"src/lib/tasks/apply-patch.ts"(){mm()}});function Q_(e,t){return{branch:e,hash:t,success:!0}}function $_(e){return{branch:e,hash:null,success:!1}}var ev,tv=Z({"src/lib/responses/BranchDeleteSummary.ts"(){ev=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function nv(e,t){return t===1&&iv.test(e)}var rv,iv,av,ov,sv=Z({"src/lib/parsers/parse-branch-delete.ts"(){tv(),$(),rv=/(\S+)\s+\(\S+\s([^)]+)\)/,iv=/^error[^']+'([^']+)'/m,av=[new Q(rv,(e,[t,n])=>{let r=Q_(t,n);e.all.push(r),e.branches[t]=r}),new Q(iv,(e,[t])=>{let n=$_(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],ov=(e,t)=>Hp(new ev,av,[e,t])}}),cv,lv=Z({"src/lib/responses/BranchSummary.ts"(){cv=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 uv(e){return e?e.charAt(0):``}function dv(e,t=!1){return Hp(new cv,t?[pv]:fv,e)}var fv,pv,mv=Z({"src/lib/parsers/parse-branch.ts"(){lv(),$(),fv=[new Q(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(uv(t),!0,n,r,i)}),new Q(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(uv(t),!1,n,r,i)})],pv=new Q(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),hv={};Af(hv,{branchLocalTask:()=>vv,branchTask:()=>_v,containsDeleteBranchCommand:()=>gv,deleteBranchTask:()=>bv,deleteBranchesTask:()=>yv});function gv(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function _v(e){let t=gv(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?ov(e,r).all[0]:dv(e,n)}}}function vv(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return dv(e)}}}function yv(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return ov(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!nv(String(n),e))return i(n);r(t)}}}function bv(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return ov(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!nv(String(i),e))return o(i);throw new Bf(n.parser(sp(r),sp(t)),String(i))}};return n}var xv=Z({"src/lib/tasks/branch.ts"(){Vf(),sv(),mv(),$()}});function Sv(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&ba(t)}var Cv,wv=Z({"src/lib/responses/CheckIgnore.ts"(){Cv=e=>e.split(/\n/g).map(Sv).filter(Boolean)}}),Tv={};Af(Tv,{checkIgnoreTask:()=>Ev});function Ev(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:Cv}}var Dv=Z({"src/lib/tasks/check-ignore.ts"(){wv()}});function Ov(e,t){return Hp({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},kv,[e,t])}var kv,Av=Z({"src/lib/parsers/parse-fetch.ts"(){$(),kv=[new Q(/From (.+)$/,(e,[t])=>{e.remote=t}),new Q(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new Q(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new Q(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new Q(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),jv={};Af(jv,{fetchTask:()=>Nv});function Mv(e){return/^--upload-pack(=|$)/.test(e)}function Nv(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(Mv)?cm(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:Ov}}var Pv=Z({"src/lib/tasks/fetch.ts"(){Av(),mm()}});function Fv(e){return Hp({moves:[]},Iv,e)}var Iv,Lv=Z({"src/lib/parsers/parse-move.ts"(){$(),Iv=[new Q(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),Rv={};Af(Rv,{moveTask:()=>zv});function zv(e,t){return{commands:[`mv`,`-v`,...np(e),t],format:`utf-8`,parser:Fv}}var Bv=Z({"src/lib/tasks/move.ts"(){Lv(),$()}}),Vv={};Af(Vv,{pullTask:()=>Hv});function Hv(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 Zg(e,t)},onError(e,t,n,r){let i=Wg(sp(e.stdOut),sp(e.stdErr));if(i)return r(new Bf(i));r(t)}}}var Uv=Z({"src/lib/tasks/pull.ts"(){Vf(),Qg(),$()}});function Wv(e){let t={};return Kv(e,([e])=>t[e]={name:e}),Object.values(t)}function Gv(e){let t={};return Kv(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 Kv(e,t){Zf(e,e=>t(e.split(/\s+/)))}var qv=Z({"src/lib/responses/GetRemoteSummary.ts"(){$()}}),Jv={};Af(Jv,{addRemoteTask:()=>Yv,getRemotesTask:()=>Xv,listRemotesTask:()=>Zv,remoteTask:()=>Qv,removeRemoteTask:()=>$v});function Yv(e,t,n){return lm([`remote`,`add`,...n,e,t])}function Xv(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Gv:Wv}}function Zv(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),lm(t)}function Qv(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),lm(t)}function $v(e){return lm([`remote`,`remove`,e])}var ey=Z({"src/lib/tasks/remote.ts"(){qv(),mm()}}),ty={};Af(ty,{stashListTask:()=>ny});function ny(e={},t){let n=Tg(e),r=[`stash`,`list`,...n.commands,...t],i=pg(n.splitter,n.fields,$h(r));return xg(r)||{commands:r,format:`utf-8`,parser:i}}var ry=Z({"src/lib/tasks/stash-list.ts"(){ng(),vg(),Sg(),kg()}}),iy={};Af(iy,{addSubModuleTask:()=>ay,initSubModuleTask:()=>oy,subModuleTask:()=>sy,updateSubModuleTask:()=>cy});function ay(e,t){return sy([`add`,e,t])}function oy(e){return sy([`init`,...e])}function sy(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),lm(t)}function cy(e){return sy([`update`,...e])}var ly=Z({"src/lib/tasks/sub-module.ts"(){mm()}});function uy(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?dy(e,t):0:n?1:-1}function dy(e,t){return e===t?0:e>t?1:-1}function fy(e){return e.trim()}function py(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var my,hy,gy=Z({"src/lib/responses/TagList.ts"(){my=class{constructor(e,t){this.all=e,this.latest=t}},hy=function(e,t=!1){let n=e.split(`
22
+ `).map(fy).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return uy(py(n[0]),py(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=dy(py(n[e]),py(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new my(n,r)}}}),_y={};Af(_y,{addAnnotatedTagTask:()=>by,addTagTask:()=>yy,tagListTask:()=>vy});function vy(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return hy(e,t)}}}function yy(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function by(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var xy=Z({"src/lib/tasks/tag.ts"(){gy()}}),Sy=kf({"src/git.js"(e,t){var{GitExecutor:n}=(xh(),Mf(yh)),{SimpleGitApi:r}=(W_(),Mf(H_)),{Scheduler:i}=(J_(),Mf(G_)),{adhocExecTask:a,configurationErrorTask:o}=(mm(),Mf(om)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=($(),Mf(Wp)),{applyPatchTask:g}=(Z_(),Mf(Y_)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(xv(),Mf(hv)),{checkIgnoreTask:x}=(Dv(),Mf(Tv)),{checkIsRepoTask:ee}=($p(),Mf(Gp)),{cleanWithOptionsTask:S,isCleanOptionsArray:C}=(Om(),Mf(hm)),{diffSummaryTask:w}=(Sg(),Mf(yg)),{fetchTask:te}=(Pv(),Mf(jv)),{moveTask:T}=(Bv(),Mf(Rv)),{pullTask:E}=(Uv(),Mf(Vv)),{pushTagsTask:D}=(p_(),Mf(u_)),{addRemoteTask:ne,getRemotesTask:O,listRemotesTask:k,remoteTask:A,removeRemoteTask:re}=(ey(),Mf(Jv)),{getResetMode:j,resetTask:ie}=(oh(),Mf(eh)),{stashListTask:M}=(ry(),Mf(ty)),{addSubModuleTask:ae,initSubModuleTask:N,subModuleTask:oe,updateSubModuleTask:P}=(ly(),Mf(iy)),{addAnnotatedTagTask:F,addTagTask:se,tagListTask:ce}=(xy(),Mf(_y)),{straightThroughBufferTask:le,straightThroughStringTask:I}=(mm(),Mf(om));function L(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(L.prototype=Object.create(r.prototype)).constructor=L,L.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},L.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},L.prototype.stashList=function(e){return this._runTask(M(h(arguments)||{},c(e)&&e||[]),m(arguments))},L.prototype.mv=function(e,t){return this._runTask(T(e,t),m(arguments))},L.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},L.prototype.pull=function(e,t,n,r){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},L.prototype.fetch=function(e,t){return this._runTask(te(f(e,u),f(t,u),p(arguments)),m(arguments))},L.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.")))},L.prototype.tags=function(e,t){return this._runTask(ce(p(arguments)),m(arguments))},L.prototype.rebase=function(){return this._runTask(I([`rebase`,...p(arguments)]),m(arguments))},L.prototype.reset=function(e){return this._runTask(ie(j(e),p(arguments)),m(arguments))},L.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(I([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},L.prototype.addTag=function(e){let t=typeof e==`string`?se(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},L.prototype.addAnnotatedTag=function(e,t){return this._runTask(F(e,t),m(arguments))},L.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},L.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},L.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},L.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},L.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(I(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},L.prototype.submoduleAdd=function(e,t,n){return this._runTask(ae(e,t),m(arguments))},L.prototype.submoduleUpdate=function(e,t){return this._runTask(P(p(arguments,!0)),m(arguments))},L.prototype.submoduleInit=function(e,t){return this._runTask(N(p(arguments,!0)),m(arguments))},L.prototype.subModule=function(e,t){return this._runTask(oe(p(arguments)),m(arguments))},L.prototype.listRemote=function(){return this._runTask(k(p(arguments)),m(arguments))},L.prototype.addRemote=function(e,t,n){return this._runTask(ne(e,t,p(arguments)),m(arguments))},L.prototype.removeRemote=function(e,t){return this._runTask(re(e),m(arguments))},L.prototype.getRemotes=function(e,t){return this._runTask(O(e===!0),m(arguments))},L.prototype.remote=function(e,t){return this._runTask(A(p(arguments)),m(arguments))},L.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(I(n),m(arguments))},L.prototype.updateServerInfo=function(e){return this._runTask(I([`update-server-info`]),m(arguments))},L.prototype.pushTags=function(e,t){let n=D({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},L.prototype.rm=function(e){return this._runTask(I([`rm`,`-f`,...s(e)]),m(arguments))},L.prototype.rmKeepLocal=function(e){return this._runTask(I([`rm`,`--cached`,...s(e)]),m(arguments))},L.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},L.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},L.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`?le(r):I(r);return this._runTask(a,n)},L.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`):I([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},L.prototype.diffSummary=function(){return this._runTask(w(p(arguments,1)),m(arguments))},L.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))},L.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(I(e,!0),m(arguments))},L.prototype.clean=function(e,t,n){let r=C(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(S(i,a),m(arguments))},L.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},L.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.`)))},L.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},L.prototype.checkIsRepo=function(e,t){return this._runTask(ee(f(e,u)),m(arguments))},t.exports=L}});Lf(),zf();var Cy=class extends Rf{constructor(e,t){super(void 0,t),this.config=e}};zf(),zf();var wy=class extends Rf{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};Vf(),Uf(),$p(),Om(),Vm(),Gm(),$m(),oh();function Ty(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new wy(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new wy(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function Ey(e){return typeof e==`string`&&e.trim().toLowerCase()===`-c`}function Dy(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 Oy(e,t,n=String(e)){let r=typeof e==`string`?RegExp(`\\s*${e}`,`i`):e;return function(e,i,a){if(e[t]!==!0&&Ey(i)&&r.test(a))throw new wy(void 0,`unsafe`,`Configuring ${n} is not permitted without enabling ${t}`)}}var ky=[Oy(/^\s*protocol(.[a-z]+)?.allow/i,`allowUnsafeProtocolOverride`,`protocol.allow`),Oy(`core.sshCommand`,`allowUnsafeSshCommand`),Oy(`core.gitProxy`,`allowUnsafeGitProxy`),Oy(`core.hooksPath`,`allowUnsafeHooksPath`),Oy(`diff.external`,`allowUnsafeDiffExternal`)];function Ay(e,t){if(/^\s*--(upload|receive)-pack/.test(e))throw new wy(void 0,`unsafe`,`Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);if(t===`clone`&&Dy(`u`,e))throw new wy(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 wy(void 0,`unsafe`,`Use of push with option --exec is not permitted without enabling allowUnsafePack`)}function jy({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||Ay(i,r.method),ky.forEach(e=>e(t,i,o))}),n}}}$();function My(e){let t=op(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}$();var Ny=(0,wf.deferred)().promise;function Py({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,wf.deferred)(),closeTimeout:(0,wf.deferred)(),exit:(0,wf.deferred)(),exitTimeout:(0,wf.deferred)()},a=Promise.race([e===!1?Ny:i.closeTimeout.promise,t===!1?Ny: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(()=>lp(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 lp(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}$();var Fy=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,Iy=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function Ly(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function Ry(e,t){if(e.length<1||e.length>2)throw new wy(void 0,`binary`,Fy);if(e.some(Ly))if(t)console.warn(Iy);else throw new wy(void 0,`binary`,Iy);let[n,r]=e;return{binary:n,prefix:r}}function zy(e,t=[`git`],n=!1){let r=Ry(np(t),n);e.on(`binary`,e=>{r=Ry(np(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}zf();function By(e){return!!(e.exitCode&&e.stdErr.length)}function Vy(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function Hy(e=!1,t=By,n=Vy){return(r,i)=>!e&&r||!t(i)?r:n(i)}function Uy(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 Rf(void 0,r.toString(`utf-8`))}:{error:r}}}}$();var Wy=class{constructor(){this.plugins=new Set,this.events=new Ha}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=$f(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return np(e).forEach(e=>e&&this.plugins.add($f(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}};$();function Gy(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?ep(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:Ky(n[1]),progress:ap(n[2]),processed:ap(n[3]),total:ap(n[4])})})}}]}function Ky(e){return String(e.toLowerCase().split(` `,1))||`unknown`}$();function qy(e){let t=cp(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function Jy({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 wy(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()}}}Lf();function Yy(){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(Pf(i)){r(Ff(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>Pf(e)&&Ff(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}$();var Xy=Sy();function Zy(e,t){let n=new Wy,r=Mp(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!Qf(r.baseDir))throw new Cy(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(My(r.config)),n.add(jy(r.unsafe)),n.add(Py(r.completion)),r.abort&&n.add(Ty(r.abort)),r.progress&&n.add(Gy(r.progress)),r.timeout&&n.add(Jy(r.timeout)),r.spawnOptions&&n.add(qy(r.spawnOptions)),n.add(Yy()),n.add(Uy(Hy(!0))),r.errors&&n.add(Uy(r.errors)),zy(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new Xy(r,n)}Vf();var Qy=Zy,$y=class extends Zr()(`@supervisor/Updates`,{make:H(function*(){let e=yield*Mr();return{publish:qt(`Updates.publish`)(function*(t){yield*Gn(e,new lc({content:t,receivedAt:D()}))}),stream:qt(`Updates.stream`)(function*(){return Ki(e)})}})}){static layer=sr(this)(this.make)};const eb=`.expect`,tb=qt(`ensureStateDir`)(function*(e){let t=yield*qe,n=_a.join(e,eb);yield*t.makeDirectory(n,{recursive:!0}).pipe(_(`PlatformError`,()=>R));let r=_a.join(n,`.gitignore`);return(yield*t.exists(r).pipe(_(`PlatformError`,()=>V(!1))))||(yield*t.writeFileString(r,`*
23
+ `).pipe(_(`PlatformError`,()=>R))),n});var nb=class extends xt(`GitError`)({_tag:De(`GitError`),operation:B,cause:zi}){message=`Git error during "${this.operation}"`},rb=class extends xt(`FindRepoRootError`)({_tag:De(`FindRepoRootError`),cause:zi}){message=`Could not find git repository root`},ib=class extends Zr()(`@supervisor/GitRepoRoot`){},ab=class e extends Zr()(`@supervisor/Git`,{make:H(function*(){let e=yield*qe,t=e=>H(function*(){let t=yield*ib;return yield*Mt({try:()=>Qy(t).raw(e.args),catch:t=>new nb({operation:e.operation,cause:t})}).pipe(U(e.trim?Rn:Bt))}),n=e=>Mt({try:()=>Qy(e).revparse([`--show-toplevel`]),catch:e=>new rb({cause:e})}).pipe(U(Rn)),r=e=>t=>H(function*(){let r=yield*n(e);return yield*t.pipe(Di(ib,r))}),i=t({args:[`symbolic-ref`,`refs/remotes/origin/HEAD`],operation:`getting main branch`,trim:!0}).pipe(U(e=>e.replace(`refs/remotes/origin/`,``)),_(`GitError`,()=>t({args:[`revparse`,`--verify`,`origin/main`],operation:`getting main branch (origin/main)`,trim:!0}).pipe(be(`main`))),_(`GitError`,()=>t({args:[`rev-parse`,`--verify`,`main`],operation:`getting main branch (main)`,trim:!0}).pipe(be(`main`))),_(`GitError`,()=>V(`main`))),a=t({args:[`rev-parse`,`--abbrev-ref`,`HEAD`],operation:`getting current branch`,trim:!0}).pipe(_(`GitError`,()=>V(`HEAD`))),s=t({args:[`rev-parse`,`--is-inside-work-tree`],operation:`checking if inside work tree`,trim:!0}).pipe(U(e=>e===`true`),_(`GitError`,()=>V(!1))),c=e=>{let[t,n,r]=e.split(` `);return new Fs({relativePath:r??``,added:Number.parseInt(t??`0`,10)||0,removed:Number.parseInt(n??`0`,10)||0})},l=qt(`Git.getFileStats`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`,`--numstat`],operation:`getting working tree file stats`}).pipe(U(o(`
24
+ `)),U(yi(Rn)),U(Br(ct)),U(yi(c)),_(`GitError`,()=>V([]))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`,`--numstat`],operation:`getting file stats`}).pipe(U(o(`
25
+ `)),U(yi(Rn)),U(Br(ct)),U(yi(c)),_(`GitError`,()=>V([])))}),u=e=>e===`A`?`A`:e===`D`?`D`:e===`R`?`R`:e===`C`?`C`:e===`?`?`?`:`M`,d=qt(`Git.getChangedFiles`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`status`,`--porcelain`],operation:`getting working tree changes`}).pipe(U(o(`
26
+ `)),U(Br(ct)),U(yi(e=>{let t=e.at(0)??`M`;return{path:e.slice(3).trim(),status:u(t)}})),_(`GitError`,()=>V([]))):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(U(o(`
27
+ `)),U(yi(Rn)),U(Br(ct)),U(yi(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)}})),_(`GitError`,()=>V([])))}),f=qt(`Git.getDiffPreview`)(function*(e){return e._tag===`WorkingTree`?yield*t({args:[`diff`,`HEAD`],operation:`getting diff preview`,trim:!0}).pipe(_(`GitError`,()=>V(``))):yield*t({args:[`diff`,e._tag===`Branch`||e._tag===`Changes`?`${e.mainBranch}..HEAD`:`${e.hash}^..${e.hash}`],operation:`getting diff preview`,trim:!0}).pipe(_(`GitError`,()=>V(``)))}),p=qt(`Git.getRecentCommits`)(function*(e){return yield*t({args:[`log`,`--format=%H %h %s`,e],operation:`getting recent commits`,trim:!0}).pipe(U(o(`
28
+ `)),U(yi(Rn)),U(Br(ct)),U(yi(e=>{let[t,n,...r]=e.split(` `);return{hash:t??``,shortHash:n??``,subject:r.join(` `)}})),_(`GitError`,()=>V([])))}),m=qt(`Git.getCommitSummary`)(function*(e){return yield*t({args:[`log`,`-1`,`--format=%H %h %s`,e],operation:`getting commit summary`,trim:!0}).pipe(U(e=>{let[t,n,...r]=e.split(` `);if(!(!t||!n))return{hash:t,shortHash:n,subject:r.join(` `)}}),_(`GitError`,()=>V(void 0)))}),h=qt(`Git.computeFingerprint`)(function*(){let e=yield*t({args:[`rev-parse`,`HEAD`],operation:`getting HEAD for fingerprint`,trim:!0}).pipe(_(`GitError`,()=>V(``)));if(!e)return;let n=yield*t({args:[`diff`],operation:`getting unstaged diff for fingerprint`}).pipe(_(`GitError`,()=>V(``))),r=yield*t({args:[`diff`,`--cached`],operation:`getting staged diff for fingerprint`}).pipe(_(`GitError`,()=>V(``)));return ka.createHash(`sha256`).update(e).update(`\0`).update(n).update(`\0`).update(r).digest(`hex`)}),g=H(function*(){let e=yield*tb(yield*ib);return _a.join(e,`last-tested`)}),v=qt(`Git.loadSavedFingerprint`)(function*(){let t=yield*g;return yield*e.readFileString(t).pipe(U(Rn),_(`PlatformError`,()=>V(void 0)))}),y=qt(`Git.saveTestedFingerprint`)(function*(){let t=yield*h();if(!t)return;let n=yield*g;yield*e.writeFileString(n,t)});return{withRepoRoot:r,getMainBranch:i,getCurrentBranch:a,isInsideWorkTree:s,getFileStats:l,getChangedFiles:d,getDiffPreview:f,getRecentCommits:p,getCommitSummary:m,getState:qt(`Git.getState`)(function*(){if(!(yield*s))return new Is({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*mr([a,i,h(),v()],{concurrency:`unbounded`}),o=e===t,[c,u,d]=yield*mr([l(zs.makeUnsafe({_tag:`Changes`,mainBranch:t})),l(zs.makeUnsafe({_tag:`WorkingTree`})),p(`${t}..HEAD`)],{concurrency:`unbounded`});return new Is({isGitRepo:!0,currentBranch:e,mainBranch:t,isOnMain:o,hasChangesFromMain:c.length>0,hasUnstagedChanges:u.length>0,hasBranchCommits:d.length>0,branchCommitCount:d.length,fileStats:c,workingTreeFileStats:u,fingerprint:n,savedFingerprint:r})}),computeFingerprint:h,saveTestedFingerprint:y}})}){static layer=sr(this)(this.make).pipe(Dn(Ra.layer));static withRepoRoot=t=>{let n=sr(ib)(Mt({try:()=>Qy(t).revparse([`--show-toplevel`]),catch:e=>new rb({cause:e})}).pipe(U(e=>e.trim())));return ci(e.layer.pipe(Dn(n)),n)}},ob=class extends xt(`@supervisor/ExecutionError`)({_tag:De(`@supervisor/ExecutionError`),reason:ht([Zd,Qd])}){message=`Execution failed: ${this.reason.message}`},sb=class extends Zr()(`@supervisor/Executor`,{make:H(function*(){let e=yield*rf,t=yield*ab,n=qt(`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:qt(`Executor.execute`)(function*(t){let r=yield*n(t.changesFor),i=df({userInstruction:t.instruction,scope:t.changesFor._tag,currentBranch:r.currentBranch,mainBranch:r.mainBranch,changedFiles:r.changedFiles,recentCommits:r.recentCommits,diffPreview:r.diffPreview,baseUrl:t.baseUrl,isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,savedFlow:t.savedFlow,learnings:t.learnings}),a=Rs.makeUnsafe(crypto.randomUUID()),o=_a.join(process.cwd(),eb,`replays`,`${a}.ndjson`),s=new Js({id:a,changesFor:t.changesFor,currentBranch:r.currentBranch,diffPreview:r.diffPreview,fileStats:[],instruction:t.instruction,baseUrl:t.baseUrl?A(t.baseUrl):Ct(),isHeadless:t.isHeadless,requiresCookies:t.requiresCookies,title:t.instruction,rationale:`Direct execution`,steps:[]}),c=new _c({...s,events:[new Ys({plan:s})]}),l=[{name:`EXPECT_REPLAY_OUTPUT_PATH`,value:o}];t.liveViewUrl&&l.push({name:fi,value:t.liveViewUrl});let u=new Zu({cwd:process.cwd(),sessionId:Ct(),prompt:i,systemPrompt:Ct(),mcpEnv:l});return e.stream(u).pipe(Ot(()=>c,(e,t)=>{let n=e.addEvent(t);return[n,[n]]}),ce(e=>new ob({reason:e})))},Wr)}})}){static layer=sr(this)(this.make).pipe(Dn(Ra.layer))},cb=class extends Zr()(`@supervisor/Reporter`,{make:H(function*(){return{report:qt(`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 vc({...e,summary:i,screenshotPaths:a,pullRequest:Ct()})})}})}){static layer=sr(this)(this.make)};const lb=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
+ `)},ub=e=>`---\n${lb(e)}\n---\n`,db=e=>e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e,fb=e=>dt(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.instruction==`string`&&typeof e.expectedOutcome==`string`,pb=e=>dt(e)?{title:typeof e.title==`string`?e.title:``,userInstruction:typeof e.userInstruction==`string`?e.userInstruction:``,steps:Array.isArray(e.steps)?e.steps.filter(fb):[]}:{title:``,userInstruction:``,steps:[]},mb=e=>dt(e)?{baseUrl:typeof e.baseUrl==`string`?e.baseUrl:``,cookies:typeof e.cookies==`boolean`?e.cookies:!1}:{baseUrl:``,cookies:!1},hb=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:db(r.get(`title`)??``),description:db(r.get(`description`)??``),slug:db(r.get(`slug`)??``),savedTargetScope:db(r.get(`saved_target_scope`)??``),savedTargetDisplayName:db(r.get(`saved_target_display_name`)??``),flow:pb(JSON.parse(r.get(`flow`)??`{}`)),environment:mb(JSON.parse(r.get(`environment`)??`{}`))},a=r.get(`selected_commit`);return a!==void 0&&(i.selectedCommit=db(a)),i},gb=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,60).replace(/-$/,``),_b=e=>({formatVersion:3,title:e.title,description:e.instruction.slice(0,120),slug:gb(e.title),savedTargetScope:e.changesFor._tag,savedTargetDisplayName:Bs(e.changesFor),flow:{title:e.title,userInstruction:e.instruction,steps:e.steps.map(e=>{let t=wi(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:wi(e.baseUrl,()=>``),cookies:e.requiresCookies}});var vb=class extends Zr()(`@supervisor/FlowStorage`,{make:H(function*(){let e=yield*qe,t=H(function*(){let e=yield*tb(yield*ib);return _a.join(e,`flows`)});return{save:qt(`FlowStorage.save`)(function*(n){let r=_b(n),i=yield*t,a=_a.join(i,`${r.slug}.md`);return yield*e.makeDirectory(i,{recursive:!0}).pipe(_(`PlatformError`,()=>R)),yield*e.writeFileString(a,ub(r)),yield*kn(`Flow saved`,{slug:r.slug,stepCount:r.flow.steps.length,filePath:a}),r}),list:qt(`FlowStorage.list`)(function*(){let n=yield*t;if(!(yield*e.exists(n).pipe(_(`PlatformError`,()=>V(!1)))))return[];let r=(yield*e.readDirectory(n).pipe(_(`PlatformError`,()=>V([])))).filter(e=>e.endsWith(`.md`)),i=[];for(let t of r){let r=yield*e.readFileString(_a.join(n,t)).pipe(_(`PlatformError`,()=>V(``)));if(!r)continue;let a=yield*Ut({try:()=>hb(r),catch:()=>({_tag:`FlowParseError`})}).pipe(_(`FlowParseError`,()=>V(void 0)));a&&i.push(a)}return yield*Ur(`Flows listed`,{count:i.length}),i})}})}){static layer=sr(this)(this.make).pipe(Dn(Ra.layer))};const yb=(e,t)=>{try{return Oa(`git checkout ${t}`,{cwd:e,encoding:`utf-8`,timeout:5e3,stdio:`pipe`}),!0}catch{return!1}};var bb=class extends xt(`GitHubCommandError`)({_tag:De(`GitHubCommandError`),cause:B}){message=`GitHub CLI command failed: ${this.cause}`},xb=class extends Zr()(`@supervisor/GitHub`,{make:H(function*(){let e=yield*Hn,t=yield*qe,n=qt(`GitHub.runGhCommand`)(function*(t,n){return yield*e.string(vi(`gh`,n,{cwd:t})).pipe(Xi(15e3),Lt({PlatformError:e=>je(new bb({cause:e.message})),TimeoutError:()=>je(new bb({cause:`command timed out`}))}),U(e=>e.trim()))}),r=qt(`GitHub.findPullRequest`)(function*(e,t){let r=yield*n(e,[`pr`,`list`,`--head`,yn(t).pipe(Pi({_tag:`Branch`},e=>e.branchName),sn),`--state`,`open`,`--limit`,`1`,`--json`,`number,url,title,headRefName`]);return yield*zt(ue($n(uc)))(r).pipe(U(si),_(`SchemaError`,()=>V(Ct())))}),i=ue($n(Vs));return{findPullRequest:r,listPullRequests:qt(`GitHub.listPullRequests`)(function*(e){let t=yield*n(e,[`pr`,`list`,`--state`,`all`,`--json`,`number,headRefName,author,state,updatedAt`,`--limit`,`100`]).pipe(_(`GitHubCommandError`,()=>V(`[]`)));return(yield*zt(i)(t).pipe(_(`SchemaError`,Ht))).map(e=>new Us({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:qt(`GitHub.addComment`)(function*(e,r,i){yield*Ze(H(function*(){let a=ya(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=sr(this)(this.make).pipe(Dn(Ra.layer))};const Sb=e=>_a.join(Na.homedir(),eb,`${e}.json`),Cb=new Map,wb={getItem:async e=>{try{let t=await Wa.readFile(Sb(e),`utf-8`);return Cb.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Cb.get(e)===t)return;Cb.set(e,t);let n=Sb(e);await Wa.mkdir(_a.dirname(n),{recursive:!0}),await Wa.writeFile(n,t,`utf-8`)},removeItem:async e=>{Cb.delete(e);try{await Wa.unlink(Sb(e))}catch{}}},Tb=e=>_a.join(process.cwd(),eb,`${e}.json`),Eb=new Map,Db={getItem:async e=>{try{let t=await Wa.readFile(Tb(e),`utf-8`);return Eb.set(e,t),t}catch{return null}},setItem:async(e,t)=>{if(Eb.get(e)===t)return;Eb.set(e,t);let n=Tb(e);await Wa.mkdir(_a.dirname(n),{recursive:!0}),await Wa.writeFile(n,t,`utf-8`)},removeItem:async e=>{Eb.delete(e);try{await Wa.unlink(Tb(e))}catch{}}},Ob=e=>e.pipe(dn(xb.layer)),kb=async e=>{let t=[];if(e.hasUntestedChanges&&t.push(dc.makeUnsafe({_tag:`WorkingTree`})),e.mainBranch){let n=process.cwd(),r=await C(H(function*(){return yield*(yield*ab).getRecentCommits(`${e.mainBranch}..HEAD`)}).pipe(dn(ab.withRepoRoot(n))));for(let e of r)t.push(dc.makeUnsafe({_tag:`Commit`,hash:e.hash,shortHash:e.shortHash,subject:e.subject}))}return t},Ab=e=>C(Ob(xb.use(t=>t.listPullRequests(e)))),jb=async e=>{let t=await Ab(process.cwd()),n=t.filter(e=>e.prNumber!==null&&e.prStatus===`open`).map(e=>dc.makeUnsafe({_tag:`PullRequest`,branch:e})),r=t.filter(e=>e.prNumber!==null&&e.prStatus===`merged`).slice(0,5).map(e=>dc.makeUnsafe({_tag:`PullRequest`,branch:e})),i=t.filter(t=>t.name!==e.currentBranch&&t.prNumber===null).map(e=>dc.makeUnsafe({_tag:`Branch`,branch:e}));return[...n,...r,...i]},Mb=(e,t)=>e._tag===`WorkingTree`&&t&&!t.isOnMain?t.currentBranch:mc(e),Nb=(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 hc(e)},Pb=(e,t)=>e._tag===`WorkingTree`?Mb(e,t):gc(e),Fb=(e,t,n)=>{if(!t)return[...e];let r=t.toLowerCase();return e.filter(e=>(e._tag===`WorkingTree`?`local changes ${n?.currentBranch??``}`:pc(e)).toLowerCase().includes(r))},Ib=()=>sa({queryKey:[`remote-branches`],queryFn:()=>Ab(process.cwd())}),Lb=e=>{let t=ca(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=ds(),i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(Ga,{type:`dots`}),t[1]=i):i=t[1];let a;t[2]===r.SELECTION?a=t[3]:(a=q(G,{color:r.SELECTION,children:i}),t[2]=r.SELECTION,t[3]=a);let o;t[4]===n?o=t[5]:(o=n?J(G,{children:[` `,n]}):null,t[4]=n,t[5]=o);let s;return t[6]!==r.DIM||t[7]!==a||t[8]!==o?(s=J(G,{color:r.DIM,children:[a,o]}),t[6]=r.DIM,t[7]=a,t[8]=o,t[9]=s):s=t[9],s},Rb=(e,t)=>{let n=Math.max(0,t-qa(e));return e+` `.repeat(n)},zb=({itemCount:e,visibleCount:t,initialIndex:n})=>{let[r,i]=K(n??0),a=ma(e);return a.current!==e&&(a.current=e,i(t=>Math.min(t,Math.max(0,e-1)))),{highlightedIndex:r,setHighlightedIndex:i,scrollOffset:pa(()=>{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:ua((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])}},Bb=/(?:https?:\/\/|localhost[:/]|[\w-]+\.[\w-]+\.[\w]+|[\w-]+\.(com|org|net|io|dev|app|co|me|ai))\S*/i,Vb=e=>Bb.test(e),Hb=Ir(),Ub=e=>Vb(e.instruction)?Hb.Testing(e):Hb.PortPicker(e),Wb=Ja(e=>({screen:Hb.Main(),previousScreen:Hb.Main(),navigateTo:t=>e(e=>({screen:t,previousScreen:e.screen})),setScreen:t=>e({screen:t})})),Gb=new ia({defaultOptions:{queries:{staleTime:1/0,retry:!1}}}),Kb=e=>{let t=ca(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]=cs(),s,c,l;t[1]!==r||t[2]!==n?(l=n.toUpperCase(),s=r?` │ ${r}`:``,c=qa(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+qa(s),d=a?Math.max(0,o-u-3):0,f;t[6]===l?f=t[7]:(f=q(G,{bold:!0,color:ls.text,children:l}),t[6]=l,t[7]=f);let p;t[8]!==r||t[9]!==s?(p=r?q(G,{color:ls.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?J(G,{color:ls.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=J(G,{children:[f,p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=h):h=t[17],h},qb=()=>{let e=ca(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]=cs(),n=Wb(Jb),r=ds(),[i,a]=K(null),[o,s]=K(``),[c,l]=K(`recent`),[u,d]=K(!1),[f,p]=K(void 0),{data:m,isLoading:h}=Ib(),g=m===void 0?[]:m,_=Us.filterBranches(g,c,o),{highlightedIndex:v,setHighlightedIndex:y,scrollOffset:b,handleNavigation:x}=zb({itemCount:_.length,visibleCount:15}),ee=t-2-32-16-2,S=_.slice(b,b+15),C;e[1]===y?C=e[2]:(C=e=>{s(as(e)),y(0)},e[1]=y,e[2]=C);let w=C,te;e[3]===n?te=e[4]:(te=e=>{yb(process.cwd(),e)?(p(void 0),Gb.invalidateQueries({queryKey:[`git-state`]}),n(Hb.Main())):p(`Could not checkout "${e}". You may have uncommitted changes or the branch may not exist locally.`)},e[3]=n,e[4]=te);let T=te,E;e[5]!==c||e[6]!==y?(E=e=>{l(Hs[(Hs.indexOf(c)+e+Hs.length)%Hs.length]),y(0)},e[5]=c,e[6]=y,e[7]=E):E=e[7];let D=E;na((e,t)=>{if(u){t.escape&&d(!1);return}if(!x(e,t)){if(t.rightArrow&&D(1),t.leftArrow&&D(-1),t.return){let e=_[v];e&&(p(void 0),T(e.name))}e===`/`&&d(!0)}});let ne;e[8]!==i||e[9]!==T?(ne=(e,t)=>{i&&(e.toLowerCase()===`y`&&(p(void 0),T(i.name),a(null)),(e.toLowerCase()===`n`||t.escape)&&a(null))},e[8]=i,e[9]=T,e[10]=ne):ne=e[10];let O=i!==null,k;e[11]===O?k=e[12]:(k={isActive:O},e[11]=O,e[12]=k),na(ne,k);let A=W,re=`${_.length} branches`,j;e[13]===re?j=e[14]:(j=q(W,{paddingX:1,children:q(Kb,{title:`Select a PR or branch to test`,subtitle:re})}),e[13]=re,e[14]=j);let ie;e[15]!==r||e[16]!==c||e[17]!==y?(ie=Hs.map((e,t)=>{let n=e===c,i=t<Hs.length-1?` · `:``,a={recent:r.CYAN,all:r.TEXT,open:r.GREEN,draft:r.DIM,merged:r.PURPLE,"no-pr":r.YELLOW};return J(W,{children:[q(ms,{fullWidth:!1,onClick:()=>{l(e),y(0)},children:q(G,{color:n?a[e]:r.DIM,children:n?`[${e}]`:e})}),q(G,{color:r.DIM,children:i})]},e)}),e[15]=r,e[16]=c,e[17]=y,e[18]=ie):ie=e[18];let M;e[19]===ie?M=e[20]:(M=q(W,{marginTop:1,paddingX:1,children:ie}),e[19]=ie,e[20]=M);let ae=h?q(W,{marginTop:1,paddingX:1,children:q(Lb,{message:`Fetching PRs...`})}):J(W,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:[S.map((e,t)=>{let n=t+b,i=n===v;return J(ms,{onClick:()=>{y(n),T(e.name)},children:[q(G,{color:i?r.PRIMARY:r.DIM,children:i?`${Y.pointer} `:` `}),q(G,{color:i?r.PRIMARY:r.DIM,bold:i,children:Rb(Ka(e.name,31),32)}),q(G,{color:r.CYAN,children:Rb(Ka(e.author||`—`,15),16)}),e.prNumber&&e.prStatus?q(G,{color:e.prStatus===`open`?r.GREEN:e.prStatus===`merged`?r.PURPLE:r.DIM,children:Ka(`#${e.prNumber} ${e.prStatus}`,ee)}):q(G,{color:r.DIM,children:`—`})]},e.name)}),_.length===0&&q(G,{color:r.DIM,children:`No matching branches`})]}),N;e[21]!==r||e[22]!==f?(N=f?q(W,{marginTop:1,paddingX:1,children:q(G,{color:r.RED,children:f})}):null,e[21]=r,e[22]=f,e[23]=N):N=e[23];let oe;e[24]!==r||e[25]!==i?(oe=i?J(fs,{color:r.YELLOW,marginTop:1,children:[J(G,{color:r.YELLOW,bold:!0,children:[`Switch to `,i.name,`?`]}),J(G,{color:r.DIM,children:[`Press `,q(G,{color:r.PRIMARY,children:`y`}),` to continue or`,` `,q(G,{color:r.PRIMARY,children:`n`}),` to cancel.`]})]}):null,e[24]=r,e[25]=i,e[26]=oe):oe=e[26];let P;e[27]!==w||e[28]!==u||e[29]!==o?(P=q(W,{paddingX:1,children:q(xs,{isSearching:u,query:o,onChange:w})}),e[27]=w,e[28]=u,e[29]=o,e[30]=P):P=e[30];let F;return e[31]!==A||e[32]!==j||e[33]!==M||e[34]!==ae||e[35]!==N||e[36]!==oe||e[37]!==P?(F=J(A,{flexDirection:`column`,width:`100%`,paddingY:1,children:[j,M,ae,N,oe,P]}),e[31]=A,e[32]=j,e[33]=M,e[34]=ae,e[35]=N,e[36]=oe,e[37]=P,e[38]=F):F=e[38],F};function Jb(e){return e.setScreen}const Yb=va.join(process.cwd(),`.expect`,`logs.md`),Xb=gt.pipe(ki(Yb)),Zb=ci(hn(H(function*(){let e=yield*qe;yield*e.makeDirectory(va.dirname(Yb),{recursive:!0}),yield*e.writeFileString(va.join(va.dirname(Yb),`.gitignore`),`*
31
+ `)})),b([Xb])).pipe(Dn(La.layer));var Qb=n(((t,n)=>{(function(r,i){typeof t==`object`&&typeof n==`object`?n.exports=i(e(`child_process`),e(`crypto`)):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],i):typeof t==`object`?t[`electron-machine-id`]=i(e(`child_process`),e(`crypto`)):r[`electron-machine-id`]=i(r.child_process,r.crypto)})(t,function(t,n){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),`a`,{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,S,C,w=function(e){if(!p&&e in D)return D[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},te=t+` Iterator`,T=y==g,E=!1,D=e.prototype,ne=D[f]||D[m]||y&&D[y],O=ne||w(y),k=y?T?w(`entries`):O:void 0,A=t==`Array`&&D.entries||ne;if(A&&(C=d(A.call(new e)),C!==Object.prototype&&(u(C,te,!0),r||s(C,f)||o(C,f,_))),T&&ne&&ne.name!==g&&(E=!0,O=function(){return ne.call(this)}),r&&!x||!p&&!E&&D[f]||o(D,f,O),c[t]=O,c[te]=_,y)if(ee={values:T?O:w(g),keys:b?O:w(h),entries:k},x)for(S in ee)S in D||a(D,S,ee[S]);else i(i.P+i.F*(p||E),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
32
+ `)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,`__esModule`,{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,S=function(){},C=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(S,S)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(S)instanceof t}catch{}}(),w=function(e,t){return e===t||e===x&&t===a},te=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},T=function(e){return w(x,e)?new E(e):new i(e)},E=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},D=function(e){try{e()}catch(e){return{error:e}}},ne=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&A(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=te(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&O(e)})}},O=function(e){g.call(s,function(){var t,n,r,i=e._v;if(k(e)&&(t=D(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||k(e)?2:1),e._a=void 0,t)throw t.error})},k=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!k(t.promise))return!1;return!0},A=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},re=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),ne(t,!0))},j=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=te(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(j,r,1),c(re,r,1))}catch(e){re.call(r,e)}}):(n._v=e,n._s=1,ne(n,!1))}catch(e){re.call({_w:n,_d:!1},e)}}};C||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(j,this,1),c(re,this,1))}catch(e){re.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=T(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&ne(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),E=function(){var e=new r;this.promise=e,this.resolve=c(j,e,1),this.reject=c(re,e,1)}),u(u.G+u.W+u.F*!C,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!C,v,{reject:function(e){var t=T(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!C),v,{resolve:function(e){if(e instanceof x&&w(e.constructor,this))return e;var t=T(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(C&&n(46)(function(e){x.all(e).catch(S)})),v,{all:function(e){var t=this,n=T(t),r=n.resolve,i=n.reject,a=D(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=T(t),r=n.reject,i=D(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(t,n){t.exports=e(`child_process`)},function(t,n){t.exports=e(`crypto`)}])})}))();function $b(e){return typeof e==`string`?`'${e}'`:new ex().serialize(e)}const ex=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}(),tx=globalThis.process?.getBuiltinModule?.(`crypto`)?.hash,nx=`sha256`,rx=`base64url`;function ix(e){if(tx)return tx(nx,e,rx);let t=Aa(nx).update(e);return globalThis.process?.versions?.webcontainer?t.digest().toString(rx):t.digest(rx)}function ax(e){return ix($b(e))}function ox(){let e=sx();return async t=>{for(let n of t)n.module=e(n.filename);return t}}function sx(e=process.argv[1]?Ya(process.argv[1]):process.cwd(),t=Za===`\\`){let n=t?cx(e):e;return e=>{if(!e)return;let r=t?cx(e):e,{dir:i,base:a,ext:o}=Xa.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 cx(e){return e.replace(/^[A-Z]:/,``).replace(/\\/g,`/`)}const lx=e=>{if(`flags`in e){let t=dx(e.flags),n=fx(e.flags);return{...e,featureFlags:t,featureFlagPayloads:n}}{let t=e.featureFlags??{},n=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([e,t])=>[e,mx(t)])),r=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,ux(e,t,n[e])]));return{...e,featureFlags:t,featureFlagPayloads:n,flags:r}}};function ux(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 dx=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,px(t)]).filter(([,e])=>e!==void 0)),fx=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?mx(n):void 0]}))},px=e=>e===void 0?void 0:e.variant??e.enabled,mx=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},hx=`0123456789abcdef`;var gx=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+=hx.charAt(this.bytes[t]>>>4),e+=hx.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+=hx.charAt(this.bytes[t]>>>4),e+=hx.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}},_x=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??vx()}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 gx.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,gx.ofInner(e)}};const vx=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let yx;const bx=()=>xx().toString(),xx=()=>(yx||=new _x).generate();var Sx=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 Cx=`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(`,`),wx=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return Cx.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})},Tx=Array.isArray,Ex=Object.prototype;Ex.hasOwnProperty;const Dx=Ex.toString,Ox=Tx||function(e){return Dx.call(e)===`[object Array]`},kx=e=>e===Object(e)&&!Ox(e),Ax=e=>e===void 0,jx=e=>Dx.call(e)==`[object String]`,Mx=e=>jx(e)&&e.trim().length===0,Nx=e=>Dx.call(e)==`[object Number]`&&e===e,Px=e=>e instanceof Error;function Fx(e){return typeof e!=`object`||!e}function Ix(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function Lx(e){return!Ax(Event)&&zx(e,Event)}function Rx(e){return Ix(e,`Object`)}function zx(e,t){try{return e instanceof t}catch{return!1}}function Bx(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Nx(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),Bx(i||n,t,n,r))}var Vx=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Bx(e.bucketSize,0,100,e._logger),this._refillRate=Bx(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Bx(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={}}},Hx=class{add(e){let t=bx();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 Ux(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const Wx=(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=>Wx(`${e} ${r}`,t,n)}},Gx=e=>e();function Kx(e,t=Gx){return Wx(e,t,Ux())}const qx=`Android`;qx+``;const Jx=`BlackBerry`,Yx=`Samsung`;Yx+``,Yx+``;const Xx=`Chrome`;Xx+``,Xx+``;const Zx=`Opera`;Zx+``;const Qx=`Edge`;``+Qx;const $x=`Firefox`;$x+``;const eS=`Nintendo`,tS=`PlayStation`,nS=`Xbox`;qx+``;const rS=`Windows`;rS+``;const iS=`Generic`;iS+``,iS+``;const aS=`(\\d+(\\.\\d+)?)`;RegExp(`Version/`+aS),new RegExp(nS,`i`),RegExp(tS+` \\w+`,`i`),RegExp(eS+` \\w+`,`i`),RegExp(Jx+`|PlayBook|BB10`,`i`),RegExp(`rv:`+aS),RegExp(Qx+`?\\/(\\d+(\\.\\d+)?)`),RegExp(`(`+Xx+`|CrMo)\\/(\\d+(\\.\\d+)?)`),RegExp(`CriOS\\/`+aS),RegExp(`(UCBrowser|UCWEB)\\/`+aS),RegExp(`(`+Zx+`|OPR)\\/(\\d+(\\.\\d+)?)`),RegExp($x+`\\/(\\d+(\\.\\d+)?)`),RegExp(`FxiOS\\/`+aS),RegExp(`Konqueror[:/]?`+aS,`i`),RegExp(Jx+` (\\d+(\\.\\d+)?)`),RegExp(`android\\s`+aS,`i`),RegExp(`(rv:|MSIE )`+aS),RegExp(`rv:`+aS),RegExp(nS+`; Xbox (.*?)[);]`,`i`),new RegExp(eS,`i`),new RegExp(tS,`i`),new RegExp(rS,`i`),RegExp(`(`+qx+` (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`);function oS(e,t){if(!e||typeof e!=`string`||sS(e))throw Error(t)}function sS(e){return e.trim().length===0}function cS(e){return e?.replace(/\/+$/,``)}async function lS(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 uS(){return new Date().toISOString()}function dS(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const fS=e=>e instanceof Error;function pS(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var mS=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 hS(){return`CompressionStream`in globalThis}async function gS(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 _S=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()}},vS=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function yS(e){if(e instanceof _S){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 bS(e){return typeof e==`object`&&(e instanceof _S||e instanceof vS)}function xS(e){return typeof e==`object`&&e instanceof _S&&e.status===413}var SS=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new Hx,this._events=new mS,this._isInitialized=!1,oS(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=cS(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:bS},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=Kx(`[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=!hS()||(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(Sx.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(Sx.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(Sx.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:lx(e)})).catch(e=>(this._events.emit(`error`,e),{success:!1,error:this.categorizeRequestError(e)}))}categorizeRequestError(e){if(e instanceof _S)return{type:`api_error`,statusCode:e.status};if(e instanceof vS){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=px(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(Sx.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(Sx.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(Sx.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(Sx.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(Sx.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=dS(()=>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:uS()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=`${this.host}/batch/`,s=this.disableCompression?null:await gS(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:uS(),uuid:n?.uuid?n.uuid:bx()};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 yS(e)})}async flush(){let e=pS([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),pS([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(Sx.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(Sx.Queue)||[]).slice(n.length);this.setPersistedProperty(Sx.Queue,t),e=t,await this.flushStorage()},a={api_key:this.apiKey,batch:r,sent_at:uS()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await gS(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>xS(e)?!1:bS(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(xS(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 vS||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 lS(async()=>{let n=new AbortController,i=dS(()=>n.abort(),r??this.requestTimeout),o=null;try{o=await this.fetch(e,{signal:n.signal,...t})}catch(e){throw new vS(e)}finally{clearTimeout(i)}if(t.mode!==`no-cors`&&(o.status<200||o.status>=400))throw new _S(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(Sx.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!bS(e))throw e;await yS(e)}},r;try{return await Promise.race([new Promise((n,i)=>{r=dS(()=>{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 CS,wS,TS;function ES(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return TS&&n.length===wS?TS:(wS=n.length,TS=n.reduce((n,r)=>{CS||={};let i=CS[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,CS[r]=[a,o];break}}}return n},{}),TS)}var DS=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&&Ox(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:ES(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 OS=/^\s*[-]{4,}$/,kS=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,AS=(e,t)=>{let n=e.match(kS);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:MS(n[3]),colno:MS(n[4]),in_app:jS(s||``,c),platform:t}}if(e.match(OS))return{filename:e,platform:t}};function jS(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 MS(e){return parseInt(e||``,10)||void 0}const NS=/\(error: (.*)\)/;function PS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||FS(t).filename,function:e.function||`?`}))}function FS(e){return e[e.length-1]||{}}function IS(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
33
+ `);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=NS.test(r)?r.replace(NS,`$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 PS(i)}}var LS=class{match(e){return Px(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 RS=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var zS=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(RS);return r&&(t=r[1],n=r[2]),[t,n]}};const BS=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function VS(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 HS=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 Lx(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=VS(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return jx(e)&&!Mx(e)&&BS.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(fS(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},US=class{match(e){return Lx(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${VS(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},WS=class{match(e){return Fx(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},GS=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 KS=new GS(25),qS=new GS(20);async function JS(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`||$S(i)||eC(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(qS.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=nC(n);if(i.every(t=>tC(e,t)))continue;let a=oC(KS,e,{});r.push(YS(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&XS(e,KS),KS.reduce(),e}function YS(e,t,n){return new Promise(r=>{let i=Ma(e),a=Ia({input:i});function o(){i.destroy(),r()}let s=0,c=0,l=t[c];if(l===void 0)return void o();let u=l[0],d=l[1];function f(){qS.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]=sC(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 XS(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;ZS(n.lineno,n,e)}}function ZS(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=iC(e);r<e;r++){let e=n[r];if(e===void 0)return void QS(t);t.pre_context.push(e)}if(n[e]===void 0)return void QS(t);t.context_line=n[e];let r=aC(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 QS(e){delete e.pre_context,delete e.context_line,delete e.post_context}function $S(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function eC(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function tC(e,t){let n=KS.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 nC(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=rC(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=rC(n)),t++}return i}function rC(e){return[iC(e),aC(e)]}function iC(e){return Math.max(1,e-7)}function aC(e){return e+7}function oC(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function sC(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 cC(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 lC(e,t){globalThis.process?.on(`uncaughtException`,cC(e,t))}function uC(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var dC=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Vx({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(e){return kx(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||bx(),properties:{...a,...i},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(lC(this.onException.bind(this),this.onFatalError.bind(this)),uC(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 fC={ERRORS_WHILE_COMPUTING:`errors_while_computing_flags`,FLAG_MISSING:`flag_missing`,QUOTA_LIMITED:`quota_limited`,UNKNOWN_ERROR:`unknown_error`};async function pC(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 mC=[`is_not`];var hC=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},gC=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},_C=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},vC=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 _C||t instanceof gC?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 _C||t instanceof gC?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 gC(`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 gC(`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 gC(`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 gC(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new gC(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new gC(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new gC(`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 gC(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1;else throw new gC(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new gC(`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 _C)throw e;if(e instanceof gC)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new gC(`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`?SC(e,r,this.cohorts,this.debugMode):t===`flag`?await this.evaluateFlagDependency(e,r,i):bC(e,r,o),!n)return!1}if(a==null)return!0}return!(a!=null&&await yC(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await yC(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 hC(`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 hC(`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 hC(`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 hC&&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=dS(()=>{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 yC(e,t,n=``){let r=await pC(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function bC(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 gC(`Operator is_not_set is not supported`)}else throw new gC(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!mC.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 wC(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return wC(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 gC(`Date operations cannot be performed on boolean values`);let e=jC(String(i));if(e??=AC(i),e==null)throw new gC(`Invalid date: ${i}`);let t=AC(o);return[`is_date_before`].includes(a)?t<e:t>e}case`semver_eq`:return EC(TC(String(o)),TC(String(i)))===0;case`semver_neq`:return EC(TC(String(o)),TC(String(i)))!==0;case`semver_gt`:return EC(TC(String(o)),TC(String(i)))>0;case`semver_gte`:return EC(TC(String(o)),TC(String(i)))>=0;case`semver_lt`:return EC(TC(String(o)),TC(String(i)))<0;case`semver_lte`:return EC(TC(String(o)),TC(String(i)))<=0;case`semver_tilde`:{let e=TC(String(o)),{lower:t,upper:n}=DC(String(i));return EC(e,t)>=0&&EC(e,n)<0}case`semver_caret`:{let e=TC(String(o)),{lower:t,upper:n}=OC(String(i));return EC(e,t)>=0&&EC(e,n)<0}case`semver_wildcard`:{let e=TC(String(o)),{lower:t,upper:n}=kC(String(i));return EC(e,t)>=0&&EC(e,n)<0}default:throw new gC(`Unknown operator: ${a}`)}}function xC(e,t){if(!(e in t))throw new _C(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function SC(e,t,n,r=!1){let i=String(e.value);xC(i,n);let a=n[i];return CC(a,t,n,r)}function CC(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=CC(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof _C)throw t;if(t instanceof gC)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new gC(`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=SC(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=bC(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 _C)throw t;if(t instanceof gC)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new gC(`can't match cohort without a given cohort property value`);return i===`AND`}function wC(e){try{return new RegExp(e),!0}catch{return!1}}function TC(e){let t=String(e).trim().replace(/^[vV]/,``).split(`-`)[0].split(`+`)[0];if(!t||t.startsWith(`.`))throw new gC(`Invalid semver: ${e}`);let n=t.split(`.`),r=t=>{if(t===void 0||t===``)return 0;if(!/^\d+$/.test(t))throw new gC(`Invalid semver: ${e}`);return parseInt(t,10)};return[r(n[0]),r(n[1]),r(n[2])]}function EC(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 DC(e){let t=TC(e);return{lower:[t[0],t[1],t[2]],upper:[t[0],t[1]+1,0]}}function OC(e){let[t,n,r]=TC(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 kC(e){let t=String(e).trim().replace(/^[vV]/,``).replace(/\.\*$/,``).replace(/\*$/,``);if(!t)throw new gC(`Invalid wildcard semver: ${e}`);let n=t.split(`.`),r=parseInt(n[0],10);if(isNaN(r))throw new gC(`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 gC(`Invalid wildcard semver: ${e}`);i=[r,t,0],a=[r,t+1,0]}return{lower:i,upper:a}}function AC(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 gC(`${e} is in an invalid date format`)}throw new gC(`The date provided ${e} must be a string, number, or date object`)}function jC(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 MC=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const NC=3e4;var PC=class extends SS{constructor(e,t={}){if(super(e,t),this._memoryStorage=new MC,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):NC,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 vC({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 dC(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=dS(()=>{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=NC){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 _C||t instanceof gC)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=fC.UNKNOWN_ERROR;else{m=t.requestId,h=t.evaluatedAt;let n=[];t.errorsWhileComputingFlags&&n.push(fC.ERRORS_WHILE_COMPUTING),t.quotaLimited?.includes(`feature_flags`)&&n.push(fC.QUOTA_LIMITED);let r=t.flags[e];if(r===void 0)n.push(fC.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=dS(()=>{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(Rx(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(!dC.isPreviouslyCapturedError(e)){let i=Error(`PostHog syntheticException`);this.addPendingPromise(dC.buildEventMessage(e,{syntheticException:i},t,n).then(e=>this.capture({...e,uuid:r})))}}async captureExceptionImmediate(e,t,n){if(!dC.isPreviouslyCapturedError(e)){let r=Error(`PostHog syntheticException`);return this.addPendingPromise(dC.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=bx(),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`&&wx(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}},FC=class{constructor(){this.storage=new Qa}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 IC=`posthog-node`;function LC(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[RC.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 RC=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=IC,this.name=IC,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(LC(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};dC.errorPropertiesBuilder=new DS([new US,new LS,new HS,new zS,new WS],IS(`node:javascript`,AS),[ox(),JS]);const zC=new class extends PC{getLibraryId(){return`posthog-node`}initializeContext(){return new FC}}(`phc_t5FKk9mlc4pKbbBimiIlrM5Acq9meRp1FSuNjmwxjAX`,{host:`https://us.i.posthog.com`}),BC=Ke({email:B}),VC=qt(`getClaudeCodeEmail`)(function*(){let e=yield*(yield*Hn).string(vi(`claude`,[`auth`,`status`])).pipe(Xi(`5 seconds`));return(yield*zt(ue(BC))(e)).email}),HC=qt(`getGitEmail`)(function*(){let e=yield*(yield*Hn).string(vi(`git`,[`config`,`user.email`])).pipe(Xi(`5 seconds`),U(e=>e.trim()));return e.length===0?yield*je(`empty`):e}),UC=qt(`getGitName`)(function*(){let e=yield*(yield*Hn).string(vi(`git`,[`config`,`user.name`])).pipe(Xi(`5 seconds`),U(e=>e.trim()));return e.length===0?yield*je(`empty`):e});var WC=class extends Zr()(`@expect/AnalyticsProvider`){static layerPostHog=bi(this)({capture:e=>F(()=>{zC.captureImmediate({event:e.eventName,properties:e.properties,distinctId:e.distinctId})}),identify:e=>F(()=>{zC.identify({distinctId:e.distinctId,properties:{email:e.email,...e.name?{name:e.name}:{}}})}),flush:Mt({try:()=>zC.flush(),catch:e=>e}).pipe(ii)});static layerDev=bi(this)({capture:e=>kn(`Tracked event`,{eventName:e.eventName,distinctId:e.distinctId,...e.properties}).pipe(nt({module:`Analytics`})),identify:e=>kn(`Identified user`,{distinctId:e.distinctId,email:e.email,name:e.name}).pipe(nt({module:`Analytics`})),flush:R})},GC=class extends Zr()(`@expect/Analytics`,{make:H(function*(){let e=yield*WC,t=yield*Mt({try:()=>(0,Qb.machineId)(),catch:()=>`unknown`}),n=ax(process.cwd());yield*mr({email:VC().pipe(_(`PlatformError`,()=>HC()),_(`TimeoutError`,()=>HC()),_(`SchemaError`,()=>HC())),name:UC().pipe(Yi(()=>V(void 0)))}).pipe(xe(({email:n,name:r})=>e.identify({distinctId:t,email:n,name:r})),Yi(()=>R),Bn);let r=(r,...[i])=>H(function*(){let a={timestamp:new Date().toISOString(),projectId:n};yield*e.capture({eventName:r,properties:{...a,...i??{}},distinctId:t})}).pipe(Yi(e=>Dr(`Analytics capture failed`,{eventName:r,cause:e}).pipe(nt({module:`Analytics`}))));return{capture:r,track:((e,t)=>n=>xe(n,n=>{let i=t?t(n):void 0;return r.call(void 0,e,...i===void 0?[]:[i])})),flush:e.flush}})}){static layerPostHog=sr(this)(this.make).pipe(Dn(WC.layerPostHog),Dn(Ra.layer));static layerDev=sr(this)(this.make).pipe(Dn(WC.layerDev),Dn(Ra.layer))};const KC=e=>{let t=It(e);return{error_tag:et(t,`_tag`)?String(t._tag):`Unknown`,error_message:g(e)}};(class extends Zr()(`@expect/ErrorHandler`,{make:H(function*(){let e=yield*GC;return{orDie:t=>t.pipe(Fe(t=>e.capture(`error:unexpected`,KC(t))),ir),streamOrDie:t=>t.pipe(Rr(t=>e.capture(`error:unexpected`,KC(t))),Ce),tapCause:(...t)=>n=>n.pipe(Fe(n=>mr([e.capture(`error:expected`,KC(n)),ui(...t,n)],{discard:!0})))}})}){static layer=sr(this)(this.make)});const qC=Ja()(eo(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:$a(()=>wb),partialize:e=>({instructionHistory:e.instructionHistory,notifications:e.notifications})})),JC=GC.layerPostHog,YC=(e,...[t])=>C(H(function*(){let n=yield*GC;yield*n.capture.call(n,e,...t===void 0?[]:[t])}).pipe(Yi(()=>R),dn(JC))),XC=()=>YC(`session:started`,{mode:`interactive`,skip_planning:!1,browser_headed:qC.getState().browserHeaded}),ZC=e=>C(H(function*(){let t=yield*GC;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush}).pipe(dn(JC))),QC=()=>{let e=ca(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=ds(),n,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=q(G,{color:`red`,children:Y.cross}),r=q(G,{color:`green`,children:Y.tick}),e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]===t.PRIMARY?i=e[4]:(i=q(G,{bold:!0,color:t.PRIMARY,children:` Expect`}),e[3]=t.PRIMARY,e[4]=i);let a;e[5]===t.DIM?a=e[6]:(a=q(G,{color:t.DIM,children:` v${Jo}`}),e[5]=t.DIM,e[6]=a);let o;return e[7]!==t.BORDER||e[8]!==i||e[9]!==a?(o=q(W,{children:J(G,{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},$C=[{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.`}],ew=e=>{let t=ca(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=ds(),o=Wb(tw),[s,c]=K(0),l;t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==o?(l=e=>{let t=e.id===`enable-sync`;YC(`cookies:sync_choice`,{choice:t?`use_cookies`:`skip_cookies`}),o(Ub({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(nw),(t.upArrow||e===`k`||t.ctrl&&e===`p`)&&c(rw),e===`c`&&u($C[0]),e===`a`&&u($C[1]),t.return&&u($C[s])},t[6]=u,t[7]=s,t[8]=d):d=t[8],na(d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=q(QC,{}),t[9]=f):f=t[9];let p;t[10]===a.DIM?p=t[11]:(p=q(G,{color:a.DIM,children:Y.pointerSmall}),t[10]=a.DIM,t[11]=p);let m;t[12]!==a.TEXT||t[13]!==r?(m=q(G,{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=J(W,{children:[f,J(G,{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=q(W,{marginTop:1,children:s===0?J(G,{color:a.GREEN,children:[Y.tick,` Your signed-in session will be synced to the browser. Cookies stay on device.`]}):J(G,{color:a.YELLOW,children:[Y.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?(_=$C.map((e,t)=>{let n=t===s;return q(ms,{onClick:()=>{c(t),u(e)},children:J(W,{flexDirection:`column`,marginBottom:1,children:[J(G,{children:[q(G,{color:n?a.PRIMARY:a.DIM,children:n?`${Y.pointer} `:` `}),q(G,{color:n?a.PRIMARY:a.TEXT,bold:n,children:e.label})]}),J(G,{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=q(W,{flexDirection:`column`,marginTop:1,children:_}),t[28]=_,t[29]=v);let y;return t[30]!==h||t[31]!==g||t[32]!==v?(y=J(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 tw(e){return e.setScreen}function nw(e){return Math.min($C.length-1,e+1)}function rw(e){return Math.max(0,e-1)}const iw=Ja()(eo(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:$a(()=>Db)})),aw=`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(`,`),ow=[[/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`]],sw=e=>{let t=e.toLowerCase();return aw.some(e=>t.startsWith(e))},cw=e=>{if(!/^\d+$/.test(e))return``;try{let t=Ba(`lsof -p ${e} -a -d cwd -Fn`,{encoding:`utf-8`,timeout:1e3}).split(`
34
+ `).find(e=>e.startsWith(`n`));return t?t.slice(1):``}catch{return``}},lw=(e,t)=>{if(!/^\d+$/.test(e)||sw(t))return;let n=cw(e);try{let t=Ba(`ps -p ${e} -o command=`,{encoding:`utf-8`,timeout:1e3}).trim();for(let[e,r]of ow)if(e.test(t))return{name:r,isFramework:!0,cwd:n}}catch{}return{name:t,isFramework:!1,cwd:n}},uw=e=>{let t=new Set,n=[];for(let r of e.split(`
35
+ `)){let e=r.trim().split(/\s+/);if(e.length<9)continue;let i=e[0]??``,a=e[1]??``,o=(e[8]??``).match(/:(\d+)$/);if(!o)continue;let s=Number(o[1]);s<1024||s>65535||t.has(s)||(t.add(s),n.push({port:s,pid:a,commandName:i}))}return n},dw=()=>{try{let e=uw(Ba(`lsof -iTCP -sTCP:LISTEN -nP`,{encoding:`utf-8`,timeout:3e3})),t=[];for(let n of e){let e=lw(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[]}},fw=()=>sa({queryKey:[`listening-ports`],queryFn:()=>dw(),refetchInterval:5e3}),pw=e=>`http://localhost:${e}`,mw=(e,t)=>{let n=t.toLowerCase();return String(e.port).includes(n)||e.processName.toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n)},hw=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}},gw=e=>{let t=ca(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=ds(),s=Wb(_w),c=iw(vw),l=iw(yw),{data:u}=fw(),d=u===void 0?[]:u,[f,p]=K(!1),[m,h]=K(``),[g,_]=K(!1),[v,y]=K(``),b;t[1]===c?b=t[2]:(b=()=>{if(!c)return new Set;let e=c.match(/:(\d+)/);return e?new Set([Number(e[1])]):new Set},t[1]=c,t[2]=b);let[x,ee]=K(b),S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=new Set,t[3]=S):S=t[3];let[C,w]=K(S),te=d.map(bw),T=m?te.filter(e=>mw(e,m)):te,E=T.length,D=T.length+1,ne=T.length+2,O;t[4]===ne?O=t[5]:(O={itemCount:ne,visibleCount:10},t[4]=ne,t[5]=O);let{highlightedIndex:k,setHighlightedIndex:A,scrollOffset:re,handleNavigation:j}=zb(O),ie;t[6]!==n||t[7]!==C||t[8]!==r||t[9]!==a||t[10]!==i||t[11]!==l||t[12]!==s?(ie=e=>{let t=[...e,...C];l(t.length>0?t[0]:void 0),t.length===0?YC(`port:skipped`):YC(`port:selected`,{port_count:t.length,has_custom_url:C.size>0}),s(Hb.Testing({changesFor:n,instruction:r,savedFlow:i,requiresCookies:a,baseUrls:t.length>0?t:void 0}))},t[6]=n,t[7]=C,t[8]=r,t[9]=a,t[10]=i,t[11]=l,t[12]=s,t[13]=ie):ie=t[13];let M=ie,ae;t[14]===ee?ae=t[15]:(ae=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[14]=ee,t[15]=ae);let N=ae,oe;t[16]!==E||t[17]!==C||t[18]!==T||t[19]!==k||t[20]!==M||t[21]!==x||t[22]!==_||t[23]!==D?(oe=()=>{if(k===D){M([]);return}if(x.size>0||C.size>0){M([...x].sort(xw).map(pw));return}if(k===E){_(!0);return}let e=T[k];e&&M([pw(e.port)])},t[16]=E,t[17]=C,t[18]=T,t[19]=k,t[20]=M,t[21]=x,t[22]=_,t[23]=D,t[24]=oe):oe=t[24];let P=oe,F=Sw,se;t[25]!==y||t[26]!==w||t[27]!==_?(se=e=>{let t=e.trim();if(!t){_(!1);return}let n=F(t);w(e=>new Set([...e,n])),y(``),_(!1)},t[25]=y,t[26]=w,t[27]=_,t[28]=se):se=t[28];let ce=se,le;t[29]===w?le=t[30]:(le=e=>{w(t=>{let n=new Set(t);return n.delete(e),n})},t[29]=w,t[30]=le);let I=le,L;t[31]!==A||t[32]!==h?(L=e=>{h(e),A(0)},t[31]=A,t[32]=h,t[33]=L):L=t[33];let ue=L,de;t[34]!==p||t[35]!==h||t[36]!==N?(de=e=>{let t=hw(e);if(t){N(t),p(!1),h(``);return}p(!1)},t[34]=p,t[35]=h,t[36]=N,t[37]=de):de=t[37];let fe=de,pe;t[38]!==P||t[39]!==E||t[40]!==T||t[41]!==j||t[42]!==k||t[43]!==g||t[44]!==f||t[45]!==y||t[46]!==_||t[47]!==p||t[48]!==N?(pe=(e,t)=>{if(g){if(t.escape){_(!1),y(``);return}return}if(f){if(t.escape){p(!1);return}return}if(!j(e,t)){if(e===`/`){p(!0);return}if(e===` `){if(k===E){_(!0);return}let e=T[k];e&&N(e.port);return}t.return&&P()}},t[38]=P,t[39]=E,t[40]=T,t[41]=j,t[42]=k,t[43]=g,t[44]=f,t[45]=y,t[46]=_,t[47]=p,t[48]=N,t[49]=pe):pe=t[49],na(pe);let me,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke;if(t[50]!==o.DIM||t[51]!==o.GREEN||t[52]!==o.PRIMARY||t[53]!==o.TEXT||t[54]!==o.YELLOW||t[55]!==E||t[56]!==C||t[57]!==T||t[58]!==k||t[59]!==r||t[60]!==re||t[61]!==x||t[62]!==A||t[63]!==D||t[64]!==N){let e=T.slice(re,re+8);ge=re+8>=T.length,ye=ge;let n=T[k];_e=k===E,ve=k===D;let i;t[81]!==C||t[82]!==x?(i=[...[...x].sort(Cw).map(pw),...C],t[81]=C,t[82]=x,t[83]=i):i=t[83];let a=i;he=W,Ce=`column`,we=`100%`,Te=1,Ee=1;let s;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(s=q(QC,{}),t[84]=s):s=t[84];let c;t[85]===o.DIM?c=t[86]:(c=q(G,{color:o.DIM,children:Y.pointerSmall}),t[85]=o.DIM,t[86]=c);let l;t[87]!==o.TEXT||t[88]!==r?(l=q(G,{color:o.TEXT,children:r}),t[87]=o.TEXT,t[88]=r,t[89]=l):l=t[89],t[90]!==c||t[91]!==l?(De=J(W,{children:[s,J(G,{wrap:`truncate`,children:[` `,c,` `,l]})]}),t[90]=c,t[91]=l,t[92]=De):De=t[92],t[93]===o.DIM?Oe=t[94]:(Oe=q(W,{marginTop:1,children:q(G,{color:o.DIM,children:`Pick the dev server the agent should open in the browser.`})}),t[93]=o.DIM,t[94]=Oe);let u;t[95]!==o.GREEN||t[96]!==a?(u=a.length>0&&J(G,{color:o.GREEN,children:[Y.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]!==_e||t[102]!==ve?(d=a.length===0&&!ve&&!_e&&n&&J(G,{color:o.DIM,children:[Y.arrowRight,` `,pw(n.port)]}),t[98]=o.DIM,t[99]=a.length,t[100]=n,t[101]=_e,t[102]=ve,t[103]=d):d=t[103];let f;t[104]!==o.YELLOW||t[105]!==a.length||t[106]!==ve?(f=a.length===0&&ve&&J(G,{color:o.YELLOW,children:[Y.warning,` No base URL. The agent won`,`'`,`t know where your dev server is.`]}),t[104]=o.YELLOW,t[105]=a.length,t[106]=ve,t[107]=f):f=t[107],t[108]!==u||t[109]!==d||t[110]!==f?(ke=J(W,{marginTop:1,children:[u,d,f]}),t[108]=u,t[109]=d,t[110]=f,t[111]=ke):ke=t[111],me=W,be=`column`,xe=1;let p;t[112]!==o.DIM||t[113]!==o.PRIMARY||t[114]!==o.TEXT||t[115]!==k||t[116]!==re||t[117]!==x||t[118]!==A||t[119]!==N?(p=(e,t)=>{let n=t+re,r=n===k,i=x.has(e.port);return q(ms,{onClick:()=>{A(n),N(e.port)},children:J(W,{children:[q(G,{color:r?o.PRIMARY:o.DIM,children:r?`${Y.pointer} `:` `}),J(G,{color:i?o.PRIMARY:o.DIM,children:[i?Y.checkboxOn:Y.checkboxOff,` `]}),J(G,{color:r?o.PRIMARY:o.TEXT,bold:r,children:[`:`,e.port]}),e.processName&&J(G,{color:o.DIM,children:[` `,e.processName]}),e.cwd&&J(G,{color:o.DIM,children:[` `,e.cwd]})]})},e.port)},t[112]=o.DIM,t[113]=o.PRIMARY,t[114]=o.TEXT,t[115]=k,t[116]=re,t[117]=x,t[118]=A,t[119]=N,t[120]=p):p=t[120],Se=e.map(p),t[50]=o.DIM,t[51]=o.GREEN,t[52]=o.PRIMARY,t[53]=o.TEXT,t[54]=o.YELLOW,t[55]=E,t[56]=C,t[57]=T,t[58]=k,t[59]=r,t[60]=re,t[61]=x,t[62]=A,t[63]=D,t[64]=N,t[65]=me,t[66]=he,t[67]=ge,t[68]=_e,t[69]=ve,t[70]=ye,t[71]=be,t[72]=xe,t[73]=Se,t[74]=Ce,t[75]=we,t[76]=Te,t[77]=Ee,t[78]=De,t[79]=Oe,t[80]=ke}else me=t[65],he=t[66],ge=t[67],_e=t[68],ve=t[69],ye=t[70],be=t[71],xe=t[72],Se=t[73],Ce=t[74],we=t[75],Te=t[76],Ee=t[77],De=t[78],Oe=t[79],ke=t[80];let Ae;t[121]!==o.DIM||t[122]!==o.PRIMARY||t[123]!==o.TEXT||t[124]!==E||t[125]!==v||t[126]!==ge||t[127]!==ce||t[128]!==_e||t[129]!==g||t[130]!==y||t[131]!==A||t[132]!==_?(Ae=ge&&q(ms,{onClick:()=>{A(E),_(!0)},children:J(W,{children:[q(G,{color:_e?o.PRIMARY:o.DIM,children:_e?`${Y.pointer} `:` `}),g&&J(W,{children:[q(G,{color:o.PRIMARY,children:`URL: `}),q(bs,{focus:!0,value:v,placeholder:`http://localhost:4000 or staging.example.com`,onChange:y,onSubmit:ce})]}),!g&&J(G,{color:_e?o.PRIMARY:o.TEXT,bold:_e,children:[`Enter a custom URL`,Y.ellipsis]})]})}),t[121]=o.DIM,t[122]=o.PRIMARY,t[123]=o.TEXT,t[124]=E,t[125]=v,t[126]=ge,t[127]=ce,t[128]=_e,t[129]=g,t[130]=y,t[131]=A,t[132]=_,t[133]=Ae):Ae=t[133];let je;t[134]!==o.DIM||t[135]!==o.PRIMARY||t[136]!==o.TEXT||t[137]!==ge||t[138]!==C||t[139]!==I?(je=ge&&[...C].map(e=>q(ms,{onClick:()=>I(e),children:J(W,{children:[q(G,{children:` `}),J(G,{color:o.PRIMARY,children:[Y.checkboxOn,` `]}),q(G,{color:o.TEXT,children:e}),q(G,{color:o.DIM,children:` (click to remove)`})]})},e)),t[134]=o.DIM,t[135]=o.PRIMARY,t[136]=o.TEXT,t[137]=ge,t[138]=C,t[139]=I,t[140]=je):je=t[140];let R;t[141]!==o.DIM||t[142]!==o.PRIMARY||t[143]!==ve||t[144]!==M||t[145]!==A||t[146]!==D||t[147]!==ye?(R=ye&&q(ms,{onClick:()=>{A(D),M([])},children:J(W,{children:[q(G,{color:ve?o.PRIMARY:o.DIM,children:ve?`${Y.pointer} `:` `}),J(G,{color:ve?o.PRIMARY:o.DIM,bold:ve,children:[`Skip `,Y.arrowRight,` no base URL`]})]})}),t[141]=o.DIM,t[142]=o.PRIMARY,t[143]=ve,t[144]=M,t[145]=A,t[146]=D,t[147]=ye,t[148]=R):R=t[148];let z;t[149]!==o.DIM||t[150]!==T.length||t[151]!==ye?(z=T.length===0&&!ye&&q(G,{color:o.DIM,children:`No matching ports`}),t[149]=o.DIM,t[150]=T.length,t[151]=ye,t[152]=z):z=t[152];let Me;t[153]!==me||t[154]!==be||t[155]!==xe||t[156]!==Se||t[157]!==Ae||t[158]!==je||t[159]!==R||t[160]!==z?(Me=J(me,{flexDirection:be,marginTop:xe,children:[Se,Ae,je,R,z]}),t[153]=me,t[154]=be,t[155]=xe,t[156]=Se,t[157]=Ae,t[158]=je,t[159]=R,t[160]=z,t[161]=Me):Me=t[161];let Ne;t[162]!==ue||t[163]!==fe||t[164]!==f||t[165]!==m?(Ne=q(xs,{isSearching:f,query:m,onChange:ue,onSubmit:fe}),t[162]=ue,t[163]=fe,t[164]=f,t[165]=m,t[166]=Ne):Ne=t[166];let Pe;return t[167]!==he||t[168]!==Ce||t[169]!==we||t[170]!==Te||t[171]!==Ee||t[172]!==De||t[173]!==Oe||t[174]!==ke||t[175]!==Me||t[176]!==Ne?(Pe=J(he,{flexDirection:Ce,width:we,paddingY:Te,paddingX:Ee,children:[De,Oe,ke,Me,Ne]}),t[167]=he,t[168]=Ce,t[169]=we,t[170]=Te,t[171]=Ee,t[172]=De,t[173]=Oe,t[174]=ke,t[175]=Me,t[176]=Ne,t[177]=Pe):Pe=t[177],Pe};function _w(e){return e.setScreen}function vw(e){return e.lastBaseUrl}function yw(e){return e.setLastBaseUrl}function bw(e){return{port:e.port,processName:e.processName,cwd:e.cwd}}function xw(e,t){return e-t}function Sw(e){let t=e.trim(),n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?pw(n):/^https?:\/\//i.test(t)?t:`http://${t}`}function Cw(e,t){return e-t}const ww={"~effect/reactivity/AsyncResult":{E:Bt,A:Bt},pipe(){return ke(this,arguments)},[vr](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return Je(this.value,e.value);case`Failure`:return Je(this.cause,e.cause)}},[Ue](){let e=Re(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:l(e)(this._tag===`Success`?fr(this.value):fr(this.cause))}},Tw=e=>e.waiting,Ew=(e,t)=>e._tag===`Success`?jw(e.value):Pw(e.cause,{previous:t}),Dw=e=>e._tag===`None`?kw(!0):Iw(e.value),Ow=e=>e._tag===`Initial`,kw=(e=!1)=>{let t=Object.create(ww);return t._tag=`Initial`,t.waiting=e,t},Aw=e=>e._tag===`Success`,jw=(e,t)=>{let n=Object.create(ww);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},Mw=e=>e._tag===`Failure`,Nw=(e,t)=>{let n=Object.create(ww);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??Ct(),n.waiting=t?.waiting??!1,n},Pw=(e,t)=>Nw(e,{previousSuccess:tr(t.previous,e=>Aw(e)?A(e):Mw(e)?e.previousSuccess:Ct()),waiting:t.waiting}),Fw=(e,t)=>Pw(tt(e),t),Iw=(e,t)=>{if(e.waiting)return t?.touch?Lw(e):e;let n=Object.assign(Object.create(ww),e);return n.waiting=!0,t?.touch&&Aw(n)&&(n.timestamp=Date.now()),n},Lw=e=>Aw(e)?jw(e.value,{waiting:e.waiting}):e,Rw=(e,t)=>e._tag===`Failure`?Pw(e.cause,{previous:t,waiting:e.waiting}):e,zw=e=>e._tag===`Success`?A(e.value):e._tag===`Failure`?x(e.previousSuccess,e=>e.value):Ct(),Bw=e=>bn(zw(e),()=>new pr(`AsyncResult.getOrThrow: no value found`)),Vw=e=>new Hw(e);var Hw=class{constructor(e){this.result=e}result;output=Ct();when(e,t){if(Fi(this.output)&&e(this.result)){let e=t(this.result);_t(e)&&(this.output=e)}return this}pipe(){return ke(this,arguments)}onWaiting(e){return this.when(e=>e.waiting,t=>A(e(t)))}onInitialOrWaiting(e){return this.when(e=>Ow(e)||e.waiting,t=>A(e(t)))}onInitial(e){return this.when(Ow,t=>A(e(t)))}onSuccess(e){return this.when(Aw,t=>A(e(t.value,t)))}onFailure(e){return this.when(Mw,t=>A(e(t.cause,t)))}onError(e){return this.onErrorIf(h,e)}onErrorIf(e,t){return this.when(Mw,n=>Ne(n.cause).pipe(Ar(e),x(e=>t(e,n))))}onErrorTag(e,t){return this.onErrorIf(t=>et(t,`_tag`)&&(Array.isArray(e)?e.includes(t._tag):t._tag===e),t)}onDefect(e){return this.when(Mw,t=>{let n=ye(t.cause);return Kr(n)?Ct():A(e(n.success,t))})}orElse(e){return wi(this.output,e)}orNull(){return Vi(this.output)}render(){if(_t(this.output))return this.output.value;if(Mw(this.result))throw It(this.result.cause);return null}};const Uw=Zr(`~effect/reactivity/AtomRegistry`),Ww={alive:1,initialized:2,waitingForValue:4},Gw={uninitialized:Ww.alive|Ww.waitingForValue,stale:Ww.alive|Ww.initialized|Ww.waitingForValue,valid:Ww.alive|Ww.initialized,removed:0},Kw={disabled:0,collect:1,commit:2},qw={phase:Kw.disabled,depth:0,stale:[],notify:new Set};function Jw(e){qw.phase=Kw.collect,qw.depth++;try{if(e(),qw.depth===1){for(let e=0;e<qw.stale.length;e++)Yw(qw.stale[e]);qw.phase=Kw.commit;for(let e of qw.notify)e.notify();qw.notify.clear()}}finally{qw.depth--,qw.depth===0&&(qw.phase=Kw.disabled,qw.stale=[])}}function Yw(e){if(e.state!==Gw.valid){for(let t=0;t<e.parents.length;t++){let n=e.parents[t];n.state!==Gw.valid&&Yw(n)}e.state!==Gw.valid&&e.value()}}const Xw=`~effect/reactivity/Atom`,Zw=e=>et(e,Xw),Qw=`~effect/reactivity/Atom/Writable`,$w=fe(2,(e,t)=>{let n=pi(t),r=Fr(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?ti(n):void 0})})(0),eT={[Xw]:Xw,...T,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},tT={...eT,atom(e,t){let n=lT(e,t);return aT(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):Rw(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>nT(this,e,t):nT(this,e,t)},pull(e,t){let n=$w(fT(0));return TT(n,aT(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?mT(r,wT(r,n,e,t),kw(!0),a.value):Rw(a,i)}))},subscriptionRef(e){return bT($w(aT(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return Rw(r,n);let i=typeof e==`function`?e(t):e;return Bo(i)?i:mT(t,i,kw(!0),r.value)})),(e,t)=>yT(e,t,Bw(e(this))))}},nT=(e,t,n)=>{let[r,i,a]=CT(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return _n(i)?Mo(i,n.reactivityKeys):_e(i,No(n.reactivityKeys))}:t,n);return oT(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):Rw(i,n)},i)},rT={...eT,[Qw]:Qw},iT=e=>Qw in e,aT=(e,t)=>{let n=Object.create(eT);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},oT=(e,t,n)=>{let r=Object.create(rT);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function sT(e,t){e.setSelf(t)}const cT=(e,t)=>{let n=lT(e,t);return`~effect/reactivity/Atom`in n?n:aT(n)},lT=(e,t)=>{if(typeof e==`function`&&!_n(e)&&!Pt(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:uT in i?pT(e,i,t,r):dT in i?_T(e,i,t,r):i;default:return i}}}else if(_n(e))return function(n,r){return pT(n,e,t,r)};else if(Pt(e))return function(n,r){return _T(n,e,t,r)};return fT(e)},uT=`~effect/Effect`,dT=`~effect/Stream`,fT=e=>oT(function(t){return e},sT),pT=(e,t,n,r)=>mT(e,t,n?.initialValue===void 0?kw():jw(n.initialValue),r,n?.uninterruptible);function mT(e,t,n,r=Zt(),i=!1){let a=e.self(),o=nr();e.addFinalizer(()=>{bt(r)(jr(o,yr))});let s=new Map(r.mapUnsafe);s.set(Wn.key,o),s.set(Uw.key,e.registry),s.set(Ae.key,e.registry.scheduler);let c,l=!1,u=hT(nn(s),t,function(t){c=Ew(t,a),l&&e.setSelf(c)},i);return l=!0,u!==void 0&&e.addFinalizer(u),c===void 0?a._tag===`Some`?Dw(a):Iw(n):c}function hT(e,t,n,r=!1){if(wt(t)){n(t);return}let i=bt(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}const gT=(e=>{let t=Po;function n(r){let i=Object.create(tT);i.keepAlive=!1,i.lazy=!0,i.refresh=void 0,i.factory=n;let a=ET(aT(typeof r==`function`?e=>Tr(r(e),t):()=>Tr(r,t)));return i.layer=a,i.read=function(t){let n=t(a);return pT(t,Qt(ne,t=>ni(n,e.memoMap,t)),{uninterruptible:!0})},i}n.memoMap=e.memoMap,n.addGlobalLayer=e=>{t=Tr(t,Dn(e,Po))};let r=$w(cT(Ve(t=>ni(Po,e.memoMap,Kt(t,Wn))).pipe(U(Kt(ko)))));return n.withReactivity=e=>t=>DT(t,n=>{let i=Bw(n(r));return n.addFinalizer(i.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),n})({memoMap:Vr()});gT.withReactivity;const _T=(e,t,n,r)=>vT(e,t,n?.initialValue===void 0?kw():jw(n.initialValue),r);function vT(e,t,n,r=Zt()){let i=e.self();r=we(r,Uw,e.registry);let a=xr(n=>Qt(ri(t.channel,n),t=>$r({while:h,body:()=>t,step(t){e.setSelf(jw(wr(t),{waiting:!0}))}}))).pipe(Yi(t=>(an(t)?le(e.self(),tr(zw),Ai({onNone:()=>e.setSelf(Fw(new pr,{previous:e.self()})),onSome:t=>e.setSelf(jw(t))})):e.setSelf(Pw(t,{previous:e.self()})),R))),o=new Map(r.mapUnsafe);o.set(Uw.key,e.registry),o.set(Ae.key,e.registry.scheduler);let s=hT(nn(o),a,Ft,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?Dw(i):Iw(n)}const yT=(e,t,n=Zt())=>Bo(t)?(e.addFinalizer(Vo(t).pipe(at(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return R}),Cn(n))),ie(n)(Ho(t))):t._tag===`Success`?vT(e,Vo(t.value),kw(!0),n):t,bT=(e,t)=>{function n(t,n){let r=t.get(e);Bo(r)?Et(Wo(r,n)):Aw(r)&&Et(Wo(r.value,n))}return oT(n=>{let r=n(e);return Bo(r)||Aw(r)?t(n,r):r},n)},xT=Symbol.for(`effect/reactivity/atom/Atom/Reset`),ST=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`);function CT(e,t){let n=$w(fT([0,void 0])),r=t?.initialValue===void 0?kw():jw(t.initialValue),i=t?.concurrent?$w(aT(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===ST)return Pw(Ji(),{previous:t.self()});let l=e(c,t);return uT in l?(o&&(l=Qt(Bn(l,{startImmediately:!0}),e=>(o.add(e),e.addObserver(()=>o.delete(e)),U(Ui(o),e=>e[0])))),mT(t,l,r,a,!1)):vT(t,l,r,a)}function o(e,t){kT(()=>{t===xT?e.set(n,[0,void 0]):t===ST?e.set(n,[e.get(n)[0]+1,ST]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}const wT=(e,t,n,r)=>Qt(ai(typeof n==`function`?n(e):n),n=>{let i=un().services,a=mn(),o=Fn(n,{onFailure(e){return an(e)?En(a)?V({done:!0,items:a}):je(new pr(`Atom.pull: no items`)):Qr(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=or(a,e),a=t),V({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(Dw(e.self()));let t;t=hT(i,o,n=>{t&&s.delete(t);let r=Ew(n,e.self()),i=s.size>0;e.setSelf(i?Iw(r):r)}),t&&s.add(t)}),o}),TT=(e,t)=>oT(t.read,function(t,n){t.set(e,t.get(e)+1)}),ET=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),DT=fe(e=>Zw(e[0]),(e,t,n)=>{let r=$w(iT(e)?oT(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):aT(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=OT(n.initialValueTarget)),r}),OT=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},kT=Jw,AT=e=>{let t=e.replace(`#`,``);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]},jT=(e,t,n)=>`#${[e,t,n].map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`,MT=(e,t,n)=>e+(t-e)*n,NT=(e,t,n)=>{let[r,i,a]=AT(e),[o,s,c]=AT(t);return jT(MT(r,o,n),MT(i,s,n),MT(a,c,n))},PT=({text:e,baseColor:t,highlightColor:n,speed:r=1})=>{let[i,a]=K(-16),o=ma(r);o.current=r;let s=ma(e.length);s.current=e.length;let c=ma(!1);return c.current||(c.current=!0,setTimeout(()=>{setInterval(()=>{let e=s.current+16;a(t=>t>=e?-16:t+o.current)},50)},0)),q(G,{children:[...e].map((e,r)=>{let a=Math.abs(r-i),o=Math.max(0,1-a/16);return q(G,{color:o>0?NT(t,n,o):t,children:e},r)})})},FT=Ja(e=>({executedPlan:void 0,expanded:!1,setExecutedPlan:t=>e({executedPlan:t}),setExpanded:t=>e({expanded:t}),toggleExpanded:()=>e(e=>({expanded:!e.expanded}))})),IT=e=>ao(Math.max(0,e),{secondsDecimalDigits:0}),LT=new Set([`warpterminal`]),RT=so.stdout,zT=oo({preferOuter:!0}),BT=process.stdout.isTTY&&!LT.has(zT??``),VT=BT&&RT.kitty,HT=BT&&RT.iterm2,UT=VT||HT,WT=oo(),GT=WT===`tmux`||WT===`screen`,KT=e=>GT?`Ptmux;${e.replaceAll(`\x1B`,`\x1B\x1B`)}\\`:e,qT=(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}`),KT(`_G${r};${n}\\`)},JT=(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`)}`,KT(n)},YT=(e,t={})=>{if(!ja.existsSync(e))return null;if(VT)return qT(e,t);if(HT)try{return JT(ja.readFileSync(e),t)}catch{return null}return null},XT=e=>e.startsWith(`file://`),ZT=e=>{let t=ca(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=XT(n)?xa.fileURLToPath(n):_a.resolve(n),a=XT(n)?n:xa.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=q(G,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==o||t[7]!==c?(l=q(co,{url:o,children:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l},QT=({src:e,alt:t,width:n,height:r})=>{let i=_a.resolve(e),{write:a}=ra(),o=ma(!1);if(!o.current){let e=YT(i,{width:n,height:r});e&&(a(e+`
36
+ `),o.current=!0)}return UT?null:q(ZT,{path:i,label:t})},$T=({message:e})=>e?q(W,{marginTop:1,children:q(G,{color:ds().RED,children:e})}):null,eE=`~effect/encoding/Ndjson/NdjsonError`;var tE=class extends mi(`NdjsonError`){[eE]=eE;get message(){return this.kind}};const nE=()=>on((e,t)=>V(Qt(e,e=>{try{return V(Mn(e.map(e=>JSON.stringify(e)).join(`
58
37
  `)+`
59
- `))}catch(e){return G(new vW({kind:`Pack`,cause:e}))}}))),bW=e=>ob(yb().pipe(e?.ignoreEmptyLines===!0?ub(e=>e.length>0):F),e=>{try{return U(Hi(e,e=>JSON.parse(e)))}catch(e){return G(new vW({kind:`Unpack`,cause:e}))}}),xW=P(e=>Ry(e[0]),(e,t)=>bb(bb(yW(),e),bW(t))),SW=P(2,(e,t)=>mS(xW(e,t),t)),CW=Mx([X({_tag:Bx(`Started`),startTime:wx}),X({_tag:Bx(`Ended`),startTime:wx,endTime:wx})]),wW=X({_tag:Bx(`ExternalSpan`),spanId:Y,traceId:Y,sampled:Cx}),TW=X({_tag:Bx(`Span`),spanId:Y,traceId:Y,name:Y,sampled:Cx,attributes:Qx(Y,vx),status:CW,parent:Kx(Ix(()=>DW))}),EW=X({_tag:Bx(`SpanEvent`),traceId:Y,spanId:Y,name:Y,startTime:wx,attributes:Fx(Ex(Y,vx))}),DW=Mx([TW,wW]),OW=X({_tag:Bx(`Ping`)}),kW=X({_tag:Bx(`Pong`)}),AW=X({_tag:Bx(`MetricsRequest`)}),jW=(e,t)=>X({id:Y,type:Bx(e),description:Fx(Y),attributes:Fx(Ex(Y,Y)),state:t}),MW=Mx([OW,TW,EW,X({_tag:Bx(`MetricsSnapshot`),metrics:kx(Mx([jW(`Counter`,X({count:Mx([Sx,wx]),incremental:Cx})),jW(`Frequency`,X({occurrences:Qx(Y,Sx)})),jW(`Gauge`,X({value:Mx([Sx,wx])})),jW(`Histogram`,X({buckets:kx(Ox([Sx,Sx])),count:Sx,min:Sx,max:Sx,sum:Sx})),jW(`Summary`,X({quantiles:kx(Ox([Sx,Fx(Sx)])),count:Sx,min:Sx,max:Sx,sum:Sx}))]))})]),NW=Mx([kW,AW]),PW=dS(MW),FW=dS(NW);var IW=class extends Ga()(`effect/devtools/DevToolsClient`){};const LW=gp(function*(){let e=yield*QU,t=yield*Wp(),n=yield*uy(),r=yield*Td(),i=W(()=>{fy(n,RW(t))});return yield*$S(n).pipe(fC(SW(lW(e),{inputSchema:PW,outputSchema:FW})),hC(()=>Dd(r,mp)),bC(e=>{switch(e._tag){case`MetricsRequest`:return i;case`Pong`:return mp}}),pm),yield*tm(()=>i.pipe(Sp(K(hm,e=>py(n,td(e)))))),yield*pp(()=>dy(n,{_tag:`Ping`})).pipe(Rp(`3 seconds`),lm,pm),yield*Ed(r).pipe(Ip(`1 second`),Ep),IW.of({sendUnsafe(e){fy(n,e)}})}),RW=e=>({_tag:`MetricsSnapshot`,metrics:ip(e)}),zW=rf(IW,LW.pipe(Pm({module:`DevTools`,service:`Client`}))),BW=rf(Ao,gp(function*(){let e=yield*IW,t=yield*um;return To({span(n){let r=t.span(n);e.sendUnsafe(r);let i=r.event;r.event=function(t,n,a){return e.sendUnsafe({_tag:`SpanEvent`,traceId:r.traceId,spanId:r.spanId,name:t,startTime:n,attributes:a}),i.call(this,t,n,a)};let a=r.end;return r.end=function(t,n){a.call(this,t,n),e.sendUnsafe(r)},r},context:t.context})}).pipe(Pm({module:`DevTools`,service:`Tracer`}))).pipe(ff(zW)),VW=(e=`ws://localhost:34437`)=>BW.pipe(ff(gW(e))),HW=(e=`ws://localhost:34437`)=>VW(e).pipe(ff(pW)),UW=({verbose:e,agent:t})=>{let n=MR.withRepoRoot(process.cwd());return uf(PR.layer.pipe(ff(n)),FR.layer,ER.layer,GR.layer,HW(),n,JU.layerPostHog).pipe(ff(PA.layerFor(t??`claude`)),ff(eV),pf(tf(Vo,e?`All`:`Error`)))},WW=aB(z()),GW=pB(Om(function*(e){return UW({verbose:!0,agent:yield*e.some(WW)})},cf)).pipe(CB),KW=e=>e,qW=aB([]),JW=Om(function*(e,t){let n=yield*FR,r=yield*PR,i=yield*JU,a=yield*MR,o=Date.now(),s=yield*r.execute(e.options).pipe(iC(t=>W(()=>e.onUpdate(t))),yC,q(t=>t._tag===`Some`?t.value:new OE({...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,title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),c=yield*n.report(s),l=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`passed`).length,u=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`failed`).length;return yield*i.capture(`run:completed`,{plan_id:s.id??`direct`,passed:l,failed:u,step_count:s.steps.length,file_count:0,duration_ms:Date.now()-o}),c.status===`passed`&&(yield*a.saveTestedFingerprint()),{executedPlan:s,report:c}},Pm({fn:`executeFn`})),YW=GW.fn()((e,t)=>KW(JW(e,t))),XW=e=>{if(!ei(e.startedAt))return(ti(e.endedAt)?rh(e.endedAt.value):Date.now())-rh(e.startedAt.value)},ZW=e=>{let t=f(145);if(t[0]!==`447bd25450076f2f5c2b221ff4f492f14d8f1d33d6cbc58b16bee9c6a114a105`){for(let e=0;e<145;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`447bd25450076f2f5c2b221ff4f492f14d8f1d33d6cbc58b16bee9c6a114a105`}let{changesFor:a,instruction:s,savedFlow:c}=e,l=dz(QW),u=CT(),[d]=bT(),p=NB($W),m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m={mode:`promiseExit`},t[1]=m):m=t[1];let[h,_]=Se(YW,m),v=we(qW),w;t[2]===h?w=t[3]:(w=Sz(h),t[2]=h,t[3]=w);let T=w,E;t[4]===h?E=t[5]:(E=Dz(h),t[4]=h,t[5]=E);let D=E,O=D?h.value.report:void 0,[k,ee]=y(void 0),[te,ne]=y(void 0),[A,j]=y(0),[re,ie]=y(!1),ae;t[6]===A?ae=t[7]:(ae=PB(A),t[6]=A,t[7]=ae);let oe=ae,se,ce;t[8]!==p||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==_?(se=()=>(ne(Date.now()),_({options:{changesFor:a,instruction:s,isHeadless:!0,requiresCookies:!1,savedFlow:c},agentBackend:p,onUpdate:ee}),()=>{_(yB)}),ce=[_,p,a,s,c],t[8]=p,t[9]=a,t[10]=s,t[11]=c,t[12]=_,t[13]=se,t[14]=ce):(se=t[13],ce=t[14]),g(se,ce);let le,ue;t[15]!==k||t[16]!==D||t[17]!==O||t[18]!==l?(le=()=>{D&&k&&O&&(MB.getState().setExecutedPlan(k),l(uz.Results({report:O})))},ue=[D,k,O,l],t[15]=k,t[16]=D,t[17]=O,t[18]=l,t[19]=le,t[20]=ue):(le=t[19],ue=t[20]),g(le,ue);let de;t[21]===l?de=t[22]:(de=()=>{MB.getState().setExecutedPlan(void 0),l(uz.Main())},t[21]=l,t[22]=de);let fe=de,pe,me;t[23]!==T||t[24]!==te?(pe=()=>{if(te===void 0||!T)return;let e=setInterval(()=>{j(Date.now()-te)},1e3);return()=>clearInterval(e)},me=[te,T],t[23]=T,t[24]=te,t[25]=pe,t[26]=me):(pe=t[25],me=t[26]),g(pe,me);let M;t[27]!==k||t[28]!==h||t[29]!==fe||t[30]!==T||t[31]!==O||t[32]!==l||t[33]!==re?(M=(e,t)=>{let n=e.toLowerCase();if(re){if(t.return||n===`y`){ie(!1),fe();return}(t.escape||n===`n`)&&ie(!1);return}if(t.escape){if(kz(h)){fe();return}if(T){ie(!0);return}if(k&&O){MB.getState().setExecutedPlan(k),l(uz.Results({report:O}));return}fe()}},t[27]=k,t[28]=h,t[29]=fe,t[30]=T,t[31]=O,t[32]=l,t[33]=re,t[34]=M):M=t[34],o(M);let he;t[35]===k?he=t[36]:(he=k?.steps?k.steps.filter(eG).length:0,t[35]=k,t[36]=he);let ge=he,_e=k?.steps?k.steps.length:0,be;t[37]===k?.steps?be=t[38]:(be=k?.steps?.find(tG),t[37]=k?.steps,t[38]=be);let xe=be,Ce=xe?`Running ${xe.title}`:ge===_e&&_e>0?`Finishing up`:`Starting`,Te=T?`RUNNING`:`COMPLETE`,Ee=`${C.bullet} ${Te}`,De=` ${ge}/${_e} `,Oe=T?` ${C.pointerSmall} ${oe}`:``,ke=Math.max(0,d-2),Ae=Math.max(0,ke-ye(Ee)-1-ye(De)-1-ye(Oe)),je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke;if(t[39]!==u.SELECTION||t[40]!==ge||t[41]!==s||t[42]!==Ae||t[43]!==Ee||t[44]!==v||t[45]!==_e){let e=_e>0?Math.round(ge/_e*Ae):0;Pe=Ae-e,t[62]===v?Ke=t[63]:(Ke=x(r,{items:[...v],children:nG}),t[62]=v,t[63]=Ke),Ne=n,He=`column`,Ue=`100%`,We=1,t[64]===s?Ge=t[65]:(Ge=x(n,{paddingX:1,children:x(pz,{title:`Running browser test`,subtitle:s,showDivider:!1})}),t[64]=s,t[65]=Ge),Me=n,Le=1,Re=1,ze=`center`,t[66]!==u.SELECTION||t[67]!==Ee?(Be=x(i,{bold:!0,color:u.SELECTION,children:Ee}),t[66]=u.SELECTION,t[67]=Ee,t[68]=Be):Be=t[68],t[69]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=x(i,{children:` `}),t[69]=Ve):Ve=t[69],je=i,Fe=u.SELECTION,Ie=` `.repeat(e),t[39]=u.SELECTION,t[40]=ge,t[41]=s,t[42]=Ae,t[43]=Ee,t[44]=v,t[45]=_e,t[46]=je,t[47]=Me,t[48]=Ne,t[49]=Pe,t[50]=Fe,t[51]=Ie,t[52]=Le,t[53]=Re,t[54]=ze,t[55]=Be,t[56]=Ve,t[57]=He,t[58]=Ue,t[59]=We,t[60]=Ge,t[61]=Ke}else je=t[46],Me=t[47],Ne=t[48],Pe=t[49],Fe=t[50],Ie=t[51],Le=t[52],Re=t[53],ze=t[54],Be=t[55],Ve=t[56],He=t[57],Ue=t[58],We=t[59],Ge=t[60],Ke=t[61];let N;t[70]!==je||t[71]!==Fe||t[72]!==Ie?(N=x(je,{backgroundColor:Fe,children:Ie}),t[70]=je,t[71]=Fe,t[72]=Ie,t[73]=N):N=t[73];let qe=u.DIVIDER,Je;t[74]===Pe?Je=t[75]:(Je=` `.repeat(Pe),t[74]=Pe,t[75]=Je);let P;t[76]!==u.DIVIDER||t[77]!==Je?(P=x(i,{backgroundColor:qe,children:Je}),t[76]=u.DIVIDER,t[77]=Je,t[78]=P):P=t[78];let F;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(F=x(i,{children:` `}),t[79]=F):F=t[79];let Ye;t[80]!==u.DIVIDER||t[81]!==u.TEXT||t[82]!==De?(Ye=x(i,{backgroundColor:u.DIVIDER,color:u.TEXT,children:De}),t[80]=u.DIVIDER,t[81]=u.TEXT,t[82]=De,t[83]=Ye):Ye=t[83];let Xe;t[84]!==u.DIM||t[85]!==Oe?(Xe=Oe?x(i,{color:u.DIM,children:Oe}):null,t[84]=u.DIM,t[85]=Oe,t[86]=Xe):Xe=t[86];let Ze;t[87]!==Me||t[88]!==Le||t[89]!==Re||t[90]!==ze||t[91]!==Be||t[92]!==Ve||t[93]!==N||t[94]!==P||t[95]!==Ye||t[96]!==Xe?(Ze=S(Me,{marginTop:Le,paddingX:Re,alignItems:ze,children:[Be,Ve,N,P,F,Ye,Xe]}),t[87]=Me,t[88]=Le,t[89]=Re,t[90]=ze,t[91]=Be,t[92]=Ve,t[93]=N,t[94]=P,t[95]=Ye,t[96]=Xe,t[97]=Ze):Ze=t[97];let Qe;t[98]===k?.steps?Qe=t[99]:(Qe=k?.steps??[],t[98]=k?.steps,t[99]=Qe);let $e;if(t[100]!==u.DIM||t[101]!==u.GREEN||t[102]!==u.RED||t[103]!==A||t[104]!==Qe){let e;t[106]!==u.DIM||t[107]!==u.GREEN||t[108]!==u.RED||t[109]!==A?(e=(e,t)=>{let r=`Step ${t+1}`,a=ti(e.summary)?e.summary.value:e.title,o=XW(e),s=o===void 0?void 0:PB(o);return S(n,{flexDirection:`column`,children:[e.status===`passed`&&x(i,{color:u.GREEN,children:` ${C.tick} ${r} ${ve(a,100)}${s?` ${s}`:``}`}),e.status===`failed`&&x(i,{color:u.RED,children:` ${C.cross} ${r} ${ve(a,100)}${s?` ${s}`:``}`}),e.status===`active`&&S(n,{children:[x(i,{children:` `}),x(sz,{}),x(i,{children:` `}),x(jB,{text:`${r} ${e.title} ${PB(Math.round(A))}`,baseColor:xT.shimmerBase,highlightColor:xT.shimmerHighlight})]}),e.status!==`passed`&&e.status!==`failed`&&e.status!==`active`&&x(i,{color:u.DIM,children:` ○ ${r} ${e.title}`})]},e.id)},t[106]=u.DIM,t[107]=u.GREEN,t[108]=u.RED,t[109]=A,t[110]=e):e=t[110],$e=Qe.map(e),t[100]=u.DIM,t[101]=u.GREEN,t[102]=u.RED,t[103]=A,t[104]=Qe,t[105]=$e}else $e=t[105];let et;t[111]===$e?et=t[112]:(et=x(n,{flexDirection:`column`,marginTop:1,paddingX:1,children:$e}),t[111]=$e,t[112]=et);let tt;t[113]!==u.DIM||t[114]!==u.PRIMARY||t[115]!==u.YELLOW||t[116]!==re?(tt=re&&S(wT,{color:u.YELLOW,marginTop:1,children:[x(i,{color:u.YELLOW,bold:!0,children:`Stop this browser run?`}),x(i,{color:u.DIM,children:`This will terminate the agent and close the browser.`}),S(i,{color:u.DIM,children:[`Press `,x(i,{color:u.PRIMARY,children:`Enter`}),` or`,` `,x(i,{color:u.PRIMARY,children:`y`}),` to stop, or`,` `,x(i,{color:u.PRIMARY,children:`Esc`}),` or `,x(i,{color:u.PRIMARY,children:`n`}),` to keep it running.`]})]}),t[113]=u.DIM,t[114]=u.PRIMARY,t[115]=u.YELLOW,t[116]=re,t[117]=tt):tt=t[117];let nt;t[118]!==oe||t[119]!==T||t[120]!==Ce||t[121]!==re?(nt=T&&!re&&x(n,{marginTop:1,paddingX:1,flexDirection:`column`,children:x(jB,{text:`${Ce}${C.ellipsis} ${oe}`,baseColor:xT.shimmerBase,highlightColor:xT.shimmerHighlight})}),t[118]=oe,t[119]=T,t[120]=Ce,t[121]=re,t[122]=nt):nt=t[122];let rt;if(t[123]!==u.GREEN||t[124]!==h){let e;t[126]===u.GREEN?e=t[127]:(e=()=>x(n,{marginTop:1,flexDirection:`column`,paddingX:1,children:x(i,{color:u.GREEN,bold:!0,children:`Done`})}),t[126]=u.GREEN,t[127]=e),rt=Rz(h).onSuccess(e).orNull(),t[123]=u.GREEN,t[124]=h,t[125]=rt}else rt=t[125];let it;t[128]===h?it=t[129]:(it=Rz(h).onError(rG).orNull(),t[128]=h,t[129]=it);let at;t[130]!==Ne||t[131]!==He||t[132]!==Ue||t[133]!==We||t[134]!==Ge||t[135]!==Ze||t[136]!==et||t[137]!==tt||t[138]!==nt||t[139]!==rt||t[140]!==it?(at=S(Ne,{flexDirection:He,width:Ue,paddingY:We,children:[Ge,Ze,et,tt,nt,rt,it]}),t[130]=Ne,t[131]=He,t[132]=Ue,t[133]=We,t[134]=Ge,t[135]=Ze,t[136]=et,t[137]=tt,t[138]=nt,t[139]=rt,t[140]=it,t[141]=at):at=t[141];let ot;return t[142]!==Ke||t[143]!==at?(ot=S(b,{children:[Ke,at]}),t[142]=Ke,t[143]=at,t[144]=ot):ot=t[144],ot};function QW(e){return e.setScreen}function $W(e){return e.agentBackend}function eG(e){return e.status===`passed`||e.status===`failed`}function tG(e){return e.status===`active`}function nG(e){return x(n,{paddingX:1,children:x(XB,{src:e,alt:e})},e)}function rG(e){return x(n,{paddingX:1,children:x(ZB,{message:e instanceof Error?e.message:String(e)})})}const iG=e=>{try{return k.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},aG=(e,t)=>bm(JR.use(n=>n.addComment(process.cwd(),e,t)).pipe(Kp(JR.layer))),oG=()=>u({mutationFn:({pullRequest:e,body:t})=>aG(e,t)}),sG=GW.fn(Om(function*(e,t){return yield*(yield*GR).save(e.plan)},Pm({fn:`saveFlowFn`}))),cG=e=>{let t=f(127);if(t[0]!==`92621563db1765562efb133be09923a7c3871b2df21610dafefb890e2e5a6ea4`){for(let e=0;e<127;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`92621563db1765562efb133be09923a7c3871b2df21610dafefb890e2e5a6ea4`}let{report:r}=e,a=CT(),s=dz(lG),[c,l]=y(void 0),[u,d]=y(void 0),p=oG(),m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m={mode:`promiseExit`},t[1]=m):m=t[1];let[h,g]=Se(sG,m),_=h.waiting,v;t[2]===h?v=t[3]:(v=Dz(h),t[2]=h,t[3]=v);let b=v,C;t[4]===h?C=t[5]:(C=kz(h),t[4]=h,t[5]=C);let w=C,T;t[6]!==p||t[7]!==r.pullRequest||t[8]!==r.toPlainText?(T=()=>{ti(r.pullRequest)&&p.mutate({pullRequest:r.pullRequest.value,body:r.toPlainText})},t[6]=p,t[7]=r.pullRequest,t[8]=r.toPlainText,t[9]=T):T=t[9];let E=T,D;t[10]===r.toPlainText?D=t[11]:(D=()=>{if(d(void 0),l(void 0),iG(r.toPlainText)){l(`Copied share details to the clipboard.`);return}d(`Failed to copy share details to the clipboard.`)},t[10]=r.toPlainText,t[11]=D);let O=D,k;t[12]!==r||t[13]!==_||t[14]!==b||t[15]!==g?(k=async()=>{_||b||await g({plan:r})},t[12]=r,t[13]=_,t[14]=b,t[15]=g,t[16]=k):k=t[16];let ee=k,te;t[17]!==r.changesFor||t[18]!==r.instruction||t[19]!==s?(te=()=>{MB.getState().setExecutedPlan(void 0),s(uz.Testing({changesFor:r.changesFor,instruction:r.instruction}))},t[17]=r.changesFor,t[18]=r.instruction,t[19]=s,t[20]=te):te=t[20];let ne=te,A;t[21]!==O||t[22]!==E||t[23]!==ne||t[24]!==ee?(A=e=>{let t=e.toLowerCase();t===`y`&&O(),t===`p`&&E(),t===`s`&&ee(),t===`r`&&ne()},t[21]=O,t[22]=E,t[23]=ne,t[24]=ee,t[25]=A):A=t[25],o(A);let j=r.title,re;t[26]===r.status?re=t[27]:(re=r.status.toUpperCase(),t[26]=r.status,t[27]=re);let ie=`${j} │ ${re}`,ae;t[28]===ie?ae=t[29]:(ae=x(n,{paddingX:1,children:x(pz,{title:`Run results`,subtitle:ie})}),t[28]=ie,t[29]=ae);let oe=r.status===`passed`?a.GREEN:a.RED,se=r.status===`passed`?a.GREEN:a.RED,ce=r.status===`passed`?`Test completed`:`Issues found`,le;t[30]!==se||t[31]!==ce?(le=x(i,{color:se,bold:!0,children:ce}),t[30]=se,t[31]=ce,t[32]=le):le=t[32];let ue;t[33]!==a.TEXT||t[34]!==r.summary?(ue=x(i,{color:a.TEXT,children:r.summary}),t[33]=a.TEXT,t[34]=r.summary,t[35]=ue):ue=t[35];let de;t[36]!==a.DIM||t[37]!==r.pullRequest?(de=ti(r.pullRequest)?S(i,{color:a.DIM,children:[`PR: `,r.pullRequest.value.title,` (#`,r.pullRequest.value.number,`)`]}):null,t[36]=a.DIM,t[37]=r.pullRequest,t[38]=de):de=t[38];let fe;t[39]!==oe||t[40]!==le||t[41]!==ue||t[42]!==de?(fe=S(wT,{color:oe,marginTop:1,children:[le,ue,de]}),t[39]=oe,t[40]=le,t[41]=ue,t[42]=de,t[43]=fe):fe=t[43];let pe;t[44]===a.DIM?pe=t[45]:(pe=x(i,{color:a.DIM,bold:!0,children:`STEP SUMMARY`}),t[44]=a.DIM,t[45]=pe);let me;if(t[46]!==a.GREEN||t[47]!==a.RED||t[48]!==a.TEXT||t[49]!==a.YELLOW||t[50]!==r.steps){let e;t[52]!==a.GREEN||t[53]!==a.RED||t[54]!==a.TEXT||t[55]!==a.YELLOW?(e=e=>S(i,{color:e.status===`passed`?a.GREEN:e.status===`failed`?a.RED:a.YELLOW,children:[`• `,e.title,`: `,x(i,{color:a.TEXT,children:ri(e.summary,uG)})]},e.id),t[52]=a.GREEN,t[53]=a.RED,t[54]=a.TEXT,t[55]=a.YELLOW,t[56]=e):e=t[56],me=r.steps.map(e),t[46]=a.GREEN,t[47]=a.RED,t[48]=a.TEXT,t[49]=a.YELLOW,t[50]=r.steps,t[51]=me}else me=t[51];let M;t[57]!==pe||t[58]!==me?(M=S(n,{flexDirection:`column`,marginTop:1,paddingX:1,children:[pe,me]}),t[57]=pe,t[58]=me,t[59]=M):M=t[59];let he;t[60]===a.PRIMARY?he=t[61]:(he=x(i,{color:a.PRIMARY,children:`y`}),t[60]=a.PRIMARY,t[61]=he);let ge;t[62]!==a.DIM||t[63]!==he?(ge=S(i,{color:a.DIM,children:[`Press `,he,` to copy share details to the clipboard.`]}),t[62]=a.DIM,t[63]=he,t[64]=ge):ge=t[64];let _e;t[65]!==O||t[66]!==ge?(_e=x(ET,{onClick:O,children:ge}),t[65]=O,t[66]=ge,t[67]=_e):_e=t[67];let ve;t[68]!==a.GREEN||t[69]!==c?(ve=c?x(i,{color:a.GREEN,children:c}):null,t[68]=a.GREEN,t[69]=c,t[70]=ve):ve=t[70];let ye;t[71]!==a.RED||t[72]!==u?(ye=u?x(i,{color:a.RED,children:u}):null,t[71]=a.RED,t[72]=u,t[73]=ye):ye=t[73];let be;t[74]!==_e||t[75]!==ve||t[76]!==ye?(be=S(n,{flexDirection:`column`,paddingX:1,marginTop:1,children:[_e,ve,ye]}),t[74]=_e,t[75]=ve,t[76]=ye,t[77]=be):be=t[77];let xe;t[78]!==a.DIM||t[79]!==a.GREEN||t[80]!==a.PRIMARY||t[81]!==a.RED||t[82]!==p||t[83]!==E||t[84]!==r.pullRequest?(xe=ti(r.pullRequest)?S(n,{flexDirection:`column`,paddingX:1,children:[x(ET,{onClick:E,children:S(i,{color:a.DIM,children:[`Press `,x(i,{color:a.PRIMARY,children:`p`}),` to post this summary to the PR.`]})}),p.isPending?x(i,{color:a.DIM,children:`Posting PR comment...`}):null,p.isSuccess?x(i,{color:a.GREEN,children:`Comment posted to PR.`}):null,p.isError?x(i,{color:a.RED,children:`Failed to post PR comment.`}):null]}):null,t[78]=a.DIM,t[79]=a.GREEN,t[80]=a.PRIMARY,t[81]=a.RED,t[82]=p,t[83]=E,t[84]=r.pullRequest,t[85]=xe):xe=t[85];let Ce;t[86]===a.PRIMARY?Ce=t[87]:(Ce=x(i,{color:a.PRIMARY,children:`s`}),t[86]=a.PRIMARY,t[87]=Ce);let we;t[88]!==a.DIM||t[89]!==Ce?(we=S(i,{color:a.DIM,children:[`Press `,Ce,` to save this flow for re-use.`]}),t[88]=a.DIM,t[89]=Ce,t[90]=we):we=t[90];let Te;t[91]!==ee||t[92]!==we?(Te=x(ET,{onClick:ee,children:we}),t[91]=ee,t[92]=we,t[93]=Te):Te=t[93];let Ee;t[94]!==a.DIM||t[95]!==_?(Ee=_&&x(i,{color:a.DIM,children:`Saving flow...`}),t[94]=a.DIM,t[95]=_,t[96]=Ee):Ee=t[96];let De;t[97]!==a.GREEN||t[98]!==b?(De=b&&x(i,{color:a.GREEN,children:`Flow saved.`}),t[97]=a.GREEN,t[98]=b,t[99]=De):De=t[99];let Oe;t[100]!==a.RED||t[101]!==w?(Oe=w&&x(i,{color:a.RED,children:`Failed to save flow.`}),t[100]=a.RED,t[101]=w,t[102]=Oe):Oe=t[102];let ke;t[103]!==Te||t[104]!==Ee||t[105]!==De||t[106]!==Oe?(ke=S(n,{flexDirection:`column`,paddingX:1,marginTop:1,children:[Te,Ee,De,Oe]}),t[103]=Te,t[104]=Ee,t[105]=De,t[106]=Oe,t[107]=ke):ke=t[107];let Ae;t[108]===a.PRIMARY?Ae=t[109]:(Ae=x(i,{color:a.PRIMARY,children:`r`}),t[108]=a.PRIMARY,t[109]=Ae);let je;t[110]!==a.DIM||t[111]!==Ae?(je=S(i,{color:a.DIM,children:[`Press `,Ae,` to restart this flow.`]}),t[110]=a.DIM,t[111]=Ae,t[112]=je):je=t[112];let Me;t[113]!==ne||t[114]!==je?(Me=x(n,{flexDirection:`column`,paddingX:1,marginTop:1,children:x(ET,{onClick:ne,children:je})}),t[113]=ne,t[114]=je,t[115]=Me):Me=t[115];let Ne;t[116]===r.screenshotPaths?Ne=t[117]:(Ne=r.screenshotPaths.map(dG),t[116]=r.screenshotPaths,t[117]=Ne);let Pe;return t[118]!==ae||t[119]!==fe||t[120]!==M||t[121]!==be||t[122]!==xe||t[123]!==ke||t[124]!==Me||t[125]!==Ne?(Pe=S(n,{flexDirection:`column`,width:`100%`,paddingY:1,children:[ae,fe,M,be,xe,ke,Me,Ne]}),t[118]=ae,t[119]=fe,t[120]=M,t[121]=be,t[122]=xe,t[123]=ke,t[124]=Me,t[125]=Ne,t[126]=Pe):Pe=t[126],Pe};function lG(e){return e.setScreen}function uG(){return`no summary found`}function dG(e){return x(n,{paddingX:1,children:x(XB,{src:e,alt:`Screenshot: ${e}`})},e)}const fG=uf(GR.layer,MR.withRepoRoot(process.cwd())),pG=()=>d({queryKey:[`saved-flows`],queryFn:()=>gp(function*(){return yield*(yield*GR).list()}).pipe(Kp(fG),bm)}),mG=new JT({isGitRepo:!1,currentBranch:`HEAD`,mainBranch:void 0,isOnMain:!1,hasChangesFromMain:!1,hasUnstagedChanges:!1,hasBranchCommits:!1,branchCommitCount:0,fileStats:[],fingerprint:void 0,savedFingerprint:void 0}),hG=()=>d({queryKey:[`git-state`],queryFn:async()=>{let e=await Sm(gp(function*(){return yield*(yield*MR).getState()}).pipe(Kp(MR.withRepoRoot(process.cwd())),J(`FindRepoRootError`,()=>U(mG)),Lp({duration:1e4,onTimeout:()=>U(mG)})));return bd(e)?e.value:mG}}),gG=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],_G=(e,t)=>{let n=ZT.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=gG(e);dz.getState().setScreen(uz.Testing({changesFor:n,instruction:e.flow.userInstruction,savedFlow:{title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r}}))},vG=()=>{let e=f(11);if(e[0]!==`9d8b667af674bbd8e6f4ac3c69bd48353aed39e0d7710f3e58b74a9e312bd40d`){for(let t=0;t<11;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`9d8b667af674bbd8e6f4ac3c69bd48353aed39e0d7710f3e58b74a9e312bd40d`}let t=CT(),[r]=bT(),a=dz(yG),{data:s}=hG(),{data:c,isLoading:l}=pG(),u=c===void 0?[]:c,{highlightedIndex:d,setHighlightedIndex:p,scrollOffset:m,handleNavigation:h}=lz({itemCount:u.length,visibleCount:15}),g=Math.min(40,Math.floor(r*.35)),_=Math.max(20,r-g-8),v=u.slice(m,m+15);o((e,t)=>{if(!h(e,t)){if(t.return){let e=u[d];e&&_G(e,s?.mainBranch??`main`)}t.escape&&a(uz.Main())}});let y=n,b=`${u.length} flow${u.length===1?``:`s`}`,w;e[1]===b?w=e[2]:(w=x(n,{paddingX:1,children:x(pz,{title:`Saved flows`,subtitle:b})}),e[1]=b,e[2]=w);let T;e[3]===l?T=e[4]:(T=l&&x(n,{marginTop:1,paddingX:1,children:x(sz,{message:`Loading saved flows...`})}),e[3]=l,e[4]=T);let E=!l&&u.length===0&&x(n,{marginTop:1,paddingX:1,flexDirection:`column`,children:S(i,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,x(i,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),D=!l&&u.length>0&&x(n,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:v.map((e,n)=>{let r=n+m,a=r===d,o=gG(e).length;return S(ET,{onClick:()=>{p(r),_G(e,s?.mainBranch??`main`)},children:[x(i,{color:a?t.PRIMARY:t.DIM,children:a?`${C.pointer} `:` `}),x(i,{color:a?t.PRIMARY:t.TEXT,bold:a,children:cz(ve(e.title,g-1),g)}),x(i,{color:t.DIM,children:cz(`${o} step${o===1?``:`s`}`,10)}),x(i,{color:t.DIM,children:ve(e.description,_)})]},e.slug)})}),O;return e[5]!==y||e[6]!==w||e[7]!==T||e[8]!==E||e[9]!==D?(O=S(y,{flexDirection:`column`,width:`100%`,paddingY:1,children:[w,T,E,D]}),e[5]=y,e[6]=w,e[7]=T,e[8]=E,e[9]=D,e[10]=O):O=e[10],O};function yG(e){return e.setScreen}const bG=e=>{let t=f(7);if(t[0]!==`070c94f090c259613af1b54fafa11f04098cc74e999b5505c4b7c3689a987d6d`){for(let e=0;e<7;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`070c94f090c259613af1b54fafa11f04098cc74e999b5505c4b7c3689a987d6d`}let{status:n}=e,r=CT();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=S(i,{color:r.GREEN,children:[C.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=S(i,{color:r.PURPLE,children:[C.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=S(i,{color:r.DIM,children:[C.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},xG=e=>{let t=f(50);if(t[0]!==`070c94f090c259613af1b54fafa11f04098cc74e999b5505c4b7c3689a987d6d`){for(let e=0;e<50;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`070c94f090c259613af1b54fafa11f04098cc74e999b5505c4b7c3689a987d6d`}let{options:r,selectedIndex:a,isLoading:s,onSelect:c,onNavigate:l,query:u,onQueryChange:d,onDismiss:p,gitState:m}=e,h=CT(),g;t[1]!==p||t[2]!==l||t[3]!==d||t[4]!==c||t[5]!==r||t[6]!==u||t[7]!==a?(g=(e,t)=>{if(t.escape){p();return}if(t.downArrow||t.ctrl&&e===`n`){l(Math.min(r.length-1,a+1));return}if(t.upArrow||t.ctrl&&e===`p`){l(Math.max(0,a-1));return}if(t.return||t.tab){let e=r[a];e&&c(e);return}if(t.backspace||t.delete){u.length===0?p():d(u.slice(0,-1));return}if(e&&!t.ctrl&&!t.meta){let t=_T(e);t&&d(u+t)}},t[1]=p,t[2]=l,t[3]=d,t[4]=c,t[5]=r,t[6]=u,t[7]=a,t[8]=g):g=t[8],o(g);let _;bb0:{if(r.length<=8){_=0;break bb0}let e=r.length-8;_=Math.min(e,Math.max(0,a-4))}let v=_,y,b,w,T;if(t[9]!==h.BORDER||t[10]!==h.DIM||t[11]!==h.GREEN||t[12]!==h.PRIMARY||t[13]!==h.PURPLE||t[14]!==h.TEXT||t[15]!==m||t[16]!==s||t[17]!==r||t[18]!==v||t[19]!==a){T=Symbol.for(`react.early_return_sentinel`);bb1:{let e=r.slice(v,v+8);if(r.length===0&&!s){let e;t[24]===h.DIM?e=t[25]:(e=x(i,{color:h.DIM,children:`No matching results`}),t[24]=h.DIM,t[25]=e);let n;t[26]!==h.BORDER||t[27]!==e?(n=x(wT,{color:h.BORDER,children:e}),t[26]=h.BORDER,t[27]=e,t[28]=n):n=t[28],T=n;break bb1}y=wT,b=h.PRIMARY;let o;t[29]!==h.DIM||t[30]!==h.GREEN||t[31]!==h.PRIMARY||t[32]!==h.PURPLE||t[33]!==h.TEXT||t[34]!==m||t[35]!==v||t[36]!==a?(o=(e,t)=>{let r=t+v===a,o=nz(e,m),s=rz(e,m),c=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prNumber:null,l=e._tag===`PullRequest`||e._tag===`Branch`?e.branch.prStatus:null;return S(n,{children:[x(i,{color:r?h.PRIMARY:h.DIM,children:r?`${C.pointer} `:` `}),e._tag===`WorkingTree`?S(i,{color:h.GREEN,children:[C.bullet,` `]}):null,l?x(bG,{status:l}):null,x(i,{color:r?h.PRIMARY:h.TEXT,bold:r,children:o}),c?S(i,{children:[` `,S(i,{color:l===`open`?h.GREEN:l===`merged`?h.PURPLE:h.DIM,children:[`#`,c]}),l?S(i,{color:h.DIM,children:[` `,l]}):null]}):null,s&&!c?S(i,{color:h.DIM,children:[` `,s]}):null]},CE(e))},t[29]=h.DIM,t[30]=h.GREEN,t[31]=h.PRIMARY,t[32]=h.PURPLE,t[33]=h.TEXT,t[34]=m,t[35]=v,t[36]=a,t[37]=o):o=t[37],w=e.map(o)}t[9]=h.BORDER,t[10]=h.DIM,t[11]=h.GREEN,t[12]=h.PRIMARY,t[13]=h.PURPLE,t[14]=h.TEXT,t[15]=m,t[16]=s,t[17]=r,t[18]=v,t[19]=a,t[20]=y,t[21]=b,t[22]=w,t[23]=T}else y=t[20],b=t[21],w=t[22],T=t[23];if(T!==Symbol.for(`react.early_return_sentinel`))return T;let E;t[38]!==h.DIM||t[39]!==s?(E=s?x(n,{children:S(i,{color:h.DIM,children:[` Loading PRs and branches`,C.ellipsis]})}):null,t[38]=h.DIM,t[39]=s,t[40]=E):E=t[40];let D;t[41]!==h.DIM||t[42]!==r.length?(D=r.length>8?x(n,{children:S(i,{color:h.DIM,children:[` `,r.length-8,` more `,C.arrowUp,`/`,C.arrowDown]})}):null,t[41]=h.DIM,t[42]=r.length,t[43]=D):D=t[43];let O;return t[44]!==y||t[45]!==b||t[46]!==w||t[47]!==E||t[48]!==D?(O=S(y,{color:b,children:[w,E,D]}),t[44]=y,t[45]=b,t[46]=w,t[47]=E,t[48]=D,t[49]=O):O=t[49],O},SG=({gitState:e,onSelect:t})=>{let[n,r]=y(!1),[i,a]=y(``),[o,s]=y(0),{data:c=[]}=d({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>$R(e),enabled:!!e}),{data:l=[],isLoading:u}=d({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>tz(e),enabled:n&&!!e}),f=_(()=>[...c,...l],[c,l]),p=_(()=>az(f,i,e),[f,i,e]);g(()=>{s(0)},[i]);let h=m(()=>{r(!0),a(``),s(0)},[]),v=m(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:p,localOptions:c,remoteLoading:u,openPicker:h,closePicker:v,handleContextSelect:m(e=>{t(e),v()},[t,v]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=_T(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)),h();return}if(n){i.length-o.length<0?(v(),t(i)):a(e=>{let n=i.slice(o.length);return n.includes(` `)?(v(),t(i),``):e+n});return}t(i)}}},CG=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],wG=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],TG=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],EG=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],DG=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],OG=(e,t)=>{if(!e)return CG;switch(e._tag){case`WorkingTree`:return wG;case`Branch`:return TG;case`PullRequest`:return EG;case`Commit`:return DG;default:return CG}},kG=({gitState:e})=>{let t=CT(),[r]=bT(),a=NB(e=>e.instructionHistory),s=dz(e=>e.setScreen),[c,l]=y(void 0),[u,d]=y(``),[f,p]=y(0),[h,b]=y(0),[C,w]=y(!1),[T,E]=y(void 0),[D,O]=y(-1),[k,ee]=y(``),te=m(()=>{if(a.length===0)return;let e=D+1;e>=a.length||(D===-1&&ee(u),O(e),d(a[e]),p(e=>e+1))},[D,a,u]),ne=m(()=>{if(D<=-1)return;let e=D-1;O(e),d(e===-1?k:a[e]),p(e=>e+1)},[D,a,k]),A=SG({gitState:e,onSelect:l}),j=!A.pickerOpen,re=_(()=>A.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,[A.localOptions]),ie=c??re??null,ae=_(()=>OG(ie,e),[ie,e]);g(()=>{b(0)},[ie,e]);let oe=m(t=>{let n=(t??u).trim();if(console.error(`[main-menu] submit called, trimmed:`,JSON.stringify(n)),!n){E(`Describe what you want the browser agent to test.`);return}let r=e.mainBranch??`main`,i;console.error(`[main-menu] activeContext:`,ie?._tag??`none`),ie?._tag===`Commit`?i=ZT.makeUnsafe({_tag:`Commit`,hash:ie.hash}):ie?._tag===`Branch`||ie?._tag===`PullRequest`?(ie.branch.name&&(KR(process.cwd(),ie.branch.name),fz.invalidateQueries({queryKey:[`git-state`]})),i=ZT.makeUnsafe({_tag:`Branch`,mainBranch:r})):i=ZT.makeUnsafe({_tag:`Changes`,mainBranch:r}),console.error(`[main-menu] changesFor:`,i._tag),NB.getState().rememberInstruction(n),s(uz.Testing({changesFor:i,instruction:n}))},[u,ie,e,s]),se=v(u);se.current=u;let ce=_(()=>A.createInputChangeHandler(se,e=>{d(e),T&&E(void 0)}),[A,T]),le=u===``&&!A.pickerOpen&&ae.length>0,ue=le&&!C,de=ae[h%ae.length];return o((e,t)=>{if(!A.pickerOpen){if(t.tab&&!t.shift&&le&&de){d(de),p(e=>e+1);return}if(!(t.tab&&t.shift)&&le){if(t.rightArrow){b(e=>(e+1)%ae.length),w(!0);return}if(t.leftArrow){b(e=>(e-1+ae.length)%ae.length),w(!0);return}}}},{isActive:!0}),S(n,{flexDirection:`column`,width:`100%`,paddingY:1,children:[S(n,{flexDirection:`column`,marginBottom:1,paddingX:1,children:[S(i,{color:t.BORDER,children:[x(i,{bold:!0,color:t.TEXT,children:`Expect CLI`}),x(i,{color:t.DIM,children:` v0.0.2`})]}),x(i,{color:t.BORDER,children:`─`.repeat(Math.max(0,r-2))})]}),S(n,{flexDirection:`column`,width:`100%`,children:[x(n,{justifyContent:`space-between`,paddingX:1,children:x(ET,{fullWidth:!1,onClick:()=>{A.pickerOpen?A.closePicker():A.openPicker()},children:ie?S(i,{color:t.DIM,children:[`Testing`,` `,S(i,{color:t.PRIMARY,children:[`@`,iz(ie,e)]}),` `,rz(ie,e)]}):S(i,{color:t.DIM,children:[x(i,{color:t.PRIMARY,children:`@`}),` no context`]})})}),x(ET,{children:x(wT,{color:j?t.PRIMARY:t.BORDER,marginTop:1,paddingX:0,children:S(n,{justifyContent:`space-between`,children:[S(n,{children:[x(i,{color:t.PRIMARY,children:`❯ `}),x(MT,{focus:!A.pickerOpen,multiline:!0,placeholder:de?`${de} [tab]`:``,value:u,onSubmit:oe,onUpArrowAtTop:te,onDownArrowAtBottom:ne,onChange:ce},f)]}),ue?x(i,{color:t.DIM,children:`←→ cycle test suggestions `}):null]})})}),A.pickerOpen?S(n,{flexDirection:`column`,children:[S(n,{marginBottom:0,paddingX:1,children:[x(i,{color:t.DIM,children:`@ `}),x(i,{color:t.PRIMARY,children:A.pickerQuery}),x(i,{color:t.DIM,children:A.pickerQuery?``:`type to filter`})]}),x(xG,{options:A.filteredOptions,selectedIndex:A.pickerIndex,isLoading:A.remoteLoading,query:A.pickerQuery,gitState:e,onQueryChange:A.setPickerQuery,onSelect:A.handleContextSelect,onNavigate:A.setPickerIndex,onDismiss:A.closePicker})]}):x(n,{marginTop:1,paddingX:1,children:S(i,{color:t.DIM,children:[`type `,x(i,{color:t.PRIMARY,children:`@`}),` to set context (PRs, branches, commits)`]})})]}),x(ZB,{message:T})]})},AG=e=>{let t=f(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,a=n.color??r,o;t[1]!==n.label||t[2]!==a?(o=S(i,{color:a,children:[n.label,` `]}),t[1]=n.label,t[2]=a,t[3]=o):o=t[3];let s=n.color??r,c;t[4]!==n.key||t[5]!==s?(c=S(i,{color:s,children:[`[`,n.key,`]`]}),t[4]=n.key,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==o||t[8]!==c?(l=S(b,{children:[o,c]}),t[7]=o,t[8]=c,t[9]=l):l=t[9],l},jG=e=>{let t=f(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:r,color:a,mutedColor:o}=e,s;t[1]===a?s=t[2]:(s=x(i,{color:a,children:` `}),t[1]=a,t[2]=s);let c;if(t[3]!==o||t[4]!==r){let e;t[6]!==o||t[7]!==r.length?(e=(e,t)=>S(n,{children:[e.onClick?x(ET,{fullWidth:!1,onClick:e.onClick,children:x(AG,{segment:e,mutedColor:o})}):x(AG,{segment:e,mutedColor:o}),t<r.length-1&&x(i,{color:o,children:` `})]},e.key+e.label),t[6]=o,t[7]=r.length,t[8]=e):e=t[8],c=r.map(e),t[3]=o,t[4]=r,t[5]=c}else c=t[5];let l;return t[9]!==s||t[10]!==c?(l=S(n,{children:[s,c]}),t[9]=s,t[10]=c,t[11]=l):l=t[11],l},MG=e=>{let t=f(68);if(t[0]!==`5d74254ed54c6b272b969b0663f412c0ff909e17657716d79e201d8fcab8b2a0`){for(let e=0;e<68;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`5d74254ed54c6b272b969b0663f412c0ff909e17657716d79e201d8fcab8b2a0`}let n=CT(),r=dz(FG);switch(e._tag){case`Main`:{let e;t[1]===r?e=t[2]:(e={key:`ctrl+r`,label:`saved flows`,cta:!0,onClick:()=>r(uz.SavedFlowPicker())},t[1]=r,t[2]=e);let n;t[3]===r?n=t[4]:(n={key:`ctrl+p`,label:`pick pr`,cta:!0,onClick:()=>r(uz.SelectPr())},t[3]=r,t[4]=n);let i;return t[5]!==e||t[6]!==n?(i=[e,n],t[5]=e,t[6]=n,t[7]=i):i=t[7],i}case`SelectPr`:{let e,i,a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},i={key:`←→`,label:`filter`},a={key:`/`,label:`search`},t[8]=e,t[9]=i,t[10]=a):(e=t[8],i=t[9],a=t[10]);let o;t[11]===r?o=t[12]:(o={key:`esc`,label:`back`,cta:!0,onClick:()=>r(uz.Main())},t[11]=r,t[12]=o);let s;t[13]===n.PRIMARY?s=t[14]:(s={key:`enter`,label:`select`,color:n.PRIMARY,cta:!0},t[13]=n.PRIMARY,t[14]=s);let c;return t[15]!==o||t[16]!==s?(c=[e,i,a,o,s],t[15]=o,t[16]=s,t[17]=c):c=t[17],c}case`SavedFlowPicker`:{let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`↑↓`,label:`nav`},t[18]=e):e=t[18];let i;t[19]===r?i=t[20]:(i={key:`esc`,label:`back`,cta:!0,onClick:()=>r(uz.Main())},t[19]=r,t[20]=i);let a;t[21]===n.PRIMARY?a=t[22]:(a={key:`enter`,label:`select`,color:n.PRIMARY,cta:!0},t[21]=n.PRIMARY,t[22]=a);let o;return t[23]!==i||t[24]!==a?(o=[e,i,a],t[23]=i,t[24]=a,t[25]=o):o=t[25],o}case`CookieSyncConfirm`:{let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i={key:`↑↓`,label:`nav`},t[26]=i):i=t[26];let a;t[27]===r?a=t[28]:(a={key:`esc`,label:`back`,onClick:()=>r(uz.Main())},t[27]=r,t[28]=a);let o;t[29]!==e.changesFor||t[30]!==e.instruction||t[31]!==e.savedFlow||t[32]!==r?(o={key:`c`,label:`enable sync`,cta:!0,onClick:()=>{r(uz.Testing({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow}))}},t[29]=e.changesFor,t[30]=e.instruction,t[31]=e.savedFlow,t[32]=r,t[33]=o):o=t[33];let s;t[34]!==e.changesFor||t[35]!==e.instruction||t[36]!==e.savedFlow||t[37]!==r?(s=()=>{r(uz.Testing({changesFor:e.changesFor,instruction:e.instruction,savedFlow:e.savedFlow}))},t[34]=e.changesFor,t[35]=e.instruction,t[36]=e.savedFlow,t[37]=r,t[38]=s):s=t[38];let c;t[39]!==n.PRIMARY||t[40]!==s?(c={key:`a`,label:`run anyway`,color:n.PRIMARY,cta:!0,onClick:s},t[39]=n.PRIMARY,t[40]=s,t[41]=c):c=t[41];let l;return t[42]!==a||t[43]!==o||t[44]!==c?(l=[i,a,o,c],t[42]=a,t[43]=o,t[44]=c,t[45]=l):l=t[45],l}case`Testing`:{let e;return t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=[{key:`esc`,label:`cancel`}],t[46]=e):e=t[46],e}case`Results`:{let i;t[47]===n.PRIMARY?i=t[48]:(i={key:`y`,label:`copy`,color:n.PRIMARY,cta:!0},t[47]=n.PRIMARY,t[48]=i);let a;if(t[49]!==n.PRIMARY||t[50]!==e.report.changesFor||t[51]!==e.report.instruction||t[52]!==e.report.pullRequest||t[53]!==r||t[54]!==i){if(a=[i],ti(e.report.pullRequest)){let e;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(e={key:`p`,label:`post to PR`,cta:!0},t[56]=e):e=t[56],a.push(e)}let o;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(o={key:`s`,label:`save flow`,cta:!0},t[57]=o):o=t[57],a.push(o);let s;t[58]!==e.report.changesFor||t[59]!==e.report.instruction||t[60]!==r?(s=()=>{MB.getState().setExecutedPlan(void 0),r(uz.Testing({changesFor:e.report.changesFor,instruction:e.report.instruction}))},t[58]=e.report.changesFor,t[59]=e.report.instruction,t[60]=r,t[61]=s):s=t[61];let c;t[62]!==n.PRIMARY||t[63]!==s?(c={key:`r`,label:`restart`,color:n.PRIMARY,cta:!0,onClick:s},t[62]=n.PRIMARY,t[63]=s,t[64]=c):c=t[64],a.push(c);let l;t[65]===r?l=t[66]:(l={key:`esc`,label:`main menu`,cta:!0,onClick:()=>{MB.getState().setExecutedPlan(void 0),r(uz.Main())}},t[65]=r,t[66]=l),a.push(l),t[49]=n.PRIMARY,t[50]=e.report.changesFor,t[51]=e.report.instruction,t[52]=e.report.pullRequest,t[53]=r,t[54]=i,t[55]=a}else a=t[55];return a}default:{let e;return t[67]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[67]=e):e=t[67],e}}},NG=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,PG=()=>{let e=f(32);if(e[0]!==`5d74254ed54c6b272b969b0663f412c0ff909e17657716d79e201d8fcab8b2a0`){for(let t=0;t<32;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`5d74254ed54c6b272b969b0663f412c0ff909e17657716d79e201d8fcab8b2a0`}let[t]=bT(),{data:r}=hG(),a=dz(IG),o=MG(a);if(!r)return null;let s,c,l,u,d,p,m,h;if(e[1]!==t||e[2]!==a._tag||e[3]!==o){u=o.filter(LG);let r=o.filter(RG),f=NG(u),g=r.map(zG).join(` `),_=r.length>0?ye(g):0,v=ye(f);l=Math.max(0,t-_-v-2),c=n,m=`column`,e[12]!==t||e[13]!==a._tag?(h=a._tag===`Testing`?x(jB,{text:`─`.repeat(t),baseColor:xT.shimmerBase,highlightColor:xT.shimmerHighlight,speed:3}):x(i,{color:xT.border,children:`─`.repeat(t)}),e[12]=t,e[13]=a._tag,e[14]=h):h=e[14],s=n,d=1,p=r.map(BG),e[1]=t,e[2]=a._tag,e[3]=o,e[4]=s,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=p,e[10]=m,e[11]=h}else s=e[4],c=e[5],l=e[6],u=e[7],d=e[8],p=e[9],m=e[10],h=e[11];let g;e[15]===l?g=e[16]:(g=` `.repeat(l),e[15]=l,e[16]=g);let _;e[17]===g?_=e[18]:(_=x(i,{children:g}),e[17]=g,e[18]=_);let v;e[19]===u?v=e[20]:(v=u.length>0?x(jG,{segments:u,color:xT.primary,mutedColor:xT.textMuted}):null,e[19]=u,e[20]=v);let y;e[21]!==s||e[22]!==d||e[23]!==p||e[24]!==_||e[25]!==v?(y=S(s,{paddingX:d,children:[p,_,v]}),e[21]=s,e[22]=d,e[23]=p,e[24]=_,e[25]=v,e[26]=y):y=e[26];let b;return e[27]!==c||e[28]!==m||e[29]!==h||e[30]!==y?(b=S(c,{flexDirection:m,children:[h,y]}),e[27]=c,e[28]=m,e[29]=h,e[30]=y,e[31]=b):b=e[31],b};function FG(e){return e.setScreen}function IG(e){return e.screen}function LG(e){return!e.cta}function RG(e){return e.cta}function zG(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function BG(e,t){let n=S(i,{children:[t>0?` `:``,e.color?S(i,{backgroundColor:e.color,color:`black`,children:[` `,x(i,{bold:!0,children:e.label}),` `,S(i,{children:[`[`,e.key,`]`]}),` `]}):S(i,{children:[S(i,{color:xT.textMuted,children:[e.label,` `]}),S(i,{color:xT.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?x(ET,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let VG=null;const HG=e=>{VG=e},UG=()=>VG?.clear(),WG=e=>{let t=f(28);if(t[0]!==`190045d8ba62145bccb104eb8a31671f055cc5f1701ab1ca9b750b96679c56bd`){for(let e=0;e<28;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`190045d8ba62145bccb104eb8a31671f055cc5f1701ab1ca9b750b96679c56bd`}let{agent:r}=e,i=dz(GG),a=dz(KG),s=dz(qG),{data:c,isLoading:l}=hG(),u=Ce(WW),d,p;t[1]!==r||t[2]!==u?(d=()=>{u(B(r))},p=[r,u],t[1]=r,t[2]=u,t[3]=d,t[4]=p):(d=t[3],p=t[4]),g(d,p);let m;t[5]!==i._tag||t[6]!==a?(m=()=>{if(i._tag===`CookieSyncConfirm`){a(uz.Main());return}if(i._tag===`Results`){MB.getState().setExecutedPlan(void 0),a(uz.Main());return}i._tag!==`Testing`&&a(uz.Main())},t[5]=i._tag,t[6]=a,t[7]=m):m=t[7];let h=m,[,_]=y(0),[,v]=bT(),b;if(t[8]!==c?.isGitRepo||t[9]!==h||t[10]!==s||t[11]!==i._tag||t[12]!==_?(b=(e,t)=>{if(t.ctrl&&e===`l`){UG(),_(JG);return}t.escape&&i._tag!==`Main`&&h(),t.ctrl&&e===`p`&&i._tag===`Main`&&c?.isGitRepo&&s(uz.SelectPr()),t.ctrl&&e===`r`&&i._tag===`Main`&&s(uz.SavedFlowPicker())},t[8]=c?.isGitRepo,t[9]=h,t[10]=s,t[11]=i._tag,t[12]=_,t[13]=b):b=t[13],o(b),l||!c){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=x(n,{flexDirection:`column`,paddingX:2,paddingY:1,children:x(sz,{message:`Checking git state...`})}),t[14]=e):e=t[14],e}let C;t[15]!==c||t[16]!==i._tag||t[17]!==i.changesFor||t[18]!==i.instruction||t[19]!==i.report||t[20]!==i.savedFlow?(C=()=>{switch(i._tag){case`Testing`:return x(ZW,{changesFor:i.changesFor,instruction:i.instruction,savedFlow:i.savedFlow});case`Results`:return x(cG,{report:i.report});case`SelectPr`:return x(mz,{});case`CookieSyncConfirm`:return x(_z,{changesFor:i.changesFor,instruction:i.instruction,savedFlow:i.savedFlow});case`SavedFlowPicker`:return x(vG,{});default:return x(kG,{gitState:c})}},t[15]=c,t[16]=i._tag,t[17]=i.changesFor,t[18]=i.instruction,t[19]=i.report,t[20]=i.savedFlow,t[21]=C):C=t[21];let w=C,T;t[22]===w?T=t[23]:(T=x(n,{flexGrow:1,children:w()}),t[22]=w,t[23]=T);let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=x(PG,{}),t[24]=E):E=t[24];let D;return t[25]!==v||t[26]!==T?(D=x(mT,{children:S(n,{flexDirection:`column`,width:`100%`,height:v,children:[T,E]})}),t[25]=v,t[26]=T,t[27]=D):D=t[27],D};function GG(e){return e.screen}function KG(e){return e.setScreen}function qG(e){return e.navigateTo}function JG(e){return e+1}const YG=()=>{let e=ae();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`},XG=()=>new Promise(e=>{ee(YG(),()=>e())}),ZG=e=>bm(KW(gp(function*(){let t=yield*PR,n=yield*FR,r=yield*JU,i=Date.now();yield*r.capture(`session:started`,{mode:`headless`,skip_planning:!1}),console.log(`expect v${lT}`),console.log(`Testing ${QT(e.changesFor)}`),console.log(`Starting browser test...`);let a=Date.now(),o=new Set,s=yield*t.execute({changesFor:e.changesFor,instruction:e.instruction,isHeadless:!0,requiresCookies:!1}).pipe(iC(e=>W(()=>{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(`${C.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${C.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${C.cross} ${t.stepId} ${t.message}`);break}})),yC,q(t=>t._tag===`Some`?t.value:new OE({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!0,requiresCookies:!1,title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),c=yield*n.report(s),l=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`passed`).length,u=c.steps.filter(e=>c.stepStatuses.get(e.id)?.status===`failed`).length;yield*r.capture(`run:completed`,{plan_id:s.id??`direct`,passed:l,failed:u,step_count:s.steps.length,file_count:0,duration_ms:Date.now()-a}),yield*r.capture(`session:ended`,{session_ms:Date.now()-i}),yield*r.flush,console.error(`\n${c.toPlainText}`),yield*lp(()=>XG()),process.exit(c.status===`passed`?0:1)}).pipe(Kp(UW({verbose:e.verbose,agent:e.agent}))))),QG={error:w.red,warn:w.yellow,info:w.cyan,success:w.green,dim:w.dim},$G={error(...e){console.log(QG.error(e.join(` `)))},warn(...e){console.log(QG.warn(e.join(` `)))},info(...e){console.log(QG.info(e.join(` `)))},success(...e){console.log(QG.success(e.join(` `)))},dim(...e){console.log(QG.dim(e.join(` `)))},log(...e){console.log(e.join(` `))},break(){console.log(``)}},eK=()=>{$G.break(),$G.log(`Cancelled.`),$G.break(),process.exit(0)},tK=e=>Fe(e,{onCancel:eK}),nK=(e,t)=>Ie({text:e,isSilent:t?.silent}),rK=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],iK=()=>rK.some(e=>!!process.env[e]),aK=()=>!process.stdin.isTTY,oK=`npm install -g expect-cli@latest`,sK=`npx skills add https://github.com/millionco/expect --skill expect-cli`,cK=e=>e||iK()||aK(),lK=e=>{try{return te(e,{stdio:`pipe`}),!0}catch{return!1}},uK=async(e={})=>{let t=cK(e.yes??!1);$G.break(),$G.log(` ${QG.info(`expect-cli`)} ${QG.dim(`— AI-powered browser testing`)}`),$G.break();let n=nK(`Installing expect-cli globally...`).start();lK(oK)?n.succeed(`Installed! You can now run ${QG.info(`expect-cli`)} from anywhere.`):(n.fail(`Failed to install globally.`),$G.dim(` Run manually: ${QG.info(oK)}`)),$G.break();let r=t;if(t||(r=(await tK({type:`confirm`,name:`installSkill`,message:`Install the ${QG.info(`expect-cli`)} skill for your coding agent?`,initial:!0})).installSkill),r){let e=nK(`Installing skill...`).start();lK(sK)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),$G.dim(` Run manually: ${QG.info(sK)}`))}$G.break(),$G.success(`You're all set!`),$G.log(` Run ${QG.info(`expect-cli`)} in any project to start testing.`),$G.break()},dK=ww(JU.layerPostHog),fK=()=>dK.runPromise(gp(function*(){yield*(yield*JU).capture(`session:started`,{mode:`interactive`,skip_planning:!1})})),pK=e=>dK.runPromise(gp(function*(){let t=yield*JU;yield*t.capture(`session:ended`,{session_ms:Date.now()-e}),yield*t.flush})),mK=[`unstaged`,`branch`,`changes`],hK=new t().name(`expect`).description(`AI-powered browser testing for your changes`).version(lT,`-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`).addHelpText(`after`,`
38
+ `))}catch(e){return je(new tE({kind:`Pack`,cause:e}))}}))),rE=e=>zn(Lr().pipe(e?.ignoreEmptyLines===!0?Yt(e=>e.length>0):Bt),e=>{try{return V(yi(e,e=>JSON.parse(e)))}catch(e){return je(new tE({kind:`Unpack`,cause:e}))}}),iE=fe(e=>lt(e[0]),(e,t)=>hi(hi(nE(),e),rE(t))),aE=fe(2,(e,t)=>_o(iE(e,t),t)),oE=ht([Ke({_tag:De(`Started`),startTime:fn}),Ke({_tag:De(`Ended`),startTime:fn,endTime:fn})]),sE=Ke({_tag:De(`ExternalSpan`),spanId:B,traceId:B,sampled:Oi}),cE=Ke({_tag:De(`Span`),spanId:B,traceId:B,name:B,sampled:Oi,attributes:p(B,ar),status:oE,parent:Qe(ei(()=>uE))}),lE=Ke({_tag:De(`SpanEvent`),traceId:B,spanId:B,name:B,startTime:fn,attributes:Ie(gr(B,ar))}),uE=ht([cE,sE]),dE=Ke({_tag:De(`Ping`)}),fE=Ke({_tag:De(`Pong`)}),pE=Ke({_tag:De(`MetricsRequest`)}),mE=(e,t)=>Ke({id:B,type:De(e),description:Ie(B),attributes:Ie(gr(B,B)),state:t}),hE=ht([dE,cE,lE,Ke({_tag:De(`MetricsSnapshot`),metrics:$n(ht([mE(`Counter`,Ke({count:ht([O,fn]),incremental:Oi})),mE(`Frequency`,Ke({occurrences:p(B,O)})),mE(`Gauge`,Ke({value:ht([O,fn])})),mE(`Histogram`,Ke({buckets:$n(Se([O,O])),count:O,min:O,max:O,sum:O})),mE(`Summary`,Ke({quantiles:$n(Se([O,Ie(O)])),count:O,min:O,max:O,sum:O}))]))})]),gE=ht([fE,pE]),_E=en(hE),vE=en(gE);var yE=class extends Zr()(`effect/devtools/DevToolsClient`){};const bE=H(function*(){let e=yield*pn,t=yield*hr(),n=yield*Pn(),r=yield*Ii(),i=F(()=>{xi(n,xE(t))});return yield*m(n).pipe(Xt(aE(Tn(e),{inputSchema:_E,outputSchema:vE})),Xr(()=>ln(r,R)),tn(e=>{switch(e._tag){case`MetricsRequest`:return i;case`Pong`:return R}}),gi),yield*d(()=>i.pipe(Be(Qt(Te,e=>Hr(n,Ji(e)))))),yield*rt(()=>Er(n,{_tag:`Ping`})).pipe(jt(`3 seconds`),a,gi),yield*Xn(r).pipe(v(`1 second`),Pe),yE.of({sendUnsafe(e){xi(n,e)}})}),xE=e=>({_tag:`MetricsSnapshot`,metrics:$t(e)}),SE=sr(yE,bE.pipe(nt({module:`DevTools`,service:`Client`}))),CE=sr(At,H(function*(){let e=yield*yE,t=yield*he;return Vt({span(n){let r=t.span(n);e.sendUnsafe(r);let i=r.event;r.event=function(t,n,a){return e.sendUnsafe({_tag:`SpanEvent`,traceId:r.traceId,spanId:r.spanId,name:t,startTime:n,attributes:a}),i.call(this,t,n,a)};let a=r.end;return r.end=function(t,n){a.call(this,t,n),e.sendUnsafe(r)},r},context:t.context})}).pipe(nt({module:`DevTools`,service:`Tracer`}))).pipe(Dn(SE)),wE=(e=`ws://localhost:34437`)=>CE.pipe(Dn(zr(e))),TE=(e=`ws://localhost:34437`)=>wE(e).pipe(Dn(oi)),EE=({verbose:e,agent:t})=>{let n=ab.withRepoRoot(process.cwd());return ci(sb.layer.pipe(Dn(n)),cb.layer,$y.layer,vb.layer,TE(),n,GC.layerPostHog).pipe(Dn(rf.layerFor(t??`claude`)),Dn(Zb),Tr(bi(pe,e?`All`:`Error`)))},DE=cT(Ct()),OE=gT(rn(function*(e){return EE({verbose:!0,agent:yield*e.some(DE)})},Nn)).pipe(ET),kE=e=>e,AE=(e,t,n,r)=>{let i=new URL(e.url??`/`,r),a=Ua({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()},jE=qt(`startReplayProxy`)(function*(e){let t=new lo,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=new URL(e.replayHost);t.all(`/*`,async t=>{let n=t.req.path;if(n===`/latest.json`||n===`/steps`)return t.text(`Not Found`,404);let r=new URL(n,e.replayHost);r.search=new URL(t.req.url).search;try{return await uo(r.toString(),{headers:{"User-Agent":t.req.header(`user-agent`)??``,Accept:t.req.header(`accept`)??`*/*`,Host:o.host}})}catch(e){return console.error(`[replay-proxy] Failed to proxy ${n} to ${r}:`,e),t.text(`Bad Gateway: could not reach ${o.host}`,502)}}),t.onError((e,t)=>(console.error(`[replay-proxy] Unhandled error:`,e),t.text(`Internal Server Error`,500)));let s=yield*Ut({try:()=>fo({fetch:t.fetch,port:0}),catch:e=>Error(`Failed to start replay proxy: ${e}`)});s.on(`upgrade`,(t,n,r)=>{AE(t,n,r,e.replayHost)});let c=s.address(),l=`http://localhost:${typeof c==`object`&&c?c.port:0}`;return yield*kn(`Replay proxy started`,{proxyUrl:l,liveViewUrl:e.liveViewUrl}),{url:l,close:pt(e=>{s.close(()=>e(R))})}}),ME=e=>_t(e)?Number(Xe(e.value)):void 0,NE=e=>e.length===0||!e.every(e=>e.status===`passed`||e.status===`failed`)?`running`:e.some(e=>e.status===`failed`)?`failed`:`passed`,PE=e=>{let t=e.events.find(e=>e._tag===`RunFinished`),n=t&&t._tag===`RunFinished`?t.status:NE(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:_t(e.summary)?e.summary.value:void 0,startedAtMs:ME(e.startedAt),endedAtMs:ME(e.endedAt)}));return{title:e.title,status:n,summary:r,steps:i}},FE=qt(`pushStepState`)(function*(e,t){yield*Mt(()=>fetch(`${e}/steps`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).pipe(Yi(()=>R))}),IE=`rrweb report:`,LE=`Playwright video:`,RE=()=>5e4+Math.floor(Math.random()*1e4),zE=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(IE))?.replace(IE,``),i=n.find(e=>e.startsWith(LE))?.replace(LE,``);return{localReplayUrl:r&&r.trim().length>0?Ca(r.trim()).href:void 0,videoUrl:i&&i.trim().length>0?Ca(i.trim()).href:void 0}},BE=cT([]),VE=rn(function*(e,t){let n=yield*cb,i=yield*sb,a=yield*GC,o=yield*ab,s=Date.now(),c=`http://localhost:${RE()}`,l;e.replayHost&&(l=`${(yield*jE({replayHost:e.replayHost,liveViewUrl:c})).url}/replay?live=true`,yield*kn(`Replay viewer available`,{replayUrl:l}),yield*F(()=>e.onReplayUrl?.(l)));let u={...e.options,liveViewUrl:c};yield*a.capture(`run:started`,{plan_id:`direct`});let d=yield*i.execute(u).pipe(_i(t=>H(function*(){e.onUpdate(t),yield*FE(c,PE(t))})),r,U(t=>t._tag===`Some`?t.value:new _c({...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,title:e.options.instruction,rationale:`Direct execution`,steps:[],events:[]}))),f=zE(d.events);if(l){let e=l.split(`/replay`)[0];yield*Mt(()=>fetch(`${c}/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(Yi(()=>R)),yield*FE(e,PE(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*a.capture(`run:completed`,{plan_id:d.id??`direct`,passed:m,failed:h,step_count:d.steps.length,file_count:0,duration_ms:Date.now()-s}),p.status===`passed`&&(yield*o.saveTestedFingerprint()),{executedPlan:d,report:p,replayUrl:l??f.localReplayUrl,localReplayUrl:f.localReplayUrl,videoUrl:f.videoUrl}},nt({fn:`executeFn`})),HE=OE.fn()((e,t)=>kE(VE(e,t)).pipe(mt(e=>H(function*(){let t=yield*GC,n=e instanceof Error?e.constructor.name:`UnknownError`;yield*t.capture(`run:failed`,{plan_id:`direct`,error_tag:n})}).pipe(Yi(()=>R))),dn(Ra.layer))),UE=e=>{if(typeof e==`string`)try{let t=JSON.parse(e);if(dt(t))return t}catch{return{}}return dt(e)?e:{}},WE=e=>e.replace(/\s+/g,` `).trim(),GE=e=>{let t=e.match(/^mcp__.+__(.+)$/);return t?t[1]:e},KE=(e,t)=>{let n=GE(e),r=typeof t==`string`?t:JSON.stringify(t??{}),i=UE(t),a=yn(n).pipe(Pi(`open`,()=>i.url?`"${i.url}"`:``),Pi(`screenshot`,()=>{let e=i.mode??`screenshot`;return e===`screenshot`?``:e}),Pi(`playwright`,()=>Ka(WE(i.code??r),100)),Pi(`console_logs`,()=>i.type?`type: "${i.type}"`:``),Pi(`network_requests`,()=>{let e=[];return i.method&&e.push(i.method),i.url&&e.push(`"${i.url}"`),e.join(`, `)}),Pi(`performance_metrics`,()=>``),Pi(`close`,()=>``),Ci(()=>qE(i))),o=(i.code??r).trim();return{name:n,args:a,multilineArgs:n===`playwright`&&o.includes(`
41
+ `)?o:void 0}},qE=e=>{let t=Object.values(e).filter(e=>typeof e==`string`&&e.length>0);return t.length===0?``:Ka(WE(t.join(`, `)),100)},JE=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`,YE=(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:KE(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},XE=(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},ZE=(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=XE(YE(e,n+1),e);return t?r:r.slice(-5)},QE=(e,t=!1)=>{let n=XE(YE(e,0),e);return t?n:n.slice(-5)},$E=(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]},eD=(e,t)=>{let[n,r]=$E(e,t);return YE(e,n,r)},tD=e=>{let t=ca(15);if(t[0]!==`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`){for(let e=0;e<15;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`}let{display:n,indent:r}=e,i=ds(),a;t[1]!==i.TEXT||t[2]!==n.tool.name?(a=q(G,{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&&J(G,{children:[` `,q(Ga,{type:`line`})]}),t[4]=n.isRunning,t[5]=o);let s;t[6]===n.resultTokens?s=t[7]:(s=n.resultTokens!==void 0&&` ${Y.arrowDown} ${JE(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=J(G,{color:i.DIM,wrap:`truncate`,children:[r,Y.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},nD=e=>{if(!Fi(e.startedAt))return(_t(e.endedAt)?Xe(e.endedAt.value):Date.now())-Xe(e.startedAt.value)},rD=(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(J(G,{color:r.DIM,wrap:`truncate`,children:[t,Y.lineVertical,` `,q(G,{color:r.TEXT,children:o.tool.name}),`(`,o.isRunning&&J(G,{children:[` `,q(Ga,{type:`line`})]}),o.resultTokens!==void 0&&` ${Y.arrowDown} ${JE(o.resultTokens)} tokens`]},`${s}-h`));for(let n=0;n<e.length;n++)i.push(J(G,{color:r.DIM,children:[t,Y.lineVertical,` `,` `,q(G,{color:r.TEXT,children:e[n]})]},`${s}-${n}`));i.push(J(G,{color:r.DIM,children:[t,Y.lineVertical,` )`]},`${s}-c`))}else i.push(J(G,{color:r.DIM,wrap:`truncate`,children:[t,Y.lineVertical,` `,q(G,{color:r.TEXT,children:o.tool.name}),`(`,o.tool.args,`)`,o.isRunning&&J(G,{children:[` `,q(Ga,{type:`line`})]}),o.resultTokens!==void 0&&` ${Y.arrowDown} ${JE(o.resultTokens)} tokens`]},s))}return i},iD=t=>{let n=ca(110);if(n[0]!==`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`){for(let e=0;e<110;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`27a6e4564d444ede431a56553e82d15c31bed9991bc9b26bce11b132e6169fbb`}let{changesFor:r,instruction:i,savedFlow:a,requiresCookies:o,baseUrls:s}=t,c=o===void 0?!1:o,l=Wb(aD),u=ds(),[,d]=cs(),f=qC(oD),p=qC(sD),m=qC(cD),h=qC(lD),g;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(g={mode:`promiseExit`},n[1]=g):g=n[1];let[_,v]=no(HE,g),y=io(BE),[b,x]=K(void 0),ee;n[2]===_?ee=n[3]:(ee=Tw(_),n[2]=_,n[3]=ee);let S=ee,C;n[4]===_?C=n[5]:(C=Aw(_),n[4]=_,n[5]=C);let w=C,te=w?_.value.report:void 0,[T,E]=K(void 0),[D,ne]=K(void 0),[O,k]=K(0),[A,re]=K(!1),j=FT(uD),ie=FT(dD),M=FT(fD),ae;n[6]===O?ae=n[7]:(ae=IT(O),n[6]=O,n[7]=ae);let N=ae,oe=T?.steps?T.steps.length:0,P;if(n[8]!==u||n[9]!==N||n[10]!==T||n[11]!==j||n[12]!==S){if(P=[],j&&T){let e=T.steps??[];if(e.length===0&&S){let e=QE(T.events,!0);P.push(...rD(e,` `,`planning`,u))}for(let t=0;t<e.length;t++){let n=e[t],r=_t(n.summary)?n.summary.value:n.title,i=nD(n),a=i===void 0?void 0:IT(i),o=`${t+1}.`;if(n.status===`active`){P.push(J(W,{children:[J(G,{color:u.DIM,children:[` `,o,` `]}),q(Lb,{}),q(G,{children:` `}),q(PT,{text:`${n.title} ${N}`,baseColor:ls.shimmerBase,highlightColor:ls.shimmerHighlight})]},`step-${t}`));let e=ZE(T.events,!0);P.push(...rD(e,` `,`s${t}`,u))}else if(n.status===`passed`){P.push(J(G,{children:[J(G,{color:u.DIM,children:[` `,o]}),J(G,{color:u.GREEN,children:[` `,Y.tick,` `,Ka(r,100)]}),a&&J(G,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=eD(T.events,t);P.push(...rD(e,` `,`s${t}`,u))}else if(n.status===`failed`){P.push(J(G,{children:[J(G,{color:u.DIM,children:[` `,o]}),J(G,{color:u.RED,children:[` `,Y.cross,` `,Ka(r,100)]}),a&&J(G,{color:u.DIM,children:[` `,a]})]},`step-${t}`));let e=eD(T.events,t);P.push(...rD(e,` `,`s${t}`,u))}else P.push(J(G,{color:u.DIM,children:[` `,o,` `,Y.circle,` `,n.title]},`step-${t}`))}}n[8]=u,n[9]=N,n[10]=T,n[11]=j,n[12]=S,n[13]=P}else P=n[13];let F=Math.max(1,d-6),se;n[14]!==P.length||n[15]!==F?(se={itemCount:P.length,visibleCount:F},n[14]=P.length,n[15]=F,n[16]=se):se=n[16];let ce=zb(se),le=ma(!1),I,L;n[17]!==j||n[18]!==P.length||n[19]!==ce?(I=()=>{j&&!le.current&&P.length>0&&ce.setHighlightedIndex(P.length-1),le.current=j},L=[j,P.length,ce],n[17]=j,n[18]=P.length,n[19]=ce,n[20]=I,n[21]=L):(I=n[20],L=n[21]),fa(I,L);let ue,de;n[22]!==f||n[23]!==s||n[24]!==p||n[25]!==r||n[26]!==i||n[27]!==m||n[28]!==c||n[29]!==a||n[30]!==v?(de=()=>{ne(Date.now());let e=s&&s.length>0?s.join(`, `):void 0,t=s?s.map(pD).join(` `):void 0;return v({options:{changesFor:r,instruction:t?`${i} ${t}`:i,isHeadless:!p,requiresCookies:c,savedFlow:a,baseUrl:e},agentBackend:f,replayHost:m,onUpdate:E,onReplayUrl:x}),()=>{v(ST)}},ue=[v,f,p,r,i,a,c,s,m],n[22]=f,n[23]=s,n[24]=p,n[25]=r,n[26]=i,n[27]=m,n[28]=c,n[29]=a,n[30]=v,n[31]=ue,n[32]=de):(ue=n[31],de=n[32]),fa(de,ue);let fe=w?_.value.replayUrl:void 0,pe=w?_.value.localReplayUrl:void 0,me=w?_.value.videoUrl:void 0,he,ge;n[33]!==T||n[34]!==w||n[35]!==pe||n[36]!==fe||n[37]!==te||n[38]!==l||n[39]!==me?(he=()=>{w&&T&&te&&(FT.getState().setExecutedPlan(T),l(Hb.Results({report:te,replayUrl:fe,localReplayUrl:pe,videoUrl:me})))},ge=[w,T,te,fe,pe,me,l],n[33]=T,n[34]=w,n[35]=pe,n[36]=fe,n[37]=te,n[38]=l,n[39]=me,n[40]=he,n[41]=ge):(he=n[40],ge=n[41]),fa(he,ge);let _e;n[42]===l?_e=n[43]:(_e=()=>{FT.getState().setExecutedPlan(void 0),l(Hb.Main())},n[42]=l,n[43]=_e);let ve=_e,ye,be;n[44]!==S||n[45]!==D?(ye=()=>{if(D===void 0||!S)return;let e=setInterval(()=>{k(Date.now()-D)},1e3);return()=>clearInterval(e)},be=[D,S],n[44]=S,n[45]=D,n[46]=ye,n[47]=be):(ye=n[46],be=n[47]),fa(ye,be);let xe;n[48]!==T||n[49]!==_||n[50]!==j||n[51]!==ce||n[52]!==ve||n[53]!==S||n[54]!==b||n[55]!==pe||n[56]!==fe||n[57]!==te||n[58]!==ie||n[59]!==l||n[60]!==A||n[61]!==M||n[62]!==h||n[63]!==me?(xe=(t,n)=>{let r=t.toLowerCase();if(A){if(n.return||r===`y`){re(!1),YC(`run:cancelled`),ve();return}(n.escape||r===`n`)&&re(!1);return}if(r===`o`&&!n.ctrl&&!n.meta&&b){let{exec:t}=e(`node:child_process`);t(`open "${b.replace(/"/g,`\\"`)}"`),YC(`live_preview:opened`);return}if(n.ctrl&&t===`o`){M();return}if(n.ctrl&&t===`n`){h();return}if(j){if(ce.handleNavigation(t,n))return;if(n.escape){ie(!1);return}return}if(n.escape){if(Mw(_)){ve();return}if(S){re(!0);return}if(T&&te){FT.getState().setExecutedPlan(T),l(Hb.Results({report:te,replayUrl:fe,localReplayUrl:pe,videoUrl:me}));return}ve()}},n[48]=T,n[49]=_,n[50]=j,n[51]=ce,n[52]=ve,n[53]=S,n[54]=b,n[55]=pe,n[56]=fe,n[57]=te,n[58]=ie,n[59]=l,n[60]=A,n[61]=M,n[62]=h,n[63]=me,n[64]=xe):xe=n[64],na(xe);let Se;n[65]!==P||n[66]!==ce.scrollOffset||n[67]!==F?(Se=P.slice(ce.scrollOffset,ce.scrollOffset+F),n[65]=P,n[66]=ce.scrollOffset,n[67]=F,n[68]=Se):Se=n[68];let Ce=Se,we;n[69]===y?we=n[70]:(we=q(ea,{items:[...y],children:mD}),n[69]=y,n[70]=we);let Te;n[71]===Symbol.for(`react.memo_cache_sentinel`)?(Te=q(QC,{}),n[71]=Te):Te=n[71];let Ee;n[72]===u.DIM?Ee=n[73]:(Ee=q(G,{color:u.DIM,children:Y.pointerSmall}),n[72]=u.DIM,n[73]=Ee);let De;n[74]!==u.TEXT||n[75]!==i?(De=q(G,{color:u.TEXT,children:i}),n[74]=u.TEXT,n[75]=i,n[76]=De):De=n[76];let Oe;n[77]!==Ee||n[78]!==De?(Oe=J(W,{children:[Te,J(G,{wrap:`truncate`,children:[` `,Ee,` `,De]})]}),n[77]=Ee,n[78]=De,n[79]=Oe):Oe=n[79];let ke;n[80]!==u.DIM||n[81]!==u.PRIMARY||n[82]!==S||n[83]!==b?(ke=b&&S&&q(W,{marginTop:0,children:J(G,{color:u.DIM,children:[` `,`Press `,q(G,{color:u.PRIMARY,children:`o`}),` to open live preview`]})}),n[80]=u.DIM,n[81]=u.PRIMARY,n[82]=S,n[83]=b,n[84]=ke):ke=n[84];let Ae;n[85]!==u.DIM||n[86]!==u.GREEN||n[87]!==u.RED||n[88]!==N||n[89]!==T||n[90]!==j||n[91]!==S||n[92]!==oe||n[93]!==Ce?(Ae=j?q(W,{flexDirection:`column`,marginTop:1,children:Ce}):J(ha,{children:[oe===0&&S&&(()=>{let e=T?QE(T.events,!1):[];return J(W,{marginTop:1,flexDirection:`column`,children:[J(W,{children:[q(Lb,{}),q(G,{children:` `}),q(PT,{text:`Starting${Y.ellipsis} ${N}`,baseColor:ls.shimmerBase,highlightColor:ls.shimmerHighlight})]}),e.map(hD)]})})(),q(W,{flexDirection:`column`,marginTop:1,children:(T?.steps??[]).map((e,t)=>{let n=_t(e.summary)?e.summary.value:e.title,r=nD(e),i=r===void 0?void 0:IT(r),a=`${t+1}.`;if(e.status===`active`){let t=T?ZE(T.events,!1):[];return J(W,{flexDirection:`column`,children:[J(W,{children:[J(G,{color:u.DIM,children:[` `,a,` `]}),q(Lb,{}),q(G,{children:` `}),q(PT,{text:`${e.title} ${N}`,baseColor:ls.shimmerBase,highlightColor:ls.shimmerHighlight})]}),t.map(gD)]},e.id)}return e.status===`passed`?J(G,{children:[J(G,{color:u.DIM,children:[` `,a]}),J(G,{color:u.GREEN,children:[` `,Y.tick,` `,Ka(n,100)]}),i&&J(G,{color:u.DIM,children:[` `,i]})]},e.id):e.status===`failed`?J(G,{children:[J(G,{color:u.DIM,children:[` `,a]}),J(G,{color:u.RED,children:[` `,Y.cross,` `,Ka(n,100)]}),i&&J(G,{color:u.DIM,children:[` `,i]})]},e.id):J(G,{color:u.DIM,children:[` `,a,` `,Y.circle,` `,e.title]},e.id)})})]}),n[85]=u.DIM,n[86]=u.GREEN,n[87]=u.RED,n[88]=N,n[89]=T,n[90]=j,n[91]=S,n[92]=oe,n[93]=Ce,n[94]=Ae):Ae=n[94];let je;n[95]!==u.PRIMARY||n[96]!==u.YELLOW||n[97]!==A?(je=A&&q(W,{marginTop:1,children:J(G,{color:u.YELLOW,children:[`Stop run? `,q(G,{color:u.PRIMARY,children:`enter`}),` to stop,`,` `,q(G,{color:u.PRIMARY,children:`esc`}),` to dismiss`]})}),n[95]=u.PRIMARY,n[96]=u.YELLOW,n[97]=A,n[98]=je):je=n[98];let R;n[99]===_?R=n[100]:(R=Vw(_).onError(_D).orNull(),n[99]=_,n[100]=R);let z;n[101]!==Oe||n[102]!==ke||n[103]!==Ae||n[104]!==je||n[105]!==R?(z=J(W,{flexDirection:`column`,width:`100%`,paddingY:1,paddingX:1,children:[Oe,ke,Ae,je,R]}),n[101]=Oe,n[102]=ke,n[103]=Ae,n[104]=je,n[105]=R,n[106]=z):z=n[106];let Me;return n[107]!==we||n[108]!==z?(Me=J(ha,{children:[we,z]}),n[107]=we,n[108]=z,n[109]=Me):Me=n[109],Me};function aD(e){return e.setScreen}function oD(e){return e.agentBackend}function sD(e){return e.browserHeaded}function cD(e){return e.replayHost}function lD(e){return e.toggleNotifications}function uD(e){return e.expanded}function dD(e){return e.setExpanded}function fD(e){return e.toggleExpanded}function pD(e){return`[url: ${e}]`}function mD(e){return q(W,{paddingX:1,children:q(QT,{src:e,alt:e})},e)}function hD(e,t){return q(tD,{display:e,indent:` `},t)}function gD(e,t){return q(tD,{display:e,indent:` `},t)}function _D(e){return q($T,{message:e instanceof Error?e.message:String(e)})}const vD=e=>{try{return Ta.execSync(`pbcopy`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}},yD=(e,t)=>C(xb.use(n=>n.addComment(process.cwd(),e,t)).pipe(dn(xb.layer))),bD=()=>oa({mutationFn:({pullRequest:e,body:t})=>yD(e,t)}),xD=OE.fn(rn(function*(e,t){return yield*(yield*vb).save(e.plan)},nt({fn:`saveFlowFn`}),dn(Ra.layer))),SD=e=>{if(!(Fi(e.startedAt)||Fi(e.endedAt)))return Xe(e.endedAt.value)-Xe(e.startedAt.value)},CD=e=>{let t=0;for(let n of e){let e=SD(n);e!==void 0&&(t+=e)}return t},wD=e=>{let t=ca(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=ds(),s=Wb(TD),[c,l]=K(void 0),u=bD(),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d={mode:`promiseExit`},t[1]=d):d=t[1];let[f,p]=no(xD,d),m=f.waiting,h;t[2]===f?h=t[3]:(h=Aw(f),t[2]=f,t[3]=h);let g=h,_;t[4]!==u||t[5]!==n.pullRequest||t[6]!==n.toPlainText?(_=()=>{_t(n.pullRequest)&&(YC(`results:posted_to_pr`),u.mutate({pullRequest:n.pullRequest.value,body:n.toPlainText}))},t[4]=u,t[5]=n.pullRequest,t[6]=n.toPlainText,t[7]=_):_=t[7];let v=_,y;t[8]!==o.GREEN||t[9]!==o.RED||t[10]!==n.toPlainText?(y=()=>{vD(n.toPlainText)?(YC(`results:copied_to_clipboard`),l({text:`${Y.tick} Copied to clipboard`,color:o.GREEN})):l({text:`${Y.cross} Failed to copy to clipboard`,color:o.RED})},t[8]=o.GREEN,t[9]=o.RED,t[10]=n.toPlainText,t[11]=y):y=t[11];let b=y,x;t[12]!==n||t[13]!==m||t[14]!==g||t[15]!==p?(x=async()=>{m||g||(YC(`flow:saved`,{step_count:n.steps.length}),await p({plan:n}))},t[12]=n,t[13]=m,t[14]=g,t[15]=p,t[16]=x):x=t[16];let ee=x,S;t[17]!==n.changesFor||t[18]!==n.instruction||t[19]!==s?(S=()=>{YC(`results:restarted`),FT.getState().setExecutedPlan(void 0),s(Ub({changesFor:n.changesFor,instruction:n.instruction}))},t[17]=n.changesFor,t[18]=n.instruction,t[19]=s,t[20]=S):S=t[20];let C=S,w;t[21]!==b||t[22]!==v||t[23]!==C||t[24]!==ee?(w=e=>{let t=e.toLowerCase();t===`y`&&b(),t===`p`&&v(),t===`s`&&ee(),t===`r`&&C()},t[21]=b,t[22]=v,t[23]=C,t[24]=ee,t[25]=w):w=t[25],na(w);let te=n.status===`passed`,T=te?o.GREEN:o.RED,E=te?Y.tick:Y.cross,D=te?`Passed`:`Failed`,ne,O,k,A,re,j,ie,M,ae,N,oe;if(t[26]!==o.DIM||t[27]!==o.GREEN||t[28]!==o.RED||t[29]!==o.TEXT||t[30]!==i||t[31]!==r||t[32]!==n.instruction||t[33]!==n.stepStatuses||t[34]!==n.steps||t[35]!==T||t[36]!==E||t[37]!==D){let e=CD(n.steps);O=r??i,k=!!r&&!!i&&r!==i&&i!==void 0,ne=W,N=`column`,oe=`100%`,A=1,re=1;let a;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(a=q(QC,{}),t[49]=a):a=t[49];let s;t[50]===o.DIM?s=t[51]:(s=q(G,{color:o.DIM,children:Y.pointerSmall}),t[50]=o.DIM,t[51]=s);let c;t[52]!==o.TEXT||t[53]!==n.instruction?(c=q(G,{color:o.TEXT,children:n.instruction}),t[52]=o.TEXT,t[53]=n.instruction,t[54]=c):c=t[54],t[55]!==s||t[56]!==c?(j=J(W,{children:[a,J(G,{wrap:`truncate`,children:[` `,s,` `,c]})]}),t[55]=s,t[56]=c,t[57]=j):j=t[57];let l;t[58]!==T||t[59]!==E||t[60]!==D?(l=J(G,{color:T,bold:!0,children:[E,` `,D]}),t[58]=T,t[59]=E,t[60]=D,t[61]=l):l=t[61];let u=n.steps.length===1?``:`s`,d;t[62]!==o.DIM||t[63]!==n.steps.length||t[64]!==u?(d=J(G,{color:o.DIM,children:[` `,n.steps.length,` step`,u]}),t[62]=o.DIM,t[63]=n.steps.length,t[64]=u,t[65]=d):d=t[65],t[66]!==l||t[67]!==d?(ie=J(W,{marginTop:1,children:[l,d]}),t[66]=l,t[67]=d,t[68]=ie):ie=t[68];let f;if(t[69]!==o.DIM||t[70]!==o.GREEN||t[71]!==o.RED||t[72]!==n.stepStatuses||t[73]!==n.steps){let e;t[75]!==o.DIM||t[76]!==o.GREEN||t[77]!==o.RED||t[78]!==n.stepStatuses?(e=(e,t)=>{let r=SD(e),i=r===void 0?void 0:IT(r),a=n.stepStatuses.get(e.id),s=a?.status===`failed`,c=s?o.RED:o.GREEN,l=s?Y.cross:Y.tick,u=`${t+1}.`;return J(W,{flexDirection:`column`,children:[J(G,{children:[J(G,{color:o.DIM,children:[` `,u]}),J(G,{color:c,children:[` `,l,` `,e.title]}),i&&J(G,{color:o.DIM,children:[` `,i]})]}),s&&a.summary&&J(G,{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?M=t[81]:(M=q(W,{flexDirection:`column`,marginTop:1,children:f}),t[80]=f,t[81]=M),ae=e>0&&q(W,{marginTop:1,children:J(G,{color:o.DIM,children:[`Worked for `,IT(e)]})}),t[26]=o.DIM,t[27]=o.GREEN,t[28]=o.RED,t[29]=o.TEXT,t[30]=i,t[31]=r,t[32]=n.instruction,t[33]=n.stepStatuses,t[34]=n.steps,t[35]=T,t[36]=E,t[37]=D,t[38]=ne,t[39]=O,t[40]=k,t[41]=A,t[42]=re,t[43]=j,t[44]=ie,t[45]=M,t[46]=ae,t[47]=N,t[48]=oe}else ne=t[38],O=t[39],k=t[40],A=t[41],re=t[42],j=t[43],ie=t[44],M=t[45],ae=t[46],N=t[47],oe=t[48];let P;t[82]===c?P=t[83]:(P=c&&q(W,{marginTop:1,children:q(G,{color:c.color,children:c.text})}),t[82]=c,t[83]=P);let F;t[84]!==o.DIM||t[85]!==u.isPending?(F=u.isPending&&q(W,{marginTop:1,children:J(G,{color:o.DIM,children:[`Posting to PR`,Y.ellipsis]})}),t[84]=o.DIM,t[85]=u.isPending,t[86]=F):F=t[86];let se;t[87]!==o.GREEN||t[88]!==u.isSuccess?(se=u.isSuccess&&q(W,{marginTop:1,children:J(G,{color:o.GREEN,children:[Y.tick,` Posted to PR`]})}),t[87]=o.GREEN,t[88]=u.isSuccess,t[89]=se):se=t[89];let ce;t[90]!==o.RED||t[91]!==u.isError?(ce=u.isError&&q(W,{marginTop:1,children:J(G,{color:o.RED,children:[Y.cross,` Failed to post to PR`]})}),t[90]=o.RED,t[91]=u.isError,t[92]=ce):ce=t[92];let le;t[93]!==o.DIM||t[94]!==m?(le=m&&q(W,{marginTop:1,children:J(G,{color:o.DIM,children:[`Saving flow`,Y.ellipsis]})}),t[93]=o.DIM,t[94]=m,t[95]=le):le=t[95];let I;t[96]!==o.GREEN||t[97]!==g?(I=g&&q(W,{marginTop:1,children:J(G,{color:o.GREEN,children:[Y.tick,` Flow saved`]})}),t[96]=o.GREEN,t[97]=g,t[98]=I):I=t[98];let L;t[99]!==o.RED||t[100]!==f?(L=Mw(f)&&q(W,{marginTop:1,children:J(G,{color:o.RED,children:[Y.cross,` Failed to save flow`]})}),t[99]=o.RED,t[100]=f,t[101]=L):L=t[101];let ue;t[102]!==o.DIM||t[103]!==o.PRIMARY||t[104]!==O?(ue=O&&q(W,{flexDirection:`column`,paddingX:1,marginTop:1,children:J(G,{color:o.DIM,children:[`Replay:`,` `,q(G,{color:o.PRIMARY,bold:!0,children:O})]})}),t[102]=o.DIM,t[103]=o.PRIMARY,t[104]=O,t[105]=ue):ue=t[105];let de;t[106]!==o.DIM||t[107]!==o.PRIMARY||t[108]!==i||t[109]!==k?(de=k&&q(W,{flexDirection:`column`,paddingX:1,children:J(G,{color:o.DIM,children:[`Local Replay:`,` `,q(G,{color:o.PRIMARY,bold:!0,children:i})]})}),t[106]=o.DIM,t[107]=o.PRIMARY,t[108]=i,t[109]=k,t[110]=de):de=t[110];let fe;t[111]!==o.DIM||t[112]!==o.PRIMARY||t[113]!==a?(fe=a&&q(W,{flexDirection:`column`,paddingX:1,children:J(G,{color:o.DIM,children:[`Video:`,` `,q(G,{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(ED),t[115]=n.screenshotPaths,t[116]=pe);let me;return t[117]!==ne||t[118]!==A||t[119]!==re||t[120]!==j||t[121]!==ie||t[122]!==M||t[123]!==ae||t[124]!==P||t[125]!==F||t[126]!==se||t[127]!==ce||t[128]!==le||t[129]!==I||t[130]!==L||t[131]!==ue||t[132]!==de||t[133]!==fe||t[134]!==pe||t[135]!==N||t[136]!==oe?(me=J(ne,{flexDirection:N,width:oe,paddingY:A,paddingX:re,children:[j,ie,M,ae,P,F,se,ce,le,I,L,ue,de,fe,pe]}),t[117]=ne,t[118]=A,t[119]=re,t[120]=j,t[121]=ie,t[122]=M,t[123]=ae,t[124]=P,t[125]=F,t[126]=se,t[127]=ce,t[128]=le,t[129]=I,t[130]=L,t[131]=ue,t[132]=de,t[133]=fe,t[134]=pe,t[135]=N,t[136]=oe,t[137]=me):me=t[137],me};function TD(e){return e.setScreen}function ED(e){return q(W,{marginTop:1,children:q(QT,{src:e,alt:`Screenshot: ${e}`})},e)}const DD=ci(vb.layer,ab.withRepoRoot(process.cwd())),OD=()=>sa({queryKey:[`saved-flows`],queryFn:()=>H(function*(){return yield*(yield*vb).list()}).pipe(dn(DD),dn(Ra.layer),_(`FindRepoRootError`,()=>V([])),C)}),kD=new Is({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}),AD=()=>sa({queryKey:[`git-state`],queryFn:async()=>{let e=await Mi(H(function*(){return yield*(yield*ab).getState()}).pipe(dn(ab.withRepoRoot(process.cwd())),_(`FindRepoRootError`,()=>V(kD)),Rt({duration:1e4,onTimeout:()=>V(kD)}),dn(Ra.layer)));return E(e)?e.value:kD}}),jD=e=>Array.isArray(e.flow?.steps)?e.flow.steps:[],MD=(e,t)=>{let n=zs.makeUnsafe({_tag:`Changes`,mainBranch:t}),r=jD(e),i={title:e.flow.title,userInstruction:e.flow.userInstruction,steps:r},a=e.environment.cookies;YC(`flow:reused`,{slug:e.slug,step_count:r.length}),Wb.getState().setScreen(Ub({changesFor:n,instruction:e.flow.userInstruction,savedFlow:i,requiresCookies:a}))},ND=()=>{let e=ca(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=ds(),[n]=cs(),r=Wb(PD),{data:i}=AD(),{data:a,isLoading:o}=OD(),s=a===void 0?[]:a,{highlightedIndex:c,setHighlightedIndex:l,scrollOffset:u,handleNavigation:d}=zb({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);na((e,t)=>{if(!d(e,t)){if(t.return){let e=s[c];e&&MD(e,i?.mainBranch??`main`)}t.escape&&r(Hb.Main())}});let h=W,g=`${s.length} flow${s.length===1?``:`s`}`,_;e[1]===g?_=e[2]:(_=q(W,{paddingX:1,children:q(Kb,{title:`Saved flows`,subtitle:g})}),e[1]=g,e[2]=_);let v;e[3]===o?v=e[4]:(v=o&&q(W,{marginTop:1,paddingX:1,children:q(Lb,{message:`Loading saved flows...`})}),e[3]=o,e[4]=v);let y=!o&&s.length===0&&q(W,{marginTop:1,paddingX:1,flexDirection:`column`,children:J(G,{color:t.DIM,children:[`No saved flows yet. Run a test and press `,q(G,{color:t.PRIMARY,children:`s`}),` on the results screen to save a flow.`]})}),b=!o&&s.length>0&&q(W,{marginTop:1,flexDirection:`column`,height:15,overflow:`hidden`,paddingX:1,children:m.map((e,n)=>{let r=n+u,a=r===c,o=jD(e).length;return J(ms,{onClick:()=>{l(r),MD(e,i?.mainBranch??`main`)},children:[q(G,{color:a?t.PRIMARY:t.DIM,children:a?`${Y.pointer} `:` `}),q(G,{color:a?t.PRIMARY:t.TEXT,bold:a,children:Rb(Ka(e.title,f-1),f)}),q(G,{color:t.DIM,children:Rb(`${o} step${o===1?``:`s`}`,10)}),q(G,{color:t.DIM,children:Ka(e.description,p)})]},e.slug)})}),x;return e[5]!==h||e[6]!==_||e[7]!==v||e[8]!==y||e[9]!==b?(x=J(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 PD(e){return e.setScreen}const FD=e=>{let t=ca(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=ds();if(n===`open`){let e;return t[1]===r.GREEN?e=t[2]:(e=J(G,{color:r.GREEN,children:[Y.bullet,` `]}),t[1]=r.GREEN,t[2]=e),e}if(n===`merged`){let e;return t[3]===r.PURPLE?e=t[4]:(e=J(G,{color:r.PURPLE,children:[Y.bullet,` `]}),t[3]=r.PURPLE,t[4]=e),e}if(n===`draft`){let e;return t[5]===r.DIM?e=t[6]:(e=J(G,{color:r.DIM,children:[Y.bullet,` `]}),t[5]=r.DIM,t[6]=e),e}return null},ID=e=>{let t=ca(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=ds(),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=q(W,{flexDirection:`column`,children:q(G,{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=Mb(e,a),s=Nb(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 J(G,{wrap:`truncate`,children:[q(G,{color:n?o.PRIMARY:o.DIM,children:n?`${Y.pointer} `:` `}),e._tag===`WorkingTree`?J(G,{color:o.GREEN,children:[Y.bullet,` `]}):null,u?q(FD,{status:u}):null,q(G,{color:n?o.PRIMARY:o.TEXT,bold:n,children:i}),l?J(G,{children:[` `,J(G,{color:u===`open`?o.GREEN:u===`merged`?o.PURPLE:o.DIM,children:[`#`,l]}),u?J(G,{color:o.DIM,children:[` `,u]}):null]}):null,s&&!l?J(G,{color:o.DIM,children:[` `,s]}):null]},fc(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?q(W,{children:J(G,{color:o.DIM,children:[` Loading PRs and branches`,Y.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?q(W,{children:J(G,{color:o.DIM,children:[` `,n.length-8,` more `,Y.arrowUp,`/`,Y.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=J(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},LD=({gitState:e,onSelect:t})=>{let[n,r]=K(!1),[i,a]=K(``),[o,s]=K(0),{data:c=[]}=sa({queryKey:[`local-context-options`,e?.currentBranch],queryFn:()=>kb(e),enabled:!!e}),{data:l=[],isLoading:u}=sa({queryKey:[`remote-context-options`,e?.currentBranch],queryFn:()=>jb(e),enabled:n&&!!e}),d=pa(()=>[...c,...l],[c,l]),f=pa(()=>Fb(d,i,e),[d,i,e]);fa(()=>{s(0)},[i]);let p=ua(()=>{r(!0),a(``),s(0)},[]),m=ua(()=>{r(!1),a(``)},[]);return{pickerOpen:n,pickerQuery:i,pickerIndex:o,filteredOptions:f,localOptions:c,remoteLoading:u,openPicker:p,closePicker:m,handleContextSelect:ua(e=>{t(e),m()},[t,m]),setPickerQuery:a,setPickerIndex:s,createInputChangeHandler:(e,t)=>r=>{let i=as(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)}}},RD=[`Test the main user flow end to end`,`Smoke test the homepage and key pages`,`Check authentication and protected routes`],zD=[`Verify my recent changes work as expected`,`Check for regressions in related features`,`Test the main user flow end to end`],BD=[`Test the changes on this branch`,`Smoke test this branch end to end`,`Check for regressions on this branch`],VD=[`Test the changes in this pull request`,`Check for regressions introduced by this PR`,`Verify the PR works end to end`],HD=[`Test the changes from this commit`,`Check if this commit introduces regressions`,`Verify this commit works as expected`],UD=(e,t)=>{if(!e)return RD;switch(e._tag){case`WorkingTree`:return zD;case`Branch`:return BD;case`PullRequest`:return VD;case`Commit`:return HD;default:return RD}},WD=({gitState:e})=>{let t=ds(),[n]=cs(),r=qC(e=>e.instructionHistory),i=Wb(e=>e.setScreen),[a,o]=K(void 0),[s,c]=K(``),[l,u]=K(0),[d,f]=K(0),[p,m]=K(!1),[h,g]=K(void 0),[_,v]=K(-1),[y,b]=K(``),x=iw(e=>e.cookiesEnabled),ee=iw(e=>e.toggleCookies),S=()=>{if(r.length===0)return;let e=_+1;e>=r.length||(_===-1&&b(s),v(e),c(r[e]),u(e=>e+1))},C=()=>{if(_<=-1)return;let e=_-1;v(e),c(e===-1?y:r[e]),u(e=>e+1)},w=LD({gitState:e??null,onSelect:e=>{o(e),YC(`context:selected`,{context_type:{WorkingTree:`working_tree`,Branch:`branch`,PullRequest:`pull_request`,Commit:`commit`}[e._tag]})}}),te=w.localOptions.find(e=>e._tag===`WorkingTree`)??void 0,T=a??te??null,E=UD(T,e??null);fa(()=>{f(0)},[T,e]);let D=t=>{let n=(t??s).trim();if(!n){g(`Describe what you want the browser agent to test.`);return}if(!e)return;let r=e.mainBranch??`main`,a;T?._tag===`Commit`?a=zs.makeUnsafe({_tag:`Commit`,hash:T.hash}):T?._tag===`Branch`||T?._tag===`PullRequest`?(T.branch.name&&(yb(process.cwd(),T.branch.name),Gb.invalidateQueries({queryKey:[`git-state`]})),a=zs.makeUnsafe({_tag:`Branch`,mainBranch:r})):a=zs.makeUnsafe({_tag:`Changes`,mainBranch:r}),qC.getState().rememberInstruction(n),x||Vb(n)?i(Ub({changesFor:a,instruction:n,requiresCookies:x})):i(Hb.CookieSyncConfirm({changesFor:a,instruction:n}))},ne=ma(s);ne.current=s;let O=w.createInputChangeHandler(ne,e=>{c(e),h&&g(void 0)}),k=!s.includes(`
43
+ `),A=s===``&&!w.pickerOpen&&E.length>0,re=A&&!p&&n>=80,j=E[d%E.length];return na((e,t)=>{if(w.pickerOpen){if(t.escape){w.closePicker();return}if(t.downArrow||t.ctrl&&e===`n`){w.setPickerIndex(Math.min(w.filteredOptions.length-1,w.pickerIndex+1));return}if(t.upArrow||t.ctrl&&e===`p`){w.setPickerIndex(Math.max(0,w.pickerIndex-1));return}if(t.return||t.tab){let e=w.filteredOptions[w.pickerIndex];e&&w.handleContextSelect(e);return}if(t.backspace||t.delete){w.pickerQuery.length===0?w.closePicker():w.setPickerQuery(w.pickerQuery.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&w.setPickerQuery(w.pickerQuery+e);return}if(k&&t.upArrow){S();return}if(k&&t.downArrow){C();return}if(t.ctrl&&e===`k`){ee(),YC(`cookies:toggled`,{enabled:!x});return}if(t.tab&&!t.shift&&A&&j){c(j),u(e=>e+1),YC(`suggestion:accepted`);return}if(!(t.tab&&t.shift)&&A){if(t.rightArrow){f(e=>(e+1)%E.length),m(!0);return}if(t.leftArrow){f(e=>(e-1+E.length)%E.length),m(!0);return}}},{isActive:!0}),J(W,{flexDirection:`column`,width:`100%`,paddingY:1,children:[q(W,{flexDirection:`column`,marginBottom:1,paddingX:1,children:q(QC,{})}),e?.hasUntestedChanges&&J(W,{paddingX:1,paddingY:1,marginBottom:1,backgroundColor:t.BANNER_BG,width:`100%`,flexDirection:`column`,gap:0,children:[(()=>{let n=e.workingTreeFileStats,r=n.reduce((e,t)=>e+t.added,0),i=n.reduce((e,t)=>e+t.removed,0);return J(W,{children:[J(G,{color:t.YELLOW,bold:!0,children:[Y.warning,` Untested changes detected`]}),n.length>0&&J(ha,{children:[J(G,{color:t.DIM,children:[` `,n.length,` file`,n.length===1?``:`s`,` `]}),r>0&&J(G,{color:t.GREEN,children:[`+`,r]}),r>0&&i>0&&q(G,{color:t.DIM,children:` `}),i>0&&J(G,{color:t.RED,children:[`-`,i]})]})]})})(),J(G,{color:t.DIM,children:[`Describe what to test and hit `,q(G,{color:t.YELLOW,children:`enter`}),` to verify your changes.`]})]}),J(W,{flexDirection:`column`,width:`100%`,children:[J(W,{paddingX:1,children:[!e&&q(Lb,{message:`loading context`}),e&&e.isGitRepo&&T&&q(ms,{fullWidth:!1,onClick:()=>{w.pickerOpen?w.closePicker():w.openPicker()},children:J(G,{color:t.DIM,children:[Y.bullet,` `,J(G,{color:t.PRIMARY,children:[`@`,Pb(T,e)]}),Nb(T,e)&&` (${Nb(T,e)})`]})})]}),q(ms,{children:q(W,{flexDirection:`column`,marginTop:1,backgroundColor:t.INPUT_BG,width:`100%`,paddingX:1,paddingY:1,children:J(W,{children:[q(G,{color:t.PRIMARY,children:`❯ `}),q(W,{flexGrow:1,children:q(bs,{focus:!w.pickerOpen,multiline:!0,placeholder:j?`${j} [tab]`:``,value:s,onSubmit:D,onUpArrowAtTop:k?void 0:S,onDownArrowAtBottom:k?void 0:C,onChange:O},l)}),re?q(G,{color:t.DIM,children:` ←→ cycle test suggestions`}):null]})})}),e?.isGitRepo&&w.pickerOpen&&J(fs,{color:t.BORDER,children:[J(W,{marginBottom:0,children:[q(G,{color:t.DIM,children:`@ `}),q(G,{color:t.PRIMARY,children:w.pickerQuery}),q(G,{color:t.DIM,children:w.pickerQuery?``:`type to filter`})]}),q(ID,{options:w.filteredOptions,selectedIndex:w.pickerIndex,isLoading:w.remoteLoading,gitState:e})]}),e?.isGitRepo&&!w.pickerOpen&&q(W,{marginTop:1,paddingX:1,children:J(G,{color:t.DIM,children:[q(G,{color:t.PRIMARY,children:`@`}),` add context`]})})]}),q($T,{message:h})]})},GD=e=>{let t=ca(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=J(G,{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=J(G,{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=J(ha,{children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},KD=e=>{let t=ca(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=q(G,{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)=>J(W,{children:[e.onClick?q(ms,{fullWidth:!1,onClick:e.onClick,children:q(GD,{segment:e,mutedColor:i})}):q(GD,{segment:e,mutedColor:i}),t<n.length-1&&q(G,{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=J(W,{children:[a,o]}),t[9]=a,t[10]=o,t[11]=s):s=t[11],s},qD=(e,t)=>{let n=ca(87);if(n[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let e=0;e<87;e+=1)n[e]=Symbol.for(`react.memo_cache_sentinel`);n[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let r=ds(),i=Wb(XD),a=iw(ZD),o=iw(QD),s=qC($D),c=qC(eO),l=FT(tO);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(Hb.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(Hb.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(Hb.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(Hb.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(Hb.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(Ub({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(Ub({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(Hb.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],_t(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:()=>{FT.getState().setExecutedPlan(void 0),i(Ub({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:()=>{FT.getState().setExecutedPlan(void 0),i(Hb.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}}},JD=e=>e.length>0?` ${e.map(e=>`${e.label} [${e.key}]`).join(` `)}`:``,YD=()=>{let e=ca(35);if(e[0]!==`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`){for(let t=0;t<35;t+=1)e[t]=Symbol.for(`react.memo_cache_sentinel`);e[0]=`b550868c87cf6b1dfe1682300fe0d38844022dce570a0a2326bec2f32013cc8b`}let[t]=cs(),{data:n}=AD(),r=Wb(nO),i=qD(r,n),a,o;e[1]===i?(a=e[2],o=e[3]):(a=i.filter(rO),o=qa(JD(a)),e[1]=i,e[2]=a,e[3]=o);let s=o,c=aO,l,u,d,f,p,m,h;if(e[4]!==i||e[5]!==t||e[6]!==s||e[7]!==r._tag){let n=i.filter(oO),a=c(n)+s+2>t?n.filter(sO):n,o=c(a);d=Math.max(0,t-o-s-2),u=W,m=`column`,e[15]!==t||e[16]!==r._tag?(h=r._tag===`Testing`?q(PT,{text:`─`.repeat(t),baseColor:ls.shimmerBase,highlightColor:ls.shimmerHighlight,speed:3}):q(G,{color:ls.border,children:`─`.repeat(t)}),e[15]=t,e[16]=r._tag,e[17]=h):h=e[17],l=W,f=1,p=a.map(cO),e[4]=i,e[5]=t,e[6]=s,e[7]=r._tag,e[8]=l,e[9]=u,e[10]=d,e[11]=f,e[12]=p,e[13]=m,e[14]=h}else l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14];let g;e[18]===d?g=e[19]:(g=` `.repeat(d),e[18]=d,e[19]=g);let _;e[20]===g?_=e[21]:(_=q(G,{children:g}),e[20]=g,e[21]=_);let v;e[22]===a?v=e[23]:(v=a.length>0?q(KD,{segments:a,color:ls.primary,mutedColor:ls.textMuted}):null,e[22]=a,e[23]=v);let y;e[24]!==l||e[25]!==f||e[26]!==p||e[27]!==_||e[28]!==v?(y=J(l,{paddingX:f,children:[p,_,v]}),e[24]=l,e[25]=f,e[26]=p,e[27]=_,e[28]=v,e[29]=y):y=e[29];let b;return e[30]!==u||e[31]!==m||e[32]!==h||e[33]!==y?(b=J(u,{flexDirection:m,children:[h,y]}),e[30]=u,e[31]=m,e[32]=h,e[33]=y,e[34]=b):b=e[34],b};function XD(e){return e.setScreen}function ZD(e){return e.cookiesEnabled}function QD(e){return e.toggleCookies}function $D(e){return e.notifications}function eO(e){return e.toggleNotifications}function tO(e){return e.expanded}function nO(e){return e.screen}function rO(e){return!e.cta}function iO(e){return e.color?` ${e.label} [${e.key}] `:`${e.label} [${e.key}]`}function aO(e){return qa(e.map(iO).join(` `))}function oO(e){return e.cta}function sO(e){return e.key!==`ctrl+p`}function cO(e,t){let n=J(G,{children:[t>0?` `:``,e.color?J(G,{backgroundColor:e.color,color:`black`,children:[` `,q(G,{bold:!0,children:e.label}),` `,J(G,{children:[`[`,e.key,`]`]}),` `]}):J(G,{children:[J(G,{color:ls.textMuted,children:[e.label,` `]}),J(G,{color:ls.textMuted,children:[`[`,e.key,`]`]})]})]},e.key+e.label);return e.onClick?q(ms,{onClick:e.onClick,fullWidth:!1,children:n},e.key+e.label):n}let lO=null;const uO=e=>{lO=e},dO=()=>lO?.clear(),fO=e=>{let t=ca(32);if(t[0]!==`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`){for(let e=0;e<32;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`55ea97aad1f2a785565d81fb2926f5458ca90308c23ea4df7f06a9353bc781af`}let{agent:n}=e,r=Wb(pO),i=Wb(mO),a=Wb(hO),{data:o}=AD(),s=ro(DE),c,l;t[1]!==n||t[2]!==s?(c=()=>{s(A(n))},l=[n,s],t[1]=n,t[2]=s,t[3]=c,t[4]=l):(c=t[3],l=t[4]),fa(c,l);let u;t[5]!==r._tag||t[6]!==i?(u=()=>{if(r._tag===`CookieSyncConfirm`){i(Hb.Main());return}if(r._tag===`PortPicker`){i(Hb.Main());return}if(r._tag===`Results`){FT.getState().setExecutedPlan(void 0),i(Hb.Main());return}r._tag!==`Testing`&&i(Hb.Main())},t[5]=r._tag,t[6]=i,t[7]=u):u=t[7];let d=u,[,f]=K(0),[,p]=cs(),m;t[8]!==o?.isGitRepo||t[9]!==d||t[10]!==a||t[11]!==r._tag||t[12]!==f?(m=(e,t)=>{if(t.ctrl&&e===`l`){dO(),f(gO);return}t.escape&&r._tag!==`Main`&&d(),t.ctrl&&e===`p`&&r._tag===`Main`&&o?.isGitRepo&&a(Hb.SelectPr()),t.ctrl&&e===`r`&&r._tag===`Main`&&a(Hb.SavedFlowPicker())},t[8]=o?.isGitRepo,t[9]=d,t[10]=a,t[11]=r._tag,t[12]=f,t[13]=m):m=t[13],na(m);let h;t[14]!==o||t[15]!==r._tag||t[16]!==r.baseUrls||t[17]!==r.changesFor||t[18]!==r.instruction||t[19]!==r.localReplayUrl||t[20]!==r.replayUrl||t[21]!==r.report||t[22]!==r.requiresCookies||t[23]!==r.savedFlow||t[24]!==r.videoUrl?(h=()=>{if(!o)return q(WD,{gitState:void 0});switch(r._tag){case`PortPicker`:return q(gw,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies});case`Testing`:return q(iD,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow,requiresCookies:r.requiresCookies,baseUrls:r.baseUrls});case`Results`:return q(wD,{report:r.report,replayUrl:r.replayUrl,localReplayUrl:r.localReplayUrl,videoUrl:r.videoUrl});case`SelectPr`:return q(qb,{});case`CookieSyncConfirm`:return q(ew,{changesFor:r.changesFor,instruction:r.instruction,savedFlow:r.savedFlow});case`SavedFlowPicker`:return q(ND,{});default:return q(WD,{gitState:o})}},t[14]=o,t[15]=r._tag,t[16]=r.baseUrls,t[17]=r.changesFor,t[18]=r.instruction,t[19]=r.localReplayUrl,t[20]=r.replayUrl,t[21]=r.report,t[22]=r.requiresCookies,t[23]=r.savedFlow,t[24]=r.videoUrl,t[25]=h):h=t[25];let g=h,_;t[26]===g?_=t[27]:(_=q(W,{flexGrow:1,children:g()}),t[26]=g,t[27]=_);let v;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(YD,{}),t[28]=v):v=t[28];let y;return t[29]!==p||t[30]!==_?(y=q(ns,{children:J(W,{flexDirection:`column`,width:`100%`,height:p,children:[_,v]})}),t[29]=p,t[30]=_,t[31]=y):y=t[31],y};function pO(e){return e.screen}function mO(e){return e.setScreen}function hO(e){return e.navigateTo}function gO(e){return e+1}const _O=()=>{let e=Pa();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`},vO=()=>new Promise(e=>{Ea(_O(),()=>e())}),yO=e=>C(kE(H(function*(){let t=yield*sb,n=yield*cb,i=yield*GC,a=Date.now();yield*i.capture(`session:started`,{mode:`headless`,skip_planning:!1,browser_headed:e.headed}),console.log(`expect v${Jo}`),console.log(`Testing ${Bs(e.changesFor)}`),console.log(`Starting browser test...`);let o=Date.now();yield*i.capture(`run:started`,{plan_id:`direct`});let s=new Set,c=yield*t.execute({changesFor:e.changesFor,instruction:e.instruction,isHeadless:!e.headed,requiresCookies:!1}).pipe(_i(e=>F(()=>{for(let t of e.events)if(!s.has(t.id))switch(s.add(t.id),t._tag){case`RunStarted`:console.log(`Starting ${t.plan.title}`);break;case`StepStarted`:console.log(`${Y.arrowRight} ${t.stepId} ${t.title}`);break;case`StepCompleted`:console.log(` ${Y.tick} ${t.stepId} ${t.summary}`);break;case`StepFailed`:console.log(` ${Y.cross} ${t.stepId} ${t.message}`);break}})),r,U(t=>t._tag===`Some`?t.value:new _c({id:``,changesFor:e.changesFor,currentBranch:``,diffPreview:``,fileStats:[],instruction:e.instruction,baseUrl:void 0,isHeadless:!e.headed,requiresCookies:!1,title:e.instruction,rationale:`Direct execution`,steps:[],events:[]}))),l=yield*n.report(c),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*i.capture(`run:completed`,{plan_id:c.id??`direct`,passed:u,failed:d,step_count:c.steps.length,file_count:0,duration_ms:Date.now()-o}),yield*i.capture(`session:ended`,{session_ms:Date.now()-a}),yield*i.flush,console.error(`\n${l.toPlainText}`),yield*Qn(()=>vO()),process.exit(l.status===`passed`?0:1)}).pipe(dn(EE({verbose:e.verbose,agent:e.agent}))))),bO={error:ga.red,warn:ga.yellow,info:ga.cyan,success:ga.green,dim:ga.dim},xO={error:(...e)=>{console.log(bO.error(e.join(` `)))},warn:(...e)=>{console.log(bO.warn(e.join(` `)))},info:(...e)=>{console.log(bO.info(e.join(` `)))},success:(...e)=>{console.log(bO.success(e.join(` `)))},dim:(...e)=>{console.log(bO.dim(e.join(` `)))},log:(...e)=>{console.log(e.join(` `))},break:()=>{console.log(``)}},SO=()=>{xO.break(),xO.log(`Cancelled.`),xO.break(),process.exit(0)},CO=e=>po(e,{onCancel:SO}),wO=(e,t)=>mo({text:e,isSilent:t?.silent}),TO=[`CI`,`CLAUDECODE`,`CURSOR_AGENT`,`CODEX_CI`,`OPENCODE`,`AMP_HOME`,`AMI`],EO=()=>TO.some(e=>!!process.env[e]),DO=()=>!process.stdin.isTTY,OO={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`},kO=`npx skills add https://github.com/millionco/expect --skill expect-cli`,AO=()=>{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`},jO=e=>e||EO()||DO(),MO=e=>{try{return Oa(e,{stdio:`pipe`}),!0}catch{return!1}},NO=async(e={})=>{let t=jO(e.yes??!1),n=OO[AO()];xO.break(),xO.log(` ${bO.info(`expect`)} ${bO.dim(`— AI-powered browser testing`)}`),xO.break(),sf().length===0&&(xO.error(`No supported coding agent found. expect requires one of: Claude Code, Codex, or Cursor.`),xO.break(),xO.log(` Install one to get started:`),xO.log(` ${bO.info(`Claude Code`)} ${bO.dim(`https://docs.anthropic.com/en/docs/claude-code`)}`),xO.log(` ${bO.info(`Codex`)} ${bO.dim(`https://github.com/openai/codex`)}`),xO.log(` ${bO.info(`Cursor`)} ${bO.dim(`https://cursor.com`)}`),xO.break(),process.exit(1));let r=wO(`Installing expect-cli globally...`).start();MO(n)?r.succeed(`Installed! You can now run ${bO.info(`expect-cli`)} from anywhere.`):(r.fail(`Failed to install globally.`),xO.dim(` Run manually: ${bO.info(n)}`)),xO.break();let i=t;if(t||(i=(await CO({type:`confirm`,name:`installSkill`,message:`Install the ${bO.info(`expect`)} skill for your coding agent?`,initial:!0})).installSkill),i){let e=wO(`Installing skill...`).start();MO(kO)?e.succeed(`Skill installed.`):(e.fail(`Failed to install skill.`),xO.dim(` Run manually: ${bO.info(kO)}`))}xO.break(),xO.success(`You're all set!`),xO.log(` Run ${bO.info(`expect-cli`)} in any project to start testing.`),xO.break()},PO=[`packages/*`,`apps/*`],FO=e=>Zo.some(t=>e.includes(t)),IO=qt(`detectAgent`)(function*(e){let t=yield*qe;for(let[n,r]of Object.entries(Qo)){let i=_a.join(e,n);if(yield*t.exists(i).pipe(_(`PlatformError`,()=>V(!1))))return r}let n=_a.join(e,`package.json`),r=yield*t.readFileString(n).pipe(_(`PlatformError`,()=>V(``)));if(r){let e=yield*Ut({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})}).pipe(_(`JsonParseError`,()=>V(void 0)));if(e?.packageManager){let t=e.packageManager.split(`@`)[0];if(t)return t}}return`npm`}),LO=qt(`readPackageJson`)(function*(e){let t=yield*qe,n=_a.join(e,`package.json`),r=yield*t.readFileString(n);return yield*Ut({try:()=>JSON.parse(r),catch:()=>({_tag:`JsonParseError`})})}),RO=qt(`listWorkspaceDirectories`)(function*(e){let t=yield*qe,n=[];for(let r of PO){let i=_a.join(e,_a.dirname(r)),a=yield*t.readDirectory(i).pipe(_(`PlatformError`,()=>V([])));for(let e of a){let r=_a.join(i,e);(yield*t.stat(r).pipe(_(`PlatformError`,()=>V(void 0))))?.type===`Directory`&&n.push(r)}}return n}),zO=(e,t,n)=>new Promise(r=>{Da(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})})}),BO=qt(`discoverPackages`)(function*(e){let t=yield*RO(e),n=[];for(let e of t){let t=yield*LO(e).pipe(_(`PlatformError`,()=>V(void 0)),_(`JsonParseError`,()=>V(void 0)));if(!t?.scripts)continue;let r=Object.keys(t.scripts).filter(FO);r.length!==0&&n.push({packageName:t.name??_a.basename(e),directory:e,scripts:r})}return n}),VO=async(e,t)=>C(H(function*(){let n=yield*IO(e);return yield*st(yield*BO(e),e=>H(function*(){t.onPackageStart(e.packageName,e.scripts);let r=[];for(let i of e.scripts){let a=yield*Qn(()=>zO(n,e.directory,i));t.onScriptDone(e.packageName,a),r.push(a)}return{packageName:e.packageName,directory:e.directory,results:r}}),{concurrency:4})}).pipe(dn(Ra.layer))),HO=e=>{let t=ca(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=q(G,{bold:!0,children:`expect audit`}),a=q(G,{children:` `}),t[3]=i,t[4]=a):(i=t[3],a=t[4]),r=J(W,{flexDirection:`column`,paddingY:1,children:[i,a,e.map(XO)]}),t[1]=n,t[2]=r}else r=t[2];return r},UO=e=>{let t=ca(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=q(G,{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&&J(G,{color:`yellow`,children:[`Run `,q(G,{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&&J(G,{color:`green`,children:[`Looking good! Run `,q(G,{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=J(W,{flexDirection:`column`,gap:1,children:[s,c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u},WO=async()=>{let e=process.cwd(),t={current:new Map},n,r,i=ta(q(()=>{let[e,t]=K(new Map),[i,a]=K();return n=e=>t(new Map(e)),r=a,J(W,{flexDirection:`column`,children:[q(HO,{statusMap:e}),i&&q(UO,{results:i})]})},{})),a=await VO(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)},GO=async()=>{let e=process.cwd();console.log(``),console.log(ga.bold(`expect audit`)),console.log(``);let t=await VO(e,{onPackageStart:(e,t)=>{console.log(`${Y.arrowRight} ${ga.bold(e)} (${t.join(`, `)})`)},onScriptDone:(e,t)=>{let n=t.passed?ga.green(Y.tick):ga.red(Y.cross);if(console.log(` ${n} ${t.script}`),!t.passed){let e=t.output.split(`
45
+ `).slice(-3).join(`
46
+ `);console.log(ga.dim(` ${e.split(`
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?ga.red:ga.green;console.log(a(ga.bold(i))),r>0?(console.log(``),console.log(ga.yellow(`Run ${ga.bold(`expect`)} to test your changes in a real browser and catch issues before they ship.`))):(console.log(``),console.log(ga.green(`Looking good! Run ${ga.bold(`expect`)} to verify your changes work end-to-end in the browser.`))),console.log(``),r>0&&process.exit(1)},KO=async()=>{EO()||DO()?await GO():await WO()};function qO(e){return e.passed}function JO(e){return J(W,{flexDirection:`column`,children:[J(G,{children:[` `,e.passed?q(G,{color:`green`,children:Y.tick}):q(G,{color:`red`,children:Y.cross}),` `,e.script]}),!e.passed&&J(G,{color:`gray`,children:[` `,e.output.split(`
49
+ `).slice(-3).join(`
50
+ `)]})]},e.script)}function YO(e){return J(G,{color:`gray`,children:[` `,q(Ga,{type:`dots`}),` `,e]},e)}function XO(e){let[t,n]=e;return J(W,{flexDirection:`column`,children:[J(W,{children:[n.done&&q(G,{children:n.completed.every(qO)?q(G,{color:`green`,children:Y.tick}):q(G,{color:`red`,children:Y.cross})}),!n.done&&q(G,{color:`white`,children:q(Ga,{type:`dots`})}),J(G,{bold:!0,children:[` `,t]})]}),n.completed.map(JO),!n.done&&n.scripts.filter(e=>!n.completed.some(t=>t.script===e)).slice(0,1).map(YO)]},t)}const ZO=[`unstaged`,`branch`,`changes`],QO=new $i().name(`expect`).description(`AI-powered browser testing for your changes`).version(Jo,`-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`,`
60
51
  Examples:
61
52
  $ expect open interactive TUI
62
53
  $ expect -m "test the login flow" -y run immediately
54
+ $ expect --headed -m "smoke test" -y run with a visible browser
63
55
  $ expect --target branch test all branch changes
64
- $ expect --target unstaged test unstaged changes`),gK=async e=>{let t=Date.now();await fK();let n=!1;process.on(`SIGINT`,()=>{n=!0}),process.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`),process.on(`exit`,()=>process.stdout.write(`\x1B[?1049l`));let r=a(x(xe,{initialValues:[[WW,B(e)]],children:x(l,{client:fz,children:x(WG,{agent:e})})}));HG(r),await r.waitUntilExit(),await pK(t),n||await XG(),process.exit(0)},_K=async e=>{let t=process.cwd();return bm(gp(function*(){let t=yield*MR,n=yield*t.getMainBranch,r=yield*t.getCurrentBranch;return e===`branch`?{changesFor:ZT.makeUnsafe({_tag:`Branch`,mainBranch:n}),currentBranch:r}:e===`changes`?{changesFor:ZT.makeUnsafe({_tag:`Changes`,mainBranch:n}),currentBranch:r}:{changesFor:ZT.makeUnsafe({_tag:`WorkingTree`}),currentBranch:r}}).pipe(Kp(MR.withRepoRoot(t))))},vK=(e,t)=>{NB.setState({...e.agent?{agentBackend:e.agent}:{}}),e.message?dz.setState({screen:uz.Testing({changesFor:t,instruction:e.message})}):dz.setState({screen:uz.Main()})},yK=async(e,t)=>{let{changesFor:n}=await _K(e);return ZG({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})},bK=async(e,t)=>{let{changesFor:n}=await _K(e);vK(t,n),gK(t.agent??`claude`)};hK.command(`init`).description(`set up expect for your coding agent`).option(`-y, --yes`,`skip confirmation prompts`).action(async e=>{await uK(e)}),hK.action(async()=>{let e=hK.opts(),t=e.target??`changes`;if(mK.includes(t)||hK.error(`Unknown target: ${t}. Use ${mK.join(`, `)}.`),iK()||aK())return yK(t,e);e.message||e.flow||e.yes||e.target?await bK(t,e):gK(e.agent??`claude`)}),hK.parse();export{};
56
+ $ expect --target unstaged test unstaged changes`),$O=`\x1B[?1000l\x1B[?1006l`,ek=async e=>{let t=Date.now();await XC(),process.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`),process.on(`exit`,()=>process.stdout.write($O+Yo));let n=ta(q(to,{initialValues:[[DE,A(e)]],children:q(aa,{client:Gb,children:q(fO,{agent:e})})}));uO(n),await n.waitUntilExit(),await ZC(t),process.stdout.write($O+Yo),process.exit(0)},tk=async e=>{let t=process.cwd();return C(H(function*(){let t=yield*ab,n=yield*t.getMainBranch,r=yield*t.getCurrentBranch;return e===`branch`?{changesFor:zs.makeUnsafe({_tag:`Branch`,mainBranch:n}),currentBranch:r}:e===`changes`?{changesFor:zs.makeUnsafe({_tag:`Changes`,mainBranch:n}),currentBranch:r}:{changesFor:zs.makeUnsafe({_tag:`WorkingTree`}),currentBranch:r}}).pipe(dn(ab.withRepoRoot(t))))},nk=(e,t)=>{qC.setState({...e.agent?{agentBackend:e.agent}:{},browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),e.message?Wb.setState({screen:Hb.Testing({changesFor:t,instruction:e.message})}):Wb.setState({screen:Hb.Main()})},rk=async(e,t)=>{let{changesFor:n}=await tk(e);return yO({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})},ik=async(e,t)=>{let{changesFor:n}=await tk(e);nk(t,n),ek(t.agent??`claude`)};QO.command(`init`).description(`set up expect for your coding agent`).option(`-y, --yes`,`skip confirmation prompts`).action(async e=>{await NO(e)}),QO.command(`audit`).description(`audit your workspace for lint, type, and formatting issues`).action(async()=>{await KO()}),QO.action(async()=>{let e=QO.opts(),t=e.target??`changes`;if(ZO.includes(t)||QO.error(`Unknown target: ${t}. Use ${ZO.join(`, `)}.`),EO()||DO())return rk(t,e);e.message||e.flow||e.yes?await ik(t,e):(qC.setState({browserHeaded:e.headed??!1,replayHost:e.replayHost??`https://expect.dev`}),ek(e.agent??`claude`))}),QO.parse();export{};
65
57
  //# sourceMappingURL=index.js.map